@fluid-experimental/property-changeset 2.0.0-internal.3.0.5 → 2.0.0-internal.3.1.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.
Files changed (113) hide show
  1. package/README.md +1 -0
  2. package/dist/changeset.d.ts +2 -2
  3. package/dist/changeset.d.ts.map +1 -1
  4. package/dist/changeset.js +61 -45
  5. package/dist/changeset.js.map +1 -1
  6. package/dist/changeset_operations/array.d.ts +6 -6
  7. package/dist/changeset_operations/array.d.ts.map +1 -1
  8. package/dist/changeset_operations/array.js +87 -56
  9. package/dist/changeset_operations/array.js.map +1 -1
  10. package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
  11. package/dist/changeset_operations/arrayChangesetIterator.js +43 -41
  12. package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
  13. package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
  14. package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
  15. package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
  16. package/dist/changeset_operations/indexedCollection.js +76 -44
  17. package/dist/changeset_operations/indexedCollection.js.map +1 -1
  18. package/dist/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
  19. package/dist/changeset_operations/isEmptyChangeset.js +2 -1
  20. package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
  21. package/dist/changeset_operations/operationTypes.d.ts.map +1 -1
  22. package/dist/changeset_operations/operationTypes.js.map +1 -1
  23. package/dist/helpers/typeidHelper.d.ts +10 -10
  24. package/dist/helpers/typeidHelper.d.ts.map +1 -1
  25. package/dist/helpers/typeidHelper.js +19 -17
  26. package/dist/helpers/typeidHelper.js.map +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/isReservedKeyword.d.ts.map +1 -1
  30. package/dist/isReservedKeyword.js.map +1 -1
  31. package/dist/pathHelper.d.ts.map +1 -1
  32. package/dist/pathHelper.js +16 -10
  33. package/dist/pathHelper.js.map +1 -1
  34. package/dist/rebase.d.ts.map +1 -1
  35. package/dist/rebase.js +20 -13
  36. package/dist/rebase.js.map +1 -1
  37. package/dist/templateSchema.d.ts.map +1 -1
  38. package/dist/templateSchema.js +10 -11
  39. package/dist/templateSchema.js.map +1 -1
  40. package/dist/templateValidator.d.ts.map +1 -1
  41. package/dist/templateValidator.js +135 -102
  42. package/dist/templateValidator.js.map +1 -1
  43. package/dist/test/array.spec.js +141 -343
  44. package/dist/test/array.spec.js.map +1 -1
  45. package/dist/test/pathHelper.spec.js +299 -166
  46. package/dist/test/pathHelper.spec.js.map +1 -1
  47. package/dist/test/reversibleCs.spec.js.map +1 -1
  48. package/dist/test/schemaValidator.js +3 -1
  49. package/dist/test/schemaValidator.js.map +1 -1
  50. package/dist/test/schemas/badBothPropertiesAndTypeid.js +8 -8
  51. package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
  52. package/dist/test/schemas/badInvalidSemverInTypeid.js +18 -16
  53. package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
  54. package/dist/test/schemas/badMissingSemverInTypeid.js +18 -16
  55. package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
  56. package/dist/test/schemas/badNestedProperties.js +18 -17
  57. package/dist/test/schemas/badNestedProperties.js.map +1 -1
  58. package/dist/test/schemas/badPrimitiveTypeid.js +9 -8
  59. package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
  60. package/dist/test/schemas/badVersionedTypeid.js +19 -17
  61. package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
  62. package/dist/test/schemas/goodColorPalette.js +4 -4
  63. package/dist/test/schemas/goodColorPalette.js.map +1 -1
  64. package/dist/test/schemas/goodDraftAsVersion.js +2 -4
  65. package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
  66. package/dist/test/schemas/goodPointId.js +18 -16
  67. package/dist/test/schemas/goodPointId.js.map +1 -1
  68. package/dist/test/schemas/goodReferenceAndRegular.js +5 -5
  69. package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
  70. package/dist/test/schemas/goodReservedTypes.js +8 -7
  71. package/dist/test/schemas/goodReservedTypes.js.map +1 -1
  72. package/dist/test/schemas/goodUIBorder.js +19 -16
  73. package/dist/test/schemas/goodUIBorder.js.map +1 -1
  74. package/dist/test/tsconfig.tsbuildinfo +1 -1
  75. package/dist/test/validator/templateSyntax.spec.js.map +1 -1
  76. package/dist/test/validator/templateValidator.spec.js +329 -306
  77. package/dist/test/validator/templateValidator.spec.js.map +1 -1
  78. package/dist/test/validator/typeidHelper.spec.js +98 -65
  79. package/dist/test/validator/typeidHelper.spec.js.map +1 -1
  80. package/dist/utils.d.ts +1 -1
  81. package/dist/utils.d.ts.map +1 -1
  82. package/dist/utils.js +149 -95
  83. package/dist/utils.js.map +1 -1
  84. package/dist/validationResultBuilder.d.ts.map +1 -1
  85. package/dist/validationResultBuilder.js.map +1 -1
  86. package/lib/changeset.js +63 -47
  87. package/lib/changeset.js.map +1 -1
  88. package/lib/changeset_operations/array.js +88 -57
  89. package/lib/changeset_operations/array.js.map +1 -1
  90. package/lib/changeset_operations/arrayChangesetIterator.js +43 -41
  91. package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
  92. package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
  93. package/lib/changeset_operations/indexedCollection.js +76 -44
  94. package/lib/changeset_operations/indexedCollection.js.map +1 -1
  95. package/lib/changeset_operations/isEmptyChangeset.js +2 -1
  96. package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
  97. package/lib/changeset_operations/operationTypes.js.map +1 -1
  98. package/lib/helpers/typeidHelper.js +19 -17
  99. package/lib/helpers/typeidHelper.js.map +1 -1
  100. package/lib/index.js.map +1 -1
  101. package/lib/isReservedKeyword.js.map +1 -1
  102. package/lib/pathHelper.js +17 -11
  103. package/lib/pathHelper.js.map +1 -1
  104. package/lib/rebase.js +20 -13
  105. package/lib/rebase.js.map +1 -1
  106. package/lib/templateSchema.js +10 -11
  107. package/lib/templateSchema.js.map +1 -1
  108. package/lib/templateValidator.js +135 -102
  109. package/lib/templateValidator.js.map +1 -1
  110. package/lib/utils.js +149 -95
  111. package/lib/utils.js.map +1 -1
  112. package/lib/validationResultBuilder.js.map +1 -1
  113. package/package.json +100 -100
@@ -71,8 +71,7 @@ class ArrayChangeSetIterator {
71
71
  let type;
72
72
  this._op.removeInsertOperation = undefined;
73
73
  // Process the current remove entry
74
- if (this._changeSet.remove &&
75
- this._currentIndices.remove < this._changeSet.remove.length) {
74
+ if (this._changeSet.remove && this._currentIndices.remove < this._changeSet.remove.length) {
76
75
  type = ArrayChangeSetIterator.types.REMOVE;
77
76
  currentIndex = this._changeSet.remove[this._currentIndices.remove][0];
78
77
  let currentLength = this._changeSet.remove[this._currentIndices.remove][1];
@@ -82,8 +81,10 @@ class ArrayChangeSetIterator {
82
81
  // Check, whether this is a removeInsertOperation
83
82
  if (this._changeSet.insert &&
84
83
  this._currentIndices.insert < this._changeSet.insert.length &&
85
- this._changeSet.insert[this._currentIndices.insert][0] <= currentIndex + currentLength) {
86
- this._op.removeInsertOperation = this._changeSet.insert[this._currentIndices.insert];
84
+ this._changeSet.insert[this._currentIndices.insert][0] <=
85
+ currentIndex + currentLength) {
86
+ this._op.removeInsertOperation =
87
+ this._changeSet.insert[this._currentIndices.insert];
87
88
  }
88
89
  }
89
90
  // Process the current insert entry (we prefer remove over insert, since this prevents the array from growing more
@@ -131,51 +132,52 @@ class ArrayChangeSetIterator {
131
132
  this._op.operation = this._changeSet.remove[this._currentIndices.remove];
132
133
  this._op.offset = this._currentOffset;
133
134
  // Update the current offset. For a remove we have to decrement it by the number of the removed elements
134
- var removedElements = (0, isNumber_1.default)(this._op.operation[1]) ? this._op.operation[1] : this._op.operation[1].length;
135
+ var removedElements = (0, isNumber_1.default)(this._op.operation[1])
136
+ ? this._op.operation[1]
137
+ : this._op.operation[1].length;
135
138
  this._lastOperationOffset -= removedElements;
136
139
  // Shift the internal index
137
140
  this._currentIndices.remove++;
138
141
  break;
139
- case ArrayChangeSetIterator.types.MODIFY:
140
- {
141
- this._op.type = ArrayChangeSetIterator.types.MODIFY;
142
- this._op.offset = this._currentOffset;
143
- // check, if the modify's range overlaps with coming insert changes:
144
- let nextModify = this._copiedModifies[this._currentIndices.modify];
145
- const modifyEnd = nextModify[0] + nextModify[1].length;
146
- if (this._changeSet.insert &&
147
- this._currentIndices.insert < this._changeSet.insert.length &&
148
- this._changeSet.insert[this._currentIndices.insert][0] < modifyEnd) {
149
- // we have an overlap and need to cut the modify
150
- const insertPosition = this._changeSet.insert[this._currentIndices.insert][0];
151
- // if we haven't copied the change set's modifies yet, we need to do that now
152
- if (this._copiedModifies === this._changeSet.modify) {
153
- this._copiedModifies = this._copyModifies(this._changeSet.modify);
154
- // now we need to update nextModify!
155
- nextModify = this._copiedModifies[this._currentIndices.modify];
156
- }
157
- // use modify only up to insert's position
158
- // build a partial modify and cut the remaining one:
159
- const partialModify = [nextModify[0], undefined];
160
- if ((0, isString_1.default)(nextModify[1])) {
161
- partialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);
162
- nextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);
163
- }
164
- else {
165
- partialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);
166
- }
167
- nextModify[0] = insertPosition;
168
- // use the whole modify
169
- this._op.operation = partialModify;
142
+ case ArrayChangeSetIterator.types.MODIFY: {
143
+ this._op.type = ArrayChangeSetIterator.types.MODIFY;
144
+ this._op.offset = this._currentOffset;
145
+ // check, if the modify's range overlaps with coming insert changes:
146
+ let nextModify = this._copiedModifies[this._currentIndices.modify];
147
+ const modifyEnd = nextModify[0] + nextModify[1].length;
148
+ if (this._changeSet.insert &&
149
+ this._currentIndices.insert < this._changeSet.insert.length &&
150
+ this._changeSet.insert[this._currentIndices.insert][0] < modifyEnd) {
151
+ // we have an overlap and need to cut the modify
152
+ const insertPosition = this._changeSet.insert[this._currentIndices.insert][0];
153
+ // if we haven't copied the change set's modifies yet, we need to do that now
154
+ if (this._copiedModifies === this._changeSet.modify) {
155
+ this._copiedModifies = this._copyModifies(this._changeSet.modify);
156
+ // now we need to update nextModify!
157
+ nextModify = this._copiedModifies[this._currentIndices.modify];
158
+ }
159
+ // use modify only up to insert's position
160
+ // build a partial modify and cut the remaining one:
161
+ const partialModify = [nextModify[0], undefined];
162
+ if ((0, isString_1.default)(nextModify[1])) {
163
+ partialModify[1] = nextModify[1].substr(0, insertPosition - nextModify[0]);
164
+ nextModify[1] = nextModify[1].substr(insertPosition - nextModify[0]);
170
165
  }
171
166
  else {
172
- // use the whole modify
173
- this._op.operation = nextModify;
174
- // Shift the internal index
175
- this._currentIndices.modify++;
167
+ partialModify[1] = nextModify[1].splice(0, insertPosition - nextModify[0]);
176
168
  }
177
- break;
169
+ nextModify[0] = insertPosition;
170
+ // use the whole modify
171
+ this._op.operation = partialModify;
172
+ }
173
+ else {
174
+ // use the whole modify
175
+ this._op.operation = nextModify;
176
+ // Shift the internal index
177
+ this._currentIndices.modify++;
178
178
  }
179
+ break;
180
+ }
179
181
  default:
180
182
  throw new Error(`ArrayChangeSetIterator: ${MSG.UNKNOWN_OPERATION}`);
181
183
  }
@@ -1 +1 @@
1
- {"version":3,"file":"arrayChangesetIterator.js","sourceRoot":"","sources":["../../src/changeset_operations/arrayChangesetIterator.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;;;;AAEF,+DAAuC;AACvC,+DAAuC;AAExC,aAAa;AACb,yEAAgE;AAGhE,qDAA+D;AAE/D,MAAM,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AAsD1B;;;;;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,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uB;wBACvB,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,aAAa,CAAC;qBACtC;yBAAM;wBACH,uBAAuB;wBACvB,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,UAAU,CAAC;wBAEhC,2BAA2B;wBAC3B,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;qBACjC;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;IAED;;OAEG;IACH,KAAK;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEO,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;;AAhNL,wDAiNC;AAhNU,4BAAK,GAAG,4CAA2B,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\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\nconst { MSG } = constants;\n\ntype genericArray = (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 * 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 * 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 readonly _changeSet: SerializedChangeSet;\n private _copiedModifies: string | any[];\n private readonly _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;;;;;;AAEH,+DAAuC;AACvC,+DAAuC;AAEvC,aAAa;AACb,yEAAgE;AAGhE,qDAA+D;AAE/D,MAAM,EAAE,GAAG,EAAE,GAAG,2BAAS,CAAC;AA0D1B;;;;;GAKG;AACH,MAAa,sBAAsB;IA6BlC;;OAEG;IACH,YAAY,YAAiC;QAC5C,IAAI,CAAC,U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CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;qBAC3E;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;;AA1NF,wDA2NC;AA1NO,4BAAK,GAAG,4CAA2B,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 +1 @@
1
- {"version":3,"file":"changesetConflictTypes.d.ts","sourceRoot":"","sources":["../../src/changeset_operations/changesetConflictTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,oBAAY,YAAY;IACpB,oGAAoG;IACpG,sBAAsB,IAAI;IAC1B,6CAA6C;IAC7C,aAAa,IAAA;IACb,wCAAwC;IACxC,2BAA2B,IAAA;IAC3B;;;;OAIG;IACH,sCAAsC,IAAA;IACtC,kEAAkE;IAClE,4BAA4B,IAAA;IAC5B,+GAA+G;IAC/G,mBAAmB,IAAA;IAEnB,kBAAkB,IAAA;IAElB,uBAAuB,IAAA;CAC1B"}
1
+ {"version":3,"file":"changesetConflictTypes.d.ts","sourceRoot":"","sources":["../../src/changeset_operations/changesetConflictTypes.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAEH,oBAAY,YAAY;IACvB,oGAAoG;IACpG,sBAAsB,IAAI;IAC1B,6CAA6C;IAC7C,aAAa,IAAA;IACb,wCAAwC;IACxC,2BAA2B,IAAA;IAC3B;;;;OAIG;IACH,sCAAsC,IAAA;IACtC,kEAAkE;IAClE,4BAA4B,IAAA;IAC5B,+GAA+G;IAC/G,mBAAmB,IAAA;IAEnB,kBAAkB,IAAA;IAElB,uBAAuB,IAAA;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"changesetConflictTypes.js","sourceRoot":"","sources":["../../src/changeset_operations/changesetConflictTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,IAAY,YAqBX;AArBD,WAAY,YAAY;IACpB,oGAAoG;IACpG,mFAA0B,CAAA;IAC1B,6CAA6C;IAC7C,iEAAa,CAAA;IACb,wCAAwC;IACxC,6FAA2B,CAAA;IAC3B;;;;OAIG;IACH,mHAAsC,CAAA;IACtC,kEAAkE;IAClE,+FAA4B,CAAA;IAC5B,+GAA+G;IAC/G,6EAAmB,CAAA;IACnB,oDAAoD;IACpD,2EAAkB,CAAA;IAClB,+CAA+C;IAC/C,qFAAuB,CAAA;AAC3B,CAAC,EArBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAqBvB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Conflict types that can occur during changeset operations\n */\n\nexport enum ConflictType {\n /** We had two incompatible ChangeSets, they probably were with respect to different base commits */\n INVALID_CHANGESET_BASE = 1,\n /** A value was changed in both ChangeSets */\n COLLIDING_SET,\n /** A deleted child node was modified */\n ENTRY_MODIFIED_AFTER_REMOVE,\n /** A child was modified after it had been removed and added.\n *\n * The modification can no longer be applied, since the affected object has changed and thus\n * the ChangeSet is no longer compatible.\n */\n ENTRY_MODIFICATION_AFTER_REMOVE_INSERT,\n /** An entry with the same key was inserted into the collection */\n INSERTED_ENTRY_WITH_SAME_KEY,\n /** A property was removed after a modify, this should mostly be safe, be we report it for completeness sake */\n REMOVE_AFTER_MODIFY,\n // Templates do not match from one commit to another\n MISMATCH_TEMPLATES,\n // Tried to insert inside a removed array range\n INSERT_IN_REMOVED_RANGE,\n}\n"]}
1
+ {"version":3,"file":"changesetConflictTypes.js","sourceRoot":"","sources":["../../src/changeset_operations/changesetConflictTypes.ts"],"names":[],"mappings":";AAAA;;;GAGG;AACH;;GAEG;;;AAEH,IAAY,YAqBX;AArBD,WAAY,YAAY;IACvB,oGAAoG;IACpG,mFAA0B,CAAA;IAC1B,6CAA6C;IAC7C,iEAAa,CAAA;IACb,wCAAwC;IACxC,6FAA2B,CAAA;IAC3B;;;;OAIG;IACH,mHAAsC,CAAA;IACtC,kEAAkE;IAClE,+FAA4B,CAAA;IAC5B,+GAA+G;IAC/G,6EAAmB,CAAA;IACnB,oDAAoD;IACpD,2EAAkB,CAAA;IAClB,+CAA+C;IAC/C,qFAAuB,CAAA;AACxB,CAAC,EArBW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAqBvB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n/**\n * @fileoverview Conflict types that can occur during changeset operations\n */\n\nexport enum ConflictType {\n\t/** We had two incompatible ChangeSets, they probably were with respect to different base commits */\n\tINVALID_CHANGESET_BASE = 1,\n\t/** A value was changed in both ChangeSets */\n\tCOLLIDING_SET,\n\t/** A deleted child node was modified */\n\tENTRY_MODIFIED_AFTER_REMOVE,\n\t/** A child was modified after it had been removed and added.\n\t *\n\t * The modification can no longer be applied, since the affected object has changed and thus\n\t * the ChangeSet is no longer compatible.\n\t */\n\tENTRY_MODIFICATION_AFTER_REMOVE_INSERT,\n\t/** An entry with the same key was inserted into the collection */\n\tINSERTED_ENTRY_WITH_SAME_KEY,\n\t/** A property was removed after a modify, this should mostly be safe, be we report it for completeness sake */\n\tREMOVE_AFTER_MODIFY,\n\t// Templates do not match from one commit to another\n\tMISMATCH_TEMPLATES,\n\t// Tried to insert inside a removed array range\n\tINSERT_IN_REMOVED_RANGE,\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"indexedCollection.d.ts","sourceRoot":"","sources":["../../src/changeset_operations/indexedCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAWH,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAsCxF,yBAAiB,mCAAmC,CAAC;IACjD;;;;;;;;;;;;;OAaG;IACI,MAAM,6CAA6C,2BAC9B,mBAAmB,6BAChB,mBAAmB,aACnC,MAAM,cACL,qBAAqB,SAgUpC,CAAC;IAEF;;;;;;;;;;;;;;;OAeG;IACI,MAAM,4CAA4C,4BAC5B,mBAAmB,8BAChB,mBAAmB,eAClC,MAAM,aACR,MAAM,8BACW,OAAO,iBACpB,YAAY,EAAE,cACjB,qBAAqB,SA+UpC,CAAC;IAEF;;;;;;OAMG;IACI,MAAM,gCAAgC,uBAAgC,mBAAmB,sBAAsB,OAAO,SAwD5H,CAAC;CACL"}
1
+ {"version":3,"file":"indexedCollection.d.ts","sourceRoot":"","sources":["../../src/changeset_operations/indexedCollection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;GAEG;AAWH,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAsCxF,yBAAiB,mCAAmC,CAAC;IACpD;;;;;;;;;;;;;OAaG;IACI,MAAM,6CAA6C,2BACjC,mBAAmB,6BAChB,mBAAmB,aACnC,MAAM,cACL,qBAAqB,SAoXjC,CAAC;IAEF;;;;;;;;;;;;;;;OAeG;IACI,MAAM,4CAA4C,4BAC/B,mBAAmB,8BAChB,mBAAmB,eAClC,MAAM,aACR,MAAM,8BACW,OAAO,iBACpB,YAAY,EAAE,cACjB,qBAAqB,SAmYjC,CAAC;IAEF;;;;;;OAMG;IACI,MAAM,gCAAgC,uBACxB,mBAAmB,sBACnB,OAAO,SAyD3B,CAAC;CACF"}
@@ -74,8 +74,9 @@ var ChangeSetIndexedCollectionFunctions;
74
74
  // Get and initialize the corresponding entries in the existing collection
75
75
  let removedEntries = in_appliedPropertyChanges.remove;
76
76
  io_basePropertyChanges = io_basePropertyChanges || {};
77
- io_basePropertyChanges.remove = io_basePropertyChanges.remove ||
78
- (Array.isArray(in_appliedPropertyChanges.remove) ? [] : {});
77
+ io_basePropertyChanges.remove =
78
+ io_basePropertyChanges.remove ||
79
+ (Array.isArray(in_appliedPropertyChanges.remove) ? [] : {});
79
80
  let baseInserted = io_basePropertyChanges.insert || {};
80
81
  let baseRemoved = io_basePropertyChanges.remove;
81
82
  let baseModified = io_basePropertyChanges.modify;
@@ -100,7 +101,8 @@ var ChangeSetIndexedCollectionFunctions;
100
101
  }
101
102
  }
102
103
  else {
103
- if (baseModified && baseModified[removedTypes[t]] &&
104
+ if (baseModified &&
105
+ baseModified[removedTypes[t]] &&
104
106
  baseModified[removedTypes[t]][removedKeys[i]] !== undefined) {
105
107
  delete baseModified[removedTypes[t]][removedKeys[i]];
106
108
  // If all entries for a typeid have been removed, we can remove
@@ -116,7 +118,8 @@ var ChangeSetIndexedCollectionFunctions;
116
118
  if (!baseRemoved[removedTypes[t]]) {
117
119
  baseRemoved[removedTypes[t]] = {};
118
120
  }
119
- baseRemoved[removedTypes[t]][removedKeys[i]] = removedEntries[removedTypes[t]][removedKeys[i]];
121
+ baseRemoved[removedTypes[t]][removedKeys[i]] =
122
+ removedEntries[removedTypes[t]][removedKeys[i]];
120
123
  }
121
124
  }
122
125
  }
@@ -199,11 +202,14 @@ var ChangeSetIndexedCollectionFunctions;
199
202
  let baseRemoved = io_basePropertyChanges.remove;
200
203
  // Insert the inserted entries
201
204
  // If no typeids are included, we just use a placeholder for the iteration below
202
- const insertedTypeids = isPrimitiveTypeid ? [undefined] : Object.keys(in_appliedPropertyChanges.insert);
205
+ const insertedTypeids = isPrimitiveTypeid
206
+ ? [undefined]
207
+ : Object.keys(in_appliedPropertyChanges.insert);
203
208
  for (let i = 0; i < insertedTypeids.length; i++) {
204
209
  let typeid = insertedTypeids[i];
205
- const insertedEntries = isPrimitiveTypeid ?
206
- in_appliedPropertyChanges.insert : in_appliedPropertyChanges.insert[typeid];
210
+ const insertedEntries = isPrimitiveTypeid
211
+ ? in_appliedPropertyChanges.insert
212
+ : in_appliedPropertyChanges.insert[typeid];
207
213
  const insertedKeys = Object.keys(insertedEntries);
208
214
  let removalCS;
209
215
  if (baseRemoved) {
@@ -217,7 +223,10 @@ var ChangeSetIndexedCollectionFunctions;
217
223
  // TODO: We should actually compute a diff between the two and recursively convert portions to modifies
218
224
  // Instead, right now, we only handle the case where the two keys cancel each out perfectly, i.e.,
219
225
  // the insert is reinserting exactly what was removed.
220
- if (!isPrimitiveTypeid && removalCS && (0, isObject_1.default)(removalCS) && removalCS[key] !== undefined) {
226
+ if (!isPrimitiveTypeid &&
227
+ removalCS &&
228
+ (0, isObject_1.default)(removalCS) &&
229
+ removalCS[key] !== undefined) {
221
230
  // Split out the two parts: all the keys other than remove/insert should match exactly.
222
231
  // The contents 'remove' and 'insert', if they exist, should also match.
223
232
  deeplyEqualCS = !!insertedEntries[key].insert === !!removalCS[key].remove;
@@ -226,13 +235,20 @@ var ChangeSetIndexedCollectionFunctions;
226
235
  deeplyEqualCS = (0, isEqual_1.default)(insertedEntries[key].insert, removalCS[key].remove);
227
236
  }
228
237
  // Finally, check if the data being inserted matches the data that was removed
229
- const insertedEntry = (0, isObject_1.default)(insertedEntries[key]) ? (0, without_1.default)(insertedEntries[key], "insert") : insertedEntries[key];
230
- const removedEntry = (0, isObject_1.default)(removalCS[key]) ? (0, without_1.default)(removalCS[key], "remove") : removalCS[key];
238
+ const insertedEntry = (0, isObject_1.default)(insertedEntries[key])
239
+ ? (0, without_1.default)(insertedEntries[key], "insert")
240
+ : insertedEntries[key];
241
+ const removedEntry = (0, isObject_1.default)(removalCS[key])
242
+ ? (0, without_1.default)(removalCS[key], "remove")
243
+ : removalCS[key];
231
244
  deeplyEqualCS = deeplyEqualCS && (0, isEqual_1.default)(insertedEntry, removedEntry);
232
245
  }
233
- if ((isPrimitiveTypeid || typeidHelper_1.TypeIdHelper.isPrimitiveType(typeid) || deeplyEqualCS) &&
246
+ if ((isPrimitiveTypeid ||
247
+ typeidHelper_1.TypeIdHelper.isPrimitiveType(typeid) ||
248
+ deeplyEqualCS) &&
234
249
  removalCS &&
235
- ((Array.isArray(removalCS) && (0, includes_1.default)(baseRemoved, key)) || removalCS[key] !== undefined)) {
250
+ ((Array.isArray(removalCS) && (0, includes_1.default)(baseRemoved, key)) ||
251
+ removalCS[key] !== undefined)) {
236
252
  // A remove and insert are combined into a modify for primitive types
237
253
  // Remove the old remove command
238
254
  let oldValueMatches = false;
@@ -245,7 +261,8 @@ var ChangeSetIndexedCollectionFunctions;
245
261
  }
246
262
  }
247
263
  else {
248
- oldValueMatches = deeplyEqualCS || (removalCS[key] === insertedEntries[key]);
264
+ oldValueMatches =
265
+ deeplyEqualCS || removalCS[key] === insertedEntries[key];
249
266
  delete removalCS[key];
250
267
  }
251
268
  // Insert a modify command instead
@@ -255,7 +272,8 @@ var ChangeSetIndexedCollectionFunctions;
255
272
  io_basePropertyChanges.modify[key] = insertedEntries[key];
256
273
  }
257
274
  else {
258
- io_basePropertyChanges.modify[typeid] = io_basePropertyChanges.modify[typeid] || {};
275
+ io_basePropertyChanges.modify[typeid] =
276
+ io_basePropertyChanges.modify[typeid] || {};
259
277
  io_basePropertyChanges.modify[typeid][key] = (0, fastest_json_copy_1.copy)(insertedEntries[key]);
260
278
  }
261
279
  }
@@ -263,7 +281,8 @@ var ChangeSetIndexedCollectionFunctions;
263
281
  else if (isPrimitiveTypeid && baseInserted[key] === undefined) {
264
282
  baseInserted[key] = insertedEntries[key];
265
283
  }
266
- else if (!isPrimitiveTypeid && (!baseInserted[typeid] || baseInserted[typeid][key] === undefined)) {
284
+ else if (!isPrimitiveTypeid &&
285
+ (!baseInserted[typeid] || baseInserted[typeid][key] === undefined)) {
267
286
  baseInserted[typeid] = baseInserted[typeid] || {};
268
287
  baseInserted[typeid][key] = (0, fastest_json_copy_1.copy)(insertedEntries[key]);
269
288
  }
@@ -325,7 +344,8 @@ var ChangeSetIndexedCollectionFunctions;
325
344
  if (typeid === "Int64" || typeid === "Uint64") {
326
345
  newValue = newValue.slice();
327
346
  }
328
- if (baseInserted[typeid][key] && baseInserted[typeid][key].hasOwnProperty("value")) {
347
+ if (baseInserted[typeid][key] &&
348
+ baseInserted[typeid][key].hasOwnProperty("value")) {
329
349
  baseInserted[typeid][key].value = newValue;
330
350
  }
331
351
  else {
@@ -336,7 +356,8 @@ var ChangeSetIndexedCollectionFunctions;
336
356
  this.performApplyAfterOnPropertyWithTypeid(key, baseInserted[typeid], modifiedEntries[typeid], typeid, false, in_options);
337
357
  }
338
358
  }
339
- else if (baseModified[typeid] && baseModified[typeid][key] !== undefined) {
359
+ else if (baseModified[typeid] &&
360
+ baseModified[typeid][key] !== undefined) {
340
361
  // If there was a previous modification operation, we have to merge the two
341
362
  if (isEntryPrimitiveType && typeid !== "String") {
342
363
  // Primitive types can simply be overwritten, however we have an exception for
@@ -403,9 +424,9 @@ var ChangeSetIndexedCollectionFunctions;
403
424
  const key = keys[j];
404
425
  // Store the type of the change
405
426
  changesByKeys[key] = changesByKeys[key] || {};
406
- changesByKeys[key][in_changePrefix] = changesByKeys[key][in_changePrefix] ?
407
- `${changesByKeys[key][in_changePrefix]}_${in_changeIdentifier}` :
408
- in_changeIdentifier;
427
+ changesByKeys[key][in_changePrefix] = changesByKeys[key][in_changePrefix]
428
+ ? `${changesByKeys[key][in_changePrefix]}_${in_changeIdentifier}`
429
+ : in_changeIdentifier;
409
430
  // If applicable store the typeid of the change
410
431
  if (in_typeidChange) {
411
432
  changesByKeys[key][`${in_changePrefix}Typeid`] = in_typeidChange;
@@ -472,9 +493,9 @@ var ChangeSetIndexedCollectionFunctions;
472
493
  const changedKeys = Object.keys(changesByKeys);
473
494
  for (let i = 0; i < changedKeys.length; i++) {
474
495
  const key = changedKeys[i];
475
- const newPath = in_useSquareBracketsInPath ?
476
- `${in_basePath}[${pathHelper_1.PathHelper.quotePathSegmentIfNeeded(key)}]` :
477
- (0, property_common_1.joinPaths)(in_basePath, pathHelper_1.PathHelper.quotePathSegmentIfNeeded(key), PROPERTY_PATH_DELIMITER);
496
+ const newPath = in_useSquareBracketsInPath
497
+ ? `${in_basePath}[${pathHelper_1.PathHelper.quotePathSegmentIfNeeded(key)}]`
498
+ : (0, property_common_1.joinPaths)(in_basePath, pathHelper_1.PathHelper.quotePathSegmentIfNeeded(key), PROPERTY_PATH_DELIMITER);
478
499
  const modification = changesByKeys[key];
479
500
  if (modification.own && modification.other) {
480
501
  /*
@@ -512,7 +533,8 @@ var ChangeSetIndexedCollectionFunctions;
512
533
  // A key was modified after it had been removed
513
534
  if (modification.own === "modify" && modification.other === "modify") {
514
535
  if (isPrimitiveTypeid ||
515
- (typeidHelper_1.TypeIdHelper.isPrimitiveType(modification.ownTypeid) && modification.ownTypeid !== "String")) {
536
+ (typeidHelper_1.TypeIdHelper.isPrimitiveType(modification.ownTypeid) &&
537
+ modification.ownTypeid !== "String")) {
516
538
  // We have two modification operations that affect the same entry for a base type.
517
539
  // This is a legal operation, the second one will overwrite the first one, but we
518
540
  // report it as a possible conflict
@@ -534,10 +556,13 @@ var ChangeSetIndexedCollectionFunctions;
534
556
  ownValue = ownValue.value;
535
557
  }
536
558
  let rebaseValue = rebasedModify[key];
537
- if (typeof rebaseValue === "object" && rebaseValue.hasOwnProperty("value")) {
559
+ if (typeof rebaseValue === "object" &&
560
+ rebaseValue.hasOwnProperty("value")) {
538
561
  rebaseValue = rebaseValue.value;
539
562
  }
540
- if (modification.ownTypeid === "Int64" || modification.ownTypeid === "Uint64" || ownValue.length === 2) {
563
+ if (modification.ownTypeid === "Int64" ||
564
+ modification.ownTypeid === "Uint64" ||
565
+ ownValue.length === 2) {
541
566
  // For (u)int64, values are arrays of 2 elements
542
567
  if (ownValue[0] === rebaseValue[0] && ownValue[1] === rebaseValue[1]) {
543
568
  delete rebasedModify[key];
@@ -554,8 +579,9 @@ var ChangeSetIndexedCollectionFunctions;
554
579
  }
555
580
  }
556
581
  else if (modification.own === "remove" && modification.other === "modify") {
557
- modifyMap = modification.otherTypeid ? io_rebasePropertyChangeSet.modify[modification.otherTypeid] :
558
- io_rebasePropertyChangeSet.modify;
582
+ modifyMap = modification.otherTypeid
583
+ ? io_rebasePropertyChangeSet.modify[modification.otherTypeid]
584
+ : io_rebasePropertyChangeSet.modify;
559
585
  // Create the conflict information
560
586
  let conflict = {
561
587
  path: newPath,
@@ -566,7 +592,8 @@ var ChangeSetIndexedCollectionFunctions;
566
592
  // Delete the modification from the rebased ChangeSet
567
593
  delete modifyMap[key];
568
594
  }
569
- else if (modification.own === "remove_insert" && modification.other === "modify") {
595
+ else if (modification.own === "remove_insert" &&
596
+ modification.other === "modify") {
570
597
  // We have a conflicting change. A node was removed and inserted (replaced) in the original
571
598
  // ChangeSet and then modified by the rebased ChangeSet. Since the base of the modification
572
599
  // can have been changed significantly by this operation, we don't know whether we can
@@ -584,8 +611,9 @@ var ChangeSetIndexedCollectionFunctions;
584
611
  else if ((modification.own === "modify" || modification.own === "remove") &&
585
612
  (modification.other === "remove" || modification.other === "remove_insert")) {
586
613
  if (modification.own === "modify") {
587
- modifyMap = modification.ownTypeid ? in_ownPropertyChangeSet.modify[modification.ownTypeid] :
588
- in_ownPropertyChangeSet.modify;
614
+ modifyMap = modification.ownTypeid
615
+ ? in_ownPropertyChangeSet.modify[modification.ownTypeid]
616
+ : in_ownPropertyChangeSet.modify;
589
617
  // Create the conflict information
590
618
  let conflict = {
591
619
  path: newPath,
@@ -610,10 +638,10 @@ var ChangeSetIndexedCollectionFunctions;
610
638
  }
611
639
  }
612
640
  else if (modification.own === "insert" && modification.other === "insert") {
613
- if (isPrimitiveTypeid ||
614
- (typeidHelper_1.TypeIdHelper.isPrimitiveType(modification.ownTypeid))) {
615
- let insertMap = modification.otherTypeid ? io_rebasePropertyChangeSet.insert[modification.otherTypeid] :
616
- io_rebasePropertyChangeSet.insert;
641
+ if (isPrimitiveTypeid || typeidHelper_1.TypeIdHelper.isPrimitiveType(modification.ownTypeid)) {
642
+ let insertMap = modification.otherTypeid
643
+ ? io_rebasePropertyChangeSet.insert[modification.otherTypeid]
644
+ : io_rebasePropertyChangeSet.insert;
617
645
  // We have two insert operations that affect the same key for a primitive type.
618
646
  // This is a legal operation, the second one will overwrite the first one, but we
619
647
  // report it as a possible conflicting set
@@ -626,14 +654,16 @@ var ChangeSetIndexedCollectionFunctions;
626
654
  // Convert to modify
627
655
  let oldValue;
628
656
  if (modification.otherTypeid) {
629
- io_rebasePropertyChangeSet.modify = io_rebasePropertyChangeSet.modify || {};
657
+ io_rebasePropertyChangeSet.modify =
658
+ io_rebasePropertyChangeSet.modify || {};
630
659
  io_rebasePropertyChangeSet.modify[modification.otherTypeid] =
631
660
  io_rebasePropertyChangeSet.modify[modification.otherTypeid] || {};
632
661
  modifyMap = io_rebasePropertyChangeSet.modify[modification.otherTypeid];
633
662
  oldValue = in_ownPropertyChangeSet.insert[modification.ownTypeid][key];
634
663
  }
635
664
  else {
636
- io_rebasePropertyChangeSet.modify = io_rebasePropertyChangeSet.modify || {};
665
+ io_rebasePropertyChangeSet.modify =
666
+ io_rebasePropertyChangeSet.modify || {};
637
667
  modifyMap = io_rebasePropertyChangeSet.modify;
638
668
  oldValue = in_ownPropertyChangeSet.insert[key];
639
669
  }
@@ -643,8 +673,9 @@ var ChangeSetIndexedCollectionFunctions;
643
673
  else {
644
674
  // Here we have two insert operations for objects. Since these affect a whole sub-tree and not
645
675
  // just a single value, we cannot easily convert it into a modify and instead report it as invalid
646
- let insertMap = modification.otherTypeid ? io_rebasePropertyChangeSet.insert[modification.otherTypeid] :
647
- io_rebasePropertyChangeSet.insert;
676
+ let insertMap = modification.otherTypeid
677
+ ? io_rebasePropertyChangeSet.insert[modification.otherTypeid]
678
+ : io_rebasePropertyChangeSet.insert;
648
679
  // Create the conflict information
649
680
  let conflict = {
650
681
  path: newPath,
@@ -656,9 +687,11 @@ var ChangeSetIndexedCollectionFunctions;
656
687
  delete insertMap[key];
657
688
  }
658
689
  }
659
- else if (modification.own === "remove_insert" && modification.other === "remove_insert") {
660
- let insertMap = modification.otherTypeid ? io_rebasePropertyChangeSet.insert[modification.otherTypeid] :
661
- io_rebasePropertyChangeSet.insert;
690
+ else if (modification.own === "remove_insert" &&
691
+ modification.other === "remove_insert") {
692
+ let insertMap = modification.otherTypeid
693
+ ? io_rebasePropertyChangeSet.insert[modification.otherTypeid]
694
+ : io_rebasePropertyChangeSet.insert;
662
695
  // Raise the duplicate inserts as a conflict
663
696
  let conflict = {
664
697
  path: newPath,
@@ -689,8 +722,7 @@ var ChangeSetIndexedCollectionFunctions;
689
722
  else {
690
723
  // Remove remove operations from the ChangeSet
691
724
  if (Array.isArray(io_rebasePropertyChangeSet[modification.other])) {
692
- io_rebasePropertyChangeSet[modification.other] =
693
- (0, without_1.default)(io_rebasePropertyChangeSet[modification.other], key);
725
+ io_rebasePropertyChangeSet[modification.other] = (0, without_1.default)(io_rebasePropertyChangeSet[modification.other], key);
694
726
  }
695
727
  else {
696
728
  delete io_rebasePropertyChangeSet[modification.other][key];