@fluid-experimental/property-changeset 2.0.0-rc.2.0.2 → 2.0.0-rc.3.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/ajvFactory.cjs +19 -0
- package/dist/ajvFactory.cjs.map +1 -0
- package/dist/ajvFactory.d.cts +7 -0
- package/dist/ajvFactory.d.cts.map +1 -0
- package/dist/changeset.d.ts +3 -6
- package/dist/changeset.d.ts.map +1 -1
- package/dist/changeset.js +75 -75
- package/dist/changeset.js.map +1 -1
- package/dist/changeset_operations/array.d.ts +6 -2
- package/dist/changeset_operations/array.d.ts.map +1 -1
- package/dist/changeset_operations/array.js +94 -96
- package/dist/changeset_operations/array.js.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.d.ts +2 -5
- package/dist/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/dist/changeset_operations/arrayChangesetIterator.js +11 -12
- package/dist/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/dist/changeset_operations/changesetConflictTypes.js +2 -2
- package/dist/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/dist/changeset_operations/indexedCollection.d.ts +1 -4
- package/dist/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/dist/changeset_operations/indexedCollection.js +48 -49
- package/dist/changeset_operations/indexedCollection.js.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.d.ts +1 -4
- package/dist/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
- package/dist/changeset_operations/isEmptyChangeset.js +9 -9
- package/dist/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/dist/helpers/typeidHelper.d.ts +0 -3
- package/dist/helpers/typeidHelper.d.ts.map +1 -1
- package/dist/helpers/typeidHelper.js +10 -10
- package/dist/helpers/typeidHelper.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -19
- package/dist/index.js.map +1 -1
- package/dist/isReservedKeyword.d.ts.map +1 -1
- package/dist/isReservedKeyword.js +2 -2
- package/dist/isReservedKeyword.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/pathHelper.d.ts +0 -3
- package/dist/pathHelper.d.ts.map +1 -1
- package/dist/pathHelper.js +2 -2
- package/dist/pathHelper.js.map +1 -1
- package/dist/rebase.js +8 -8
- package/dist/rebase.js.map +1 -1
- package/dist/templateSchema.d.ts.map +1 -1
- package/dist/templateSchema.js +2 -2
- package/dist/templateSchema.js.map +1 -1
- package/dist/templateValidator.d.ts +1 -1
- package/dist/templateValidator.d.ts.map +1 -1
- package/dist/templateValidator.js +49 -54
- package/dist/templateValidator.js.map +1 -1
- package/dist/test/array.spec.js +34 -36
- package/dist/test/array.spec.js.map +1 -1
- package/dist/test/indexedCollection.spec.js +9 -6
- package/dist/test/indexedCollection.spec.js.map +1 -1
- package/dist/test/map.spec.js +4 -4
- package/dist/test/map.spec.js.map +1 -1
- package/dist/test/pathHelper.spec.js +185 -185
- package/dist/test/pathHelper.spec.js.map +1 -1
- package/dist/test/reversibleCs.spec.js +5 -5
- package/dist/test/reversibleCs.spec.js.map +1 -1
- package/dist/test/schemaValidator.js +12 -11
- package/dist/test/schemaValidator.js.map +1 -1
- package/dist/test/schemas/badBothPropertiesAndTypeid.js +18 -18
- package/dist/test/schemas/badBothPropertiesAndTypeid.js.map +1 -1
- package/dist/test/schemas/badInvalidSemverInTypeid.js +40 -40
- package/dist/test/schemas/badInvalidSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badMissingSemverInTypeid.js +40 -40
- package/dist/test/schemas/badMissingSemverInTypeid.js.map +1 -1
- package/dist/test/schemas/badNestedProperties.js +40 -40
- package/dist/test/schemas/badNestedProperties.js.map +1 -1
- package/dist/test/schemas/badPrimitiveTypeid.js +25 -25
- package/dist/test/schemas/badPrimitiveTypeid.js.map +1 -1
- package/dist/test/schemas/badVersionedTypeid.js +41 -41
- package/dist/test/schemas/badVersionedTypeid.js.map +1 -1
- package/dist/test/schemas/goodColorPalette.js +15 -15
- package/dist/test/schemas/goodColorPalette.js.map +1 -1
- package/dist/test/schemas/goodDraftAsVersion.js +12 -12
- package/dist/test/schemas/goodDraftAsVersion.js.map +1 -1
- package/dist/test/schemas/goodPointId.js +40 -40
- package/dist/test/schemas/goodPointId.js.map +1 -1
- package/dist/test/schemas/goodReferenceAndRegular.js +16 -16
- package/dist/test/schemas/goodReferenceAndRegular.js.map +1 -1
- package/dist/test/schemas/goodReservedTypes.js +22 -22
- package/dist/test/schemas/goodReservedTypes.js.map +1 -1
- package/dist/test/schemas/goodUIBorder.js +34 -34
- package/dist/test/schemas/goodUIBorder.js.map +1 -1
- package/dist/test/schemas/index.js +55 -0
- package/dist/test/schemas/index.js.map +1 -0
- package/dist/test/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/test/validator/templateSyntax.spec.js +20 -25
- package/dist/test/validator/templateSyntax.spec.js.map +1 -1
- package/dist/test/validator/templateValidator.spec.js +118 -89
- package/dist/test/validator/templateValidator.spec.js.map +1 -1
- package/dist/test/validator/typeidHelper.spec.js +42 -41
- package/dist/test/validator/typeidHelper.spec.js.map +1 -1
- package/dist/utils.d.ts +17 -13
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +79 -79
- package/dist/utils.js.map +1 -1
- package/dist/validationResultBuilder.d.ts +2 -1
- package/dist/validationResultBuilder.d.ts.map +1 -1
- package/dist/validationResultBuilder.js.map +1 -1
- package/lib/ajvFactory.cjs +19 -0
- package/lib/ajvFactory.cjs.map +1 -0
- package/lib/ajvFactory.d.cts +7 -0
- package/lib/ajvFactory.d.cts.map +1 -0
- package/lib/changeset.d.ts +3 -6
- package/lib/changeset.d.ts.map +1 -1
- package/lib/changeset.js +16 -16
- package/lib/changeset.js.map +1 -1
- package/lib/changeset_operations/array.d.ts +6 -2
- package/lib/changeset_operations/array.d.ts.map +1 -1
- package/lib/changeset_operations/array.js +7 -9
- package/lib/changeset_operations/array.js.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.d.ts +2 -5
- package/lib/changeset_operations/arrayChangesetIterator.d.ts.map +1 -1
- package/lib/changeset_operations/arrayChangesetIterator.js +3 -4
- package/lib/changeset_operations/arrayChangesetIterator.js.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.d.ts.map +1 -1
- package/lib/changeset_operations/changesetConflictTypes.js.map +1 -1
- package/lib/changeset_operations/indexedCollection.d.ts +1 -4
- package/lib/changeset_operations/indexedCollection.d.ts.map +1 -1
- package/lib/changeset_operations/indexedCollection.js +10 -11
- package/lib/changeset_operations/indexedCollection.js.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.d.ts +1 -4
- package/lib/changeset_operations/isEmptyChangeset.d.ts.map +1 -1
- package/lib/changeset_operations/isEmptyChangeset.js +3 -3
- package/lib/changeset_operations/isEmptyChangeset.js.map +1 -1
- package/lib/helpers/typeidHelper.d.ts +0 -3
- package/lib/helpers/typeidHelper.d.ts.map +1 -1
- package/lib/helpers/typeidHelper.js +1 -1
- package/lib/helpers/typeidHelper.js.map +1 -1
- package/lib/index.d.ts +8 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +8 -8
- package/lib/index.js.map +1 -1
- package/lib/isReservedKeyword.d.ts.map +1 -1
- package/lib/isReservedKeyword.js.map +1 -1
- package/lib/pathHelper.d.ts +0 -3
- package/lib/pathHelper.d.ts.map +1 -1
- package/lib/pathHelper.js.map +1 -1
- package/lib/rebase.js +2 -2
- package/lib/rebase.js.map +1 -1
- package/lib/templateSchema.d.ts.map +1 -1
- package/lib/templateSchema.js.map +1 -1
- package/lib/templateValidator.d.ts +1 -1
- package/lib/templateValidator.d.ts.map +1 -1
- package/lib/templateValidator.js +24 -29
- package/lib/templateValidator.js.map +1 -1
- package/lib/test/array.spec.js +768 -0
- package/lib/test/array.spec.js.map +1 -0
- package/lib/test/indexedCollection.spec.js +75 -0
- package/lib/test/indexedCollection.spec.js.map +1 -0
- package/lib/test/map.spec.js +17 -0
- package/lib/test/map.spec.js.map +1 -0
- package/lib/test/pathHelper.spec.js +435 -0
- package/lib/test/pathHelper.spec.js.map +1 -0
- package/lib/test/reversibleCs.spec.js +42 -0
- package/lib/test/reversibleCs.spec.js.map +1 -0
- package/lib/test/schemaValidator.js +103 -0
- package/lib/test/schemaValidator.js.map +1 -0
- package/lib/test/schemas/badBothPropertiesAndTypeid.js +24 -0
- package/lib/test/schemas/badBothPropertiesAndTypeid.js.map +1 -0
- package/lib/test/schemas/badInvalidSemverInTypeid.js +46 -0
- package/lib/test/schemas/badInvalidSemverInTypeid.js.map +1 -0
- package/lib/test/schemas/badMissingSemverInTypeid.js +46 -0
- package/lib/test/schemas/badMissingSemverInTypeid.js.map +1 -0
- package/lib/test/schemas/badNestedProperties.js +46 -0
- package/lib/test/schemas/badNestedProperties.js.map +1 -0
- package/lib/test/schemas/badPrimitiveTypeid.js +31 -0
- package/lib/test/schemas/badPrimitiveTypeid.js.map +1 -0
- package/lib/test/schemas/badVersionedTypeid.js +47 -0
- package/lib/test/schemas/badVersionedTypeid.js.map +1 -0
- package/lib/test/schemas/goodColorPalette.js +21 -0
- package/lib/test/schemas/goodColorPalette.js.map +1 -0
- package/lib/test/schemas/goodDraftAsVersion.js +18 -0
- package/lib/test/schemas/goodDraftAsVersion.js.map +1 -0
- package/lib/test/schemas/goodPointId.js +46 -0
- package/lib/test/schemas/goodPointId.js.map +1 -0
- package/lib/test/schemas/goodReferenceAndRegular.js +22 -0
- package/lib/test/schemas/goodReferenceAndRegular.js.map +1 -0
- package/lib/test/schemas/goodReservedTypes.js +29 -0
- package/lib/test/schemas/goodReservedTypes.js.map +1 -0
- package/lib/test/schemas/goodUIBorder.js +41 -0
- package/lib/test/schemas/goodUIBorder.js.map +1 -0
- package/lib/test/schemas/index.js +29 -0
- package/lib/test/schemas/index.js.map +1 -0
- package/lib/test/tsconfig.tsbuildinfo +1 -0
- package/lib/test/validator/templateSyntax.spec.js +83 -0
- package/lib/test/validator/templateSyntax.spec.js.map +1 -0
- package/lib/test/validator/templateValidator.spec.js +1022 -0
- package/lib/test/validator/templateValidator.spec.js.map +1 -0
- package/lib/test/validator/typeidHelper.spec.js +142 -0
- package/lib/test/validator/typeidHelper.spec.js.map +1 -0
- package/lib/utils.d.ts +17 -13
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +23 -23
- package/lib/utils.js.map +1 -1
- package/lib/validationResultBuilder.d.ts +2 -1
- package/lib/validationResultBuilder.d.ts.map +1 -1
- package/lib/validationResultBuilder.js.map +1 -1
- package/package.json +37 -16
- package/dist/test/tsconfig.tsbuildinfo +0 -1
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
2
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
8
|
};
|
|
5
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
10
|
exports.ChangeSetArrayFunctions = void 0;
|
|
7
|
-
/*!
|
|
8
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
9
|
-
* Licensed under the MIT License.
|
|
10
|
-
*/
|
|
11
11
|
/**
|
|
12
12
|
* @fileoverview Helper functions and classes to work with array ChangeSets
|
|
13
13
|
*/
|
|
14
|
-
const fastest_json_copy_1 = require("fastest-json-copy");
|
|
15
|
-
const isNumber_1 = __importDefault(require("lodash/isNumber"));
|
|
16
|
-
const isString_1 = __importDefault(require("lodash/isString"));
|
|
17
|
-
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
|
18
|
-
// @ts-ignore
|
|
19
14
|
const property_common_1 = require("@fluid-experimental/property-common");
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
15
|
+
const fastest_json_copy_1 = require("fastest-json-copy");
|
|
16
|
+
const isEqual_js_1 = __importDefault(require("lodash/isEqual.js"));
|
|
17
|
+
const isNumber_js_1 = __importDefault(require("lodash/isNumber.js"));
|
|
18
|
+
const isString_js_1 = __importDefault(require("lodash/isString.js"));
|
|
19
|
+
const typeidHelper_js_1 = require("../helpers/typeidHelper.js");
|
|
20
|
+
const arrayChangesetIterator_js_1 = require("./arrayChangesetIterator.js");
|
|
21
|
+
const changesetConflictTypes_js_1 = require("./changesetConflictTypes.js");
|
|
23
22
|
const { MSG } = property_common_1.constants;
|
|
24
|
-
const { isPrimitiveType } =
|
|
23
|
+
const { isPrimitiveType } = typeidHelper_js_1.TypeIdHelper;
|
|
25
24
|
/**
|
|
26
25
|
* The range combinations of two change sets (A and B)
|
|
27
26
|
* This can either be complete operations, parts of complete operations or overlapping segments
|
|
@@ -72,9 +71,9 @@ const getRangeForCurrentStateOperation = function (io_operation, in_aOffset, io_
|
|
|
72
71
|
if (!io_operation) {
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
|
-
if (io_operation.type ===
|
|
74
|
+
if (io_operation.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP) {
|
|
76
75
|
const dummyOp = {
|
|
77
|
-
type:
|
|
76
|
+
type: arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP,
|
|
78
77
|
offset: in_aOffset,
|
|
79
78
|
};
|
|
80
79
|
io_resultingRange.begin = undefined;
|
|
@@ -85,13 +84,13 @@ const getRangeForCurrentStateOperation = function (io_operation, in_aOffset, io_
|
|
|
85
84
|
}
|
|
86
85
|
io_operation.operation[0] += in_aOffset;
|
|
87
86
|
switch (io_operation.type) {
|
|
88
|
-
case
|
|
87
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT:
|
|
89
88
|
io_resultingRange.begin = io_operation.operation[0];
|
|
90
89
|
io_resultingRange.end = io_operation.operation[0] + io_operation.operation[1].length;
|
|
91
90
|
io_resultingRange.op = io_operation;
|
|
92
91
|
io_resultingRange.flag = ArrayChangeSetRangeType.completeA;
|
|
93
92
|
return;
|
|
94
|
-
case
|
|
93
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE:
|
|
95
94
|
io_resultingRange.begin = io_operation.operation[0];
|
|
96
95
|
io_resultingRange.end = io_operation.operation[0];
|
|
97
96
|
io_resultingRange.op = io_operation;
|
|
@@ -99,7 +98,7 @@ const getRangeForCurrentStateOperation = function (io_operation, in_aOffset, io_
|
|
|
99
98
|
io_resultingRange.removeInsertOperation =
|
|
100
99
|
io_operation.removeInsertOperation;
|
|
101
100
|
return;
|
|
102
|
-
case
|
|
101
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY:
|
|
103
102
|
io_resultingRange.begin = io_operation.operation[0];
|
|
104
103
|
io_resultingRange.end = io_operation.operation[0] + io_operation.operation[1].length;
|
|
105
104
|
io_resultingRange.op = io_operation;
|
|
@@ -109,7 +108,7 @@ const getRangeForCurrentStateOperation = function (io_operation, in_aOffset, io_
|
|
|
109
108
|
throw new Error(`getRangeForCurrentStateOperation: ${MSG.UNKNOWN_OPERATION}`);
|
|
110
109
|
}
|
|
111
110
|
};
|
|
112
|
-
const getOpLength = (op) => ((0,
|
|
111
|
+
const getOpLength = (op) => ((0, isNumber_js_1.default)(op[1]) ? op[1] : op[1].length);
|
|
113
112
|
/**
|
|
114
113
|
* Computes the impact range for a given operation of the applied change set
|
|
115
114
|
* @param in_operation - The op
|
|
@@ -118,7 +117,7 @@ const getOpLength = (op) => ((0, isNumber_1.default)(op[1]) ? op[1] : op[1].leng
|
|
|
118
117
|
* @param in_options - Optional additional parameters
|
|
119
118
|
*/
|
|
120
119
|
const getRangeForAppliedOperation = function (in_operation, io_resultingRange, in_flag, in_options) {
|
|
121
|
-
if (!in_operation || in_operation.type ===
|
|
120
|
+
if (!in_operation || in_operation.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP) {
|
|
122
121
|
io_resultingRange.begin = undefined;
|
|
123
122
|
io_resultingRange.end = undefined;
|
|
124
123
|
io_resultingRange.op = undefined;
|
|
@@ -138,7 +137,7 @@ const getRangeForAppliedOperation = function (in_operation, io_resultingRange, i
|
|
|
138
137
|
io_resultingRange.op._absoluteBegin = in_operation.operation[0];
|
|
139
138
|
io_resultingRange.flag = in_flag !== undefined ? in_flag : ArrayChangeSetRangeType.completeB;
|
|
140
139
|
switch (in_operation.type) {
|
|
141
|
-
case
|
|
140
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT:
|
|
142
141
|
io_resultingRange.end = in_operation.operation[0];
|
|
143
142
|
io_resultingRange.op.operation[1] = in_operation.operation[1].slice();
|
|
144
143
|
if (in_options && in_options.applyAfterMetaInformation) {
|
|
@@ -148,7 +147,7 @@ const getRangeForAppliedOperation = function (in_operation, io_resultingRange, i
|
|
|
148
147
|
}
|
|
149
148
|
}
|
|
150
149
|
return;
|
|
151
|
-
case
|
|
150
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE:
|
|
152
151
|
let numberOfRemovedElements = getOpLength(in_operation.operation);
|
|
153
152
|
io_resultingRange.end = in_operation.operation[0] + numberOfRemovedElements;
|
|
154
153
|
io_resultingRange.op.operation[1] = Array.isArray(in_operation.operation[1])
|
|
@@ -156,7 +155,7 @@ const getRangeForAppliedOperation = function (in_operation, io_resultingRange, i
|
|
|
156
155
|
: in_operation.operation[1];
|
|
157
156
|
io_resultingRange.removeInsertOperation = in_operation.removeInsertOperation;
|
|
158
157
|
return;
|
|
159
|
-
case
|
|
158
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY:
|
|
160
159
|
io_resultingRange.end = in_operation.operation[0] + in_operation.operation[1].length;
|
|
161
160
|
io_resultingRange.op.operation[1] = in_operation.operation[1].slice();
|
|
162
161
|
if (in_operation.operation[2] !== undefined) {
|
|
@@ -179,13 +178,13 @@ const getRangeForAppliedOperation = function (in_operation, io_resultingRange, i
|
|
|
179
178
|
*/
|
|
180
179
|
const _splitArrayParameter = function (in_firstResult, in_secondResult, in_data, in_start) {
|
|
181
180
|
let firstTmp;
|
|
182
|
-
if ((0,
|
|
181
|
+
if ((0, isString_js_1.default)(in_data[1])) {
|
|
183
182
|
firstTmp = in_data[1].substr(0, in_start);
|
|
184
183
|
in_secondResult[1] = in_data[1].substr(in_start);
|
|
185
184
|
if (in_firstResult) {
|
|
186
185
|
in_firstResult[1] = firstTmp;
|
|
187
186
|
}
|
|
188
|
-
if (in_data[2] !== undefined && (0,
|
|
187
|
+
if (in_data[2] !== undefined && (0, isString_js_1.default)(in_data[2])) {
|
|
189
188
|
firstTmp = in_data[2].substr(0, in_start);
|
|
190
189
|
in_secondResult[2] = in_data[2].substr(in_start);
|
|
191
190
|
if (in_firstResult) {
|
|
@@ -225,10 +224,10 @@ const _splitArrayParameter = function (in_firstResult, in_secondResult, in_data,
|
|
|
225
224
|
const _splitOperation = function (in_targetRange, in_targetOperation, lengthUsedInResultSegment, in_updateOffset) {
|
|
226
225
|
_splitArrayParameter(in_targetOperation.operation, in_targetRange.op.operation, in_targetRange.op.operation, lengthUsedInResultSegment);
|
|
227
226
|
if (in_updateOffset) {
|
|
228
|
-
if (in_targetRange.op.type ===
|
|
227
|
+
if (in_targetRange.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT) {
|
|
229
228
|
in_targetRange.op.offset += lengthUsedInResultSegment;
|
|
230
229
|
}
|
|
231
|
-
if (in_targetRange.op.type ===
|
|
230
|
+
if (in_targetRange.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE) {
|
|
232
231
|
in_targetRange.op.offset -= lengthUsedInResultSegment;
|
|
233
232
|
}
|
|
234
233
|
}
|
|
@@ -239,7 +238,7 @@ const _splitOperation = function (in_targetRange, in_targetOperation, lengthUsed
|
|
|
239
238
|
* @param in_targetOperation - The target operation which will be overwritten
|
|
240
239
|
*/
|
|
241
240
|
const _copyOperation = function (in_sourceOperation, in_targetOperation) {
|
|
242
|
-
if (in_sourceOperation.type ===
|
|
241
|
+
if (in_sourceOperation.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE) {
|
|
243
242
|
in_targetOperation.operation[1] = in_sourceOperation.operation[1];
|
|
244
243
|
}
|
|
245
244
|
else {
|
|
@@ -262,7 +261,6 @@ const _copyOperation = function (in_sourceOperation, in_targetOperation) {
|
|
|
262
261
|
* overlapping range or
|
|
263
262
|
* (partial) A or B
|
|
264
263
|
*/
|
|
265
|
-
// eslint-disable-next-line complexity
|
|
266
264
|
const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in_rebasing, in_options) {
|
|
267
265
|
if (io_rangeA.removeInsertOperation) {
|
|
268
266
|
io_resultingSegment.removeInsertOperationA = io_rangeA.removeInsertOperation;
|
|
@@ -284,7 +282,7 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
284
282
|
return;
|
|
285
283
|
}
|
|
286
284
|
if (io_rangeB.removeInsertOperation &&
|
|
287
|
-
io_rangeB.op.type ===
|
|
285
|
+
io_rangeB.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE &&
|
|
288
286
|
(io_rangeA.begin === undefined ||
|
|
289
287
|
io_rangeB.removeInsertOperation[0] < io_rangeA.begin - io_rangeA.op.offset) &&
|
|
290
288
|
io_rangeB.removeInsertOperation[0] < io_rangeB.begin &&
|
|
@@ -292,7 +290,7 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
292
290
|
io_resultingSegment.begin = io_rangeB.removeInsertOperation[0];
|
|
293
291
|
io_resultingSegment.end = io_rangeB.removeInsertOperation[0];
|
|
294
292
|
io_resultingSegment.op = {
|
|
295
|
-
type:
|
|
293
|
+
type: arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT,
|
|
296
294
|
operation: io_rangeB.removeInsertOperation,
|
|
297
295
|
offset: io_rangeB.op.offset,
|
|
298
296
|
};
|
|
@@ -325,9 +323,9 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
325
323
|
if (!in_rebasing &&
|
|
326
324
|
io_rangeA.begin <= io_rangeB.begin &&
|
|
327
325
|
io_rangeA.begin + nextInsertOffset >= io_rangeB.begin &&
|
|
328
|
-
io_rangeA.op.type ===
|
|
326
|
+
io_rangeA.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE &&
|
|
329
327
|
Array.isArray(io_rangeA.op.operation[1]) && // This is a reversible remove operation
|
|
330
|
-
io_rangeB.op.type ===
|
|
328
|
+
io_rangeB.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT) {
|
|
331
329
|
// Are the two operations canceling out?
|
|
332
330
|
let startOffset = 0;
|
|
333
331
|
let rangeStart = 0;
|
|
@@ -355,7 +353,7 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
355
353
|
operationMetaInfo.currentInsertOffset;
|
|
356
354
|
rangeLength = operationMetaInfo.rebasedRemoveInsertRanges[i].rangeLength;
|
|
357
355
|
if (io_rangeA.op.operation[1].length - startOffset >= rangeLength &&
|
|
358
|
-
(0,
|
|
356
|
+
(0, isEqual_js_1.default)(io_rangeA.op.operation[1].slice(startOffset, startOffset + rangeLength), io_rangeB.op.operation[1].slice(rangeStart, rangeStart + rangeLength))) {
|
|
359
357
|
matchFound = true;
|
|
360
358
|
// If we have an remove / insert operation in the range A we have to make sure,
|
|
361
359
|
// the insert happens at the correct position within the remove range after canceling
|
|
@@ -378,7 +376,7 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
378
376
|
}
|
|
379
377
|
else {
|
|
380
378
|
if (io_rangeA.op.operation[1].length === rangeLength &&
|
|
381
|
-
(0,
|
|
379
|
+
(0, isEqual_js_1.default)(io_rangeA.op.operation[1], io_rangeB.op.operation[1])) {
|
|
382
380
|
matchFound = true;
|
|
383
381
|
}
|
|
384
382
|
}
|
|
@@ -448,7 +446,7 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
448
446
|
}
|
|
449
447
|
}
|
|
450
448
|
if (io_rangeA.end < io_rangeB.begin || // please see in_rebasing comments in the function description
|
|
451
|
-
((!in_rebasing || io_rangeA.op.type ===
|
|
449
|
+
((!in_rebasing || io_rangeA.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE) &&
|
|
452
450
|
io_rangeA.end === io_rangeB.begin)) {
|
|
453
451
|
io_resultingSegment.begin = io_rangeA.begin;
|
|
454
452
|
io_resultingSegment.end = io_rangeA.end;
|
|
@@ -456,11 +454,11 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
456
454
|
io_resultingSegment.flag = io_rangeA.flag;
|
|
457
455
|
// We need to store the length of the adjacent remove operation for later squashes
|
|
458
456
|
if (in_rebasing &&
|
|
459
|
-
io_rangeA.op.type ===
|
|
457
|
+
io_rangeA.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE &&
|
|
460
458
|
io_rangeA.end === io_rangeB.begin) {
|
|
461
459
|
if (in_options && in_options.applyAfterMetaInformation) {
|
|
462
460
|
let length = io_rangeB.op.operation[1];
|
|
463
|
-
if (!(0,
|
|
461
|
+
if (!(0, isNumber_js_1.default)(length)) {
|
|
464
462
|
length = length.length;
|
|
465
463
|
}
|
|
466
464
|
in_options.applyAfterMetaInformation.set(io_rangeB.op.operation[1], {
|
|
@@ -581,7 +579,7 @@ const splitOverlapping = function (io_rangeA, io_rangeB, io_resultingSegment, in
|
|
|
581
579
|
const mergeWithLastIfPossible = function (in_op, io_changeset, in_targetIndex, in_options) {
|
|
582
580
|
let lastOp;
|
|
583
581
|
switch (in_op.type) {
|
|
584
|
-
case
|
|
582
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT: {
|
|
585
583
|
if (io_changeset.insert.length === 0) {
|
|
586
584
|
return false;
|
|
587
585
|
}
|
|
@@ -611,7 +609,7 @@ const mergeWithLastIfPossible = function (in_op, io_changeset, in_targetIndex, i
|
|
|
611
609
|
}
|
|
612
610
|
}
|
|
613
611
|
// merge with last insert
|
|
614
|
-
if ((0,
|
|
612
|
+
if ((0, isString_js_1.default)(in_op.operation[1])) {
|
|
615
613
|
for (let i = 0; i < in_op.operation[1].length; i++) {
|
|
616
614
|
lastOp[1] += in_op.operation[1][i];
|
|
617
615
|
}
|
|
@@ -633,14 +631,14 @@ const mergeWithLastIfPossible = function (in_op, io_changeset, in_targetIndex, i
|
|
|
633
631
|
}
|
|
634
632
|
break;
|
|
635
633
|
}
|
|
636
|
-
case
|
|
634
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE: {
|
|
637
635
|
// We cannot perform merges for removes here, as those
|
|
638
636
|
// also depend on the insert positions, which might not
|
|
639
637
|
// yet have been processed when the remove is processed.
|
|
640
638
|
// We handle these in a post processing step instead
|
|
641
639
|
throw new Error("Should never happen");
|
|
642
640
|
}
|
|
643
|
-
case
|
|
641
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY:
|
|
644
642
|
if (io_changeset.modify.length === 0) {
|
|
645
643
|
return false;
|
|
646
644
|
}
|
|
@@ -672,7 +670,7 @@ const mergeWithLastIfPossible = function (in_op, io_changeset, in_targetIndex, i
|
|
|
672
670
|
*/
|
|
673
671
|
const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_lastIteratorARemove, in_segment) {
|
|
674
672
|
let writeTargetIndex;
|
|
675
|
-
if (
|
|
673
|
+
if (arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP !== in_op.type) {
|
|
676
674
|
writeTargetIndex = in_op.operation[0] - in_indexOffset;
|
|
677
675
|
// We have to update the write target index, if we have an insert at the
|
|
678
676
|
// position of a remove. In that case, we have to move the insert to the beginning
|
|
@@ -681,7 +679,7 @@ const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_las
|
|
|
681
679
|
// wouldn't have an effect on rebased changeset and then rebasing it with respect to the
|
|
682
680
|
// insert would move it befind the insert. If we do this rebase with respect to the combined
|
|
683
681
|
// CS, we must have the insert before the remove to make sure it is taken into account)
|
|
684
|
-
if (
|
|
682
|
+
if (arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT === in_op.type &&
|
|
685
683
|
in_lastIteratorARemove !== undefined &&
|
|
686
684
|
in_segment.flag === ArrayChangeSetRangeType.completeB) {
|
|
687
685
|
if (in_lastIteratorARemove.position == in_op.operation[0] &&
|
|
@@ -694,10 +692,10 @@ const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_las
|
|
|
694
692
|
}
|
|
695
693
|
}
|
|
696
694
|
switch (in_op.type) {
|
|
697
|
-
case
|
|
695
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT: {
|
|
698
696
|
if (in_options &&
|
|
699
697
|
in_options.applyAfterMetaInformation &&
|
|
700
|
-
!(0,
|
|
698
|
+
!(0, isNumber_js_1.default)(in_op.operation[1])) {
|
|
701
699
|
// If we don't have any meta information yet, we add an entry with the correct offset applied
|
|
702
700
|
const metaInfo = in_options.applyAfterMetaInformation.get(in_op.operation[1]);
|
|
703
701
|
if (!metaInfo) {
|
|
@@ -717,7 +715,7 @@ const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_las
|
|
|
717
715
|
}
|
|
718
716
|
break;
|
|
719
717
|
}
|
|
720
|
-
case
|
|
718
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE: {
|
|
721
719
|
// Note: we don't merge removes here, since those depend on not yet processed inserts.
|
|
722
720
|
// This is done in a post processing step instead
|
|
723
721
|
// our segmentation method currently can produce length zero remove segments
|
|
@@ -728,7 +726,7 @@ const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_las
|
|
|
728
726
|
}
|
|
729
727
|
break;
|
|
730
728
|
}
|
|
731
|
-
case
|
|
729
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY: {
|
|
732
730
|
if (!mergeWithLastIfPossible(in_op, io_changeset, writeTargetIndex, in_options)) {
|
|
733
731
|
if (in_op.operation[2] !== undefined) {
|
|
734
732
|
io_changeset.modify.push([
|
|
@@ -743,7 +741,7 @@ const pushOp = function (in_op, io_changeset, in_indexOffset, in_options, in_las
|
|
|
743
741
|
}
|
|
744
742
|
break;
|
|
745
743
|
}
|
|
746
|
-
case
|
|
744
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP: {
|
|
747
745
|
// nothing to do
|
|
748
746
|
break;
|
|
749
747
|
}
|
|
@@ -762,31 +760,31 @@ const handleCombinations = function (in_segment, in_isPrimitiveType) {
|
|
|
762
760
|
const opA = in_segment.opA;
|
|
763
761
|
const opB = in_segment.opB;
|
|
764
762
|
switch (opA.type) {
|
|
765
|
-
case
|
|
763
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT: {
|
|
766
764
|
switch (opB.type) {
|
|
767
|
-
case
|
|
765
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT: {
|
|
768
766
|
// this combination is not reachable since this case has already been handled before
|
|
769
767
|
console.error("this combination should not occur in handleCombinations - this is a bug");
|
|
770
768
|
break;
|
|
771
769
|
}
|
|
772
|
-
case
|
|
770
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE: {
|
|
773
771
|
// Attention: B removes A completely, kill A to avoid zero inserts
|
|
774
|
-
const opBLen = (0,
|
|
772
|
+
const opBLen = (0, isNumber_js_1.default)(opB.operation[1])
|
|
775
773
|
? opB.operation[1]
|
|
776
774
|
: opB.operation[1].length;
|
|
777
775
|
if (opBLen !== opA.operation[1].length) {
|
|
778
776
|
throw new Error("handleCombinations: insert-remove: unequal number of affected entries");
|
|
779
777
|
}
|
|
780
|
-
opB.type =
|
|
778
|
+
opB.type = arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP;
|
|
781
779
|
opB.operation = null;
|
|
782
780
|
break;
|
|
783
781
|
}
|
|
784
|
-
case
|
|
782
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY: {
|
|
785
783
|
// we have to apply modify of B to As insert
|
|
786
784
|
if (in_isPrimitiveType) {
|
|
787
785
|
// since the length of A and B is equal in here
|
|
788
786
|
// we can just insert the modified values instead
|
|
789
|
-
opB.type =
|
|
787
|
+
opB.type = arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT;
|
|
790
788
|
}
|
|
791
789
|
else {
|
|
792
790
|
// the array element is a complex types
|
|
@@ -797,7 +795,7 @@ const handleCombinations = function (in_segment, in_isPrimitiveType) {
|
|
|
797
795
|
this.performApplyAfterOnPropertyWithTypeid(i, opA.operation[1], opB.operation[1], opA.operation[1][i].typeid, false);
|
|
798
796
|
}
|
|
799
797
|
opB.operation = opA.operation;
|
|
800
|
-
opB.type =
|
|
798
|
+
opB.type = arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT;
|
|
801
799
|
}
|
|
802
800
|
break;
|
|
803
801
|
}
|
|
@@ -806,12 +804,12 @@ const handleCombinations = function (in_segment, in_isPrimitiveType) {
|
|
|
806
804
|
}
|
|
807
805
|
break;
|
|
808
806
|
}
|
|
809
|
-
case
|
|
807
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE: {
|
|
810
808
|
// this combination is not reachable since this case has already been handled before
|
|
811
809
|
console.error("this combination should not occur in handleCombinations - this is a bug");
|
|
812
810
|
break;
|
|
813
811
|
}
|
|
814
|
-
case
|
|
812
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY: {
|
|
815
813
|
if (in_isPrimitiveType) {
|
|
816
814
|
// If we have a reversible changeset, we
|
|
817
815
|
// have to keep the previous state from before the
|
|
@@ -823,7 +821,7 @@ const handleCombinations = function (in_segment, in_isPrimitiveType) {
|
|
|
823
821
|
}
|
|
824
822
|
else {
|
|
825
823
|
// we have to deal with complex types here!
|
|
826
|
-
if (opB.type ===
|
|
824
|
+
if (opB.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY) {
|
|
827
825
|
for (let i = 0; i < opB.operation[1].length; ++i) {
|
|
828
826
|
// TypeIds MUST be stored in the entries
|
|
829
827
|
property_common_1.ConsoleUtils.assert(opA.operation[1][i].typeid, "Malformed Operation. Missing typeid");
|
|
@@ -930,12 +928,12 @@ const arraysHaveSameValues = function (in_arr1, in_arr2) {
|
|
|
930
928
|
const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePath, in_isPrimitiveType, in_options) {
|
|
931
929
|
const opA = in_segment.opA;
|
|
932
930
|
const opB = in_segment.opB;
|
|
933
|
-
if (opB.type ===
|
|
931
|
+
if (opB.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT) {
|
|
934
932
|
const originalStartPosition = opB.operation[0] + opB.offset;
|
|
935
933
|
if (in_options && in_options.applyAfterMetaInformation) {
|
|
936
934
|
let length;
|
|
937
935
|
const insertEntries = opB.operation[1];
|
|
938
|
-
if (!(0,
|
|
936
|
+
if (!(0, isNumber_js_1.default)(insertEntries)) {
|
|
939
937
|
length = insertEntries.length;
|
|
940
938
|
in_options.applyAfterMetaInformation.set(insertEntries, {
|
|
941
939
|
rebasedRemoveInsertRanges: [
|
|
@@ -955,7 +953,7 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
955
953
|
delete baseOp.offset;
|
|
956
954
|
const conflict = {
|
|
957
955
|
path: in_basePath,
|
|
958
|
-
type:
|
|
956
|
+
type: changesetConflictTypes_js_1.ConflictType.INSERTED_ENTRY_WITH_SAME_KEY,
|
|
959
957
|
conflictingChange: (0, fastest_json_copy_1.copy)(baseOp),
|
|
960
958
|
};
|
|
961
959
|
out_conflicts.push(conflict);
|
|
@@ -963,17 +961,17 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
963
961
|
baseOp.operation[0] += insertOp.operation[1].length;
|
|
964
962
|
};
|
|
965
963
|
switch (opA.type) {
|
|
966
|
-
case
|
|
964
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT: {
|
|
967
965
|
switch (opB.type) {
|
|
968
|
-
case
|
|
966
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT: {
|
|
969
967
|
handleInsert(opA, opB);
|
|
970
968
|
break;
|
|
971
969
|
}
|
|
972
|
-
case
|
|
970
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE: {
|
|
973
971
|
// non-conflicting insert - just keep B
|
|
974
972
|
break;
|
|
975
973
|
}
|
|
976
|
-
case
|
|
974
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY: {
|
|
977
975
|
// non-conflicting insert - just keep B
|
|
978
976
|
break;
|
|
979
977
|
}
|
|
@@ -982,9 +980,9 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
982
980
|
}
|
|
983
981
|
break;
|
|
984
982
|
}
|
|
985
|
-
case
|
|
983
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE: {
|
|
986
984
|
switch (opB.type) {
|
|
987
|
-
case
|
|
985
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT: {
|
|
988
986
|
if (opA._absoluteBegin !== opA.operation[0]) {
|
|
989
987
|
// Move the insert operation to the beginning of the removed range
|
|
990
988
|
opB.operation[0] -= opA.operation[0] - opA._absoluteBegin;
|
|
@@ -1001,23 +999,23 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
1001
999
|
}
|
|
1002
1000
|
break;
|
|
1003
1001
|
}
|
|
1004
|
-
case
|
|
1002
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE: {
|
|
1005
1003
|
// Remove already in A, no need to add the same again -> write nop
|
|
1006
|
-
const opBLen = (0,
|
|
1004
|
+
const opBLen = (0, isNumber_js_1.default)(opB.operation[1])
|
|
1007
1005
|
? opB.operation[1]
|
|
1008
1006
|
: opB.operation[1].length;
|
|
1009
|
-
const opALen = (0,
|
|
1007
|
+
const opALen = (0, isNumber_js_1.default)(opA.operation[1])
|
|
1010
1008
|
? opA.operation[1]
|
|
1011
1009
|
: opA.operation[1].length;
|
|
1012
1010
|
if (opBLen !== opALen) {
|
|
1013
1011
|
throw new Error("handleRebaseCombinations: remove-remove: unequal number of affected entries, " +
|
|
1014
1012
|
"this should never happen! Probably a bug in splitRange.");
|
|
1015
1013
|
}
|
|
1016
|
-
opB.type =
|
|
1014
|
+
opB.type = arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP;
|
|
1017
1015
|
opB.operation = null;
|
|
1018
1016
|
break;
|
|
1019
1017
|
}
|
|
1020
|
-
case
|
|
1018
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY: {
|
|
1021
1019
|
// trying to modify something that was removed ->
|
|
1022
1020
|
// replace the modify with a NOP and report a conflict
|
|
1023
1021
|
if (opB.operation[1].length > 0) {
|
|
@@ -1025,12 +1023,12 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
1025
1023
|
delete opB.offset;
|
|
1026
1024
|
let conflict = {
|
|
1027
1025
|
path: in_basePath,
|
|
1028
|
-
type:
|
|
1026
|
+
type: changesetConflictTypes_js_1.ConflictType.ENTRY_MODIFIED_AFTER_REMOVE,
|
|
1029
1027
|
conflictingChange: (0, fastest_json_copy_1.copy)(opB),
|
|
1030
1028
|
};
|
|
1031
1029
|
out_conflicts.push(conflict);
|
|
1032
1030
|
}
|
|
1033
|
-
opB.type =
|
|
1031
|
+
opB.type = arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP;
|
|
1034
1032
|
opB.operation = null;
|
|
1035
1033
|
break;
|
|
1036
1034
|
}
|
|
@@ -1039,16 +1037,16 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
1039
1037
|
}
|
|
1040
1038
|
break;
|
|
1041
1039
|
}
|
|
1042
|
-
case
|
|
1040
|
+
case arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY: {
|
|
1043
1041
|
if (in_isPrimitiveType) {
|
|
1044
1042
|
// just use opB and notify accordingly
|
|
1045
|
-
if (opB.type ===
|
|
1043
|
+
if (opB.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY &&
|
|
1046
1044
|
opB.operation[1].length > 0) {
|
|
1047
1045
|
delete opA._absoluteBegin;
|
|
1048
1046
|
delete opB.offset;
|
|
1049
1047
|
let conflict = {
|
|
1050
1048
|
path: in_basePath,
|
|
1051
|
-
type:
|
|
1049
|
+
type: changesetConflictTypes_js_1.ConflictType.COLLIDING_SET,
|
|
1052
1050
|
conflictingChange: (0, fastest_json_copy_1.copy)(opB),
|
|
1053
1051
|
};
|
|
1054
1052
|
out_conflicts.push(conflict);
|
|
@@ -1059,7 +1057,7 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
1059
1057
|
// Ex. [[0, [30, 20, 10]]] over [[0, [10, 20, 30]]] should become [[0, [30]], [2, [10]]].
|
|
1060
1058
|
// This does not seem easily doable in the current code.
|
|
1061
1059
|
if (arraysHaveSameValues(opA.operation[1], opB.operation[1])) {
|
|
1062
|
-
opB.type =
|
|
1060
|
+
opB.type = arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP;
|
|
1063
1061
|
opB.operation = null;
|
|
1064
1062
|
// If any, change the opB old value by the opA new value
|
|
1065
1063
|
}
|
|
@@ -1069,13 +1067,13 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
1069
1067
|
}
|
|
1070
1068
|
// WARNING: 'operation[1]' is 'string | number | genericArray'. The cast to 'number'
|
|
1071
1069
|
// preserves the JavaScript coercion behavior, which was permitted prior to TS5.
|
|
1072
|
-
if (opB.type ===
|
|
1070
|
+
if (opB.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE &&
|
|
1073
1071
|
opB.operation[1] > 0) {
|
|
1074
1072
|
delete opA._absoluteBegin;
|
|
1075
1073
|
delete opB.offset;
|
|
1076
1074
|
let conflict = {
|
|
1077
1075
|
path: in_basePath,
|
|
1078
|
-
type:
|
|
1076
|
+
type: changesetConflictTypes_js_1.ConflictType.REMOVE_AFTER_MODIFY,
|
|
1079
1077
|
conflictingChange: (0, fastest_json_copy_1.copy)(opB),
|
|
1080
1078
|
};
|
|
1081
1079
|
out_conflicts.push(conflict);
|
|
@@ -1084,7 +1082,7 @@ const handleRebaseCombinations = function (in_segment, out_conflicts, in_basePat
|
|
|
1084
1082
|
}
|
|
1085
1083
|
else {
|
|
1086
1084
|
// we have to deal with complex types here!
|
|
1087
|
-
if (opB.type ===
|
|
1085
|
+
if (opB.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.MODIFY) {
|
|
1088
1086
|
for (let i = 0; i < opB.operation[1].length; ++i) {
|
|
1089
1087
|
property_common_1.ConsoleUtils.assert(opA.operation[1][i].typeid, "Malformed Operation. Missing typeid");
|
|
1090
1088
|
this.rebaseChangeSetForPropertyEntryWithTypeid(i, opA.operation[1], opB.operation[1], opA.operation[1][i].typeid, `${in_basePath}[${i}]`, false, out_conflicts, in_options);
|
|
@@ -1170,12 +1168,12 @@ var ChangeSetArrayFunctions;
|
|
|
1170
1168
|
*/
|
|
1171
1169
|
function _performApplyAfterOnPropertyArray(io_basePropertyChanges, in_appliedPropertyChanges, in_typeid, in_options) {
|
|
1172
1170
|
property_common_1.ConsoleUtils.assert(in_typeid, "_performApplyAfterOnPropertyArray: typeid missing");
|
|
1173
|
-
property_common_1.ConsoleUtils.assert(!(0,
|
|
1174
|
-
property_common_1.ConsoleUtils.assert(!(0,
|
|
1171
|
+
property_common_1.ConsoleUtils.assert(!(0, isString_js_1.default)(io_basePropertyChanges), io_basePropertyChanges);
|
|
1172
|
+
property_common_1.ConsoleUtils.assert(!(0, isString_js_1.default)(in_appliedPropertyChanges), in_appliedPropertyChanges);
|
|
1175
1173
|
const isPrimitiveTypeid = isPrimitiveType(in_typeid);
|
|
1176
1174
|
// Iterator to process the changes in the ChangeSet in the correct order
|
|
1177
|
-
const iteratorA = new
|
|
1178
|
-
const iteratorB = new
|
|
1175
|
+
const iteratorA = new arrayChangesetIterator_js_1.ArrayChangeSetIterator(io_basePropertyChanges);
|
|
1176
|
+
const iteratorB = new arrayChangesetIterator_js_1.ArrayChangeSetIterator(in_appliedPropertyChanges);
|
|
1179
1177
|
const rangeA = {};
|
|
1180
1178
|
const rangeB = {};
|
|
1181
1179
|
const opA = iteratorA.opDescription;
|
|
@@ -1218,13 +1216,13 @@ var ChangeSetArrayFunctions;
|
|
|
1218
1216
|
if (lastOpWasNop &&
|
|
1219
1217
|
(rangeA.begin === undefined || rangeA.begin >= segment.begin) &&
|
|
1220
1218
|
segment.flag === ArrayChangeSetRangeType.completeB &&
|
|
1221
|
-
segment.op.type ===
|
|
1219
|
+
segment.op.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.INSERT &&
|
|
1222
1220
|
segment.op.operation[0] === canceledSegmentBegin) {
|
|
1223
1221
|
indexOffset = lastIndexOffset;
|
|
1224
1222
|
}
|
|
1225
1223
|
applySegment.call(this, segment, resultPropertyChanges, indexOffset, lastIteratorARemove, isPrimitiveTypeid);
|
|
1226
1224
|
lastOpWasNop =
|
|
1227
|
-
segment.opB !== undefined && segment.opB.type ===
|
|
1225
|
+
segment.opB !== undefined && segment.opB.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.NOP;
|
|
1228
1226
|
if (lastOpWasNop) {
|
|
1229
1227
|
canceledSegmentBegin = segment.begin;
|
|
1230
1228
|
}
|
|
@@ -1237,7 +1235,7 @@ var ChangeSetArrayFunctions;
|
|
|
1237
1235
|
// offset has already been incremented by the remove. Therefore, the insert would
|
|
1238
1236
|
// be placed behind the remove. We detect this case and correct the offset accordingly
|
|
1239
1237
|
// in pushOp
|
|
1240
|
-
if (opA.type ===
|
|
1238
|
+
if (opA.type === arrayChangesetIterator_js_1.ArrayChangeSetIterator.types.REMOVE) {
|
|
1241
1239
|
if (!lastIteratorARemove || lastIteratorARemove.position !== opA.operation[0]) {
|
|
1242
1240
|
lastIteratorARemove = {
|
|
1243
1241
|
position: opA.operation[0],
|
|
@@ -1334,8 +1332,8 @@ var ChangeSetArrayFunctions;
|
|
|
1334
1332
|
function _rebaseArrayChangeSetForProperty(in_ownPropertyChangeSet, io_rebasePropertyChangeSet, in_basePath, out_conflicts, in_typeid, in_options) {
|
|
1335
1333
|
const isPrimitiveTypeid = isPrimitiveType(in_typeid);
|
|
1336
1334
|
// Iterator to process the changes in the ChangeSet in the correct order
|
|
1337
|
-
const iteratorA = new
|
|
1338
|
-
const iteratorB = new
|
|
1335
|
+
const iteratorA = new arrayChangesetIterator_js_1.ArrayChangeSetIterator(in_ownPropertyChangeSet);
|
|
1336
|
+
const iteratorB = new arrayChangesetIterator_js_1.ArrayChangeSetIterator(io_rebasePropertyChangeSet);
|
|
1339
1337
|
const opA = iteratorA.opDescription;
|
|
1340
1338
|
const rangeA = {};
|
|
1341
1339
|
getRangeForAppliedOperation(opA, rangeA, ArrayChangeSetRangeType.completeA, in_options);
|
|
@@ -1471,13 +1469,13 @@ var ChangeSetArrayFunctions;
|
|
|
1471
1469
|
* @param out_conflicts - A list of paths that resulted in conflicts together with the type of the conflict
|
|
1472
1470
|
*/
|
|
1473
1471
|
function _rebaseChangeSetForString(in_ownPropertyChangeSet, io_rebasePropertyChangeSetParent, in_key, in_basePath, out_conflicts, in_options) {
|
|
1474
|
-
if ((0,
|
|
1472
|
+
if ((0, isString_js_1.default)(io_rebasePropertyChangeSetParent[in_key]) ||
|
|
1475
1473
|
(io_rebasePropertyChangeSetParent[in_key] &&
|
|
1476
1474
|
io_rebasePropertyChangeSetParent[in_key].hasOwnProperty("value"))) {
|
|
1477
1475
|
// other overwrites any old changes, we ignore them and report the conflict
|
|
1478
1476
|
let conflict = {
|
|
1479
1477
|
path: in_basePath,
|
|
1480
|
-
type:
|
|
1478
|
+
type: changesetConflictTypes_js_1.ConflictType.COLLIDING_SET,
|
|
1481
1479
|
conflictingChange: (0, fastest_json_copy_1.copy)(in_ownPropertyChangeSet),
|
|
1482
1480
|
};
|
|
1483
1481
|
out_conflicts.push(conflict);
|
|
@@ -1494,13 +1492,13 @@ var ChangeSetArrayFunctions;
|
|
|
1494
1492
|
delete io_rebasePropertyChangeSetParent[in_key];
|
|
1495
1493
|
}
|
|
1496
1494
|
}
|
|
1497
|
-
else if ((0,
|
|
1495
|
+
else if ((0, isString_js_1.default)(in_ownPropertyChangeSet) ||
|
|
1498
1496
|
(in_ownPropertyChangeSet && in_ownPropertyChangeSet.hasOwnProperty("value"))) {
|
|
1499
1497
|
// we have a conflict since we cannot allow insert/remove/modify on an unknown state
|
|
1500
1498
|
// we just ignore other's modifications and take own's set
|
|
1501
1499
|
let conflict = {
|
|
1502
1500
|
path: in_basePath,
|
|
1503
|
-
type:
|
|
1501
|
+
type: changesetConflictTypes_js_1.ConflictType.COLLIDING_SET,
|
|
1504
1502
|
conflictingChange: (0, fastest_json_copy_1.copy)(io_rebasePropertyChangeSetParent[in_key]),
|
|
1505
1503
|
};
|
|
1506
1504
|
out_conflicts.push(conflict);
|