@fluid-experimental/property-changeset 2.0.0-internal.6.4.0 → 2.0.0-internal.7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/changeset.d.ts +2 -2
- package/dist/changeset.d.ts.map +1 -1
- package/dist/changeset_operations/array.d.ts +2 -2
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +1 -1
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.d.ts +6 -6
- package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.js +12 -12
- package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +1 -1
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/changeset_operations/operationTypes.js +1 -1
- package/dist/changeset_operations/operationTypes.js.map +1 -1
- package/dist/helpers/typeidHelper.js +1 -1
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/pathHelper.d.ts +1 -1
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +1 -1
- package/dist/pathHelper.js.map +1 -1
- package/dist/templateValidator.d.ts +3 -3
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/test/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.js +12 -12
- package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/package.json +5 -5
|
@@ -18,6 +18,18 @@ const { MSG } = constants;
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
export class ArrayChangeSetIterator {
|
|
21
|
+
get opDescription() {
|
|
22
|
+
return this._op;
|
|
23
|
+
}
|
|
24
|
+
get currentOffset() {
|
|
25
|
+
return this._currentOffset;
|
|
26
|
+
}
|
|
27
|
+
get lastOperationIndex() {
|
|
28
|
+
return this._lastOperationIndex;
|
|
29
|
+
}
|
|
30
|
+
get lastOperationOffset() {
|
|
31
|
+
return this._lastOperationOffset;
|
|
32
|
+
}
|
|
21
33
|
/**
|
|
22
34
|
* @param in_changeSet - The ChangeSet to iterate over (this has to be an array ChangeSet
|
|
23
35
|
*/
|
|
@@ -43,18 +55,6 @@ export class ArrayChangeSetIterator {
|
|
|
43
55
|
// go to the first element
|
|
44
56
|
this.next();
|
|
45
57
|
}
|
|
46
|
-
get opDescription() {
|
|
47
|
-
return this._op;
|
|
48
|
-
}
|
|
49
|
-
get currentOffset() {
|
|
50
|
-
return this._currentOffset;
|
|
51
|
-
}
|
|
52
|
-
get lastOperationIndex() {
|
|
53
|
-
return this._lastOperationIndex;
|
|
54
|
-
}
|
|
55
|
-
get lastOperationOffset() {
|
|
56
|
-
return this._lastOperationOffset;
|
|
57
|
-
}
|
|
58
58
|
/**
|
|
59
59
|
* Returns the next operation in the ChangeSet
|
|
60
60
|
* @returns true, if there are operations left
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrayChangesetIterator.js","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AA0D1B;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IA6BlC;;OAEG;IACH,YAAY,YAAiC;QAC5C,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;QAC/B,8EAA8E;QAC9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3E;oBAED,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC;oBAE/B,uBAAuB;oBACvB,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,aAAa,CAAC;iBACnC;qBAAM;oBACN,uBAAuB;oBACvB,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,UAAU,CAAC;oBAEhC,2BAA2B;oBAC3B,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;iBAC9B;gBACD,MAAM;aACN;YACD;gBACC,MAAM,IAAI,KAAK,CAAC,2BAA2B,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC;SACrE;QACD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;OAEG;IACH,KAAK;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAEO,aAAa,CAAC,WAAqB;QAC1C,IAAI,CAAC,WAAW,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;YAC7C,OAAO,SAAS,CAAC;SACjB;QACD,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC5C,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;SAC5D;QACD,OAAO,MAAM,CAAC;IACf,CAAC;;AAzNM,4BAAK,GAAG,2BAA2B,CAAC,CAAC,uEAAuE","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\nimport isNumber from \"lodash/isNumber\";\nimport 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\nconst { MSG } = constants;\n\ntype genericArray = (number | string | (SerializedChangeSet & { typeid: string }))[];\nexport type arrayInsertList = [number, string | genericArray];\nexport type arrayModifyList =\n\t| [number, string | genericArray]\n\t| [number, string, string]\n\t| [number, genericArray, genericArray];\nexport type arrayRemoveList = [number, number | string | genericArray];\n\n/**\n * Description of an array operation\n */\nexport interface OperationDescription {\n\t_absoluteBegin?: number;\n\ttype?: ArrayIteratorOperationTypes;\n\toffset?: number;\n}\n\n/**\n * Description of an insert array operation\n */\nexport interface InsertOperation extends OperationDescription {\n\ttype: ArrayIteratorOperationTypes.INSERT;\n\tremoveInsertOperation?: arrayInsertList;\n\toperation?: arrayInsertList;\n}\n\n/**\n * Description of a remove array operation\n */\nexport interface RemoveOperation extends OperationDescription {\n\ttype: ArrayIteratorOperationTypes.REMOVE;\n\tremoveInsertOperation?: arrayRemoveList;\n\toperation?: arrayRemoveList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface ModifyOperation extends OperationDescription {\n\ttype: ArrayIteratorOperationTypes.MODIFY;\n\tremoveInsertOperation?: arrayModifyList;\n\toperation: arrayModifyList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface NOPOperation\n\textends Omit<OperationDescription, \"removeInsertOperation\" | \"operation\"> {\n\ttype: ArrayIteratorOperationTypes.NOP;\n\toperation?: [];\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\tstatic types = ArrayIteratorOperationTypes; // @TODO Not sure if this is still required if we export it separately.\n\n\tprivate readonly _changeSet: SerializedChangeSet;\n\tprivate _copiedModifies: string | any[];\n\tprivate readonly _currentIndices: { insert: number; remove: number; modify: number };\n\tprivate _currentOffset: number;\n\tprivate _lastOperationIndex: number;\n\tprivate _lastOperationOffset: number;\n\n\tprivate _atEnd: boolean;\n\tprivate _op: GenericOperation;\n\n\tpublic get opDescription(): GenericOperation {\n\t\treturn this._op;\n\t}\n\n\tpublic get currentOffset(): number {\n\t\treturn this._currentOffset;\n\t}\n\n\tpublic get lastOperationIndex(): number {\n\t\treturn this._lastOperationIndex;\n\t}\n\n\tpublic get lastOperationOffset(): number {\n\t\treturn this._lastOperationOffset;\n\t}\n\n\t/**\n\t * @param in_changeSet - The ChangeSet to iterate over (this has to be an array ChangeSet\n\t */\n\tconstructor(in_changeSet: SerializedChangeSet) {\n\t\tthis._changeSet = in_changeSet;\n\t\t// if we need to chop overlapping modifies internally, so we have to copy them\n\t\t// we do this lazy and only if really needed\n\t\tthis._copiedModifies = in_changeSet.modify;\n\t\tthis._currentIndices = {\n\t\t\tinsert: 0,\n\t\t\tremove: 0,\n\t\t\tmodify: 0,\n\t\t};\n\n\t\tthis._currentOffset = 0;\n\t\tthis._lastOperationIndex = -1;\n\t\tthis._lastOperationOffset = 0;\n\t\tthis._atEnd = false;\n\n\t\tthis._op = {\n\t\t\ttype: ArrayIteratorOperationTypes.NOP,\n\t\t\toffset: 0,\n\t\t\toperation: undefined,\n\t\t};\n\n\t\t// go to the first element\n\t\tthis.next();\n\t}\n\n\t/**\n\t * Returns the next operation in the ChangeSet\n\t * @returns true, if there are operations left\n\t */\n\tnext(): boolean {\n\t\t// Find the smallest index in the operations lists\n\t\tlet currentIndex = Infinity;\n\t\tlet type: ArrayIteratorOperationTypes;\n\t\t(this._op as any).removeInsertOperation = undefined;\n\t\t// Process the current remove entry\n\t\tif (this._changeSet.remove && this._currentIndices.remove < this._changeSet.remove.length) {\n\t\t\ttype = ArrayChangeSetIterator.types.REMOVE;\n\t\t\tcurrentIndex = this._changeSet.remove[this._currentIndices.remove][0];\n\t\t\tlet currentLength = this._changeSet.remove[this._currentIndices.remove][1];\n\t\t\tif (!isNumber(currentLength)) {\n\t\t\t\tcurrentLength = currentLength.length;\n\t\t\t}\n\n\t\t\t// Check, whether this is a removeInsertOperation\n\t\t\tif (\n\t\t\t\tthis._changeSet.insert &&\n\t\t\t\tthis._currentIndices.insert < this._changeSet.insert.length &&\n\t\t\t\tthis._changeSet.insert[this._currentIndices.insert][0] <=\n\t\t\t\t\tcurrentIndex + currentLength\n\t\t\t) {\n\t\t\t\t(this._op as InsertOperation).removeInsertOperation =\n\t\t\t\t\tthis._changeSet.insert[this._currentIndices.insert];\n\t\t\t}\n\t\t}\n\n\t\t// Process the current insert entry (we prefer remove over insert, since this prevents the array from growing more\n\t\t// than necessary)\n\t\tif (\n\t\t\tthis._changeSet.insert &&\n\t\t\tthis._currentIndices.insert < this._changeSet.insert.length &&\n\t\t\tthis._changeSet.insert[this._currentIndices.insert][0] < currentIndex\n\t\t) {\n\t\t\ttype = ArrayChangeSetIterator.types.INSERT;\n\t\t\tcurrentIndex = this._changeSet.insert[this._currentIndices.insert][0];\n\t\t}\n\n\t\t// Process the current modify entry\n\t\tif (\n\t\t\tthis._copiedModifies &&\n\t\t\tthis._currentIndices.modify < this._copiedModifies.length &&\n\t\t\tthis._copiedModifies[this._currentIndices.modify][0] < currentIndex\n\t\t) {\n\t\t\ttype = ArrayChangeSetIterator.types.MODIFY;\n\t\t}\n\n\t\tif (this._lastOperationIndex !== currentIndex) {\n\t\t\tthis._currentOffset += this._lastOperationOffset;\n\t\t\tthis._lastOperationIndex = currentIndex;\n\t\t\tthis._lastOperationOffset = 0;\n\t\t}\n\n\t\t// We have found nothing, so we are at the end of the ChangeSet\n\t\tif (type === undefined) {\n\t\t\tthis._op.type = ArrayChangeSetIterator.types.NOP;\n\t\t\tthis._op.offset = this._currentOffset;\n\t\t\tthis._op.operation = undefined;\n\t\t\tthis._atEnd = true;\n\t\t\treturn false;\n\t\t}\n\n\t\t// Determine the return value and update the internal indices and offsets depending on the next operation\n\t\tswitch (type) {\n\t\t\tcase ArrayChangeSetIterator.types.INSERT:\n\t\t\t\tthis._op.type = ArrayChangeSetIterator.types.INSERT;\n\t\t\t\t// Define the return value\n\t\t\t\tthis._op.operation = this._changeSet.insert[this._currentIndices.insert];\n\t\t\t\tthis._op.offset = this._currentOffset;\n\t\t\t\t// Update the current offset. For an insert we have to increase it by the number of the inserted elements\n\t\t\t\tthis._lastOperationOffset += (this._op.operation[1] as any).length;\n\n\t\t\t\t// Shift the internal index\n\t\t\t\tthis._currentIndices.insert++;\n\t\t\t\tbreak;\n\t\t\tcase ArrayChangeSetIterator.types.REMOVE:\n\t\t\t\tthis._op.type = ArrayChangeSetIterator.types.REMOVE;\n\t\t\t\t// Define the return value\n\t\t\t\tthis._op.operation = this._changeSet.remove[this._currentIndices.remove];\n\t\t\t\tthis._op.offset = this._currentOffset;\n\t\t\t\t// Update the current offset. For a remove we have to decrement it by the number of the removed elements\n\t\t\t\tvar removedElements = isNumber(this._op.operation[1])\n\t\t\t\t\t? this._op.operation[1]\n\t\t\t\t\t: this._op.operation[1].length;\n\t\t\t\tthis._lastOperationOffset -= removedElements;\n\n\t\t\t\t// Shift the internal index\n\t\t\t\tthis._currentIndices.remove++;\n\t\t\t\tbreak;\n\t\t\tcase ArrayChangeSetIterator.types.MODIFY: {\n\t\t\t\tthis._op.type = ArrayChangeSetIterator.types.MODIFY;\n\t\t\t\tthis._op.offset = this._currentOffset;\n\t\t\t\t// check, if the modify's range overlaps with coming insert changes:\n\t\t\t\tlet nextModify = this._copiedModifies[this._currentIndices.modify];\n\t\t\t\tconst modifyEnd = nextModify[0] + nextModify[1].length;\n\t\t\t\tif (\n\t\t\t\t\tthis._changeSet.insert &&\n\t\t\t\t\tthis._currentIndices.insert < this._changeSet.insert.length &&\n\t\t\t\t\tthis._changeSet.insert[this._currentIndices.insert][0] < modifyEnd\n\t\t\t\t) {\n\t\t\t\t\t// we have an overlap and need to cut the modify\n\t\t\t\t\tconst insertPosition = this._changeSet.insert[this._currentIndices.insert][0];\n\n\t\t\t\t\t// if we haven't copied the change set's modifies yet, we need to do that now\n\t\t\t\t\tif (this._copiedModifies === this._changeSet.modify) {\n\t\t\t\t\t\tthis._copiedModifies = this._copyModifies(this._changeSet.modify);\n\t\t\t\t\t\t// now we need to update nextModify!\n\t\t\t\t\t\tnextModify = this._copiedModifies[this._currentIndices.modify];\n\t\t\t\t\t}\n\n\t\t\t\t\t// use modify only up to insert's position\n\n\t\t\t\t\t// build a partial modify and cut the remaining one:\n\t\t\t\t\tconst partialModify: arrayModifyList = [nextModify[0], undefined];\n\t\t\t\t\tif (isString(nextModify[1])) {\n\t\t\t\t\t\tpartialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);\n\t\t\t\t\t\tnextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpartialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);\n\t\t\t\t\t}\n\n\t\t\t\t\tnextModify[0] = insertPosition;\n\n\t\t\t\t\t// use the whole modify\n\t\t\t\t\tthis._op.operation = partialModify;\n\t\t\t\t} else {\n\t\t\t\t\t// use the whole modify\n\t\t\t\t\tthis._op.operation = nextModify;\n\n\t\t\t\t\t// Shift the internal index\n\t\t\t\t\tthis._currentIndices.modify++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`ArrayChangeSetIterator: ${MSG.UNKNOWN_OPERATION}`);\n\t\t}\n\t\tthis._atEnd = false;\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns true, if there are no more operations left\n\t */\n\tatEnd(): boolean {\n\t\treturn this._atEnd;\n\t}\n\n\tprivate _copyModifies(in_modifies: string[]) {\n\t\tif (!in_modifies || in_modifies.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst result = [];\n\t\tfor (let i = 0; i < in_modifies.length; i++) {\n\t\t\tresult.push([in_modifies[i][0], in_modifies[i][1].slice()]);\n\t\t}\n\t\treturn result;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"arrayChangesetIterator.js","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AACvC,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAEvC,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAGhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;AA0D1B;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAalC,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,GAAG,CAAC;IACjB,CAAC;IAED,IAAW,aAAa;QACvB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC5B,CAAC;IAED,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC,mBAAmB,CAAC;IACjC,CAAC;IAED,IAAW,mBAAmB;QAC7B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,YAAY,YAAiC;QAC5C,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;YACtB,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;SACT,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;YACV,IAA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AAG,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC5C,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;SAC5D;QACD,OAAO,MAAM,CAAC;IACf,CAAC;;AAzNM,4BAAK,GAAG,2BAA2B,CAAC,CAAC,uEAAuE","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\nimport isNumber from \"lodash/isNumber\";\nimport 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\nconst { MSG } = constants;\n\ntype genericArray = (number | string | (SerializedChangeSet & { typeid: string }))[];\nexport type arrayInsertList = [number, string | genericArray];\nexport type arrayModifyList =\n\t| [number, string | genericArray]\n\t| [number, string, string]\n\t| [number, genericArray, genericArray];\nexport type arrayRemoveList = [number, number | string | genericArray];\n\n/**\n * Description of an array operation\n */\nexport interface OperationDescription {\n\t_absoluteBegin?: number;\n\ttype?: ArrayIteratorOperationTypes;\n\toffset?: number;\n}\n\n/**\n * Description of an insert array operation\n */\nexport interface InsertOperation extends OperationDescription {\n\ttype: ArrayIteratorOperationTypes.INSERT;\n\tremoveInsertOperation?: arrayInsertList;\n\toperation?: arrayInsertList;\n}\n\n/**\n * Description of a remove array operation\n */\nexport interface RemoveOperation extends OperationDescription {\n\ttype: ArrayIteratorOperationTypes.REMOVE;\n\tremoveInsertOperation?: arrayRemoveList;\n\toperation?: arrayRemoveList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface ModifyOperation extends OperationDescription {\n\ttype: ArrayIteratorOperationTypes.MODIFY;\n\tremoveInsertOperation?: arrayModifyList;\n\toperation: arrayModifyList;\n}\n\n/**\n * Description of a modify array operation\n */\nexport interface NOPOperation\n\textends Omit<OperationDescription, \"removeInsertOperation\" | \"operation\"> {\n\ttype: ArrayIteratorOperationTypes.NOP;\n\toperation?: [];\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\tstatic types = ArrayIteratorOperationTypes; // @TODO Not sure if this is still required if we export it separately.\n\n\tprivate readonly _changeSet: SerializedChangeSet;\n\tprivate _copiedModifies: string | any[];\n\tprivate readonly _currentIndices: { insert: number; remove: number; modify: number };\n\tprivate _currentOffset: number;\n\tprivate _lastOperationIndex: number;\n\tprivate _lastOperationOffset: number;\n\n\tprivate _atEnd: boolean;\n\tprivate _op: GenericOperation;\n\n\tpublic get opDescription(): GenericOperation {\n\t\treturn this._op;\n\t}\n\n\tpublic get currentOffset(): number {\n\t\treturn this._currentOffset;\n\t}\n\n\tpublic get lastOperationIndex(): number {\n\t\treturn this._lastOperationIndex;\n\t}\n\n\tpublic get lastOperationOffset(): number {\n\t\treturn this._lastOperationOffset;\n\t}\n\n\t/**\n\t * @param in_changeSet - The ChangeSet to iterate over (this has to be an array ChangeSet\n\t */\n\tconstructor(in_changeSet: SerializedChangeSet) {\n\t\tthis._changeSet = in_changeSet;\n\t\t// if we need to chop overlapping modifies internally, so we have to copy them\n\t\t// we do this lazy and only if really needed\n\t\tthis._copiedModifies = in_changeSet.modify;\n\t\tthis._currentIndices = {\n\t\t\tinsert: 0,\n\t\t\tremove: 0,\n\t\t\tmodify: 0,\n\t\t};\n\n\t\tthis._currentOffset = 0;\n\t\tthis._lastOperationIndex = -1;\n\t\tthis._lastOperationOffset = 0;\n\t\tthis._atEnd = false;\n\n\t\tthis._op = {\n\t\t\ttype: ArrayIteratorOperationTypes.NOP,\n\t\t\toffset: 0,\n\t\t\toperation: undefined,\n\t\t};\n\n\t\t// go to the first element\n\t\tthis.next();\n\t}\n\n\t/**\n\t * Returns the next operation in the ChangeSet\n\t * @returns true, if there are operations left\n\t */\n\tnext(): boolean {\n\t\t// Find the smallest index in the operations lists\n\t\tlet currentIndex = Infinity;\n\t\tlet type: ArrayIteratorOperationTypes;\n\t\t(this._op as any).removeInsertOperation = undefined;\n\t\t// Process the current remove entry\n\t\tif (this._changeSet.remove && this._currentIndices.remove < this._changeSet.remove.length) {\n\t\t\ttype = ArrayChangeSetIterator.types.REMOVE;\n\t\t\tcurrentIndex = this._changeSet.remove[this._currentIndices.remove][0];\n\t\t\tlet currentLength = this._changeSet.remove[this._currentIndices.remove][1];\n\t\t\tif (!isNumber(currentLength)) {\n\t\t\t\tcurrentLength = currentLength.length;\n\t\t\t}\n\n\t\t\t// Check, whether this is a removeInsertOperation\n\t\t\tif (\n\t\t\t\tthis._changeSet.insert &&\n\t\t\t\tthis._currentIndices.insert < this._changeSet.insert.length &&\n\t\t\t\tthis._changeSet.insert[this._currentIndices.insert][0] <=\n\t\t\t\t\tcurrentIndex + currentLength\n\t\t\t) {\n\t\t\t\t(this._op as InsertOperation).removeInsertOperation =\n\t\t\t\t\tthis._changeSet.insert[this._currentIndices.insert];\n\t\t\t}\n\t\t}\n\n\t\t// Process the current insert entry (we prefer remove over insert, since this prevents the array from growing more\n\t\t// than necessary)\n\t\tif (\n\t\t\tthis._changeSet.insert &&\n\t\t\tthis._currentIndices.insert < this._changeSet.insert.length &&\n\t\t\tthis._changeSet.insert[this._currentIndices.insert][0] < currentIndex\n\t\t) {\n\t\t\ttype = ArrayChangeSetIterator.types.INSERT;\n\t\t\tcurrentIndex = this._changeSet.insert[this._currentIndices.insert][0];\n\t\t}\n\n\t\t// Process the current modify entry\n\t\tif (\n\t\t\tthis._copiedModifies &&\n\t\t\tthis._currentIndices.modify < this._copiedModifies.length &&\n\t\t\tthis._copiedModifies[this._currentIndices.modify][0] < currentIndex\n\t\t) {\n\t\t\ttype = ArrayChangeSetIterator.types.MODIFY;\n\t\t}\n\n\t\tif (this._lastOperationIndex !== currentIndex) {\n\t\t\tthis._currentOffset += this._lastOperationOffset;\n\t\t\tthis._lastOperationIndex = currentIndex;\n\t\t\tthis._lastOperationOffset = 0;\n\t\t}\n\n\t\t// We have found nothing, so we are at the end of the ChangeSet\n\t\tif (type === undefined) {\n\t\t\tthis._op.type = ArrayChangeSetIterator.types.NOP;\n\t\t\tthis._op.offset = this._currentOffset;\n\t\t\tthis._op.operation = undefined;\n\t\t\tthis._atEnd = true;\n\t\t\treturn false;\n\t\t}\n\n\t\t// Determine the return value and update the internal indices and offsets depending on the next operation\n\t\tswitch (type) {\n\t\t\tcase ArrayChangeSetIterator.types.INSERT:\n\t\t\t\tthis._op.type = ArrayChangeSetIterator.types.INSERT;\n\t\t\t\t// Define the return value\n\t\t\t\tthis._op.operation = this._changeSet.insert[this._currentIndices.insert];\n\t\t\t\tthis._op.offset = this._currentOffset;\n\t\t\t\t// Update the current offset. For an insert we have to increase it by the number of the inserted elements\n\t\t\t\tthis._lastOperationOffset += (this._op.operation[1] as any).length;\n\n\t\t\t\t// Shift the internal index\n\t\t\t\tthis._currentIndices.insert++;\n\t\t\t\tbreak;\n\t\t\tcase ArrayChangeSetIterator.types.REMOVE:\n\t\t\t\tthis._op.type = ArrayChangeSetIterator.types.REMOVE;\n\t\t\t\t// Define the return value\n\t\t\t\tthis._op.operation = this._changeSet.remove[this._currentIndices.remove];\n\t\t\t\tthis._op.offset = this._currentOffset;\n\t\t\t\t// Update the current offset. For a remove we have to decrement it by the number of the removed elements\n\t\t\t\tvar removedElements = isNumber(this._op.operation[1])\n\t\t\t\t\t? this._op.operation[1]\n\t\t\t\t\t: this._op.operation[1].length;\n\t\t\t\tthis._lastOperationOffset -= removedElements;\n\n\t\t\t\t// Shift the internal index\n\t\t\t\tthis._currentIndices.remove++;\n\t\t\t\tbreak;\n\t\t\tcase ArrayChangeSetIterator.types.MODIFY: {\n\t\t\t\tthis._op.type = ArrayChangeSetIterator.types.MODIFY;\n\t\t\t\tthis._op.offset = this._currentOffset;\n\t\t\t\t// check, if the modify's range overlaps with coming insert changes:\n\t\t\t\tlet nextModify = this._copiedModifies[this._currentIndices.modify];\n\t\t\t\tconst modifyEnd = nextModify[0] + nextModify[1].length;\n\t\t\t\tif (\n\t\t\t\t\tthis._changeSet.insert &&\n\t\t\t\t\tthis._currentIndices.insert < this._changeSet.insert.length &&\n\t\t\t\t\tthis._changeSet.insert[this._currentIndices.insert][0] < modifyEnd\n\t\t\t\t) {\n\t\t\t\t\t// we have an overlap and need to cut the modify\n\t\t\t\t\tconst insertPosition = this._changeSet.insert[this._currentIndices.insert][0];\n\n\t\t\t\t\t// if we haven't copied the change set's modifies yet, we need to do that now\n\t\t\t\t\tif (this._copiedModifies === this._changeSet.modify) {\n\t\t\t\t\t\tthis._copiedModifies = this._copyModifies(this._changeSet.modify);\n\t\t\t\t\t\t// now we need to update nextModify!\n\t\t\t\t\t\tnextModify = this._copiedModifies[this._currentIndices.modify];\n\t\t\t\t\t}\n\n\t\t\t\t\t// use modify only up to insert's position\n\n\t\t\t\t\t// build a partial modify and cut the remaining one:\n\t\t\t\t\tconst partialModify: arrayModifyList = [nextModify[0], undefined];\n\t\t\t\t\tif (isString(nextModify[1])) {\n\t\t\t\t\t\tpartialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);\n\t\t\t\t\t\tnextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpartialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);\n\t\t\t\t\t}\n\n\t\t\t\t\tnextModify[0] = insertPosition;\n\n\t\t\t\t\t// use the whole modify\n\t\t\t\t\tthis._op.operation = partialModify;\n\t\t\t\t} else {\n\t\t\t\t\t// use the whole modify\n\t\t\t\t\tthis._op.operation = nextModify;\n\n\t\t\t\t\t// Shift the internal index\n\t\t\t\t\tthis._currentIndices.modify++;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`ArrayChangeSetIterator: ${MSG.UNKNOWN_OPERATION}`);\n\t\t}\n\t\tthis._atEnd = false;\n\t\treturn true;\n\t}\n\n\t/**\n\t * @returns true, if there are no more operations left\n\t */\n\tatEnd(): boolean {\n\t\treturn this._atEnd;\n\t}\n\n\tprivate _copyModifies(in_modifies: string[]) {\n\t\tif (!in_modifies || in_modifies.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst result = [];\n\t\tfor (let i = 0; i < in_modifies.length; i++) {\n\t\t\tresult.push([in_modifies[i][0], in_modifies[i][1].slice()]);\n\t\t}\n\t\treturn result;\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/property-changeset",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.7.0.0",
|
|
4
4
|
"description": "property changeset definitions and related functionalities",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"temp-directory": "nyc/.nyc_output"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@fluid-experimental/property-common": ">=2.0.0-internal.
|
|
42
|
+
"@fluid-experimental/property-common": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
43
43
|
"ajv": "7.1.1",
|
|
44
44
|
"ajv-keywords": "4.0.0",
|
|
45
45
|
"async": "^3.2.2",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@fluidframework/build-common": "^2.0.0",
|
|
53
|
-
"@fluidframework/build-tools": "^0.
|
|
54
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.
|
|
53
|
+
"@fluidframework/build-tools": "^0.24.0",
|
|
54
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.7.0.0 <2.0.0-internal.7.1.0",
|
|
55
55
|
"@types/lodash": "^4.14.118",
|
|
56
56
|
"@types/mocha": "^9.1.1",
|
|
57
57
|
"@types/node": "^16.18.38",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"prettier": "~2.6.2",
|
|
69
69
|
"rimraf": "^4.4.0",
|
|
70
70
|
"sinon": "^7.4.2",
|
|
71
|
-
"typescript": "~
|
|
71
|
+
"typescript": "~5.1.6"
|
|
72
72
|
},
|
|
73
73
|
"typeValidation": {
|
|
74
74
|
"disabled": true,
|