@fluidframework/legacy-dds 2.60.0 → 2.61.0-355054
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mocharc.cjs +1 -2
- package/dist/array/sharedArray.d.ts.map +1 -1
- package/dist/array/sharedArray.js +25 -2
- package/dist/array/sharedArray.js.map +1 -1
- package/dist/legacy.d.ts +2 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/signal/sharedSignal.d.ts +1 -0
- package/dist/signal/sharedSignal.d.ts.map +1 -1
- package/dist/signal/sharedSignal.js +4 -0
- package/dist/signal/sharedSignal.js.map +1 -1
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/array/sharedArray.d.ts.map +1 -1
- package/lib/array/sharedArray.js +25 -2
- package/lib/array/sharedArray.js.map +1 -1
- package/lib/legacy.d.ts +2 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/signal/sharedSignal.d.ts +1 -0
- package/lib/signal/sharedSignal.d.ts.map +1 -1
- package/lib/signal/sharedSignal.js +4 -0
- package/lib/signal/sharedSignal.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +23 -23
- package/src/array/sharedArray.ts +28 -2
- package/src/packageVersion.ts +1 -1
- package/src/signal/sharedSignal.ts +5 -0
package/.mocharc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedArray.d.ts","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,K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,EAAE,OAAO,GAAG,IAAI;CA6DhD"}
|
|
@@ -339,9 +339,32 @@ class SharedArrayClass extends internal_4.SharedObject {
|
|
|
339
339
|
this.emitValueChangedEvent(moveOp, true /* isLocal */);
|
|
340
340
|
break;
|
|
341
341
|
}
|
|
342
|
-
case sharedArrayOperations_js_1.OperationType.toggle:
|
|
342
|
+
case sharedArrayOperations_js_1.OperationType.toggle: {
|
|
343
|
+
const entryId = arrayOp.entryId;
|
|
344
|
+
const liveEntry = this.getLiveEntry(entryId);
|
|
345
|
+
const isDeleted = liveEntry.isDeleted;
|
|
346
|
+
// Toggling the isDeleted flag to undo the last operation for the skip list payload/value
|
|
347
|
+
liveEntry.isDeleted = !isDeleted;
|
|
348
|
+
liveEntry.isLocalPendingDelete -= 1;
|
|
349
|
+
const toggleOp = {
|
|
350
|
+
type: sharedArrayOperations_js_1.OperationType.toggle,
|
|
351
|
+
entryId,
|
|
352
|
+
isDeleted: liveEntry.isDeleted,
|
|
353
|
+
};
|
|
354
|
+
this.emitValueChangedEvent(toggleOp, true /* isLocal */);
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
343
357
|
case sharedArrayOperations_js_1.OperationType.toggleMove: {
|
|
344
|
-
|
|
358
|
+
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
359
|
+
this.getEntryForId(oldEntryId).isLocalPendingMove -= 1;
|
|
360
|
+
this.updateLiveEntry(oldEntryId, newEntryId);
|
|
361
|
+
const toggleMoveOp = {
|
|
362
|
+
type: sharedArrayOperations_js_1.OperationType.toggleMove,
|
|
363
|
+
entryId: newEntryId,
|
|
364
|
+
changedToEntryId: oldEntryId,
|
|
365
|
+
};
|
|
366
|
+
this.emitValueChangedEvent(toggleMoveOp, true /* isLocal */);
|
|
367
|
+
break;
|
|
345
368
|
}
|
|
346
369
|
default: {
|
|
347
370
|
(0, internal_1.unreachableCase)(arrayOp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedArray.js","sour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G,EAAE,CAAC,SAAS,CAAC;gBACvD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,oBAAoB,IAAI,CAAC,CAAC;gBACzD,MAAM;YACP,CAAC;YACD,KAAK,wCAAa,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC/B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;gBACxE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,kBAAkB,IAAI,CAAC,CAAC;gBACvD,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,IAAA,0BAAe,EAAC,EAAE,CAAC,CAAC;YACrB,CAAC;QACF,CAAC;QACD,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACD;AAz6BD,4CAy6BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tSerializable,\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelFactory,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tISharedArrayEvents,\n\tISharedArray,\n\tISharedArrayRevertible,\n\tSerializableTypeForSharedArray,\n\tSharedArrayEntry,\n\tSnapshotFormat,\n\tSharedArrayEntryCore,\n} from \"./interfaces.js\";\nimport { SharedArrayFactory } from \"./sharedArrayFactory.js\";\nimport type {\n\tISharedArrayOperation,\n\tIDeleteOperation,\n\tIMoveOperation,\n\tIToggleMoveOperation,\n\tIToggleOperation,\n} from \"./sharedArrayOperations.js\";\nimport { OperationType } from \"./sharedArrayOperations.js\";\nimport { SharedArrayRevertible } from \"./sharedArrayRevertible.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared array that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedArrayClass<T extends SerializableTypeForSharedArray>\n\textends SharedObject<ISharedArrayEvents>\n\timplements ISharedArray<T>, ISharedArrayRevertible\n{\n\t/**\n\t * Stores the data held by this shared array.\n\t */\n\tprivate sharedArray: SharedArrayEntry<T>[];\n\n\t/**\n\t * Stores a map of entryid to entries of the sharedArray. This is meant of search optimizations and\n\t * so shouldn't be snapshotted.\n\t * Note: This map needs to be updated only when the sharedArray is being deserialized and when new entries are\n\t * being added. New entries are added upon insert ops and the second leg of the move op.\n\t * As we don't delete the entries once created, deletion or move to another position needs no special\n\t * handling for this data structure\n\t */\n\tprivate readonly idToEntryMap: Map<string, SharedArrayEntry<T>>;\n\n\t/**\n\t * Set of entry IDs that are marked for deletion by remote clients, but have local pending deletes.\n\t * Used to prevent resuscitating entries while rolling back a delete operation.\n\t * We should not rollback to life an entry that was deleted by remote clients.\n\t */\n\tprivate readonly remoteDeleteWithLocalPendingDelete: Set<string> = new Set<string>();\n\n\t/**\n\t * Create a new shared array\n\t *\n\t * @param runtime - data store runtime the new shared array belongs to\n\t * @param id - optional name of the shared array\n\t * @returns newly create shared array (but not attached yet)\n\t */\n\tpublic static create<T extends SerializableTypeForSharedArray>(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid?: string,\n\t): SharedArrayClass<T> {\n\t\treturn runtime.createChannel(id, SharedArrayFactory.Type) as SharedArrayClass<T>;\n\t}\n\n\t/**\n\t * Get a factory for SharedArray to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedArray\n\t */\n\tpublic static getFactory<T extends SerializableTypeForSharedArray>(): IChannelFactory {\n\t\treturn new SharedArrayFactory<T>();\n\t}\n\n\t/**\n\t * Constructs a new shared array. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param id - optional name of the shared array\n\t * @param runtime - data store runtime the shared array belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedArray_\" /* telemetryContextPrefix */);\n\t\tthis.sharedArray = [];\n\t\tthis.idToEntryMap = new Map<string, SharedArrayEntry<T>>();\n\t}\n\n\t/**\n\t * Method that returns the ordered list of the items held in the DDS at this point in time.\n\t * Note: This is only a snapshot of the array\n\t */\n\tpublic get(): readonly T[] {\n\t\treturn this.sharedArray.filter((item) => !item.isDeleted).map((entry) => entry.value);\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Deep copy and unset the local flags. Needed when snapshotting is happening for runtime not attached\n\t\tconst dataArrayCopy: SharedArrayEntryCore<T>[] = [];\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tdataArrayCopy.push({\n\t\t\t\tentryId: entry.entryId,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tvalue: JSON.parse(serializer.stringify(entry.value, this.handle)),\n\t\t\t\tisDeleted: entry.isDeleted,\n\t\t\t\tprevEntryId: entry.prevEntryId,\n\t\t\t\tnextEntryId: entry.nextEntryId,\n\t\t\t});\n\t\t}\n\n\t\t// We are snapshotting current client data so autoacking pending local.\n\t\t// Assumption : This should happen only for offline client creating the array. All other scenarios should\n\t\t// get to MSN - where there can be no local pending possible.\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t\tconst contents: SnapshotFormat<SharedArrayEntryCore<T>> = {\n\t\t\tdataArray: dataArrayCopy,\n\t\t};\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: serializer.stringify(contents, this.handle),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\tpublic insertBulkAfter<TWrite>(\n\t\tref: T | undefined,\n\t\tvalues: (Serializable<TWrite> & T)[],\n\t): void {\n\t\tlet itemIndex: number = 0;\n\n\t\tif (ref !== undefined) {\n\t\t\tfor (itemIndex = this.sharedArray.length - 1; itemIndex > 0; itemIndex -= 1) {\n\t\t\t\tconst item = this.sharedArray[itemIndex];\n\t\t\t\tif (item && !item.isDeleted && item.value === ref) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add one since we're inserting it after this rowId. If rowId is not found, we will get -1, which after\n\t\t\t// adding one, will be 0, which will place the new rows at the right place too\n\t\t\titemIndex += 1;\n\t\t}\n\n\t\t// Insert new elements\n\t\tfor (const value of values) {\n\t\t\tthis.insertCore(itemIndex, value);\n\t\t\titemIndex += 1;\n\t\t}\n\t}\n\n\tpublic insert<TWrite>(index: number, value: Serializable<TWrite> & T): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Insertion index provided is less than 0.\");\n\t\t}\n\t\tthis.insertCore(this.findInternalInsertionIndex(index), value);\n\t}\n\n\tprivate insertCore<TWrite>(indexInternal: number, value: Serializable<TWrite> & T): void {\n\t\tconst insertAfterEntryId =\n\t\t\tindexInternal >= 1 ? this.sharedArray[indexInternal - 1]?.entryId : undefined;\n\t\tconst newEntryId = this.createAddEntry(indexInternal, value);\n\n\t\tconst op = {\n\t\t\ttype: OperationType.insertEntry,\n\t\t\tentryId: newEntryId,\n\t\t\tvalue,\n\t\t\tinsertAfterEntryId,\n\t\t};\n\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic delete(index: number): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Deletion index provided is less than 0.\");\n\t\t}\n\n\t\tconst indexInternal: number = this.findInternalDeletionIndex(index);\n\n\t\tconst entry = this.sharedArray[indexInternal];\n\t\tassert(entry !== undefined, 0xb90 /* Invalid index */);\n\t\tconst entryId = entry.entryId;\n\t\tthis.deleteCore(indexInternal);\n\n\t\tconst op: IDeleteOperation = {\n\t\t\ttype: OperationType.deleteEntry,\n\t\t\tentryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rearrangeToFront(values: T[]): void {\n\t\tfor (let toIndex = 0; toIndex < values.length; toIndex += 1) {\n\t\t\tconst value = values[toIndex];\n\t\t\t// Can skip searching first <toIndex> indices, as they contain elements we already moved.\n\t\t\tfor (let fromIndex = toIndex; fromIndex < this.sharedArray.length; fromIndex += 1) {\n\t\t\t\tconst item = this.sharedArray[fromIndex];\n\t\t\t\tassert(item !== undefined, 0xb91 /* Invalid index */);\n\t\t\t\tif (item.value !== value) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!item.isDeleted &&\n\t\t\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\t\t\tfromIndex !== toIndex &&\n\t\t\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\t\t\ttoIndex !== fromIndex + 1\n\t\t\t\t) {\n\t\t\t\t\tthis.moveCore(fromIndex, toIndex);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Moves the DDS entry from one index to another\n\t *\n\t * @param fromIndex - User index of the element to be moved\n\t * @param toIndex - User index to which the element should move to\n\t */\n\tpublic move(fromIndex: number, toIndex: number): void {\n\t\tif (fromIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: fromIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (toIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: toIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (\n\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\tfromIndex === toIndex ||\n\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\ttoIndex === fromIndex + 1\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst fromIndexInternal: number = this.findInternalDeletionIndex(fromIndex);\n\t\tconst toIndexInternal: number = this.findInternalInsertionIndex(toIndex);\n\n\t\tthis.moveCore(fromIndexInternal, toIndexInternal);\n\t}\n\n\tprivate moveCore(fromIndexInternal: number, toIndexInternal: number): void {\n\t\tconst insertAfterEntryId =\n\t\t\ttoIndexInternal >= 1 ? this.sharedArray[toIndexInternal - 1]?.entryId : undefined;\n\t\tconst entryId = this.sharedArray[fromIndexInternal]?.entryId;\n\t\tassert(entryId !== undefined, 0xb92 /* Invalid index */);\n\t\tconst changedToEntryId = this.createMoveEntry(fromIndexInternal, toIndexInternal);\n\n\t\tconst op: IMoveOperation = {\n\t\t\ttype: OperationType.moveEntry,\n\t\t\tentryId,\n\t\t\tinsertAfterEntryId,\n\t\t\tchangedToEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\t/**\n\t * Method used to do undo/redo operation for the given entry id. This method is\n\t * used for undo/redo of only insert and delete operations. Move operation is NOT handled\n\t * by this method\n\t *\n\t * @param entryId - Entry Id for which the the undo/redo operation is to be applied\n\t */\n\tpublic toggle(entryId: string): void {\n\t\tconst liveEntry = this.getLiveEntry(entryId);\n\t\tconst isDeleted = !liveEntry.isDeleted;\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(entryId).isLocalPendingDelete += 1;\n\n\t\t// Toggling the isDeleted flag to undo the last operation for the skip list payload/value\n\t\tliveEntry.isDeleted = isDeleted;\n\n\t\tconst op: IToggleOperation = {\n\t\t\ttype: OperationType.toggle,\n\t\t\tentryId,\n\t\t\tisDeleted,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\t/**\n\t * Method to do undo/redo of move operation. All entries of the same payload/value are stored\n\t * in the same doubly linked skip list. This skip list is updated upon every move by adding the\n\t * new location as a new entry in the skip list and update the isDeleted flag to indicate the new\n\t * entry is the cuurent live location for the user.\n\t *\n\t * @param oldEntryId - EntryId of the last live entry\n\t * @param newEntryId - EntryId of the to be live entry\n\t */\n\tpublic toggleMove(oldEntryId: string, newEntryId: string): void {\n\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(oldEntryId).isLocalPendingMove += 1;\n\n\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\n\t\tconst op: IToggleMoveOperation = {\n\t\t\ttype: OperationType.toggleMove,\n\t\t\tentryId: oldEntryId,\n\t\t\tchangedToEntryId: newEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rollback(op: unknown, _localOpMetadata: unknown): void {\n\t\tconst arrayOp = op as ISharedArrayOperation<T>;\n\t\tswitch (arrayOp.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\tliveEntry.isDeleted = true;\n\t\t\t\tconst deleteOp: IDeleteOperation = {\n\t\t\t\t\ttype: OperationType.deleteEntry,\n\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(deleteOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tif (this.remoteDeleteWithLocalPendingDelete.has(arrayOp.entryId)) {\n\t\t\t\t\t// If remote already deleted the entry, we should not resurrect it.\n\t\t\t\t\t// Just remove the local pending delete.\n\t\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(arrayOp.entryId);\n\t\t\t\t} else {\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\t\tliveEntry.isDeleted = false;\n\t\t\t\t\tconst insertOp = {\n\t\t\t\t\t\ttype: OperationType.insertEntry,\n\t\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t\t\tvalue: liveEntry.value,\n\t\t\t\t\t};\n\t\t\t\t\tthis.emitValueChangedEvent(insertOp, true /* isLocal */);\n\t\t\t\t\tconst entry = this.getEntryForId(arrayOp.entryId);\n\t\t\t\t\tif (entry !== undefined && entry.isLocalPendingDelete > 0) {\n\t\t\t\t\t\tentry.isLocalPendingDelete -= 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;\n\t\t\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\t\t\t\tconst inputEntry = this.getEntryForId(oldEntryId);\n\t\t\t\tinputEntry.prevEntryId = undefined;\n\t\t\t\tinputEntry.nextEntryId = undefined;\n\t\t\t\tinputEntry.isLocalPendingMove = 0;\n\t\t\t\tconst moveOp: IMoveOperation = {\n\t\t\t\t\ttype: OperationType.moveEntry,\n\t\t\t\t\tentryId: newEntryId,\n\t\t\t\t\tchangedToEntryId: oldEntryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(moveOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle:\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tthrow new Error(`Rollback not implemented for ${arrayOp.type} operations`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(arrayOp);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Load share array from snapshot\n\t *\n\t * @param storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst header = await storage.readBlob(snapshotFileName);\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\tconst utf8 = new TextDecoder(\"utf-8\").decode(header);\n\t\t// Note: IFluidSerializer.parse() doesn't guarantee any typing; the explicit typing here is based on this code's\n\t\t// knowledge of what it is deserializing.\n\t\tconst deserializedSharedArray = this.serializer.parse(utf8) as {\n\t\t\tdataArray: SharedArrayEntry<T>[];\n\t\t};\n\t\tthis.sharedArray = deserializedSharedArray.dataArray;\n\t\t// Initializing the idToEntryMap optimizer data set\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.idToEntryMap.set(entry.entryId, entry);\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Tracks the doubly linked skip list for the given entry to identify local pending counter attribute.\n\t * It signifies if a local pending operation exists for the payload/value being tracked in the skip list\n\t *\n\t * returns true if counterAttribute's count \\> 0\n\t * @param entryId - id for which counter attribute is to be tracked in chian.\n\t * @param counterAttribute - flag or property name from SharedArrayEntry whose counter is to be tracked.\n\t */\n\tprivate isLocalPending(\n\t\tentryId: string,\n\t\tcounterAttribute: keyof SharedArrayEntry<T>,\n\t): boolean {\n\t\tconst getCounterAttributeValue = (\n\t\t\tentry: SharedArrayEntry<T>,\n\t\t\tcounterAttr: keyof SharedArrayEntry<T>,\n\t\t): number => {\n\t\t\treturn entry[counterAttr] as number;\n\t\t};\n\n\t\tconst inputEntry = this.getEntryForId(entryId);\n\t\tlet prevEntryId = inputEntry.prevEntryId;\n\t\tlet nextEntryId = inputEntry.nextEntryId;\n\t\tif (getCounterAttributeValue(inputEntry, counterAttribute) > 0) {\n\t\t\treturn true;\n\t\t}\n\t\t// track back in chain\n\t\twhile (prevEntryId !== undefined && prevEntryId) {\n\t\t\tconst prevEntry = this.getEntryForId(prevEntryId);\n\t\t\tif (getCounterAttributeValue(prevEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tprevEntryId = prevEntry.prevEntryId;\n\t\t}\n\n\t\t// track forward in the chain\n\t\twhile (nextEntryId !== undefined && nextEntryId) {\n\t\t\tconst nextEntry = this.getEntryForId(nextEntryId);\n\t\t\tif (getCounterAttributeValue(nextEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tnextEntryId = nextEntry.nextEntryId;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate getEntryForId(entryId: string): SharedArrayEntry<T> {\n\t\treturn this.idToEntryMap.get(entryId) as SharedArrayEntry<T>;\n\t}\n\n\t/**\n\t * Process a shared array operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ISharedArrayOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase OperationType.insertEntry: {\n\t\t\t\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\t\t\t\top.entryId,\n\t\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t\top.value,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\t\tthis.handleDeleteOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.moveEntry: {\n\t\t\t\t\tthis.handleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggle: {\n\t\t\t\t\tthis.handleToggleOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggleMove: {\n\t\t\t\t\tthis.handleToggleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!local) {\n\t\t\t\tthis.emitValueChangedEvent(op, local);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleInsertOp<TWrite>(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tlocal: boolean,\n\t\tvalue: Serializable<TWrite> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (local) {\n\t\t\tthis.getEntryForId(entryId).isAckPending = false;\n\t\t} else {\n\t\t\tif (insertAfterEntryId !== undefined) {\n\t\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t\t}\n\t\t\tconst newEntry = this.createNewEntry(entryId, value);\n\t\t\tnewEntry.isAckPending = false;\n\t\t\tthis.addEntry(this.getInternalInsertIndexByIgnoringLocalPendingInserts(index), newEntry);\n\t\t}\n\t}\n\n\tprivate handleDeleteOp(op: IDeleteOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// Decrementing local pending counter as op is already applied to local state\n\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(op.entryId);\n\t\t} else {\n\t\t\tif (this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.add(op.entryId);\n\t\t\t} else {\n\t\t\t\t// last element in skip list is the most recent and live entry, so marking it deleted\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleMoveOp(op: IMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\top.changedToEntryId,\n\t\t\top.insertAfterEntryId,\n\t\t\tlocal,\n\t\t\topEntry.value,\n\t\t);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t} else {\n\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t// If local pending then simply mark the new location dead as finally the local op will win\n\t\t\tif (\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t) {\n\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t} else {\n\t\t\t\t// move the element\n\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\tif (isDeleted) {\n\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleOp(op: IToggleOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending delete op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingDelete) {\n\t\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleMoveOp(op: IToggleMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingMove) {\n\t\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t\t}\n\t\t} else if (\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingDelete\") &&\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t) {\n\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t}\n\t}\n\n\tprivate findInternalIndex(countEntries: number): number {\n\t\tif (countEntries < 0) {\n\t\t\tthrow new Error(\"Input count is zero\");\n\t\t}\n\n\t\tlet countDown = countEntries;\n\t\tlet entriesIterator = 0;\n\t\tfor (; entriesIterator < this.sharedArray.length; entriesIterator = entriesIterator + 1) {\n\t\t\tconst entry = this.sharedArray[entriesIterator];\n\t\t\tassert(entry !== undefined, 0xb93 /* Invalid index */);\n\t\t\tif (entry.isDeleted === false) {\n\t\t\t\tif (countDown === 0) {\n\t\t\t\t\treturn entriesIterator;\n\t\t\t\t}\n\t\t\t\tcountDown = countDown - 1;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Count of live entries is less than required`);\n\t}\n\n\tprivate findInternalInsertionIndex(index: number): number {\n\t\treturn index === 0 ? index : this.findInternalIndex(index - 1) + 1;\n\t}\n\n\tprivate findInternalDeletionIndex(index: number): number {\n\t\treturn this.findInternalIndex(index);\n\t}\n\n\tprivate createAddEntry<TWrite>(index: number, value: Serializable<TWrite> & T): string {\n\t\tconst newEntry = this.createNewEntry(uuid(), value);\n\t\tthis.addEntry(index, newEntry);\n\t\treturn newEntry.entryId;\n\t}\n\n\tprivate addEntry(insertIndex: number, newEntry: SharedArrayEntry<T>): void {\n\t\t// in scenario where we populate 100K rows, we insert them all at the end of array.\n\t\t// slicing array is way slower than pushing elements.\n\t\tif (insertIndex === this.sharedArray.length) {\n\t\t\tthis.sharedArray.push(newEntry);\n\t\t} else {\n\t\t\tthis.sharedArray.splice(insertIndex, 0 /* deleteCount */, newEntry);\n\t\t}\n\n\t\t// Updating the idToEntryMap optimizer data set as new entry has been added\n\t\tthis.idToEntryMap.set(newEntry.entryId, newEntry);\n\t}\n\n\tprivate emitValueChangedEvent(op: ISharedArrayOperation, isLocal: boolean): void {\n\t\tthis.emit(\"valueChanged\", op, isLocal, this);\n\t}\n\n\tprivate emitRevertibleEvent(op: ISharedArrayOperation): void {\n\t\tconst revertible = new SharedArrayRevertible(this, op);\n\t\tthis.emit(\"revertible\", revertible);\n\t}\n\n\tprivate deleteCore(index: number): void {\n\t\tconst entry = this.sharedArray[index];\n\t\tassert(entry !== undefined, 0xb94 /* Invalid index */);\n\n\t\tif (entry.isDeleted) {\n\t\t\tthrow new Error(\"Entry already deleted.\");\n\t\t}\n\t\tentry.isDeleted = true;\n\n\t\t// Adding local pending counter\n\t\tentry.isLocalPendingDelete += 1;\n\t}\n\n\tprivate createMoveEntry(oldIndex: number, newIndex: number): string {\n\t\tconst oldEntry = this.sharedArray[oldIndex];\n\t\tassert(oldEntry !== undefined, 0xb95 /* Invalid index */);\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(\n\t\t\tuuid(),\n\t\t\toldEntry.value,\n\t\t\toldEntry.entryId,\n\t\t);\n\n\t\toldEntry.isDeleted = true;\n\t\toldEntry.nextEntryId = newEntry.entryId;\n\n\t\t// Adding local pending counter\n\t\toldEntry.isLocalPendingMove += 1;\n\n\t\tthis.addEntry(newIndex /* insertIndex */, newEntry);\n\n\t\treturn newEntry.entryId;\n\t}\n\n\t/**\n\t * Creates new entry of type SharedArrayEntry interface.\n\t * @param entryId - id for which new entry is created\n\t * @param value - value for the new entry\n\t * @param prevEntryId - prevEntryId if exists to update the previous pointer of double ended linked list\n\t */\n\tprivate createNewEntry<TWrite>(\n\t\tentryId: string,\n\t\tvalue: Serializable<TWrite> & T,\n\t\tprevEntryId?: string,\n\t): SharedArrayEntry<T> {\n\t\treturn {\n\t\t\tentryId,\n\t\t\tvalue,\n\t\t\tisAckPending: true,\n\t\t\tisDeleted: false,\n\t\t\tprevEntryId,\n\t\t\tnextEntryId: undefined,\n\t\t\tisLocalPendingDelete: 0,\n\t\t\tisLocalPendingMove: 0,\n\t\t};\n\t}\n\n\t/**\n\t * Unsets all local flags used by the DDS. This method can be used after reading from snapshott to ensure\n\t * local flags are initialized for use by the DDS.\n\t * @param entry - Entry for which the local flags have to be cleaned up\n\t */\n\tprivate unsetLocalFlags(entry: SharedArrayEntry<T>): void {\n\t\tentry.isAckPending = false;\n\t\tentry.isLocalPendingDelete = 0;\n\t\tentry.isLocalPendingMove = 0;\n\t}\n\n\t/**\n\t * Returns the index of the first entry starting with startIndex that does not have the isAckPending flag\n\t */\n\tprivate getInternalInsertIndexByIgnoringLocalPendingInserts(startIndex: number): number {\n\t\tlet localOpsIterator = startIndex;\n\t\tfor (\n\t\t\t;\n\t\t\tlocalOpsIterator < this.sharedArray.length;\n\t\t\tlocalOpsIterator = localOpsIterator + 1\n\t\t) {\n\t\t\tconst entry = this.sharedArray[localOpsIterator];\n\t\t\tassert(entry !== undefined, 0xb96 /* Invalid index */);\n\t\t\tif (!entry.isAckPending) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn localOpsIterator;\n\t}\n\n\tprivate findIndexOfEntryId(entryId: string | undefined): number {\n\t\tfor (let index = 0; index < this.sharedArray.length; index = index + 1) {\n\t\t\tif (this.sharedArray[index]?.entryId === entryId) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n\tprivate prepareToMakeEntryIdLive(entry: SharedArrayEntry<T>): void {\n\t\tconst prevIndex = this.findIndexOfEntryId(entry.prevEntryId);\n\t\tconst nextIndex = this.findIndexOfEntryId(entry.nextEntryId);\n\t\tif (prevIndex !== -1) {\n\t\t\tconst prevEntry = this.sharedArray[prevIndex];\n\t\t\tassert(prevEntry !== undefined, 0xb97 /* Invalid index */);\n\t\t\tprevEntry.nextEntryId = entry.nextEntryId;\n\t\t}\n\t\tif (nextIndex !== -1) {\n\t\t\tconst nextEntry = this.sharedArray[nextIndex];\n\t\t\tassert(nextEntry !== undefined, 0xb98 /* Invalid index */);\n\t\t\tnextEntry.prevEntryId = entry.prevEntryId;\n\t\t}\n\t\tentry.prevEntryId = undefined;\n\t\tentry.nextEntryId = undefined;\n\t}\n\n\t/**\n\t * Method that returns the live entry.\n\t * The shared array internally can store a skip list of all related entries which got created\n\t * due to move operations for the same payload/value. However, all elements except for one element\n\t * can have isDeleted flag as false indicating this is the live entry for the value.\n\t * Current implementation ensures that the last element in the skip list of entries is the liveEntry/\n\t * last live entry\n\t *\n\t * @param entryId - Entry id of any node in the skip list for the same payload/value\n\t */\n\tprivate getLiveEntry(entryId: string): SharedArrayEntry<T> {\n\t\tlet liveEntry = this.getEntryForId(entryId);\n\t\twhile (liveEntry.nextEntryId !== undefined && liveEntry.nextEntryId) {\n\t\t\tliveEntry = this.getEntryForId(liveEntry.nextEntryId);\n\t\t}\n\t\treturn liveEntry;\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps us keep track of the current position of an entry.value by marking the entry\n\t * at previous position deleted and appending the entry at the new position at the end of the double linked\n\t * list for that entry.value.\n\t */\n\tprivate updateLiveEntry(oldLiveEntryEntryId: string, newLiveEntryEntryId: string): void {\n\t\tconst oldLiveEntry = this.getEntryForId(oldLiveEntryEntryId);\n\t\tconst newLiveEntry = this.getEntryForId(newLiveEntryEntryId);\n\t\tif (oldLiveEntryEntryId === newLiveEntryEntryId) {\n\t\t\toldLiveEntry.isDeleted = false;\n\t\t} else {\n\t\t\tthis.prepareToMakeEntryIdLive(newLiveEntry);\n\t\t\t// Make entryId live\n\t\t\toldLiveEntry.nextEntryId = newLiveEntryEntryId;\n\t\t\tnewLiveEntry.prevEntryId = oldLiveEntryEntryId;\n\t\t\tnewLiveEntry.isDeleted = false;\n\t\t\toldLiveEntry.isDeleted = true;\n\t\t}\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps to insert the new entry as dead entry and reconnecting the double linked list with\n\t * existingEntry -\\> deadeEntry(appended) -\\> existing chain(if any).\n\t */\n\tprivate updateDeadEntry(existingEntryId: string, deadEntryId: string): void {\n\t\tconst existingEntry = this.getEntryForId(existingEntryId);\n\t\tconst deadEntry = this.getEntryForId(deadEntryId);\n\n\t\t// update dead entry's next to existingEntry's next, if existingEntry's next entry exists.\n\t\t// It can be undefined if the exiting element is the last element (or only element) of chain.\n\t\tif (existingEntry.nextEntryId !== undefined) {\n\t\t\tdeadEntry.nextEntryId = existingEntry.nextEntryId;\n\t\t\tthis.getEntryForId(existingEntry.nextEntryId).prevEntryId = deadEntryId;\n\t\t}\n\n\t\t// update current entry's next pointer to dead entry and vice versa.\n\t\texistingEntry.nextEntryId = deadEntryId;\n\t\tdeadEntry.prevEntryId = existingEntryId;\n\t\tdeadEntry.isDeleted = true;\n\t}\n\n\tprivate handleStashedInsert(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tvalue: Serializable<SerializableTypeForSharedArray> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (insertAfterEntryId !== undefined) {\n\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t}\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(entryId, value);\n\t\tnewEntry.isAckPending = true;\n\t\tthis.addEntry(index, newEntry);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as ISharedArrayOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.entryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\top.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.changedToEntryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\topEntry.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\n\t\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t\tif (\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t\t) {\n\t\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t\t} else {\n\t\t\t\t\t// move the element\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\t\tif (isDeleted) {\n\t\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnewElement.isLocalPendingMove += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingMove += 1;\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\tthis.submitLocalMessage(op);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedArray.js","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAY9E,0EAA+F;AAE/F,qEAAuF;AAEvF,0EAA2E;AAC3E,+BAAkC;AAWlC,mEAA6D;AAQ7D,yEAA2D;AAC3D,yEAAmE;AAEn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I,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACD;AAn8BD,4CAm8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tSerializable,\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelFactory,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tISharedArrayEvents,\n\tISharedArray,\n\tISharedArrayRevertible,\n\tSerializableTypeForSharedArray,\n\tSharedArrayEntry,\n\tSnapshotFormat,\n\tSharedArrayEntryCore,\n} from \"./interfaces.js\";\nimport { SharedArrayFactory } from \"./sharedArrayFactory.js\";\nimport type {\n\tISharedArrayOperation,\n\tIDeleteOperation,\n\tIMoveOperation,\n\tIToggleMoveOperation,\n\tIToggleOperation,\n} from \"./sharedArrayOperations.js\";\nimport { OperationType } from \"./sharedArrayOperations.js\";\nimport { SharedArrayRevertible } from \"./sharedArrayRevertible.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared array that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedArrayClass<T extends SerializableTypeForSharedArray>\n\textends SharedObject<ISharedArrayEvents>\n\timplements ISharedArray<T>, ISharedArrayRevertible\n{\n\t/**\n\t * Stores the data held by this shared array.\n\t */\n\tprivate sharedArray: SharedArrayEntry<T>[];\n\n\t/**\n\t * Stores a map of entryid to entries of the sharedArray. This is meant of search optimizations and\n\t * so shouldn't be snapshotted.\n\t * Note: This map needs to be updated only when the sharedArray is being deserialized and when new entries are\n\t * being added. New entries are added upon insert ops and the second leg of the move op.\n\t * As we don't delete the entries once created, deletion or move to another position needs no special\n\t * handling for this data structure\n\t */\n\tprivate readonly idToEntryMap: Map<string, SharedArrayEntry<T>>;\n\n\t/**\n\t * Set of entry IDs that are marked for deletion by remote clients, but have local pending deletes.\n\t * Used to prevent resuscitating entries while rolling back a delete operation.\n\t * We should not rollback to life an entry that was deleted by remote clients.\n\t */\n\tprivate readonly remoteDeleteWithLocalPendingDelete: Set<string> = new Set<string>();\n\n\t/**\n\t * Create a new shared array\n\t *\n\t * @param runtime - data store runtime the new shared array belongs to\n\t * @param id - optional name of the shared array\n\t * @returns newly create shared array (but not attached yet)\n\t */\n\tpublic static create<T extends SerializableTypeForSharedArray>(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid?: string,\n\t): SharedArrayClass<T> {\n\t\treturn runtime.createChannel(id, SharedArrayFactory.Type) as SharedArrayClass<T>;\n\t}\n\n\t/**\n\t * Get a factory for SharedArray to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedArray\n\t */\n\tpublic static getFactory<T extends SerializableTypeForSharedArray>(): IChannelFactory {\n\t\treturn new SharedArrayFactory<T>();\n\t}\n\n\t/**\n\t * Constructs a new shared array. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param id - optional name of the shared array\n\t * @param runtime - data store runtime the shared array belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedArray_\" /* telemetryContextPrefix */);\n\t\tthis.sharedArray = [];\n\t\tthis.idToEntryMap = new Map<string, SharedArrayEntry<T>>();\n\t}\n\n\t/**\n\t * Method that returns the ordered list of the items held in the DDS at this point in time.\n\t * Note: This is only a snapshot of the array\n\t */\n\tpublic get(): readonly T[] {\n\t\treturn this.sharedArray.filter((item) => !item.isDeleted).map((entry) => entry.value);\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Deep copy and unset the local flags. Needed when snapshotting is happening for runtime not attached\n\t\tconst dataArrayCopy: SharedArrayEntryCore<T>[] = [];\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tdataArrayCopy.push({\n\t\t\t\tentryId: entry.entryId,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tvalue: JSON.parse(serializer.stringify(entry.value, this.handle)),\n\t\t\t\tisDeleted: entry.isDeleted,\n\t\t\t\tprevEntryId: entry.prevEntryId,\n\t\t\t\tnextEntryId: entry.nextEntryId,\n\t\t\t});\n\t\t}\n\n\t\t// We are snapshotting current client data so autoacking pending local.\n\t\t// Assumption : This should happen only for offline client creating the array. All other scenarios should\n\t\t// get to MSN - where there can be no local pending possible.\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t\tconst contents: SnapshotFormat<SharedArrayEntryCore<T>> = {\n\t\t\tdataArray: dataArrayCopy,\n\t\t};\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: serializer.stringify(contents, this.handle),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\tpublic insertBulkAfter<TWrite>(\n\t\tref: T | undefined,\n\t\tvalues: (Serializable<TWrite> & T)[],\n\t): void {\n\t\tlet itemIndex: number = 0;\n\n\t\tif (ref !== undefined) {\n\t\t\tfor (itemIndex = this.sharedArray.length - 1; itemIndex > 0; itemIndex -= 1) {\n\t\t\t\tconst item = this.sharedArray[itemIndex];\n\t\t\t\tif (item && !item.isDeleted && item.value === ref) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add one since we're inserting it after this rowId. If rowId is not found, we will get -1, which after\n\t\t\t// adding one, will be 0, which will place the new rows at the right place too\n\t\t\titemIndex += 1;\n\t\t}\n\n\t\t// Insert new elements\n\t\tfor (const value of values) {\n\t\t\tthis.insertCore(itemIndex, value);\n\t\t\titemIndex += 1;\n\t\t}\n\t}\n\n\tpublic insert<TWrite>(index: number, value: Serializable<TWrite> & T): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Insertion index provided is less than 0.\");\n\t\t}\n\t\tthis.insertCore(this.findInternalInsertionIndex(index), value);\n\t}\n\n\tprivate insertCore<TWrite>(indexInternal: number, value: Serializable<TWrite> & T): void {\n\t\tconst insertAfterEntryId =\n\t\t\tindexInternal >= 1 ? this.sharedArray[indexInternal - 1]?.entryId : undefined;\n\t\tconst newEntryId = this.createAddEntry(indexInternal, value);\n\n\t\tconst op = {\n\t\t\ttype: OperationType.insertEntry,\n\t\t\tentryId: newEntryId,\n\t\t\tvalue,\n\t\t\tinsertAfterEntryId,\n\t\t};\n\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic delete(index: number): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Deletion index provided is less than 0.\");\n\t\t}\n\n\t\tconst indexInternal: number = this.findInternalDeletionIndex(index);\n\n\t\tconst entry = this.sharedArray[indexInternal];\n\t\tassert(entry !== undefined, 0xb90 /* Invalid index */);\n\t\tconst entryId = entry.entryId;\n\t\tthis.deleteCore(indexInternal);\n\n\t\tconst op: IDeleteOperation = {\n\t\t\ttype: OperationType.deleteEntry,\n\t\t\tentryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rearrangeToFront(values: T[]): void {\n\t\tfor (let toIndex = 0; toIndex < values.length; toIndex += 1) {\n\t\t\tconst value = values[toIndex];\n\t\t\t// Can skip searching first <toIndex> indices, as they contain elements we already moved.\n\t\t\tfor (let fromIndex = toIndex; fromIndex < this.sharedArray.length; fromIndex += 1) {\n\t\t\t\tconst item = this.sharedArray[fromIndex];\n\t\t\t\tassert(item !== undefined, 0xb91 /* Invalid index */);\n\t\t\t\tif (item.value !== value) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!item.isDeleted &&\n\t\t\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\t\t\tfromIndex !== toIndex &&\n\t\t\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\t\t\ttoIndex !== fromIndex + 1\n\t\t\t\t) {\n\t\t\t\t\tthis.moveCore(fromIndex, toIndex);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Moves the DDS entry from one index to another\n\t *\n\t * @param fromIndex - User index of the element to be moved\n\t * @param toIndex - User index to which the element should move to\n\t */\n\tpublic move(fromIndex: number, toIndex: number): void {\n\t\tif (fromIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: fromIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (toIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: toIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (\n\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\tfromIndex === toIndex ||\n\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\ttoIndex === fromIndex + 1\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst fromIndexInternal: number = this.findInternalDeletionIndex(fromIndex);\n\t\tconst toIndexInternal: number = this.findInternalInsertionIndex(toIndex);\n\n\t\tthis.moveCore(fromIndexInternal, toIndexInternal);\n\t}\n\n\tprivate moveCore(fromIndexInternal: number, toIndexInternal: number): void {\n\t\tconst insertAfterEntryId =\n\t\t\ttoIndexInternal >= 1 ? this.sharedArray[toIndexInternal - 1]?.entryId : undefined;\n\t\tconst entryId = this.sharedArray[fromIndexInternal]?.entryId;\n\t\tassert(entryId !== undefined, 0xb92 /* Invalid index */);\n\t\tconst changedToEntryId = this.createMoveEntry(fromIndexInternal, toIndexInternal);\n\n\t\tconst op: IMoveOperation = {\n\t\t\ttype: OperationType.moveEntry,\n\t\t\tentryId,\n\t\t\tinsertAfterEntryId,\n\t\t\tchangedToEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\t/**\n\t * Method used to do undo/redo operation for the given entry id. This method is\n\t * used for undo/redo of only insert and delete operations. Move operation is NOT handled\n\t * by this method\n\t *\n\t * @param entryId - Entry Id for which the the undo/redo operation is to be applied\n\t */\n\tpublic toggle(entryId: string): void {\n\t\tconst liveEntry = this.getLiveEntry(entryId);\n\t\tconst isDeleted = !liveEntry.isDeleted;\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(entryId).isLocalPendingDelete += 1;\n\n\t\t// Toggling the isDeleted flag to undo the last operation for the skip list payload/value\n\t\tliveEntry.isDeleted = isDeleted;\n\n\t\tconst op: IToggleOperation = {\n\t\t\ttype: OperationType.toggle,\n\t\t\tentryId,\n\t\t\tisDeleted,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\t/**\n\t * Method to do undo/redo of move operation. All entries of the same payload/value are stored\n\t * in the same doubly linked skip list. This skip list is updated upon every move by adding the\n\t * new location as a new entry in the skip list and update the isDeleted flag to indicate the new\n\t * entry is the cuurent live location for the user.\n\t *\n\t * @param oldEntryId - EntryId of the last live entry\n\t * @param newEntryId - EntryId of the to be live entry\n\t */\n\tpublic toggleMove(oldEntryId: string, newEntryId: string): void {\n\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(oldEntryId).isLocalPendingMove += 1;\n\n\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\n\t\tconst op: IToggleMoveOperation = {\n\t\t\ttype: OperationType.toggleMove,\n\t\t\tentryId: oldEntryId,\n\t\t\tchangedToEntryId: newEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rollback(op: unknown, _localOpMetadata: unknown): void {\n\t\tconst arrayOp = op as ISharedArrayOperation<T>;\n\t\tswitch (arrayOp.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\tliveEntry.isDeleted = true;\n\t\t\t\tconst deleteOp: IDeleteOperation = {\n\t\t\t\t\ttype: OperationType.deleteEntry,\n\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(deleteOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tif (this.remoteDeleteWithLocalPendingDelete.has(arrayOp.entryId)) {\n\t\t\t\t\t// If remote already deleted the entry, we should not resurrect it.\n\t\t\t\t\t// Just remove the local pending delete.\n\t\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(arrayOp.entryId);\n\t\t\t\t} else {\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\t\tliveEntry.isDeleted = false;\n\t\t\t\t\tconst insertOp = {\n\t\t\t\t\t\ttype: OperationType.insertEntry,\n\t\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t\t\tvalue: liveEntry.value,\n\t\t\t\t\t};\n\t\t\t\t\tthis.emitValueChangedEvent(insertOp, true /* isLocal */);\n\t\t\t\t\tconst entry = this.getEntryForId(arrayOp.entryId);\n\t\t\t\t\tif (entry !== undefined && entry.isLocalPendingDelete > 0) {\n\t\t\t\t\t\tentry.isLocalPendingDelete -= 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;\n\t\t\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\t\t\t\tconst inputEntry = this.getEntryForId(oldEntryId);\n\t\t\t\tinputEntry.prevEntryId = undefined;\n\t\t\t\tinputEntry.nextEntryId = undefined;\n\t\t\t\tinputEntry.isLocalPendingMove = 0;\n\t\t\t\tconst moveOp: IMoveOperation = {\n\t\t\t\t\ttype: OperationType.moveEntry,\n\t\t\t\t\tentryId: newEntryId,\n\t\t\t\t\tchangedToEntryId: oldEntryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(moveOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle: {\n\t\t\t\tconst entryId = arrayOp.entryId;\n\t\t\t\tconst liveEntry = this.getLiveEntry(entryId);\n\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\n\t\t\t\t// Toggling the isDeleted flag to undo the last operation for the skip list payload/value\n\t\t\t\tliveEntry.isDeleted = !isDeleted;\n\t\t\t\tliveEntry.isLocalPendingDelete -= 1;\n\n\t\t\t\tconst toggleOp: IToggleOperation = {\n\t\t\t\t\ttype: OperationType.toggle,\n\t\t\t\t\tentryId,\n\t\t\t\t\tisDeleted: liveEntry.isDeleted,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(toggleOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tconst { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;\n\t\t\t\tthis.getEntryForId(oldEntryId).isLocalPendingMove -= 1;\n\t\t\t\tthis.updateLiveEntry(oldEntryId, newEntryId);\n\n\t\t\t\tconst toggleMoveOp: IToggleMoveOperation = {\n\t\t\t\t\ttype: OperationType.toggleMove,\n\t\t\t\t\tentryId: newEntryId,\n\t\t\t\t\tchangedToEntryId: oldEntryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(toggleMoveOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(arrayOp);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Load share array from snapshot\n\t *\n\t * @param storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst header = await storage.readBlob(snapshotFileName);\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\tconst utf8 = new TextDecoder(\"utf-8\").decode(header);\n\t\t// Note: IFluidSerializer.parse() doesn't guarantee any typing; the explicit typing here is based on this code's\n\t\t// knowledge of what it is deserializing.\n\t\tconst deserializedSharedArray = this.serializer.parse(utf8) as {\n\t\t\tdataArray: SharedArrayEntry<T>[];\n\t\t};\n\t\tthis.sharedArray = deserializedSharedArray.dataArray;\n\t\t// Initializing the idToEntryMap optimizer data set\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.idToEntryMap.set(entry.entryId, entry);\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Tracks the doubly linked skip list for the given entry to identify local pending counter attribute.\n\t * It signifies if a local pending operation exists for the payload/value being tracked in the skip list\n\t *\n\t * returns true if counterAttribute's count \\> 0\n\t * @param entryId - id for which counter attribute is to be tracked in chian.\n\t * @param counterAttribute - flag or property name from SharedArrayEntry whose counter is to be tracked.\n\t */\n\tprivate isLocalPending(\n\t\tentryId: string,\n\t\tcounterAttribute: keyof SharedArrayEntry<T>,\n\t): boolean {\n\t\tconst getCounterAttributeValue = (\n\t\t\tentry: SharedArrayEntry<T>,\n\t\t\tcounterAttr: keyof SharedArrayEntry<T>,\n\t\t): number => {\n\t\t\treturn entry[counterAttr] as number;\n\t\t};\n\n\t\tconst inputEntry = this.getEntryForId(entryId);\n\t\tlet prevEntryId = inputEntry.prevEntryId;\n\t\tlet nextEntryId = inputEntry.nextEntryId;\n\t\tif (getCounterAttributeValue(inputEntry, counterAttribute) > 0) {\n\t\t\treturn true;\n\t\t}\n\t\t// track back in chain\n\t\twhile (prevEntryId !== undefined && prevEntryId) {\n\t\t\tconst prevEntry = this.getEntryForId(prevEntryId);\n\t\t\tif (getCounterAttributeValue(prevEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tprevEntryId = prevEntry.prevEntryId;\n\t\t}\n\n\t\t// track forward in the chain\n\t\twhile (nextEntryId !== undefined && nextEntryId) {\n\t\t\tconst nextEntry = this.getEntryForId(nextEntryId);\n\t\t\tif (getCounterAttributeValue(nextEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tnextEntryId = nextEntry.nextEntryId;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate getEntryForId(entryId: string): SharedArrayEntry<T> {\n\t\treturn this.idToEntryMap.get(entryId) as SharedArrayEntry<T>;\n\t}\n\n\t/**\n\t * Process a shared array operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ISharedArrayOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase OperationType.insertEntry: {\n\t\t\t\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\t\t\t\top.entryId,\n\t\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t\top.value,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\t\tthis.handleDeleteOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.moveEntry: {\n\t\t\t\t\tthis.handleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggle: {\n\t\t\t\t\tthis.handleToggleOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggleMove: {\n\t\t\t\t\tthis.handleToggleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!local) {\n\t\t\t\tthis.emitValueChangedEvent(op, local);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleInsertOp<TWrite>(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tlocal: boolean,\n\t\tvalue: Serializable<TWrite> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (local) {\n\t\t\tthis.getEntryForId(entryId).isAckPending = false;\n\t\t} else {\n\t\t\tif (insertAfterEntryId !== undefined) {\n\t\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t\t}\n\t\t\tconst newEntry = this.createNewEntry(entryId, value);\n\t\t\tnewEntry.isAckPending = false;\n\t\t\tthis.addEntry(this.getInternalInsertIndexByIgnoringLocalPendingInserts(index), newEntry);\n\t\t}\n\t}\n\n\tprivate handleDeleteOp(op: IDeleteOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// Decrementing local pending counter as op is already applied to local state\n\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(op.entryId);\n\t\t} else {\n\t\t\tif (this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.add(op.entryId);\n\t\t\t} else {\n\t\t\t\t// last element in skip list is the most recent and live entry, so marking it deleted\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleMoveOp(op: IMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\top.changedToEntryId,\n\t\t\top.insertAfterEntryId,\n\t\t\tlocal,\n\t\t\topEntry.value,\n\t\t);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t} else {\n\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t// If local pending then simply mark the new location dead as finally the local op will win\n\t\t\tif (\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t) {\n\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t} else {\n\t\t\t\t// move the element\n\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\tif (isDeleted) {\n\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleOp(op: IToggleOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending delete op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingDelete) {\n\t\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleMoveOp(op: IToggleMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingMove) {\n\t\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t\t}\n\t\t} else if (\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingDelete\") &&\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t) {\n\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t}\n\t}\n\n\tprivate findInternalIndex(countEntries: number): number {\n\t\tif (countEntries < 0) {\n\t\t\tthrow new Error(\"Input count is zero\");\n\t\t}\n\n\t\tlet countDown = countEntries;\n\t\tlet entriesIterator = 0;\n\t\tfor (; entriesIterator < this.sharedArray.length; entriesIterator = entriesIterator + 1) {\n\t\t\tconst entry = this.sharedArray[entriesIterator];\n\t\t\tassert(entry !== undefined, 0xb93 /* Invalid index */);\n\t\t\tif (entry.isDeleted === false) {\n\t\t\t\tif (countDown === 0) {\n\t\t\t\t\treturn entriesIterator;\n\t\t\t\t}\n\t\t\t\tcountDown = countDown - 1;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Count of live entries is less than required`);\n\t}\n\n\tprivate findInternalInsertionIndex(index: number): number {\n\t\treturn index === 0 ? index : this.findInternalIndex(index - 1) + 1;\n\t}\n\n\tprivate findInternalDeletionIndex(index: number): number {\n\t\treturn this.findInternalIndex(index);\n\t}\n\n\tprivate createAddEntry<TWrite>(index: number, value: Serializable<TWrite> & T): string {\n\t\tconst newEntry = this.createNewEntry(uuid(), value);\n\t\tthis.addEntry(index, newEntry);\n\t\treturn newEntry.entryId;\n\t}\n\n\tprivate addEntry(insertIndex: number, newEntry: SharedArrayEntry<T>): void {\n\t\t// in scenario where we populate 100K rows, we insert them all at the end of array.\n\t\t// slicing array is way slower than pushing elements.\n\t\tif (insertIndex === this.sharedArray.length) {\n\t\t\tthis.sharedArray.push(newEntry);\n\t\t} else {\n\t\t\tthis.sharedArray.splice(insertIndex, 0 /* deleteCount */, newEntry);\n\t\t}\n\n\t\t// Updating the idToEntryMap optimizer data set as new entry has been added\n\t\tthis.idToEntryMap.set(newEntry.entryId, newEntry);\n\t}\n\n\tprivate emitValueChangedEvent(op: ISharedArrayOperation, isLocal: boolean): void {\n\t\tthis.emit(\"valueChanged\", op, isLocal, this);\n\t}\n\n\tprivate emitRevertibleEvent(op: ISharedArrayOperation): void {\n\t\tconst revertible = new SharedArrayRevertible(this, op);\n\t\tthis.emit(\"revertible\", revertible);\n\t}\n\n\tprivate deleteCore(index: number): void {\n\t\tconst entry = this.sharedArray[index];\n\t\tassert(entry !== undefined, 0xb94 /* Invalid index */);\n\n\t\tif (entry.isDeleted) {\n\t\t\tthrow new Error(\"Entry already deleted.\");\n\t\t}\n\t\tentry.isDeleted = true;\n\n\t\t// Adding local pending counter\n\t\tentry.isLocalPendingDelete += 1;\n\t}\n\n\tprivate createMoveEntry(oldIndex: number, newIndex: number): string {\n\t\tconst oldEntry = this.sharedArray[oldIndex];\n\t\tassert(oldEntry !== undefined, 0xb95 /* Invalid index */);\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(\n\t\t\tuuid(),\n\t\t\toldEntry.value,\n\t\t\toldEntry.entryId,\n\t\t);\n\n\t\toldEntry.isDeleted = true;\n\t\toldEntry.nextEntryId = newEntry.entryId;\n\n\t\t// Adding local pending counter\n\t\toldEntry.isLocalPendingMove += 1;\n\n\t\tthis.addEntry(newIndex /* insertIndex */, newEntry);\n\n\t\treturn newEntry.entryId;\n\t}\n\n\t/**\n\t * Creates new entry of type SharedArrayEntry interface.\n\t * @param entryId - id for which new entry is created\n\t * @param value - value for the new entry\n\t * @param prevEntryId - prevEntryId if exists to update the previous pointer of double ended linked list\n\t */\n\tprivate createNewEntry<TWrite>(\n\t\tentryId: string,\n\t\tvalue: Serializable<TWrite> & T,\n\t\tprevEntryId?: string,\n\t): SharedArrayEntry<T> {\n\t\treturn {\n\t\t\tentryId,\n\t\t\tvalue,\n\t\t\tisAckPending: true,\n\t\t\tisDeleted: false,\n\t\t\tprevEntryId,\n\t\t\tnextEntryId: undefined,\n\t\t\tisLocalPendingDelete: 0,\n\t\t\tisLocalPendingMove: 0,\n\t\t};\n\t}\n\n\t/**\n\t * Unsets all local flags used by the DDS. This method can be used after reading from snapshott to ensure\n\t * local flags are initialized for use by the DDS.\n\t * @param entry - Entry for which the local flags have to be cleaned up\n\t */\n\tprivate unsetLocalFlags(entry: SharedArrayEntry<T>): void {\n\t\tentry.isAckPending = false;\n\t\tentry.isLocalPendingDelete = 0;\n\t\tentry.isLocalPendingMove = 0;\n\t}\n\n\t/**\n\t * Returns the index of the first entry starting with startIndex that does not have the isAckPending flag\n\t */\n\tprivate getInternalInsertIndexByIgnoringLocalPendingInserts(startIndex: number): number {\n\t\tlet localOpsIterator = startIndex;\n\t\tfor (\n\t\t\t;\n\t\t\tlocalOpsIterator < this.sharedArray.length;\n\t\t\tlocalOpsIterator = localOpsIterator + 1\n\t\t) {\n\t\t\tconst entry = this.sharedArray[localOpsIterator];\n\t\t\tassert(entry !== undefined, 0xb96 /* Invalid index */);\n\t\t\tif (!entry.isAckPending) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn localOpsIterator;\n\t}\n\n\tprivate findIndexOfEntryId(entryId: string | undefined): number {\n\t\tfor (let index = 0; index < this.sharedArray.length; index = index + 1) {\n\t\t\tif (this.sharedArray[index]?.entryId === entryId) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n\tprivate prepareToMakeEntryIdLive(entry: SharedArrayEntry<T>): void {\n\t\tconst prevIndex = this.findIndexOfEntryId(entry.prevEntryId);\n\t\tconst nextIndex = this.findIndexOfEntryId(entry.nextEntryId);\n\t\tif (prevIndex !== -1) {\n\t\t\tconst prevEntry = this.sharedArray[prevIndex];\n\t\t\tassert(prevEntry !== undefined, 0xb97 /* Invalid index */);\n\t\t\tprevEntry.nextEntryId = entry.nextEntryId;\n\t\t}\n\t\tif (nextIndex !== -1) {\n\t\t\tconst nextEntry = this.sharedArray[nextIndex];\n\t\t\tassert(nextEntry !== undefined, 0xb98 /* Invalid index */);\n\t\t\tnextEntry.prevEntryId = entry.prevEntryId;\n\t\t}\n\t\tentry.prevEntryId = undefined;\n\t\tentry.nextEntryId = undefined;\n\t}\n\n\t/**\n\t * Method that returns the live entry.\n\t * The shared array internally can store a skip list of all related entries which got created\n\t * due to move operations for the same payload/value. However, all elements except for one element\n\t * can have isDeleted flag as false indicating this is the live entry for the value.\n\t * Current implementation ensures that the last element in the skip list of entries is the liveEntry/\n\t * last live entry\n\t *\n\t * @param entryId - Entry id of any node in the skip list for the same payload/value\n\t */\n\tprivate getLiveEntry(entryId: string): SharedArrayEntry<T> {\n\t\tlet liveEntry = this.getEntryForId(entryId);\n\t\twhile (liveEntry.nextEntryId !== undefined && liveEntry.nextEntryId) {\n\t\t\tliveEntry = this.getEntryForId(liveEntry.nextEntryId);\n\t\t}\n\t\treturn liveEntry;\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps us keep track of the current position of an entry.value by marking the entry\n\t * at previous position deleted and appending the entry at the new position at the end of the double linked\n\t * list for that entry.value.\n\t */\n\tprivate updateLiveEntry(oldLiveEntryEntryId: string, newLiveEntryEntryId: string): void {\n\t\tconst oldLiveEntry = this.getEntryForId(oldLiveEntryEntryId);\n\t\tconst newLiveEntry = this.getEntryForId(newLiveEntryEntryId);\n\t\tif (oldLiveEntryEntryId === newLiveEntryEntryId) {\n\t\t\toldLiveEntry.isDeleted = false;\n\t\t} else {\n\t\t\tthis.prepareToMakeEntryIdLive(newLiveEntry);\n\t\t\t// Make entryId live\n\t\t\toldLiveEntry.nextEntryId = newLiveEntryEntryId;\n\t\t\tnewLiveEntry.prevEntryId = oldLiveEntryEntryId;\n\t\t\tnewLiveEntry.isDeleted = false;\n\t\t\toldLiveEntry.isDeleted = true;\n\t\t}\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps to insert the new entry as dead entry and reconnecting the double linked list with\n\t * existingEntry -\\> deadeEntry(appended) -\\> existing chain(if any).\n\t */\n\tprivate updateDeadEntry(existingEntryId: string, deadEntryId: string): void {\n\t\tconst existingEntry = this.getEntryForId(existingEntryId);\n\t\tconst deadEntry = this.getEntryForId(deadEntryId);\n\n\t\t// update dead entry's next to existingEntry's next, if existingEntry's next entry exists.\n\t\t// It can be undefined if the exiting element is the last element (or only element) of chain.\n\t\tif (existingEntry.nextEntryId !== undefined) {\n\t\t\tdeadEntry.nextEntryId = existingEntry.nextEntryId;\n\t\t\tthis.getEntryForId(existingEntry.nextEntryId).prevEntryId = deadEntryId;\n\t\t}\n\n\t\t// update current entry's next pointer to dead entry and vice versa.\n\t\texistingEntry.nextEntryId = deadEntryId;\n\t\tdeadEntry.prevEntryId = existingEntryId;\n\t\tdeadEntry.isDeleted = true;\n\t}\n\n\tprivate handleStashedInsert(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tvalue: Serializable<SerializableTypeForSharedArray> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (insertAfterEntryId !== undefined) {\n\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t}\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(entryId, value);\n\t\tnewEntry.isAckPending = true;\n\t\tthis.addEntry(index, newEntry);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as ISharedArrayOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.entryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\top.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.changedToEntryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\topEntry.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\n\t\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t\tif (\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t\t) {\n\t\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t\t} else {\n\t\t\t\t\t// move the element\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\t\tif (isDeleted) {\n\t\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnewElement.isLocalPendingMove += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingMove += 1;\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\tthis.submitLocalMessage(op);\n\t}\n}\n"]}
|
package/dist/legacy.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
|
-
// @
|
|
12
|
+
// #region @legacyBeta APIs
|
|
13
13
|
IDeleteOperation,
|
|
14
14
|
IInsertOperation,
|
|
15
15
|
IMoveOperation,
|
|
@@ -28,4 +28,5 @@ export {
|
|
|
28
28
|
SharedArray,
|
|
29
29
|
SharedArrayBuilder,
|
|
30
30
|
SharedSignal
|
|
31
|
+
// #endregion
|
|
31
32
|
} from "./index.js";
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -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/legacy-dds";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.61.0-355054";
|
|
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,+BAA+B,CAAC;AACpD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,+BAA+B,CAAC;AACpD,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -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/legacy-dds";
|
|
11
|
-
exports.pkgVersion = "2.
|
|
11
|
+
exports.pkgVersion = "2.61.0-355054";
|
|
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,4BAA4B,CAAC;AACvC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4BAA4B,CAAC;AACvC,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/legacy-dds\";\nexport const pkgVersion = \"2.61.0-355054\";\n"]}
|
|
@@ -63,6 +63,7 @@ export declare class SharedSignalClass<T extends SerializableTypeForSharedSignal
|
|
|
63
63
|
*/
|
|
64
64
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, _localOpMetadata: unknown): void;
|
|
65
65
|
private notifyCore;
|
|
66
|
+
rollback(content: unknown, _localOpMetadata: unknown): void;
|
|
66
67
|
protected applyStashedOp(_content: unknown): void;
|
|
67
68
|
}
|
|
68
69
|
//# sourceMappingURL=sharedSignal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSignal.d.ts","sourceRoot":"","sources":["../../src/signal/sharedSignal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO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,EAAE,gBAAgB,EAAE,OAAO,GAAG,IAAI;IAIlE,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;CAYjD"}
|
|
@@ -116,6 +116,10 @@ class SharedSignalClass extends internal_4.SharedObject {
|
|
|
116
116
|
notifyCore(op, isLocal) {
|
|
117
117
|
this.emit("notify", op.metadata, isLocal);
|
|
118
118
|
}
|
|
119
|
+
// Nothing to roll back. Allowing other DDSs to handle rollback if necessary.
|
|
120
|
+
rollback(content, _localOpMetadata) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
119
123
|
applyStashedOp(_content) {
|
|
120
124
|
const op = _content;
|
|
121
125
|
switch (op.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSignal.js","sourceRoot":"","sources":["../../src/signal/sharedSignal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uDAAuD;AACvD,kEAAsE;AAOtE,0EAA+F;AAM/F,qEAAuF;AAEvF,0EAA2E;AAQ3E,qEAA+D;AAE/D,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAa,iBACZ,SAAQ,uBAAoC;IAG5C;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,OAA+B,EAAE,EAAW;QAChE,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,4CAAmB,CAAC,IAAI,CAAsB,CAAC;IACjF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,4CAAmB,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,oBAAoB,CAAC,4BAA4B,CAAC,CAAC;IACnF,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAAY;QACzB,+CAA+C;QAC/C,IAAI,CAAC,IAAI,CAAC,UAAU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oBAC3B,MAAM;gBACP,CAAC;gBAED,OAAO,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;gBACtC,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAEO,UAAU,CAAC,EAAuB,EAAE,OAAgB;QAC3D,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,6EAA6E;IACtE,QAAQ,CAAC,OAAgB,EAAE,gBAAyB;QAC1D,OAAO;IACR,CAAC;IAES,cAAc,CAAC,QAAiB;QACzC,MAAM,EAAE,GAAG,QAA+B,CAAC;QAE3C,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;YACjB,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACf,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,IAAA,0BAAe,EAAC,EAAW,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;IACF,CAAC;CACD;AAhJD,8CAgJC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tISharedSignal,\n\tISharedSignalEvents,\n\tISignalOperation,\n\tSerializableTypeForSharedSignal,\n} from \"./interfaces.js\";\nimport { SharedSignalFactory } from \"./sharedSignalFactory.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared signal that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedSignalClass<T extends SerializableTypeForSharedSignal = any>\n\textends SharedObject<ISharedSignalEvents<T>>\n\timplements ISharedSignal<T>\n{\n\t/**\n\t * Create a new shared signal\n\t *\n\t * @param runtime - data store runtime the new shared signal belongs to\n\t * @param id - optional name of the shared signal\n\t * @returns newly create shared signal (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedSignalClass {\n\t\treturn runtime.createChannel(id, SharedSignalFactory.Type) as SharedSignalClass;\n\t}\n\n\t/**\n\t * Get a factory for SharedSignal to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedSignal\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new SharedSignalFactory();\n\t}\n\n\t/**\n\t * Constructs a new shared signal. If the object is non-local an id and service interfaces will\n\t * be provided\n\t * @param id - optional name of the shared signal\n\t * @param runtime - data store runtime the shared signal belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedSignal_\" /* telemetryContextPrefix */);\n\t}\n\n\t/**\n\t * Method used for generating a signal.\n\t */\n\tpublic notify(metadata?: T): void {\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISignalOperation<T> = {\n\t\t\ttype: \"signal\",\n\t\t\tmetadata,\n\t\t};\n\n\t\tthis.notifyCore(op, true);\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tprotected summarizeCore(_serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: JSON.stringify(\"\"),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\t/**\n\t * Load share signal from snapshot\n\t *\n\t * @param _storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(_storage: IChannelStorageService): Promise<void> {}\n\n\tprotected override initializeLocalCore(): void {}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Process a shared signal operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\tif ((message.type as MessageType) === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ISignalOperation<T>;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"signal\": {\n\t\t\t\t\tthis.notifyCore(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate notifyCore(op: ISignalOperation<T>, isLocal: boolean): void {\n\t\tthis.emit(\"notify\", op.metadata, isLocal);\n\t}\n\n\t// Nothing to roll back. Allowing other DDSs to handle rollback if necessary.\n\tpublic rollback(content: unknown, _localOpMetadata: unknown): void {\n\t\treturn;\n\t}\n\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst op = _content as ISignalOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase \"signal\": {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(op as never);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/internal.d.ts
CHANGED
package/legacy.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedArray.d.ts","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACX,YAAY,EACZ,kBAAkB,EAClB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAG3E,OAAO,KAAK,EACX,kBAAkB,EAClB,YAAY,EACZ,sBAAsB,EACtB,8BAA8B,EAI9B,MAAM,iBAAiB,CAAC;AAczB;;;;GAIG;AACH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,8BAA8B,CACrE,SAAQ,YAAY,CAAC,kBAAkB,CACvC,YAAW,YAAY,CAAC,CAAC,CAAC,EAAE,sBAAsB;IAElD;;OAEG;IACH,OAAO,CAAC,WAAW,CAAwB;IAE3C;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAmC;IAEhE;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,kCAAkC,CAAkC;IAErF;;;;;;OAMG;WACW,M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B,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,yBAAyB;IAIjC,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,eAAe;IAoBvB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAiBtB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,mDAAmD;IAgB3D,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,wBAAwB;IAiBhC;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAevB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAiBvB,OAAO,CAAC,mBAAmB;IAc3B,SAAS,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CA6DhD"}
|
package/lib/array/sharedArray.js
CHANGED
|
@@ -336,9 +336,32 @@ export class SharedArrayClass extends SharedObject {
|
|
|
336
336
|
this.emitValueChangedEvent(moveOp, true /* isLocal */);
|
|
337
337
|
break;
|
|
338
338
|
}
|
|
339
|
-
case OperationType.toggle:
|
|
339
|
+
case OperationType.toggle: {
|
|
340
|
+
const entryId = arrayOp.entryId;
|
|
341
|
+
const liveEntry = this.getLiveEntry(entryId);
|
|
342
|
+
const isDeleted = liveEntry.isDeleted;
|
|
343
|
+
// Toggling the isDeleted flag to undo the last operation for the skip list payload/value
|
|
344
|
+
liveEntry.isDeleted = !isDeleted;
|
|
345
|
+
liveEntry.isLocalPendingDelete -= 1;
|
|
346
|
+
const toggleOp = {
|
|
347
|
+
type: OperationType.toggle,
|
|
348
|
+
entryId,
|
|
349
|
+
isDeleted: liveEntry.isDeleted,
|
|
350
|
+
};
|
|
351
|
+
this.emitValueChangedEvent(toggleOp, true /* isLocal */);
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
340
354
|
case OperationType.toggleMove: {
|
|
341
|
-
|
|
355
|
+
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
356
|
+
this.getEntryForId(oldEntryId).isLocalPendingMove -= 1;
|
|
357
|
+
this.updateLiveEntry(oldEntryId, newEntryId);
|
|
358
|
+
const toggleMoveOp = {
|
|
359
|
+
type: OperationType.toggleMove,
|
|
360
|
+
entryId: newEntryId,
|
|
361
|
+
changedToEntryId: oldEntryId,
|
|
362
|
+
};
|
|
363
|
+
this.emitValueChangedEvent(toggleMoveOp, true /* isLocal */);
|
|
364
|
+
break;
|
|
342
365
|
}
|
|
343
366
|
default: {
|
|
344
367
|
unreachableCase(arrayOp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedArray.js","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAY9E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAE/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAWlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAQ7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAM,OAAO,gBACZ,SAAQ,YAAgC;IAyBxC;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CACnB,OAA+B,EAC/B,EAAW;QAEX,OAAO,OAAO,CAAC,aAAa,CAAC,EA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CAAC;QACD,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tSerializable,\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelFactory,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tISharedArrayEvents,\n\tISharedArray,\n\tISharedArrayRevertible,\n\tSerializableTypeForSharedArray,\n\tSharedArrayEntry,\n\tSnapshotFormat,\n\tSharedArrayEntryCore,\n} from \"./interfaces.js\";\nimport { SharedArrayFactory } from \"./sharedArrayFactory.js\";\nimport type {\n\tISharedArrayOperation,\n\tIDeleteOperation,\n\tIMoveOperation,\n\tIToggleMoveOperation,\n\tIToggleOperation,\n} from \"./sharedArrayOperations.js\";\nimport { OperationType } from \"./sharedArrayOperations.js\";\nimport { SharedArrayRevertible } from \"./sharedArrayRevertible.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared array that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedArrayClass<T extends SerializableTypeForSharedArray>\n\textends SharedObject<ISharedArrayEvents>\n\timplements ISharedArray<T>, ISharedArrayRevertible\n{\n\t/**\n\t * Stores the data held by this shared array.\n\t */\n\tprivate sharedArray: SharedArrayEntry<T>[];\n\n\t/**\n\t * Stores a map of entryid to entries of the sharedArray. This is meant of search optimizations and\n\t * so shouldn't be snapshotted.\n\t * Note: This map needs to be updated only when the sharedArray is being deserialized and when new entries are\n\t * being added. New entries are added upon insert ops and the second leg of the move op.\n\t * As we don't delete the entries once created, deletion or move to another position needs no special\n\t * handling for this data structure\n\t */\n\tprivate readonly idToEntryMap: Map<string, SharedArrayEntry<T>>;\n\n\t/**\n\t * Set of entry IDs that are marked for deletion by remote clients, but have local pending deletes.\n\t * Used to prevent resuscitating entries while rolling back a delete operation.\n\t * We should not rollback to life an entry that was deleted by remote clients.\n\t */\n\tprivate readonly remoteDeleteWithLocalPendingDelete: Set<string> = new Set<string>();\n\n\t/**\n\t * Create a new shared array\n\t *\n\t * @param runtime - data store runtime the new shared array belongs to\n\t * @param id - optional name of the shared array\n\t * @returns newly create shared array (but not attached yet)\n\t */\n\tpublic static create<T extends SerializableTypeForSharedArray>(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid?: string,\n\t): SharedArrayClass<T> {\n\t\treturn runtime.createChannel(id, SharedArrayFactory.Type) as SharedArrayClass<T>;\n\t}\n\n\t/**\n\t * Get a factory for SharedArray to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedArray\n\t */\n\tpublic static getFactory<T extends SerializableTypeForSharedArray>(): IChannelFactory {\n\t\treturn new SharedArrayFactory<T>();\n\t}\n\n\t/**\n\t * Constructs a new shared array. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param id - optional name of the shared array\n\t * @param runtime - data store runtime the shared array belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedArray_\" /* telemetryContextPrefix */);\n\t\tthis.sharedArray = [];\n\t\tthis.idToEntryMap = new Map<string, SharedArrayEntry<T>>();\n\t}\n\n\t/**\n\t * Method that returns the ordered list of the items held in the DDS at this point in time.\n\t * Note: This is only a snapshot of the array\n\t */\n\tpublic get(): readonly T[] {\n\t\treturn this.sharedArray.filter((item) => !item.isDeleted).map((entry) => entry.value);\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Deep copy and unset the local flags. Needed when snapshotting is happening for runtime not attached\n\t\tconst dataArrayCopy: SharedArrayEntryCore<T>[] = [];\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tdataArrayCopy.push({\n\t\t\t\tentryId: entry.entryId,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tvalue: JSON.parse(serializer.stringify(entry.value, this.handle)),\n\t\t\t\tisDeleted: entry.isDeleted,\n\t\t\t\tprevEntryId: entry.prevEntryId,\n\t\t\t\tnextEntryId: entry.nextEntryId,\n\t\t\t});\n\t\t}\n\n\t\t// We are snapshotting current client data so autoacking pending local.\n\t\t// Assumption : This should happen only for offline client creating the array. All other scenarios should\n\t\t// get to MSN - where there can be no local pending possible.\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t\tconst contents: SnapshotFormat<SharedArrayEntryCore<T>> = {\n\t\t\tdataArray: dataArrayCopy,\n\t\t};\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: serializer.stringify(contents, this.handle),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\tpublic insertBulkAfter<TWrite>(\n\t\tref: T | undefined,\n\t\tvalues: (Serializable<TWrite> & T)[],\n\t): void {\n\t\tlet itemIndex: number = 0;\n\n\t\tif (ref !== undefined) {\n\t\t\tfor (itemIndex = this.sharedArray.length - 1; itemIndex > 0; itemIndex -= 1) {\n\t\t\t\tconst item = this.sharedArray[itemIndex];\n\t\t\t\tif (item && !item.isDeleted && item.value === ref) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add one since we're inserting it after this rowId. If rowId is not found, we will get -1, which after\n\t\t\t// adding one, will be 0, which will place the new rows at the right place too\n\t\t\titemIndex += 1;\n\t\t}\n\n\t\t// Insert new elements\n\t\tfor (const value of values) {\n\t\t\tthis.insertCore(itemIndex, value);\n\t\t\titemIndex += 1;\n\t\t}\n\t}\n\n\tpublic insert<TWrite>(index: number, value: Serializable<TWrite> & T): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Insertion index provided is less than 0.\");\n\t\t}\n\t\tthis.insertCore(this.findInternalInsertionIndex(index), value);\n\t}\n\n\tprivate insertCore<TWrite>(indexInternal: number, value: Serializable<TWrite> & T): void {\n\t\tconst insertAfterEntryId =\n\t\t\tindexInternal >= 1 ? this.sharedArray[indexInternal - 1]?.entryId : undefined;\n\t\tconst newEntryId = this.createAddEntry(indexInternal, value);\n\n\t\tconst op = {\n\t\t\ttype: OperationType.insertEntry,\n\t\t\tentryId: newEntryId,\n\t\t\tvalue,\n\t\t\tinsertAfterEntryId,\n\t\t};\n\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic delete(index: number): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Deletion index provided is less than 0.\");\n\t\t}\n\n\t\tconst indexInternal: number = this.findInternalDeletionIndex(index);\n\n\t\tconst entry = this.sharedArray[indexInternal];\n\t\tassert(entry !== undefined, 0xb90 /* Invalid index */);\n\t\tconst entryId = entry.entryId;\n\t\tthis.deleteCore(indexInternal);\n\n\t\tconst op: IDeleteOperation = {\n\t\t\ttype: OperationType.deleteEntry,\n\t\t\tentryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rearrangeToFront(values: T[]): void {\n\t\tfor (let toIndex = 0; toIndex < values.length; toIndex += 1) {\n\t\t\tconst value = values[toIndex];\n\t\t\t// Can skip searching first <toIndex> indices, as they contain elements we already moved.\n\t\t\tfor (let fromIndex = toIndex; fromIndex < this.sharedArray.length; fromIndex += 1) {\n\t\t\t\tconst item = this.sharedArray[fromIndex];\n\t\t\t\tassert(item !== undefined, 0xb91 /* Invalid index */);\n\t\t\t\tif (item.value !== value) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!item.isDeleted &&\n\t\t\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\t\t\tfromIndex !== toIndex &&\n\t\t\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\t\t\ttoIndex !== fromIndex + 1\n\t\t\t\t) {\n\t\t\t\t\tthis.moveCore(fromIndex, toIndex);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Moves the DDS entry from one index to another\n\t *\n\t * @param fromIndex - User index of the element to be moved\n\t * @param toIndex - User index to which the element should move to\n\t */\n\tpublic move(fromIndex: number, toIndex: number): void {\n\t\tif (fromIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: fromIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (toIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: toIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (\n\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\tfromIndex === toIndex ||\n\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\ttoIndex === fromIndex + 1\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst fromIndexInternal: number = this.findInternalDeletionIndex(fromIndex);\n\t\tconst toIndexInternal: number = this.findInternalInsertionIndex(toIndex);\n\n\t\tthis.moveCore(fromIndexInternal, toIndexInternal);\n\t}\n\n\tprivate moveCore(fromIndexInternal: number, toIndexInternal: number): void {\n\t\tconst insertAfterEntryId =\n\t\t\ttoIndexInternal >= 1 ? this.sharedArray[toIndexInternal - 1]?.entryId : undefined;\n\t\tconst entryId = this.sharedArray[fromIndexInternal]?.entryId;\n\t\tassert(entryId !== undefined, 0xb92 /* Invalid index */);\n\t\tconst changedToEntryId = this.createMoveEntry(fromIndexInternal, toIndexInternal);\n\n\t\tconst op: IMoveOperation = {\n\t\t\ttype: OperationType.moveEntry,\n\t\t\tentryId,\n\t\t\tinsertAfterEntryId,\n\t\t\tchangedToEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\t/**\n\t * Method used to do undo/redo operation for the given entry id. This method is\n\t * used for undo/redo of only insert and delete operations. Move operation is NOT handled\n\t * by this method\n\t *\n\t * @param entryId - Entry Id for which the the undo/redo operation is to be applied\n\t */\n\tpublic toggle(entryId: string): void {\n\t\tconst liveEntry = this.getLiveEntry(entryId);\n\t\tconst isDeleted = !liveEntry.isDeleted;\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(entryId).isLocalPendingDelete += 1;\n\n\t\t// Toggling the isDeleted flag to undo the last operation for the skip list payload/value\n\t\tliveEntry.isDeleted = isDeleted;\n\n\t\tconst op: IToggleOperation = {\n\t\t\ttype: OperationType.toggle,\n\t\t\tentryId,\n\t\t\tisDeleted,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\t/**\n\t * Method to do undo/redo of move operation. All entries of the same payload/value are stored\n\t * in the same doubly linked skip list. This skip list is updated upon every move by adding the\n\t * new location as a new entry in the skip list and update the isDeleted flag to indicate the new\n\t * entry is the cuurent live location for the user.\n\t *\n\t * @param oldEntryId - EntryId of the last live entry\n\t * @param newEntryId - EntryId of the to be live entry\n\t */\n\tpublic toggleMove(oldEntryId: string, newEntryId: string): void {\n\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(oldEntryId).isLocalPendingMove += 1;\n\n\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\n\t\tconst op: IToggleMoveOperation = {\n\t\t\ttype: OperationType.toggleMove,\n\t\t\tentryId: oldEntryId,\n\t\t\tchangedToEntryId: newEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rollback(op: unknown, _localOpMetadata: unknown): void {\n\t\tconst arrayOp = op as ISharedArrayOperation<T>;\n\t\tswitch (arrayOp.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\tliveEntry.isDeleted = true;\n\t\t\t\tconst deleteOp: IDeleteOperation = {\n\t\t\t\t\ttype: OperationType.deleteEntry,\n\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(deleteOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tif (this.remoteDeleteWithLocalPendingDelete.has(arrayOp.entryId)) {\n\t\t\t\t\t// If remote already deleted the entry, we should not resurrect it.\n\t\t\t\t\t// Just remove the local pending delete.\n\t\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(arrayOp.entryId);\n\t\t\t\t} else {\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\t\tliveEntry.isDeleted = false;\n\t\t\t\t\tconst insertOp = {\n\t\t\t\t\t\ttype: OperationType.insertEntry,\n\t\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t\t\tvalue: liveEntry.value,\n\t\t\t\t\t};\n\t\t\t\t\tthis.emitValueChangedEvent(insertOp, true /* isLocal */);\n\t\t\t\t\tconst entry = this.getEntryForId(arrayOp.entryId);\n\t\t\t\t\tif (entry !== undefined && entry.isLocalPendingDelete > 0) {\n\t\t\t\t\t\tentry.isLocalPendingDelete -= 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;\n\t\t\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\t\t\t\tconst inputEntry = this.getEntryForId(oldEntryId);\n\t\t\t\tinputEntry.prevEntryId = undefined;\n\t\t\t\tinputEntry.nextEntryId = undefined;\n\t\t\t\tinputEntry.isLocalPendingMove = 0;\n\t\t\t\tconst moveOp: IMoveOperation = {\n\t\t\t\t\ttype: OperationType.moveEntry,\n\t\t\t\t\tentryId: newEntryId,\n\t\t\t\t\tchangedToEntryId: oldEntryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(moveOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle:\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tthrow new Error(`Rollback not implemented for ${arrayOp.type} operations`);\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(arrayOp);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Load share array from snapshot\n\t *\n\t * @param storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst header = await storage.readBlob(snapshotFileName);\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\tconst utf8 = new TextDecoder(\"utf-8\").decode(header);\n\t\t// Note: IFluidSerializer.parse() doesn't guarantee any typing; the explicit typing here is based on this code's\n\t\t// knowledge of what it is deserializing.\n\t\tconst deserializedSharedArray = this.serializer.parse(utf8) as {\n\t\t\tdataArray: SharedArrayEntry<T>[];\n\t\t};\n\t\tthis.sharedArray = deserializedSharedArray.dataArray;\n\t\t// Initializing the idToEntryMap optimizer data set\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.idToEntryMap.set(entry.entryId, entry);\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Tracks the doubly linked skip list for the given entry to identify local pending counter attribute.\n\t * It signifies if a local pending operation exists for the payload/value being tracked in the skip list\n\t *\n\t * returns true if counterAttribute's count \\> 0\n\t * @param entryId - id for which counter attribute is to be tracked in chian.\n\t * @param counterAttribute - flag or property name from SharedArrayEntry whose counter is to be tracked.\n\t */\n\tprivate isLocalPending(\n\t\tentryId: string,\n\t\tcounterAttribute: keyof SharedArrayEntry<T>,\n\t): boolean {\n\t\tconst getCounterAttributeValue = (\n\t\t\tentry: SharedArrayEntry<T>,\n\t\t\tcounterAttr: keyof SharedArrayEntry<T>,\n\t\t): number => {\n\t\t\treturn entry[counterAttr] as number;\n\t\t};\n\n\t\tconst inputEntry = this.getEntryForId(entryId);\n\t\tlet prevEntryId = inputEntry.prevEntryId;\n\t\tlet nextEntryId = inputEntry.nextEntryId;\n\t\tif (getCounterAttributeValue(inputEntry, counterAttribute) > 0) {\n\t\t\treturn true;\n\t\t}\n\t\t// track back in chain\n\t\twhile (prevEntryId !== undefined && prevEntryId) {\n\t\t\tconst prevEntry = this.getEntryForId(prevEntryId);\n\t\t\tif (getCounterAttributeValue(prevEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tprevEntryId = prevEntry.prevEntryId;\n\t\t}\n\n\t\t// track forward in the chain\n\t\twhile (nextEntryId !== undefined && nextEntryId) {\n\t\t\tconst nextEntry = this.getEntryForId(nextEntryId);\n\t\t\tif (getCounterAttributeValue(nextEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tnextEntryId = nextEntry.nextEntryId;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate getEntryForId(entryId: string): SharedArrayEntry<T> {\n\t\treturn this.idToEntryMap.get(entryId) as SharedArrayEntry<T>;\n\t}\n\n\t/**\n\t * Process a shared array operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ISharedArrayOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase OperationType.insertEntry: {\n\t\t\t\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\t\t\t\top.entryId,\n\t\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t\top.value,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\t\tthis.handleDeleteOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.moveEntry: {\n\t\t\t\t\tthis.handleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggle: {\n\t\t\t\t\tthis.handleToggleOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggleMove: {\n\t\t\t\t\tthis.handleToggleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!local) {\n\t\t\t\tthis.emitValueChangedEvent(op, local);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleInsertOp<TWrite>(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tlocal: boolean,\n\t\tvalue: Serializable<TWrite> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (local) {\n\t\t\tthis.getEntryForId(entryId).isAckPending = false;\n\t\t} else {\n\t\t\tif (insertAfterEntryId !== undefined) {\n\t\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t\t}\n\t\t\tconst newEntry = this.createNewEntry(entryId, value);\n\t\t\tnewEntry.isAckPending = false;\n\t\t\tthis.addEntry(this.getInternalInsertIndexByIgnoringLocalPendingInserts(index), newEntry);\n\t\t}\n\t}\n\n\tprivate handleDeleteOp(op: IDeleteOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// Decrementing local pending counter as op is already applied to local state\n\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(op.entryId);\n\t\t} else {\n\t\t\tif (this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.add(op.entryId);\n\t\t\t} else {\n\t\t\t\t// last element in skip list is the most recent and live entry, so marking it deleted\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleMoveOp(op: IMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\top.changedToEntryId,\n\t\t\top.insertAfterEntryId,\n\t\t\tlocal,\n\t\t\topEntry.value,\n\t\t);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t} else {\n\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t// If local pending then simply mark the new location dead as finally the local op will win\n\t\t\tif (\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t) {\n\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t} else {\n\t\t\t\t// move the element\n\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\tif (isDeleted) {\n\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleOp(op: IToggleOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending delete op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingDelete) {\n\t\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleMoveOp(op: IToggleMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingMove) {\n\t\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t\t}\n\t\t} else if (\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingDelete\") &&\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t) {\n\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t}\n\t}\n\n\tprivate findInternalIndex(countEntries: number): number {\n\t\tif (countEntries < 0) {\n\t\t\tthrow new Error(\"Input count is zero\");\n\t\t}\n\n\t\tlet countDown = countEntries;\n\t\tlet entriesIterator = 0;\n\t\tfor (; entriesIterator < this.sharedArray.length; entriesIterator = entriesIterator + 1) {\n\t\t\tconst entry = this.sharedArray[entriesIterator];\n\t\t\tassert(entry !== undefined, 0xb93 /* Invalid index */);\n\t\t\tif (entry.isDeleted === false) {\n\t\t\t\tif (countDown === 0) {\n\t\t\t\t\treturn entriesIterator;\n\t\t\t\t}\n\t\t\t\tcountDown = countDown - 1;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Count of live entries is less than required`);\n\t}\n\n\tprivate findInternalInsertionIndex(index: number): number {\n\t\treturn index === 0 ? index : this.findInternalIndex(index - 1) + 1;\n\t}\n\n\tprivate findInternalDeletionIndex(index: number): number {\n\t\treturn this.findInternalIndex(index);\n\t}\n\n\tprivate createAddEntry<TWrite>(index: number, value: Serializable<TWrite> & T): string {\n\t\tconst newEntry = this.createNewEntry(uuid(), value);\n\t\tthis.addEntry(index, newEntry);\n\t\treturn newEntry.entryId;\n\t}\n\n\tprivate addEntry(insertIndex: number, newEntry: SharedArrayEntry<T>): void {\n\t\t// in scenario where we populate 100K rows, we insert them all at the end of array.\n\t\t// slicing array is way slower than pushing elements.\n\t\tif (insertIndex === this.sharedArray.length) {\n\t\t\tthis.sharedArray.push(newEntry);\n\t\t} else {\n\t\t\tthis.sharedArray.splice(insertIndex, 0 /* deleteCount */, newEntry);\n\t\t}\n\n\t\t// Updating the idToEntryMap optimizer data set as new entry has been added\n\t\tthis.idToEntryMap.set(newEntry.entryId, newEntry);\n\t}\n\n\tprivate emitValueChangedEvent(op: ISharedArrayOperation, isLocal: boolean): void {\n\t\tthis.emit(\"valueChanged\", op, isLocal, this);\n\t}\n\n\tprivate emitRevertibleEvent(op: ISharedArrayOperation): void {\n\t\tconst revertible = new SharedArrayRevertible(this, op);\n\t\tthis.emit(\"revertible\", revertible);\n\t}\n\n\tprivate deleteCore(index: number): void {\n\t\tconst entry = this.sharedArray[index];\n\t\tassert(entry !== undefined, 0xb94 /* Invalid index */);\n\n\t\tif (entry.isDeleted) {\n\t\t\tthrow new Error(\"Entry already deleted.\");\n\t\t}\n\t\tentry.isDeleted = true;\n\n\t\t// Adding local pending counter\n\t\tentry.isLocalPendingDelete += 1;\n\t}\n\n\tprivate createMoveEntry(oldIndex: number, newIndex: number): string {\n\t\tconst oldEntry = this.sharedArray[oldIndex];\n\t\tassert(oldEntry !== undefined, 0xb95 /* Invalid index */);\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(\n\t\t\tuuid(),\n\t\t\toldEntry.value,\n\t\t\toldEntry.entryId,\n\t\t);\n\n\t\toldEntry.isDeleted = true;\n\t\toldEntry.nextEntryId = newEntry.entryId;\n\n\t\t// Adding local pending counter\n\t\toldEntry.isLocalPendingMove += 1;\n\n\t\tthis.addEntry(newIndex /* insertIndex */, newEntry);\n\n\t\treturn newEntry.entryId;\n\t}\n\n\t/**\n\t * Creates new entry of type SharedArrayEntry interface.\n\t * @param entryId - id for which new entry is created\n\t * @param value - value for the new entry\n\t * @param prevEntryId - prevEntryId if exists to update the previous pointer of double ended linked list\n\t */\n\tprivate createNewEntry<TWrite>(\n\t\tentryId: string,\n\t\tvalue: Serializable<TWrite> & T,\n\t\tprevEntryId?: string,\n\t): SharedArrayEntry<T> {\n\t\treturn {\n\t\t\tentryId,\n\t\t\tvalue,\n\t\t\tisAckPending: true,\n\t\t\tisDeleted: false,\n\t\t\tprevEntryId,\n\t\t\tnextEntryId: undefined,\n\t\t\tisLocalPendingDelete: 0,\n\t\t\tisLocalPendingMove: 0,\n\t\t};\n\t}\n\n\t/**\n\t * Unsets all local flags used by the DDS. This method can be used after reading from snapshott to ensure\n\t * local flags are initialized for use by the DDS.\n\t * @param entry - Entry for which the local flags have to be cleaned up\n\t */\n\tprivate unsetLocalFlags(entry: SharedArrayEntry<T>): void {\n\t\tentry.isAckPending = false;\n\t\tentry.isLocalPendingDelete = 0;\n\t\tentry.isLocalPendingMove = 0;\n\t}\n\n\t/**\n\t * Returns the index of the first entry starting with startIndex that does not have the isAckPending flag\n\t */\n\tprivate getInternalInsertIndexByIgnoringLocalPendingInserts(startIndex: number): number {\n\t\tlet localOpsIterator = startIndex;\n\t\tfor (\n\t\t\t;\n\t\t\tlocalOpsIterator < this.sharedArray.length;\n\t\t\tlocalOpsIterator = localOpsIterator + 1\n\t\t) {\n\t\t\tconst entry = this.sharedArray[localOpsIterator];\n\t\t\tassert(entry !== undefined, 0xb96 /* Invalid index */);\n\t\t\tif (!entry.isAckPending) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn localOpsIterator;\n\t}\n\n\tprivate findIndexOfEntryId(entryId: string | undefined): number {\n\t\tfor (let index = 0; index < this.sharedArray.length; index = index + 1) {\n\t\t\tif (this.sharedArray[index]?.entryId === entryId) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n\tprivate prepareToMakeEntryIdLive(entry: SharedArrayEntry<T>): void {\n\t\tconst prevIndex = this.findIndexOfEntryId(entry.prevEntryId);\n\t\tconst nextIndex = this.findIndexOfEntryId(entry.nextEntryId);\n\t\tif (prevIndex !== -1) {\n\t\t\tconst prevEntry = this.sharedArray[prevIndex];\n\t\t\tassert(prevEntry !== undefined, 0xb97 /* Invalid index */);\n\t\t\tprevEntry.nextEntryId = entry.nextEntryId;\n\t\t}\n\t\tif (nextIndex !== -1) {\n\t\t\tconst nextEntry = this.sharedArray[nextIndex];\n\t\t\tassert(nextEntry !== undefined, 0xb98 /* Invalid index */);\n\t\t\tnextEntry.prevEntryId = entry.prevEntryId;\n\t\t}\n\t\tentry.prevEntryId = undefined;\n\t\tentry.nextEntryId = undefined;\n\t}\n\n\t/**\n\t * Method that returns the live entry.\n\t * The shared array internally can store a skip list of all related entries which got created\n\t * due to move operations for the same payload/value. However, all elements except for one element\n\t * can have isDeleted flag as false indicating this is the live entry for the value.\n\t * Current implementation ensures that the last element in the skip list of entries is the liveEntry/\n\t * last live entry\n\t *\n\t * @param entryId - Entry id of any node in the skip list for the same payload/value\n\t */\n\tprivate getLiveEntry(entryId: string): SharedArrayEntry<T> {\n\t\tlet liveEntry = this.getEntryForId(entryId);\n\t\twhile (liveEntry.nextEntryId !== undefined && liveEntry.nextEntryId) {\n\t\t\tliveEntry = this.getEntryForId(liveEntry.nextEntryId);\n\t\t}\n\t\treturn liveEntry;\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps us keep track of the current position of an entry.value by marking the entry\n\t * at previous position deleted and appending the entry at the new position at the end of the double linked\n\t * list for that entry.value.\n\t */\n\tprivate updateLiveEntry(oldLiveEntryEntryId: string, newLiveEntryEntryId: string): void {\n\t\tconst oldLiveEntry = this.getEntryForId(oldLiveEntryEntryId);\n\t\tconst newLiveEntry = this.getEntryForId(newLiveEntryEntryId);\n\t\tif (oldLiveEntryEntryId === newLiveEntryEntryId) {\n\t\t\toldLiveEntry.isDeleted = false;\n\t\t} else {\n\t\t\tthis.prepareToMakeEntryIdLive(newLiveEntry);\n\t\t\t// Make entryId live\n\t\t\toldLiveEntry.nextEntryId = newLiveEntryEntryId;\n\t\t\tnewLiveEntry.prevEntryId = oldLiveEntryEntryId;\n\t\t\tnewLiveEntry.isDeleted = false;\n\t\t\toldLiveEntry.isDeleted = true;\n\t\t}\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps to insert the new entry as dead entry and reconnecting the double linked list with\n\t * existingEntry -\\> deadeEntry(appended) -\\> existing chain(if any).\n\t */\n\tprivate updateDeadEntry(existingEntryId: string, deadEntryId: string): void {\n\t\tconst existingEntry = this.getEntryForId(existingEntryId);\n\t\tconst deadEntry = this.getEntryForId(deadEntryId);\n\n\t\t// update dead entry's next to existingEntry's next, if existingEntry's next entry exists.\n\t\t// It can be undefined if the exiting element is the last element (or only element) of chain.\n\t\tif (existingEntry.nextEntryId !== undefined) {\n\t\t\tdeadEntry.nextEntryId = existingEntry.nextEntryId;\n\t\t\tthis.getEntryForId(existingEntry.nextEntryId).prevEntryId = deadEntryId;\n\t\t}\n\n\t\t// update current entry's next pointer to dead entry and vice versa.\n\t\texistingEntry.nextEntryId = deadEntryId;\n\t\tdeadEntry.prevEntryId = existingEntryId;\n\t\tdeadEntry.isDeleted = true;\n\t}\n\n\tprivate handleStashedInsert(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tvalue: Serializable<SerializableTypeForSharedArray> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (insertAfterEntryId !== undefined) {\n\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t}\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(entryId, value);\n\t\tnewEntry.isAckPending = true;\n\t\tthis.addEntry(index, newEntry);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as ISharedArrayOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.entryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\top.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.changedToEntryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\topEntry.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\n\t\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t\tif (\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t\t) {\n\t\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t\t} else {\n\t\t\t\t\t// move the element\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\t\tif (isDeleted) {\n\t\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnewElement.isLocalPendingMove += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingMove += 1;\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\tthis.submitLocalMessage(op);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedArray.js","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAY9E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAE/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAWlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAQ7D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAM,OAAO,gBACZ,SAAQ,YAAgC;IAyBxC;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CACnB,OAA+B,EAC/B,EAAW;QAEX,OAAO,OAAO,CAAC,aAAa,CAA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AS,CAAC;oBACtC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;oBAC3D,mFAAmF;oBACnF,IAAI,SAAS,EAAE,CAAC;wBACf,UAAU,CAAC,SAAS,GAAG,SAAS,CAAC;oBAClC,CAAC;gBACF,CAAC;gBACD,UAAU,CAAC,kBAAkB,IAAI,CAAC,CAAC;gBACnC,MAAM;YACP,CAAC;YACD,KAAK,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC3B,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,CAAC;gBACvD,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,oBAAoB,IAAI,CAAC,CAAC;gBACzD,MAAM;YACP,CAAC;YACD,KAAK,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC/B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;gBACxE,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,kBAAkB,IAAI,CAAC,CAAC;gBACvD,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,eAAe,CAAC,EAAE,CAAC,CAAC;YACrB,CAAC;QACF,CAAC;QACD,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tSerializable,\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelFactory,\n\tIChannelStorageService,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport type {\n\tISharedArrayEvents,\n\tISharedArray,\n\tISharedArrayRevertible,\n\tSerializableTypeForSharedArray,\n\tSharedArrayEntry,\n\tSnapshotFormat,\n\tSharedArrayEntryCore,\n} from \"./interfaces.js\";\nimport { SharedArrayFactory } from \"./sharedArrayFactory.js\";\nimport type {\n\tISharedArrayOperation,\n\tIDeleteOperation,\n\tIMoveOperation,\n\tIToggleMoveOperation,\n\tIToggleOperation,\n} from \"./sharedArrayOperations.js\";\nimport { OperationType } from \"./sharedArrayOperations.js\";\nimport { SharedArrayRevertible } from \"./sharedArrayRevertible.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared array that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedArrayClass<T extends SerializableTypeForSharedArray>\n\textends SharedObject<ISharedArrayEvents>\n\timplements ISharedArray<T>, ISharedArrayRevertible\n{\n\t/**\n\t * Stores the data held by this shared array.\n\t */\n\tprivate sharedArray: SharedArrayEntry<T>[];\n\n\t/**\n\t * Stores a map of entryid to entries of the sharedArray. This is meant of search optimizations and\n\t * so shouldn't be snapshotted.\n\t * Note: This map needs to be updated only when the sharedArray is being deserialized and when new entries are\n\t * being added. New entries are added upon insert ops and the second leg of the move op.\n\t * As we don't delete the entries once created, deletion or move to another position needs no special\n\t * handling for this data structure\n\t */\n\tprivate readonly idToEntryMap: Map<string, SharedArrayEntry<T>>;\n\n\t/**\n\t * Set of entry IDs that are marked for deletion by remote clients, but have local pending deletes.\n\t * Used to prevent resuscitating entries while rolling back a delete operation.\n\t * We should not rollback to life an entry that was deleted by remote clients.\n\t */\n\tprivate readonly remoteDeleteWithLocalPendingDelete: Set<string> = new Set<string>();\n\n\t/**\n\t * Create a new shared array\n\t *\n\t * @param runtime - data store runtime the new shared array belongs to\n\t * @param id - optional name of the shared array\n\t * @returns newly create shared array (but not attached yet)\n\t */\n\tpublic static create<T extends SerializableTypeForSharedArray>(\n\t\truntime: IFluidDataStoreRuntime,\n\t\tid?: string,\n\t): SharedArrayClass<T> {\n\t\treturn runtime.createChannel(id, SharedArrayFactory.Type) as SharedArrayClass<T>;\n\t}\n\n\t/**\n\t * Get a factory for SharedArray to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedArray\n\t */\n\tpublic static getFactory<T extends SerializableTypeForSharedArray>(): IChannelFactory {\n\t\treturn new SharedArrayFactory<T>();\n\t}\n\n\t/**\n\t * Constructs a new shared array. If the object is non-local an id and service interfaces will\n\t * be provided\n\t *\n\t * @param id - optional name of the shared array\n\t * @param runtime - data store runtime the shared array belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedArray_\" /* telemetryContextPrefix */);\n\t\tthis.sharedArray = [];\n\t\tthis.idToEntryMap = new Map<string, SharedArrayEntry<T>>();\n\t}\n\n\t/**\n\t * Method that returns the ordered list of the items held in the DDS at this point in time.\n\t * Note: This is only a snapshot of the array\n\t */\n\tpublic get(): readonly T[] {\n\t\treturn this.sharedArray.filter((item) => !item.isDeleted).map((entry) => entry.value);\n\t}\n\n\tprotected summarizeCore(serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\t// Deep copy and unset the local flags. Needed when snapshotting is happening for runtime not attached\n\t\tconst dataArrayCopy: SharedArrayEntryCore<T>[] = [];\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tdataArrayCopy.push({\n\t\t\t\tentryId: entry.entryId,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tvalue: JSON.parse(serializer.stringify(entry.value, this.handle)),\n\t\t\t\tisDeleted: entry.isDeleted,\n\t\t\t\tprevEntryId: entry.prevEntryId,\n\t\t\t\tnextEntryId: entry.nextEntryId,\n\t\t\t});\n\t\t}\n\n\t\t// We are snapshotting current client data so autoacking pending local.\n\t\t// Assumption : This should happen only for offline client creating the array. All other scenarios should\n\t\t// get to MSN - where there can be no local pending possible.\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t\tconst contents: SnapshotFormat<SharedArrayEntryCore<T>> = {\n\t\t\tdataArray: dataArrayCopy,\n\t\t};\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: serializer.stringify(contents, this.handle),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\tpublic insertBulkAfter<TWrite>(\n\t\tref: T | undefined,\n\t\tvalues: (Serializable<TWrite> & T)[],\n\t): void {\n\t\tlet itemIndex: number = 0;\n\n\t\tif (ref !== undefined) {\n\t\t\tfor (itemIndex = this.sharedArray.length - 1; itemIndex > 0; itemIndex -= 1) {\n\t\t\t\tconst item = this.sharedArray[itemIndex];\n\t\t\t\tif (item && !item.isDeleted && item.value === ref) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Add one since we're inserting it after this rowId. If rowId is not found, we will get -1, which after\n\t\t\t// adding one, will be 0, which will place the new rows at the right place too\n\t\t\titemIndex += 1;\n\t\t}\n\n\t\t// Insert new elements\n\t\tfor (const value of values) {\n\t\t\tthis.insertCore(itemIndex, value);\n\t\t\titemIndex += 1;\n\t\t}\n\t}\n\n\tpublic insert<TWrite>(index: number, value: Serializable<TWrite> & T): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Insertion index provided is less than 0.\");\n\t\t}\n\t\tthis.insertCore(this.findInternalInsertionIndex(index), value);\n\t}\n\n\tprivate insertCore<TWrite>(indexInternal: number, value: Serializable<TWrite> & T): void {\n\t\tconst insertAfterEntryId =\n\t\t\tindexInternal >= 1 ? this.sharedArray[indexInternal - 1]?.entryId : undefined;\n\t\tconst newEntryId = this.createAddEntry(indexInternal, value);\n\n\t\tconst op = {\n\t\t\ttype: OperationType.insertEntry,\n\t\t\tentryId: newEntryId,\n\t\t\tvalue,\n\t\t\tinsertAfterEntryId,\n\t\t};\n\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic delete(index: number): void {\n\t\tif (index < 0) {\n\t\t\tthrow new Error(\"Invalid input: Deletion index provided is less than 0.\");\n\t\t}\n\n\t\tconst indexInternal: number = this.findInternalDeletionIndex(index);\n\n\t\tconst entry = this.sharedArray[indexInternal];\n\t\tassert(entry !== undefined, 0xb90 /* Invalid index */);\n\t\tconst entryId = entry.entryId;\n\t\tthis.deleteCore(indexInternal);\n\n\t\tconst op: IDeleteOperation = {\n\t\t\ttype: OperationType.deleteEntry,\n\t\t\tentryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rearrangeToFront(values: T[]): void {\n\t\tfor (let toIndex = 0; toIndex < values.length; toIndex += 1) {\n\t\t\tconst value = values[toIndex];\n\t\t\t// Can skip searching first <toIndex> indices, as they contain elements we already moved.\n\t\t\tfor (let fromIndex = toIndex; fromIndex < this.sharedArray.length; fromIndex += 1) {\n\t\t\t\tconst item = this.sharedArray[fromIndex];\n\t\t\t\tassert(item !== undefined, 0xb91 /* Invalid index */);\n\t\t\t\tif (item.value !== value) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\t!item.isDeleted &&\n\t\t\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\t\t\tfromIndex !== toIndex &&\n\t\t\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\t\t\ttoIndex !== fromIndex + 1\n\t\t\t\t) {\n\t\t\t\t\tthis.moveCore(fromIndex, toIndex);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Moves the DDS entry from one index to another\n\t *\n\t * @param fromIndex - User index of the element to be moved\n\t * @param toIndex - User index to which the element should move to\n\t */\n\tpublic move(fromIndex: number, toIndex: number): void {\n\t\tif (fromIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: fromIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (toIndex < 0) {\n\t\t\tthrow new Error(\"Invalid input: toIndex value provided is less than 0\");\n\t\t}\n\n\t\tif (\n\t\t\t// Moving to and from the same index makes no sense, so noOp\n\t\t\tfromIndex === toIndex ||\n\t\t\t// Moving the same entry from current location to its immediate next makes no sense so noOp\n\t\t\ttoIndex === fromIndex + 1\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst fromIndexInternal: number = this.findInternalDeletionIndex(fromIndex);\n\t\tconst toIndexInternal: number = this.findInternalInsertionIndex(toIndex);\n\n\t\tthis.moveCore(fromIndexInternal, toIndexInternal);\n\t}\n\n\tprivate moveCore(fromIndexInternal: number, toIndexInternal: number): void {\n\t\tconst insertAfterEntryId =\n\t\t\ttoIndexInternal >= 1 ? this.sharedArray[toIndexInternal - 1]?.entryId : undefined;\n\t\tconst entryId = this.sharedArray[fromIndexInternal]?.entryId;\n\t\tassert(entryId !== undefined, 0xb92 /* Invalid index */);\n\t\tconst changedToEntryId = this.createMoveEntry(fromIndexInternal, toIndexInternal);\n\n\t\tconst op: IMoveOperation = {\n\t\t\ttype: OperationType.moveEntry,\n\t\t\tentryId,\n\t\t\tinsertAfterEntryId,\n\t\t\tchangedToEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\t/**\n\t * Method used to do undo/redo operation for the given entry id. This method is\n\t * used for undo/redo of only insert and delete operations. Move operation is NOT handled\n\t * by this method\n\t *\n\t * @param entryId - Entry Id for which the the undo/redo operation is to be applied\n\t */\n\tpublic toggle(entryId: string): void {\n\t\tconst liveEntry = this.getLiveEntry(entryId);\n\t\tconst isDeleted = !liveEntry.isDeleted;\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(entryId).isLocalPendingDelete += 1;\n\n\t\t// Toggling the isDeleted flag to undo the last operation for the skip list payload/value\n\t\tliveEntry.isDeleted = isDeleted;\n\n\t\tconst op: IToggleOperation = {\n\t\t\ttype: OperationType.toggle,\n\t\t\tentryId,\n\t\t\tisDeleted,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\t/**\n\t * Method to do undo/redo of move operation. All entries of the same payload/value are stored\n\t * in the same doubly linked skip list. This skip list is updated upon every move by adding the\n\t * new location as a new entry in the skip list and update the isDeleted flag to indicate the new\n\t * entry is the cuurent live location for the user.\n\t *\n\t * @param oldEntryId - EntryId of the last live entry\n\t * @param newEntryId - EntryId of the to be live entry\n\t */\n\tpublic toggleMove(oldEntryId: string, newEntryId: string): void {\n\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Adding local pending counter\n\t\tthis.getEntryForId(oldEntryId).isLocalPendingMove += 1;\n\n\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\n\t\tconst op: IToggleMoveOperation = {\n\t\t\ttype: OperationType.toggleMove,\n\t\t\tentryId: oldEntryId,\n\t\t\tchangedToEntryId: newEntryId,\n\t\t};\n\t\tthis.emitValueChangedEvent(op, true /* isLocal */);\n\t\tthis.emitRevertibleEvent(op);\n\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tpublic rollback(op: unknown, _localOpMetadata: unknown): void {\n\t\tconst arrayOp = op as ISharedArrayOperation<T>;\n\t\tswitch (arrayOp.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\tliveEntry.isDeleted = true;\n\t\t\t\tconst deleteOp: IDeleteOperation = {\n\t\t\t\t\ttype: OperationType.deleteEntry,\n\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(deleteOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tif (this.remoteDeleteWithLocalPendingDelete.has(arrayOp.entryId)) {\n\t\t\t\t\t// If remote already deleted the entry, we should not resurrect it.\n\t\t\t\t\t// Just remove the local pending delete.\n\t\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(arrayOp.entryId);\n\t\t\t\t} else {\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(arrayOp.entryId);\n\t\t\t\t\tliveEntry.isDeleted = false;\n\t\t\t\t\tconst insertOp = {\n\t\t\t\t\t\ttype: OperationType.insertEntry,\n\t\t\t\t\t\tentryId: arrayOp.entryId,\n\t\t\t\t\t\tvalue: liveEntry.value,\n\t\t\t\t\t};\n\t\t\t\t\tthis.emitValueChangedEvent(insertOp, true /* isLocal */);\n\t\t\t\t\tconst entry = this.getEntryForId(arrayOp.entryId);\n\t\t\t\t\tif (entry !== undefined && entry.isLocalPendingDelete > 0) {\n\t\t\t\t\t\tentry.isLocalPendingDelete -= 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;\n\t\t\t\tif (this.getEntryForId(newEntryId).isDeleted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.updateLiveEntry(newEntryId, oldEntryId);\n\t\t\t\tconst inputEntry = this.getEntryForId(oldEntryId);\n\t\t\t\tinputEntry.prevEntryId = undefined;\n\t\t\t\tinputEntry.nextEntryId = undefined;\n\t\t\t\tinputEntry.isLocalPendingMove = 0;\n\t\t\t\tconst moveOp: IMoveOperation = {\n\t\t\t\t\ttype: OperationType.moveEntry,\n\t\t\t\t\tentryId: newEntryId,\n\t\t\t\t\tchangedToEntryId: oldEntryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(moveOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle: {\n\t\t\t\tconst entryId = arrayOp.entryId;\n\t\t\t\tconst liveEntry = this.getLiveEntry(entryId);\n\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\n\t\t\t\t// Toggling the isDeleted flag to undo the last operation for the skip list payload/value\n\t\t\t\tliveEntry.isDeleted = !isDeleted;\n\t\t\t\tliveEntry.isLocalPendingDelete -= 1;\n\n\t\t\t\tconst toggleOp: IToggleOperation = {\n\t\t\t\t\ttype: OperationType.toggle,\n\t\t\t\t\tentryId,\n\t\t\t\t\tisDeleted: liveEntry.isDeleted,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(toggleOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tconst { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;\n\t\t\t\tthis.getEntryForId(oldEntryId).isLocalPendingMove -= 1;\n\t\t\t\tthis.updateLiveEntry(oldEntryId, newEntryId);\n\n\t\t\t\tconst toggleMoveOp: IToggleMoveOperation = {\n\t\t\t\t\ttype: OperationType.toggleMove,\n\t\t\t\t\tentryId: newEntryId,\n\t\t\t\t\tchangedToEntryId: oldEntryId,\n\t\t\t\t};\n\t\t\t\tthis.emitValueChangedEvent(toggleMoveOp, true /* isLocal */);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(arrayOp);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Load share array from snapshot\n\t *\n\t * @param storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(storage: IChannelStorageService): Promise<void> {\n\t\tconst header = await storage.readBlob(snapshotFileName);\n\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\tconst utf8 = new TextDecoder(\"utf-8\").decode(header);\n\t\t// Note: IFluidSerializer.parse() doesn't guarantee any typing; the explicit typing here is based on this code's\n\t\t// knowledge of what it is deserializing.\n\t\tconst deserializedSharedArray = this.serializer.parse(utf8) as {\n\t\t\tdataArray: SharedArrayEntry<T>[];\n\t\t};\n\t\tthis.sharedArray = deserializedSharedArray.dataArray;\n\t\t// Initializing the idToEntryMap optimizer data set\n\t\tfor (const entry of this.sharedArray) {\n\t\t\tthis.idToEntryMap.set(entry.entryId, entry);\n\t\t\tthis.unsetLocalFlags(entry);\n\t\t}\n\t}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Tracks the doubly linked skip list for the given entry to identify local pending counter attribute.\n\t * It signifies if a local pending operation exists for the payload/value being tracked in the skip list\n\t *\n\t * returns true if counterAttribute's count \\> 0\n\t * @param entryId - id for which counter attribute is to be tracked in chian.\n\t * @param counterAttribute - flag or property name from SharedArrayEntry whose counter is to be tracked.\n\t */\n\tprivate isLocalPending(\n\t\tentryId: string,\n\t\tcounterAttribute: keyof SharedArrayEntry<T>,\n\t): boolean {\n\t\tconst getCounterAttributeValue = (\n\t\t\tentry: SharedArrayEntry<T>,\n\t\t\tcounterAttr: keyof SharedArrayEntry<T>,\n\t\t): number => {\n\t\t\treturn entry[counterAttr] as number;\n\t\t};\n\n\t\tconst inputEntry = this.getEntryForId(entryId);\n\t\tlet prevEntryId = inputEntry.prevEntryId;\n\t\tlet nextEntryId = inputEntry.nextEntryId;\n\t\tif (getCounterAttributeValue(inputEntry, counterAttribute) > 0) {\n\t\t\treturn true;\n\t\t}\n\t\t// track back in chain\n\t\twhile (prevEntryId !== undefined && prevEntryId) {\n\t\t\tconst prevEntry = this.getEntryForId(prevEntryId);\n\t\t\tif (getCounterAttributeValue(prevEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tprevEntryId = prevEntry.prevEntryId;\n\t\t}\n\n\t\t// track forward in the chain\n\t\twhile (nextEntryId !== undefined && nextEntryId) {\n\t\t\tconst nextEntry = this.getEntryForId(nextEntryId);\n\t\t\tif (getCounterAttributeValue(nextEntry, counterAttribute)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tnextEntryId = nextEntry.nextEntryId;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate getEntryForId(entryId: string): SharedArrayEntry<T> {\n\t\treturn this.idToEntryMap.get(entryId) as SharedArrayEntry<T>;\n\t}\n\n\t/**\n\t * Process a shared array operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (message.type === MessageType.Operation) {\n\t\t\tconst op = message.contents as ISharedArrayOperation<T>;\n\t\t\tswitch (op.type) {\n\t\t\t\tcase OperationType.insertEntry: {\n\t\t\t\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\t\t\t\top.entryId,\n\t\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t\top.value,\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\t\tthis.handleDeleteOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.moveEntry: {\n\t\t\t\t\tthis.handleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggle: {\n\t\t\t\t\tthis.handleToggleOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase OperationType.toggleMove: {\n\t\t\t\t\tthis.handleToggleMoveOp(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!local) {\n\t\t\t\tthis.emitValueChangedEvent(op, local);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleInsertOp<TWrite>(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tlocal: boolean,\n\t\tvalue: Serializable<TWrite> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (local) {\n\t\t\tthis.getEntryForId(entryId).isAckPending = false;\n\t\t} else {\n\t\t\tif (insertAfterEntryId !== undefined) {\n\t\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t\t}\n\t\t\tconst newEntry = this.createNewEntry(entryId, value);\n\t\t\tnewEntry.isAckPending = false;\n\t\t\tthis.addEntry(this.getInternalInsertIndexByIgnoringLocalPendingInserts(index), newEntry);\n\t\t}\n\t}\n\n\tprivate handleDeleteOp(op: IDeleteOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// Decrementing local pending counter as op is already applied to local state\n\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\tthis.remoteDeleteWithLocalPendingDelete.delete(op.entryId);\n\t\t} else {\n\t\t\tif (this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.remoteDeleteWithLocalPendingDelete.add(op.entryId);\n\t\t\t} else {\n\t\t\t\t// last element in skip list is the most recent and live entry, so marking it deleted\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleMoveOp(op: IMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tthis.handleInsertOp<SerializableTypeForSharedArray>(\n\t\t\top.changedToEntryId,\n\t\t\top.insertAfterEntryId,\n\t\t\tlocal,\n\t\t\topEntry.value,\n\t\t);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t} else {\n\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t// If local pending then simply mark the new location dead as finally the local op will win\n\t\t\tif (\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t) {\n\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t} else {\n\t\t\t\t// move the element\n\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\tif (isDeleted) {\n\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleOp(op: IToggleOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending delete op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingDelete) {\n\t\t\t\topEntry.isLocalPendingDelete -= 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (!this.isLocalPending(op.entryId, \"isLocalPendingDelete\")) {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate handleToggleMoveOp(op: IToggleMoveOperation, local: boolean): void {\n\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\tif (local) {\n\t\t\t// decrement the local pending move op as its already applied to local state\n\t\t\tif (opEntry.isLocalPendingMove) {\n\t\t\t\topEntry.isLocalPendingMove -= 1;\n\t\t\t}\n\t\t} else if (\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingDelete\") &&\n\t\t\t!this.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t) {\n\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t}\n\t}\n\n\tprivate findInternalIndex(countEntries: number): number {\n\t\tif (countEntries < 0) {\n\t\t\tthrow new Error(\"Input count is zero\");\n\t\t}\n\n\t\tlet countDown = countEntries;\n\t\tlet entriesIterator = 0;\n\t\tfor (; entriesIterator < this.sharedArray.length; entriesIterator = entriesIterator + 1) {\n\t\t\tconst entry = this.sharedArray[entriesIterator];\n\t\t\tassert(entry !== undefined, 0xb93 /* Invalid index */);\n\t\t\tif (entry.isDeleted === false) {\n\t\t\t\tif (countDown === 0) {\n\t\t\t\t\treturn entriesIterator;\n\t\t\t\t}\n\t\t\t\tcountDown = countDown - 1;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Count of live entries is less than required`);\n\t}\n\n\tprivate findInternalInsertionIndex(index: number): number {\n\t\treturn index === 0 ? index : this.findInternalIndex(index - 1) + 1;\n\t}\n\n\tprivate findInternalDeletionIndex(index: number): number {\n\t\treturn this.findInternalIndex(index);\n\t}\n\n\tprivate createAddEntry<TWrite>(index: number, value: Serializable<TWrite> & T): string {\n\t\tconst newEntry = this.createNewEntry(uuid(), value);\n\t\tthis.addEntry(index, newEntry);\n\t\treturn newEntry.entryId;\n\t}\n\n\tprivate addEntry(insertIndex: number, newEntry: SharedArrayEntry<T>): void {\n\t\t// in scenario where we populate 100K rows, we insert them all at the end of array.\n\t\t// slicing array is way slower than pushing elements.\n\t\tif (insertIndex === this.sharedArray.length) {\n\t\t\tthis.sharedArray.push(newEntry);\n\t\t} else {\n\t\t\tthis.sharedArray.splice(insertIndex, 0 /* deleteCount */, newEntry);\n\t\t}\n\n\t\t// Updating the idToEntryMap optimizer data set as new entry has been added\n\t\tthis.idToEntryMap.set(newEntry.entryId, newEntry);\n\t}\n\n\tprivate emitValueChangedEvent(op: ISharedArrayOperation, isLocal: boolean): void {\n\t\tthis.emit(\"valueChanged\", op, isLocal, this);\n\t}\n\n\tprivate emitRevertibleEvent(op: ISharedArrayOperation): void {\n\t\tconst revertible = new SharedArrayRevertible(this, op);\n\t\tthis.emit(\"revertible\", revertible);\n\t}\n\n\tprivate deleteCore(index: number): void {\n\t\tconst entry = this.sharedArray[index];\n\t\tassert(entry !== undefined, 0xb94 /* Invalid index */);\n\n\t\tif (entry.isDeleted) {\n\t\t\tthrow new Error(\"Entry already deleted.\");\n\t\t}\n\t\tentry.isDeleted = true;\n\n\t\t// Adding local pending counter\n\t\tentry.isLocalPendingDelete += 1;\n\t}\n\n\tprivate createMoveEntry(oldIndex: number, newIndex: number): string {\n\t\tconst oldEntry = this.sharedArray[oldIndex];\n\t\tassert(oldEntry !== undefined, 0xb95 /* Invalid index */);\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(\n\t\t\tuuid(),\n\t\t\toldEntry.value,\n\t\t\toldEntry.entryId,\n\t\t);\n\n\t\toldEntry.isDeleted = true;\n\t\toldEntry.nextEntryId = newEntry.entryId;\n\n\t\t// Adding local pending counter\n\t\toldEntry.isLocalPendingMove += 1;\n\n\t\tthis.addEntry(newIndex /* insertIndex */, newEntry);\n\n\t\treturn newEntry.entryId;\n\t}\n\n\t/**\n\t * Creates new entry of type SharedArrayEntry interface.\n\t * @param entryId - id for which new entry is created\n\t * @param value - value for the new entry\n\t * @param prevEntryId - prevEntryId if exists to update the previous pointer of double ended linked list\n\t */\n\tprivate createNewEntry<TWrite>(\n\t\tentryId: string,\n\t\tvalue: Serializable<TWrite> & T,\n\t\tprevEntryId?: string,\n\t): SharedArrayEntry<T> {\n\t\treturn {\n\t\t\tentryId,\n\t\t\tvalue,\n\t\t\tisAckPending: true,\n\t\t\tisDeleted: false,\n\t\t\tprevEntryId,\n\t\t\tnextEntryId: undefined,\n\t\t\tisLocalPendingDelete: 0,\n\t\t\tisLocalPendingMove: 0,\n\t\t};\n\t}\n\n\t/**\n\t * Unsets all local flags used by the DDS. This method can be used after reading from snapshott to ensure\n\t * local flags are initialized for use by the DDS.\n\t * @param entry - Entry for which the local flags have to be cleaned up\n\t */\n\tprivate unsetLocalFlags(entry: SharedArrayEntry<T>): void {\n\t\tentry.isAckPending = false;\n\t\tentry.isLocalPendingDelete = 0;\n\t\tentry.isLocalPendingMove = 0;\n\t}\n\n\t/**\n\t * Returns the index of the first entry starting with startIndex that does not have the isAckPending flag\n\t */\n\tprivate getInternalInsertIndexByIgnoringLocalPendingInserts(startIndex: number): number {\n\t\tlet localOpsIterator = startIndex;\n\t\tfor (\n\t\t\t;\n\t\t\tlocalOpsIterator < this.sharedArray.length;\n\t\t\tlocalOpsIterator = localOpsIterator + 1\n\t\t) {\n\t\t\tconst entry = this.sharedArray[localOpsIterator];\n\t\t\tassert(entry !== undefined, 0xb96 /* Invalid index */);\n\t\t\tif (!entry.isAckPending) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn localOpsIterator;\n\t}\n\n\tprivate findIndexOfEntryId(entryId: string | undefined): number {\n\t\tfor (let index = 0; index < this.sharedArray.length; index = index + 1) {\n\t\t\tif (this.sharedArray[index]?.entryId === entryId) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t\treturn -1;\n\t}\n\n\tprivate prepareToMakeEntryIdLive(entry: SharedArrayEntry<T>): void {\n\t\tconst prevIndex = this.findIndexOfEntryId(entry.prevEntryId);\n\t\tconst nextIndex = this.findIndexOfEntryId(entry.nextEntryId);\n\t\tif (prevIndex !== -1) {\n\t\t\tconst prevEntry = this.sharedArray[prevIndex];\n\t\t\tassert(prevEntry !== undefined, 0xb97 /* Invalid index */);\n\t\t\tprevEntry.nextEntryId = entry.nextEntryId;\n\t\t}\n\t\tif (nextIndex !== -1) {\n\t\t\tconst nextEntry = this.sharedArray[nextIndex];\n\t\t\tassert(nextEntry !== undefined, 0xb98 /* Invalid index */);\n\t\t\tnextEntry.prevEntryId = entry.prevEntryId;\n\t\t}\n\t\tentry.prevEntryId = undefined;\n\t\tentry.nextEntryId = undefined;\n\t}\n\n\t/**\n\t * Method that returns the live entry.\n\t * The shared array internally can store a skip list of all related entries which got created\n\t * due to move operations for the same payload/value. However, all elements except for one element\n\t * can have isDeleted flag as false indicating this is the live entry for the value.\n\t * Current implementation ensures that the last element in the skip list of entries is the liveEntry/\n\t * last live entry\n\t *\n\t * @param entryId - Entry id of any node in the skip list for the same payload/value\n\t */\n\tprivate getLiveEntry(entryId: string): SharedArrayEntry<T> {\n\t\tlet liveEntry = this.getEntryForId(entryId);\n\t\twhile (liveEntry.nextEntryId !== undefined && liveEntry.nextEntryId) {\n\t\t\tliveEntry = this.getEntryForId(liveEntry.nextEntryId);\n\t\t}\n\t\treturn liveEntry;\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps us keep track of the current position of an entry.value by marking the entry\n\t * at previous position deleted and appending the entry at the new position at the end of the double linked\n\t * list for that entry.value.\n\t */\n\tprivate updateLiveEntry(oldLiveEntryEntryId: string, newLiveEntryEntryId: string): void {\n\t\tconst oldLiveEntry = this.getEntryForId(oldLiveEntryEntryId);\n\t\tconst newLiveEntry = this.getEntryForId(newLiveEntryEntryId);\n\t\tif (oldLiveEntryEntryId === newLiveEntryEntryId) {\n\t\t\toldLiveEntry.isDeleted = false;\n\t\t} else {\n\t\t\tthis.prepareToMakeEntryIdLive(newLiveEntry);\n\t\t\t// Make entryId live\n\t\t\toldLiveEntry.nextEntryId = newLiveEntryEntryId;\n\t\t\tnewLiveEntry.prevEntryId = oldLiveEntryEntryId;\n\t\t\tnewLiveEntry.isDeleted = false;\n\t\t\toldLiveEntry.isDeleted = true;\n\t\t}\n\t}\n\n\t/**\n\t * We track sequence of moves for a entry in the shared array using doubly linked skip list.\n\t * This utility function helps to insert the new entry as dead entry and reconnecting the double linked list with\n\t * existingEntry -\\> deadeEntry(appended) -\\> existing chain(if any).\n\t */\n\tprivate updateDeadEntry(existingEntryId: string, deadEntryId: string): void {\n\t\tconst existingEntry = this.getEntryForId(existingEntryId);\n\t\tconst deadEntry = this.getEntryForId(deadEntryId);\n\n\t\t// update dead entry's next to existingEntry's next, if existingEntry's next entry exists.\n\t\t// It can be undefined if the exiting element is the last element (or only element) of chain.\n\t\tif (existingEntry.nextEntryId !== undefined) {\n\t\t\tdeadEntry.nextEntryId = existingEntry.nextEntryId;\n\t\t\tthis.getEntryForId(existingEntry.nextEntryId).prevEntryId = deadEntryId;\n\t\t}\n\n\t\t// update current entry's next pointer to dead entry and vice versa.\n\t\texistingEntry.nextEntryId = deadEntryId;\n\t\tdeadEntry.prevEntryId = existingEntryId;\n\t\tdeadEntry.isDeleted = true;\n\t}\n\n\tprivate handleStashedInsert(\n\t\tentryId: string,\n\t\tinsertAfterEntryId: string | undefined,\n\t\tvalue: Serializable<SerializableTypeForSharedArray> & T,\n\t): void {\n\t\tlet index = 0;\n\t\tif (insertAfterEntryId !== undefined) {\n\t\t\tindex = this.findIndexOfEntryId(insertAfterEntryId) + 1;\n\t\t}\n\t\tconst newEntry = this.createNewEntry<SerializableTypeForSharedArray>(entryId, value);\n\t\tnewEntry.isAckPending = true;\n\t\tthis.addEntry(index, newEntry);\n\t}\n\n\tprotected applyStashedOp(content: unknown): void {\n\t\tconst op = content as ISharedArrayOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase OperationType.insertEntry: {\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.entryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\top.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.deleteEntry: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = true;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.moveEntry: {\n\t\t\t\tconst opEntry = this.getEntryForId(op.entryId);\n\t\t\t\tthis.handleStashedInsert(\n\t\t\t\t\top.changedToEntryId,\n\t\t\t\t\top.insertAfterEntryId,\n\t\t\t\t\topEntry.value as Serializable<SerializableTypeForSharedArray> & T,\n\t\t\t\t);\n\n\t\t\t\tconst newElementEntryId = op.changedToEntryId;\n\t\t\t\tconst newElement = this.getEntryForId(newElementEntryId);\n\t\t\t\tif (\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingDelete\") ||\n\t\t\t\t\tthis.isLocalPending(op.entryId, \"isLocalPendingMove\")\n\t\t\t\t) {\n\t\t\t\t\tthis.updateDeadEntry(op.entryId, newElementEntryId);\n\t\t\t\t} else {\n\t\t\t\t\t// move the element\n\t\t\t\t\tconst liveEntry = this.getLiveEntry(op.entryId);\n\t\t\t\t\tconst isDeleted = liveEntry.isDeleted;\n\t\t\t\t\tthis.updateLiveEntry(liveEntry.entryId, newElementEntryId);\n\t\t\t\t\t// mark newly added element as deleted if existing live element was already deleted\n\t\t\t\t\tif (isDeleted) {\n\t\t\t\t\t\tnewElement.isDeleted = isDeleted;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnewElement.isLocalPendingMove += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggle: {\n\t\t\t\tthis.getLiveEntry(op.entryId).isDeleted = op.isDeleted;\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingDelete += 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase OperationType.toggleMove: {\n\t\t\t\tthis.updateLiveEntry(this.getLiveEntry(op.entryId).entryId, op.entryId);\n\t\t\t\tthis.getEntryForId(op.entryId).isLocalPendingMove += 1;\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\tthis.submitLocalMessage(op);\n\t}\n}\n"]}
|
package/lib/legacy.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
|
-
// @
|
|
12
|
+
// #region @legacyBeta APIs
|
|
13
13
|
IDeleteOperation,
|
|
14
14
|
IInsertOperation,
|
|
15
15
|
IMoveOperation,
|
|
@@ -28,4 +28,5 @@ export {
|
|
|
28
28
|
SharedArray,
|
|
29
29
|
SharedArrayBuilder,
|
|
30
30
|
SharedSignal
|
|
31
|
+
// #endregion
|
|
31
32
|
} from "./index.js";
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -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/legacy-dds";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.61.0-355054";
|
|
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,+BAA+B,CAAC;AACpD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,+BAA+B,CAAC;AACpD,eAAO,MAAM,UAAU,kBAAkB,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AACpD,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/legacy-dds\";\nexport const pkgVersion = \"2.61.0-355054\";\n"]}
|
|
@@ -63,6 +63,7 @@ export declare class SharedSignalClass<T extends SerializableTypeForSharedSignal
|
|
|
63
63
|
*/
|
|
64
64
|
protected processCore(message: ISequencedDocumentMessage, local: boolean, _localOpMetadata: unknown): void;
|
|
65
65
|
private notifyCore;
|
|
66
|
+
rollback(content: unknown, _localOpMetadata: unknown): void;
|
|
66
67
|
protected applyStashedOp(_content: unknown): void;
|
|
67
68
|
}
|
|
68
69
|
//# sourceMappingURL=sharedSignal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSignal.d.ts","sourceRoot":"","sources":["../../src/signal/sharedSignal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EACX,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,eAAe,EACf,MAAM,gDAAgD,CAAC;AAExD,OAAO,KAAK,EACX,yBAAyB,EAEzB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAE3E,OAAO,KAAK,EACX,aAAa,EACb,mBAAmB,EAEnB,+BAA+B,EAC/B,MAAM,iBAAiB,CAAC;AAKzB;;;;GAIG;AACH,qBAAa,iBAAiB,CAAC,CAAC,SAAS,+BAA+B,GAAG,GAAG,CAC7E,SAAQ,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAC3C,YAAW,aAAa,CAAC,CAAC,CAAC;IAE3B;;;;;;OAMG;WACW,MAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,iBAAiB;IAIrF;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C;;;;;;OAMG;gBAEF,EAAE,EAAE,MAAM,EACV,OAAO,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sBAAsB,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,iBAAiB;IAIrF;;;;OAIG;WACW,UAAU,IAAI,eAAe;IAI3C;;;;;;OAMG;gBAEF,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,sBAAsB,EAC/B,UAAU,EAAE,kBAAkB;IAK/B;;OAEG;IACI,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI;IAgBjC,SAAS,CAAC,aAAa,CAAC,WAAW,EAAE,gBAAgB,GAAG,qBAAqB;IAqB7E;;;;;OAKG;cACa,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;cAEtD,mBAAmB,IAAI,IAAI;IAE9C;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,IAAI;IAE9B;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACpB,OAAO,EAAE,yBAAyB,EAClC,KAAK,EAAE,OAAO,EACd,gBAAgB,EAAE,OAAO,GACvB,IAAI;IAiBP,OAAO,CAAC,UAAU;IAKX,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,OAAO,GAAG,IAAI;IAIlE,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;CAYjD"}
|
|
@@ -113,6 +113,10 @@ export class SharedSignalClass extends SharedObject {
|
|
|
113
113
|
notifyCore(op, isLocal) {
|
|
114
114
|
this.emit("notify", op.metadata, isLocal);
|
|
115
115
|
}
|
|
116
|
+
// Nothing to roll back. Allowing other DDSs to handle rollback if necessary.
|
|
117
|
+
rollback(content, _localOpMetadata) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
116
120
|
applyStashedOp(_content) {
|
|
117
121
|
const op = _content;
|
|
118
122
|
switch (op.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedSignal.js","sourceRoot":"","sources":["../../src/signal/sharedSignal.ts"],"names":[],"mappings":"AAAA;;;GAGG;A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QAAQ,CAAC,CAAC,CAAC;gBACf,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,eAAe,CAAC,EAAW,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tISharedSignal,\n\tISharedSignalEvents,\n\tISignalOperation,\n\tSerializableTypeForSharedSignal,\n} from \"./interfaces.js\";\nimport { SharedSignalFactory } from \"./sharedSignalFactory.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared signal that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedSignalClass<T extends SerializableTypeForSharedSignal = any>\n\textends SharedObject<ISharedSignalEvents<T>>\n\timplements ISharedSignal<T>\n{\n\t/**\n\t * Create a new shared signal\n\t *\n\t * @param runtime - data store runtime the new shared signal belongs to\n\t * @param id - optional name of the shared signal\n\t * @returns newly create shared signal (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedSignalClass {\n\t\treturn runtime.createChannel(id, SharedSignalFactory.Type) as SharedSignalClass;\n\t}\n\n\t/**\n\t * Get a factory for SharedSignal to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedSignal\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new SharedSignalFactory();\n\t}\n\n\t/**\n\t * Constructs a new shared signal. If the object is non-local an id and service interfaces will\n\t * be provided\n\t * @param id - optional name of the shared signal\n\t * @param runtime - data store runtime the shared signal belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedSignal_\" /* telemetryContextPrefix */);\n\t}\n\n\t/**\n\t * Method used for generating a signal.\n\t */\n\tpublic notify(metadata?: T): void {\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISignalOperation<T> = {\n\t\t\ttype: \"signal\",\n\t\t\tmetadata,\n\t\t};\n\n\t\tthis.notifyCore(op, true);\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tprotected summarizeCore(_serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: JSON.stringify(\"\"),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\t/**\n\t * Load share signal from snapshot\n\t *\n\t * @param _storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(_storage: IChannelStorageService): Promise<void> {}\n\n\tprotected override initializeLocalCore(): void {}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Process a shared signal operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\tif ((message.type as MessageType) === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ISignalOperation<T>;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"signal\": {\n\t\t\t\t\tthis.notifyCore(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate notifyCore(op: ISignalOperation<T>, isLocal: boolean): void {\n\t\tthis.emit(\"notify\", op.metadata, isLocal);\n\t}\n\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst op = _content as ISignalOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase \"signal\": {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(op as never);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sharedSignal.js","sourceRoot":"","sources":["../../src/signal/sharedSignal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAOtE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAM/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,OAAO,EAAE,YAA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F,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport type {\n\tIChannelAttributes,\n\tIFluidDataStoreRuntime,\n\tIChannelStorageService,\n\tIChannelFactory,\n} from \"@fluidframework/datastore-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISequencedDocumentMessage,\n\tITree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { ISummaryTreeWithStats } from \"@fluidframework/runtime-definitions/internal\";\nimport { convertToSummaryTreeWithStats } from \"@fluidframework/runtime-utils/internal\";\nimport type { IFluidSerializer } from \"@fluidframework/shared-object-base/internal\";\nimport { SharedObject } from \"@fluidframework/shared-object-base/internal\";\n\nimport type {\n\tISharedSignal,\n\tISharedSignalEvents,\n\tISignalOperation,\n\tSerializableTypeForSharedSignal,\n} from \"./interfaces.js\";\nimport { SharedSignalFactory } from \"./sharedSignalFactory.js\";\n\nconst snapshotFileName = \"header\";\n\n/**\n * Represents a shared signal that allows communication between distributed clients.\n *\n * @internal\n */\nexport class SharedSignalClass<T extends SerializableTypeForSharedSignal = any>\n\textends SharedObject<ISharedSignalEvents<T>>\n\timplements ISharedSignal<T>\n{\n\t/**\n\t * Create a new shared signal\n\t *\n\t * @param runtime - data store runtime the new shared signal belongs to\n\t * @param id - optional name of the shared signal\n\t * @returns newly create shared signal (but not attached yet)\n\t */\n\tpublic static create(runtime: IFluidDataStoreRuntime, id?: string): SharedSignalClass {\n\t\treturn runtime.createChannel(id, SharedSignalFactory.Type) as SharedSignalClass;\n\t}\n\n\t/**\n\t * Get a factory for SharedSignal to register with the data store.\n\t *\n\t * @returns a factory that creates and load SharedSignal\n\t */\n\tpublic static getFactory(): IChannelFactory {\n\t\treturn new SharedSignalFactory();\n\t}\n\n\t/**\n\t * Constructs a new shared signal. If the object is non-local an id and service interfaces will\n\t * be provided\n\t * @param id - optional name of the shared signal\n\t * @param runtime - data store runtime the shared signal belongs to\n\t * @param attributes - represents the attributes of a channel/DDS.\n\t */\n\tpublic constructor(\n\t\tid: string,\n\t\truntime: IFluidDataStoreRuntime,\n\t\tattributes: IChannelAttributes,\n\t) {\n\t\tsuper(id, runtime, attributes, \"loop_sharedSignal_\" /* telemetryContextPrefix */);\n\t}\n\n\t/**\n\t * Method used for generating a signal.\n\t */\n\tpublic notify(metadata?: T): void {\n\t\t// If we are not attached, don't submit the op.\n\t\tif (!this.isAttached()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst op: ISignalOperation<T> = {\n\t\t\ttype: \"signal\",\n\t\t\tmetadata,\n\t\t};\n\n\t\tthis.notifyCore(op, true);\n\n\t\tthis.submitLocalMessage(op);\n\t}\n\n\tprotected summarizeCore(_serializer: IFluidSerializer): ISummaryTreeWithStats {\n\t\tconst tree: ITree = {\n\t\t\tentries: [\n\t\t\t\t{\n\t\t\t\t\tmode: FileMode.File,\n\t\t\t\t\tpath: snapshotFileName,\n\t\t\t\t\ttype: TreeEntry[TreeEntry.Blob],\n\t\t\t\t\tvalue: {\n\t\t\t\t\t\tcontents: JSON.stringify(\"\"),\n\t\t\t\t\t\t// eslint-disable-next-line unicorn/text-encoding-identifier-case\n\t\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst summaryTreeWithStats = convertToSummaryTreeWithStats(tree);\n\n\t\treturn summaryTreeWithStats;\n\t}\n\n\t/**\n\t * Load share signal from snapshot\n\t *\n\t * @param _storage - the storage to get the snapshot from\n\t * @returns - promise that resolved when the load is completed\n\t */\n\tprotected async loadCore(_storage: IChannelStorageService): Promise<void> {}\n\n\tprotected override initializeLocalCore(): void {}\n\n\t/**\n\t * Callback on disconnect\n\t */\n\tprotected onDisconnect(): void {}\n\n\t/**\n\t * Process a shared signal operation\n\t *\n\t * @param message - the message to prepare\n\t * @param local - whether the message was sent by 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\tprotected processCore(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\t_localOpMetadata: unknown,\n\t): void {\n\t\tif ((message.type as MessageType) === MessageType.Operation && !local) {\n\t\t\tconst op = message.contents as ISignalOperation<T>;\n\n\t\t\tswitch (op.type) {\n\t\t\t\tcase \"signal\": {\n\t\t\t\t\tthis.notifyCore(op, local);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault: {\n\t\t\t\t\tthrow new Error(\"Unknown operation\");\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate notifyCore(op: ISignalOperation<T>, isLocal: boolean): void {\n\t\tthis.emit(\"notify\", op.metadata, isLocal);\n\t}\n\n\t// Nothing to roll back. Allowing other DDSs to handle rollback if necessary.\n\tpublic rollback(content: unknown, _localOpMetadata: unknown): void {\n\t\treturn;\n\t}\n\n\tprotected applyStashedOp(_content: unknown): void {\n\t\tconst op = _content as ISignalOperation<T>;\n\n\t\tswitch (op.type) {\n\t\t\tcase \"signal\": {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(op as never);\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/legacy-dds",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.61.0-355054",
|
|
4
4
|
"description": "Legacy DDSs for the Fluid Framework. These are not intended for use in new code.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -81,34 +81,34 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "
|
|
85
|
-
"@fluidframework/core-interfaces": "
|
|
86
|
-
"@fluidframework/core-utils": "
|
|
87
|
-
"@fluidframework/datastore-definitions": "
|
|
88
|
-
"@fluidframework/driver-definitions": "
|
|
89
|
-
"@fluidframework/driver-utils": "
|
|
90
|
-
"@fluidframework/runtime-definitions": "
|
|
91
|
-
"@fluidframework/runtime-utils": "
|
|
92
|
-
"@fluidframework/shared-object-base": "
|
|
84
|
+
"@fluid-internal/client-utils": "2.61.0-355054",
|
|
85
|
+
"@fluidframework/core-interfaces": "2.61.0-355054",
|
|
86
|
+
"@fluidframework/core-utils": "2.61.0-355054",
|
|
87
|
+
"@fluidframework/datastore-definitions": "2.61.0-355054",
|
|
88
|
+
"@fluidframework/driver-definitions": "2.61.0-355054",
|
|
89
|
+
"@fluidframework/driver-utils": "2.61.0-355054",
|
|
90
|
+
"@fluidframework/runtime-definitions": "2.61.0-355054",
|
|
91
|
+
"@fluidframework/runtime-utils": "2.61.0-355054",
|
|
92
|
+
"@fluidframework/shared-object-base": "2.61.0-355054",
|
|
93
93
|
"uuid": "^11.1.0"
|
|
94
94
|
},
|
|
95
95
|
"devDependencies": {
|
|
96
96
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
97
97
|
"@biomejs/biome": "~1.9.3",
|
|
98
|
-
"@fluid-internal/mocha-test-setup": "
|
|
99
|
-
"@fluid-private/stochastic-test-utils": "
|
|
100
|
-
"@fluid-private/test-dds-utils": "
|
|
101
|
-
"@fluid-tools/build-cli": "^0.
|
|
98
|
+
"@fluid-internal/mocha-test-setup": "2.61.0-355054",
|
|
99
|
+
"@fluid-private/stochastic-test-utils": "2.61.0-355054",
|
|
100
|
+
"@fluid-private/test-dds-utils": "2.61.0-355054",
|
|
101
|
+
"@fluid-tools/build-cli": "^0.58.2",
|
|
102
102
|
"@fluidframework/build-common": "^2.0.3",
|
|
103
|
-
"@fluidframework/build-tools": "^0.
|
|
104
|
-
"@fluidframework/container-definitions": "
|
|
103
|
+
"@fluidframework/build-tools": "^0.58.2",
|
|
104
|
+
"@fluidframework/container-definitions": "2.61.0-355054",
|
|
105
105
|
"@fluidframework/eslint-config-fluid": "^6.0.0",
|
|
106
|
-
"@fluidframework/test-runtime-utils": "
|
|
107
|
-
"@microsoft/api-extractor": "7.52.
|
|
106
|
+
"@fluidframework/test-runtime-utils": "2.61.0-355054",
|
|
107
|
+
"@microsoft/api-extractor": "7.52.11",
|
|
108
108
|
"@types/jest": "29.5.3",
|
|
109
109
|
"@types/mocha": "^10.0.10",
|
|
110
110
|
"@types/node": "^18.19.0",
|
|
111
|
-
"c8": "^
|
|
111
|
+
"c8": "^10.1.3",
|
|
112
112
|
"concurrently": "^8.2.1",
|
|
113
113
|
"copyfiles": "^2.4.1",
|
|
114
114
|
"cross-env": "^7.0.3",
|
|
@@ -125,8 +125,8 @@
|
|
|
125
125
|
},
|
|
126
126
|
"scripts": {
|
|
127
127
|
"api": "fluid-build . --task api",
|
|
128
|
-
"api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
|
|
129
|
-
"api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
|
|
128
|
+
"api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./dist",
|
|
129
|
+
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
|
|
130
130
|
"build": "fluid-build . --task build",
|
|
131
131
|
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
|
132
132
|
"build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
|
|
@@ -162,8 +162,8 @@
|
|
|
162
162
|
"test": "npm run test:mocha",
|
|
163
163
|
"test:coverage": "c8 npm test",
|
|
164
164
|
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
165
|
-
"test:mocha:cjs": "
|
|
166
|
-
"test:mocha:esm": "mocha
|
|
165
|
+
"test:mocha:cjs": "cross-env MOCHA_SPEC=dist/test mocha",
|
|
166
|
+
"test:mocha:esm": "mocha",
|
|
167
167
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
168
168
|
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
169
169
|
"typetests:gen": "flub generate typetests --dir . -v",
|
package/src/array/sharedArray.ts
CHANGED
|
@@ -444,9 +444,35 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
444
444
|
this.emitValueChangedEvent(moveOp, true /* isLocal */);
|
|
445
445
|
break;
|
|
446
446
|
}
|
|
447
|
-
case OperationType.toggle:
|
|
447
|
+
case OperationType.toggle: {
|
|
448
|
+
const entryId = arrayOp.entryId;
|
|
449
|
+
const liveEntry = this.getLiveEntry(entryId);
|
|
450
|
+
const isDeleted = liveEntry.isDeleted;
|
|
451
|
+
|
|
452
|
+
// Toggling the isDeleted flag to undo the last operation for the skip list payload/value
|
|
453
|
+
liveEntry.isDeleted = !isDeleted;
|
|
454
|
+
liveEntry.isLocalPendingDelete -= 1;
|
|
455
|
+
|
|
456
|
+
const toggleOp: IToggleOperation = {
|
|
457
|
+
type: OperationType.toggle,
|
|
458
|
+
entryId,
|
|
459
|
+
isDeleted: liveEntry.isDeleted,
|
|
460
|
+
};
|
|
461
|
+
this.emitValueChangedEvent(toggleOp, true /* isLocal */);
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
448
464
|
case OperationType.toggleMove: {
|
|
449
|
-
|
|
465
|
+
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
466
|
+
this.getEntryForId(oldEntryId).isLocalPendingMove -= 1;
|
|
467
|
+
this.updateLiveEntry(oldEntryId, newEntryId);
|
|
468
|
+
|
|
469
|
+
const toggleMoveOp: IToggleMoveOperation = {
|
|
470
|
+
type: OperationType.toggleMove,
|
|
471
|
+
entryId: newEntryId,
|
|
472
|
+
changedToEntryId: oldEntryId,
|
|
473
|
+
};
|
|
474
|
+
this.emitValueChangedEvent(toggleMoveOp, true /* isLocal */);
|
|
475
|
+
break;
|
|
450
476
|
}
|
|
451
477
|
default: {
|
|
452
478
|
unreachableCase(arrayOp);
|
package/src/packageVersion.ts
CHANGED
|
@@ -163,6 +163,11 @@ export class SharedSignalClass<T extends SerializableTypeForSharedSignal = any>
|
|
|
163
163
|
this.emit("notify", op.metadata, isLocal);
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
// Nothing to roll back. Allowing other DDSs to handle rollback if necessary.
|
|
167
|
+
public rollback(content: unknown, _localOpMetadata: unknown): void {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
166
171
|
protected applyStashedOp(_content: unknown): void {
|
|
167
172
|
const op = _content as ISignalOperation<T>;
|
|
168
173
|
|