@fluidframework/legacy-dds 2.74.0-365691 → 2.74.0-370705
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array/interfaces.d.ts +7 -0
- package/dist/array/interfaces.d.ts.map +1 -1
- package/dist/array/interfaces.js.map +1 -1
- package/dist/array/sharedArray.d.ts.map +1 -1
- package/dist/array/sharedArray.js +12 -0
- package/dist/array/sharedArray.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/array/interfaces.d.ts +7 -0
- package/lib/array/interfaces.d.ts.map +1 -1
- package/lib/array/interfaces.js.map +1 -1
- package/lib/array/sharedArray.d.ts.map +1 -1
- package/lib/array/sharedArray.js +12 -0
- package/lib/array/sharedArray.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +16 -16
- package/src/array/interfaces.ts +8 -0
- package/src/array/sharedArray.ts +12 -0
- package/src/packageVersion.ts +1 -1
|
@@ -89,6 +89,13 @@ export interface SharedArrayEntry<T extends SerializableTypeForSharedArray> exte
|
|
|
89
89
|
* being if there is a remote delete, we will have to respect that
|
|
90
90
|
*/
|
|
91
91
|
isLocalPendingMove: number;
|
|
92
|
+
/**
|
|
93
|
+
* Optional flag indicating that this entry has been rolled back
|
|
94
|
+
*
|
|
95
|
+
* Used to prevent undo/redo operations that have already been rolled back.
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
isRollback?: boolean;
|
|
92
99
|
}
|
|
93
100
|
/**
|
|
94
101
|
* Interface defining the core entry attributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/array/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MA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AO,CAAC;IAEtB;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,8BAA8B;IAC7E;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IAET;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,EAAE,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/array/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEventThisPlaceHolder, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { Serializable } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObjectEvents,\n\tISharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedArrayOperation } from \"./sharedArrayOperations.js\";\n/**\n * Basic types for the SharedArray DDS\n * It can be used as a generic constraint (`extends SerializableTypeForSharedArray`) but is\n * *never* meant to be a concrete/real type on its own.\n *\n * @legacy @beta\n */\nexport type SerializableTypeForSharedArray = boolean | number | string | object | IFluidHandle;\n\n/**\n * Interface defining the events that can be emitted by the SharedArray DDS\n * and the events that can be listened to by the SharedArray DDS\n *\n * @legacy @beta\n */\nexport interface ISharedArrayEvents extends ISharedObjectEvents {\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"valueChanged\",\n\t\tlistener: (\n\t\t\top: ISharedArrayOperation,\n\t\t\tisLocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"revertible\", listener: (revertible: IRevertible) => void): void;\n}\n\n/**\n * Interface defining the SharedArray DDS\n * It is a generic interface that can be used to create a SharedArray of any type\n * The type of the SharedArray is defined by the type parameter T\n *\n * @typeParam T - The type of the SharedArray\n *\n * @legacy @beta\n */\nexport interface ISharedArray<T extends SerializableTypeForSharedArray>\n\textends ISharedObject<ISharedArrayEvents> {\n\tget(): readonly T[];\n\tinsert<TWrite>(index: number, value: Serializable<TWrite> & T): void;\n\tdelete(index: number): void;\n\tmove(oldIndex: number, newIndex: number): void;\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n\tinsertBulkAfter<TWrite>(ref: T | undefined, values: (Serializable<TWrite> & T)[]): void;\n}\n\n/**\n *\n * @internal\n */\nexport interface ISharedArrayRevertible extends ISharedObject<ISharedArrayEvents> {\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n}\n\n/**\n * Interface defining the in memory shared array entry of the DDS\n *\n * @internal\n */\nexport interface SharedArrayEntry<T extends SerializableTypeForSharedArray>\n\textends SharedArrayEntryCore<T> {\n\t/**\n\t * Flag that tracks whether an ack from the server has been received for a local insert.\n\t * True for local changes.\n\t */\n\tisAckPending: boolean;\n\n\t/**\n\t * Counter is shared by delete and undo/redo (of delete and insert) as undo/redo simply\n\t * operates on the isDeleted flag of the DDS. This flag will help us skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping\n\t */\n\tisLocalPendingDelete: number;\n\n\t/**\n\t * Counter is for move and its undo/redo. This flag will be used to skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping. Only exception\n\t * being if there is a remote delete, we will have to respect that\n\t */\n\tisLocalPendingMove: number;\n}\n\n/**\n * Interface defining the core entry attributes\n *\n * @internal\n */\nexport interface SharedArrayEntryCore<T extends SerializableTypeForSharedArray> {\n\t/**\n\t * a unique ID for this particular entry\n\t */\n\tentryId: string;\n\n\t/**\n\t * the value stored in this entry, may not be unique\n\t */\n\tvalue: T;\n\n\t/**\n\t * Flag to track whether this entry is deleted or not.\n\t */\n\tisDeleted: boolean;\n\n\t/**\n\t * Primarily used for move op and tracks the old entry id from which this entry was changed from.\n\t */\n\tprevEntryId?: string;\n\n\t/**\n\t * Primarily used for move op and tracks the new entry id to which this entry was changed to.\n\t */\n\tnextEntryId?: string;\n}\n\n/**\n * Format of the snapshot for the DDS\n *\n * @internal\n */\nexport interface SnapshotFormat<T> {\n\t/**\n\t * Array of the data entries that represent the DDS in-memory representation\n\t */\n\tdataArray: T[];\n}\n\n/**\n * @legacy @beta\n */\nexport interface IRevertible {\n\trevert(): void;\n\tdispose(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/array/interfaces.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEventThisPlaceHolder, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { Serializable } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObjectEvents,\n\tISharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedArrayOperation } from \"./sharedArrayOperations.js\";\n/**\n * Basic types for the SharedArray DDS\n * It can be used as a generic constraint (`extends SerializableTypeForSharedArray`) but is\n * *never* meant to be a concrete/real type on its own.\n *\n * @legacy @beta\n */\nexport type SerializableTypeForSharedArray = boolean | number | string | object | IFluidHandle;\n\n/**\n * Interface defining the events that can be emitted by the SharedArray DDS\n * and the events that can be listened to by the SharedArray DDS\n *\n * @legacy @beta\n */\nexport interface ISharedArrayEvents extends ISharedObjectEvents {\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"valueChanged\",\n\t\tlistener: (\n\t\t\top: ISharedArrayOperation,\n\t\t\tisLocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"revertible\", listener: (revertible: IRevertible) => void): void;\n}\n\n/**\n * Interface defining the SharedArray DDS\n * It is a generic interface that can be used to create a SharedArray of any type\n * The type of the SharedArray is defined by the type parameter T\n *\n * @typeParam T - The type of the SharedArray\n *\n * @legacy @beta\n */\nexport interface ISharedArray<T extends SerializableTypeForSharedArray>\n\textends ISharedObject<ISharedArrayEvents> {\n\tget(): readonly T[];\n\tinsert<TWrite>(index: number, value: Serializable<TWrite> & T): void;\n\tdelete(index: number): void;\n\tmove(oldIndex: number, newIndex: number): void;\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n\tinsertBulkAfter<TWrite>(ref: T | undefined, values: (Serializable<TWrite> & T)[]): void;\n}\n\n/**\n *\n * @internal\n */\nexport interface ISharedArrayRevertible extends ISharedObject<ISharedArrayEvents> {\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n}\n\n/**\n * Interface defining the in memory shared array entry of the DDS\n *\n * @internal\n */\nexport interface SharedArrayEntry<T extends SerializableTypeForSharedArray>\n\textends SharedArrayEntryCore<T> {\n\t/**\n\t * Flag that tracks whether an ack from the server has been received for a local insert.\n\t * True for local changes.\n\t */\n\tisAckPending: boolean;\n\n\t/**\n\t * Counter is shared by delete and undo/redo (of delete and insert) as undo/redo simply\n\t * operates on the isDeleted flag of the DDS. This flag will help us skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping\n\t */\n\tisLocalPendingDelete: number;\n\n\t/**\n\t * Counter is for move and its undo/redo. This flag will be used to skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping. Only exception\n\t * being if there is a remote delete, we will have to respect that\n\t */\n\tisLocalPendingMove: number;\n\n\t/**\n\t * Optional flag indicating that this entry has been rolled back\n\t *\n\t * Used to prevent undo/redo operations that have already been rolled back.\n\t *\n\t */\n\tisRollback?: boolean;\n}\n\n/**\n * Interface defining the core entry attributes\n *\n * @internal\n */\nexport interface SharedArrayEntryCore<T extends SerializableTypeForSharedArray> {\n\t/**\n\t * a unique ID for this particular entry\n\t */\n\tentryId: string;\n\n\t/**\n\t * the value stored in this entry, may not be unique\n\t */\n\tvalue: T;\n\n\t/**\n\t * Flag to track whether this entry is deleted or not.\n\t */\n\tisDeleted: boolean;\n\n\t/**\n\t * Primarily used for move op and tracks the old entry id from which this entry was changed from.\n\t */\n\tprevEntryId?: string;\n\n\t/**\n\t * Primarily used for move op and tracks the new entry id to which this entry was changed to.\n\t */\n\tnextEntryId?: string;\n}\n\n/**\n * Format of the snapshot for the DDS\n *\n * @internal\n */\nexport interface SnapshotFormat<T> {\n\t/**\n\t * Array of the data entries that represent the DDS in-memory representation\n\t */\n\tdataArray: T[];\n}\n\n/**\n * @legacy @beta\n */\nexport interface IRevertible {\n\trevert(): void;\n\tdispose(): void;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedAr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|
|
|
239
239
|
*/
|
|
240
240
|
toggle(entryId) {
|
|
241
241
|
const liveEntry = this.getLiveEntry(entryId);
|
|
242
|
+
if (liveEntry?.isRollback === true) {
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
242
245
|
const isDeleted = !liveEntry.isDeleted;
|
|
243
246
|
// Adding local pending counter
|
|
244
247
|
this.getEntryForId(entryId).isLocalPendingDelete += 1;
|
|
@@ -267,6 +270,10 @@ class SharedArrayClass extends internal_4.SharedObject {
|
|
|
267
270
|
* @param newEntryId - EntryId of the to be live entry
|
|
268
271
|
*/
|
|
269
272
|
toggleMove(oldEntryId, newEntryId) {
|
|
273
|
+
const liveEntry = this.getLiveEntry(newEntryId);
|
|
274
|
+
if (liveEntry?.isRollback === true) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
270
277
|
if (this.getEntryForId(newEntryId).isDeleted) {
|
|
271
278
|
return;
|
|
272
279
|
}
|
|
@@ -292,6 +299,7 @@ class SharedArrayClass extends internal_4.SharedObject {
|
|
|
292
299
|
case sharedArrayOperations_js_1.OperationType.insertEntry: {
|
|
293
300
|
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
294
301
|
liveEntry.isDeleted = true;
|
|
302
|
+
liveEntry.isRollback = true;
|
|
295
303
|
const deleteOp = {
|
|
296
304
|
type: sharedArrayOperations_js_1.OperationType.deleteEntry,
|
|
297
305
|
entryId: arrayOp.entryId,
|
|
@@ -308,6 +316,7 @@ class SharedArrayClass extends internal_4.SharedObject {
|
|
|
308
316
|
else {
|
|
309
317
|
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
310
318
|
liveEntry.isDeleted = false;
|
|
319
|
+
liveEntry.isRollback = true;
|
|
311
320
|
const insertOp = {
|
|
312
321
|
type: sharedArrayOperations_js_1.OperationType.insertEntry,
|
|
313
322
|
entryId: arrayOp.entryId,
|
|
@@ -326,6 +335,7 @@ class SharedArrayClass extends internal_4.SharedObject {
|
|
|
326
335
|
if (this.getEntryForId(newEntryId).isDeleted) {
|
|
327
336
|
return;
|
|
328
337
|
}
|
|
338
|
+
this.getEntryForId(oldEntryId).isRollback = true;
|
|
329
339
|
this.updateLiveEntry(newEntryId, oldEntryId);
|
|
330
340
|
const inputEntry = this.getEntryForId(oldEntryId);
|
|
331
341
|
inputEntry.prevEntryId = undefined;
|
|
@@ -346,6 +356,7 @@ class SharedArrayClass extends internal_4.SharedObject {
|
|
|
346
356
|
// Toggling the isDeleted flag to undo the last operation for the skip list payload/value
|
|
347
357
|
liveEntry.isDeleted = !isDeleted;
|
|
348
358
|
liveEntry.isLocalPendingDelete -= 1;
|
|
359
|
+
liveEntry.isRollback = true;
|
|
349
360
|
const toggleOp = {
|
|
350
361
|
type: sharedArrayOperations_js_1.OperationType.toggle,
|
|
351
362
|
entryId,
|
|
@@ -357,6 +368,7 @@ class SharedArrayClass extends internal_4.SharedObject {
|
|
|
357
368
|
case sharedArrayOperations_js_1.OperationType.toggleMove: {
|
|
358
369
|
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
359
370
|
this.getEntryForId(oldEntryId).isLocalPendingMove -= 1;
|
|
371
|
+
this.getEntryForId(newEntryId).isRollback = true;
|
|
360
372
|
this.updateLiveEntry(oldEntryId, newEntryId);
|
|
361
373
|
const toggleMoveOp = {
|
|
362
374
|
type: sharedArrayOperations_js_1.OperationType.toggleMove,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedArray.js","sourceRoot":"","sources":["../../src/array/sharedArray.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kEAA8E;AAS9E,0EAA+F;AAO/F,qEAAuF;AAEvF,0EAA2E;AAC3E,+BAAkC;AAWlC,mEAA6D;AAQ7D,yEAA2D;AAC3D,yEAAmE;AAEnE,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAa,gBACZ,SAAQ,uBAAgC;IAyBxC;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CACnB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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;AAt8BD,4CAs8BC","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 { ITree } from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} 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 * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.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\tthis.getLiveEntry(op.entryId).isDeleted === false\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\topEntry.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;AAS9E,0EAA+F;AAO/F,qEAAuF;AAEvF,0EAA2E;AAC3E,+BAAkC;AAWlC,mEAA6D;AAQ7D,yEAA2D;AAC3D,yEAAmE;AAEnE,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAElC;;;;GAIG;AACH,MAAa,gBACZ,SAAQ,uBAAgC;IAyBxC;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CACnB,OAA+B,EAC/B,EAAW;QAEX,OAAO,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,0CAAkB,CAAC,IAAI,CAAwB,CAAC;IAClF,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU;QACvB,OAAO,IAAI,0CAAkB,EAAK,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACH,YACC,EAAU,EACV,OAA+B,EAC/B,UAA8B;QAE9B,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,mBAAmB,CAAC,4BAA4B,CAAC,CAAC;QA3ClF;;;;WAIG;QACc,uCAAkC,GAAgB,IAAI,GAAG,EAAU,CAAC;QAuCpF,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAA+B,CAAC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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;AAl9BD,4CAk9BC","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 { ITree } from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} 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\tif (liveEntry?.isRollback === true) {\n\t\t\treturn;\n\t\t}\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\tconst liveEntry = this.getLiveEntry(newEntryId);\n\t\tif (liveEntry?.isRollback === true) {\n\t\t\treturn;\n\t\t}\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\tliveEntry.isRollback = 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\tliveEntry.isRollback = true;\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.getEntryForId(oldEntryId).isRollback = true;\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\t\t\t\tliveEntry.isRollback = true;\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.getEntryForId(newEntryId).isRollback = true;\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 * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.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\tthis.getLiveEntry(op.entryId).isDeleted === false\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\topEntry.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/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.74.0-
|
|
8
|
+
export declare const pkgVersion = "2.74.0-370705";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
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.74.0-
|
|
11
|
+
exports.pkgVersion = "2.74.0-370705";
|
|
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,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.74.0-
|
|
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.74.0-370705\";\n"]}
|
|
@@ -89,6 +89,13 @@ export interface SharedArrayEntry<T extends SerializableTypeForSharedArray> exte
|
|
|
89
89
|
* being if there is a remote delete, we will have to respect that
|
|
90
90
|
*/
|
|
91
91
|
isLocalPendingMove: number;
|
|
92
|
+
/**
|
|
93
|
+
* Optional flag indicating that this entry has been rolled back
|
|
94
|
+
*
|
|
95
|
+
* Used to prevent undo/redo operations that have already been rolled back.
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
isRollback?: boolean;
|
|
92
99
|
}
|
|
93
100
|
/**
|
|
94
101
|
* Interface defining the core entry attributes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/array/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,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IAC/B;;;OAGG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAE3B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,8BAA8B;IAC7E;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IAET;;OAEG;IACH,SAAS,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAChC;;OAEG;IACH,SAAS,EAAE,CAAC,EAAE,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC3B,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;CAChB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/array/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEventThisPlaceHolder, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { Serializable } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObjectEvents,\n\tISharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedArrayOperation } from \"./sharedArrayOperations.js\";\n/**\n * Basic types for the SharedArray DDS\n * It can be used as a generic constraint (`extends SerializableTypeForSharedArray`) but is\n * *never* meant to be a concrete/real type on its own.\n *\n * @legacy @beta\n */\nexport type SerializableTypeForSharedArray = boolean | number | string | object | IFluidHandle;\n\n/**\n * Interface defining the events that can be emitted by the SharedArray DDS\n * and the events that can be listened to by the SharedArray DDS\n *\n * @legacy @beta\n */\nexport interface ISharedArrayEvents extends ISharedObjectEvents {\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"valueChanged\",\n\t\tlistener: (\n\t\t\top: ISharedArrayOperation,\n\t\t\tisLocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"revertible\", listener: (revertible: IRevertible) => void): void;\n}\n\n/**\n * Interface defining the SharedArray DDS\n * It is a generic interface that can be used to create a SharedArray of any type\n * The type of the SharedArray is defined by the type parameter T\n *\n * @typeParam T - The type of the SharedArray\n *\n * @legacy @beta\n */\nexport interface ISharedArray<T extends SerializableTypeForSharedArray>\n\textends ISharedObject<ISharedArrayEvents> {\n\tget(): readonly T[];\n\tinsert<TWrite>(index: number, value: Serializable<TWrite> & T): void;\n\tdelete(index: number): void;\n\tmove(oldIndex: number, newIndex: number): void;\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n\tinsertBulkAfter<TWrite>(ref: T | undefined, values: (Serializable<TWrite> & T)[]): void;\n}\n\n/**\n *\n * @internal\n */\nexport interface ISharedArrayRevertible extends ISharedObject<ISharedArrayEvents> {\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n}\n\n/**\n * Interface defining the in memory shared array entry of the DDS\n *\n * @internal\n */\nexport interface SharedArrayEntry<T extends SerializableTypeForSharedArray>\n\textends SharedArrayEntryCore<T> {\n\t/**\n\t * Flag that tracks whether an ack from the server has been received for a local insert.\n\t * True for local changes.\n\t */\n\tisAckPending: boolean;\n\n\t/**\n\t * Counter is shared by delete and undo/redo (of delete and insert) as undo/redo simply\n\t * operates on the isDeleted flag of the DDS. This flag will help us skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping\n\t */\n\tisLocalPendingDelete: number;\n\n\t/**\n\t * Counter is for move and its undo/redo. This flag will be used to skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping. Only exception\n\t * being if there is a remote delete, we will have to respect that\n\t */\n\tisLocalPendingMove: number;\n}\n\n/**\n * Interface defining the core entry attributes\n *\n * @internal\n */\nexport interface SharedArrayEntryCore<T extends SerializableTypeForSharedArray> {\n\t/**\n\t * a unique ID for this particular entry\n\t */\n\tentryId: string;\n\n\t/**\n\t * the value stored in this entry, may not be unique\n\t */\n\tvalue: T;\n\n\t/**\n\t * Flag to track whether this entry is deleted or not.\n\t */\n\tisDeleted: boolean;\n\n\t/**\n\t * Primarily used for move op and tracks the old entry id from which this entry was changed from.\n\t */\n\tprevEntryId?: string;\n\n\t/**\n\t * Primarily used for move op and tracks the new entry id to which this entry was changed to.\n\t */\n\tnextEntryId?: string;\n}\n\n/**\n * Format of the snapshot for the DDS\n *\n * @internal\n */\nexport interface SnapshotFormat<T> {\n\t/**\n\t * Array of the data entries that represent the DDS in-memory representation\n\t */\n\tdataArray: T[];\n}\n\n/**\n * @legacy @beta\n */\nexport interface IRevertible {\n\trevert(): void;\n\tdispose(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/array/interfaces.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IEventThisPlaceHolder, IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport type { Serializable } from \"@fluidframework/datastore-definitions/internal\";\nimport type {\n\tISharedObjectEvents,\n\tISharedObject,\n} from \"@fluidframework/shared-object-base/internal\";\n\nimport type { ISharedArrayOperation } from \"./sharedArrayOperations.js\";\n/**\n * Basic types for the SharedArray DDS\n * It can be used as a generic constraint (`extends SerializableTypeForSharedArray`) but is\n * *never* meant to be a concrete/real type on its own.\n *\n * @legacy @beta\n */\nexport type SerializableTypeForSharedArray = boolean | number | string | object | IFluidHandle;\n\n/**\n * Interface defining the events that can be emitted by the SharedArray DDS\n * and the events that can be listened to by the SharedArray DDS\n *\n * @legacy @beta\n */\nexport interface ISharedArrayEvents extends ISharedObjectEvents {\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(\n\t\tevent: \"valueChanged\",\n\t\tlistener: (\n\t\t\top: ISharedArrayOperation,\n\t\t\tisLocal: boolean,\n\t\t\ttarget: IEventThisPlaceHolder,\n\t\t) => void,\n\t): void;\n\n\t/**\n\t *\n\t * @param event - The event name.\n\t * @param listener - An event listener.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"revertible\", listener: (revertible: IRevertible) => void): void;\n}\n\n/**\n * Interface defining the SharedArray DDS\n * It is a generic interface that can be used to create a SharedArray of any type\n * The type of the SharedArray is defined by the type parameter T\n *\n * @typeParam T - The type of the SharedArray\n *\n * @legacy @beta\n */\nexport interface ISharedArray<T extends SerializableTypeForSharedArray>\n\textends ISharedObject<ISharedArrayEvents> {\n\tget(): readonly T[];\n\tinsert<TWrite>(index: number, value: Serializable<TWrite> & T): void;\n\tdelete(index: number): void;\n\tmove(oldIndex: number, newIndex: number): void;\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n\tinsertBulkAfter<TWrite>(ref: T | undefined, values: (Serializable<TWrite> & T)[]): void;\n}\n\n/**\n *\n * @internal\n */\nexport interface ISharedArrayRevertible extends ISharedObject<ISharedArrayEvents> {\n\ttoggle(entryId: string): void;\n\ttoggleMove(oldEntryId: string, newEntryId: string): void;\n}\n\n/**\n * Interface defining the in memory shared array entry of the DDS\n *\n * @internal\n */\nexport interface SharedArrayEntry<T extends SerializableTypeForSharedArray>\n\textends SharedArrayEntryCore<T> {\n\t/**\n\t * Flag that tracks whether an ack from the server has been received for a local insert.\n\t * True for local changes.\n\t */\n\tisAckPending: boolean;\n\n\t/**\n\t * Counter is shared by delete and undo/redo (of delete and insert) as undo/redo simply\n\t * operates on the isDeleted flag of the DDS. This flag will help us skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping\n\t */\n\tisLocalPendingDelete: number;\n\n\t/**\n\t * Counter is for move and its undo/redo. This flag will be used to skip local op acks as\n\t * they have already inflicted state change. The flag helps us ignore remote ops if there is a\n\t * local pending delete as we would be getting the pending op after server stamping. Only exception\n\t * being if there is a remote delete, we will have to respect that\n\t */\n\tisLocalPendingMove: number;\n\n\t/**\n\t * Optional flag indicating that this entry has been rolled back\n\t *\n\t * Used to prevent undo/redo operations that have already been rolled back.\n\t *\n\t */\n\tisRollback?: boolean;\n}\n\n/**\n * Interface defining the core entry attributes\n *\n * @internal\n */\nexport interface SharedArrayEntryCore<T extends SerializableTypeForSharedArray> {\n\t/**\n\t * a unique ID for this particular entry\n\t */\n\tentryId: string;\n\n\t/**\n\t * the value stored in this entry, may not be unique\n\t */\n\tvalue: T;\n\n\t/**\n\t * Flag to track whether this entry is deleted or not.\n\t */\n\tisDeleted: boolean;\n\n\t/**\n\t * Primarily used for move op and tracks the old entry id from which this entry was changed from.\n\t */\n\tprevEntryId?: string;\n\n\t/**\n\t * Primarily used for move op and tracks the new entry id to which this entry was changed to.\n\t */\n\tnextEntryId?: string;\n}\n\n/**\n * Format of the snapshot for the DDS\n *\n * @internal\n */\nexport interface SnapshotFormat<T> {\n\t/**\n\t * Array of the data entries that represent the DDS in-memory representation\n\t */\n\tdataArray: T[];\n}\n\n/**\n * @legacy @beta\n */\nexport interface IRevertible {\n\trevert(): void;\n\tdispose(): void;\n}\n"]}
|
|
@@ -1 +1 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.js
CHANGED
|
@@ -236,6 +236,9 @@ export class SharedArrayClass extends SharedObject {
|
|
|
236
236
|
*/
|
|
237
237
|
toggle(entryId) {
|
|
238
238
|
const liveEntry = this.getLiveEntry(entryId);
|
|
239
|
+
if (liveEntry?.isRollback === true) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
239
242
|
const isDeleted = !liveEntry.isDeleted;
|
|
240
243
|
// Adding local pending counter
|
|
241
244
|
this.getEntryForId(entryId).isLocalPendingDelete += 1;
|
|
@@ -264,6 +267,10 @@ export class SharedArrayClass extends SharedObject {
|
|
|
264
267
|
* @param newEntryId - EntryId of the to be live entry
|
|
265
268
|
*/
|
|
266
269
|
toggleMove(oldEntryId, newEntryId) {
|
|
270
|
+
const liveEntry = this.getLiveEntry(newEntryId);
|
|
271
|
+
if (liveEntry?.isRollback === true) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
267
274
|
if (this.getEntryForId(newEntryId).isDeleted) {
|
|
268
275
|
return;
|
|
269
276
|
}
|
|
@@ -289,6 +296,7 @@ export class SharedArrayClass extends SharedObject {
|
|
|
289
296
|
case OperationType.insertEntry: {
|
|
290
297
|
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
291
298
|
liveEntry.isDeleted = true;
|
|
299
|
+
liveEntry.isRollback = true;
|
|
292
300
|
const deleteOp = {
|
|
293
301
|
type: OperationType.deleteEntry,
|
|
294
302
|
entryId: arrayOp.entryId,
|
|
@@ -305,6 +313,7 @@ export class SharedArrayClass extends SharedObject {
|
|
|
305
313
|
else {
|
|
306
314
|
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
307
315
|
liveEntry.isDeleted = false;
|
|
316
|
+
liveEntry.isRollback = true;
|
|
308
317
|
const insertOp = {
|
|
309
318
|
type: OperationType.insertEntry,
|
|
310
319
|
entryId: arrayOp.entryId,
|
|
@@ -323,6 +332,7 @@ export class SharedArrayClass extends SharedObject {
|
|
|
323
332
|
if (this.getEntryForId(newEntryId).isDeleted) {
|
|
324
333
|
return;
|
|
325
334
|
}
|
|
335
|
+
this.getEntryForId(oldEntryId).isRollback = true;
|
|
326
336
|
this.updateLiveEntry(newEntryId, oldEntryId);
|
|
327
337
|
const inputEntry = this.getEntryForId(oldEntryId);
|
|
328
338
|
inputEntry.prevEntryId = undefined;
|
|
@@ -343,6 +353,7 @@ export class SharedArrayClass extends SharedObject {
|
|
|
343
353
|
// Toggling the isDeleted flag to undo the last operation for the skip list payload/value
|
|
344
354
|
liveEntry.isDeleted = !isDeleted;
|
|
345
355
|
liveEntry.isLocalPendingDelete -= 1;
|
|
356
|
+
liveEntry.isRollback = true;
|
|
346
357
|
const toggleOp = {
|
|
347
358
|
type: OperationType.toggle,
|
|
348
359
|
entryId,
|
|
@@ -354,6 +365,7 @@ export class SharedArrayClass extends SharedObject {
|
|
|
354
365
|
case OperationType.toggleMove: {
|
|
355
366
|
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
356
367
|
this.getEntryForId(oldEntryId).isLocalPendingMove -= 1;
|
|
368
|
+
this.getEntryForId(newEntryId).isRollback = true;
|
|
357
369
|
this.updateLiveEntry(oldEntryId, newEntryId);
|
|
358
370
|
const toggleMoveOp = {
|
|
359
371
|
type: OperationType.toggleMove,
|
|
@@ -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;AAS9E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAO/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,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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 { ITree } from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} 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 * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.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\tthis.getLiveEntry(op.entryId).isDeleted === false\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\topEntry.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;AAS9E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAO/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,aAA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AS,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 { ITree } from \"@fluidframework/driver-definitions/internal\";\nimport { FileMode, MessageType, TreeEntry } from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tISummaryTreeWithStats,\n\tIRuntimeMessageCollection,\n\tIRuntimeMessagesContent,\n\tISequencedMessageEnvelope,\n} 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\tif (liveEntry?.isRollback === true) {\n\t\t\treturn;\n\t\t}\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\tconst liveEntry = this.getLiveEntry(newEntryId);\n\t\tif (liveEntry?.isRollback === true) {\n\t\t\treturn;\n\t\t}\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\tliveEntry.isRollback = 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\tliveEntry.isRollback = true;\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.getEntryForId(oldEntryId).isRollback = true;\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\t\t\t\tliveEntry.isRollback = true;\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.getEntryForId(newEntryId).isRollback = true;\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 * {@inheritDoc @fluidframework/shared-object-base#SharedObject.processMessagesCore}\n\t */\n\tprotected processMessagesCore(messagesCollection: IRuntimeMessageCollection): void {\n\t\tconst { envelope, local, messagesContent } = messagesCollection;\n\t\tfor (const messageContent of messagesContent) {\n\t\t\tthis.processMessage(envelope, messageContent, local);\n\t\t}\n\t}\n\n\tprivate processMessage(\n\t\tmessageEnvelope: ISequencedMessageEnvelope,\n\t\tmessageContent: IRuntimeMessagesContent,\n\t\tlocal: boolean,\n\t): void {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison\n\t\tif (messageEnvelope.type === MessageType.Operation) {\n\t\t\tconst op = messageContent.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\tthis.getLiveEntry(op.entryId).isDeleted === false\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\topEntry.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/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.74.0-
|
|
8
|
+
export declare const pkgVersion = "2.74.0-370705";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
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,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.74.0-
|
|
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.74.0-370705\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/legacy-dds",
|
|
3
|
-
"version": "2.74.0-
|
|
3
|
+
"version": "2.74.0-370705",
|
|
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,29 +81,29 @@
|
|
|
81
81
|
"temp-directory": "nyc/.nyc_output"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@fluid-internal/client-utils": "2.74.0-
|
|
85
|
-
"@fluidframework/core-interfaces": "2.74.0-
|
|
86
|
-
"@fluidframework/core-utils": "2.74.0-
|
|
87
|
-
"@fluidframework/datastore-definitions": "2.74.0-
|
|
88
|
-
"@fluidframework/driver-definitions": "2.74.0-
|
|
89
|
-
"@fluidframework/driver-utils": "2.74.0-
|
|
90
|
-
"@fluidframework/runtime-definitions": "2.74.0-
|
|
91
|
-
"@fluidframework/runtime-utils": "2.74.0-
|
|
92
|
-
"@fluidframework/shared-object-base": "2.74.0-
|
|
84
|
+
"@fluid-internal/client-utils": "2.74.0-370705",
|
|
85
|
+
"@fluidframework/core-interfaces": "2.74.0-370705",
|
|
86
|
+
"@fluidframework/core-utils": "2.74.0-370705",
|
|
87
|
+
"@fluidframework/datastore-definitions": "2.74.0-370705",
|
|
88
|
+
"@fluidframework/driver-definitions": "2.74.0-370705",
|
|
89
|
+
"@fluidframework/driver-utils": "2.74.0-370705",
|
|
90
|
+
"@fluidframework/runtime-definitions": "2.74.0-370705",
|
|
91
|
+
"@fluidframework/runtime-utils": "2.74.0-370705",
|
|
92
|
+
"@fluidframework/shared-object-base": "2.74.0-370705",
|
|
93
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": "2.74.0-
|
|
99
|
-
"@fluid-private/stochastic-test-utils": "2.74.0-
|
|
100
|
-
"@fluid-private/test-dds-utils": "2.74.0-
|
|
98
|
+
"@fluid-internal/mocha-test-setup": "2.74.0-370705",
|
|
99
|
+
"@fluid-private/stochastic-test-utils": "2.74.0-370705",
|
|
100
|
+
"@fluid-private/test-dds-utils": "2.74.0-370705",
|
|
101
101
|
"@fluid-tools/build-cli": "^0.60.0",
|
|
102
102
|
"@fluidframework/build-common": "^2.0.3",
|
|
103
103
|
"@fluidframework/build-tools": "^0.60.0",
|
|
104
|
-
"@fluidframework/container-definitions": "2.74.0-
|
|
105
|
-
"@fluidframework/eslint-config-fluid": "2.74.0-
|
|
106
|
-
"@fluidframework/test-runtime-utils": "2.74.0-
|
|
104
|
+
"@fluidframework/container-definitions": "2.74.0-370705",
|
|
105
|
+
"@fluidframework/eslint-config-fluid": "2.74.0-370705",
|
|
106
|
+
"@fluidframework/test-runtime-utils": "2.74.0-370705",
|
|
107
107
|
"@microsoft/api-extractor": "7.52.11",
|
|
108
108
|
"@types/jest": "29.5.3",
|
|
109
109
|
"@types/mocha": "^10.0.10",
|
package/src/array/interfaces.ts
CHANGED
|
@@ -110,6 +110,14 @@ export interface SharedArrayEntry<T extends SerializableTypeForSharedArray>
|
|
|
110
110
|
* being if there is a remote delete, we will have to respect that
|
|
111
111
|
*/
|
|
112
112
|
isLocalPendingMove: number;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Optional flag indicating that this entry has been rolled back
|
|
116
|
+
*
|
|
117
|
+
* Used to prevent undo/redo operations that have already been rolled back.
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
isRollback?: boolean;
|
|
113
121
|
}
|
|
114
122
|
|
|
115
123
|
/**
|
package/src/array/sharedArray.ts
CHANGED
|
@@ -336,6 +336,9 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
336
336
|
*/
|
|
337
337
|
public toggle(entryId: string): void {
|
|
338
338
|
const liveEntry = this.getLiveEntry(entryId);
|
|
339
|
+
if (liveEntry?.isRollback === true) {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
339
342
|
const isDeleted = !liveEntry.isDeleted;
|
|
340
343
|
|
|
341
344
|
// Adding local pending counter
|
|
@@ -369,6 +372,10 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
369
372
|
* @param newEntryId - EntryId of the to be live entry
|
|
370
373
|
*/
|
|
371
374
|
public toggleMove(oldEntryId: string, newEntryId: string): void {
|
|
375
|
+
const liveEntry = this.getLiveEntry(newEntryId);
|
|
376
|
+
if (liveEntry?.isRollback === true) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
372
379
|
if (this.getEntryForId(newEntryId).isDeleted) {
|
|
373
380
|
return;
|
|
374
381
|
}
|
|
@@ -400,6 +407,7 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
400
407
|
case OperationType.insertEntry: {
|
|
401
408
|
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
402
409
|
liveEntry.isDeleted = true;
|
|
410
|
+
liveEntry.isRollback = true;
|
|
403
411
|
const deleteOp: IDeleteOperation = {
|
|
404
412
|
type: OperationType.deleteEntry,
|
|
405
413
|
entryId: arrayOp.entryId,
|
|
@@ -415,6 +423,7 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
415
423
|
} else {
|
|
416
424
|
const liveEntry = this.getLiveEntry(arrayOp.entryId);
|
|
417
425
|
liveEntry.isDeleted = false;
|
|
426
|
+
liveEntry.isRollback = true;
|
|
418
427
|
const insertOp = {
|
|
419
428
|
type: OperationType.insertEntry,
|
|
420
429
|
entryId: arrayOp.entryId,
|
|
@@ -433,6 +442,7 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
433
442
|
if (this.getEntryForId(newEntryId).isDeleted) {
|
|
434
443
|
return;
|
|
435
444
|
}
|
|
445
|
+
this.getEntryForId(oldEntryId).isRollback = true;
|
|
436
446
|
this.updateLiveEntry(newEntryId, oldEntryId);
|
|
437
447
|
const inputEntry = this.getEntryForId(oldEntryId);
|
|
438
448
|
inputEntry.prevEntryId = undefined;
|
|
@@ -454,6 +464,7 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
454
464
|
// Toggling the isDeleted flag to undo the last operation for the skip list payload/value
|
|
455
465
|
liveEntry.isDeleted = !isDeleted;
|
|
456
466
|
liveEntry.isLocalPendingDelete -= 1;
|
|
467
|
+
liveEntry.isRollback = true;
|
|
457
468
|
|
|
458
469
|
const toggleOp: IToggleOperation = {
|
|
459
470
|
type: OperationType.toggle,
|
|
@@ -466,6 +477,7 @@ export class SharedArrayClass<T extends SerializableTypeForSharedArray>
|
|
|
466
477
|
case OperationType.toggleMove: {
|
|
467
478
|
const { entryId: oldEntryId, changedToEntryId: newEntryId } = arrayOp;
|
|
468
479
|
this.getEntryForId(oldEntryId).isLocalPendingMove -= 1;
|
|
480
|
+
this.getEntryForId(newEntryId).isRollback = true;
|
|
469
481
|
this.updateLiveEntry(oldEntryId, newEntryId);
|
|
470
482
|
|
|
471
483
|
const toggleMoveOp: IToggleMoveOperation = {
|
package/src/packageVersion.ts
CHANGED