@fluidframework/map 2.74.0-370705 → 2.80.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"mapKernel.d.ts","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAGpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EACX,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAEhB,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,yBAAyB,CAAC;AAiCjC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAExF;;;;;;;GAOG;AAEH,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAE5E;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAsCxE;;GAEG;AACH,qBAAa,SAAS;IAsCpB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAzC9B;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAGxB;IAED;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsD;IAEtF;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA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AAE,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,GAC1E,IAAI;IAWP;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAiBtC;IAEF;;OAEG;IACI,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAKnD;;;;OAIG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACI,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAyD7C;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IA2CnC;;OAEG;IACI,KAAK,IAAI,IAAI;IA4CpB;;;;OAIG;IACI,oBAAoB,CAAC,UAAU,EAAE,gBAAgB,GAAG,wBAAwB;IAQnF;;;OAGG;IACI,wBAAwB,CAAC,IAAI,EAAE,0BAA0B,GAAG,IAAI;IASvE;;;;;;;OAOG;IACI,kBAAkB,CAAC,EAAE,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,GAAG,OAAO;IASxE,iBAAiB,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAqBjD;;;;;;;;;;;;;;OAcG;IACI,iBAAiB,CACvB,EAAE,EAAE,aAAa,EACjB,KAAK,EAAE,OAAO,EACd,eAAe,EAAE,OAAO,GACtB,OAAO;IASV;;;;OAIG;IACI,QAAQ,CAAC,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,GAAG,IAAI;IAgE5D;;;OAGG;IACH,OAAO,CAAC,kBAAkB;CAiJ1B"}
package/dist/mapKernel.js CHANGED
@@ -326,10 +326,25 @@ class MapKernel {
326
326
  */
327
327
  clear() {
328
328
  if (!this.isAttached()) {
329
+ // Collect keys to delete before clearing
330
+ // eslint-disable-next-line @typescript-eslint/no-shadow
331
+ const keysToDelete = [];
332
+ for (const [key, value] of this.sequencedData) {
333
+ keysToDelete.push({ key, previousValue: value.value });
334
+ }
329
335
  this.sequencedData.clear();
330
336
  this.eventEmitter.emit("clear", true, this.eventEmitter);
337
+ // Emit delete-like valueChanged events for keys that were removed
338
+ for (const { key, previousValue } of keysToDelete) {
339
+ this.eventEmitter.emit("valueChanged", { key, previousValue }, true, this.eventEmitter);
340
+ }
331
341
  return;
332
342
  }
343
+ // Collect keys that will be deleted (those without pending ops that supersede the clear)
344
+ const keysToDelete = [];
345
+ for (const [key, value] of this.internalIterator()) {
346
+ keysToDelete.push({ key, previousValue: value.value });
347
+ }
333
348
  const pendingClear = {
334
349
  type: "clear",
335
350
  };
@@ -339,6 +354,10 @@ class MapKernel {
339
354
  };
340
355
  this.submitMessage(op, pendingClear);
341
356
  this.eventEmitter.emit("clear", true, this.eventEmitter);
357
+ // Emit delete-like valueChanged events for keys that were removed
358
+ for (const { key, previousValue } of keysToDelete) {
359
+ this.eventEmitter.emit("valueChanged", { key, previousValue }, true, this.eventEmitter);
360
+ }
342
361
  }
343
362
  /**
344
363
  * Serializes the data stored in the shared map to a JSON string
@@ -472,18 +491,33 @@ class MapKernel {
472
491
  const messageHandlers = new Map();
473
492
  messageHandlers.set("clear", {
474
493
  process: (op, local, localOpMetadata) => {
475
- this.sequencedData.clear();
476
494
  if (local) {
495
+ this.sequencedData.clear();
477
496
  const pendingClear = this.pendingData.shift();
478
497
  (0, internal_1.assert)(pendingClear !== undefined &&
479
498
  pendingClear.type === "clear" &&
480
499
  pendingClear === localOpMetadata, 0xbf6 /* Got a local clear message we weren't expecting */);
481
500
  }
482
501
  else {
502
+ const keysToDelete = [];
503
+ for (const [key, value] of this.sequencedData) {
504
+ // Check if this key has pending local operations that supersede the remote op
505
+ const hasPendingOps = this.pendingData.some((entry) => (entry.type === "delete" && entry.key === key) ||
506
+ (entry.type === "lifetime" && entry.key === key));
507
+ // Only collect keys without pending operations (i.e., actually deleted)
508
+ if (!hasPendingOps) {
509
+ keysToDelete.push({ key, previousValue: value.value });
510
+ }
511
+ }
512
+ this.sequencedData.clear();
483
513
  // Only emit for remote ops, we would have already emitted for local ops. Only emit if there
484
514
  // is no optimistically-applied local pending clear that would supersede this remote clear.
485
515
  if (!this.pendingData.some((entry) => entry.type === "clear")) {
486
516
  this.eventEmitter.emit("clear", local, this.eventEmitter);
517
+ // Emit delete-like valueChanged events for keys that were removed
518
+ for (const { key, previousValue } of keysToDelete) {
519
+ this.eventEmitter.emit("valueChanged", { key, previousValue }, local, this.eventEmitter);
520
+ }
487
521
  }
488
522
  }
489
523
  },
@@ -1 +1 @@
1
- {"version":3,"file":"mapKernel.js","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA8E;AAE9E,0EAAwE;AAWxE,qDAI0B;AAC1B,yCAAqD;AAoFrD;;GAEG;AACH,MAAa,SAAS;IACrB;;OAEG;IACH,IAAW,IAAI;QACd,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACnD,OAAO,aAAa,CAAC,MAAM,CAAC;IAC7B,CAAC;IAqBD;;;;;;;;OAQG;IACH,YACkB,UAA4B,EAC5B,MAAoB,EACpB,aAA8D,EAC9D,UAAyB,EACzB,YAAiD;QAJjD,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAAiD;QAC9D,eAAU,GAAV,UAAU,CAAe;QACzB,iBAAY,GAAZ,YAAY,CAAqC;QAjCnE;;WAEG;QACc,oBAAe,GAA4C,IAAI,GAAG,EAAE,CAAC;QAEtF;;;WAGG;QACc,kBAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;QAChE;;;;;;WAMG;QACc,gBAAW,GAAuB,EAAE,CAAC;QAqBtD;;;;;;;;;;;;;;;WAeG;QACc,qBAAgB,GAAG,GAA4C,EAAE;YACjF,yGAAyG;YACzG,yGAAyG;YACzG,yGAAyG;YACzG,kFAAkF;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AC,CAAC;oBAExC,sGAAsG;oBACtG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;wBACpF,IAAI,CAAC,YAAY,CAAC,IAAI,CACrB,cAAc,EACd,EAAE,GAAG,EAAE,aAAa,EAAE,EACtB,KAAK,EACL,IAAI,CAAC,YAAY,CACjB,CAAC;oBACH,CAAC;gBACF,CAAC;YACF,CAAC;YACD,QAAQ,EAAE,CAAC,EAAoB,EAAE,eAAuC,EAAE,EAAE;gBAC3E,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YACzC,CAAC;SACD,CAAC,CAAC;QAEH,OAAO,eAAe,CAAC;IACxB,CAAC;CACD;AA/qBD,8BA+qBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { ValueType } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedMapEvents } from \"./interfaces.js\";\nimport type {\n\tIMapClearOperation,\n\tIMapDeleteOperation,\n\tIMapSetOperation,\n\t// eslint-disable-next-line import-x/no-deprecated\n\tISerializableValue,\n\tISerializedValue,\n} from \"./internalInterfaces.js\";\nimport {\n\ttype ILocalValue,\n\tserializeValue,\n\tmigrateIfSharedSerializable,\n} from \"./localValues.js\";\nimport { findLast, findLastIndex } from \"./utils.js\";\n\n/**\n * Defines the means to process and resubmit a given op on a map.\n */\ninterface IMapMessageHandler {\n\t/**\n\t * Apply the given operation.\n\t * @param op - The map operation to apply\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprocess(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t): void;\n\n\t/**\n\t * Resubmit a previously submitted operation that was not delivered.\n\t * @param op - The map operation to resubmit\n\t * @param localOpMetadata - The metadata that was originally submitted with the message.\n\t */\n\tresubmit(op: IMapOperation, localOpMetadata: PendingLocalOpMetadata): void;\n}\n\n/**\n * Union of all possible map operations.\n */\nexport type IMapOperation = IMapSetOperation | IMapDeleteOperation | IMapClearOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n *\n * @remarks Directly used in\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n * | JSON.stringify}, direct result from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.\n */\n// eslint-disable-next-line import-x/no-deprecated\nexport type IMapDataObjectSerializable = Record<string, ISerializableValue>;\n\n/**\n * Serialized key/value data.\n */\nexport type IMapDataObjectSerialized = Record<string, ISerializedValue>;\n\ninterface PendingKeySet {\n\ttype: \"set\";\n\tvalue: ILocalValue;\n}\n\ninterface PendingKeyDelete {\n\ttype: \"delete\";\n\tkey: string;\n}\n\ninterface PendingClear {\n\ttype: \"clear\";\n}\n\ninterface PendingKeyLifetime {\n\ttype: \"lifetime\";\n\tkey: string;\n\t/**\n\t * A non-empty array of pending key sets that occurred during this lifetime. If the list\n\t * becomes empty (e.g. during processing or rollback), the lifetime no longer exists and\n\t * must be removed from the pending data.\n\t */\n\tkeySets: PendingKeySet[];\n}\n\n/**\n * A member of the pendingData array, which tracks outstanding changes and can be used to\n * compute optimistic values. Local sets are aggregated into lifetimes.\n */\ntype PendingDataEntry = PendingKeyLifetime | PendingKeyDelete | PendingClear;\n/**\n * An individual outstanding change, which will also be found in the pendingData array\n * (though the PendingKeySets will be contained within a PendingKeyLifetime there).\n */\ntype PendingLocalOpMetadata = PendingKeySet | PendingKeyDelete | PendingClear;\n\n/**\n * A SharedMap is a map-like distributed data structure.\n */\nexport class MapKernel {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\tconst iterableItems = [...this.internalIterator()];\n\t\treturn iterableItems.length;\n\t}\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n\t/**\n\t * The data the map is storing, but only including sequenced values (no local pending\n\t * modifications are included).\n\t */\n\tprivate readonly sequencedData = new Map<string, ILocalValue>();\n\t/**\n\t * A data structure containing all local pending modifications, which is used in combination\n\t * with the sequencedData to compute optimistic values.\n\t *\n\t * Pending sets are aggregated into \"lifetimes\", which permit correct relative iteration order\n\t * even across remote operations and rollbacks.\n\t */\n\tprivate readonly pendingData: PendingDataEntry[] = [];\n\n\t/**\n\t * Create a new shared map kernel.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param isAttached - To query whether the shared object should generate ops\n\t * @param valueTypes - The value types to register\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tpublic constructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (op: unknown, localOpMetadata: unknown) => void,\n\t\tprivate readonly isAttached: () => boolean,\n\t\tprivate readonly eventEmitter: TypedEventEmitter<ISharedMapEvents>,\n\t) {\n\t\tthis.messageHandlers = this.getMessageHandlers();\n\t}\n\n\t/**\n\t * Get an iterator over the optimistically observable ILocalValue entries in the map. For example, excluding\n\t * sequenced entries that have pending deletes/clears.\n\t *\n\t * @remarks\n\t * There is no perfect solution here, particularly when the iterator is retained over time and the map is\n\t * modified or new ack's are received. The pendingData portion of the iteration is the most susceptible to\n\t * this problem. The implementation prioritizes (in roughly this order):\n\t * 1. Correct immediate iteration (i.e. when the map is not modified before iteration completes)\n\t * 2. Consistent iteration order before/after sequencing of pending ops; acks don't change order\n\t * 3. Consistent iteration order between synchronized clients, even if they each modified the map concurrently\n\t * 4. Remaining as close as possible to the native Map iterator behavior, e.g. live-ish view rather than snapshot\n\t *\n\t * For this reason, it's important not to internally snapshot the output of the iterator for any purpose that\n\t * does not immediately (synchronously) consume that output and dispose of it.\n\t */\n\tprivate readonly internalIterator = (): IterableIterator<[string, ILocalValue]> => {\n\t\t// We perform iteration in two steps - first by iterating over members of the sequenced data that are not\n\t\t// optimistically deleted or cleared, and then over the pending data lifetimes that have not subsequently\n\t\t// been deleted or cleared. In total, this give an ordering of members based on when they were initially\n\t\t// added to the map (even if they were later modified), similar to the native Map.\n\t\tconst sequencedDataIterator = this.sequencedData.keys();\n\t\tconst pendingDataIterator = this.pendingData.values();\n\t\tconst next = (): IteratorResult<[string, ILocalValue]> => {\n\t\t\tlet nextSequencedKey = sequencedDataIterator.next();\n\t\t\twhile (!nextSequencedKey.done) {\n\t\t\t\tconst key = nextSequencedKey.value;\n\t\t\t\t// If we have any pending deletes or clears, then we won't iterate to this key yet (if at all).\n\t\t\t\t// Either it is optimistically deleted and will not be part of the iteration, or it was\n\t\t\t\t// re-added later and we'll iterate to it when we get to the pending data.\n\t\t\t\tif (\n\t\t\t\t\t!this.pendingData.some(\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.type === \"clear\" || (entry.type === \"delete\" && entry.key === key),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst optimisticValue = this.getOptimisticLocalValue(key);\n\t\t\t\t\tassert(\n\t\t\t\t\t\toptimisticValue !== undefined,\n\t\t\t\t\t\t0xbf1 /* Should never iterate to a key with undefined optimisticValue */,\n\t\t\t\t\t);\n\t\t\t\t\treturn { value: [key, optimisticValue], done: false };\n\t\t\t\t}\n\t\t\t\tnextSequencedKey = sequencedDataIterator.next();\n\t\t\t}\n\n\t\t\tlet nextPending = pendingDataIterator.next();\n\t\t\twhile (!nextPending.done) {\n\t\t\t\tconst nextPendingEntry = nextPending.value;\n\t\t\t\t// A lifetime entry may need to be iterated.\n\t\t\t\tif (nextPendingEntry.type === \"lifetime\") {\n\t\t\t\t\tconst nextPendingEntryIndex = this.pendingData.indexOf(nextPendingEntry);\n\t\t\t\t\tconst mostRecentDeleteOrClearIndex = findLastIndex(\n\t\t\t\t\t\tthis.pendingData,\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.type === \"clear\" ||\n\t\t\t\t\t\t\t(entry.type === \"delete\" && entry.key === nextPendingEntry.key),\n\t\t\t\t\t);\n\t\t\t\t\t// Only iterate the pending entry now if it hasn't been deleted or cleared.\n\t\t\t\t\tif (nextPendingEntryIndex > mostRecentDeleteOrClearIndex) {\n\t\t\t\t\t\tconst latestPendingValue =\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tnextPendingEntry.keySets[nextPendingEntry.keySets.length - 1]!;\n\t\t\t\t\t\t// Skip iterating if we would have would have already iterated it as part of the sequenced data.\n\t\t\t\t\t\t// This is not a perfect check in the case the map has changed since the iterator was created\n\t\t\t\t\t\t// (e.g. if a remote client added the same key in the meantime).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!this.sequencedData.has(nextPendingEntry.key) ||\n\t\t\t\t\t\t\tmostRecentDeleteOrClearIndex !== -1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn { value: [nextPendingEntry.key, latestPendingValue.value], done: false };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnextPending = pendingDataIterator.next();\n\t\t\t}\n\n\t\t\treturn { value: undefined, done: true };\n\t\t};\n\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<[string, ILocalValue]> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t};\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic entries(): IterableIterator<[string, unknown]> {\n\t\tconst internalIterator = this.internalIterator();\n\t\tconst next = (): IteratorResult<[string, unknown]> => {\n\t\t\tconst nextResult = internalIterator.next();\n\t\t\tif (nextResult.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\t// Unpack the stored value\n\t\t\tconst [key, localValue] = nextResult.value;\n\t\t\treturn { value: [key, localValue.value], done: false };\n\t\t};\n\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<[string, unknown]> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\tconst internalIterator = this.internalIterator();\n\t\tconst next = (): IteratorResult<string> => {\n\t\t\tconst nextResult = internalIterator.next();\n\t\t\tif (nextResult.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\tconst [key] = nextResult.value;\n\t\t\treturn { value: key, done: false };\n\t\t};\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<string> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<unknown> {\n\t\tconst internalIterator = this.internalIterator();\n\t\tconst next = (): IteratorResult<unknown> => {\n\t\t\tconst nextResult = internalIterator.next();\n\t\t\tif (nextResult.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\tconst [, localValue] = nextResult.value;\n\t\t\treturn { value: localValue.value, done: false };\n\t\t};\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<unknown> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic [Symbol.iterator](): IterableIterator<[string, unknown]> {\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\tpublic forEach(\n\t\tcallbackFn: (value: unknown, key: string, map: Map<string, unknown>) => void,\n\t): void {\n\t\t// It would be better to iterate over the data without a temp map. However, we don't have a valid\n\t\t// map to pass for the third argument here (really, it should probably should be a reference to the\n\t\t// SharedMap and not the MapKernel).\n\t\tconst tempMap = new Map(this.internalIterator());\n\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\ttempMap.forEach((localValue, key, m) => {\n\t\t\tcallbackFn(localValue.value, key, m);\n\t\t});\n\t}\n\n\t/**\n\t * Compute the optimistic local value for a given key. This combines the sequenced data with\n\t * any pending changes that have not yet been sequenced.\n\t */\n\tprivate readonly getOptimisticLocalValue = (key: string): ILocalValue | undefined => {\n\t\tconst latestPendingEntry = findLast(\n\t\t\tthis.pendingData,\n\t\t\t(entry) => entry.type === \"clear\" || entry.key === key,\n\t\t);\n\n\t\tif (latestPendingEntry === undefined) {\n\t\t\treturn this.sequencedData.get(key);\n\t\t} else if (latestPendingEntry.type === \"lifetime\") {\n\t\t\tconst latestPendingSet =\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tlatestPendingEntry.keySets[latestPendingEntry.keySets.length - 1]!;\n\t\t\treturn latestPendingSet.value;\n\t\t} else {\n\t\t\t// Delete or clear\n\t\t\treturn undefined;\n\t\t}\n\t};\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get<T = unknown>(key: string): T | undefined {\n\t\tconst localValue = this.getOptimisticLocalValue(key);\n\t\treturn localValue === undefined ? undefined : (localValue.value as T);\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.getOptimisticLocalValue(key) !== undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.set}\n\t */\n\tpublic set(key: string, value: unknown): void {\n\t\t// Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.\n\t\tif (key === undefined || key === null) {\n\t\t\tthrow new Error(\"Undefined and null keys are not supported\");\n\t\t}\n\n\t\tconst localValue: ILocalValue = { value };\n\t\tconst previousOptimisticLocalValue = this.getOptimisticLocalValue(key);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\tthis.sequencedData.set(key, localValue);\n\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\"valueChanged\",\n\t\t\t\t{ key, previousValue: previousOptimisticLocalValue?.value },\n\t\t\t\ttrue,\n\t\t\t\tthis.eventEmitter,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// A new pending key lifetime is created if:\n\t\t// 1. There isn't any pending entry for the key yet\n\t\t// 2. The most recent pending entry for the key was a deletion (as this terminates the prior lifetime)\n\t\t// 3. A clear was sent after the last pending entry for the key (which also terminates the prior lifetime)\n\t\tlet latestPendingEntry = findLast(\n\t\t\tthis.pendingData,\n\t\t\t(entry) => entry.type === \"clear\" || entry.key === key,\n\t\t);\n\t\tif (\n\t\t\tlatestPendingEntry === undefined ||\n\t\t\tlatestPendingEntry.type === \"delete\" ||\n\t\t\tlatestPendingEntry.type === \"clear\"\n\t\t) {\n\t\t\tlatestPendingEntry = { type: \"lifetime\", key, keySets: [] };\n\t\t\tthis.pendingData.push(latestPendingEntry);\n\t\t}\n\t\tconst pendingKeySet: PendingKeySet = {\n\t\t\ttype: \"set\",\n\t\t\tvalue: localValue,\n\t\t};\n\t\tlatestPendingEntry.keySets.push(pendingKeySet);\n\n\t\tconst op: IMapSetOperation = {\n\t\t\tkey,\n\t\t\ttype: \"set\",\n\t\t\tvalue: { type: ValueType[ValueType.Plain], value: localValue.value },\n\t\t};\n\t\tthis.submitMessage(op, pendingKeySet);\n\t\tthis.eventEmitter.emit(\n\t\t\t\"valueChanged\",\n\t\t\t{ key, previousValue: previousOptimisticLocalValue?.value },\n\t\t\ttrue,\n\t\t\tthis.eventEmitter,\n\t\t);\n\t}\n\n\t/**\n\t * Delete a key from the map.\n\t * @param key - Key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\tconst previousOptimisticLocalValue = this.getOptimisticLocalValue(key);\n\n\t\tif (!this.isAttached()) {\n\t\t\tconst successfullyRemoved = this.sequencedData.delete(key);\n\t\t\t// Only emit if we actually deleted something.\n\t\t\tif (previousOptimisticLocalValue !== undefined) {\n\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t{ key, previousValue: previousOptimisticLocalValue.value },\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn successfullyRemoved;\n\t\t}\n\n\t\tconst pendingKeyDelete: PendingKeyDelete = {\n\t\t\ttype: \"delete\",\n\t\t\tkey,\n\t\t};\n\t\tthis.pendingData.push(pendingKeyDelete);\n\n\t\tconst op: IMapDeleteOperation = {\n\t\t\tkey,\n\t\t\ttype: \"delete\",\n\t\t};\n\t\tthis.submitMessage(op, pendingKeyDelete);\n\t\t// Only emit if we locally believe we deleted something. Otherwise we still send the op\n\t\t// (permitting speculative deletion even if we don't see anything locally) but don't emit\n\t\t// a valueChanged since we in fact did not locally observe a value change.\n\t\tif (previousOptimisticLocalValue !== undefined) {\n\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\"valueChanged\",\n\t\t\t\t{ key, previousValue: previousOptimisticLocalValue.value },\n\t\t\t\ttrue,\n\t\t\t\tthis.eventEmitter,\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Clear all data from the map.\n\t */\n\tpublic clear(): void {\n\t\tif (!this.isAttached()) {\n\t\t\tthis.sequencedData.clear();\n\t\t\tthis.eventEmitter.emit(\"clear\", true, this.eventEmitter);\n\t\t\treturn;\n\t\t}\n\n\t\tconst pendingClear: PendingClear = {\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.pendingData.push(pendingClear);\n\n\t\tconst op: IMapClearOperation = {\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.submitMessage(op, pendingClear);\n\t\tthis.eventEmitter.emit(\"clear\", true, this.eventEmitter);\n\t}\n\n\t/**\n\t * Serializes the data stored in the shared map to a JSON string\n\t * @param serializer - The serializer to use to serialize handles in its values.\n\t * @returns A JSON string containing serialized map data\n\t */\n\tpublic getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n\t\tconst serializedMapData: IMapDataObjectSerialized = {};\n\t\tfor (const [key, localValue] of this.sequencedData.entries()) {\n\t\t\tserializedMapData[key] = serializeValue(localValue.value, serializer, this.handle);\n\t\t}\n\t\treturn serializedMapData;\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t * @param data - A JSON string containing serialized map data\n\t */\n\tpublic populateFromSerializable(json: IMapDataObjectSerializable): void {\n\t\tfor (const [key, serializable] of Object.entries(\n\t\t\tthis.serializer.decode(json) as IMapDataObjectSerializable,\n\t\t)) {\n\t\t\tmigrateIfSharedSerializable(serializable, this.serializer, this.handle);\n\t\t\tthis.sequencedData.set(key, { value: serializable.value });\n\t\t}\n\t}\n\n\t/**\n\t * Resubmit the given op if a handler is registered.\n\t * @param op - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(op: IMapOperation, localOpMetadata: unknown): boolean {\n\t\tconst handler = this.messageHandlers.get(op.type);\n\t\tif (handler === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\thandler.resubmit(op, localOpMetadata as PendingLocalOpMetadata);\n\t\treturn true;\n\t}\n\n\tpublic tryApplyStashedOp(op: IMapOperation): void {\n\t\tswitch (op.type) {\n\t\t\tcase \"clear\": {\n\t\t\t\tthis.clear();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthis.delete(op.key);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"set\": {\n\t\t\t\tmigrateIfSharedSerializable(op.value, this.serializer, this.handle);\n\t\t\t\tthis.set(op.key, op.value.value);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(op);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was recognized and thus processed, false otherwise.\n\t *\n\t * @remarks\n\t * When this returns false and the caller doesn't handle the op itself, then the op could be from a different version of this code.\n\t * In such a case, not applying the op would result in this client becoming out of sync with clients that do handle the op\n\t * and could result in data corruption or data loss as well.\n\t * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption\n\t * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.\n\t */\n\tpublic tryProcessMessage(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tconst handler = this.messageHandlers.get(op.type);\n\t\tif (handler === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\thandler.process(op, local, localOpMetadata as PendingLocalOpMetadata | undefined);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Rollback a local op\n\t * @param op - The operation to rollback\n\t * @param localOpMetadata - The local metadata associated with the op.\n\t */\n\tpublic rollback(op: unknown, localOpMetadata: unknown): void {\n\t\tconst mapOp: IMapOperation = op as IMapOperation;\n\t\tconst typedLocalOpMetadata = localOpMetadata as PendingLocalOpMetadata;\n\t\tif (mapOp.type === \"clear\") {\n\t\t\t// A pending clear will be last in the list, since it terminates all prior lifetimes.\n\t\t\tconst pendingClear = this.pendingData.pop();\n\t\t\tassert(\n\t\t\t\tpendingClear !== undefined &&\n\t\t\t\t\tpendingClear.type === \"clear\" &&\n\t\t\t\t\tpendingClear === typedLocalOpMetadata,\n\t\t\t\t0xbf2 /* Unexpected clear rollback */,\n\t\t\t);\n\t\t\tfor (const [key] of this.internalIterator()) {\n\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t{ key, previousValue: undefined },\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// A pending set/delete may not be last in the list, as the lifetimes' order is based on when\n\t\t\t// they were created, not when they were last modified.\n\t\t\tconst pendingEntryIndex = findLastIndex(\n\t\t\t\tthis.pendingData,\n\t\t\t\t(entry) => entry.type !== \"clear\" && entry.key === mapOp.key,\n\t\t\t);\n\t\t\tconst pendingEntry = this.pendingData[pendingEntryIndex];\n\t\t\tassert(\n\t\t\t\tpendingEntry !== undefined &&\n\t\t\t\t\t(pendingEntry.type === \"delete\" || pendingEntry.type === \"lifetime\"),\n\t\t\t\t0xbf3 /* Unexpected pending data for set/delete op */,\n\t\t\t);\n\t\t\tif (pendingEntry.type === \"delete\") {\n\t\t\t\tassert(pendingEntry === typedLocalOpMetadata, 0xbf4 /* Unexpected delete rollback */);\n\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\t\t\t\t// Only emit if rolling back the delete actually results in a value becoming visible.\n\t\t\t\tif (this.getOptimisticLocalValue(mapOp.key) !== undefined) {\n\t\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t\t{ key: mapOp.key, previousValue: undefined },\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (pendingEntry.type === \"lifetime\") {\n\t\t\t\tconst pendingKeySet = pendingEntry.keySets.pop();\n\t\t\t\tassert(\n\t\t\t\t\tpendingKeySet !== undefined && pendingKeySet === typedLocalOpMetadata,\n\t\t\t\t\t0xbf5 /* Unexpected set rollback */,\n\t\t\t\t);\n\t\t\t\tif (pendingEntry.keySets.length === 0) {\n\t\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\t\t\t\t}\n\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t{ key: mapOp.key, previousValue: pendingKeySet.value.value },\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get the message handlers for the map.\n\t * @returns A map of string op names to IMapMessageHandlers for those ops\n\t */\n\tprivate getMessageHandlers(): Map<string, IMapMessageHandler> {\n\t\tconst messageHandlers = new Map<string, IMapMessageHandler>();\n\t\tmessageHandlers.set(\"clear\", {\n\t\t\tprocess: (\n\t\t\t\top: IMapClearOperation,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t\t\t) => {\n\t\t\t\tthis.sequencedData.clear();\n\t\t\t\tif (local) {\n\t\t\t\t\tconst pendingClear = this.pendingData.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingClear !== undefined &&\n\t\t\t\t\t\t\tpendingClear.type === \"clear\" &&\n\t\t\t\t\t\t\tpendingClear === localOpMetadata,\n\t\t\t\t\t\t0xbf6 /* Got a local clear message we weren't expecting */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// Only emit for remote ops, we would have already emitted for local ops. Only emit if there\n\t\t\t\t\t// is no optimistically-applied local pending clear that would supersede this remote clear.\n\t\t\t\t\tif (!this.pendingData.some((entry) => entry.type === \"clear\")) {\n\t\t\t\t\t\tthis.eventEmitter.emit(\"clear\", local, this.eventEmitter);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tresubmit: (op: IMapClearOperation, localOpMetadata: PendingLocalOpMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t});\n\t\tmessageHandlers.set(\"delete\", {\n\t\t\tprocess: (\n\t\t\t\top: IMapDeleteOperation,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t\t\t) => {\n\t\t\t\tconst { key } = op;\n\n\t\t\t\tif (local) {\n\t\t\t\t\tconst pendingEntryIndex = this.pendingData.findIndex(\n\t\t\t\t\t\t(entry) => entry.type !== \"clear\" && entry.key === key,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingEntry = this.pendingData[pendingEntryIndex];\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingEntry !== undefined &&\n\t\t\t\t\t\t\tpendingEntry.type === \"delete\" &&\n\t\t\t\t\t\t\tpendingEntry === localOpMetadata,\n\t\t\t\t\t\t0xbf7 /* Got a local delete message we weren't expecting */,\n\t\t\t\t\t);\n\t\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\n\t\t\t\t\tthis.sequencedData.delete(key);\n\t\t\t\t} else {\n\t\t\t\t\tconst previousValue: unknown = this.sequencedData.get(key)?.value;\n\t\t\t\t\tthis.sequencedData.delete(key);\n\t\t\t\t\t// Suppress the event if local changes would cause the incoming change to be invisible optimistically.\n\t\t\t\t\tif (!this.pendingData.some((entry) => entry.type === \"clear\" || entry.key === key)) {\n\t\t\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t\t\t{ key, previousValue },\n\t\t\t\t\t\t\tlocal,\n\t\t\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tresubmit: (op: IMapDeleteOperation, localOpMetadata: PendingLocalOpMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t});\n\t\tmessageHandlers.set(\"set\", {\n\t\t\tprocess: (\n\t\t\t\top: IMapSetOperation,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t\t\t) => {\n\t\t\t\tconst { key, value } = op;\n\n\t\t\t\tif (local) {\n\t\t\t\t\tconst pendingEntryIndex = this.pendingData.findIndex(\n\t\t\t\t\t\t(entry) => entry.type !== \"clear\" && entry.key === key,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingEntry = this.pendingData[pendingEntryIndex];\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingEntry !== undefined && pendingEntry.type === \"lifetime\",\n\t\t\t\t\t\t0xbf8 /* Couldn't match local set message to pending lifetime */,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingKeySet = pendingEntry.keySets.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingKeySet !== undefined && pendingKeySet === localOpMetadata,\n\t\t\t\t\t\t0xbf9 /* Got a local set message we weren't expecting */,\n\t\t\t\t\t);\n\t\t\t\t\tif (pendingEntry.keySets.length === 0) {\n\t\t\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.sequencedData.set(key, pendingKeySet.value);\n\t\t\t\t} else {\n\t\t\t\t\tmigrateIfSharedSerializable(value, this.serializer, this.handle);\n\t\t\t\t\tconst localValue: ILocalValue = { value: value.value };\n\t\t\t\t\tconst previousValue: unknown = this.sequencedData.get(key)?.value;\n\t\t\t\t\tthis.sequencedData.set(key, localValue);\n\n\t\t\t\t\t// Suppress the event if local changes would cause the incoming change to be invisible optimistically.\n\t\t\t\t\tif (!this.pendingData.some((entry) => entry.type === \"clear\" || entry.key === key)) {\n\t\t\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t\t\t{ key, previousValue },\n\t\t\t\t\t\t\tlocal,\n\t\t\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tresubmit: (op: IMapSetOperation, localOpMetadata: PendingLocalOpMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t});\n\n\t\treturn messageHandlers;\n\t}\n}\n"]}
1
+ {"version":3,"file":"mapKernel.js","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,kEAA8E;AAE9E,0EAAwE;AAWxE,qDAI0B;AAC1B,yCAAqD;AAoFrD;;GAEG;AACH,MAAa,SAAS;IACrB;;OAEG;IACH,IAAW,IAAI;QACd,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC;QACnD,OAAO,aAAa,CAAC,MAAM,CAAC;IAC7B,CAAC;IAqBD;;;;;;;;OAQG;IACH,YACkB,UAA4B,EAC5B,MAAoB,EACpB,aAA8D,EAC9D,UAAyB,EACzB,YAAiD;QAJjD,eAAU,GAAV,UAAU,CAAkB;QAC5B,WAAM,GAAN,MAAM,CAAc;QACpB,kBAAa,GAAb,aAAa,CAAiD;QAC9D,eAAU,GAAV,UAAU,CAAe;QACzB,iBAAY,GAAZ,YAAY,CAAqC;QAjCnE;;WAEG;QACc,oBAAe,GAA4C,IAAI,GAAG,EAAE,CAAC;QAEtF;;;WAGG;QACc,kBAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;QAChE;;;;;;WAMG;QACc,gBAAW,GAAuB,EAAE,CAAC;QAqBtD;;;;;;;;;;;;;;;WAeG;QACc,qBAAgB,GAAG,GAA4C,EAAE;YACjF,yGAAyG;YACzG,yGAAyG;YACzG,yGAAyG;YACz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\n * Licensed under the MIT License.\n */\n\nimport type { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { ValueType } from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedMapEvents } from \"./interfaces.js\";\nimport type {\n\tIMapClearOperation,\n\tIMapDeleteOperation,\n\tIMapSetOperation,\n\t// eslint-disable-next-line import-x/no-deprecated\n\tISerializableValue,\n\tISerializedValue,\n} from \"./internalInterfaces.js\";\nimport {\n\ttype ILocalValue,\n\tserializeValue,\n\tmigrateIfSharedSerializable,\n} from \"./localValues.js\";\nimport { findLast, findLastIndex } from \"./utils.js\";\n\n/**\n * Defines the means to process and resubmit a given op on a map.\n */\ninterface IMapMessageHandler {\n\t/**\n\t * Apply the given operation.\n\t * @param op - The map operation to apply\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t */\n\tprocess(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t): void;\n\n\t/**\n\t * Resubmit a previously submitted operation that was not delivered.\n\t * @param op - The map operation to resubmit\n\t * @param localOpMetadata - The metadata that was originally submitted with the message.\n\t */\n\tresubmit(op: IMapOperation, localOpMetadata: PendingLocalOpMetadata): void;\n}\n\n/**\n * Union of all possible map operations.\n */\nexport type IMapOperation = IMapSetOperation | IMapDeleteOperation | IMapClearOperation;\n\n/**\n * Defines the in-memory object structure to be used for the conversion to/from serialized.\n *\n * @remarks Directly used in\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify\n * | JSON.stringify}, direct result from\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}.\n */\n// eslint-disable-next-line import-x/no-deprecated\nexport type IMapDataObjectSerializable = Record<string, ISerializableValue>;\n\n/**\n * Serialized key/value data.\n */\nexport type IMapDataObjectSerialized = Record<string, ISerializedValue>;\n\ninterface PendingKeySet {\n\ttype: \"set\";\n\tvalue: ILocalValue;\n}\n\ninterface PendingKeyDelete {\n\ttype: \"delete\";\n\tkey: string;\n}\n\ninterface PendingClear {\n\ttype: \"clear\";\n}\n\ninterface PendingKeyLifetime {\n\ttype: \"lifetime\";\n\tkey: string;\n\t/**\n\t * A non-empty array of pending key sets that occurred during this lifetime. If the list\n\t * becomes empty (e.g. during processing or rollback), the lifetime no longer exists and\n\t * must be removed from the pending data.\n\t */\n\tkeySets: PendingKeySet[];\n}\n\n/**\n * A member of the pendingData array, which tracks outstanding changes and can be used to\n * compute optimistic values. Local sets are aggregated into lifetimes.\n */\ntype PendingDataEntry = PendingKeyLifetime | PendingKeyDelete | PendingClear;\n/**\n * An individual outstanding change, which will also be found in the pendingData array\n * (though the PendingKeySets will be contained within a PendingKeyLifetime there).\n */\ntype PendingLocalOpMetadata = PendingKeySet | PendingKeyDelete | PendingClear;\n\n/**\n * A SharedMap is a map-like distributed data structure.\n */\nexport class MapKernel {\n\t/**\n\t * The number of key/value pairs stored in the map.\n\t */\n\tpublic get size(): number {\n\t\tconst iterableItems = [...this.internalIterator()];\n\t\treturn iterableItems.length;\n\t}\n\n\t/**\n\t * Mapping of op types to message handlers.\n\t */\n\tprivate readonly messageHandlers: ReadonlyMap<string, IMapMessageHandler> = new Map();\n\n\t/**\n\t * The data the map is storing, but only including sequenced values (no local pending\n\t * modifications are included).\n\t */\n\tprivate readonly sequencedData = new Map<string, ILocalValue>();\n\t/**\n\t * A data structure containing all local pending modifications, which is used in combination\n\t * with the sequencedData to compute optimistic values.\n\t *\n\t * Pending sets are aggregated into \"lifetimes\", which permit correct relative iteration order\n\t * even across remote operations and rollbacks.\n\t */\n\tprivate readonly pendingData: PendingDataEntry[] = [];\n\n\t/**\n\t * Create a new shared map kernel.\n\t * @param serializer - The serializer to serialize / parse handles\n\t * @param handle - The handle of the shared object using the kernel\n\t * @param submitMessage - A callback to submit a message through the shared object\n\t * @param isAttached - To query whether the shared object should generate ops\n\t * @param valueTypes - The value types to register\n\t * @param eventEmitter - The object that will emit map events\n\t */\n\tpublic constructor(\n\t\tprivate readonly serializer: IFluidSerializer,\n\t\tprivate readonly handle: IFluidHandle,\n\t\tprivate readonly submitMessage: (op: unknown, localOpMetadata: unknown) => void,\n\t\tprivate readonly isAttached: () => boolean,\n\t\tprivate readonly eventEmitter: TypedEventEmitter<ISharedMapEvents>,\n\t) {\n\t\tthis.messageHandlers = this.getMessageHandlers();\n\t}\n\n\t/**\n\t * Get an iterator over the optimistically observable ILocalValue entries in the map. For example, excluding\n\t * sequenced entries that have pending deletes/clears.\n\t *\n\t * @remarks\n\t * There is no perfect solution here, particularly when the iterator is retained over time and the map is\n\t * modified or new ack's are received. The pendingData portion of the iteration is the most susceptible to\n\t * this problem. The implementation prioritizes (in roughly this order):\n\t * 1. Correct immediate iteration (i.e. when the map is not modified before iteration completes)\n\t * 2. Consistent iteration order before/after sequencing of pending ops; acks don't change order\n\t * 3. Consistent iteration order between synchronized clients, even if they each modified the map concurrently\n\t * 4. Remaining as close as possible to the native Map iterator behavior, e.g. live-ish view rather than snapshot\n\t *\n\t * For this reason, it's important not to internally snapshot the output of the iterator for any purpose that\n\t * does not immediately (synchronously) consume that output and dispose of it.\n\t */\n\tprivate readonly internalIterator = (): IterableIterator<[string, ILocalValue]> => {\n\t\t// We perform iteration in two steps - first by iterating over members of the sequenced data that are not\n\t\t// optimistically deleted or cleared, and then over the pending data lifetimes that have not subsequently\n\t\t// been deleted or cleared. In total, this give an ordering of members based on when they were initially\n\t\t// added to the map (even if they were later modified), similar to the native Map.\n\t\tconst sequencedDataIterator = this.sequencedData.keys();\n\t\tconst pendingDataIterator = this.pendingData.values();\n\t\tconst next = (): IteratorResult<[string, ILocalValue]> => {\n\t\t\tlet nextSequencedKey = sequencedDataIterator.next();\n\t\t\twhile (!nextSequencedKey.done) {\n\t\t\t\tconst key = nextSequencedKey.value;\n\t\t\t\t// If we have any pending deletes or clears, then we won't iterate to this key yet (if at all).\n\t\t\t\t// Either it is optimistically deleted and will not be part of the iteration, or it was\n\t\t\t\t// re-added later and we'll iterate to it when we get to the pending data.\n\t\t\t\tif (\n\t\t\t\t\t!this.pendingData.some(\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.type === \"clear\" || (entry.type === \"delete\" && entry.key === key),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tconst optimisticValue = this.getOptimisticLocalValue(key);\n\t\t\t\t\tassert(\n\t\t\t\t\t\toptimisticValue !== undefined,\n\t\t\t\t\t\t0xbf1 /* Should never iterate to a key with undefined optimisticValue */,\n\t\t\t\t\t);\n\t\t\t\t\treturn { value: [key, optimisticValue], done: false };\n\t\t\t\t}\n\t\t\t\tnextSequencedKey = sequencedDataIterator.next();\n\t\t\t}\n\n\t\t\tlet nextPending = pendingDataIterator.next();\n\t\t\twhile (!nextPending.done) {\n\t\t\t\tconst nextPendingEntry = nextPending.value;\n\t\t\t\t// A lifetime entry may need to be iterated.\n\t\t\t\tif (nextPendingEntry.type === \"lifetime\") {\n\t\t\t\t\tconst nextPendingEntryIndex = this.pendingData.indexOf(nextPendingEntry);\n\t\t\t\t\tconst mostRecentDeleteOrClearIndex = findLastIndex(\n\t\t\t\t\t\tthis.pendingData,\n\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\tentry.type === \"clear\" ||\n\t\t\t\t\t\t\t(entry.type === \"delete\" && entry.key === nextPendingEntry.key),\n\t\t\t\t\t);\n\t\t\t\t\t// Only iterate the pending entry now if it hasn't been deleted or cleared.\n\t\t\t\t\tif (nextPendingEntryIndex > mostRecentDeleteOrClearIndex) {\n\t\t\t\t\t\tconst latestPendingValue =\n\t\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\t\t\t\tnextPendingEntry.keySets[nextPendingEntry.keySets.length - 1]!;\n\t\t\t\t\t\t// Skip iterating if we would have would have already iterated it as part of the sequenced data.\n\t\t\t\t\t\t// This is not a perfect check in the case the map has changed since the iterator was created\n\t\t\t\t\t\t// (e.g. if a remote client added the same key in the meantime).\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t!this.sequencedData.has(nextPendingEntry.key) ||\n\t\t\t\t\t\t\tmostRecentDeleteOrClearIndex !== -1\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn { value: [nextPendingEntry.key, latestPendingValue.value], done: false };\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnextPending = pendingDataIterator.next();\n\t\t\t}\n\n\t\t\treturn { value: undefined, done: true };\n\t\t};\n\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<[string, ILocalValue]> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t};\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic entries(): IterableIterator<[string, unknown]> {\n\t\tconst internalIterator = this.internalIterator();\n\t\tconst next = (): IteratorResult<[string, unknown]> => {\n\t\t\tconst nextResult = internalIterator.next();\n\t\t\tif (nextResult.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\t// Unpack the stored value\n\t\t\tconst [key, localValue] = nextResult.value;\n\t\t\treturn { value: [key, localValue.value], done: false };\n\t\t};\n\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<[string, unknown]> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the keys in this map.\n\t * @returns The iterator\n\t */\n\tpublic keys(): IterableIterator<string> {\n\t\tconst internalIterator = this.internalIterator();\n\t\tconst next = (): IteratorResult<string> => {\n\t\t\tconst nextResult = internalIterator.next();\n\t\t\tif (nextResult.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\tconst [key] = nextResult.value;\n\t\t\treturn { value: key, done: false };\n\t\t};\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<string> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the values in this map.\n\t * @returns The iterator\n\t */\n\tpublic values(): IterableIterator<unknown> {\n\t\tconst internalIterator = this.internalIterator();\n\t\tconst next = (): IteratorResult<unknown> => {\n\t\t\tconst nextResult = internalIterator.next();\n\t\t\tif (nextResult.done) {\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t}\n\t\t\tconst [, localValue] = nextResult.value;\n\t\t\treturn { value: localValue.value, done: false };\n\t\t};\n\t\tconst iterator = {\n\t\t\tnext,\n\t\t\t[Symbol.iterator](): IterableIterator<unknown> {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Get an iterator over the entries in this map.\n\t * @returns The iterator\n\t */\n\tpublic [Symbol.iterator](): IterableIterator<[string, unknown]> {\n\t\treturn this.entries();\n\t}\n\n\t/**\n\t * Executes the given callback on each entry in the map.\n\t * @param callbackFn - Callback function\n\t */\n\tpublic forEach(\n\t\tcallbackFn: (value: unknown, key: string, map: Map<string, unknown>) => void,\n\t): void {\n\t\t// It would be better to iterate over the data without a temp map. However, we don't have a valid\n\t\t// map to pass for the third argument here (really, it should probably should be a reference to the\n\t\t// SharedMap and not the MapKernel).\n\t\tconst tempMap = new Map(this.internalIterator());\n\t\t// eslint-disable-next-line unicorn/no-array-for-each\n\t\ttempMap.forEach((localValue, key, m) => {\n\t\t\tcallbackFn(localValue.value, key, m);\n\t\t});\n\t}\n\n\t/**\n\t * Compute the optimistic local value for a given key. This combines the sequenced data with\n\t * any pending changes that have not yet been sequenced.\n\t */\n\tprivate readonly getOptimisticLocalValue = (key: string): ILocalValue | undefined => {\n\t\tconst latestPendingEntry = findLast(\n\t\t\tthis.pendingData,\n\t\t\t(entry) => entry.type === \"clear\" || entry.key === key,\n\t\t);\n\n\t\tif (latestPendingEntry === undefined) {\n\t\t\treturn this.sequencedData.get(key);\n\t\t} else if (latestPendingEntry.type === \"lifetime\") {\n\t\t\tconst latestPendingSet =\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tlatestPendingEntry.keySets[latestPendingEntry.keySets.length - 1]!;\n\t\t\treturn latestPendingSet.value;\n\t\t} else {\n\t\t\t// Delete or clear\n\t\t\treturn undefined;\n\t\t}\n\t};\n\n\t/**\n\t * {@inheritDoc ISharedMap.get}\n\t */\n\tpublic get<T = unknown>(key: string): T | undefined {\n\t\tconst localValue = this.getOptimisticLocalValue(key);\n\t\treturn localValue === undefined ? undefined : (localValue.value as T);\n\t}\n\n\t/**\n\t * Check if a key exists in the map.\n\t * @param key - The key to check\n\t * @returns True if the key exists, false otherwise\n\t */\n\tpublic has(key: string): boolean {\n\t\treturn this.getOptimisticLocalValue(key) !== undefined;\n\t}\n\n\t/**\n\t * {@inheritDoc ISharedMap.set}\n\t */\n\tpublic set(key: string, value: unknown): void {\n\t\t// Undefined/null keys can't be serialized to JSON in the manner we currently snapshot.\n\t\tif (key === undefined || key === null) {\n\t\t\tthrow new Error(\"Undefined and null keys are not supported\");\n\t\t}\n\n\t\tconst localValue: ILocalValue = { value };\n\t\tconst previousOptimisticLocalValue = this.getOptimisticLocalValue(key);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\tthis.sequencedData.set(key, localValue);\n\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\"valueChanged\",\n\t\t\t\t{ key, previousValue: previousOptimisticLocalValue?.value },\n\t\t\t\ttrue,\n\t\t\t\tthis.eventEmitter,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// A new pending key lifetime is created if:\n\t\t// 1. There isn't any pending entry for the key yet\n\t\t// 2. The most recent pending entry for the key was a deletion (as this terminates the prior lifetime)\n\t\t// 3. A clear was sent after the last pending entry for the key (which also terminates the prior lifetime)\n\t\tlet latestPendingEntry = findLast(\n\t\t\tthis.pendingData,\n\t\t\t(entry) => entry.type === \"clear\" || entry.key === key,\n\t\t);\n\t\tif (\n\t\t\tlatestPendingEntry === undefined ||\n\t\t\tlatestPendingEntry.type === \"delete\" ||\n\t\t\tlatestPendingEntry.type === \"clear\"\n\t\t) {\n\t\t\tlatestPendingEntry = { type: \"lifetime\", key, keySets: [] };\n\t\t\tthis.pendingData.push(latestPendingEntry);\n\t\t}\n\t\tconst pendingKeySet: PendingKeySet = {\n\t\t\ttype: \"set\",\n\t\t\tvalue: localValue,\n\t\t};\n\t\tlatestPendingEntry.keySets.push(pendingKeySet);\n\n\t\tconst op: IMapSetOperation = {\n\t\t\tkey,\n\t\t\ttype: \"set\",\n\t\t\tvalue: { type: ValueType[ValueType.Plain], value: localValue.value },\n\t\t};\n\t\tthis.submitMessage(op, pendingKeySet);\n\t\tthis.eventEmitter.emit(\n\t\t\t\"valueChanged\",\n\t\t\t{ key, previousValue: previousOptimisticLocalValue?.value },\n\t\t\ttrue,\n\t\t\tthis.eventEmitter,\n\t\t);\n\t}\n\n\t/**\n\t * Delete a key from the map.\n\t * @param key - Key to delete\n\t * @returns True if the key existed and was deleted, false if it did not exist\n\t */\n\tpublic delete(key: string): boolean {\n\t\tconst previousOptimisticLocalValue = this.getOptimisticLocalValue(key);\n\n\t\tif (!this.isAttached()) {\n\t\t\tconst successfullyRemoved = this.sequencedData.delete(key);\n\t\t\t// Only emit if we actually deleted something.\n\t\t\tif (previousOptimisticLocalValue !== undefined) {\n\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t{ key, previousValue: previousOptimisticLocalValue.value },\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn successfullyRemoved;\n\t\t}\n\n\t\tconst pendingKeyDelete: PendingKeyDelete = {\n\t\t\ttype: \"delete\",\n\t\t\tkey,\n\t\t};\n\t\tthis.pendingData.push(pendingKeyDelete);\n\n\t\tconst op: IMapDeleteOperation = {\n\t\t\tkey,\n\t\t\ttype: \"delete\",\n\t\t};\n\t\tthis.submitMessage(op, pendingKeyDelete);\n\t\t// Only emit if we locally believe we deleted something. Otherwise we still send the op\n\t\t// (permitting speculative deletion even if we don't see anything locally) but don't emit\n\t\t// a valueChanged since we in fact did not locally observe a value change.\n\t\tif (previousOptimisticLocalValue !== undefined) {\n\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\"valueChanged\",\n\t\t\t\t{ key, previousValue: previousOptimisticLocalValue.value },\n\t\t\t\ttrue,\n\t\t\t\tthis.eventEmitter,\n\t\t\t);\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Clear all data from the map.\n\t */\n\tpublic clear(): void {\n\t\tif (!this.isAttached()) {\n\t\t\t// Collect keys to delete before clearing\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-shadow\n\t\t\tconst keysToDelete: { key: string; previousValue: unknown }[] = [];\n\t\t\tfor (const [key, value] of this.sequencedData) {\n\t\t\t\tkeysToDelete.push({ key, previousValue: value.value });\n\t\t\t}\n\t\t\tthis.sequencedData.clear();\n\t\t\tthis.eventEmitter.emit(\"clear\", true, this.eventEmitter);\n\t\t\t// Emit delete-like valueChanged events for keys that were removed\n\t\t\tfor (const { key, previousValue } of keysToDelete) {\n\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t{ key, previousValue },\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\t// Collect keys that will be deleted (those without pending ops that supersede the clear)\n\t\tconst keysToDelete: { key: string; previousValue: unknown }[] = [];\n\t\tfor (const [key, value] of this.internalIterator()) {\n\t\t\tkeysToDelete.push({ key, previousValue: value.value });\n\t\t}\n\n\t\tconst pendingClear: PendingClear = {\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.pendingData.push(pendingClear);\n\n\t\tconst op: IMapClearOperation = {\n\t\t\ttype: \"clear\",\n\t\t};\n\t\tthis.submitMessage(op, pendingClear);\n\t\tthis.eventEmitter.emit(\"clear\", true, this.eventEmitter);\n\t\t// Emit delete-like valueChanged events for keys that were removed\n\t\tfor (const { key, previousValue } of keysToDelete) {\n\t\t\tthis.eventEmitter.emit(\"valueChanged\", { key, previousValue }, true, this.eventEmitter);\n\t\t}\n\t}\n\n\t/**\n\t * Serializes the data stored in the shared map to a JSON string\n\t * @param serializer - The serializer to use to serialize handles in its values.\n\t * @returns A JSON string containing serialized map data\n\t */\n\tpublic getSerializedStorage(serializer: IFluidSerializer): IMapDataObjectSerialized {\n\t\tconst serializedMapData: IMapDataObjectSerialized = {};\n\t\tfor (const [key, localValue] of this.sequencedData.entries()) {\n\t\t\tserializedMapData[key] = serializeValue(localValue.value, serializer, this.handle);\n\t\t}\n\t\treturn serializedMapData;\n\t}\n\n\t/**\n\t * Populate the kernel with the given map data.\n\t * @param data - A JSON string containing serialized map data\n\t */\n\tpublic populateFromSerializable(json: IMapDataObjectSerializable): void {\n\t\tfor (const [key, serializable] of Object.entries(\n\t\t\tthis.serializer.decode(json) as IMapDataObjectSerializable,\n\t\t)) {\n\t\t\tmigrateIfSharedSerializable(serializable, this.serializer, this.handle);\n\t\t\tthis.sequencedData.set(key, { value: serializable.value });\n\t\t}\n\t}\n\n\t/**\n\t * Resubmit the given op if a handler is registered.\n\t * @param op - The operation to attempt to submit\n\t * @param localOpMetadata - The local metadata associated with the op. This is kept locally by the runtime\n\t * and not sent to the server. This will be sent back when this message is received back from the server. This is\n\t * also sent if we are asked to resubmit the message.\n\t * @returns True if the operation was submitted, false otherwise.\n\t */\n\tpublic tryResubmitMessage(op: IMapOperation, localOpMetadata: unknown): boolean {\n\t\tconst handler = this.messageHandlers.get(op.type);\n\t\tif (handler === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\thandler.resubmit(op, localOpMetadata as PendingLocalOpMetadata);\n\t\treturn true;\n\t}\n\n\tpublic tryApplyStashedOp(op: IMapOperation): void {\n\t\tswitch (op.type) {\n\t\t\tcase \"clear\": {\n\t\t\t\tthis.clear();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"delete\": {\n\t\t\t\tthis.delete(op.key);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"set\": {\n\t\t\t\tmigrateIfSharedSerializable(op.value, this.serializer, this.handle);\n\t\t\t\tthis.set(op.key, op.value.value);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(op);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Process the given op if a handler is registered.\n\t * @param message - The message to process\n\t * @param local - Whether the message originated from the local client\n\t * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.\n\t * For messages from a remote client, this will be undefined.\n\t * @returns True if the operation was recognized and thus processed, false otherwise.\n\t *\n\t * @remarks\n\t * When this returns false and the caller doesn't handle the op itself, then the op could be from a different version of this code.\n\t * In such a case, not applying the op would result in this client becoming out of sync with clients that do handle the op\n\t * and could result in data corruption or data loss as well.\n\t * Therefore, in such cases the caller should typically throw an error, ensuring that this client treats the situation as data corruption\n\t * (since its data no longer matches what other clients think the data should be) and will avoid overriding document content or misleading the users into thinking their current state is accurate.\n\t */\n\tpublic tryProcessMessage(\n\t\top: IMapOperation,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): boolean {\n\t\tconst handler = this.messageHandlers.get(op.type);\n\t\tif (handler === undefined) {\n\t\t\treturn false;\n\t\t}\n\t\thandler.process(op, local, localOpMetadata as PendingLocalOpMetadata | undefined);\n\t\treturn true;\n\t}\n\n\t/**\n\t * Rollback a local op\n\t * @param op - The operation to rollback\n\t * @param localOpMetadata - The local metadata associated with the op.\n\t */\n\tpublic rollback(op: unknown, localOpMetadata: unknown): void {\n\t\tconst mapOp: IMapOperation = op as IMapOperation;\n\t\tconst typedLocalOpMetadata = localOpMetadata as PendingLocalOpMetadata;\n\t\tif (mapOp.type === \"clear\") {\n\t\t\t// A pending clear will be last in the list, since it terminates all prior lifetimes.\n\t\t\tconst pendingClear = this.pendingData.pop();\n\t\t\tassert(\n\t\t\t\tpendingClear !== undefined &&\n\t\t\t\t\tpendingClear.type === \"clear\" &&\n\t\t\t\t\tpendingClear === typedLocalOpMetadata,\n\t\t\t\t0xbf2 /* Unexpected clear rollback */,\n\t\t\t);\n\t\t\tfor (const [key] of this.internalIterator()) {\n\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t{ key, previousValue: undefined },\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\t// A pending set/delete may not be last in the list, as the lifetimes' order is based on when\n\t\t\t// they were created, not when they were last modified.\n\t\t\tconst pendingEntryIndex = findLastIndex(\n\t\t\t\tthis.pendingData,\n\t\t\t\t(entry) => entry.type !== \"clear\" && entry.key === mapOp.key,\n\t\t\t);\n\t\t\tconst pendingEntry = this.pendingData[pendingEntryIndex];\n\t\t\tassert(\n\t\t\t\tpendingEntry !== undefined &&\n\t\t\t\t\t(pendingEntry.type === \"delete\" || pendingEntry.type === \"lifetime\"),\n\t\t\t\t0xbf3 /* Unexpected pending data for set/delete op */,\n\t\t\t);\n\t\t\tif (pendingEntry.type === \"delete\") {\n\t\t\t\tassert(pendingEntry === typedLocalOpMetadata, 0xbf4 /* Unexpected delete rollback */);\n\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\t\t\t\t// Only emit if rolling back the delete actually results in a value becoming visible.\n\t\t\t\tif (this.getOptimisticLocalValue(mapOp.key) !== undefined) {\n\t\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t\t{ key: mapOp.key, previousValue: undefined },\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else if (pendingEntry.type === \"lifetime\") {\n\t\t\t\tconst pendingKeySet = pendingEntry.keySets.pop();\n\t\t\t\tassert(\n\t\t\t\t\tpendingKeySet !== undefined && pendingKeySet === typedLocalOpMetadata,\n\t\t\t\t\t0xbf5 /* Unexpected set rollback */,\n\t\t\t\t);\n\t\t\t\tif (pendingEntry.keySets.length === 0) {\n\t\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\t\t\t\t}\n\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t{ key: mapOp.key, previousValue: pendingKeySet.value.value },\n\t\t\t\t\ttrue,\n\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get the message handlers for the map.\n\t * @returns A map of string op names to IMapMessageHandlers for those ops\n\t */\n\tprivate getMessageHandlers(): Map<string, IMapMessageHandler> {\n\t\tconst messageHandlers = new Map<string, IMapMessageHandler>();\n\t\tmessageHandlers.set(\"clear\", {\n\t\t\tprocess: (\n\t\t\t\top: IMapClearOperation,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t\t\t) => {\n\t\t\t\tif (local) {\n\t\t\t\t\tthis.sequencedData.clear();\n\t\t\t\t\tconst pendingClear = this.pendingData.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingClear !== undefined &&\n\t\t\t\t\t\t\tpendingClear.type === \"clear\" &&\n\t\t\t\t\t\t\tpendingClear === localOpMetadata,\n\t\t\t\t\t\t0xbf6 /* Got a local clear message we weren't expecting */,\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tconst keysToDelete: { key: string; previousValue: unknown }[] = [];\n\t\t\t\t\tfor (const [key, value] of this.sequencedData) {\n\t\t\t\t\t\t// Check if this key has pending local operations that supersede the remote op\n\t\t\t\t\t\tconst hasPendingOps = this.pendingData.some(\n\t\t\t\t\t\t\t(entry) =>\n\t\t\t\t\t\t\t\t(entry.type === \"delete\" && entry.key === key) ||\n\t\t\t\t\t\t\t\t(entry.type === \"lifetime\" && entry.key === key),\n\t\t\t\t\t\t);\n\t\t\t\t\t\t// Only collect keys without pending operations (i.e., actually deleted)\n\t\t\t\t\t\tif (!hasPendingOps) {\n\t\t\t\t\t\t\tkeysToDelete.push({ key, previousValue: value.value });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthis.sequencedData.clear();\n\n\t\t\t\t\t// Only emit for remote ops, we would have already emitted for local ops. Only emit if there\n\t\t\t\t\t// is no optimistically-applied local pending clear that would supersede this remote clear.\n\t\t\t\t\tif (!this.pendingData.some((entry) => entry.type === \"clear\")) {\n\t\t\t\t\t\tthis.eventEmitter.emit(\"clear\", local, this.eventEmitter);\n\n\t\t\t\t\t\t// Emit delete-like valueChanged events for keys that were removed\n\t\t\t\t\t\tfor (const { key, previousValue } of keysToDelete) {\n\t\t\t\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t\t\t\t{ key, previousValue },\n\t\t\t\t\t\t\t\tlocal,\n\t\t\t\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tresubmit: (op: IMapClearOperation, localOpMetadata: PendingLocalOpMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t});\n\t\tmessageHandlers.set(\"delete\", {\n\t\t\tprocess: (\n\t\t\t\top: IMapDeleteOperation,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t\t\t) => {\n\t\t\t\tconst { key } = op;\n\n\t\t\t\tif (local) {\n\t\t\t\t\tconst pendingEntryIndex = this.pendingData.findIndex(\n\t\t\t\t\t\t(entry) => entry.type !== \"clear\" && entry.key === key,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingEntry = this.pendingData[pendingEntryIndex];\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingEntry !== undefined &&\n\t\t\t\t\t\t\tpendingEntry.type === \"delete\" &&\n\t\t\t\t\t\t\tpendingEntry === localOpMetadata,\n\t\t\t\t\t\t0xbf7 /* Got a local delete message we weren't expecting */,\n\t\t\t\t\t);\n\t\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\n\t\t\t\t\tthis.sequencedData.delete(key);\n\t\t\t\t} else {\n\t\t\t\t\tconst previousValue: unknown = this.sequencedData.get(key)?.value;\n\t\t\t\t\tthis.sequencedData.delete(key);\n\t\t\t\t\t// Suppress the event if local changes would cause the incoming change to be invisible optimistically.\n\t\t\t\t\tif (!this.pendingData.some((entry) => entry.type === \"clear\" || entry.key === key)) {\n\t\t\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t\t\t{ key, previousValue },\n\t\t\t\t\t\t\tlocal,\n\t\t\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tresubmit: (op: IMapDeleteOperation, localOpMetadata: PendingLocalOpMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t});\n\t\tmessageHandlers.set(\"set\", {\n\t\t\tprocess: (\n\t\t\t\top: IMapSetOperation,\n\t\t\t\tlocal: boolean,\n\t\t\t\tlocalOpMetadata: PendingLocalOpMetadata | undefined,\n\t\t\t) => {\n\t\t\t\tconst { key, value } = op;\n\n\t\t\t\tif (local) {\n\t\t\t\t\tconst pendingEntryIndex = this.pendingData.findIndex(\n\t\t\t\t\t\t(entry) => entry.type !== \"clear\" && entry.key === key,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingEntry = this.pendingData[pendingEntryIndex];\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingEntry !== undefined && pendingEntry.type === \"lifetime\",\n\t\t\t\t\t\t0xbf8 /* Couldn't match local set message to pending lifetime */,\n\t\t\t\t\t);\n\t\t\t\t\tconst pendingKeySet = pendingEntry.keySets.shift();\n\t\t\t\t\tassert(\n\t\t\t\t\t\tpendingKeySet !== undefined && pendingKeySet === localOpMetadata,\n\t\t\t\t\t\t0xbf9 /* Got a local set message we weren't expecting */,\n\t\t\t\t\t);\n\t\t\t\t\tif (pendingEntry.keySets.length === 0) {\n\t\t\t\t\t\tthis.pendingData.splice(pendingEntryIndex, 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.sequencedData.set(key, pendingKeySet.value);\n\t\t\t\t} else {\n\t\t\t\t\tmigrateIfSharedSerializable(value, this.serializer, this.handle);\n\t\t\t\t\tconst localValue: ILocalValue = { value: value.value };\n\t\t\t\t\tconst previousValue: unknown = this.sequencedData.get(key)?.value;\n\t\t\t\t\tthis.sequencedData.set(key, localValue);\n\n\t\t\t\t\t// Suppress the event if local changes would cause the incoming change to be invisible optimistically.\n\t\t\t\t\tif (!this.pendingData.some((entry) => entry.type === \"clear\" || entry.key === key)) {\n\t\t\t\t\t\tthis.eventEmitter.emit(\n\t\t\t\t\t\t\t\"valueChanged\",\n\t\t\t\t\t\t\t{ key, previousValue },\n\t\t\t\t\t\t\tlocal,\n\t\t\t\t\t\t\tthis.eventEmitter,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tresubmit: (op: IMapSetOperation, localOpMetadata: PendingLocalOpMetadata) => {\n\t\t\t\tthis.submitMessage(op, localOpMetadata);\n\t\t\t},\n\t\t});\n\n\t\treturn messageHandlers;\n\t}\n}\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/map";
8
- export declare const pkgVersion = "2.74.0-370705";
8
+ export declare const pkgVersion = "2.80.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,wBAAwB,CAAC;AAC7C,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,wBAAwB,CAAC;AAC7C,eAAO,MAAM,UAAU,WAAW,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/map";
11
- exports.pkgVersion = "2.74.0-370705";
11
+ exports.pkgVersion = "2.80.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qBAAqB,CAAC;AAChC,QAAA,UAAU,GAAG,eAAe,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/map\";\nexport const pkgVersion = \"2.74.0-370705\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,qBAAqB,CAAC;AAChC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/map\";\nexport const pkgVersion = \"2.80.0\";\n"]}
@@ -0,0 +1,27 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * GENERATED FILE - DO NOT EDIT DIRECTLY.
4
+ * To regenerate: pnpm tsx scripts/generate-flat-eslint-configs.ts --typescript
5
+ */
6
+ import type { Linter } from "eslint";
7
+ import { strict } from "../../../common/build/eslint-config-fluid/flat.mts";
8
+
9
+ const config: Linter.Config[] = [
10
+ ...strict,
11
+ {
12
+ rules: {
13
+ "@typescript-eslint/no-use-before-define": "off",
14
+ "@typescript-eslint/strict-boolean-expressions": "off",
15
+ "unicorn/numeric-separators-style": "off",
16
+ "@fluid-internal/fluid/no-unchecked-record-access": "warn",
17
+ },
18
+ },
19
+ {
20
+ files: ["src/test/**"],
21
+ rules: {
22
+ "unicorn/prefer-module": "off",
23
+ },
24
+ },
25
+ ];
26
+
27
+ export default config;
@@ -579,6 +579,24 @@ declare class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implement
579
579
  * is true, we will include them since some scenarios require this.
580
580
  */
581
581
  private readonly getOptimisticSubDirectory;
582
+ /**
583
+ * Checks if this directory should be considered visible in the optimistic view.
584
+ * This requires both:
585
+ * 1. The directory object must not be disposed (disposed = true means fully deleted)
586
+ * 2. The directory must be reachable via getWorkingDirectory (respects pending deletes)
587
+ *
588
+ * There's a timing window where a directory has a pending delete but is not yet disposed:
589
+ * - When deleteSubDirectory is called locally, it adds a pending delete entry and emits a
590
+ * "dispose" event, but doesn't set disposed = true yet.
591
+ * - The directory only gets fully disposed when the delete message is sequenced.
592
+ * - During this window, !disposed is true but getWorkingDirectory returns undefined.
593
+ *
594
+ * This method should be used before emitting events during remote message processing to ensure
595
+ * events aren't emitted for directories that are invisible in the optimistic view.
596
+ *
597
+ * @returns true if this directory is visible in the optimistic view, false otherwise
598
+ */
599
+ private isNotDisposedAndReachable;
582
600
  get sequencedSubdirectories(): ReadonlyMap<string, SubDirectory>;
583
601
  /**
584
602
  * Process a clear operation.
@@ -1 +1 @@
1
- {"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../src/directory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AAGxD,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,yBAAyB,EAEzB,yBAAyB,EACzB,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EACN,YAAY,EAIZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAEN,KAAK,mBAAmB,EAGxB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACX,UAAU,EACV,gBAAgB,EAEhB,gBAAgB,EAChB,8BAA8B,EAE9B,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAEX,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,yBAAyB,CAAC;AAuCjC;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACtC;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC;IAEZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IAEH,KAAK,EAAE,kBAAkB,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAEf;;OAEG;IACH,GAAG,EAAE,MAAM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;;;OAIG;IAEI,QAAQ,CAAC,EAAE,EAAE,GAAG,EAAE,eAAe,EAAE,wBAAwB,GAAG,IAAI;IAwJzE;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAIpB;;;;;OAKG;IACH,OAAO,CAAC,yCAAyC;IAgBjD,OAAO,CAAC,4BAA4B;IASpC,OAAO,CAAC,uBAAuB;IAiB/B,OAAO,CAAC,wBAAwB;IAehC,OAAO,CAAC,yBAAyB;IAQjC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAwCvC;;;;OAIG;IACI,8BAA8B,IAAI,IAAI;CAQ7C"}
package/lib/directory.js CHANGED
@@ -1078,7 +1078,9 @@ class SubDirectory extends TypedEventEmitter {
1078
1078
  if (!this.directory.isAttached()) {
1079
1079
  const successfullyRemoved = this.sequencedStorageData.delete(key);
1080
1080
  // Only emit if we actually deleted something.
1081
- if (previousOptimisticLocalValue !== undefined && successfullyRemoved) {
1081
+ if (this.isNotDisposedAndReachable() &&
1082
+ previousOptimisticLocalValue !== undefined &&
1083
+ successfullyRemoved) {
1082
1084
  const event = {
1083
1085
  key,
1084
1086
  path: this.absolutePath,
@@ -1109,7 +1111,7 @@ class SubDirectory extends TypedEventEmitter {
1109
1111
  // Only emit if we locally believe we deleted something. Otherwise we still send the op
1110
1112
  // (permitting speculative deletion even if we don't see anything locally) but don't emit
1111
1113
  // a valueChanged since we in fact did not locally observe a value change.
1112
- if (previousOptimisticLocalValue !== undefined) {
1114
+ if (this.isNotDisposedAndReachable() && previousOptimisticLocalValue !== undefined) {
1113
1115
  const event = {
1114
1116
  key,
1115
1117
  path: this.absolutePath,
@@ -1244,6 +1246,26 @@ class SubDirectory extends TypedEventEmitter {
1244
1246
  this.throwIfDisposed();
1245
1247
  return this.internalIterator();
1246
1248
  }
1249
+ /**
1250
+ * Checks if this directory should be considered visible in the optimistic view.
1251
+ * This requires both:
1252
+ * 1. The directory object must not be disposed (disposed = true means fully deleted)
1253
+ * 2. The directory must be reachable via getWorkingDirectory (respects pending deletes)
1254
+ *
1255
+ * There's a timing window where a directory has a pending delete but is not yet disposed:
1256
+ * - When deleteSubDirectory is called locally, it adds a pending delete entry and emits a
1257
+ * "dispose" event, but doesn't set disposed = true yet.
1258
+ * - The directory only gets fully disposed when the delete message is sequenced.
1259
+ * - During this window, !disposed is true but getWorkingDirectory returns undefined.
1260
+ *
1261
+ * This method should be used before emitting events during remote message processing to ensure
1262
+ * events aren't emitted for directories that are invisible in the optimistic view.
1263
+ *
1264
+ * @returns true if this directory is visible in the optimistic view, false otherwise
1265
+ */
1266
+ isNotDisposedAndReachable() {
1267
+ return (!this.disposed && this.directory.getWorkingDirectory(this.absolutePath) !== undefined);
1268
+ }
1247
1269
  get sequencedSubdirectories() {
1248
1270
  this.throwIfDisposed();
1249
1271
  return this._sequencedSubdirectories;
@@ -1280,6 +1302,7 @@ class SubDirectory extends TypedEventEmitter {
1280
1302
  this.sequencedStorageData.clear();
1281
1303
  // Only emit for remote ops, we would have already emitted for local ops. Only emit if there
1282
1304
  // is no optimistically-applied local pending clear that would supersede this remote clear.
1305
+ // Don't emit events if this directory has been disposed or no longer exists
1283
1306
  if (!this.pendingStorageData.some((entry) => entry.type === "clear")) {
1284
1307
  this.directory.emit("clear", local, this.directory);
1285
1308
  this.directory.emit("clearInternal", this.absolutePath, local, this.directory);
@@ -1287,6 +1310,10 @@ class SubDirectory extends TypedEventEmitter {
1287
1310
  // For pending set operations, emit valueChanged events
1288
1311
  // Include 'path' so listeners can identify which subdirectory the change occurred in
1289
1312
  for (const { key, previousValue } of pendingSets) {
1313
+ // Stop emitting events if this directory has been disposed or is no longer reachable
1314
+ if (!this.isNotDisposedAndReachable()) {
1315
+ break;
1316
+ }
1290
1317
  this.directory.emit("valueChanged", {
1291
1318
  key,
1292
1319
  path: this.absolutePath,
@@ -1321,7 +1348,8 @@ class SubDirectory extends TypedEventEmitter {
1321
1348
  const previousValue = this.sequencedStorageData.get(op.key);
1322
1349
  this.sequencedStorageData.delete(op.key);
1323
1350
  // Suppress the event if local changes would cause the incoming change to be invisible optimistically.
1324
- if (!this.pendingStorageData.some((entry) => entry.type === "clear" || entry.key === op.key)) {
1351
+ if (this.isNotDisposedAndReachable() &&
1352
+ !this.pendingStorageData.some((entry) => entry.type === "clear" || entry.key === op.key)) {
1325
1353
  const event = {
1326
1354
  key: op.key,
1327
1355
  path: this.absolutePath,
@@ -1363,7 +1391,8 @@ class SubDirectory extends TypedEventEmitter {
1363
1391
  const previousValue = this.sequencedStorageData.get(key);
1364
1392
  this.sequencedStorageData.set(key, value);
1365
1393
  // Suppress the event if local changes would cause the incoming change to be invisible optimistically.
1366
- if (!this.pendingStorageData.some((entry) => entry.type === "clear" || entry.key === key)) {
1394
+ if (this.isNotDisposedAndReachable() &&
1395
+ !this.pendingStorageData.some((entry) => entry.type === "clear" || entry.key === key)) {
1367
1396
  const event = { key, path: this.absolutePath, previousValue };
1368
1397
  this.directory.emit("valueChanged", event, local, this.directory);
1369
1398
  const containedEvent = { key, previousValue };
@@ -1422,7 +1451,8 @@ class SubDirectory extends TypedEventEmitter {
1422
1451
  this.registerEventsOnSubDirectory(subDir, op.subdirName);
1423
1452
  this._sequencedSubdirectories.set(op.subdirName, subDir);
1424
1453
  // Suppress the event if local changes would cause the incoming change to be invisible optimistically.
1425
- if (!this.pendingSubDirectoryData.some((entry) => entry.subdirName === op.subdirName)) {
1454
+ if (!this.pendingSubDirectoryData.some((entry) => entry.subdirName === op.subdirName) &&
1455
+ subDir.isNotDisposedAndReachable()) {
1426
1456
  this.emit("subDirectoryCreated", op.subdirName, local, this);
1427
1457
  }
1428
1458
  }