@fluid-experimental/property-changeset 0.56.7 → 0.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"arrayChangesetIterator.d.ts","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AASH,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAO/D,aAAK,YAAY,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,mBAAmB,GAAG;IAAC,MAAM,EAAC,MAAM,CAAA;CAAC,CAAC,CAAC,CAAC;AACrF,oBAAY,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,CAAA;AAC7D,oBAAY,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,EAAG,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAG,YAAY,EAAE,YAAY,CAAC,CAAA;AACjI,oBAAY,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC,CAAA;AAItE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,2BAA2B,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,oBAAoB;IACzD,IAAI,EAAE,2BAA2B,CAAC,MAAM,CAAC;IACzC,qBAAqB,CAAC,EAAE,eAAe,CAAC;IACxC,SAAS,CAAC,EAAE,eAAe,CAAC;CAC/B;AAGD;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,oBAAoB;IACzD,IAAI,EAAE,2BAA2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,IAAI,EAAE,2BAA2B,CAAC,MAAM,CAAC;IACzC,qBAAqB,CAAC,EAAE,eAAe,CAAC;IACxC,SAAS,EAAE,eAAe,CAAC;CAC9B;AAED;;GAEG;AACF,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,oBAAoB,EAAE,uBAAuB,GAAC,WAAW,CAAC;IAClG,IAAI,EAAE,2BAA2B,CAAC,GAAG,CAAC;IACtC,SAAS,CAAC,EAAE,EAAE,CAAC;CAClB;AAED,oBAAY,gBAAgB,GAAG,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;AACnF,oBAAY,gBAAgB,GAAG,gBAAgB,GAAG,YAAY,CAAC;AAE/D;;;;;GAKG;AACH,qBAAa,sBAAsB;IAC/B,MAAM,CAAC,KAAK,qCAA+B;IAE3C,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,eAAe,CAAiB;IACxC,OAAO,CAAC,eAAe,CAAsD;IAC7E,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,oBAAoB,CAAS;IAErC,OAAO,CAAC,MAAM,CAAU;IACxB,OAAO,CAAC,GAAG,CAAmB;IAE9B,IAAW,aAAa,IAAI,gBAAgB,CAE3C;IAED,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED,IAAW,kBAAkB,IAAI,MAAM,CAEtC;IAED,IAAW,mBAAmB,IAAI,MAAM,CAEvC;IAED;;OAEG;gBACS,YAAY,EAAE,mBAAmB;IA0B7C;;;OAGG;IACH,IAAI,IAAI,OAAO;IAkIf;;OAEG;IACH,KAAK,IAAI,OAAO;IAIhB,OAAO,CAAC,aAAa;CAUxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"arrayChangesetIterator.js","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;;;;AAGF,+DAAuC;AACvC,+DAAuC;AAExC,aAAa;AACb,yEA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A,CAAC;;AAhNN,wDAiNC;AAhNU,4BAAK,GAAG,4CAA2B,CAAC,CAAC,uEAAuE;AAgNtH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Iterator to iterate over array ChangeSets\n */\n\n\n import isNumber from \"lodash/isNumber\";\n import isString from \"lodash/isString\";\n\n// @ts-ignore\nimport { constants } from \"@fluid-experimental/property-common\";\n\nimport { SerializedChangeSet } from \"../changeset\";\nimport { ArrayIteratorOperationTypes } from \"./operationTypes\";\n\n\nconst { MSG } = constants;\n\n\n\ntype genericArray = Array<number | string | (SerializedChangeSet & {typeid:string})>;\nexport type arrayInsertList = [number, string | genericArray]\nexport type arrayModifyList = [number, string | genericArray] | [number, string, string] | [number, genericArray, genericArray]\nexport type arrayRemoveList = [number, number | string | genericArray]\n\n\n\n/**\n * Description of an array operation\n */\nexport interface OperationDescription {\n _absoluteBegin?: number;\n type?: ArrayIteratorOperationTypes,\n offset?: number,\n}\n\n/**\n * Description of an insert array operation\n */\nexport interface InsertOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.INSERT;\n removeInsertOperation?: arrayInsertList;\n operation?: arrayInsertList;\n}\n\n\n/**\n * Description of a remove array operation\n */\nexport interface RemoveOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.REMOVE;\n removeInsertOperation?: arrayRemoveList;\n operation?: arrayRemoveList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface ModifyOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.MODIFY;\n removeInsertOperation?: arrayModifyList;\n operation: arrayModifyList;\n}\n\n/**\n * Description of a modify array operation\n */\n export interface NOPOperation extends Omit<OperationDescription, \"removeInsertOperation\"|\"operation\"> {\n type: ArrayIteratorOperationTypes.NOP;\n operation?: [];\n}\n\nexport type NoneNOPOperation = RemoveOperation | InsertOperation | ModifyOperation;\nexport type GenericOperation = NoneNOPOperation | NOPOperation;\n\n/**\n * Iterator class which iterates over an array ChangeSet. It will successively return the operations ordered by their\n * position within the array. Additionally, it will keep track of the modifications to the array indices caused\n * by the previous operations.\n *\n */\nexport class ArrayChangeSetIterator {\n static types = ArrayIteratorOperationTypes; // @TODO Not sure if this is still required if we export it separately.\n\n private _changeSet: SerializedChangeSet;\n private _copiedModifies: string | any[];\n private _currentIndices: { insert: number; remove: number; modify: number; };\n private _currentOffset: number;\n private _lastOperationIndex: number;\n private _lastOperationOffset: number;\n\n private _atEnd: boolean;\n private _op: GenericOperation;\n\n public get opDescription(): GenericOperation {\n return this._op;\n }\n\n public get currentOffset(): number {\n return this._currentOffset;\n }\n\n public get lastOperationIndex(): number {\n return this._lastOperationIndex;\n }\n\n public get lastOperationOffset(): number {\n return this._lastOperationOffset;\n }\n\n /**\n * @param in_changeSet - The ChangeSet to iterate over (this has to be an array ChangeSet\n */\n constructor(in_changeSet: SerializedChangeSet) {\n this._changeSet = in_changeSet;\n // if we need to chop overlapping modifies internally, so we have to copy them\n // we do this lazy and only if really needed\n this._copiedModifies = in_changeSet.modify;\n this._currentIndices = {\n insert: 0,\n remove: 0,\n modify: 0,\n };\n\n this._currentOffset = 0;\n this._lastOperationIndex = -1;\n this._lastOperationOffset = 0;\n this._atEnd = false;\n\n this._op = {\n type: ArrayIteratorOperationTypes.NOP,\n offset: 0,\n operation: undefined\n };\n\n // go to the first element\n this.next();\n }\n\n /**\n * Returns the next operation in the ChangeSet\n * @returns true, if there are operations left\n */\n next(): boolean {\n // Find the smallest index in the operations lists\n let currentIndex = Infinity;\n let type: ArrayIteratorOperationTypes;\n (this._op as any).removeInsertOperation = undefined;\n // Process the current remove entry\n if (this._changeSet.remove &&\n this._currentIndices.remove < this._changeSet.remove.length) {\n type = ArrayChangeSetIterator.types.REMOVE;\n currentIndex = this._changeSet.remove[this._currentIndices.remove][0];\n let currentLength = this._changeSet.remove[this._currentIndices.remove][1];\n if (!isNumber(currentLength)) {\n currentLength = currentLength.length;\n }\n\n // Check, whether this is a removeInsertOperation\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] <= currentIndex + currentLength) {\n (this._op as InsertOperation).removeInsertOperation = this._changeSet.insert[this._currentIndices.insert];\n }\n }\n\n // Process the current insert entry (we prefer remove over insert, since this prevents the array from growing more\n // than necessary)\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.INSERT;\n currentIndex = this._changeSet.insert[this._currentIndices.insert][0];\n }\n\n // Process the current modify entry\n if (this._copiedModifies &&\n this._currentIndices.modify < this._copiedModifies.length &&\n this._copiedModifies[this._currentIndices.modify][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.MODIFY;\n }\n\n if (this._lastOperationIndex !== currentIndex) {\n this._currentOffset += this._lastOperationOffset;\n this._lastOperationIndex = currentIndex;\n this._lastOperationOffset = 0;\n }\n\n // We have found nothing, so we are at the end of the ChangeSet\n if (type === undefined) {\n this._op.type = ArrayChangeSetIterator.types.NOP;\n this._op.offset = this._currentOffset;\n this._op.operation = undefined;\n this._atEnd = true;\n return false;\n }\n\n // Determine the return value and update the internal indices and offsets depending on the next operation\n switch (type) {\n case ArrayChangeSetIterator.types.INSERT:\n this._op.type = ArrayChangeSetIterator.types.INSERT;\n // Define the return value\n this._op.operation = this._changeSet.insert[this._currentIndices.insert];\n this._op.offset = this._currentOffset;\n // Update the current offset. For an insert we have to increase it by the number of the inserted elements\n this._lastOperationOffset += (this._op.operation[1] as any).length;\n\n // Shift the internal index\n this._currentIndices.insert++;\n break;\n case ArrayChangeSetIterator.types.REMOVE:\n this._op.type = ArrayChangeSetIterator.types.REMOVE;\n // Define the return value\n this._op.operation = this._changeSet.remove[this._currentIndices.remove];\n this._op.offset = this._currentOffset;\n // Update the current offset. For a remove we have to decrement it by the number of the removed elements\n var removedElements = isNumber(this._op.operation[1]) ? this._op.operation[1] : this._op.operation[1].length;\n this._lastOperationOffset -= removedElements;\n\n // Shift the internal index\n this._currentIndices.remove++;\n break;\n case ArrayChangeSetIterator.types.MODIFY:\n {\n this._op.type = ArrayChangeSetIterator.types.MODIFY;\n this._op.offset = this._currentOffset;\n // check, if the modify's range overlaps with coming insert changes:\n let nextModify = this._copiedModifies[this._currentIndices.modify];\n const modifyEnd = nextModify[0] + nextModify[1].length;\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < modifyEnd) {\n // we have an overlap and need to cut the modify\n const insertPosition = this._changeSet.insert[this._currentIndices.insert][0];\n\n // if we haven't copied the change set's modifies yet, we need to do that now\n if (this._copiedModifies === this._changeSet.modify) {\n this._copiedModifies = this._copyModifies(this._changeSet.modify);\n // now we need to update nextModify!\n nextModify = this._copiedModifies[this._currentIndices.modify];\n }\n\n // use modify only up to insert's position\n\n // build a partial modify and cut the remaining one:\n const partialModify: arrayModifyList = [nextModify[0], undefined];\n if (isString(nextModify[1])) {\n partialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);\n nextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);\n } else {\n partialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);\n }\n\n nextModify[0] = insertPosition;\n\n // use the whole modify\n this._op.operation = partialModify;\n } else {\n // use the whole modify\n this._op.operation = nextModify;\n\n // Shift the internal index\n this._currentIndices.modify++;\n }\n break;\n }\n default:\n throw new Error(`ArrayChangeSetIterator: ${MSG.UNKNOWN_OPERATION}`);\n }\n this._atEnd = false;\n return true;\n };\n\n /**\n * @returns true, if there are no more operations left\n */\n atEnd(): boolean {\n return this._atEnd;\n };\n\n private _copyModifies(in_modifies: string[]) {\n if (!in_modifies || in_modifies.length === 0) {\n return undefined;\n }\n const result = [];\n for (let i = 0; i < in_modifies.length; i++) {\n result.push([in_modifies[i][0], in_modifies[i][1].slice()]);\n }\n return result;\n };\n};\n"]}
1
+ {"version":3,"file":"arrayChangesetIterator.js","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;;;;AAGF,+DAAuC;AACvC,+DAAuC;AAExC,aAAa;AACb,yEAAgE;AAGhE,qDAA+D;AAG/D,MAAM,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AA2D1B;;;;;GAKG;AACH,MAAa,sBAAsB;IA6B/B;;OAEG;IACH,YAAY,YAAiC;QACzC,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;QAC/B,8EAA8E;QAC9E,4CAA4C;QAC5C,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,MAAM,CAAC;QAC3C,IAAI,CAAC,eAAe,GAAG;YACnB,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;SACZ,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC,GAAG,GAAG;YACP,IAAI,EAAE,4CAA2B,CAAC,GAAG;YACrC,MAAM,EAAE,CAAC;YACT,SAAS,EAAE,SAAS;SACvB,CAAC;QAEF,0BAA0B;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IA3CD,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,IAAW,kBAAkB;QACzB,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACpC,CAAC;IAED,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IA+BD;;;OAGG;IACH,IAAI;QACA,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W,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC/D;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAAA,CAAC;;AAhNN,wDAiNC;AAhNU,4BAAK,GAAG,4CAA2B,CAAC,CAAC,uEAAuE;AAgNtH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Iterator to iterate over array ChangeSets\n */\n\n\n import isNumber from \"lodash/isNumber\";\n import isString from \"lodash/isString\";\n\n// @ts-ignore\nimport { constants } from \"@fluid-experimental/property-common\";\n\nimport { SerializedChangeSet } from \"../changeset\";\nimport { ArrayIteratorOperationTypes } from \"./operationTypes\";\n\n\nconst { MSG } = constants;\n\n\n\ntype genericArray = Array<number | string | (SerializedChangeSet & {typeid:string})>;\nexport type arrayInsertList = [number, string | genericArray]\nexport type arrayModifyList = [number, string | genericArray] | [number, string, string] | [number, genericArray, genericArray]\nexport type arrayRemoveList = [number, number | string | genericArray]\n\n\n\n/**\n * Description of an array operation\n */\nexport interface OperationDescription {\n _absoluteBegin?: number;\n type?: ArrayIteratorOperationTypes,\n offset?: number,\n}\n\n/**\n * Description of an insert array operation\n */\nexport interface InsertOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.INSERT;\n removeInsertOperation?: arrayInsertList;\n operation?: arrayInsertList;\n}\n\n\n/**\n * Description of a remove array operation\n */\nexport interface RemoveOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.REMOVE;\n removeInsertOperation?: arrayRemoveList;\n operation?: arrayRemoveList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface ModifyOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.MODIFY;\n removeInsertOperation?: arrayModifyList;\n operation: arrayModifyList;\n}\n\n/**\n * Description of a modify array operation\n */\n export interface NOPOperation extends Omit<OperationDescription, \"removeInsertOperation\"|\"operation\"> {\n type: ArrayIteratorOperationTypes.NOP;\n operation?: [];\n}\n\nexport type NoneNOPOperation = RemoveOperation | InsertOperation | ModifyOperation;\nexport type GenericOperation = NoneNOPOperation | NOPOperation;\n\n/**\n * Iterator class which iterates over an array ChangeSet. It will successively return the operations ordered by their\n * position within the array. Additionally, it will keep track of the modifications to the array indices caused\n * by the previous operations.\n *\n */\nexport class ArrayChangeSetIterator {\n static types = ArrayIteratorOperationTypes; // @TODO Not sure if this is still required if we export it separately.\n\n private _changeSet: SerializedChangeSet;\n private _copiedModifies: string | any[];\n private _currentIndices: { insert: number; remove: number; modify: number; };\n private _currentOffset: number;\n private _lastOperationIndex: number;\n private _lastOperationOffset: number;\n\n private _atEnd: boolean;\n private _op: GenericOperation;\n\n public get opDescription(): GenericOperation {\n return this._op;\n }\n\n public get currentOffset(): number {\n return this._currentOffset;\n }\n\n public get lastOperationIndex(): number {\n return this._lastOperationIndex;\n }\n\n public get lastOperationOffset(): number {\n return this._lastOperationOffset;\n }\n\n /**\n * @param in_changeSet - The ChangeSet to iterate over (this has to be an array ChangeSet\n */\n constructor(in_changeSet: SerializedChangeSet) {\n this._changeSet = in_changeSet;\n // if we need to chop overlapping modifies internally, so we have to copy them\n // we do this lazy and only if really needed\n this._copiedModifies = in_changeSet.modify;\n this._currentIndices = {\n insert: 0,\n remove: 0,\n modify: 0,\n };\n\n this._currentOffset = 0;\n this._lastOperationIndex = -1;\n this._lastOperationOffset = 0;\n this._atEnd = false;\n\n this._op = {\n type: ArrayIteratorOperationTypes.NOP,\n offset: 0,\n operation: undefined\n };\n\n // go to the first element\n this.next();\n }\n\n /**\n * Returns the next operation in the ChangeSet\n * @returns true, if there are operations left\n */\n next(): boolean {\n // Find the smallest index in the operations lists\n let currentIndex = Infinity;\n let type: ArrayIteratorOperationTypes;\n (this._op as any).removeInsertOperation = undefined;\n // Process the current remove entry\n if (this._changeSet.remove &&\n this._currentIndices.remove < this._changeSet.remove.length) {\n type = ArrayChangeSetIterator.types.REMOVE;\n currentIndex = this._changeSet.remove[this._currentIndices.remove][0];\n let currentLength = this._changeSet.remove[this._currentIndices.remove][1];\n if (!isNumber(currentLength)) {\n currentLength = currentLength.length;\n }\n\n // Check, whether this is a removeInsertOperation\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] <= currentIndex + currentLength) {\n (this._op as InsertOperation).removeInsertOperation = this._changeSet.insert[this._currentIndices.insert];\n }\n }\n\n // Process the current insert entry (we prefer remove over insert, since this prevents the array from growing more\n // than necessary)\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.INSERT;\n currentIndex = this._changeSet.insert[this._currentIndices.insert][0];\n }\n\n // Process the current modify entry\n if (this._copiedModifies &&\n this._currentIndices.modify < this._copiedModifies.length &&\n this._copiedModifies[this._currentIndices.modify][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.MODIFY;\n }\n\n if (this._lastOperationIndex !== currentIndex) {\n this._currentOffset += this._lastOperationOffset;\n this._lastOperationIndex = currentIndex;\n this._lastOperationOffset = 0;\n }\n\n // We have found nothing, so we are at the end of the ChangeSet\n if (type === undefined) {\n this._op.type = ArrayChangeSetIterator.types.NOP;\n this._op.offset = this._currentOffset;\n this._op.operation = undefined;\n this._atEnd = true;\n return false;\n }\n\n // Determine the return value and update the internal indices and offsets depending on the next operation\n switch (type) {\n case ArrayChangeSetIterator.types.INSERT:\n this._op.type = ArrayChangeSetIterator.types.INSERT;\n // Define the return value\n this._op.operation = this._changeSet.insert[this._currentIndices.insert];\n this._op.offset = this._currentOffset;\n // Update the current offset. For an insert we have to increase it by the number of the inserted elements\n this._lastOperationOffset += (this._op.operation[1] as any).length;\n\n // Shift the internal index\n this._currentIndices.insert++;\n break;\n case ArrayChangeSetIterator.types.REMOVE:\n this._op.type = ArrayChangeSetIterator.types.REMOVE;\n // Define the return value\n this._op.operation = this._changeSet.remove[this._currentIndices.remove];\n this._op.offset = this._currentOffset;\n // Update the current offset. For a remove we have to decrement it by the number of the removed elements\n var removedElements = isNumber(this._op.operation[1]) ? this._op.operation[1] : this._op.operation[1].length;\n this._lastOperationOffset -= removedElements;\n\n // Shift the internal index\n this._currentIndices.remove++;\n break;\n case ArrayChangeSetIterator.types.MODIFY:\n {\n this._op.type = ArrayChangeSetIterator.types.MODIFY;\n this._op.offset = this._currentOffset;\n // check, if the modify's range overlaps with coming insert changes:\n let nextModify = this._copiedModifies[this._currentIndices.modify];\n const modifyEnd = nextModify[0] + nextModify[1].length;\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < modifyEnd) {\n // we have an overlap and need to cut the modify\n const insertPosition = this._changeSet.insert[this._currentIndices.insert][0];\n\n // if we haven't copied the change set's modifies yet, we need to do that now\n if (this._copiedModifies === this._changeSet.modify) {\n this._copiedModifies = this._copyModifies(this._changeSet.modify);\n // now we need to update nextModify!\n nextModify = this._copiedModifies[this._currentIndices.modify];\n }\n\n // use modify only up to insert's position\n\n // build a partial modify and cut the remaining one:\n const partialModify: arrayModifyList = [nextModify[0], undefined];\n if (isString(nextModify[1])) {\n partialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);\n nextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);\n } else {\n partialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);\n }\n\n nextModify[0] = insertPosition;\n\n // use the whole modify\n this._op.operation = partialModify;\n } else {\n // use the whole modify\n this._op.operation = nextModify;\n\n // Shift the internal index\n this._currentIndices.modify++;\n }\n break;\n }\n default:\n throw new Error(`ArrayChangeSetIterator: ${MSG.UNKNOWN_OPERATION}`);\n }\n this._atEnd = false;\n return true;\n };\n\n /**\n * @returns true, if there are no more operations left\n */\n atEnd(): boolean {\n return this._atEnd;\n };\n\n private _copyModifies(in_modifies: string[]) {\n if (!in_modifies || in_modifies.length === 0) {\n return undefined;\n }\n const result = [];\n for (let i = 0; i < in_modifies.length; i++) {\n result.push([in_modifies[i][0], in_modifies[i][1].slice()]);\n }\n return result;\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"arrayChangesetIterator.js","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAGF,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAExC,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAG/D,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AA2D1B;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IA6B/B;;OAEG;IACH,YAAY,YAAiC;QACzC,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;QAC/B,8EAA8E;QAC9E,4CAA4C;QAC5C,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,MAAM,CAAC;QAC3C,IAAI,CAAC,eAAe,GAAG;YACnB,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;SACZ,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QAEpB,IAAI,CAAC,GAAG,GAAG;YACP,IAAI,EAAE,2BAA2B,CAAC,GAAG;YACrC,MAAM,EAAE,CAAC;YACT,SAAS,EAAE,SAAS;SACvB,CAAC;QAEF,0BAA0B;QAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;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A,CAAC;IAEM,aAAa,CAAC,WAAqB;QACvC,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1C,OAAO,SAAS,CAAC;SACpB;QACD,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC/D;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAAA,CAAC;;AA/MK,4BAAK,GAAG,2BAA2B,CAAC,CAAC,uEAAuE;AAgNtH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Iterator to iterate over array ChangeSets\n */\n\n\n import isNumber from \"lodash/isNumber\";\n import isString from \"lodash/isString\";\n\n// @ts-ignore\nimport { constants } from \"@fluid-experimental/property-common\";\n\nimport { SerializedChangeSet } from \"../changeset\";\nimport { ArrayIteratorOperationTypes } from \"./operationTypes\";\n\n\nconst { MSG } = constants;\n\n\n\ntype genericArray = Array<number | string | (SerializedChangeSet & {typeid:string})>;\nexport type arrayInsertList = [number, string | genericArray]\nexport type arrayModifyList = [number, string | genericArray] | [number, string, string] | [number, genericArray, genericArray]\nexport type arrayRemoveList = [number, number | string | genericArray]\n\n\n\n/**\n * Description of an array operation\n */\nexport interface OperationDescription {\n _absoluteBegin?: number;\n type?: ArrayIteratorOperationTypes,\n offset?: number,\n}\n\n/**\n * Description of an insert array operation\n */\nexport interface InsertOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.INSERT;\n removeInsertOperation?: arrayInsertList;\n operation?: arrayInsertList;\n}\n\n\n/**\n * Description of a remove array operation\n */\nexport interface RemoveOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.REMOVE;\n removeInsertOperation?: arrayRemoveList;\n operation?: arrayRemoveList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface ModifyOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.MODIFY;\n removeInsertOperation?: arrayModifyList;\n operation: arrayModifyList;\n}\n\n/**\n * Description of a modify array operation\n */\n export interface NOPOperation extends Omit<OperationDescription, \"removeInsertOperation\"|\"operation\"> {\n type: ArrayIteratorOperationTypes.NOP;\n operation?: [];\n}\n\nexport type NoneNOPOperation = RemoveOperation | InsertOperation | ModifyOperation;\nexport type GenericOperation = NoneNOPOperation | NOPOperation;\n\n/**\n * Iterator class which iterates over an array ChangeSet. It will successively return the operations ordered by their\n * position within the array. Additionally, it will keep track of the modifications to the array indices caused\n * by the previous operations.\n *\n */\nexport class ArrayChangeSetIterator {\n static types = ArrayIteratorOperationTypes; // @TODO Not sure if this is still required if we export it separately.\n\n private _changeSet: SerializedChangeSet;\n private _copiedModifies: string | any[];\n private _currentIndices: { insert: number; remove: number; modify: number; };\n private _currentOffset: number;\n private _lastOperationIndex: number;\n private _lastOperationOffset: number;\n\n private _atEnd: boolean;\n private _op: GenericOperation;\n\n public get opDescription(): GenericOperation {\n return this._op;\n }\n\n public get currentOffset(): number {\n return this._currentOffset;\n }\n\n public get lastOperationIndex(): number {\n return this._lastOperationIndex;\n }\n\n public get lastOperationOffset(): number {\n return this._lastOperationOffset;\n }\n\n /**\n * @param in_changeSet - The ChangeSet to iterate over (this has to be an array ChangeSet\n */\n constructor(in_changeSet: SerializedChangeSet) {\n this._changeSet = in_changeSet;\n // if we need to chop overlapping modifies internally, so we have to copy them\n // we do this lazy and only if really needed\n this._copiedModifies = in_changeSet.modify;\n this._currentIndices = {\n insert: 0,\n remove: 0,\n modify: 0,\n };\n\n this._currentOffset = 0;\n this._lastOperationIndex = -1;\n this._lastOperationOffset = 0;\n this._atEnd = false;\n\n this._op = {\n type: ArrayIteratorOperationTypes.NOP,\n offset: 0,\n operation: undefined\n };\n\n // go to the first element\n this.next();\n }\n\n /**\n * Returns the next operation in the ChangeSet\n * @returns true, if there are operations left\n */\n next(): boolean {\n // Find the smallest index in the operations lists\n let currentIndex = Infinity;\n let type: ArrayIteratorOperationTypes;\n (this._op as any).removeInsertOperation = undefined;\n // Process the current remove entry\n if (this._changeSet.remove &&\n this._currentIndices.remove < this._changeSet.remove.length) {\n type = ArrayChangeSetIterator.types.REMOVE;\n currentIndex = this._changeSet.remove[this._currentIndices.remove][0];\n let currentLength = this._changeSet.remove[this._currentIndices.remove][1];\n if (!isNumber(currentLength)) {\n currentLength = currentLength.length;\n }\n\n // Check, whether this is a removeInsertOperation\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] <= currentIndex + currentLength) {\n (this._op as InsertOperation).removeInsertOperation = this._changeSet.insert[this._currentIndices.insert];\n }\n }\n\n // Process the current insert entry (we prefer remove over insert, since this prevents the array from growing more\n // than necessary)\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.INSERT;\n currentIndex = this._changeSet.insert[this._currentIndices.insert][0];\n }\n\n // Process the current modify entry\n if (this._copiedModifies &&\n this._currentIndices.modify < this._copiedModifies.length &&\n this._copiedModifies[this._currentIndices.modify][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.MODIFY;\n }\n\n if (this._lastOperationIndex !== currentIndex) {\n this._currentOffset += this._lastOperationOffset;\n this._lastOperationIndex = currentIndex;\n this._lastOperationOffset = 0;\n }\n\n // We have found nothing, so we are at the end of the ChangeSet\n if (type === undefined) {\n this._op.type = ArrayChangeSetIterator.types.NOP;\n this._op.offset = this._currentOffset;\n this._op.operation = undefined;\n this._atEnd = true;\n return false;\n }\n\n // Determine the return value and update the internal indices and offsets depending on the next operation\n switch (type) {\n case ArrayChangeSetIterator.types.INSERT:\n this._op.type = ArrayChangeSetIterator.types.INSERT;\n // Define the return value\n this._op.operation = this._changeSet.insert[this._currentIndices.insert];\n this._op.offset = this._currentOffset;\n // Update the current offset. For an insert we have to increase it by the number of the inserted elements\n this._lastOperationOffset += (this._op.operation[1] as any).length;\n\n // Shift the internal index\n this._currentIndices.insert++;\n break;\n case ArrayChangeSetIterator.types.REMOVE:\n this._op.type = ArrayChangeSetIterator.types.REMOVE;\n // Define the return value\n this._op.operation = this._changeSet.remove[this._currentIndices.remove];\n this._op.offset = this._currentOffset;\n // Update the current offset. For a remove we have to decrement it by the number of the removed elements\n var removedElements = isNumber(this._op.operation[1]) ? this._op.operation[1] : this._op.operation[1].length;\n this._lastOperationOffset -= removedElements;\n\n // Shift the internal index\n this._currentIndices.remove++;\n break;\n case ArrayChangeSetIterator.types.MODIFY:\n {\n this._op.type = ArrayChangeSetIterator.types.MODIFY;\n this._op.offset = this._currentOffset;\n // check, if the modify's range overlaps with coming insert changes:\n let nextModify = this._copiedModifies[this._currentIndices.modify];\n const modifyEnd = nextModify[0] + nextModify[1].length;\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < modifyEnd) {\n // we have an overlap and need to cut the modify\n const insertPosition = this._changeSet.insert[this._currentIndices.insert][0];\n\n // if we haven't copied the change set's modifies yet, we need to do that now\n if (this._copiedModifies === this._changeSet.modify) {\n this._copiedModifies = this._copyModifies(this._changeSet.modify);\n // now we need to update nextModify!\n nextModify = this._copiedModifies[this._currentIndices.modify];\n }\n\n // use modify only up to insert's position\n\n // build a partial modify and cut the remaining one:\n const partialModify: arrayModifyList = [nextModify[0], undefined];\n if (isString(nextModify[1])) {\n partialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);\n nextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);\n } else {\n partialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);\n }\n\n nextModify[0] = insertPosition;\n\n // use the whole modify\n this._op.operation = partialModify;\n } else {\n // use the whole modify\n this._op.operation = nextModify;\n\n // Shift the internal index\n this._currentIndices.modify++;\n }\n break;\n }\n default:\n throw new Error(`ArrayChangeSetIterator: ${MSG.UNKNOWN_OPERATION}`);\n }\n this._atEnd = false;\n return true;\n };\n\n /**\n * @returns true, if there are no more operations left\n */\n atEnd(): boolean {\n return this._atEnd;\n };\n\n private _copyModifies(in_modifies: string[]) {\n if (!in_modifies || in_modifies.length === 0) {\n return undefined;\n }\n const result = [];\n for (let i = 0; i < in_modifies.length; i++) {\n result.push([in_modifies[i][0], in_modifies[i][1].slice()]);\n }\n return result;\n };\n};\n"]}
1
+ {"version":3,"file":"arrayChangesetIterator.js","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAGF,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAExC,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAG/D,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AA2D1B;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IA6B/B;;OAEG;IACH,YAAY,YAAiC;QACzC,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;QAC/B,8EAA8E;QAC9E,4CAA4C;QAC5C,IAAI,CAAC,eAAe,GAAG,YAAY,CAAC,MAAM,CAAC;QAC3C,IAAI,CAAC,eAAe,GAAG;YACnB,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;SACZ,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,CAAC;QAC9B,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C;oBACD,MAAM;iBACT;YACL;gBACI,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC;SAC3E;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAAA,CAAC;IAEF;;OAEG;IACH,KAAK;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAAA,CAAC;IAEM,aAAa,CAAC,WAAqB;QACvC,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC1C,OAAO,SAAS,CAAC;SACpB;QACD,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACzC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC/D;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;IAAA,CAAC;;AA/MK,4BAAK,GAAG,2BAA2B,CAAC,CAAC,uEAAuE;AAgNtH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Iterator to iterate over array ChangeSets\n */\n\n\n import isNumber from \"lodash/isNumber\";\n import isString from \"lodash/isString\";\n\n// @ts-ignore\nimport { constants } from \"@fluid-experimental/property-common\";\n\nimport { SerializedChangeSet } from \"../changeset\";\nimport { ArrayIteratorOperationTypes } from \"./operationTypes\";\n\n\nconst { MSG } = constants;\n\n\n\ntype genericArray = Array<number | string | (SerializedChangeSet & {typeid:string})>;\nexport type arrayInsertList = [number, string | genericArray]\nexport type arrayModifyList = [number, string | genericArray] | [number, string, string] | [number, genericArray, genericArray]\nexport type arrayRemoveList = [number, number | string | genericArray]\n\n\n\n/**\n * Description of an array operation\n */\nexport interface OperationDescription {\n _absoluteBegin?: number;\n type?: ArrayIteratorOperationTypes,\n offset?: number,\n}\n\n/**\n * Description of an insert array operation\n */\nexport interface InsertOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.INSERT;\n removeInsertOperation?: arrayInsertList;\n operation?: arrayInsertList;\n}\n\n\n/**\n * Description of a remove array operation\n */\nexport interface RemoveOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.REMOVE;\n removeInsertOperation?: arrayRemoveList;\n operation?: arrayRemoveList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface ModifyOperation extends OperationDescription {\n type: ArrayIteratorOperationTypes.MODIFY;\n removeInsertOperation?: arrayModifyList;\n operation: arrayModifyList;\n}\n\n/**\n * Description of a modify array operation\n */\n export interface NOPOperation extends Omit<OperationDescription, \"removeInsertOperation\"|\"operation\"> {\n type: ArrayIteratorOperationTypes.NOP;\n operation?: [];\n}\n\nexport type NoneNOPOperation = RemoveOperation | InsertOperation | ModifyOperation;\nexport type GenericOperation = NoneNOPOperation | NOPOperation;\n\n/**\n * Iterator class which iterates over an array ChangeSet. It will successively return the operations ordered by their\n * position within the array. Additionally, it will keep track of the modifications to the array indices caused\n * by the previous operations.\n *\n */\nexport class ArrayChangeSetIterator {\n static types = ArrayIteratorOperationTypes; // @TODO Not sure if this is still required if we export it separately.\n\n private _changeSet: SerializedChangeSet;\n private _copiedModifies: string | any[];\n private _currentIndices: { insert: number; remove: number; modify: number; };\n private _currentOffset: number;\n private _lastOperationIndex: number;\n private _lastOperationOffset: number;\n\n private _atEnd: boolean;\n private _op: GenericOperation;\n\n public get opDescription(): GenericOperation {\n return this._op;\n }\n\n public get currentOffset(): number {\n return this._currentOffset;\n }\n\n public get lastOperationIndex(): number {\n return this._lastOperationIndex;\n }\n\n public get lastOperationOffset(): number {\n return this._lastOperationOffset;\n }\n\n /**\n * @param in_changeSet - The ChangeSet to iterate over (this has to be an array ChangeSet\n */\n constructor(in_changeSet: SerializedChangeSet) {\n this._changeSet = in_changeSet;\n // if we need to chop overlapping modifies internally, so we have to copy them\n // we do this lazy and only if really needed\n this._copiedModifies = in_changeSet.modify;\n this._currentIndices = {\n insert: 0,\n remove: 0,\n modify: 0,\n };\n\n this._currentOffset = 0;\n this._lastOperationIndex = -1;\n this._lastOperationOffset = 0;\n this._atEnd = false;\n\n this._op = {\n type: ArrayIteratorOperationTypes.NOP,\n offset: 0,\n operation: undefined\n };\n\n // go to the first element\n this.next();\n }\n\n /**\n * Returns the next operation in the ChangeSet\n * @returns true, if there are operations left\n */\n next(): boolean {\n // Find the smallest index in the operations lists\n let currentIndex = Infinity;\n let type: ArrayIteratorOperationTypes;\n (this._op as any).removeInsertOperation = undefined;\n // Process the current remove entry\n if (this._changeSet.remove &&\n this._currentIndices.remove < this._changeSet.remove.length) {\n type = ArrayChangeSetIterator.types.REMOVE;\n currentIndex = this._changeSet.remove[this._currentIndices.remove][0];\n let currentLength = this._changeSet.remove[this._currentIndices.remove][1];\n if (!isNumber(currentLength)) {\n currentLength = currentLength.length;\n }\n\n // Check, whether this is a removeInsertOperation\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] <= currentIndex + currentLength) {\n (this._op as InsertOperation).removeInsertOperation = this._changeSet.insert[this._currentIndices.insert];\n }\n }\n\n // Process the current insert entry (we prefer remove over insert, since this prevents the array from growing more\n // than necessary)\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.INSERT;\n currentIndex = this._changeSet.insert[this._currentIndices.insert][0];\n }\n\n // Process the current modify entry\n if (this._copiedModifies &&\n this._currentIndices.modify < this._copiedModifies.length &&\n this._copiedModifies[this._currentIndices.modify][0] < currentIndex) {\n type = ArrayChangeSetIterator.types.MODIFY;\n }\n\n if (this._lastOperationIndex !== currentIndex) {\n this._currentOffset += this._lastOperationOffset;\n this._lastOperationIndex = currentIndex;\n this._lastOperationOffset = 0;\n }\n\n // We have found nothing, so we are at the end of the ChangeSet\n if (type === undefined) {\n this._op.type = ArrayChangeSetIterator.types.NOP;\n this._op.offset = this._currentOffset;\n this._op.operation = undefined;\n this._atEnd = true;\n return false;\n }\n\n // Determine the return value and update the internal indices and offsets depending on the next operation\n switch (type) {\n case ArrayChangeSetIterator.types.INSERT:\n this._op.type = ArrayChangeSetIterator.types.INSERT;\n // Define the return value\n this._op.operation = this._changeSet.insert[this._currentIndices.insert];\n this._op.offset = this._currentOffset;\n // Update the current offset. For an insert we have to increase it by the number of the inserted elements\n this._lastOperationOffset += (this._op.operation[1] as any).length;\n\n // Shift the internal index\n this._currentIndices.insert++;\n break;\n case ArrayChangeSetIterator.types.REMOVE:\n this._op.type = ArrayChangeSetIterator.types.REMOVE;\n // Define the return value\n this._op.operation = this._changeSet.remove[this._currentIndices.remove];\n this._op.offset = this._currentOffset;\n // Update the current offset. For a remove we have to decrement it by the number of the removed elements\n var removedElements = isNumber(this._op.operation[1]) ? this._op.operation[1] : this._op.operation[1].length;\n this._lastOperationOffset -= removedElements;\n\n // Shift the internal index\n this._currentIndices.remove++;\n break;\n case ArrayChangeSetIterator.types.MODIFY:\n {\n this._op.type = ArrayChangeSetIterator.types.MODIFY;\n this._op.offset = this._currentOffset;\n // check, if the modify's range overlaps with coming insert changes:\n let nextModify = this._copiedModifies[this._currentIndices.modify];\n const modifyEnd = nextModify[0] + nextModify[1].length;\n if (this._changeSet.insert &&\n this._currentIndices.insert < this._changeSet.insert.length &&\n this._changeSet.insert[this._currentIndices.insert][0] < modifyEnd) {\n // we have an overlap and need to cut the modify\n const insertPosition = this._changeSet.insert[this._currentIndices.insert][0];\n\n // if we haven't copied the change set's modifies yet, we need to do that now\n if (this._copiedModifies === this._changeSet.modify) {\n this._copiedModifies = this._copyModifies(this._changeSet.modify);\n // now we need to update nextModify!\n nextModify = this._copiedModifies[this._currentIndices.modify];\n }\n\n // use modify only up to insert's position\n\n // build a partial modify and cut the remaining one:\n const partialModify: arrayModifyList = [nextModify[0], undefined];\n if (isString(nextModify[1])) {\n partialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);\n nextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);\n } else {\n partialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);\n }\n\n nextModify[0] = insertPosition;\n\n // use the whole modify\n this._op.operation = partialModify;\n } else {\n // use the whole modify\n this._op.operation = nextModify;\n\n // Shift the internal index\n this._currentIndices.modify++;\n }\n break;\n }\n default:\n throw new Error(`ArrayChangeSetIterator: ${MSG.UNKNOWN_OPERATION}`);\n }\n this._atEnd = false;\n return true;\n };\n\n /**\n * @returns true, if there are no more operations left\n */\n atEnd(): boolean {\n return this._atEnd;\n };\n\n private _copyModifies(in_modifies: string[]) {\n if (!in_modifies || in_modifies.length === 0) {\n return undefined;\n }\n const result = [];\n for (let i = 0; i < in_modifies.length; i++) {\n result.push([in_modifies[i][0], in_modifies[i][1].slice()]);\n }\n return result;\n };\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/property-changeset",
3
- "version": "0.56.7",
3
+ "version": "0.57.1",
4
4
  "description": "property changeset definitions and related functionalities",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": "https://github.com/microsoft/FluidFramework",
@@ -56,7 +56,7 @@
56
56
  "temp-directory": "nyc/.nyc_output"
57
57
  },
58
58
  "dependencies": {
59
- "@fluid-experimental/property-common": "^0.56.7",
59
+ "@fluid-experimental/property-common": "^0.57.1",
60
60
  "ajv": "7.1.1",
61
61
  "ajv-keywords": "4.0.0",
62
62
  "async": "^3.2.0",
@@ -67,7 +67,7 @@
67
67
  },
68
68
  "devDependencies": {
69
69
  "@fluidframework/build-common": "^0.23.0",
70
- "@fluidframework/mocha-test-setup": "^0.56.7",
70
+ "@fluidframework/mocha-test-setup": "^0.57.1",
71
71
  "@rushstack/eslint-config": "^2.5.1",
72
72
  "@types/lodash": "^4.14.118",
73
73
  "@types/mocha": "^8.2.2",