@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/lib/mapKernel.js CHANGED
@@ -323,10 +323,25 @@ export class MapKernel {
323
323
  */
324
324
  clear() {
325
325
  if (!this.isAttached()) {
326
+ // Collect keys to delete before clearing
327
+ // eslint-disable-next-line @typescript-eslint/no-shadow
328
+ const keysToDelete = [];
329
+ for (const [key, value] of this.sequencedData) {
330
+ keysToDelete.push({ key, previousValue: value.value });
331
+ }
326
332
  this.sequencedData.clear();
327
333
  this.eventEmitter.emit("clear", true, this.eventEmitter);
334
+ // Emit delete-like valueChanged events for keys that were removed
335
+ for (const { key, previousValue } of keysToDelete) {
336
+ this.eventEmitter.emit("valueChanged", { key, previousValue }, true, this.eventEmitter);
337
+ }
328
338
  return;
329
339
  }
340
+ // Collect keys that will be deleted (those without pending ops that supersede the clear)
341
+ const keysToDelete = [];
342
+ for (const [key, value] of this.internalIterator()) {
343
+ keysToDelete.push({ key, previousValue: value.value });
344
+ }
330
345
  const pendingClear = {
331
346
  type: "clear",
332
347
  };
@@ -336,6 +351,10 @@ export class MapKernel {
336
351
  };
337
352
  this.submitMessage(op, pendingClear);
338
353
  this.eventEmitter.emit("clear", true, this.eventEmitter);
354
+ // Emit delete-like valueChanged events for keys that were removed
355
+ for (const { key, previousValue } of keysToDelete) {
356
+ this.eventEmitter.emit("valueChanged", { key, previousValue }, true, this.eventEmitter);
357
+ }
339
358
  }
340
359
  /**
341
360
  * Serializes the data stored in the shared map to a JSON string
@@ -469,18 +488,33 @@ export class MapKernel {
469
488
  const messageHandlers = new Map();
470
489
  messageHandlers.set("clear", {
471
490
  process: (op, local, localOpMetadata) => {
472
- this.sequencedData.clear();
473
491
  if (local) {
492
+ this.sequencedData.clear();
474
493
  const pendingClear = this.pendingData.shift();
475
494
  assert(pendingClear !== undefined &&
476
495
  pendingClear.type === "clear" &&
477
496
  pendingClear === localOpMetadata, 0xbf6 /* Got a local clear message we weren't expecting */);
478
497
  }
479
498
  else {
499
+ const keysToDelete = [];
500
+ for (const [key, value] of this.sequencedData) {
501
+ // Check if this key has pending local operations that supersede the remote op
502
+ const hasPendingOps = this.pendingData.some((entry) => (entry.type === "delete" && entry.key === key) ||
503
+ (entry.type === "lifetime" && entry.key === key));
504
+ // Only collect keys without pending operations (i.e., actually deleted)
505
+ if (!hasPendingOps) {
506
+ keysToDelete.push({ key, previousValue: value.value });
507
+ }
508
+ }
509
+ this.sequencedData.clear();
480
510
  // Only emit for remote ops, we would have already emitted for local ops. Only emit if there
481
511
  // is no optimistically-applied local pending clear that would supersede this remote clear.
482
512
  if (!this.pendingData.some((entry) => entry.type === "clear")) {
483
513
  this.eventEmitter.emit("clear", local, this.eventEmitter);
514
+ // Emit delete-like valueChanged events for keys that were removed
515
+ for (const { key, previousValue } of keysToDelete) {
516
+ this.eventEmitter.emit("valueChanged", { key, previousValue }, local, this.eventEmitter);
517
+ }
484
518
  }
485
519
  }
486
520
  },
@@ -1 +1 @@
1
- {"version":3,"file":"mapKernel.js","sourceRoot":"","sources":["../src/mapKernel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAWxE,OAAO,EAEN,cAAc,EACd,2BAA2B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAoFrD;;GAEG;AACH,MAAM,OAAO,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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AAC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,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","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,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAWxE,OAAO,EAEN,cAAc,EACd,2BAA2B,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAoFrD;;GAEG;AACH,MAAM,OAAO,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;QA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C;IACxB,CAAC;CACD","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\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"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/map";
8
- export const pkgVersion = "2.74.0-370705";
8
+ export const pkgVersion = "2.80.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAC7C,MAAM,CAAC,MAAM,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;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAC7C,MAAM,CAAC,MAAM,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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/map",
3
- "version": "2.74.0-370705",
3
+ "version": "2.80.0",
4
4
  "description": "Distributed map",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -81,44 +81,45 @@
81
81
  "temp-directory": "nyc/.nyc_output"
82
82
  },
83
83
  "dependencies": {
84
- "@fluid-internal/client-utils": "2.74.0-370705",
85
- "@fluidframework/core-interfaces": "2.74.0-370705",
86
- "@fluidframework/core-utils": "2.74.0-370705",
87
- "@fluidframework/datastore-definitions": "2.74.0-370705",
88
- "@fluidframework/driver-definitions": "2.74.0-370705",
89
- "@fluidframework/driver-utils": "2.74.0-370705",
90
- "@fluidframework/runtime-definitions": "2.74.0-370705",
91
- "@fluidframework/runtime-utils": "2.74.0-370705",
92
- "@fluidframework/shared-object-base": "2.74.0-370705",
93
- "@fluidframework/telemetry-utils": "2.74.0-370705",
84
+ "@fluid-internal/client-utils": "~2.80.0",
85
+ "@fluidframework/core-interfaces": "~2.80.0",
86
+ "@fluidframework/core-utils": "~2.80.0",
87
+ "@fluidframework/datastore-definitions": "~2.80.0",
88
+ "@fluidframework/driver-definitions": "~2.80.0",
89
+ "@fluidframework/driver-utils": "~2.80.0",
90
+ "@fluidframework/runtime-definitions": "~2.80.0",
91
+ "@fluidframework/runtime-utils": "~2.80.0",
92
+ "@fluidframework/shared-object-base": "~2.80.0",
93
+ "@fluidframework/telemetry-utils": "~2.80.0",
94
94
  "path-browserify": "^1.0.1"
95
95
  },
96
96
  "devDependencies": {
97
- "@arethetypeswrong/cli": "^0.17.1",
97
+ "@arethetypeswrong/cli": "^0.18.2",
98
98
  "@biomejs/biome": "~1.9.3",
99
- "@fluid-internal/mocha-test-setup": "2.74.0-370705",
100
- "@fluid-private/stochastic-test-utils": "2.74.0-370705",
101
- "@fluid-private/test-dds-utils": "2.74.0-370705",
99
+ "@fluid-internal/mocha-test-setup": "~2.80.0",
100
+ "@fluid-private/stochastic-test-utils": "~2.80.0",
101
+ "@fluid-private/test-dds-utils": "~2.80.0",
102
102
  "@fluid-tools/benchmark": "^0.51.0",
103
- "@fluid-tools/build-cli": "^0.60.0",
103
+ "@fluid-tools/build-cli": "^0.62.0",
104
104
  "@fluidframework/build-common": "^2.0.3",
105
- "@fluidframework/build-tools": "^0.60.0",
106
- "@fluidframework/container-definitions": "2.74.0-370705",
107
- "@fluidframework/eslint-config-fluid": "2.74.0-370705",
108
- "@fluidframework/map-previous": "npm:@fluidframework/map@2.73.0",
109
- "@fluidframework/test-runtime-utils": "2.74.0-370705",
105
+ "@fluidframework/build-tools": "^0.62.0",
106
+ "@fluidframework/container-definitions": "~2.80.0",
107
+ "@fluidframework/eslint-config-fluid": "~2.80.0",
108
+ "@fluidframework/map-previous": "npm:@fluidframework/map@2.74.0",
109
+ "@fluidframework/test-runtime-utils": "~2.80.0",
110
110
  "@microsoft/api-extractor": "7.52.11",
111
111
  "@types/mocha": "^10.0.10",
112
112
  "@types/node": "^18.19.0",
113
113
  "@types/path-browserify": "^1.0.0",
114
114
  "c8": "^10.1.3",
115
- "concurrently": "^8.2.1",
115
+ "concurrently": "^9.2.1",
116
116
  "copyfiles": "^2.4.1",
117
- "cross-env": "^7.0.3",
118
- "eslint": "~8.57.1",
117
+ "cross-env": "^10.1.0",
118
+ "eslint": "~9.39.1",
119
+ "jiti": "^2.6.1",
119
120
  "mocha": "^10.8.2",
120
121
  "mocha-multi-reporters": "^1.5.1",
121
- "rimraf": "^4.4.0",
122
+ "rimraf": "^6.1.2",
122
123
  "typescript": "~5.4.5"
123
124
  },
124
125
  "typeValidation": {
package/src/directory.ts CHANGED
@@ -1512,7 +1512,11 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1512
1512
  if (!this.directory.isAttached()) {
1513
1513
  const successfullyRemoved = this.sequencedStorageData.delete(key);
1514
1514
  // Only emit if we actually deleted something.
1515
- if (previousOptimisticLocalValue !== undefined && successfullyRemoved) {
1515
+ if (
1516
+ this.isNotDisposedAndReachable() &&
1517
+ previousOptimisticLocalValue !== undefined &&
1518
+ successfullyRemoved
1519
+ ) {
1516
1520
  const event: IDirectoryValueChanged = {
1517
1521
  key,
1518
1522
  path: this.absolutePath,
@@ -1545,7 +1549,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1545
1549
  // Only emit if we locally believe we deleted something. Otherwise we still send the op
1546
1550
  // (permitting speculative deletion even if we don't see anything locally) but don't emit
1547
1551
  // a valueChanged since we in fact did not locally observe a value change.
1548
- if (previousOptimisticLocalValue !== undefined) {
1552
+ if (this.isNotDisposedAndReachable() && previousOptimisticLocalValue !== undefined) {
1549
1553
  const event: IDirectoryValueChanged = {
1550
1554
  key,
1551
1555
  path: this.absolutePath,
@@ -1859,6 +1863,29 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1859
1863
  return subdir;
1860
1864
  };
1861
1865
 
1866
+ /**
1867
+ * Checks if this directory should be considered visible in the optimistic view.
1868
+ * This requires both:
1869
+ * 1. The directory object must not be disposed (disposed = true means fully deleted)
1870
+ * 2. The directory must be reachable via getWorkingDirectory (respects pending deletes)
1871
+ *
1872
+ * There's a timing window where a directory has a pending delete but is not yet disposed:
1873
+ * - When deleteSubDirectory is called locally, it adds a pending delete entry and emits a
1874
+ * "dispose" event, but doesn't set disposed = true yet.
1875
+ * - The directory only gets fully disposed when the delete message is sequenced.
1876
+ * - During this window, !disposed is true but getWorkingDirectory returns undefined.
1877
+ *
1878
+ * This method should be used before emitting events during remote message processing to ensure
1879
+ * events aren't emitted for directories that are invisible in the optimistic view.
1880
+ *
1881
+ * @returns true if this directory is visible in the optimistic view, false otherwise
1882
+ */
1883
+ private isNotDisposedAndReachable(): boolean {
1884
+ return (
1885
+ !this.disposed && this.directory.getWorkingDirectory(this.absolutePath) !== undefined
1886
+ );
1887
+ }
1888
+
1862
1889
  public get sequencedSubdirectories(): ReadonlyMap<string, SubDirectory> {
1863
1890
  this.throwIfDisposed();
1864
1891
  return this._sequencedSubdirectories;
@@ -1907,6 +1934,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1907
1934
 
1908
1935
  // Only emit for remote ops, we would have already emitted for local ops. Only emit if there
1909
1936
  // is no optimistically-applied local pending clear that would supersede this remote clear.
1937
+ // Don't emit events if this directory has been disposed or no longer exists
1910
1938
  if (!this.pendingStorageData.some((entry) => entry.type === "clear")) {
1911
1939
  this.directory.emit("clear", local, this.directory);
1912
1940
  this.directory.emit("clearInternal", this.absolutePath, local, this.directory);
@@ -1915,6 +1943,10 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1915
1943
  // For pending set operations, emit valueChanged events
1916
1944
  // Include 'path' so listeners can identify which subdirectory the change occurred in
1917
1945
  for (const { key, previousValue } of pendingSets) {
1946
+ // Stop emitting events if this directory has been disposed or is no longer reachable
1947
+ if (!this.isNotDisposedAndReachable()) {
1948
+ break;
1949
+ }
1918
1950
  this.directory.emit(
1919
1951
  "valueChanged",
1920
1952
  {
@@ -1967,6 +1999,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
1967
1999
  this.sequencedStorageData.delete(op.key);
1968
2000
  // Suppress the event if local changes would cause the incoming change to be invisible optimistically.
1969
2001
  if (
2002
+ this.isNotDisposedAndReachable() &&
1970
2003
  !this.pendingStorageData.some(
1971
2004
  (entry) => entry.type === "clear" || entry.key === op.key,
1972
2005
  )
@@ -2032,6 +2065,7 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
2032
2065
 
2033
2066
  // Suppress the event if local changes would cause the incoming change to be invisible optimistically.
2034
2067
  if (
2068
+ this.isNotDisposedAndReachable() &&
2035
2069
  !this.pendingStorageData.some((entry) => entry.type === "clear" || entry.key === key)
2036
2070
  ) {
2037
2071
  const event: IDirectoryValueChanged = { key, path: this.absolutePath, previousValue };
@@ -2121,7 +2155,10 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
2121
2155
  this._sequencedSubdirectories.set(op.subdirName, subDir);
2122
2156
 
2123
2157
  // Suppress the event if local changes would cause the incoming change to be invisible optimistically.
2124
- if (!this.pendingSubDirectoryData.some((entry) => entry.subdirName === op.subdirName)) {
2158
+ if (
2159
+ !this.pendingSubDirectoryData.some((entry) => entry.subdirName === op.subdirName) &&
2160
+ subDir.isNotDisposedAndReachable()
2161
+ ) {
2125
2162
  this.emit("subDirectoryCreated", op.subdirName, local, this);
2126
2163
  }
2127
2164
  }
package/src/mapKernel.ts CHANGED
@@ -495,11 +495,32 @@ export class MapKernel {
495
495
  */
496
496
  public clear(): void {
497
497
  if (!this.isAttached()) {
498
+ // Collect keys to delete before clearing
499
+ // eslint-disable-next-line @typescript-eslint/no-shadow
500
+ const keysToDelete: { key: string; previousValue: unknown }[] = [];
501
+ for (const [key, value] of this.sequencedData) {
502
+ keysToDelete.push({ key, previousValue: value.value });
503
+ }
498
504
  this.sequencedData.clear();
499
505
  this.eventEmitter.emit("clear", true, this.eventEmitter);
506
+ // Emit delete-like valueChanged events for keys that were removed
507
+ for (const { key, previousValue } of keysToDelete) {
508
+ this.eventEmitter.emit(
509
+ "valueChanged",
510
+ { key, previousValue },
511
+ true,
512
+ this.eventEmitter,
513
+ );
514
+ }
500
515
  return;
501
516
  }
502
517
 
518
+ // Collect keys that will be deleted (those without pending ops that supersede the clear)
519
+ const keysToDelete: { key: string; previousValue: unknown }[] = [];
520
+ for (const [key, value] of this.internalIterator()) {
521
+ keysToDelete.push({ key, previousValue: value.value });
522
+ }
523
+
503
524
  const pendingClear: PendingClear = {
504
525
  type: "clear",
505
526
  };
@@ -510,6 +531,10 @@ export class MapKernel {
510
531
  };
511
532
  this.submitMessage(op, pendingClear);
512
533
  this.eventEmitter.emit("clear", true, this.eventEmitter);
534
+ // Emit delete-like valueChanged events for keys that were removed
535
+ for (const { key, previousValue } of keysToDelete) {
536
+ this.eventEmitter.emit("valueChanged", { key, previousValue }, true, this.eventEmitter);
537
+ }
513
538
  }
514
539
 
515
540
  /**
@@ -685,8 +710,8 @@ export class MapKernel {
685
710
  local: boolean,
686
711
  localOpMetadata: PendingLocalOpMetadata | undefined,
687
712
  ) => {
688
- this.sequencedData.clear();
689
713
  if (local) {
714
+ this.sequencedData.clear();
690
715
  const pendingClear = this.pendingData.shift();
691
716
  assert(
692
717
  pendingClear !== undefined &&
@@ -695,10 +720,35 @@ export class MapKernel {
695
720
  0xbf6 /* Got a local clear message we weren't expecting */,
696
721
  );
697
722
  } else {
723
+ const keysToDelete: { key: string; previousValue: unknown }[] = [];
724
+ for (const [key, value] of this.sequencedData) {
725
+ // Check if this key has pending local operations that supersede the remote op
726
+ const hasPendingOps = this.pendingData.some(
727
+ (entry) =>
728
+ (entry.type === "delete" && entry.key === key) ||
729
+ (entry.type === "lifetime" && entry.key === key),
730
+ );
731
+ // Only collect keys without pending operations (i.e., actually deleted)
732
+ if (!hasPendingOps) {
733
+ keysToDelete.push({ key, previousValue: value.value });
734
+ }
735
+ }
736
+ this.sequencedData.clear();
737
+
698
738
  // Only emit for remote ops, we would have already emitted for local ops. Only emit if there
699
739
  // is no optimistically-applied local pending clear that would supersede this remote clear.
700
740
  if (!this.pendingData.some((entry) => entry.type === "clear")) {
701
741
  this.eventEmitter.emit("clear", local, this.eventEmitter);
742
+
743
+ // Emit delete-like valueChanged events for keys that were removed
744
+ for (const { key, previousValue } of keysToDelete) {
745
+ this.eventEmitter.emit(
746
+ "valueChanged",
747
+ { key, previousValue },
748
+ local,
749
+ this.eventEmitter,
750
+ );
751
+ }
702
752
  }
703
753
  }
704
754
  },
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/map";
9
- export const pkgVersion = "2.74.0-370705";
9
+ export const pkgVersion = "2.80.0";