@commercetools/sync-actions 6.1.0 → 7.0.0-rc.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.
- package/dist/sync-actions.cjs.js +477 -1665
- package/dist/sync-actions.es.js +419 -1592
- package/dist/sync-actions.umd.js +480 -1666
- package/dist/sync-actions.umd.min.js +1 -1
- package/lib/cart-discounts-actions.js +31 -0
- package/lib/cart-discounts.js +70 -0
- package/lib/categories.js +106 -0
- package/lib/category-actions.js +117 -0
- package/lib/channels.js +0 -0
- package/lib/customer-actions.js +125 -0
- package/lib/customer-group-actions.js +23 -0
- package/lib/customer-group.js +70 -0
- package/lib/customers.js +95 -0
- package/lib/discount-codes-actions.js +31 -0
- package/lib/discount-codes.js +80 -0
- package/lib/index.js +90 -0
- package/lib/inventories.js +89 -0
- package/lib/inventory-actions.js +42 -0
- package/lib/order-actions.js +71 -0
- package/lib/orders.js +89 -0
- package/lib/product-actions.js +779 -0
- package/lib/product-discounts-actions.js +27 -0
- package/lib/product-discounts.js +71 -0
- package/lib/products.js +208 -0
- package/lib/utils/clone.js +9 -0
- package/lib/utils/common-actions.js +157 -0
- package/lib/utils/create-build-actions.js +74 -0
- package/lib/utils/create-build-array-actions.js +146 -0
- package/lib/utils/create-map-action-group.js +35 -0
- package/lib/utils/diffpatcher.js +93 -0
- package/lib/utils/find-matching-pairs.js +67 -0
- package/package.json +4 -5
- package/CHANGELOG.md +0 -203
package/dist/sync-actions.cjs.js
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var flatten = require('lodash.flatten');
|
|
6
4
|
var isEqual = require('lodash.isequal');
|
|
7
5
|
var isNil = require('lodash.isnil');
|
|
8
|
-
var dmp = require('diff-match-patch');
|
|
9
|
-
var chalk = require('chalk');
|
|
10
6
|
var forEach = require('lodash.foreach');
|
|
11
7
|
var uniqWith = require('lodash.uniqwith');
|
|
12
8
|
var intersection = require('lodash.intersection');
|
|
13
9
|
var without = require('lodash.without');
|
|
14
|
-
var sortBy
|
|
15
|
-
|
|
16
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
-
|
|
18
|
-
var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
|
|
19
|
-
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
20
|
-
var isNil__default = /*#__PURE__*/_interopDefaultLegacy(isNil);
|
|
21
|
-
var dmp__default = /*#__PURE__*/_interopDefaultLegacy(dmp);
|
|
22
|
-
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
23
|
-
var forEach__default = /*#__PURE__*/_interopDefaultLegacy(forEach);
|
|
24
|
-
var uniqWith__default = /*#__PURE__*/_interopDefaultLegacy(uniqWith);
|
|
25
|
-
var intersection__default = /*#__PURE__*/_interopDefaultLegacy(intersection);
|
|
26
|
-
var without__default = /*#__PURE__*/_interopDefaultLegacy(without);
|
|
27
|
-
var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy$1);
|
|
10
|
+
var sortBy = require('lodash.sortby');
|
|
28
11
|
|
|
29
12
|
function _arrayLikeToArray(r, a) {
|
|
30
13
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -37,14 +20,69 @@ function _arrayWithHoles(r) {
|
|
|
37
20
|
function _arrayWithoutHoles(r) {
|
|
38
21
|
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
39
22
|
}
|
|
23
|
+
function _assertThisInitialized(e) {
|
|
24
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
25
|
+
return e;
|
|
26
|
+
}
|
|
27
|
+
function _callSuper(t, o, e) {
|
|
28
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
29
|
+
}
|
|
30
|
+
function _classCallCheck(a, n) {
|
|
31
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
32
|
+
}
|
|
33
|
+
function _defineProperties(e, r) {
|
|
34
|
+
for (var t = 0; t < r.length; t++) {
|
|
35
|
+
var o = r[t];
|
|
36
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function _createClass(e, r, t) {
|
|
40
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
41
|
+
writable: false
|
|
42
|
+
}), e;
|
|
43
|
+
}
|
|
40
44
|
function _defineProperty(e, r, t) {
|
|
41
45
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
46
|
value: t,
|
|
43
|
-
enumerable:
|
|
44
|
-
configurable:
|
|
45
|
-
writable:
|
|
47
|
+
enumerable: true,
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true
|
|
46
50
|
}) : e[r] = t, e;
|
|
47
51
|
}
|
|
52
|
+
function _get() {
|
|
53
|
+
return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
|
|
54
|
+
var p = _superPropBase(e, t);
|
|
55
|
+
if (p) {
|
|
56
|
+
var n = Object.getOwnPropertyDescriptor(p, t);
|
|
57
|
+
return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
|
|
58
|
+
}
|
|
59
|
+
}, _get.apply(null, arguments);
|
|
60
|
+
}
|
|
61
|
+
function _getPrototypeOf(t) {
|
|
62
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
63
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
64
|
+
}, _getPrototypeOf(t);
|
|
65
|
+
}
|
|
66
|
+
function _inherits(t, e) {
|
|
67
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
68
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
69
|
+
constructor: {
|
|
70
|
+
value: t,
|
|
71
|
+
writable: true,
|
|
72
|
+
configurable: true
|
|
73
|
+
}
|
|
74
|
+
}), Object.defineProperty(t, "prototype", {
|
|
75
|
+
writable: false
|
|
76
|
+
}), e && _setPrototypeOf(t, e);
|
|
77
|
+
}
|
|
78
|
+
function _isNativeReflectConstruct() {
|
|
79
|
+
try {
|
|
80
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
81
|
+
} catch (t) {}
|
|
82
|
+
return (_isNativeReflectConstruct = function () {
|
|
83
|
+
return !!t;
|
|
84
|
+
})();
|
|
85
|
+
}
|
|
48
86
|
function _iterableToArray(r) {
|
|
49
87
|
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
50
88
|
}
|
|
@@ -56,15 +94,15 @@ function _iterableToArrayLimit(r, l) {
|
|
|
56
94
|
i,
|
|
57
95
|
u,
|
|
58
96
|
a = [],
|
|
59
|
-
f =
|
|
60
|
-
o =
|
|
97
|
+
f = true,
|
|
98
|
+
o = false;
|
|
61
99
|
try {
|
|
62
100
|
if (i = (t = t.call(r)).next, 0 === l) {
|
|
63
101
|
if (Object(t) !== t) return;
|
|
64
102
|
f = !1;
|
|
65
103
|
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
66
104
|
} catch (r) {
|
|
67
|
-
o =
|
|
105
|
+
o = true, n = r;
|
|
68
106
|
} finally {
|
|
69
107
|
try {
|
|
70
108
|
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
@@ -94,7 +132,7 @@ function ownKeys(e, r) {
|
|
|
94
132
|
function _objectSpread2(e) {
|
|
95
133
|
for (var r = 1; r < arguments.length; r++) {
|
|
96
134
|
var t = null != arguments[r] ? arguments[r] : {};
|
|
97
|
-
r % 2 ? ownKeys(Object(t),
|
|
135
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
98
136
|
_defineProperty(e, r, t[r]);
|
|
99
137
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
100
138
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
@@ -108,8 +146,8 @@ function _objectWithoutProperties(e, t) {
|
|
|
108
146
|
r,
|
|
109
147
|
i = _objectWithoutPropertiesLoose(e, t);
|
|
110
148
|
if (Object.getOwnPropertySymbols) {
|
|
111
|
-
var
|
|
112
|
-
for (r = 0; r <
|
|
149
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
150
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
113
151
|
}
|
|
114
152
|
return i;
|
|
115
153
|
}
|
|
@@ -117,14 +155,34 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
117
155
|
if (null == r) return {};
|
|
118
156
|
var t = {};
|
|
119
157
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
120
|
-
if (e.
|
|
158
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
121
159
|
t[n] = r[n];
|
|
122
160
|
}
|
|
123
161
|
return t;
|
|
124
162
|
}
|
|
163
|
+
function _possibleConstructorReturn(t, e) {
|
|
164
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
165
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
166
|
+
return _assertThisInitialized(t);
|
|
167
|
+
}
|
|
168
|
+
function _setPrototypeOf(t, e) {
|
|
169
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
170
|
+
return t.__proto__ = e, t;
|
|
171
|
+
}, _setPrototypeOf(t, e);
|
|
172
|
+
}
|
|
125
173
|
function _slicedToArray(r, e) {
|
|
126
174
|
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
127
175
|
}
|
|
176
|
+
function _superPropBase(t, o) {
|
|
177
|
+
for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
|
|
178
|
+
return t;
|
|
179
|
+
}
|
|
180
|
+
function _superPropGet(t, o, e, r) {
|
|
181
|
+
var p = _get(_getPrototypeOf(t.prototype ), o, e);
|
|
182
|
+
return 2 & r && "function" == typeof p ? function (t) {
|
|
183
|
+
return p.apply(e, t);
|
|
184
|
+
} : p;
|
|
185
|
+
}
|
|
128
186
|
function _toConsumableArray(r) {
|
|
129
187
|
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
130
188
|
}
|
|
@@ -132,24 +190,24 @@ function _toPrimitive(t, r) {
|
|
|
132
190
|
if ("object" != typeof t || !t) return t;
|
|
133
191
|
var e = t[Symbol.toPrimitive];
|
|
134
192
|
if (void 0 !== e) {
|
|
135
|
-
var i = e.call(t, r
|
|
193
|
+
var i = e.call(t, r);
|
|
136
194
|
if ("object" != typeof i) return i;
|
|
137
195
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
138
196
|
}
|
|
139
|
-
return (
|
|
197
|
+
return (String )(t);
|
|
140
198
|
}
|
|
141
199
|
function _toPropertyKey(t) {
|
|
142
200
|
var i = _toPrimitive(t, "string");
|
|
143
201
|
return "symbol" == typeof i ? i : i + "";
|
|
144
202
|
}
|
|
145
|
-
function _typeof
|
|
203
|
+
function _typeof(o) {
|
|
146
204
|
"@babel/helpers - typeof";
|
|
147
205
|
|
|
148
|
-
return _typeof
|
|
206
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
149
207
|
return typeof o;
|
|
150
208
|
} : function (o) {
|
|
151
209
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
152
|
-
}, _typeof
|
|
210
|
+
}, _typeof(o);
|
|
153
211
|
}
|
|
154
212
|
function _unsupportedIterableToArray(r, a) {
|
|
155
213
|
if (r) {
|
|
@@ -178,7 +236,7 @@ var createPriceComparator = function createPriceComparator(price) {
|
|
|
178
236
|
function arePricesStructurallyEqual(oldPrice, newPrice) {
|
|
179
237
|
var oldPriceComparison = createPriceComparator(oldPrice);
|
|
180
238
|
var newPriceComparison = createPriceComparator(newPrice);
|
|
181
|
-
return
|
|
239
|
+
return isEqual(newPriceComparison, oldPriceComparison);
|
|
182
240
|
}
|
|
183
241
|
function extractPriceFromPreviousVariant(newPrice, previousVariant) {
|
|
184
242
|
if (!previousVariant) return null;
|
|
@@ -193,7 +251,7 @@ function injectMissingPriceIds(nextVariants, previousVariants) {
|
|
|
193
251
|
restOfVariant = _objectWithoutProperties(newVariant, _excluded$2);
|
|
194
252
|
if (!prices) return restOfVariant;
|
|
195
253
|
var oldVariant = previousVariants.find(function (previousVariant) {
|
|
196
|
-
return !
|
|
254
|
+
return !isNil(previousVariant.id) && previousVariant.id === newVariant.id || !isNil(previousVariant.key) && previousVariant.key === newVariant.key || !isNil(previousVariant.sku) && previousVariant.sku === newVariant.sku;
|
|
197
255
|
});
|
|
198
256
|
return _objectSpread2(_objectSpread2({}, restOfVariant), {}, {
|
|
199
257
|
prices: prices.map(function (price) {
|
|
@@ -202,8 +260,8 @@ function injectMissingPriceIds(nextVariants, previousVariants) {
|
|
|
202
260
|
if (oldPrice) {
|
|
203
261
|
// copy ID if not provided
|
|
204
262
|
if (!newPrice.id) newPrice.id = oldPrice.id;
|
|
205
|
-
if (
|
|
206
|
-
if (
|
|
263
|
+
if (isNil(newPrice.value.type)) newPrice.value.type = oldPrice.value.type;
|
|
264
|
+
if (isNil(newPrice.value.fractionDigits)) newPrice.value.fractionDigits = oldPrice.value.fractionDigits;
|
|
207
265
|
}
|
|
208
266
|
return newPrice;
|
|
209
267
|
})
|
|
@@ -250,129 +308,23 @@ function createMapActionGroup() {
|
|
|
250
308
|
};
|
|
251
309
|
}
|
|
252
310
|
|
|
253
|
-
var
|
|
254
|
-
return _typeof$1(obj);
|
|
255
|
-
} : function (obj) {
|
|
256
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof$1(obj);
|
|
257
|
-
};
|
|
258
|
-
var classCallCheck = function classCallCheck(instance, Constructor) {
|
|
259
|
-
if (!(instance instanceof Constructor)) {
|
|
260
|
-
throw new TypeError("Cannot call a class as a function");
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
var createClass = function () {
|
|
264
|
-
function defineProperties(target, props) {
|
|
265
|
-
for (var i = 0; i < props.length; i++) {
|
|
266
|
-
var descriptor = props[i];
|
|
267
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
268
|
-
descriptor.configurable = true;
|
|
269
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
270
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return function (Constructor, protoProps, staticProps) {
|
|
274
|
-
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
275
|
-
if (staticProps) defineProperties(Constructor, staticProps);
|
|
276
|
-
return Constructor;
|
|
277
|
-
};
|
|
278
|
-
}();
|
|
279
|
-
var get = function get(object, property, receiver) {
|
|
280
|
-
if (object === null) object = Function.prototype;
|
|
281
|
-
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
282
|
-
if (desc === undefined) {
|
|
283
|
-
var parent = Object.getPrototypeOf(object);
|
|
284
|
-
if (parent === null) {
|
|
285
|
-
return undefined;
|
|
286
|
-
} else {
|
|
287
|
-
return get(parent, property, receiver);
|
|
288
|
-
}
|
|
289
|
-
} else if ("value" in desc) {
|
|
290
|
-
return desc.value;
|
|
291
|
-
} else {
|
|
292
|
-
var getter = desc.get;
|
|
293
|
-
if (getter === undefined) {
|
|
294
|
-
return undefined;
|
|
295
|
-
}
|
|
296
|
-
return getter.call(receiver);
|
|
297
|
-
}
|
|
298
|
-
};
|
|
299
|
-
var inherits = function inherits(subClass, superClass) {
|
|
300
|
-
if (typeof superClass !== "function" && superClass !== null) {
|
|
301
|
-
throw new TypeError("Super expression must either be null or a function, not " + _typeof$1(superClass));
|
|
302
|
-
}
|
|
303
|
-
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
304
|
-
constructor: {
|
|
305
|
-
value: subClass,
|
|
306
|
-
enumerable: false,
|
|
307
|
-
writable: true,
|
|
308
|
-
configurable: true
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
312
|
-
};
|
|
313
|
-
var possibleConstructorReturn = function possibleConstructorReturn(self, call) {
|
|
314
|
-
if (!self) {
|
|
315
|
-
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
316
|
-
}
|
|
317
|
-
return call && (_typeof$1(call) === "object" || typeof call === "function") ? call : self;
|
|
318
|
-
};
|
|
319
|
-
var slicedToArray = function () {
|
|
320
|
-
function sliceIterator(arr, i) {
|
|
321
|
-
var _arr = [];
|
|
322
|
-
var _n = true;
|
|
323
|
-
var _d = false;
|
|
324
|
-
var _e = undefined;
|
|
325
|
-
try {
|
|
326
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
327
|
-
_arr.push(_s.value);
|
|
328
|
-
if (i && _arr.length === i) break;
|
|
329
|
-
}
|
|
330
|
-
} catch (err) {
|
|
331
|
-
_d = true;
|
|
332
|
-
_e = err;
|
|
333
|
-
} finally {
|
|
334
|
-
try {
|
|
335
|
-
if (!_n && _i["return"]) _i["return"]();
|
|
336
|
-
} finally {
|
|
337
|
-
if (_d) throw _e;
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
return _arr;
|
|
341
|
-
}
|
|
342
|
-
return function (arr, i) {
|
|
343
|
-
if (Array.isArray(arr)) {
|
|
344
|
-
return arr;
|
|
345
|
-
} else if (Symbol.iterator in Object(arr)) {
|
|
346
|
-
return sliceIterator(arr, i);
|
|
347
|
-
} else {
|
|
348
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
}();
|
|
352
|
-
var toConsumableArray = function toConsumableArray(arr) {
|
|
353
|
-
if (Array.isArray(arr)) {
|
|
354
|
-
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
|
|
355
|
-
return arr2;
|
|
356
|
-
} else {
|
|
357
|
-
return Array.from(arr);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
var Processor = function () {
|
|
311
|
+
var Processor = /*#__PURE__*/function () {
|
|
361
312
|
function Processor(options) {
|
|
362
|
-
|
|
313
|
+
_classCallCheck(this, Processor);
|
|
363
314
|
this.selfOptions = options || {};
|
|
364
315
|
this.pipes = {};
|
|
365
316
|
}
|
|
366
|
-
|
|
367
|
-
key:
|
|
317
|
+
return _createClass(Processor, [{
|
|
318
|
+
key: "options",
|
|
368
319
|
value: function options(_options) {
|
|
369
320
|
if (_options) {
|
|
370
321
|
this.selfOptions = _options;
|
|
371
322
|
}
|
|
372
323
|
return this.selfOptions;
|
|
373
324
|
}
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
374
326
|
}, {
|
|
375
|
-
key:
|
|
327
|
+
key: "pipe",
|
|
376
328
|
value: function pipe(name, pipeArg) {
|
|
377
329
|
var pipe = pipeArg;
|
|
378
330
|
if (typeof name === 'string') {
|
|
@@ -383,6 +335,7 @@ var Processor = function () {
|
|
|
383
335
|
}
|
|
384
336
|
}
|
|
385
337
|
if (name && name.name) {
|
|
338
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
386
339
|
pipe = name;
|
|
387
340
|
if (pipe.processor === this) {
|
|
388
341
|
return pipe;
|
|
@@ -392,14 +345,14 @@ var Processor = function () {
|
|
|
392
345
|
pipe.processor = this;
|
|
393
346
|
return pipe;
|
|
394
347
|
}
|
|
348
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
395
349
|
}, {
|
|
396
|
-
key:
|
|
350
|
+
key: "process",
|
|
397
351
|
value: function process(input, pipe) {
|
|
398
352
|
var context = input;
|
|
399
353
|
context.options = this.options();
|
|
400
354
|
var nextPipe = pipe || input.pipe || 'default';
|
|
401
|
-
var lastPipe
|
|
402
|
-
var lastContext = void 0;
|
|
355
|
+
var lastPipe;
|
|
403
356
|
while (nextPipe) {
|
|
404
357
|
if (typeof context.nextAfterChildren !== 'undefined') {
|
|
405
358
|
// children processed and coming back to parent
|
|
@@ -410,29 +363,30 @@ var Processor = function () {
|
|
|
410
363
|
nextPipe = this.pipe(nextPipe);
|
|
411
364
|
}
|
|
412
365
|
nextPipe.process(context);
|
|
413
|
-
lastContext = context;
|
|
414
366
|
lastPipe = nextPipe;
|
|
415
367
|
nextPipe = null;
|
|
416
368
|
if (context) {
|
|
417
369
|
if (context.next) {
|
|
418
370
|
context = context.next;
|
|
419
|
-
nextPipe =
|
|
371
|
+
nextPipe = context.pipe || lastPipe;
|
|
420
372
|
}
|
|
421
373
|
}
|
|
422
374
|
}
|
|
375
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
423
376
|
return context.hasResult ? context.result : undefined;
|
|
424
377
|
}
|
|
425
378
|
}]);
|
|
426
|
-
return Processor;
|
|
427
379
|
}();
|
|
428
|
-
|
|
380
|
+
|
|
381
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
382
|
+
var Pipe = /*#__PURE__*/function () {
|
|
429
383
|
function Pipe(name) {
|
|
430
|
-
|
|
384
|
+
_classCallCheck(this, Pipe);
|
|
431
385
|
this.name = name;
|
|
432
386
|
this.filters = [];
|
|
433
387
|
}
|
|
434
|
-
|
|
435
|
-
key:
|
|
388
|
+
return _createClass(Pipe, [{
|
|
389
|
+
key: "process",
|
|
436
390
|
value: function process(input) {
|
|
437
391
|
if (!this.processor) {
|
|
438
392
|
throw new Error('add this pipe to a processor before using it');
|
|
@@ -443,10 +397,10 @@ var Pipe = function () {
|
|
|
443
397
|
for (var index = 0; index < length; index++) {
|
|
444
398
|
var filter = this.filters[index];
|
|
445
399
|
if (debug) {
|
|
446
|
-
this.log(
|
|
400
|
+
this.log("filter: ".concat(filter.filterName));
|
|
447
401
|
}
|
|
448
402
|
filter(context);
|
|
449
|
-
if (
|
|
403
|
+
if (_typeof(context) === 'object' && context.exiting) {
|
|
450
404
|
context.exiting = false;
|
|
451
405
|
break;
|
|
452
406
|
}
|
|
@@ -456,26 +410,26 @@ var Pipe = function () {
|
|
|
456
410
|
}
|
|
457
411
|
}
|
|
458
412
|
}, {
|
|
459
|
-
key:
|
|
413
|
+
key: "log",
|
|
460
414
|
value: function log(msg) {
|
|
461
|
-
console.log(
|
|
415
|
+
console.log("[jsondiffpatch] ".concat(this.name, " pipe, ").concat(msg));
|
|
462
416
|
}
|
|
463
417
|
}, {
|
|
464
|
-
key:
|
|
418
|
+
key: "append",
|
|
465
419
|
value: function append() {
|
|
466
|
-
var
|
|
467
|
-
(
|
|
420
|
+
var _this$filters;
|
|
421
|
+
(_this$filters = this.filters).push.apply(_this$filters, arguments);
|
|
468
422
|
return this;
|
|
469
423
|
}
|
|
470
424
|
}, {
|
|
471
|
-
key:
|
|
425
|
+
key: "prepend",
|
|
472
426
|
value: function prepend() {
|
|
473
|
-
var
|
|
474
|
-
(
|
|
427
|
+
var _this$filters2;
|
|
428
|
+
(_this$filters2 = this.filters).unshift.apply(_this$filters2, arguments);
|
|
475
429
|
return this;
|
|
476
430
|
}
|
|
477
431
|
}, {
|
|
478
|
-
key:
|
|
432
|
+
key: "indexOf",
|
|
479
433
|
value: function indexOf(filterName) {
|
|
480
434
|
if (!filterName) {
|
|
481
435
|
throw new Error('a filter name is required');
|
|
@@ -486,67 +440,65 @@ var Pipe = function () {
|
|
|
486
440
|
return index;
|
|
487
441
|
}
|
|
488
442
|
}
|
|
489
|
-
throw new Error(
|
|
443
|
+
throw new Error("filter not found: ".concat(filterName));
|
|
490
444
|
}
|
|
491
445
|
}, {
|
|
492
|
-
key:
|
|
446
|
+
key: "list",
|
|
493
447
|
value: function list() {
|
|
494
448
|
return this.filters.map(function (f) {
|
|
495
449
|
return f.filterName;
|
|
496
450
|
});
|
|
497
451
|
}
|
|
498
452
|
}, {
|
|
499
|
-
key:
|
|
453
|
+
key: "after",
|
|
500
454
|
value: function after(filterName) {
|
|
455
|
+
var _this$filters3;
|
|
501
456
|
var index = this.indexOf(filterName);
|
|
502
|
-
var params = Array
|
|
503
|
-
|
|
504
|
-
throw new Error('a filter is required');
|
|
457
|
+
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
458
|
+
params[_key - 1] = arguments[_key];
|
|
505
459
|
}
|
|
506
|
-
|
|
507
|
-
Array.prototype.splice.apply(this.filters, params);
|
|
460
|
+
(_this$filters3 = this.filters).splice.apply(_this$filters3, [index + 1, 0].concat(params));
|
|
508
461
|
return this;
|
|
509
462
|
}
|
|
510
463
|
}, {
|
|
511
|
-
key:
|
|
464
|
+
key: "before",
|
|
512
465
|
value: function before(filterName) {
|
|
466
|
+
var _this$filters4;
|
|
513
467
|
var index = this.indexOf(filterName);
|
|
514
|
-
var params = Array
|
|
515
|
-
|
|
516
|
-
throw new Error('a filter is required');
|
|
468
|
+
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
469
|
+
params[_key2 - 1] = arguments[_key2];
|
|
517
470
|
}
|
|
518
|
-
|
|
519
|
-
Array.prototype.splice.apply(this.filters, params);
|
|
471
|
+
(_this$filters4 = this.filters).splice.apply(_this$filters4, [index, 0].concat(params));
|
|
520
472
|
return this;
|
|
521
473
|
}
|
|
522
474
|
}, {
|
|
523
|
-
key:
|
|
475
|
+
key: "replace",
|
|
524
476
|
value: function replace(filterName) {
|
|
477
|
+
var _this$filters5;
|
|
525
478
|
var index = this.indexOf(filterName);
|
|
526
|
-
var params = Array
|
|
527
|
-
|
|
528
|
-
throw new Error('a filter is required');
|
|
479
|
+
for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
480
|
+
params[_key3 - 1] = arguments[_key3];
|
|
529
481
|
}
|
|
530
|
-
|
|
531
|
-
Array.prototype.splice.apply(this.filters, params);
|
|
482
|
+
(_this$filters5 = this.filters).splice.apply(_this$filters5, [index, 1].concat(params));
|
|
532
483
|
return this;
|
|
533
484
|
}
|
|
534
485
|
}, {
|
|
535
|
-
key:
|
|
486
|
+
key: "remove",
|
|
536
487
|
value: function remove(filterName) {
|
|
537
488
|
var index = this.indexOf(filterName);
|
|
538
489
|
this.filters.splice(index, 1);
|
|
539
490
|
return this;
|
|
540
491
|
}
|
|
541
492
|
}, {
|
|
542
|
-
key:
|
|
493
|
+
key: "clear",
|
|
543
494
|
value: function clear() {
|
|
544
495
|
this.filters.length = 0;
|
|
545
496
|
return this;
|
|
546
497
|
}
|
|
547
498
|
}, {
|
|
548
|
-
key:
|
|
499
|
+
key: "shouldHaveResult",
|
|
549
500
|
value: function shouldHaveResult(should) {
|
|
501
|
+
var _this = this;
|
|
550
502
|
if (should === false) {
|
|
551
503
|
this.resultCheck = null;
|
|
552
504
|
return;
|
|
@@ -554,11 +506,10 @@ var Pipe = function () {
|
|
|
554
506
|
if (this.resultCheck) {
|
|
555
507
|
return;
|
|
556
508
|
}
|
|
557
|
-
var pipe = this;
|
|
558
509
|
this.resultCheck = function (context) {
|
|
559
510
|
if (!context.hasResult) {
|
|
560
511
|
console.log(context);
|
|
561
|
-
var error = new Error(
|
|
512
|
+
var error = new Error("".concat(_this.name, " failed"));
|
|
562
513
|
error.noResult = true;
|
|
563
514
|
throw error;
|
|
564
515
|
}
|
|
@@ -566,40 +517,27 @@ var Pipe = function () {
|
|
|
566
517
|
return this;
|
|
567
518
|
}
|
|
568
519
|
}]);
|
|
569
|
-
return Pipe;
|
|
570
520
|
}();
|
|
571
|
-
|
|
521
|
+
|
|
522
|
+
var Context = /*#__PURE__*/function () {
|
|
572
523
|
function Context() {
|
|
573
|
-
|
|
524
|
+
_classCallCheck(this, Context);
|
|
574
525
|
}
|
|
575
|
-
|
|
576
|
-
key:
|
|
526
|
+
return _createClass(Context, [{
|
|
527
|
+
key: "setResult",
|
|
577
528
|
value: function setResult(result) {
|
|
578
529
|
this.result = result;
|
|
579
530
|
this.hasResult = true;
|
|
580
531
|
return this;
|
|
581
532
|
}
|
|
582
533
|
}, {
|
|
583
|
-
key:
|
|
534
|
+
key: "exit",
|
|
584
535
|
value: function exit() {
|
|
585
536
|
this.exiting = true;
|
|
586
537
|
return this;
|
|
587
538
|
}
|
|
588
539
|
}, {
|
|
589
|
-
key:
|
|
590
|
-
value: function switchTo(next, pipe) {
|
|
591
|
-
if (typeof next === 'string' || next instanceof Pipe) {
|
|
592
|
-
this.nextPipe = next;
|
|
593
|
-
} else {
|
|
594
|
-
this.next = next;
|
|
595
|
-
if (pipe) {
|
|
596
|
-
this.nextPipe = pipe;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
return this;
|
|
600
|
-
}
|
|
601
|
-
}, {
|
|
602
|
-
key: 'push',
|
|
540
|
+
key: "push",
|
|
603
541
|
value: function push(child, name) {
|
|
604
542
|
child.parent = this;
|
|
605
543
|
if (typeof name !== 'undefined') {
|
|
@@ -619,23 +557,20 @@ var Context = function () {
|
|
|
619
557
|
return this;
|
|
620
558
|
}
|
|
621
559
|
}]);
|
|
622
|
-
return Context;
|
|
623
560
|
}();
|
|
624
|
-
|
|
625
|
-
return a instanceof Array;
|
|
626
|
-
};
|
|
561
|
+
|
|
627
562
|
function cloneRegExp(re) {
|
|
628
563
|
var regexMatch = /^\/(.*)\/([gimyu]*)$/.exec(re.toString());
|
|
629
564
|
return new RegExp(regexMatch[1], regexMatch[2]);
|
|
630
565
|
}
|
|
631
566
|
function clone$1(arg) {
|
|
632
|
-
if (
|
|
567
|
+
if (_typeof(arg) !== 'object') {
|
|
633
568
|
return arg;
|
|
634
569
|
}
|
|
635
570
|
if (arg === null) {
|
|
636
571
|
return null;
|
|
637
572
|
}
|
|
638
|
-
if (isArray(arg)) {
|
|
573
|
+
if (Array.isArray(arg)) {
|
|
639
574
|
return arg.map(clone$1);
|
|
640
575
|
}
|
|
641
576
|
if (arg instanceof Date) {
|
|
@@ -652,60 +587,63 @@ function clone$1(arg) {
|
|
|
652
587
|
}
|
|
653
588
|
return cloned;
|
|
654
589
|
}
|
|
655
|
-
|
|
656
|
-
|
|
590
|
+
|
|
591
|
+
var DiffContext = /*#__PURE__*/function (_Context) {
|
|
657
592
|
function DiffContext(left, right) {
|
|
658
|
-
|
|
659
|
-
|
|
593
|
+
var _this;
|
|
594
|
+
_classCallCheck(this, DiffContext);
|
|
595
|
+
_this = _callSuper(this, DiffContext);
|
|
660
596
|
_this.left = left;
|
|
661
597
|
_this.right = right;
|
|
662
598
|
_this.pipe = 'diff';
|
|
663
599
|
return _this;
|
|
664
600
|
}
|
|
665
|
-
|
|
666
|
-
|
|
601
|
+
_inherits(DiffContext, _Context);
|
|
602
|
+
return _createClass(DiffContext, [{
|
|
603
|
+
key: "setResult",
|
|
667
604
|
value: function setResult(result) {
|
|
668
|
-
if (this.options.cloneDiffValues &&
|
|
669
|
-
var clone
|
|
605
|
+
if (this.options.cloneDiffValues && _typeof(result) === 'object') {
|
|
606
|
+
var clone = typeof this.options.cloneDiffValues === 'function' ? this.options.cloneDiffValues : clone$1;
|
|
670
607
|
if (_typeof(result[0]) === 'object') {
|
|
671
|
-
result[0] = clone
|
|
608
|
+
result[0] = clone(result[0]);
|
|
672
609
|
}
|
|
673
610
|
if (_typeof(result[1]) === 'object') {
|
|
674
|
-
result[1] = clone
|
|
611
|
+
result[1] = clone(result[1]);
|
|
675
612
|
}
|
|
676
613
|
}
|
|
677
|
-
return
|
|
614
|
+
return _superPropGet(DiffContext, "setResult", this, 3)([result]);
|
|
678
615
|
}
|
|
679
616
|
}]);
|
|
680
|
-
return DiffContext;
|
|
681
617
|
}(Context);
|
|
682
|
-
|
|
683
|
-
|
|
618
|
+
|
|
619
|
+
var PatchContext = /*#__PURE__*/function (_Context) {
|
|
684
620
|
function PatchContext(left, delta) {
|
|
685
|
-
|
|
686
|
-
|
|
621
|
+
var _this;
|
|
622
|
+
_classCallCheck(this, PatchContext);
|
|
623
|
+
_this = _callSuper(this, PatchContext);
|
|
687
624
|
_this.left = left;
|
|
688
625
|
_this.delta = delta;
|
|
689
626
|
_this.pipe = 'patch';
|
|
690
627
|
return _this;
|
|
691
628
|
}
|
|
692
|
-
|
|
629
|
+
_inherits(PatchContext, _Context);
|
|
630
|
+
return _createClass(PatchContext);
|
|
693
631
|
}(Context);
|
|
694
|
-
|
|
695
|
-
|
|
632
|
+
|
|
633
|
+
var ReverseContext = /*#__PURE__*/function (_Context) {
|
|
696
634
|
function ReverseContext(delta) {
|
|
697
|
-
|
|
698
|
-
|
|
635
|
+
var _this;
|
|
636
|
+
_classCallCheck(this, ReverseContext);
|
|
637
|
+
_this = _callSuper(this, ReverseContext);
|
|
699
638
|
_this.delta = delta;
|
|
700
639
|
_this.pipe = 'reverse';
|
|
701
640
|
return _this;
|
|
702
641
|
}
|
|
703
|
-
|
|
642
|
+
_inherits(ReverseContext, _Context);
|
|
643
|
+
return _createClass(ReverseContext);
|
|
704
644
|
}(Context);
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
};
|
|
708
|
-
var diffFilter = function trivialMatchesDiffFilter(context) {
|
|
645
|
+
|
|
646
|
+
var diffFilter$3 = function trivialMatchesDiffFilter(context) {
|
|
709
647
|
if (context.left === context.right) {
|
|
710
648
|
context.setResult(undefined).exit();
|
|
711
649
|
return;
|
|
@@ -735,10 +673,10 @@ var diffFilter = function trivialMatchesDiffFilter(context) {
|
|
|
735
673
|
return;
|
|
736
674
|
}
|
|
737
675
|
if (context.leftType === 'object') {
|
|
738
|
-
context.leftIsArray = isArray
|
|
676
|
+
context.leftIsArray = Array.isArray(context.left);
|
|
739
677
|
}
|
|
740
678
|
if (context.rightType === 'object') {
|
|
741
|
-
context.rightIsArray = isArray
|
|
679
|
+
context.rightIsArray = Array.isArray(context.right);
|
|
742
680
|
}
|
|
743
681
|
if (context.leftIsArray !== context.rightIsArray) {
|
|
744
682
|
context.setResult([context.left, context.right]).exit();
|
|
@@ -752,64 +690,67 @@ var diffFilter = function trivialMatchesDiffFilter(context) {
|
|
|
752
690
|
}
|
|
753
691
|
}
|
|
754
692
|
};
|
|
755
|
-
diffFilter.filterName = 'trivial';
|
|
756
|
-
var patchFilter = function trivialMatchesPatchFilter(context) {
|
|
693
|
+
diffFilter$3.filterName = 'trivial';
|
|
694
|
+
var patchFilter$3 = function trivialMatchesPatchFilter(context) {
|
|
757
695
|
if (typeof context.delta === 'undefined') {
|
|
758
696
|
context.setResult(context.left).exit();
|
|
759
697
|
return;
|
|
760
698
|
}
|
|
761
|
-
context.nested = !isArray
|
|
699
|
+
context.nested = !Array.isArray(context.delta);
|
|
762
700
|
if (context.nested) {
|
|
763
701
|
return;
|
|
764
702
|
}
|
|
765
|
-
|
|
766
|
-
|
|
703
|
+
var nonNestedDelta = context.delta;
|
|
704
|
+
if (nonNestedDelta.length === 1) {
|
|
705
|
+
context.setResult(nonNestedDelta[0]).exit();
|
|
767
706
|
return;
|
|
768
707
|
}
|
|
769
|
-
if (
|
|
708
|
+
if (nonNestedDelta.length === 2) {
|
|
770
709
|
if (context.left instanceof RegExp) {
|
|
771
|
-
var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(
|
|
710
|
+
var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(nonNestedDelta[1]);
|
|
772
711
|
if (regexArgs) {
|
|
773
712
|
context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
|
|
774
713
|
return;
|
|
775
714
|
}
|
|
776
715
|
}
|
|
777
|
-
context.setResult(
|
|
716
|
+
context.setResult(nonNestedDelta[1]).exit();
|
|
778
717
|
return;
|
|
779
718
|
}
|
|
780
|
-
if (
|
|
719
|
+
if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
|
|
781
720
|
context.setResult(undefined).exit();
|
|
782
721
|
}
|
|
783
722
|
};
|
|
784
|
-
patchFilter.filterName = 'trivial';
|
|
785
|
-
var reverseFilter = function trivialReferseFilter(context) {
|
|
723
|
+
patchFilter$3.filterName = 'trivial';
|
|
724
|
+
var reverseFilter$3 = function trivialReferseFilter(context) {
|
|
786
725
|
if (typeof context.delta === 'undefined') {
|
|
787
726
|
context.setResult(context.delta).exit();
|
|
788
727
|
return;
|
|
789
728
|
}
|
|
790
|
-
context.nested = !isArray
|
|
729
|
+
context.nested = !Array.isArray(context.delta);
|
|
791
730
|
if (context.nested) {
|
|
792
731
|
return;
|
|
793
732
|
}
|
|
794
|
-
|
|
795
|
-
|
|
733
|
+
var nonNestedDelta = context.delta;
|
|
734
|
+
if (nonNestedDelta.length === 1) {
|
|
735
|
+
context.setResult([nonNestedDelta[0], 0, 0]).exit();
|
|
796
736
|
return;
|
|
797
737
|
}
|
|
798
|
-
if (
|
|
799
|
-
context.setResult([
|
|
738
|
+
if (nonNestedDelta.length === 2) {
|
|
739
|
+
context.setResult([nonNestedDelta[1], nonNestedDelta[0]]).exit();
|
|
800
740
|
return;
|
|
801
741
|
}
|
|
802
|
-
if (
|
|
803
|
-
context.setResult([
|
|
742
|
+
if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
|
|
743
|
+
context.setResult([nonNestedDelta[0]]).exit();
|
|
804
744
|
}
|
|
805
745
|
};
|
|
806
|
-
reverseFilter.filterName = 'trivial';
|
|
807
|
-
|
|
746
|
+
reverseFilter$3.filterName = 'trivial';
|
|
747
|
+
|
|
748
|
+
var collectChildrenDiffFilter = function collectChildrenDiffFilter(context) {
|
|
808
749
|
if (!context || !context.children) {
|
|
809
750
|
return;
|
|
810
751
|
}
|
|
811
752
|
var length = context.children.length;
|
|
812
|
-
var child
|
|
753
|
+
var child;
|
|
813
754
|
var result = context.result;
|
|
814
755
|
for (var index = 0; index < length; index++) {
|
|
815
756
|
child = context.children[index];
|
|
@@ -823,34 +764,36 @@ function collectChildrenDiffFilter(context) {
|
|
|
823
764
|
result._t = 'a';
|
|
824
765
|
}
|
|
825
766
|
context.setResult(result).exit();
|
|
826
|
-
}
|
|
767
|
+
};
|
|
827
768
|
collectChildrenDiffFilter.filterName = 'collectChildren';
|
|
828
|
-
function objectsDiffFilter(context) {
|
|
769
|
+
var objectsDiffFilter = function objectsDiffFilter(context) {
|
|
829
770
|
if (context.leftIsArray || context.leftType !== 'object') {
|
|
830
771
|
return;
|
|
831
772
|
}
|
|
832
|
-
var
|
|
833
|
-
var
|
|
773
|
+
var left = context.left;
|
|
774
|
+
var right = context.right;
|
|
775
|
+
var name;
|
|
776
|
+
var child;
|
|
834
777
|
var propertyFilter = context.options.propertyFilter;
|
|
835
|
-
for (name in
|
|
836
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
778
|
+
for (name in left) {
|
|
779
|
+
if (!Object.prototype.hasOwnProperty.call(left, name)) {
|
|
837
780
|
continue;
|
|
838
781
|
}
|
|
839
782
|
if (propertyFilter && !propertyFilter(name, context)) {
|
|
840
783
|
continue;
|
|
841
784
|
}
|
|
842
|
-
child = new DiffContext(
|
|
785
|
+
child = new DiffContext(left[name], right[name]);
|
|
843
786
|
context.push(child, name);
|
|
844
787
|
}
|
|
845
|
-
for (name in
|
|
846
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
788
|
+
for (name in right) {
|
|
789
|
+
if (!Object.prototype.hasOwnProperty.call(right, name)) {
|
|
847
790
|
continue;
|
|
848
791
|
}
|
|
849
792
|
if (propertyFilter && !propertyFilter(name, context)) {
|
|
850
793
|
continue;
|
|
851
794
|
}
|
|
852
|
-
if (typeof
|
|
853
|
-
child = new DiffContext(undefined,
|
|
795
|
+
if (typeof left[name] === 'undefined') {
|
|
796
|
+
child = new DiffContext(undefined, right[name]);
|
|
854
797
|
context.push(child, name);
|
|
855
798
|
}
|
|
856
799
|
}
|
|
@@ -859,79 +802,88 @@ function objectsDiffFilter(context) {
|
|
|
859
802
|
return;
|
|
860
803
|
}
|
|
861
804
|
context.exit();
|
|
862
|
-
}
|
|
805
|
+
};
|
|
863
806
|
objectsDiffFilter.filterName = 'objects';
|
|
864
|
-
var patchFilter$
|
|
807
|
+
var patchFilter$2 = function nestedPatchFilter(context) {
|
|
865
808
|
if (!context.nested) {
|
|
866
809
|
return;
|
|
867
810
|
}
|
|
868
|
-
|
|
811
|
+
var nestedDelta = context.delta;
|
|
812
|
+
if (nestedDelta._t) {
|
|
869
813
|
return;
|
|
870
814
|
}
|
|
871
|
-
var
|
|
872
|
-
var
|
|
873
|
-
|
|
874
|
-
|
|
815
|
+
var objectDelta = nestedDelta;
|
|
816
|
+
var name;
|
|
817
|
+
var child;
|
|
818
|
+
for (name in objectDelta) {
|
|
819
|
+
child = new PatchContext(context.left[name], objectDelta[name]);
|
|
875
820
|
context.push(child, name);
|
|
876
821
|
}
|
|
877
822
|
context.exit();
|
|
878
823
|
};
|
|
879
|
-
patchFilter$
|
|
880
|
-
var collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
|
|
824
|
+
patchFilter$2.filterName = 'objects';
|
|
825
|
+
var collectChildrenPatchFilter$1 = function collectChildrenPatchFilter(context) {
|
|
881
826
|
if (!context || !context.children) {
|
|
882
827
|
return;
|
|
883
828
|
}
|
|
884
|
-
|
|
829
|
+
var deltaWithChildren = context.delta;
|
|
830
|
+
if (deltaWithChildren._t) {
|
|
885
831
|
return;
|
|
886
832
|
}
|
|
833
|
+
var object = context.left;
|
|
887
834
|
var length = context.children.length;
|
|
888
|
-
var child
|
|
835
|
+
var child;
|
|
889
836
|
for (var index = 0; index < length; index++) {
|
|
890
837
|
child = context.children[index];
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
838
|
+
var property = child.childName;
|
|
839
|
+
if (Object.prototype.hasOwnProperty.call(context.left, property) && child.result === undefined) {
|
|
840
|
+
delete object[property];
|
|
841
|
+
} else if (object[property] !== child.result) {
|
|
842
|
+
object[property] = child.result;
|
|
895
843
|
}
|
|
896
844
|
}
|
|
897
|
-
context.setResult(
|
|
845
|
+
context.setResult(object).exit();
|
|
898
846
|
};
|
|
899
|
-
collectChildrenPatchFilter.filterName = 'collectChildren';
|
|
900
|
-
var reverseFilter$
|
|
847
|
+
collectChildrenPatchFilter$1.filterName = 'collectChildren';
|
|
848
|
+
var reverseFilter$2 = function nestedReverseFilter(context) {
|
|
901
849
|
if (!context.nested) {
|
|
902
850
|
return;
|
|
903
851
|
}
|
|
904
|
-
|
|
852
|
+
var nestedDelta = context.delta;
|
|
853
|
+
if (nestedDelta._t) {
|
|
905
854
|
return;
|
|
906
855
|
}
|
|
907
|
-
var
|
|
908
|
-
var
|
|
909
|
-
|
|
910
|
-
|
|
856
|
+
var objectDelta = context.delta;
|
|
857
|
+
var name;
|
|
858
|
+
var child;
|
|
859
|
+
for (name in objectDelta) {
|
|
860
|
+
child = new ReverseContext(objectDelta[name]);
|
|
911
861
|
context.push(child, name);
|
|
912
862
|
}
|
|
913
863
|
context.exit();
|
|
914
864
|
};
|
|
915
|
-
reverseFilter$
|
|
916
|
-
function collectChildrenReverseFilter(context) {
|
|
865
|
+
reverseFilter$2.filterName = 'objects';
|
|
866
|
+
var collectChildrenReverseFilter$1 = function collectChildrenReverseFilter(context) {
|
|
917
867
|
if (!context || !context.children) {
|
|
918
868
|
return;
|
|
919
869
|
}
|
|
920
|
-
|
|
870
|
+
var deltaWithChildren = context.delta;
|
|
871
|
+
if (deltaWithChildren._t) {
|
|
921
872
|
return;
|
|
922
873
|
}
|
|
923
874
|
var length = context.children.length;
|
|
924
|
-
var child
|
|
875
|
+
var child;
|
|
925
876
|
var delta = {};
|
|
926
877
|
for (var index = 0; index < length; index++) {
|
|
927
878
|
child = context.children[index];
|
|
928
|
-
|
|
929
|
-
|
|
879
|
+
var property = child.childName;
|
|
880
|
+
if (delta[property] !== child.result) {
|
|
881
|
+
delta[property] = child.result;
|
|
930
882
|
}
|
|
931
883
|
}
|
|
932
884
|
context.setResult(delta).exit();
|
|
933
|
-
}
|
|
934
|
-
collectChildrenReverseFilter.filterName = 'collectChildren';
|
|
885
|
+
};
|
|
886
|
+
collectChildrenReverseFilter$1.filterName = 'collectChildren';
|
|
935
887
|
|
|
936
888
|
/*
|
|
937
889
|
|
|
@@ -940,20 +892,17 @@ LCS implementation that supports arrays or strings
|
|
|
940
892
|
reference: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
|
|
941
893
|
|
|
942
894
|
*/
|
|
943
|
-
|
|
944
895
|
var defaultMatch = function defaultMatch(array1, array2, index1, index2) {
|
|
945
896
|
return array1[index1] === array2[index2];
|
|
946
897
|
};
|
|
947
898
|
var lengthMatrix = function lengthMatrix(array1, array2, match, context) {
|
|
948
899
|
var len1 = array1.length;
|
|
949
900
|
var len2 = array2.length;
|
|
950
|
-
var x
|
|
951
|
-
y = void 0;
|
|
952
|
-
|
|
901
|
+
var x, y;
|
|
953
902
|
// initialize empty matrix of len1+1 x len2+1
|
|
954
|
-
var matrix =
|
|
903
|
+
var matrix = new Array(len1 + 1);
|
|
955
904
|
for (x = 0; x < len1 + 1; x++) {
|
|
956
|
-
matrix[x] =
|
|
905
|
+
matrix[x] = new Array(len2 + 1);
|
|
957
906
|
for (y = 0; y < len2 + 1; y++) {
|
|
958
907
|
matrix[x][y] = 0;
|
|
959
908
|
}
|
|
@@ -999,33 +948,16 @@ var backtrack = function backtrack(matrix, array1, array2, context) {
|
|
|
999
948
|
}
|
|
1000
949
|
return subsequence;
|
|
1001
950
|
};
|
|
1002
|
-
var get
|
|
951
|
+
var get = function get(array1, array2, match, context) {
|
|
1003
952
|
var innerContext = context || {};
|
|
1004
953
|
var matrix = lengthMatrix(array1, array2, match || defaultMatch, innerContext);
|
|
1005
|
-
|
|
1006
|
-
if (typeof array1 === 'string' && typeof array2 === 'string') {
|
|
1007
|
-
result.sequence = result.sequence.join('');
|
|
1008
|
-
}
|
|
1009
|
-
return result;
|
|
954
|
+
return backtrack(matrix, array1, array2, innerContext);
|
|
1010
955
|
};
|
|
1011
956
|
var lcs = {
|
|
1012
|
-
get: get
|
|
957
|
+
get: get
|
|
1013
958
|
};
|
|
959
|
+
|
|
1014
960
|
var ARRAY_MOVE = 3;
|
|
1015
|
-
var isArray$2 = typeof Array.isArray === 'function' ? Array.isArray : function (a) {
|
|
1016
|
-
return a instanceof Array;
|
|
1017
|
-
};
|
|
1018
|
-
var arrayIndexOf = typeof Array.prototype.indexOf === 'function' ? function (array, item) {
|
|
1019
|
-
return array.indexOf(item);
|
|
1020
|
-
} : function (array, item) {
|
|
1021
|
-
var length = array.length;
|
|
1022
|
-
for (var i = 0; i < length; i++) {
|
|
1023
|
-
if (array[i] === item) {
|
|
1024
|
-
return i;
|
|
1025
|
-
}
|
|
1026
|
-
}
|
|
1027
|
-
return -1;
|
|
1028
|
-
};
|
|
1029
961
|
function arraysHaveMatchByRef(array1, array2, len1, len2) {
|
|
1030
962
|
for (var index1 = 0; index1 < len1; index1++) {
|
|
1031
963
|
var val1 = array1[index1];
|
|
@@ -1043,7 +975,7 @@ function matchItems(array1, array2, index1, index2, context) {
|
|
|
1043
975
|
if (value1 === value2) {
|
|
1044
976
|
return true;
|
|
1045
977
|
}
|
|
1046
|
-
if (
|
|
978
|
+
if (_typeof(value1) !== 'object' || _typeof(value2) !== 'object') {
|
|
1047
979
|
return false;
|
|
1048
980
|
}
|
|
1049
981
|
var objectHash = context.objectHash;
|
|
@@ -1051,35 +983,25 @@ function matchItems(array1, array2, index1, index2, context) {
|
|
|
1051
983
|
// no way to match objects was provided, try match by position
|
|
1052
984
|
return context.matchByPosition && index1 === index2;
|
|
1053
985
|
}
|
|
1054
|
-
|
|
1055
|
-
var
|
|
1056
|
-
if (typeof
|
|
1057
|
-
context.hashCache1 =
|
|
1058
|
-
hash1 = context.hashCache1[index1];
|
|
1059
|
-
if (typeof hash1 === 'undefined') {
|
|
1060
|
-
context.hashCache1[index1] = hash1 = objectHash(value1, index1);
|
|
1061
|
-
}
|
|
1062
|
-
} else {
|
|
1063
|
-
hash1 = objectHash(value1);
|
|
986
|
+
context.hashCache1 = context.hashCache1 || [];
|
|
987
|
+
var hash1 = context.hashCache1[index1];
|
|
988
|
+
if (typeof hash1 === 'undefined') {
|
|
989
|
+
context.hashCache1[index1] = hash1 = objectHash(value1, index1);
|
|
1064
990
|
}
|
|
1065
991
|
if (typeof hash1 === 'undefined') {
|
|
1066
992
|
return false;
|
|
1067
993
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
context.hashCache2[index2] = hash2 = objectHash(value2, index2);
|
|
1073
|
-
}
|
|
1074
|
-
} else {
|
|
1075
|
-
hash2 = objectHash(value2);
|
|
994
|
+
context.hashCache2 = context.hashCache2 || [];
|
|
995
|
+
var hash2 = context.hashCache2[index2];
|
|
996
|
+
if (typeof hash2 === 'undefined') {
|
|
997
|
+
context.hashCache2[index2] = hash2 = objectHash(value2, index2);
|
|
1076
998
|
}
|
|
1077
999
|
if (typeof hash2 === 'undefined') {
|
|
1078
1000
|
return false;
|
|
1079
1001
|
}
|
|
1080
1002
|
return hash1 === hash2;
|
|
1081
1003
|
}
|
|
1082
|
-
var diffFilter$
|
|
1004
|
+
var diffFilter$2 = function arraysDiffFilter(context) {
|
|
1083
1005
|
if (!context.leftIsArray) {
|
|
1084
1006
|
return;
|
|
1085
1007
|
}
|
|
@@ -1089,22 +1011,21 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1089
1011
|
};
|
|
1090
1012
|
var commonHead = 0;
|
|
1091
1013
|
var commonTail = 0;
|
|
1092
|
-
var index
|
|
1093
|
-
var index1
|
|
1094
|
-
var index2
|
|
1014
|
+
var index;
|
|
1015
|
+
var index1;
|
|
1016
|
+
var index2;
|
|
1095
1017
|
var array1 = context.left;
|
|
1096
1018
|
var array2 = context.right;
|
|
1097
1019
|
var len1 = array1.length;
|
|
1098
1020
|
var len2 = array2.length;
|
|
1099
|
-
var child
|
|
1021
|
+
var child;
|
|
1100
1022
|
if (len1 > 0 && len2 > 0 && !matchContext.objectHash && typeof matchContext.matchByPosition !== 'boolean') {
|
|
1101
1023
|
matchContext.matchByPosition = !arraysHaveMatchByRef(array1, array2, len1, len2);
|
|
1102
1024
|
}
|
|
1103
|
-
|
|
1104
1025
|
// separate common head
|
|
1105
1026
|
while (commonHead < len1 && commonHead < len2 && matchItems(array1, array2, commonHead, commonHead, matchContext)) {
|
|
1106
1027
|
index = commonHead;
|
|
1107
|
-
child = new DiffContext(
|
|
1028
|
+
child = new DiffContext(array1[index], array2[index]);
|
|
1108
1029
|
context.push(child, index);
|
|
1109
1030
|
commonHead++;
|
|
1110
1031
|
}
|
|
@@ -1112,11 +1033,11 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1112
1033
|
while (commonTail + commonHead < len1 && commonTail + commonHead < len2 && matchItems(array1, array2, len1 - 1 - commonTail, len2 - 1 - commonTail, matchContext)) {
|
|
1113
1034
|
index1 = len1 - 1 - commonTail;
|
|
1114
1035
|
index2 = len2 - 1 - commonTail;
|
|
1115
|
-
child = new DiffContext(
|
|
1036
|
+
child = new DiffContext(array1[index1], array2[index2]);
|
|
1116
1037
|
context.push(child, index2);
|
|
1117
1038
|
commonTail++;
|
|
1118
1039
|
}
|
|
1119
|
-
var result
|
|
1040
|
+
var result;
|
|
1120
1041
|
if (commonHead + commonTail === len1) {
|
|
1121
1042
|
if (len1 === len2) {
|
|
1122
1043
|
// arrays are identical
|
|
@@ -1139,7 +1060,7 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1139
1060
|
_t: 'a'
|
|
1140
1061
|
};
|
|
1141
1062
|
for (index = commonHead; index < len1 - commonTail; index++) {
|
|
1142
|
-
result[
|
|
1063
|
+
result["_".concat(index)] = [array1[index], 0, 0];
|
|
1143
1064
|
}
|
|
1144
1065
|
context.setResult(result).exit();
|
|
1145
1066
|
return;
|
|
@@ -1147,7 +1068,6 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1147
1068
|
// reset hash cache
|
|
1148
1069
|
delete matchContext.hashCache1;
|
|
1149
1070
|
delete matchContext.hashCache2;
|
|
1150
|
-
|
|
1151
1071
|
// diff is not trivial, find the LCS (Longest Common Subsequence)
|
|
1152
1072
|
var trimmed1 = array1.slice(commonHead, len1 - commonTail);
|
|
1153
1073
|
var trimmed2 = array2.slice(commonHead, len2 - commonTail);
|
|
@@ -1157,9 +1077,9 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1157
1077
|
_t: 'a'
|
|
1158
1078
|
};
|
|
1159
1079
|
for (index = commonHead; index < len1 - commonTail; index++) {
|
|
1160
|
-
if (
|
|
1080
|
+
if (seq.indices1.indexOf(index - commonHead) < 0) {
|
|
1161
1081
|
// removed
|
|
1162
|
-
result[
|
|
1082
|
+
result["_".concat(index)] = [array1[index], 0, 0];
|
|
1163
1083
|
removedItems.push(index);
|
|
1164
1084
|
}
|
|
1165
1085
|
}
|
|
@@ -1173,7 +1093,7 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1173
1093
|
}
|
|
1174
1094
|
var removedItemsLength = removedItems.length;
|
|
1175
1095
|
for (index = commonHead; index < len2 - commonTail; index++) {
|
|
1176
|
-
var indexOnArray2 =
|
|
1096
|
+
var indexOnArray2 = seq.indices2.indexOf(index - commonHead);
|
|
1177
1097
|
if (indexOnArray2 < 0) {
|
|
1178
1098
|
// added, try to match with a removed item and register as position move
|
|
1179
1099
|
var isMove = false;
|
|
@@ -1182,13 +1102,13 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1182
1102
|
index1 = removedItems[removeItemIndex1];
|
|
1183
1103
|
if (matchItems(trimmed1, trimmed2, index1 - commonHead, index - commonHead, matchContext)) {
|
|
1184
1104
|
// store position move as: [originalValue, newPosition, ARRAY_MOVE]
|
|
1185
|
-
result[
|
|
1105
|
+
result["_".concat(index1)].splice(1, 2, index, ARRAY_MOVE);
|
|
1186
1106
|
if (!includeValueOnMove) {
|
|
1187
1107
|
// don't include moved value on diff, to save bytes
|
|
1188
|
-
result[
|
|
1108
|
+
result["_".concat(index1)][0] = '';
|
|
1189
1109
|
}
|
|
1190
1110
|
index2 = index;
|
|
1191
|
-
child = new DiffContext(
|
|
1111
|
+
child = new DiffContext(array1[index1], array2[index2]);
|
|
1192
1112
|
context.push(child, index2);
|
|
1193
1113
|
removedItems.splice(removeItemIndex1, 1);
|
|
1194
1114
|
isMove = true;
|
|
@@ -1204,13 +1124,13 @@ var diffFilter$1 = function arraysDiffFilter(context) {
|
|
|
1204
1124
|
// match, do inner diff
|
|
1205
1125
|
index1 = seq.indices1[indexOnArray2] + commonHead;
|
|
1206
1126
|
index2 = seq.indices2[indexOnArray2] + commonHead;
|
|
1207
|
-
child = new DiffContext(
|
|
1127
|
+
child = new DiffContext(array1[index1], array2[index2]);
|
|
1208
1128
|
context.push(child, index2);
|
|
1209
1129
|
}
|
|
1210
1130
|
}
|
|
1211
1131
|
context.setResult(result).exit();
|
|
1212
1132
|
};
|
|
1213
|
-
diffFilter$
|
|
1133
|
+
diffFilter$2.filterName = 'arrays';
|
|
1214
1134
|
var compare = {
|
|
1215
1135
|
numerically: function numerically(a, b) {
|
|
1216
1136
|
return a - b;
|
|
@@ -1221,18 +1141,18 @@ var compare = {
|
|
|
1221
1141
|
};
|
|
1222
1142
|
}
|
|
1223
1143
|
};
|
|
1224
|
-
var patchFilter$
|
|
1144
|
+
var patchFilter$1 = function nestedPatchFilter(context) {
|
|
1225
1145
|
if (!context.nested) {
|
|
1226
1146
|
return;
|
|
1227
1147
|
}
|
|
1228
|
-
|
|
1148
|
+
var nestedDelta = context.delta;
|
|
1149
|
+
if (nestedDelta._t !== 'a') {
|
|
1229
1150
|
return;
|
|
1230
1151
|
}
|
|
1231
|
-
var index
|
|
1232
|
-
var index1
|
|
1233
|
-
var delta =
|
|
1152
|
+
var index;
|
|
1153
|
+
var index1;
|
|
1154
|
+
var delta = nestedDelta;
|
|
1234
1155
|
var array = context.left;
|
|
1235
|
-
|
|
1236
1156
|
// first, separate removals, insertions and modifications
|
|
1237
1157
|
var toRemove = [];
|
|
1238
1158
|
var toInsert = [];
|
|
@@ -1240,35 +1160,36 @@ var patchFilter$2 = function nestedPatchFilter(context) {
|
|
|
1240
1160
|
for (index in delta) {
|
|
1241
1161
|
if (index !== '_t') {
|
|
1242
1162
|
if (index[0] === '_') {
|
|
1163
|
+
var removedOrMovedIndex = index;
|
|
1243
1164
|
// removed item from original array
|
|
1244
|
-
if (delta[
|
|
1165
|
+
if (delta[removedOrMovedIndex][2] === 0 || delta[removedOrMovedIndex][2] === ARRAY_MOVE) {
|
|
1245
1166
|
toRemove.push(parseInt(index.slice(1), 10));
|
|
1246
1167
|
} else {
|
|
1247
|
-
throw new Error('only removal or move can be applied at original array indices,' +
|
|
1168
|
+
throw new Error('only removal or move can be applied at original array indices,' + " invalid diff type: ".concat(delta[removedOrMovedIndex][2]));
|
|
1248
1169
|
}
|
|
1249
1170
|
} else {
|
|
1250
|
-
|
|
1171
|
+
var numberIndex = index;
|
|
1172
|
+
if (delta[numberIndex].length === 1) {
|
|
1251
1173
|
// added item at new array
|
|
1252
1174
|
toInsert.push({
|
|
1253
|
-
index: parseInt(
|
|
1254
|
-
value: delta[
|
|
1175
|
+
index: parseInt(numberIndex, 10),
|
|
1176
|
+
value: delta[numberIndex][0]
|
|
1255
1177
|
});
|
|
1256
1178
|
} else {
|
|
1257
1179
|
// modified item at new array
|
|
1258
1180
|
toModify.push({
|
|
1259
|
-
index: parseInt(
|
|
1260
|
-
delta: delta[
|
|
1181
|
+
index: parseInt(numberIndex, 10),
|
|
1182
|
+
delta: delta[numberIndex]
|
|
1261
1183
|
});
|
|
1262
1184
|
}
|
|
1263
1185
|
}
|
|
1264
1186
|
}
|
|
1265
1187
|
}
|
|
1266
|
-
|
|
1267
1188
|
// remove items, in reverse order to avoid sawing our own floor
|
|
1268
1189
|
toRemove = toRemove.sort(compare.numerically);
|
|
1269
1190
|
for (index = toRemove.length - 1; index >= 0; index--) {
|
|
1270
1191
|
index1 = toRemove[index];
|
|
1271
|
-
var indexDiff = delta[
|
|
1192
|
+
var indexDiff = delta["_".concat(index1)];
|
|
1272
1193
|
var removedValue = array.splice(index1, 1)[0];
|
|
1273
1194
|
if (indexDiff[2] === ARRAY_MOVE) {
|
|
1274
1195
|
// reinsert later
|
|
@@ -1278,7 +1199,6 @@ var patchFilter$2 = function nestedPatchFilter(context) {
|
|
|
1278
1199
|
});
|
|
1279
1200
|
}
|
|
1280
1201
|
}
|
|
1281
|
-
|
|
1282
1202
|
// insert items, in reverse order to avoid moving our own floor
|
|
1283
1203
|
toInsert = toInsert.sort(compare.numericallyBy('index'));
|
|
1284
1204
|
var toInsertLength = toInsert.length;
|
|
@@ -1286,75 +1206,81 @@ var patchFilter$2 = function nestedPatchFilter(context) {
|
|
|
1286
1206
|
var insertion = toInsert[index];
|
|
1287
1207
|
array.splice(insertion.index, 0, insertion.value);
|
|
1288
1208
|
}
|
|
1289
|
-
|
|
1290
1209
|
// apply modifications
|
|
1291
1210
|
var toModifyLength = toModify.length;
|
|
1292
|
-
var child
|
|
1211
|
+
var child;
|
|
1293
1212
|
if (toModifyLength > 0) {
|
|
1294
1213
|
for (index = 0; index < toModifyLength; index++) {
|
|
1295
1214
|
var modification = toModify[index];
|
|
1296
|
-
child = new PatchContext(
|
|
1215
|
+
child = new PatchContext(array[modification.index], modification.delta);
|
|
1297
1216
|
context.push(child, modification.index);
|
|
1298
1217
|
}
|
|
1299
1218
|
}
|
|
1300
1219
|
if (!context.children) {
|
|
1301
|
-
context.setResult(
|
|
1220
|
+
context.setResult(array).exit();
|
|
1302
1221
|
return;
|
|
1303
1222
|
}
|
|
1304
1223
|
context.exit();
|
|
1305
1224
|
};
|
|
1306
|
-
patchFilter$
|
|
1307
|
-
var collectChildrenPatchFilter
|
|
1225
|
+
patchFilter$1.filterName = 'arrays';
|
|
1226
|
+
var collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
|
|
1308
1227
|
if (!context || !context.children) {
|
|
1309
1228
|
return;
|
|
1310
1229
|
}
|
|
1311
|
-
|
|
1230
|
+
var deltaWithChildren = context.delta;
|
|
1231
|
+
if (deltaWithChildren._t !== 'a') {
|
|
1312
1232
|
return;
|
|
1313
1233
|
}
|
|
1234
|
+
var array = context.left;
|
|
1314
1235
|
var length = context.children.length;
|
|
1315
|
-
var child
|
|
1236
|
+
var child;
|
|
1316
1237
|
for (var index = 0; index < length; index++) {
|
|
1317
1238
|
child = context.children[index];
|
|
1318
|
-
|
|
1239
|
+
var arrayIndex = child.childName;
|
|
1240
|
+
array[arrayIndex] = child.result;
|
|
1319
1241
|
}
|
|
1320
|
-
context.setResult(
|
|
1242
|
+
context.setResult(array).exit();
|
|
1321
1243
|
};
|
|
1322
|
-
collectChildrenPatchFilter
|
|
1323
|
-
var reverseFilter$
|
|
1244
|
+
collectChildrenPatchFilter.filterName = 'arraysCollectChildren';
|
|
1245
|
+
var reverseFilter$1 = function arraysReverseFilter(context) {
|
|
1324
1246
|
if (!context.nested) {
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1247
|
+
var nonNestedDelta = context.delta;
|
|
1248
|
+
if (nonNestedDelta[2] === ARRAY_MOVE) {
|
|
1249
|
+
var arrayMoveDelta = nonNestedDelta;
|
|
1250
|
+
context.newName = "_".concat(arrayMoveDelta[1]);
|
|
1251
|
+
context.setResult([arrayMoveDelta[0], parseInt(context.childName.substring(1), 10), ARRAY_MOVE]).exit();
|
|
1328
1252
|
}
|
|
1329
1253
|
return;
|
|
1330
1254
|
}
|
|
1331
|
-
|
|
1255
|
+
var nestedDelta = context.delta;
|
|
1256
|
+
if (nestedDelta._t !== 'a') {
|
|
1332
1257
|
return;
|
|
1333
1258
|
}
|
|
1334
|
-
var
|
|
1335
|
-
var
|
|
1336
|
-
|
|
1259
|
+
var arrayDelta = nestedDelta;
|
|
1260
|
+
var name;
|
|
1261
|
+
var child;
|
|
1262
|
+
for (name in arrayDelta) {
|
|
1337
1263
|
if (name === '_t') {
|
|
1338
1264
|
continue;
|
|
1339
1265
|
}
|
|
1340
|
-
child = new ReverseContext(
|
|
1266
|
+
child = new ReverseContext(arrayDelta[name]);
|
|
1341
1267
|
context.push(child, name);
|
|
1342
1268
|
}
|
|
1343
1269
|
context.exit();
|
|
1344
1270
|
};
|
|
1345
|
-
reverseFilter$
|
|
1271
|
+
reverseFilter$1.filterName = 'arrays';
|
|
1346
1272
|
var reverseArrayDeltaIndex = function reverseArrayDeltaIndex(delta, index, itemDelta) {
|
|
1347
1273
|
if (typeof index === 'string' && index[0] === '_') {
|
|
1348
|
-
return parseInt(index.
|
|
1349
|
-
} else if (isArray
|
|
1350
|
-
return
|
|
1274
|
+
return parseInt(index.substring(1), 10);
|
|
1275
|
+
} else if (Array.isArray(itemDelta) && itemDelta[2] === 0) {
|
|
1276
|
+
return "_".concat(index);
|
|
1351
1277
|
}
|
|
1352
1278
|
var reverseIndex = +index;
|
|
1353
1279
|
for (var deltaIndex in delta) {
|
|
1354
1280
|
var deltaItem = delta[deltaIndex];
|
|
1355
|
-
if (isArray
|
|
1281
|
+
if (Array.isArray(deltaItem)) {
|
|
1356
1282
|
if (deltaItem[2] === ARRAY_MOVE) {
|
|
1357
|
-
var moveFromIndex = parseInt(deltaIndex.
|
|
1283
|
+
var moveFromIndex = parseInt(deltaIndex.substring(1), 10);
|
|
1358
1284
|
var moveToIndex = deltaItem[1];
|
|
1359
1285
|
if (moveToIndex === +index) {
|
|
1360
1286
|
return moveFromIndex;
|
|
@@ -1365,26 +1291,28 @@ var reverseArrayDeltaIndex = function reverseArrayDeltaIndex(delta, index, itemD
|
|
|
1365
1291
|
reverseIndex--;
|
|
1366
1292
|
}
|
|
1367
1293
|
} else if (deltaItem[2] === 0) {
|
|
1368
|
-
var deleteIndex = parseInt(deltaIndex.
|
|
1294
|
+
var deleteIndex = parseInt(deltaIndex.substring(1), 10);
|
|
1369
1295
|
if (deleteIndex <= reverseIndex) {
|
|
1370
1296
|
reverseIndex++;
|
|
1371
1297
|
}
|
|
1372
|
-
} else if (deltaItem.length === 1 && deltaIndex <= reverseIndex) {
|
|
1298
|
+
} else if (deltaItem.length === 1 && parseInt(deltaIndex, 10) <= reverseIndex) {
|
|
1373
1299
|
reverseIndex--;
|
|
1374
1300
|
}
|
|
1375
1301
|
}
|
|
1376
1302
|
}
|
|
1377
1303
|
return reverseIndex;
|
|
1378
1304
|
};
|
|
1379
|
-
function collectChildrenReverseFilter
|
|
1305
|
+
var collectChildrenReverseFilter = function collectChildrenReverseFilter(context) {
|
|
1380
1306
|
if (!context || !context.children) {
|
|
1381
1307
|
return;
|
|
1382
1308
|
}
|
|
1383
|
-
|
|
1309
|
+
var deltaWithChildren = context.delta;
|
|
1310
|
+
if (deltaWithChildren._t !== 'a') {
|
|
1384
1311
|
return;
|
|
1385
1312
|
}
|
|
1313
|
+
var arrayDelta = deltaWithChildren;
|
|
1386
1314
|
var length = context.children.length;
|
|
1387
|
-
var child
|
|
1315
|
+
var child;
|
|
1388
1316
|
var delta = {
|
|
1389
1317
|
_t: 'a'
|
|
1390
1318
|
};
|
|
@@ -1392,16 +1320,18 @@ function collectChildrenReverseFilter$1(context) {
|
|
|
1392
1320
|
child = context.children[index];
|
|
1393
1321
|
var name = child.newName;
|
|
1394
1322
|
if (typeof name === 'undefined') {
|
|
1395
|
-
name = reverseArrayDeltaIndex(
|
|
1323
|
+
name = reverseArrayDeltaIndex(arrayDelta, child.childName, child.result);
|
|
1396
1324
|
}
|
|
1397
1325
|
if (delta[name] !== child.result) {
|
|
1326
|
+
// There's no way to type this well.
|
|
1398
1327
|
delta[name] = child.result;
|
|
1399
1328
|
}
|
|
1400
1329
|
}
|
|
1401
1330
|
context.setResult(delta).exit();
|
|
1402
|
-
}
|
|
1403
|
-
collectChildrenReverseFilter
|
|
1404
|
-
|
|
1331
|
+
};
|
|
1332
|
+
collectChildrenReverseFilter.filterName = 'arraysCollectChildren';
|
|
1333
|
+
|
|
1334
|
+
var diffFilter$1 = function datesDiffFilter(context) {
|
|
1405
1335
|
if (context.left instanceof Date) {
|
|
1406
1336
|
if (context.right instanceof Date) {
|
|
1407
1337
|
if (context.left.getTime() !== context.right.getTime()) {
|
|
@@ -1417,34 +1347,22 @@ var diffFilter$2 = function datesDiffFilter(context) {
|
|
|
1417
1347
|
context.setResult([context.left, context.right]).exit();
|
|
1418
1348
|
}
|
|
1419
1349
|
};
|
|
1420
|
-
diffFilter$
|
|
1350
|
+
diffFilter$1.filterName = 'dates';
|
|
1421
1351
|
|
|
1422
|
-
/* global diff_match_patch */
|
|
1423
1352
|
var TEXT_DIFF = 2;
|
|
1424
1353
|
var DEFAULT_MIN_LENGTH = 60;
|
|
1425
1354
|
var cachedDiffPatch = null;
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1355
|
+
function getDiffMatchPatch(options, required) {
|
|
1356
|
+
var _a;
|
|
1429
1357
|
if (!cachedDiffPatch) {
|
|
1430
|
-
var instance
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
instance = typeof diff_match_patch === 'function' ? new diff_match_patch() : new diff_match_patch.diff_match_patch();
|
|
1435
|
-
} else if (dmp__default["default"]) {
|
|
1436
|
-
try {
|
|
1437
|
-
instance = dmp__default["default"] && new dmp__default["default"]();
|
|
1438
|
-
} catch (err) {
|
|
1439
|
-
instance = null;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
/* eslint-enable camelcase, new-cap */
|
|
1443
|
-
if (!instance) {
|
|
1358
|
+
var instance;
|
|
1359
|
+
if ((_a = options === null || options === void 0 ? void 0 : options.textDiff) === null || _a === void 0 ? void 0 : _a.diffMatchPatch) {
|
|
1360
|
+
instance = new options.textDiff.diffMatchPatch();
|
|
1361
|
+
} else {
|
|
1444
1362
|
if (!required) {
|
|
1445
1363
|
return null;
|
|
1446
1364
|
}
|
|
1447
|
-
var error = new Error('
|
|
1365
|
+
var error = new Error('The diff-match-patch library was not provided. Pass the library in through the options or use the `jsondiffpatch/with-text-diffs` entry-point.');
|
|
1448
1366
|
// eslint-disable-next-line camelcase
|
|
1449
1367
|
error.diff_match_patch_not_found = true;
|
|
1450
1368
|
throw error;
|
|
@@ -1466,58 +1384,59 @@ var getDiffMatchPatch = function getDiffMatchPatch(required) {
|
|
|
1466
1384
|
};
|
|
1467
1385
|
}
|
|
1468
1386
|
return cachedDiffPatch;
|
|
1469
|
-
}
|
|
1470
|
-
var diffFilter
|
|
1387
|
+
}
|
|
1388
|
+
var diffFilter = function textsDiffFilter(context) {
|
|
1471
1389
|
if (context.leftType !== 'string') {
|
|
1472
1390
|
return;
|
|
1473
1391
|
}
|
|
1392
|
+
var left = context.left;
|
|
1393
|
+
var right = context.right;
|
|
1474
1394
|
var minLength = context.options && context.options.textDiff && context.options.textDiff.minLength || DEFAULT_MIN_LENGTH;
|
|
1475
|
-
if (
|
|
1476
|
-
context.setResult([
|
|
1395
|
+
if (left.length < minLength || right.length < minLength) {
|
|
1396
|
+
context.setResult([left, right]).exit();
|
|
1477
1397
|
return;
|
|
1478
1398
|
}
|
|
1479
1399
|
// large text, try to use a text-diff algorithm
|
|
1480
|
-
var diffMatchPatch = getDiffMatchPatch();
|
|
1400
|
+
var diffMatchPatch = getDiffMatchPatch(context.options);
|
|
1481
1401
|
if (!diffMatchPatch) {
|
|
1482
1402
|
// diff-match-patch library not available,
|
|
1483
1403
|
// fallback to regular string replace
|
|
1484
|
-
context.setResult([
|
|
1404
|
+
context.setResult([left, right]).exit();
|
|
1485
1405
|
return;
|
|
1486
1406
|
}
|
|
1487
1407
|
var diff = diffMatchPatch.diff;
|
|
1488
|
-
context.setResult([diff(
|
|
1408
|
+
context.setResult([diff(left, right), 0, TEXT_DIFF]).exit();
|
|
1489
1409
|
};
|
|
1490
|
-
diffFilter
|
|
1491
|
-
var patchFilter
|
|
1410
|
+
diffFilter.filterName = 'texts';
|
|
1411
|
+
var patchFilter = function textsPatchFilter(context) {
|
|
1492
1412
|
if (context.nested) {
|
|
1493
1413
|
return;
|
|
1494
1414
|
}
|
|
1495
|
-
|
|
1415
|
+
var nonNestedDelta = context.delta;
|
|
1416
|
+
if (nonNestedDelta[2] !== TEXT_DIFF) {
|
|
1496
1417
|
return;
|
|
1497
1418
|
}
|
|
1498
|
-
|
|
1419
|
+
var textDiffDelta = nonNestedDelta;
|
|
1499
1420
|
// text-diff, use a text-patch algorithm
|
|
1500
|
-
var patch = getDiffMatchPatch(true).patch;
|
|
1501
|
-
context.setResult(patch(context.left,
|
|
1421
|
+
var patch = getDiffMatchPatch(context.options, true).patch;
|
|
1422
|
+
context.setResult(patch(context.left, textDiffDelta[0])).exit();
|
|
1502
1423
|
};
|
|
1503
|
-
patchFilter
|
|
1424
|
+
patchFilter.filterName = 'texts';
|
|
1504
1425
|
var textDeltaReverse = function textDeltaReverse(delta) {
|
|
1505
|
-
var i
|
|
1506
|
-
var l
|
|
1507
|
-
var
|
|
1508
|
-
var
|
|
1509
|
-
var lineTmp = void 0;
|
|
1426
|
+
var i;
|
|
1427
|
+
var l;
|
|
1428
|
+
var line;
|
|
1429
|
+
var lineTmp;
|
|
1510
1430
|
var header = null;
|
|
1511
1431
|
var headerRegex = /^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/;
|
|
1512
|
-
var lineHeader
|
|
1513
|
-
lines = delta.split('\n');
|
|
1432
|
+
var lineHeader;
|
|
1433
|
+
var lines = delta.split('\n');
|
|
1514
1434
|
for (i = 0, l = lines.length; i < l; i++) {
|
|
1515
1435
|
line = lines[i];
|
|
1516
1436
|
var lineStart = line.slice(0, 1);
|
|
1517
1437
|
if (lineStart === '@') {
|
|
1518
1438
|
header = headerRegex.exec(line);
|
|
1519
1439
|
lineHeader = i;
|
|
1520
|
-
|
|
1521
1440
|
// fix header
|
|
1522
1441
|
lines[lineHeader] = '@@ -' + header[3] + ',' + header[4] + ' +' + header[1] + ',' + header[2] + ' @@';
|
|
1523
1442
|
} else if (lineStart === '+') {
|
|
@@ -1534,1167 +1453,64 @@ var textDeltaReverse = function textDeltaReverse(delta) {
|
|
|
1534
1453
|
}
|
|
1535
1454
|
return lines.join('\n');
|
|
1536
1455
|
};
|
|
1537
|
-
var reverseFilter
|
|
1456
|
+
var reverseFilter = function textsReverseFilter(context) {
|
|
1538
1457
|
if (context.nested) {
|
|
1539
1458
|
return;
|
|
1540
1459
|
}
|
|
1541
|
-
|
|
1460
|
+
var nonNestedDelta = context.delta;
|
|
1461
|
+
if (nonNestedDelta[2] !== TEXT_DIFF) {
|
|
1542
1462
|
return;
|
|
1543
1463
|
}
|
|
1544
|
-
|
|
1464
|
+
var textDiffDelta = nonNestedDelta;
|
|
1545
1465
|
// text-diff, use a text-diff algorithm
|
|
1546
|
-
context.setResult([textDeltaReverse(
|
|
1466
|
+
context.setResult([textDeltaReverse(textDiffDelta[0]), 0, TEXT_DIFF]).exit();
|
|
1547
1467
|
};
|
|
1548
|
-
reverseFilter
|
|
1549
|
-
|
|
1468
|
+
reverseFilter.filterName = 'texts';
|
|
1469
|
+
|
|
1470
|
+
var DiffPatcher = /*#__PURE__*/function () {
|
|
1550
1471
|
function DiffPatcher(options) {
|
|
1551
|
-
|
|
1472
|
+
_classCallCheck(this, DiffPatcher);
|
|
1552
1473
|
this.processor = new Processor(options);
|
|
1553
|
-
this.processor.pipe(new Pipe('diff').append(collectChildrenDiffFilter, diffFilter, diffFilter$
|
|
1554
|
-
this.processor.pipe(new Pipe('patch').append(collectChildrenPatchFilter
|
|
1555
|
-
this.processor.pipe(new Pipe('reverse').append(collectChildrenReverseFilter
|
|
1556
|
-
}
|
|
1557
|
-
|
|
1558
|
-
key:
|
|
1559
|
-
value: function options() {
|
|
1560
|
-
|
|
1561
|
-
return (_processor = this.processor).options.apply(_processor, arguments);
|
|
1474
|
+
this.processor.pipe(new Pipe('diff').append(collectChildrenDiffFilter, diffFilter$3, diffFilter$1, diffFilter, objectsDiffFilter, diffFilter$2).shouldHaveResult());
|
|
1475
|
+
this.processor.pipe(new Pipe('patch').append(collectChildrenPatchFilter$1, collectChildrenPatchFilter, patchFilter$3, patchFilter, patchFilter$2, patchFilter$1).shouldHaveResult());
|
|
1476
|
+
this.processor.pipe(new Pipe('reverse').append(collectChildrenReverseFilter$1, collectChildrenReverseFilter, reverseFilter$3, reverseFilter, reverseFilter$2, reverseFilter$1).shouldHaveResult());
|
|
1477
|
+
}
|
|
1478
|
+
return _createClass(DiffPatcher, [{
|
|
1479
|
+
key: "options",
|
|
1480
|
+
value: function options(_options) {
|
|
1481
|
+
return this.processor.options(_options);
|
|
1562
1482
|
}
|
|
1563
1483
|
}, {
|
|
1564
|
-
key:
|
|
1484
|
+
key: "diff",
|
|
1565
1485
|
value: function diff(left, right) {
|
|
1566
1486
|
return this.processor.process(new DiffContext(left, right));
|
|
1567
1487
|
}
|
|
1568
1488
|
}, {
|
|
1569
|
-
key:
|
|
1489
|
+
key: "patch",
|
|
1570
1490
|
value: function patch(left, delta) {
|
|
1571
1491
|
return this.processor.process(new PatchContext(left, delta));
|
|
1572
1492
|
}
|
|
1573
1493
|
}, {
|
|
1574
|
-
key:
|
|
1494
|
+
key: "reverse",
|
|
1575
1495
|
value: function reverse(delta) {
|
|
1576
1496
|
return this.processor.process(new ReverseContext(delta));
|
|
1577
1497
|
}
|
|
1578
1498
|
}, {
|
|
1579
|
-
key:
|
|
1499
|
+
key: "unpatch",
|
|
1580
1500
|
value: function unpatch(right, delta) {
|
|
1581
1501
|
return this.patch(right, this.reverse(delta));
|
|
1582
1502
|
}
|
|
1583
1503
|
}, {
|
|
1584
|
-
key:
|
|
1585
|
-
value: function clone
|
|
1504
|
+
key: "clone",
|
|
1505
|
+
value: function clone(value) {
|
|
1586
1506
|
return clone$1(value);
|
|
1587
1507
|
}
|
|
1588
1508
|
}]);
|
|
1589
|
-
return DiffPatcher;
|
|
1590
1509
|
}();
|
|
1591
|
-
var isArray$3 = typeof Array.isArray === 'function' ? Array.isArray : function (a) {
|
|
1592
|
-
return a instanceof Array;
|
|
1593
|
-
};
|
|
1594
|
-
var getObjectKeys = typeof Object.keys === 'function' ? function (obj) {
|
|
1595
|
-
return Object.keys(obj);
|
|
1596
|
-
} : function (obj) {
|
|
1597
|
-
var names = [];
|
|
1598
|
-
for (var property in obj) {
|
|
1599
|
-
if (Object.prototype.hasOwnProperty.call(obj, property)) {
|
|
1600
|
-
names.push(property);
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
return names;
|
|
1604
|
-
};
|
|
1605
|
-
var trimUnderscore = function trimUnderscore(str) {
|
|
1606
|
-
if (str.substr(0, 1) === '_') {
|
|
1607
|
-
return str.slice(1);
|
|
1608
|
-
}
|
|
1609
|
-
return str;
|
|
1610
|
-
};
|
|
1611
|
-
var arrayKeyToSortNumber = function arrayKeyToSortNumber(key) {
|
|
1612
|
-
if (key === '_t') {
|
|
1613
|
-
return -1;
|
|
1614
|
-
} else {
|
|
1615
|
-
if (key.substr(0, 1) === '_') {
|
|
1616
|
-
return parseInt(key.slice(1), 10);
|
|
1617
|
-
} else {
|
|
1618
|
-
return parseInt(key, 10) + 0.1;
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
};
|
|
1622
|
-
var arrayKeyComparer = function arrayKeyComparer(key1, key2) {
|
|
1623
|
-
return arrayKeyToSortNumber(key1) - arrayKeyToSortNumber(key2);
|
|
1624
|
-
};
|
|
1625
|
-
var BaseFormatter = function () {
|
|
1626
|
-
function BaseFormatter() {
|
|
1627
|
-
classCallCheck(this, BaseFormatter);
|
|
1628
|
-
}
|
|
1629
|
-
createClass(BaseFormatter, [{
|
|
1630
|
-
key: 'format',
|
|
1631
|
-
value: function format(delta, left) {
|
|
1632
|
-
var context = {};
|
|
1633
|
-
this.prepareContext(context);
|
|
1634
|
-
this.recurse(context, delta, left);
|
|
1635
|
-
return this.finalize(context);
|
|
1636
|
-
}
|
|
1637
|
-
}, {
|
|
1638
|
-
key: 'prepareContext',
|
|
1639
|
-
value: function prepareContext(context) {
|
|
1640
|
-
context.buffer = [];
|
|
1641
|
-
context.out = function () {
|
|
1642
|
-
var _buffer;
|
|
1643
|
-
(_buffer = this.buffer).push.apply(_buffer, arguments);
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
}, {
|
|
1647
|
-
key: 'typeFormattterNotFound',
|
|
1648
|
-
value: function typeFormattterNotFound(context, deltaType) {
|
|
1649
|
-
throw new Error('cannot format delta type: ' + deltaType);
|
|
1650
|
-
}
|
|
1651
|
-
}, {
|
|
1652
|
-
key: 'typeFormattterErrorFormatter',
|
|
1653
|
-
value: function typeFormattterErrorFormatter(context, err) {
|
|
1654
|
-
return err.toString();
|
|
1655
|
-
}
|
|
1656
|
-
}, {
|
|
1657
|
-
key: 'finalize',
|
|
1658
|
-
value: function finalize(_ref) {
|
|
1659
|
-
var buffer = _ref.buffer;
|
|
1660
|
-
if (isArray$3(buffer)) {
|
|
1661
|
-
return buffer.join('');
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
}, {
|
|
1665
|
-
key: 'recurse',
|
|
1666
|
-
value: function recurse(context, delta, left, key, leftKey, movedFrom, isLast) {
|
|
1667
|
-
var useMoveOriginHere = delta && movedFrom;
|
|
1668
|
-
var leftValue = useMoveOriginHere ? movedFrom.value : left;
|
|
1669
|
-
if (typeof delta === 'undefined' && typeof key === 'undefined') {
|
|
1670
|
-
return undefined;
|
|
1671
|
-
}
|
|
1672
|
-
var type = this.getDeltaType(delta, movedFrom);
|
|
1673
|
-
var nodeType = type === 'node' ? delta._t === 'a' ? 'array' : 'object' : '';
|
|
1674
|
-
if (typeof key !== 'undefined') {
|
|
1675
|
-
this.nodeBegin(context, key, leftKey, type, nodeType, isLast);
|
|
1676
|
-
} else {
|
|
1677
|
-
this.rootBegin(context, type, nodeType);
|
|
1678
|
-
}
|
|
1679
|
-
var typeFormattter = void 0;
|
|
1680
|
-
try {
|
|
1681
|
-
typeFormattter = this['format_' + type] || this.typeFormattterNotFound(context, type);
|
|
1682
|
-
typeFormattter.call(this, context, delta, leftValue, key, leftKey, movedFrom);
|
|
1683
|
-
} catch (err) {
|
|
1684
|
-
this.typeFormattterErrorFormatter(context, err, delta, leftValue, key, leftKey, movedFrom);
|
|
1685
|
-
if (typeof console !== 'undefined' && console.error) {
|
|
1686
|
-
console.error(err.stack);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
if (typeof key !== 'undefined') {
|
|
1690
|
-
this.nodeEnd(context, key, leftKey, type, nodeType, isLast);
|
|
1691
|
-
} else {
|
|
1692
|
-
this.rootEnd(context, type, nodeType);
|
|
1693
|
-
}
|
|
1694
|
-
}
|
|
1695
|
-
}, {
|
|
1696
|
-
key: 'formatDeltaChildren',
|
|
1697
|
-
value: function formatDeltaChildren(context, delta, left) {
|
|
1698
|
-
var self = this;
|
|
1699
|
-
this.forEachDeltaKey(delta, left, function (key, leftKey, movedFrom, isLast) {
|
|
1700
|
-
self.recurse(context, delta[key], left ? left[leftKey] : undefined, key, leftKey, movedFrom, isLast);
|
|
1701
|
-
});
|
|
1702
|
-
}
|
|
1703
|
-
}, {
|
|
1704
|
-
key: 'forEachDeltaKey',
|
|
1705
|
-
value: function forEachDeltaKey(delta, left, fn) {
|
|
1706
|
-
var keys = getObjectKeys(delta);
|
|
1707
|
-
var arrayKeys = delta._t === 'a';
|
|
1708
|
-
var moveDestinations = {};
|
|
1709
|
-
var name = void 0;
|
|
1710
|
-
if (typeof left !== 'undefined') {
|
|
1711
|
-
for (name in left) {
|
|
1712
|
-
if (Object.prototype.hasOwnProperty.call(left, name)) {
|
|
1713
|
-
if (typeof delta[name] === 'undefined' && (!arrayKeys || typeof delta['_' + name] === 'undefined')) {
|
|
1714
|
-
keys.push(name);
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
// look for move destinations
|
|
1720
|
-
for (name in delta) {
|
|
1721
|
-
if (Object.prototype.hasOwnProperty.call(delta, name)) {
|
|
1722
|
-
var value = delta[name];
|
|
1723
|
-
if (isArray$3(value) && value[2] === 3) {
|
|
1724
|
-
moveDestinations[value[1].toString()] = {
|
|
1725
|
-
key: name,
|
|
1726
|
-
value: left && left[parseInt(name.substr(1))]
|
|
1727
|
-
};
|
|
1728
|
-
if (this.includeMoveDestinations !== false) {
|
|
1729
|
-
if (typeof left === 'undefined' && typeof delta[value[1]] === 'undefined') {
|
|
1730
|
-
keys.push(value[1].toString());
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
if (arrayKeys) {
|
|
1737
|
-
keys.sort(arrayKeyComparer);
|
|
1738
|
-
} else {
|
|
1739
|
-
keys.sort();
|
|
1740
|
-
}
|
|
1741
|
-
for (var index = 0, length = keys.length; index < length; index++) {
|
|
1742
|
-
var key = keys[index];
|
|
1743
|
-
if (arrayKeys && key === '_t') {
|
|
1744
|
-
continue;
|
|
1745
|
-
}
|
|
1746
|
-
var leftKey = arrayKeys ? typeof key === 'number' ? key : parseInt(trimUnderscore(key), 10) : key;
|
|
1747
|
-
var isLast = index === length - 1;
|
|
1748
|
-
fn(key, leftKey, moveDestinations[leftKey], isLast);
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
}, {
|
|
1752
|
-
key: 'getDeltaType',
|
|
1753
|
-
value: function getDeltaType(delta, movedFrom) {
|
|
1754
|
-
if (typeof delta === 'undefined') {
|
|
1755
|
-
if (typeof movedFrom !== 'undefined') {
|
|
1756
|
-
return 'movedestination';
|
|
1757
|
-
}
|
|
1758
|
-
return 'unchanged';
|
|
1759
|
-
}
|
|
1760
|
-
if (isArray$3(delta)) {
|
|
1761
|
-
if (delta.length === 1) {
|
|
1762
|
-
return 'added';
|
|
1763
|
-
}
|
|
1764
|
-
if (delta.length === 2) {
|
|
1765
|
-
return 'modified';
|
|
1766
|
-
}
|
|
1767
|
-
if (delta.length === 3 && delta[2] === 0) {
|
|
1768
|
-
return 'deleted';
|
|
1769
|
-
}
|
|
1770
|
-
if (delta.length === 3 && delta[2] === 2) {
|
|
1771
|
-
return 'textdiff';
|
|
1772
|
-
}
|
|
1773
|
-
if (delta.length === 3 && delta[2] === 3) {
|
|
1774
|
-
return 'moved';
|
|
1775
|
-
}
|
|
1776
|
-
} else if ((typeof delta === 'undefined' ? 'undefined' : _typeof(delta)) === 'object') {
|
|
1777
|
-
return 'node';
|
|
1778
|
-
}
|
|
1779
|
-
return 'unknown';
|
|
1780
|
-
}
|
|
1781
|
-
}, {
|
|
1782
|
-
key: 'parseTextDiff',
|
|
1783
|
-
value: function parseTextDiff(value) {
|
|
1784
|
-
var output = [];
|
|
1785
|
-
var lines = value.split('\n@@ ');
|
|
1786
|
-
for (var i = 0, l = lines.length; i < l; i++) {
|
|
1787
|
-
var line = lines[i];
|
|
1788
|
-
var lineOutput = {
|
|
1789
|
-
pieces: []
|
|
1790
|
-
};
|
|
1791
|
-
var location = /^(?:@@ )?[-+]?(\d+),(\d+)/.exec(line).slice(1);
|
|
1792
|
-
lineOutput.location = {
|
|
1793
|
-
line: location[0],
|
|
1794
|
-
chr: location[1]
|
|
1795
|
-
};
|
|
1796
|
-
var pieces = line.split('\n').slice(1);
|
|
1797
|
-
for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
|
|
1798
|
-
var piece = pieces[pieceIndex];
|
|
1799
|
-
if (!piece.length) {
|
|
1800
|
-
continue;
|
|
1801
|
-
}
|
|
1802
|
-
var pieceOutput = {
|
|
1803
|
-
type: 'context'
|
|
1804
|
-
};
|
|
1805
|
-
if (piece.substr(0, 1) === '+') {
|
|
1806
|
-
pieceOutput.type = 'added';
|
|
1807
|
-
} else if (piece.substr(0, 1) === '-') {
|
|
1808
|
-
pieceOutput.type = 'deleted';
|
|
1809
|
-
}
|
|
1810
|
-
pieceOutput.text = piece.slice(1);
|
|
1811
|
-
lineOutput.pieces.push(pieceOutput);
|
|
1812
|
-
}
|
|
1813
|
-
output.push(lineOutput);
|
|
1814
|
-
}
|
|
1815
|
-
return output;
|
|
1816
|
-
}
|
|
1817
|
-
}]);
|
|
1818
|
-
return BaseFormatter;
|
|
1819
|
-
}();
|
|
1820
|
-
var base = Object.freeze({
|
|
1821
|
-
default: BaseFormatter
|
|
1822
|
-
});
|
|
1823
|
-
var HtmlFormatter = function (_BaseFormatter) {
|
|
1824
|
-
inherits(HtmlFormatter, _BaseFormatter);
|
|
1825
|
-
function HtmlFormatter() {
|
|
1826
|
-
classCallCheck(this, HtmlFormatter);
|
|
1827
|
-
return possibleConstructorReturn(this, (HtmlFormatter.__proto__ || Object.getPrototypeOf(HtmlFormatter)).apply(this, arguments));
|
|
1828
|
-
}
|
|
1829
|
-
createClass(HtmlFormatter, [{
|
|
1830
|
-
key: 'typeFormattterErrorFormatter',
|
|
1831
|
-
value: function typeFormattterErrorFormatter(context, err) {
|
|
1832
|
-
context.out('<pre class="jsondiffpatch-error">' + err + '</pre>');
|
|
1833
|
-
}
|
|
1834
|
-
}, {
|
|
1835
|
-
key: 'formatValue',
|
|
1836
|
-
value: function formatValue(context, value) {
|
|
1837
|
-
context.out('<pre>' + htmlEscape(JSON.stringify(value, null, 2)) + '</pre>');
|
|
1838
|
-
}
|
|
1839
|
-
}, {
|
|
1840
|
-
key: 'formatTextDiffString',
|
|
1841
|
-
value: function formatTextDiffString(context, value) {
|
|
1842
|
-
var lines = this.parseTextDiff(value);
|
|
1843
|
-
context.out('<ul class="jsondiffpatch-textdiff">');
|
|
1844
|
-
for (var i = 0, l = lines.length; i < l; i++) {
|
|
1845
|
-
var line = lines[i];
|
|
1846
|
-
context.out('<li><div class="jsondiffpatch-textdiff-location">' + ('<span class="jsondiffpatch-textdiff-line-number">' + line.location.line + '</span><span class="jsondiffpatch-textdiff-char">' + line.location.chr + '</span></div><div class="jsondiffpatch-textdiff-line">'));
|
|
1847
|
-
var pieces = line.pieces;
|
|
1848
|
-
for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
|
|
1849
|
-
/* global decodeURI */
|
|
1850
|
-
var piece = pieces[pieceIndex];
|
|
1851
|
-
context.out('<span class="jsondiffpatch-textdiff-' + piece.type + '">' + htmlEscape(decodeURI(piece.text)) + '</span>');
|
|
1852
|
-
}
|
|
1853
|
-
context.out('</div></li>');
|
|
1854
|
-
}
|
|
1855
|
-
context.out('</ul>');
|
|
1856
|
-
}
|
|
1857
|
-
}, {
|
|
1858
|
-
key: 'rootBegin',
|
|
1859
|
-
value: function rootBegin(context, type, nodeType) {
|
|
1860
|
-
var nodeClass = 'jsondiffpatch-' + type + (nodeType ? ' jsondiffpatch-child-node-type-' + nodeType : '');
|
|
1861
|
-
context.out('<div class="jsondiffpatch-delta ' + nodeClass + '">');
|
|
1862
|
-
}
|
|
1863
|
-
}, {
|
|
1864
|
-
key: 'rootEnd',
|
|
1865
|
-
value: function rootEnd(context) {
|
|
1866
|
-
context.out('</div>' + (context.hasArrows ? '<script type="text/javascript">setTimeout(' + (adjustArrows.toString() + ',10);</script>') : ''));
|
|
1867
|
-
}
|
|
1868
|
-
}, {
|
|
1869
|
-
key: 'nodeBegin',
|
|
1870
|
-
value: function nodeBegin(context, key, leftKey, type, nodeType) {
|
|
1871
|
-
var nodeClass = 'jsondiffpatch-' + type + (nodeType ? ' jsondiffpatch-child-node-type-' + nodeType : '');
|
|
1872
|
-
context.out('<li class="' + nodeClass + '" data-key="' + leftKey + '">' + ('<div class="jsondiffpatch-property-name">' + leftKey + '</div>'));
|
|
1873
|
-
}
|
|
1874
|
-
}, {
|
|
1875
|
-
key: 'nodeEnd',
|
|
1876
|
-
value: function nodeEnd(context) {
|
|
1877
|
-
context.out('</li>');
|
|
1878
|
-
}
|
|
1879
|
-
|
|
1880
|
-
/* jshint camelcase: false */
|
|
1881
|
-
/* eslint-disable camelcase */
|
|
1882
|
-
}, {
|
|
1883
|
-
key: 'format_unchanged',
|
|
1884
|
-
value: function format_unchanged(context, delta, left) {
|
|
1885
|
-
if (typeof left === 'undefined') {
|
|
1886
|
-
return;
|
|
1887
|
-
}
|
|
1888
|
-
context.out('<div class="jsondiffpatch-value">');
|
|
1889
|
-
this.formatValue(context, left);
|
|
1890
|
-
context.out('</div>');
|
|
1891
|
-
}
|
|
1892
|
-
}, {
|
|
1893
|
-
key: 'format_movedestination',
|
|
1894
|
-
value: function format_movedestination(context, delta, left) {
|
|
1895
|
-
if (typeof left === 'undefined') {
|
|
1896
|
-
return;
|
|
1897
|
-
}
|
|
1898
|
-
context.out('<div class="jsondiffpatch-value">');
|
|
1899
|
-
this.formatValue(context, left);
|
|
1900
|
-
context.out('</div>');
|
|
1901
|
-
}
|
|
1902
|
-
}, {
|
|
1903
|
-
key: 'format_node',
|
|
1904
|
-
value: function format_node(context, delta, left) {
|
|
1905
|
-
// recurse
|
|
1906
|
-
var nodeType = delta._t === 'a' ? 'array' : 'object';
|
|
1907
|
-
context.out('<ul class="jsondiffpatch-node jsondiffpatch-node-type-' + nodeType + '">');
|
|
1908
|
-
this.formatDeltaChildren(context, delta, left);
|
|
1909
|
-
context.out('</ul>');
|
|
1910
|
-
}
|
|
1911
|
-
}, {
|
|
1912
|
-
key: 'format_added',
|
|
1913
|
-
value: function format_added(context, delta) {
|
|
1914
|
-
context.out('<div class="jsondiffpatch-value">');
|
|
1915
|
-
this.formatValue(context, delta[0]);
|
|
1916
|
-
context.out('</div>');
|
|
1917
|
-
}
|
|
1918
|
-
}, {
|
|
1919
|
-
key: 'format_modified',
|
|
1920
|
-
value: function format_modified(context, delta) {
|
|
1921
|
-
context.out('<div class="jsondiffpatch-value jsondiffpatch-left-value">');
|
|
1922
|
-
this.formatValue(context, delta[0]);
|
|
1923
|
-
context.out('</div>' + '<div class="jsondiffpatch-value jsondiffpatch-right-value">');
|
|
1924
|
-
this.formatValue(context, delta[1]);
|
|
1925
|
-
context.out('</div>');
|
|
1926
|
-
}
|
|
1927
|
-
}, {
|
|
1928
|
-
key: 'format_deleted',
|
|
1929
|
-
value: function format_deleted(context, delta) {
|
|
1930
|
-
context.out('<div class="jsondiffpatch-value">');
|
|
1931
|
-
this.formatValue(context, delta[0]);
|
|
1932
|
-
context.out('</div>');
|
|
1933
|
-
}
|
|
1934
|
-
}, {
|
|
1935
|
-
key: 'format_moved',
|
|
1936
|
-
value: function format_moved(context, delta) {
|
|
1937
|
-
context.out('<div class="jsondiffpatch-value">');
|
|
1938
|
-
this.formatValue(context, delta[0]);
|
|
1939
|
-
context.out('</div><div class="jsondiffpatch-moved-destination">' + delta[1] + '</div>');
|
|
1940
|
-
|
|
1941
|
-
// draw an SVG arrow from here to move destination
|
|
1942
|
-
context.out( /* jshint multistr: true */
|
|
1943
|
-
'<div class="jsondiffpatch-arrow" ' + 'style="position: relative; left: -34px;">\n <svg width="30" height="60" ' + 'style="position: absolute; display: none;">\n <defs>\n <marker id="markerArrow" markerWidth="8" markerHeight="8"\n refx="2" refy="4"\n orient="auto" markerUnits="userSpaceOnUse">\n <path d="M1,1 L1,7 L7,4 L1,1" style="fill: #339;" />\n </marker>\n </defs>\n <path d="M30,0 Q-10,25 26,50"\n style="stroke: #88f; stroke-width: 2px; fill: none; ' + 'stroke-opacity: 0.5; marker-end: url(#markerArrow);"\n ></path>\n </svg>\n </div>');
|
|
1944
|
-
context.hasArrows = true;
|
|
1945
|
-
}
|
|
1946
|
-
}, {
|
|
1947
|
-
key: 'format_textdiff',
|
|
1948
|
-
value: function format_textdiff(context, delta) {
|
|
1949
|
-
context.out('<div class="jsondiffpatch-value">');
|
|
1950
|
-
this.formatTextDiffString(context, delta[0]);
|
|
1951
|
-
context.out('</div>');
|
|
1952
|
-
}
|
|
1953
|
-
}]);
|
|
1954
|
-
return HtmlFormatter;
|
|
1955
|
-
}(BaseFormatter);
|
|
1956
|
-
function htmlEscape(text) {
|
|
1957
|
-
var html = text;
|
|
1958
|
-
var replacements = [[/&/g, '&'], [/</g, '<'], [/>/g, '>'], [/'/g, '''], [/"/g, '"']];
|
|
1959
|
-
for (var i = 0; i < replacements.length; i++) {
|
|
1960
|
-
html = html.replace(replacements[i][0], replacements[i][1]);
|
|
1961
|
-
}
|
|
1962
|
-
return html;
|
|
1963
|
-
}
|
|
1964
|
-
var adjustArrows = function jsondiffpatchHtmlFormatterAdjustArrows(nodeArg) {
|
|
1965
|
-
var node = nodeArg || document;
|
|
1966
|
-
var getElementText = function getElementText(_ref) {
|
|
1967
|
-
var textContent = _ref.textContent,
|
|
1968
|
-
innerText = _ref.innerText;
|
|
1969
|
-
return textContent || innerText;
|
|
1970
|
-
};
|
|
1971
|
-
var eachByQuery = function eachByQuery(el, query, fn) {
|
|
1972
|
-
var elems = el.querySelectorAll(query);
|
|
1973
|
-
for (var i = 0, l = elems.length; i < l; i++) {
|
|
1974
|
-
fn(elems[i]);
|
|
1975
|
-
}
|
|
1976
|
-
};
|
|
1977
|
-
var eachChildren = function eachChildren(_ref2, fn) {
|
|
1978
|
-
var children = _ref2.children;
|
|
1979
|
-
for (var i = 0, l = children.length; i < l; i++) {
|
|
1980
|
-
fn(children[i], i);
|
|
1981
|
-
}
|
|
1982
|
-
};
|
|
1983
|
-
eachByQuery(node, '.jsondiffpatch-arrow', function (_ref3) {
|
|
1984
|
-
var parentNode = _ref3.parentNode,
|
|
1985
|
-
children = _ref3.children,
|
|
1986
|
-
style = _ref3.style;
|
|
1987
|
-
var arrowParent = parentNode;
|
|
1988
|
-
var svg = children[0];
|
|
1989
|
-
var path = svg.children[1];
|
|
1990
|
-
svg.style.display = 'none';
|
|
1991
|
-
var destination = getElementText(arrowParent.querySelector('.jsondiffpatch-moved-destination'));
|
|
1992
|
-
var container = arrowParent.parentNode;
|
|
1993
|
-
var destinationElem = void 0;
|
|
1994
|
-
eachChildren(container, function (child) {
|
|
1995
|
-
if (child.getAttribute('data-key') === destination) {
|
|
1996
|
-
destinationElem = child;
|
|
1997
|
-
}
|
|
1998
|
-
});
|
|
1999
|
-
if (!destinationElem) {
|
|
2000
|
-
return;
|
|
2001
|
-
}
|
|
2002
|
-
try {
|
|
2003
|
-
var distance = destinationElem.offsetTop - arrowParent.offsetTop;
|
|
2004
|
-
svg.setAttribute('height', Math.abs(distance) + 6);
|
|
2005
|
-
style.top = -8 + (distance > 0 ? 0 : distance) + 'px';
|
|
2006
|
-
var curve = distance > 0 ? 'M30,0 Q-10,' + Math.round(distance / 2) + ' 26,' + (distance - 4) : 'M30,' + -distance + ' Q-10,' + Math.round(-distance / 2) + ' 26,4';
|
|
2007
|
-
path.setAttribute('d', curve);
|
|
2008
|
-
svg.style.display = '';
|
|
2009
|
-
} catch (err) {}
|
|
2010
|
-
});
|
|
2011
|
-
};
|
|
2012
|
-
|
|
2013
|
-
/* jshint camelcase: true */
|
|
2014
|
-
/* eslint-enable camelcase */
|
|
2015
|
-
|
|
2016
|
-
var showUnchanged = function showUnchanged(show, node, delay) {
|
|
2017
|
-
var el = node || document.body;
|
|
2018
|
-
var prefix = 'jsondiffpatch-unchanged-';
|
|
2019
|
-
var classes = {
|
|
2020
|
-
showing: prefix + 'showing',
|
|
2021
|
-
hiding: prefix + 'hiding',
|
|
2022
|
-
visible: prefix + 'visible',
|
|
2023
|
-
hidden: prefix + 'hidden'
|
|
2024
|
-
};
|
|
2025
|
-
var list = el.classList;
|
|
2026
|
-
if (!list) {
|
|
2027
|
-
return;
|
|
2028
|
-
}
|
|
2029
|
-
if (!delay) {
|
|
2030
|
-
list.remove(classes.showing);
|
|
2031
|
-
list.remove(classes.hiding);
|
|
2032
|
-
list.remove(classes.visible);
|
|
2033
|
-
list.remove(classes.hidden);
|
|
2034
|
-
if (show === false) {
|
|
2035
|
-
list.add(classes.hidden);
|
|
2036
|
-
}
|
|
2037
|
-
return;
|
|
2038
|
-
}
|
|
2039
|
-
if (show === false) {
|
|
2040
|
-
list.remove(classes.showing);
|
|
2041
|
-
list.add(classes.visible);
|
|
2042
|
-
setTimeout(function () {
|
|
2043
|
-
list.add(classes.hiding);
|
|
2044
|
-
}, 10);
|
|
2045
|
-
} else {
|
|
2046
|
-
list.remove(classes.hiding);
|
|
2047
|
-
list.add(classes.showing);
|
|
2048
|
-
list.remove(classes.hidden);
|
|
2049
|
-
}
|
|
2050
|
-
var intervalId = setInterval(function () {
|
|
2051
|
-
adjustArrows(el);
|
|
2052
|
-
}, 100);
|
|
2053
|
-
setTimeout(function () {
|
|
2054
|
-
list.remove(classes.showing);
|
|
2055
|
-
list.remove(classes.hiding);
|
|
2056
|
-
if (show === false) {
|
|
2057
|
-
list.add(classes.hidden);
|
|
2058
|
-
list.remove(classes.visible);
|
|
2059
|
-
} else {
|
|
2060
|
-
list.add(classes.visible);
|
|
2061
|
-
list.remove(classes.hidden);
|
|
2062
|
-
}
|
|
2063
|
-
setTimeout(function () {
|
|
2064
|
-
list.remove(classes.visible);
|
|
2065
|
-
clearInterval(intervalId);
|
|
2066
|
-
}, delay + 400);
|
|
2067
|
-
}, delay);
|
|
2068
|
-
};
|
|
2069
|
-
var hideUnchanged = function hideUnchanged(node, delay) {
|
|
2070
|
-
return showUnchanged(false, node, delay);
|
|
2071
|
-
};
|
|
2072
|
-
var defaultInstance = void 0;
|
|
2073
|
-
function format(delta, left) {
|
|
2074
|
-
if (!defaultInstance) {
|
|
2075
|
-
defaultInstance = new HtmlFormatter();
|
|
2076
|
-
}
|
|
2077
|
-
return defaultInstance.format(delta, left);
|
|
2078
|
-
}
|
|
2079
|
-
var html = Object.freeze({
|
|
2080
|
-
showUnchanged: showUnchanged,
|
|
2081
|
-
hideUnchanged: hideUnchanged,
|
|
2082
|
-
default: HtmlFormatter,
|
|
2083
|
-
format: format
|
|
2084
|
-
});
|
|
2085
|
-
var AnnotatedFormatter = function (_BaseFormatter) {
|
|
2086
|
-
inherits(AnnotatedFormatter, _BaseFormatter);
|
|
2087
|
-
function AnnotatedFormatter() {
|
|
2088
|
-
classCallCheck(this, AnnotatedFormatter);
|
|
2089
|
-
var _this = possibleConstructorReturn(this, (AnnotatedFormatter.__proto__ || Object.getPrototypeOf(AnnotatedFormatter)).call(this));
|
|
2090
|
-
_this.includeMoveDestinations = false;
|
|
2091
|
-
return _this;
|
|
2092
|
-
}
|
|
2093
|
-
createClass(AnnotatedFormatter, [{
|
|
2094
|
-
key: 'prepareContext',
|
|
2095
|
-
value: function prepareContext(context) {
|
|
2096
|
-
get(AnnotatedFormatter.prototype.__proto__ || Object.getPrototypeOf(AnnotatedFormatter.prototype), 'prepareContext', this).call(this, context);
|
|
2097
|
-
context.indent = function (levels) {
|
|
2098
|
-
this.indentLevel = (this.indentLevel || 0) + (typeof levels === 'undefined' ? 1 : levels);
|
|
2099
|
-
this.indentPad = new Array(this.indentLevel + 1).join(' ');
|
|
2100
|
-
};
|
|
2101
|
-
context.row = function (json, htmlNote) {
|
|
2102
|
-
context.out('<tr><td style="white-space: nowrap;">' + '<pre class="jsondiffpatch-annotated-indent"' + ' style="display: inline-block">');
|
|
2103
|
-
context.out(context.indentPad);
|
|
2104
|
-
context.out('</pre><pre style="display: inline-block">');
|
|
2105
|
-
context.out(json);
|
|
2106
|
-
context.out('</pre></td><td class="jsondiffpatch-delta-note"><div>');
|
|
2107
|
-
context.out(htmlNote);
|
|
2108
|
-
context.out('</div></td></tr>');
|
|
2109
|
-
};
|
|
2110
|
-
}
|
|
2111
|
-
}, {
|
|
2112
|
-
key: 'typeFormattterErrorFormatter',
|
|
2113
|
-
value: function typeFormattterErrorFormatter(context, err) {
|
|
2114
|
-
context.row('', '<pre class="jsondiffpatch-error">' + err + '</pre>');
|
|
2115
|
-
}
|
|
2116
|
-
}, {
|
|
2117
|
-
key: 'formatTextDiffString',
|
|
2118
|
-
value: function formatTextDiffString(context, value) {
|
|
2119
|
-
var lines = this.parseTextDiff(value);
|
|
2120
|
-
context.out('<ul class="jsondiffpatch-textdiff">');
|
|
2121
|
-
for (var i = 0, l = lines.length; i < l; i++) {
|
|
2122
|
-
var line = lines[i];
|
|
2123
|
-
context.out('<li><div class="jsondiffpatch-textdiff-location">' + ('<span class="jsondiffpatch-textdiff-line-number">' + line.location.line + '</span><span class="jsondiffpatch-textdiff-char">' + line.location.chr + '</span></div><div class="jsondiffpatch-textdiff-line">'));
|
|
2124
|
-
var pieces = line.pieces;
|
|
2125
|
-
for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
|
|
2126
|
-
var piece = pieces[pieceIndex];
|
|
2127
|
-
context.out('<span class="jsondiffpatch-textdiff-' + piece.type + '">' + piece.text + '</span>');
|
|
2128
|
-
}
|
|
2129
|
-
context.out('</div></li>');
|
|
2130
|
-
}
|
|
2131
|
-
context.out('</ul>');
|
|
2132
|
-
}
|
|
2133
|
-
}, {
|
|
2134
|
-
key: 'rootBegin',
|
|
2135
|
-
value: function rootBegin(context, type, nodeType) {
|
|
2136
|
-
context.out('<table class="jsondiffpatch-annotated-delta">');
|
|
2137
|
-
if (type === 'node') {
|
|
2138
|
-
context.row('{');
|
|
2139
|
-
context.indent();
|
|
2140
|
-
}
|
|
2141
|
-
if (nodeType === 'array') {
|
|
2142
|
-
context.row('"_t": "a",', 'Array delta (member names indicate array indices)');
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
}, {
|
|
2146
|
-
key: 'rootEnd',
|
|
2147
|
-
value: function rootEnd(context, type) {
|
|
2148
|
-
if (type === 'node') {
|
|
2149
|
-
context.indent(-1);
|
|
2150
|
-
context.row('}');
|
|
2151
|
-
}
|
|
2152
|
-
context.out('</table>');
|
|
2153
|
-
}
|
|
2154
|
-
}, {
|
|
2155
|
-
key: 'nodeBegin',
|
|
2156
|
-
value: function nodeBegin(context, key, leftKey, type, nodeType) {
|
|
2157
|
-
context.row('"' + key + '": {');
|
|
2158
|
-
if (type === 'node') {
|
|
2159
|
-
context.indent();
|
|
2160
|
-
}
|
|
2161
|
-
if (nodeType === 'array') {
|
|
2162
|
-
context.row('"_t": "a",', 'Array delta (member names indicate array indices)');
|
|
2163
|
-
}
|
|
2164
|
-
}
|
|
2165
|
-
}, {
|
|
2166
|
-
key: 'nodeEnd',
|
|
2167
|
-
value: function nodeEnd(context, key, leftKey, type, nodeType, isLast) {
|
|
2168
|
-
if (type === 'node') {
|
|
2169
|
-
context.indent(-1);
|
|
2170
|
-
}
|
|
2171
|
-
context.row('}' + (isLast ? '' : ','));
|
|
2172
|
-
}
|
|
2173
|
-
|
|
2174
|
-
/* jshint camelcase: false */
|
|
2175
|
-
|
|
2176
|
-
/* eslint-disable camelcase */
|
|
2177
|
-
}, {
|
|
2178
|
-
key: 'format_unchanged',
|
|
2179
|
-
value: function format_unchanged() {}
|
|
2180
|
-
}, {
|
|
2181
|
-
key: 'format_movedestination',
|
|
2182
|
-
value: function format_movedestination() {}
|
|
2183
|
-
}, {
|
|
2184
|
-
key: 'format_node',
|
|
2185
|
-
value: function format_node(context, delta, left) {
|
|
2186
|
-
// recurse
|
|
2187
|
-
this.formatDeltaChildren(context, delta, left);
|
|
2188
|
-
}
|
|
2189
|
-
}]);
|
|
2190
|
-
return AnnotatedFormatter;
|
|
2191
|
-
}(BaseFormatter);
|
|
2192
|
-
|
|
2193
|
-
/* eslint-enable camelcase */
|
|
2194
|
-
|
|
2195
|
-
var wrapPropertyName = function wrapPropertyName(name) {
|
|
2196
|
-
return '<pre style="display:inline-block">"' + name + '"</pre>';
|
|
2197
|
-
};
|
|
2198
|
-
var deltaAnnotations = {
|
|
2199
|
-
added: function added(delta, left, key, leftKey) {
|
|
2200
|
-
var formatLegend = ' <pre>([newValue])</pre>';
|
|
2201
|
-
if (typeof leftKey === 'undefined') {
|
|
2202
|
-
return 'new value' + formatLegend;
|
|
2203
|
-
}
|
|
2204
|
-
if (typeof leftKey === 'number') {
|
|
2205
|
-
return 'insert at index ' + leftKey + formatLegend;
|
|
2206
|
-
}
|
|
2207
|
-
return 'add property ' + wrapPropertyName(leftKey) + formatLegend;
|
|
2208
|
-
},
|
|
2209
|
-
modified: function modified(delta, left, key, leftKey) {
|
|
2210
|
-
var formatLegend = ' <pre>([previousValue, newValue])</pre>';
|
|
2211
|
-
if (typeof leftKey === 'undefined') {
|
|
2212
|
-
return 'modify value' + formatLegend;
|
|
2213
|
-
}
|
|
2214
|
-
if (typeof leftKey === 'number') {
|
|
2215
|
-
return 'modify at index ' + leftKey + formatLegend;
|
|
2216
|
-
}
|
|
2217
|
-
return 'modify property ' + wrapPropertyName(leftKey) + formatLegend;
|
|
2218
|
-
},
|
|
2219
|
-
deleted: function deleted(delta, left, key, leftKey) {
|
|
2220
|
-
var formatLegend = ' <pre>([previousValue, 0, 0])</pre>';
|
|
2221
|
-
if (typeof leftKey === 'undefined') {
|
|
2222
|
-
return 'delete value' + formatLegend;
|
|
2223
|
-
}
|
|
2224
|
-
if (typeof leftKey === 'number') {
|
|
2225
|
-
return 'remove index ' + leftKey + formatLegend;
|
|
2226
|
-
}
|
|
2227
|
-
return 'delete property ' + wrapPropertyName(leftKey) + formatLegend;
|
|
2228
|
-
},
|
|
2229
|
-
moved: function moved(delta, left, key, leftKey) {
|
|
2230
|
-
return 'move from <span title="(position to remove at original state)">' + ('index ' + leftKey + '</span> to <span title="(position to insert at final') + (' state)">index ' + delta[1] + '</span>');
|
|
2231
|
-
},
|
|
2232
|
-
textdiff: function textdiff(delta, left, key, leftKey) {
|
|
2233
|
-
var location = typeof leftKey === 'undefined' ? '' : typeof leftKey === 'number' ? ' at index ' + leftKey : ' at property ' + wrapPropertyName(leftKey);
|
|
2234
|
-
return 'text diff' + location + ', format is <a href="https://code.google.com/' + 'p/google-diff-match-patch/wiki/Unidiff">a variation of Unidiff</a>';
|
|
2235
|
-
}
|
|
2236
|
-
};
|
|
2237
|
-
var formatAnyChange = function formatAnyChange(context, delta) {
|
|
2238
|
-
var deltaType = this.getDeltaType(delta);
|
|
2239
|
-
var annotator = deltaAnnotations[deltaType];
|
|
2240
|
-
var htmlNote = annotator && annotator.apply(annotator, Array.prototype.slice.call(arguments, 1));
|
|
2241
|
-
var json = JSON.stringify(delta, null, 2);
|
|
2242
|
-
if (deltaType === 'textdiff') {
|
|
2243
|
-
// split text diffs lines
|
|
2244
|
-
json = json.split('\\n').join('\\n"+\n "');
|
|
2245
|
-
}
|
|
2246
|
-
context.indent();
|
|
2247
|
-
context.row(json, htmlNote);
|
|
2248
|
-
context.indent(-1);
|
|
2249
|
-
};
|
|
2250
|
-
|
|
2251
|
-
/* eslint-disable camelcase */
|
|
2252
|
-
AnnotatedFormatter.prototype.format_added = formatAnyChange;
|
|
2253
|
-
AnnotatedFormatter.prototype.format_modified = formatAnyChange;
|
|
2254
|
-
AnnotatedFormatter.prototype.format_deleted = formatAnyChange;
|
|
2255
|
-
AnnotatedFormatter.prototype.format_moved = formatAnyChange;
|
|
2256
|
-
AnnotatedFormatter.prototype.format_textdiff = formatAnyChange;
|
|
2257
|
-
var defaultInstance$1 = void 0;
|
|
2258
|
-
function format$1(delta, left) {
|
|
2259
|
-
if (!defaultInstance$1) {
|
|
2260
|
-
defaultInstance$1 = new AnnotatedFormatter();
|
|
2261
|
-
}
|
|
2262
|
-
return defaultInstance$1.format(delta, left);
|
|
2263
|
-
}
|
|
2264
|
-
var annotated = Object.freeze({
|
|
2265
|
-
default: AnnotatedFormatter,
|
|
2266
|
-
format: format$1
|
|
2267
|
-
});
|
|
2268
|
-
var OPERATIONS = {
|
|
2269
|
-
add: 'add',
|
|
2270
|
-
remove: 'remove',
|
|
2271
|
-
replace: 'replace',
|
|
2272
|
-
move: 'move'
|
|
2273
|
-
};
|
|
2274
|
-
var JSONFormatter = function (_BaseFormatter) {
|
|
2275
|
-
inherits(JSONFormatter, _BaseFormatter);
|
|
2276
|
-
function JSONFormatter() {
|
|
2277
|
-
classCallCheck(this, JSONFormatter);
|
|
2278
|
-
var _this = possibleConstructorReturn(this, (JSONFormatter.__proto__ || Object.getPrototypeOf(JSONFormatter)).call(this));
|
|
2279
|
-
_this.includeMoveDestinations = true;
|
|
2280
|
-
return _this;
|
|
2281
|
-
}
|
|
2282
|
-
createClass(JSONFormatter, [{
|
|
2283
|
-
key: 'prepareContext',
|
|
2284
|
-
value: function prepareContext(context) {
|
|
2285
|
-
get(JSONFormatter.prototype.__proto__ || Object.getPrototypeOf(JSONFormatter.prototype), 'prepareContext', this).call(this, context);
|
|
2286
|
-
context.result = [];
|
|
2287
|
-
context.path = [];
|
|
2288
|
-
context.pushCurrentOp = function (obj) {
|
|
2289
|
-
var op = obj.op,
|
|
2290
|
-
value = obj.value;
|
|
2291
|
-
var val = {
|
|
2292
|
-
op: op,
|
|
2293
|
-
path: this.currentPath()
|
|
2294
|
-
};
|
|
2295
|
-
if (typeof value !== 'undefined') {
|
|
2296
|
-
val.value = value;
|
|
2297
|
-
}
|
|
2298
|
-
this.result.push(val);
|
|
2299
|
-
};
|
|
2300
|
-
context.pushMoveOp = function (to) {
|
|
2301
|
-
var from = this.currentPath();
|
|
2302
|
-
this.result.push({
|
|
2303
|
-
op: OPERATIONS.move,
|
|
2304
|
-
from: from,
|
|
2305
|
-
path: this.toPath(to)
|
|
2306
|
-
});
|
|
2307
|
-
};
|
|
2308
|
-
context.currentPath = function () {
|
|
2309
|
-
return '/' + this.path.join('/');
|
|
2310
|
-
};
|
|
2311
|
-
context.toPath = function (toPath) {
|
|
2312
|
-
var to = this.path.slice();
|
|
2313
|
-
to[to.length - 1] = toPath;
|
|
2314
|
-
return '/' + to.join('/');
|
|
2315
|
-
};
|
|
2316
|
-
}
|
|
2317
|
-
}, {
|
|
2318
|
-
key: 'typeFormattterErrorFormatter',
|
|
2319
|
-
value: function typeFormattterErrorFormatter(context, err) {
|
|
2320
|
-
context.out('[ERROR] ' + err);
|
|
2321
|
-
}
|
|
2322
|
-
}, {
|
|
2323
|
-
key: 'rootBegin',
|
|
2324
|
-
value: function rootBegin() {}
|
|
2325
|
-
}, {
|
|
2326
|
-
key: 'rootEnd',
|
|
2327
|
-
value: function rootEnd() {}
|
|
2328
|
-
}, {
|
|
2329
|
-
key: 'nodeBegin',
|
|
2330
|
-
value: function nodeBegin(_ref, key, leftKey) {
|
|
2331
|
-
var path = _ref.path;
|
|
2332
|
-
path.push(leftKey);
|
|
2333
|
-
}
|
|
2334
|
-
}, {
|
|
2335
|
-
key: 'nodeEnd',
|
|
2336
|
-
value: function nodeEnd(_ref2) {
|
|
2337
|
-
var path = _ref2.path;
|
|
2338
|
-
path.pop();
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
/* jshint camelcase: false */
|
|
2342
|
-
/* eslint-disable camelcase */
|
|
2343
|
-
}, {
|
|
2344
|
-
key: 'format_unchanged',
|
|
2345
|
-
value: function format_unchanged() {}
|
|
2346
|
-
}, {
|
|
2347
|
-
key: 'format_movedestination',
|
|
2348
|
-
value: function format_movedestination() {}
|
|
2349
|
-
}, {
|
|
2350
|
-
key: 'format_node',
|
|
2351
|
-
value: function format_node(context, delta, left) {
|
|
2352
|
-
this.formatDeltaChildren(context, delta, left);
|
|
2353
|
-
}
|
|
2354
|
-
}, {
|
|
2355
|
-
key: 'format_added',
|
|
2356
|
-
value: function format_added(context, delta) {
|
|
2357
|
-
context.pushCurrentOp({
|
|
2358
|
-
op: OPERATIONS.add,
|
|
2359
|
-
value: delta[0]
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
|
-
}, {
|
|
2363
|
-
key: 'format_modified',
|
|
2364
|
-
value: function format_modified(context, delta) {
|
|
2365
|
-
context.pushCurrentOp({
|
|
2366
|
-
op: OPERATIONS.replace,
|
|
2367
|
-
value: delta[1]
|
|
2368
|
-
});
|
|
2369
|
-
}
|
|
2370
|
-
}, {
|
|
2371
|
-
key: 'format_deleted',
|
|
2372
|
-
value: function format_deleted(context) {
|
|
2373
|
-
context.pushCurrentOp({
|
|
2374
|
-
op: OPERATIONS.remove
|
|
2375
|
-
});
|
|
2376
|
-
}
|
|
2377
|
-
}, {
|
|
2378
|
-
key: 'format_moved',
|
|
2379
|
-
value: function format_moved(context, delta) {
|
|
2380
|
-
var to = delta[1];
|
|
2381
|
-
context.pushMoveOp(to);
|
|
2382
|
-
}
|
|
2383
|
-
}, {
|
|
2384
|
-
key: 'format_textdiff',
|
|
2385
|
-
value: function format_textdiff() {
|
|
2386
|
-
throw new Error('Not implemented');
|
|
2387
|
-
}
|
|
2388
|
-
}, {
|
|
2389
|
-
key: 'format',
|
|
2390
|
-
value: function format(delta, left) {
|
|
2391
|
-
var context = {};
|
|
2392
|
-
this.prepareContext(context);
|
|
2393
|
-
this.recurse(context, delta, left);
|
|
2394
|
-
return context.result;
|
|
2395
|
-
}
|
|
2396
|
-
}]);
|
|
2397
|
-
return JSONFormatter;
|
|
2398
|
-
}(BaseFormatter);
|
|
2399
|
-
var last = function last(arr) {
|
|
2400
|
-
return arr[arr.length - 1];
|
|
2401
|
-
};
|
|
2402
|
-
var sortBy = function sortBy(arr, pred) {
|
|
2403
|
-
arr.sort(pred);
|
|
2404
|
-
return arr;
|
|
2405
|
-
};
|
|
2406
|
-
var compareByIndexDesc = function compareByIndexDesc(indexA, indexB) {
|
|
2407
|
-
var lastA = parseInt(indexA, 10);
|
|
2408
|
-
var lastB = parseInt(indexB, 10);
|
|
2409
|
-
if (!(isNaN(lastA) || isNaN(lastB))) {
|
|
2410
|
-
return lastB - lastA;
|
|
2411
|
-
} else {
|
|
2412
|
-
return 0;
|
|
2413
|
-
}
|
|
2414
|
-
};
|
|
2415
|
-
var opsByDescendingOrder = function opsByDescendingOrder(removeOps) {
|
|
2416
|
-
return sortBy(removeOps, function (a, b) {
|
|
2417
|
-
var splitA = a.path.split('/');
|
|
2418
|
-
var splitB = b.path.split('/');
|
|
2419
|
-
if (splitA.length !== splitB.length) {
|
|
2420
|
-
return splitA.length - splitB.length;
|
|
2421
|
-
} else {
|
|
2422
|
-
return compareByIndexDesc(last(splitA), last(splitB));
|
|
2423
|
-
}
|
|
2424
|
-
});
|
|
2425
|
-
};
|
|
2426
|
-
var partitionOps = function partitionOps(arr, fns) {
|
|
2427
|
-
var initArr = Array(fns.length + 1).fill().map(function () {
|
|
2428
|
-
return [];
|
|
2429
|
-
});
|
|
2430
|
-
return arr.map(function (item) {
|
|
2431
|
-
var position = fns.map(function (fn) {
|
|
2432
|
-
return fn(item);
|
|
2433
|
-
}).indexOf(true);
|
|
2434
|
-
if (position < 0) {
|
|
2435
|
-
position = fns.length;
|
|
2436
|
-
}
|
|
2437
|
-
return {
|
|
2438
|
-
item: item,
|
|
2439
|
-
position: position
|
|
2440
|
-
};
|
|
2441
|
-
}).reduce(function (acc, item) {
|
|
2442
|
-
acc[item.position].push(item.item);
|
|
2443
|
-
return acc;
|
|
2444
|
-
}, initArr);
|
|
2445
|
-
};
|
|
2446
|
-
var isMoveOp = function isMoveOp(_ref3) {
|
|
2447
|
-
var op = _ref3.op;
|
|
2448
|
-
return op === 'move';
|
|
2449
|
-
};
|
|
2450
|
-
var isRemoveOp = function isRemoveOp(_ref4) {
|
|
2451
|
-
var op = _ref4.op;
|
|
2452
|
-
return op === 'remove';
|
|
2453
|
-
};
|
|
2454
|
-
var reorderOps = function reorderOps(diff) {
|
|
2455
|
-
var _partitionOps = partitionOps(diff, [isMoveOp, isRemoveOp]),
|
|
2456
|
-
_partitionOps2 = slicedToArray(_partitionOps, 3),
|
|
2457
|
-
moveOps = _partitionOps2[0],
|
|
2458
|
-
removedOps = _partitionOps2[1],
|
|
2459
|
-
restOps = _partitionOps2[2];
|
|
2460
|
-
var removeOpsReverse = opsByDescendingOrder(removedOps);
|
|
2461
|
-
return [].concat(toConsumableArray(removeOpsReverse), toConsumableArray(moveOps), toConsumableArray(restOps));
|
|
2462
|
-
};
|
|
2463
|
-
var defaultInstance$2 = void 0;
|
|
2464
|
-
var format$2 = function format(delta, left) {
|
|
2465
|
-
if (!defaultInstance$2) {
|
|
2466
|
-
defaultInstance$2 = new JSONFormatter();
|
|
2467
|
-
}
|
|
2468
|
-
return reorderOps(defaultInstance$2.format(delta, left));
|
|
2469
|
-
};
|
|
2470
|
-
var log = function log(delta, left) {
|
|
2471
|
-
console.log(format$2(delta, left));
|
|
2472
|
-
};
|
|
2473
|
-
var jsonpatch = Object.freeze({
|
|
2474
|
-
default: JSONFormatter,
|
|
2475
|
-
partitionOps: partitionOps,
|
|
2476
|
-
format: format$2,
|
|
2477
|
-
log: log
|
|
2478
|
-
});
|
|
2479
|
-
function chalkColor(name) {
|
|
2480
|
-
return chalk__default["default"] && chalk__default["default"][name] || function () {
|
|
2481
|
-
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
|
2482
|
-
args[_key] = arguments[_key];
|
|
2483
|
-
}
|
|
2484
|
-
return args;
|
|
2485
|
-
};
|
|
2486
|
-
}
|
|
2487
|
-
var colors = {
|
|
2488
|
-
added: chalkColor('green'),
|
|
2489
|
-
deleted: chalkColor('red'),
|
|
2490
|
-
movedestination: chalkColor('gray'),
|
|
2491
|
-
moved: chalkColor('yellow'),
|
|
2492
|
-
unchanged: chalkColor('gray'),
|
|
2493
|
-
error: chalkColor('white.bgRed'),
|
|
2494
|
-
textDiffLine: chalkColor('gray')
|
|
2495
|
-
};
|
|
2496
|
-
var ConsoleFormatter = function (_BaseFormatter) {
|
|
2497
|
-
inherits(ConsoleFormatter, _BaseFormatter);
|
|
2498
|
-
function ConsoleFormatter() {
|
|
2499
|
-
classCallCheck(this, ConsoleFormatter);
|
|
2500
|
-
var _this = possibleConstructorReturn(this, (ConsoleFormatter.__proto__ || Object.getPrototypeOf(ConsoleFormatter)).call(this));
|
|
2501
|
-
_this.includeMoveDestinations = false;
|
|
2502
|
-
return _this;
|
|
2503
|
-
}
|
|
2504
|
-
createClass(ConsoleFormatter, [{
|
|
2505
|
-
key: 'prepareContext',
|
|
2506
|
-
value: function prepareContext(context) {
|
|
2507
|
-
get(ConsoleFormatter.prototype.__proto__ || Object.getPrototypeOf(ConsoleFormatter.prototype), 'prepareContext', this).call(this, context);
|
|
2508
|
-
context.indent = function (levels) {
|
|
2509
|
-
this.indentLevel = (this.indentLevel || 0) + (typeof levels === 'undefined' ? 1 : levels);
|
|
2510
|
-
this.indentPad = new Array(this.indentLevel + 1).join(' ');
|
|
2511
|
-
this.outLine();
|
|
2512
|
-
};
|
|
2513
|
-
context.outLine = function () {
|
|
2514
|
-
this.buffer.push('\n' + (this.indentPad || ''));
|
|
2515
|
-
};
|
|
2516
|
-
context.out = function () {
|
|
2517
|
-
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2518
|
-
args[_key2] = arguments[_key2];
|
|
2519
|
-
}
|
|
2520
|
-
for (var i = 0, l = args.length; i < l; i++) {
|
|
2521
|
-
var lines = args[i].split('\n');
|
|
2522
|
-
var text = lines.join('\n' + (this.indentPad || ''));
|
|
2523
|
-
if (this.color && this.color[0]) {
|
|
2524
|
-
text = this.color[0](text);
|
|
2525
|
-
}
|
|
2526
|
-
this.buffer.push(text);
|
|
2527
|
-
}
|
|
2528
|
-
};
|
|
2529
|
-
context.pushColor = function (color) {
|
|
2530
|
-
this.color = this.color || [];
|
|
2531
|
-
this.color.unshift(color);
|
|
2532
|
-
};
|
|
2533
|
-
context.popColor = function () {
|
|
2534
|
-
this.color = this.color || [];
|
|
2535
|
-
this.color.shift();
|
|
2536
|
-
};
|
|
2537
|
-
}
|
|
2538
|
-
}, {
|
|
2539
|
-
key: 'typeFormattterErrorFormatter',
|
|
2540
|
-
value: function typeFormattterErrorFormatter(context, err) {
|
|
2541
|
-
context.pushColor(colors.error);
|
|
2542
|
-
context.out('[ERROR]' + err);
|
|
2543
|
-
context.popColor();
|
|
2544
|
-
}
|
|
2545
|
-
}, {
|
|
2546
|
-
key: 'formatValue',
|
|
2547
|
-
value: function formatValue(context, value) {
|
|
2548
|
-
context.out(JSON.stringify(value, null, 2));
|
|
2549
|
-
}
|
|
2550
|
-
}, {
|
|
2551
|
-
key: 'formatTextDiffString',
|
|
2552
|
-
value: function formatTextDiffString(context, value) {
|
|
2553
|
-
var lines = this.parseTextDiff(value);
|
|
2554
|
-
context.indent();
|
|
2555
|
-
for (var i = 0, l = lines.length; i < l; i++) {
|
|
2556
|
-
var line = lines[i];
|
|
2557
|
-
context.pushColor(colors.textDiffLine);
|
|
2558
|
-
context.out(line.location.line + ',' + line.location.chr + ' ');
|
|
2559
|
-
context.popColor();
|
|
2560
|
-
var pieces = line.pieces;
|
|
2561
|
-
for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
|
|
2562
|
-
var piece = pieces[pieceIndex];
|
|
2563
|
-
context.pushColor(colors[piece.type]);
|
|
2564
|
-
context.out(piece.text);
|
|
2565
|
-
context.popColor();
|
|
2566
|
-
}
|
|
2567
|
-
if (i < l - 1) {
|
|
2568
|
-
context.outLine();
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
context.indent(-1);
|
|
2572
|
-
}
|
|
2573
|
-
}, {
|
|
2574
|
-
key: 'rootBegin',
|
|
2575
|
-
value: function rootBegin(context, type, nodeType) {
|
|
2576
|
-
context.pushColor(colors[type]);
|
|
2577
|
-
if (type === 'node') {
|
|
2578
|
-
context.out(nodeType === 'array' ? '[' : '{');
|
|
2579
|
-
context.indent();
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
}, {
|
|
2583
|
-
key: 'rootEnd',
|
|
2584
|
-
value: function rootEnd(context, type, nodeType) {
|
|
2585
|
-
if (type === 'node') {
|
|
2586
|
-
context.indent(-1);
|
|
2587
|
-
context.out(nodeType === 'array' ? ']' : '}');
|
|
2588
|
-
}
|
|
2589
|
-
context.popColor();
|
|
2590
|
-
}
|
|
2591
|
-
}, {
|
|
2592
|
-
key: 'nodeBegin',
|
|
2593
|
-
value: function nodeBegin(context, key, leftKey, type, nodeType) {
|
|
2594
|
-
context.pushColor(colors[type]);
|
|
2595
|
-
context.out(leftKey + ': ');
|
|
2596
|
-
if (type === 'node') {
|
|
2597
|
-
context.out(nodeType === 'array' ? '[' : '{');
|
|
2598
|
-
context.indent();
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
}, {
|
|
2602
|
-
key: 'nodeEnd',
|
|
2603
|
-
value: function nodeEnd(context, key, leftKey, type, nodeType, isLast) {
|
|
2604
|
-
if (type === 'node') {
|
|
2605
|
-
context.indent(-1);
|
|
2606
|
-
context.out(nodeType === 'array' ? ']' : '}' + (isLast ? '' : ','));
|
|
2607
|
-
}
|
|
2608
|
-
if (!isLast) {
|
|
2609
|
-
context.outLine();
|
|
2610
|
-
}
|
|
2611
|
-
context.popColor();
|
|
2612
|
-
}
|
|
2613
|
-
|
|
2614
|
-
/* jshint camelcase: false */
|
|
2615
|
-
/* eslint-disable camelcase */
|
|
2616
|
-
}, {
|
|
2617
|
-
key: 'format_unchanged',
|
|
2618
|
-
value: function format_unchanged(context, delta, left) {
|
|
2619
|
-
if (typeof left === 'undefined') {
|
|
2620
|
-
return;
|
|
2621
|
-
}
|
|
2622
|
-
this.formatValue(context, left);
|
|
2623
|
-
}
|
|
2624
|
-
}, {
|
|
2625
|
-
key: 'format_movedestination',
|
|
2626
|
-
value: function format_movedestination(context, delta, left) {
|
|
2627
|
-
if (typeof left === 'undefined') {
|
|
2628
|
-
return;
|
|
2629
|
-
}
|
|
2630
|
-
this.formatValue(context, left);
|
|
2631
|
-
}
|
|
2632
|
-
}, {
|
|
2633
|
-
key: 'format_node',
|
|
2634
|
-
value: function format_node(context, delta, left) {
|
|
2635
|
-
// recurse
|
|
2636
|
-
this.formatDeltaChildren(context, delta, left);
|
|
2637
|
-
}
|
|
2638
|
-
}, {
|
|
2639
|
-
key: 'format_added',
|
|
2640
|
-
value: function format_added(context, delta) {
|
|
2641
|
-
this.formatValue(context, delta[0]);
|
|
2642
|
-
}
|
|
2643
|
-
}, {
|
|
2644
|
-
key: 'format_modified',
|
|
2645
|
-
value: function format_modified(context, delta) {
|
|
2646
|
-
context.pushColor(colors.deleted);
|
|
2647
|
-
this.formatValue(context, delta[0]);
|
|
2648
|
-
context.popColor();
|
|
2649
|
-
context.out(' => ');
|
|
2650
|
-
context.pushColor(colors.added);
|
|
2651
|
-
this.formatValue(context, delta[1]);
|
|
2652
|
-
context.popColor();
|
|
2653
|
-
}
|
|
2654
|
-
}, {
|
|
2655
|
-
key: 'format_deleted',
|
|
2656
|
-
value: function format_deleted(context, delta) {
|
|
2657
|
-
this.formatValue(context, delta[0]);
|
|
2658
|
-
}
|
|
2659
|
-
}, {
|
|
2660
|
-
key: 'format_moved',
|
|
2661
|
-
value: function format_moved(context, delta) {
|
|
2662
|
-
context.out('==> ' + delta[1]);
|
|
2663
|
-
}
|
|
2664
|
-
}, {
|
|
2665
|
-
key: 'format_textdiff',
|
|
2666
|
-
value: function format_textdiff(context, delta) {
|
|
2667
|
-
this.formatTextDiffString(context, delta[0]);
|
|
2668
|
-
}
|
|
2669
|
-
}]);
|
|
2670
|
-
return ConsoleFormatter;
|
|
2671
|
-
}(BaseFormatter);
|
|
2672
|
-
var defaultInstance$3 = void 0;
|
|
2673
|
-
var format$3 = function format(delta, left) {
|
|
2674
|
-
if (!defaultInstance$3) {
|
|
2675
|
-
defaultInstance$3 = new ConsoleFormatter();
|
|
2676
|
-
}
|
|
2677
|
-
return defaultInstance$3.format(delta, left);
|
|
2678
|
-
};
|
|
2679
|
-
function log$1(delta, left) {
|
|
2680
|
-
console.log(format$3(delta, left));
|
|
2681
|
-
}
|
|
2682
|
-
var console$1 = Object.freeze({
|
|
2683
|
-
default: ConsoleFormatter,
|
|
2684
|
-
format: format$3,
|
|
2685
|
-
log: log$1
|
|
2686
|
-
});
|
|
2687
|
-
Object.freeze({
|
|
2688
|
-
base: base,
|
|
2689
|
-
html: html,
|
|
2690
|
-
annotated: annotated,
|
|
2691
|
-
jsonpatch: jsonpatch,
|
|
2692
|
-
console: console$1
|
|
2693
|
-
});
|
|
2694
1510
|
|
|
2695
1511
|
function objectHash(obj, index) {
|
|
2696
1512
|
var objIndex = "$$index:".concat(index);
|
|
2697
|
-
return _typeof
|
|
1513
|
+
return _typeof(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
|
|
2698
1514
|
}
|
|
2699
1515
|
var diffpatcher = new DiffPatcher({
|
|
2700
1516
|
objectHash: objectHash,
|
|
@@ -2858,7 +1674,7 @@ function isCreateAction(obj, key) {
|
|
|
2858
1674
|
* false otherwise
|
|
2859
1675
|
*/
|
|
2860
1676
|
function isChangeAction(obj, key) {
|
|
2861
|
-
return REGEX_NUMBER$4.test(key) && (_typeof
|
|
1677
|
+
return REGEX_NUMBER$4.test(key) && (_typeof(obj[key]) === 'object' || typeof obj[key] === 'string');
|
|
2862
1678
|
}
|
|
2863
1679
|
|
|
2864
1680
|
/**
|
|
@@ -2874,7 +1690,7 @@ function isChangeAction(obj, key) {
|
|
|
2874
1690
|
* false otherwise
|
|
2875
1691
|
*/
|
|
2876
1692
|
function isRemoveAction$1(obj, key) {
|
|
2877
|
-
return REGEX_UNDERSCORE_NUMBER$4.test(key) && Array.isArray(obj[key]) && obj[key].length === 3 && (_typeof
|
|
1693
|
+
return REGEX_UNDERSCORE_NUMBER$4.test(key) && Array.isArray(obj[key]) && obj[key].length === 3 && (_typeof(obj[key][0]) === 'object' || typeof obj[key][0] === 'string') && obj[key][1] === 0 && obj[key][2] === 0;
|
|
2878
1694
|
}
|
|
2879
1695
|
|
|
2880
1696
|
/**
|
|
@@ -3026,7 +1842,7 @@ function buildBaseAttributesActions(_ref) {
|
|
|
3026
1842
|
action: item.action
|
|
3027
1843
|
}, actionKey, patched);
|
|
3028
1844
|
}).filter(function (action) {
|
|
3029
|
-
return !
|
|
1845
|
+
return !isNil(action);
|
|
3030
1846
|
});
|
|
3031
1847
|
}
|
|
3032
1848
|
|
|
@@ -3133,7 +1949,6 @@ function actionsMapReferences$3(diff, oldObj, newObj) {
|
|
|
3133
1949
|
return buildReferenceActions({
|
|
3134
1950
|
actions: referenceActionsList$3,
|
|
3135
1951
|
diff: diff,
|
|
3136
|
-
oldObj: oldObj,
|
|
3137
1952
|
newObj: newObj
|
|
3138
1953
|
});
|
|
3139
1954
|
}
|
|
@@ -3159,7 +1974,7 @@ var CUSTOM = 'custom';
|
|
|
3159
1974
|
function copyEmptyArrayProps() {
|
|
3160
1975
|
var oldObj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
3161
1976
|
var newObj = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
3162
|
-
if (!
|
|
1977
|
+
if (!isNil(oldObj) && !isNil(newObj)) {
|
|
3163
1978
|
var nextObjectWithEmptyArray = Object.entries(oldObj).reduce(function (merged, _ref) {
|
|
3164
1979
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
3165
1980
|
key = _ref2[0],
|
|
@@ -3174,10 +1989,10 @@ function copyEmptyArrayProps() {
|
|
|
3174
1989
|
return acc;
|
|
3175
1990
|
}, {});
|
|
3176
1991
|
for (var i = 0; i < newObj[key].length; i++) {
|
|
3177
|
-
if (!
|
|
1992
|
+
if (!isNil(newObj[key][i]) && _typeof(newObj[key][i]) === 'object' && !isNil(newObj[key][i].id)) {
|
|
3178
1993
|
// Since its unordered array elements then check if the element on `oldObj` exists by id
|
|
3179
1994
|
var foundObject = hashMapValue[newObj[key][i].id];
|
|
3180
|
-
if (!
|
|
1995
|
+
if (!isNil(foundObject)) {
|
|
3181
1996
|
var _copyEmptyArrayProps = copyEmptyArrayProps(foundObject, newObj[key][i]),
|
|
3182
1997
|
_copyEmptyArrayProps2 = _slicedToArray(_copyEmptyArrayProps, 2),
|
|
3183
1998
|
nestedObject = _copyEmptyArrayProps2[1];
|
|
@@ -3193,10 +2008,10 @@ function copyEmptyArrayProps() {
|
|
|
3193
2008
|
return merged;
|
|
3194
2009
|
}
|
|
3195
2010
|
if (Array.isArray(value)) {
|
|
3196
|
-
merged[key] =
|
|
2011
|
+
merged[key] = isNil(newObj[key]) ? [] : newObj[key];
|
|
3197
2012
|
return merged;
|
|
3198
2013
|
}
|
|
3199
|
-
if (!
|
|
2014
|
+
if (!isNil(newObj[key]) && _typeof(value) === 'object' &&
|
|
3200
2015
|
// Ignore Date as this will create invalid object since typeof date === 'object' return true
|
|
3201
2016
|
// ex: {date: new Date()} will result {date: {}}
|
|
3202
2017
|
!(value instanceof Date)) {
|
|
@@ -3231,7 +2046,7 @@ function createCategoryMapActions(mapActionGroup, syncActionConfig) {
|
|
|
3231
2046
|
allActions.push(mapActionGroup('assets', function () {
|
|
3232
2047
|
return actionsMapAssets$1(diff, oldObj, newObj);
|
|
3233
2048
|
}));
|
|
3234
|
-
return
|
|
2049
|
+
return flatten(allActions);
|
|
3235
2050
|
};
|
|
3236
2051
|
}
|
|
3237
2052
|
var categories = (function (actionGroupList, syncActionConfig) {
|
|
@@ -3349,7 +2164,6 @@ function actionsMapReferences$2(diff, oldObj, newObj) {
|
|
|
3349
2164
|
return buildReferenceActions({
|
|
3350
2165
|
actions: referenceActionsList$2,
|
|
3351
2166
|
diff: diff,
|
|
3352
|
-
oldObj: oldObj,
|
|
3353
2167
|
newObj: newObj
|
|
3354
2168
|
});
|
|
3355
2169
|
}
|
|
@@ -3457,7 +2271,7 @@ function buildAuthenticationModeActions(_ref) {
|
|
|
3457
2271
|
authMode: patched
|
|
3458
2272
|
}, value, newObj.password);
|
|
3459
2273
|
}).filter(function (action) {
|
|
3460
|
-
return !
|
|
2274
|
+
return !isNil(action);
|
|
3461
2275
|
});
|
|
3462
2276
|
}
|
|
3463
2277
|
|
|
@@ -3488,7 +2302,7 @@ function createCustomerMapActions(mapActionGroup, syncActionConfig) {
|
|
|
3488
2302
|
allActions.push(mapActionGroup('authenticationModes', function () {
|
|
3489
2303
|
return actionsMapAuthenticationModes(diff, oldObj, newObj);
|
|
3490
2304
|
}));
|
|
3491
|
-
return
|
|
2305
|
+
return flatten(allActions);
|
|
3492
2306
|
};
|
|
3493
2307
|
}
|
|
3494
2308
|
var customers = (function (actionGroupList, syncActionConfig) {
|
|
@@ -3547,7 +2361,6 @@ function actionsMapReferences$1(diff, oldObj, newObj) {
|
|
|
3547
2361
|
return buildReferenceActions({
|
|
3548
2362
|
actions: referenceActionsList$1,
|
|
3549
2363
|
diff: diff,
|
|
3550
|
-
oldObj: oldObj,
|
|
3551
2364
|
newObj: newObj
|
|
3552
2365
|
});
|
|
3553
2366
|
}
|
|
@@ -3564,7 +2377,7 @@ function createInventoryMapActions(mapActionGroup, syncActionConfig) {
|
|
|
3564
2377
|
allActions.push(mapActionGroup('custom', function () {
|
|
3565
2378
|
return actionsMapCustom(diff, newObj, oldObj);
|
|
3566
2379
|
}));
|
|
3567
|
-
return
|
|
2380
|
+
return flatten(allActions);
|
|
3568
2381
|
};
|
|
3569
2382
|
}
|
|
3570
2383
|
var inventories = (function (actionGroupList, syncActionConfig) {
|
|
@@ -3631,7 +2444,7 @@ function findMatchingPairs(diff) {
|
|
|
3631
2444
|
var _preProcessCollection2 = preProcessCollection(now, identifier),
|
|
3632
2445
|
nowObjRefByIdentifier = _preProcessCollection2.refByIdentifier,
|
|
3633
2446
|
nowObjRefByIndex = _preProcessCollection2.refByIndex;
|
|
3634
|
-
|
|
2447
|
+
forEach(diff, function (item, key) {
|
|
3635
2448
|
if (REGEX_NUMBER$3.test(key)) {
|
|
3636
2449
|
var matchingIdentifier = nowObjRefByIndex[key];
|
|
3637
2450
|
result[key] = [beforeObjRefByIdentifier[matchingIdentifier], key];
|
|
@@ -3790,7 +2603,7 @@ function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAll
|
|
|
3790
2603
|
currencyCode: diffedValue.currencyCode ? getDeltaValue(diffedValue.currencyCode) : attribute.value.currencyCode
|
|
3791
2604
|
};else if (diffedValue.key)
|
|
3792
2605
|
// Enum / LEnum (use only the key)
|
|
3793
|
-
action.value = getDeltaValue(diffedValue.key);else if (_typeof
|
|
2606
|
+
action.value = getDeltaValue(diffedValue.key);else if (_typeof(diffedValue) === 'object') if ({}.hasOwnProperty.call(diffedValue, '_t') && diffedValue._t === 'a') {
|
|
3794
2607
|
// set-typed attribute
|
|
3795
2608
|
action = _objectSpread2(_objectSpread2({}, action), {}, {
|
|
3796
2609
|
value: attribute.value
|
|
@@ -3812,7 +2625,7 @@ function _buildVariantImagesAction(diffedImages) {
|
|
|
3812
2625
|
var actions = [];
|
|
3813
2626
|
// generate a hashMap to be able to reference the right image from both ends
|
|
3814
2627
|
var matchingImagePairs = findMatchingPairs(diffedImages, oldVariant.images, newVariant.images, 'url');
|
|
3815
|
-
|
|
2628
|
+
forEach(diffedImages, function (image, key) {
|
|
3816
2629
|
var _extractMatchingPairs = extractMatchingPairs(matchingImagePairs, key, oldVariant.images, newVariant.images),
|
|
3817
2630
|
oldObj = _extractMatchingPairs.oldObj,
|
|
3818
2631
|
newObj = _extractMatchingPairs.newObj;
|
|
@@ -3822,7 +2635,7 @@ function _buildVariantImagesAction(diffedImages) {
|
|
|
3822
2635
|
action: 'addExternalImage',
|
|
3823
2636
|
variantId: oldVariant.id,
|
|
3824
2637
|
image: getDeltaValue(image)
|
|
3825
|
-
});else if (_typeof
|
|
2638
|
+
});else if (_typeof(image) === 'object') if ({}.hasOwnProperty.call(image, 'url') && image.url.length === 2) {
|
|
3826
2639
|
// There is a new image, remove the old one first.
|
|
3827
2640
|
actions.push({
|
|
3828
2641
|
action: 'removeImage',
|
|
@@ -3869,7 +2682,7 @@ function _buildVariantPricesAction(diffedPrices) {
|
|
|
3869
2682
|
|
|
3870
2683
|
// generate a hashMap to be able to reference the right image from both ends
|
|
3871
2684
|
var matchingPricePairs = findMatchingPairs(diffedPrices, oldVariant.prices, newVariant.prices);
|
|
3872
|
-
|
|
2685
|
+
forEach(diffedPrices, function (price, key) {
|
|
3873
2686
|
var _extractMatchingPairs2 = extractMatchingPairs(matchingPricePairs, key, oldVariant.prices, newVariant.prices),
|
|
3874
2687
|
oldObj = _extractMatchingPairs2.oldObj,
|
|
3875
2688
|
newObj = _extractMatchingPairs2.newObj;
|
|
@@ -3917,7 +2730,7 @@ function _buildVariantPricesAction(diffedPrices) {
|
|
|
3917
2730
|
function _buildVariantAttributesActions(attributes, oldVariant, newVariant, sameForAllAttributeNames) {
|
|
3918
2731
|
var actions = [];
|
|
3919
2732
|
if (!attributes) return actions;
|
|
3920
|
-
|
|
2733
|
+
forEach(attributes, function (value, key) {
|
|
3921
2734
|
if (REGEX_NUMBER$2.test(key)) {
|
|
3922
2735
|
if (Array.isArray(value)) {
|
|
3923
2736
|
var id = oldVariant.id;
|
|
@@ -3982,8 +2795,8 @@ function _buildVariantChangeAssetOrderAction(diffAssets, oldVariant, newVariant)
|
|
|
3982
2795
|
}).filter(function (_) {
|
|
3983
2796
|
return _ !== undefined;
|
|
3984
2797
|
});
|
|
3985
|
-
var assetIdsToKeep =
|
|
3986
|
-
var assetIdsToRemove =
|
|
2798
|
+
var assetIdsToKeep = intersection(assetIdsCurrent, assetIdsBefore);
|
|
2799
|
+
var assetIdsToRemove = without.apply(void 0, [assetIdsBefore].concat(_toConsumableArray(assetIdsToKeep)));
|
|
3987
2800
|
var changeAssetOrderAction = _objectSpread2({
|
|
3988
2801
|
action: 'changeAssetOrder',
|
|
3989
2802
|
assetOrder: assetIdsToKeep.concat(assetIdsToRemove)
|
|
@@ -3995,7 +2808,7 @@ function _buildVariantAssetsActions(diffAssets, oldVariant, newVariant) {
|
|
|
3995
2808
|
|
|
3996
2809
|
// generate a hashMap to be able to reference the right asset from both ends
|
|
3997
2810
|
var matchingAssetPairs = findMatchingPairs(diffAssets, oldVariant.assets, newVariant.assets);
|
|
3998
|
-
|
|
2811
|
+
forEach(diffAssets, function (asset, key) {
|
|
3999
2812
|
var _extractMatchingPairs3 = extractMatchingPairs(matchingAssetPairs, key, oldVariant.assets, newVariant.assets),
|
|
4000
2813
|
oldAsset = _extractMatchingPairs3.oldObj,
|
|
4001
2814
|
newAsset = _extractMatchingPairs3.newObj;
|
|
@@ -4094,7 +2907,6 @@ function actionsMapReferences(diff, oldObj, newObj) {
|
|
|
4094
2907
|
return buildReferenceActions({
|
|
4095
2908
|
actions: referenceActionsList,
|
|
4096
2909
|
diff: diff,
|
|
4097
|
-
oldObj: oldObj,
|
|
4098
2910
|
newObj: newObj
|
|
4099
2911
|
});
|
|
4100
2912
|
}
|
|
@@ -4103,7 +2915,7 @@ function actionsMapCategories(diff) {
|
|
|
4103
2915
|
if (!diff.categories) return actions;
|
|
4104
2916
|
var addToCategoryActions = [];
|
|
4105
2917
|
var removeFromCategoryActions = [];
|
|
4106
|
-
|
|
2918
|
+
forEach(diff.categories, function (category) {
|
|
4107
2919
|
if (Array.isArray(category)) {
|
|
4108
2920
|
var action = {
|
|
4109
2921
|
category: category[0]
|
|
@@ -4148,7 +2960,7 @@ function actionsMapCategoryOrderHints(diff) {
|
|
|
4148
2960
|
function actionsMapAssets(diff, oldObj, newObj, variantHashMap) {
|
|
4149
2961
|
var allAssetsActions = [];
|
|
4150
2962
|
var variants = diff.variants;
|
|
4151
|
-
if (variants)
|
|
2963
|
+
if (variants) forEach(variants, function (variant, key) {
|
|
4152
2964
|
var _extractMatchingPairs4 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
|
|
4153
2965
|
oldVariant = _extractMatchingPairs4.oldObj,
|
|
4154
2966
|
newVariant = _extractMatchingPairs4.newObj;
|
|
@@ -4164,7 +2976,7 @@ function actionsMapAttributes$1(diff, oldObj, newObj) {
|
|
|
4164
2976
|
var variantHashMap = arguments.length > 4 ? arguments[4] : undefined;
|
|
4165
2977
|
var actions = [];
|
|
4166
2978
|
var variants = diff.variants;
|
|
4167
|
-
if (variants)
|
|
2979
|
+
if (variants) forEach(variants, function (variant, key) {
|
|
4168
2980
|
var _extractMatchingPairs5 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
|
|
4169
2981
|
oldVariant = _extractMatchingPairs5.oldObj,
|
|
4170
2982
|
newVariant = _extractMatchingPairs5.newObj;
|
|
@@ -4181,14 +2993,14 @@ function actionsMapAttributes$1(diff, oldObj, newObj) {
|
|
|
4181
2993
|
|
|
4182
2994
|
// Ensure that an action is unique.
|
|
4183
2995
|
// This is especially necessary for SFA attributes.
|
|
4184
|
-
return
|
|
2996
|
+
return uniqWith(actions, function (a, b) {
|
|
4185
2997
|
return a.action === b.action && a.name === b.name && a.variantId === b.variantId;
|
|
4186
2998
|
});
|
|
4187
2999
|
}
|
|
4188
3000
|
function actionsMapImages(diff, oldObj, newObj, variantHashMap) {
|
|
4189
3001
|
var actions = [];
|
|
4190
3002
|
var variants = diff.variants;
|
|
4191
|
-
if (variants)
|
|
3003
|
+
if (variants) forEach(variants, function (variant, key) {
|
|
4192
3004
|
var _extractMatchingPairs6 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
|
|
4193
3005
|
oldVariant = _extractMatchingPairs6.oldObj,
|
|
4194
3006
|
newVariant = _extractMatchingPairs6.newObj;
|
|
@@ -4204,7 +3016,7 @@ function actionsMapPrices(diff, oldObj, newObj, variantHashMap, enableDiscounted
|
|
|
4204
3016
|
var changePriceActions = [];
|
|
4205
3017
|
var removePriceActions = [];
|
|
4206
3018
|
var variants = diff.variants;
|
|
4207
|
-
if (variants)
|
|
3019
|
+
if (variants) forEach(variants, function (variant, key) {
|
|
4208
3020
|
var _extractMatchingPairs7 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
|
|
4209
3021
|
oldVariant = _extractMatchingPairs7.oldObj,
|
|
4210
3022
|
newVariant = _extractMatchingPairs7.newObj;
|
|
@@ -4226,13 +3038,13 @@ function actionsMapPrices(diff, oldObj, newObj, variantHashMap, enableDiscounted
|
|
|
4226
3038
|
function actionsMapPricesCustom(diff, oldObj, newObj, variantHashMap) {
|
|
4227
3039
|
var actions = [];
|
|
4228
3040
|
var variants = diff.variants;
|
|
4229
|
-
if (variants)
|
|
3041
|
+
if (variants) forEach(variants, function (variant, key) {
|
|
4230
3042
|
var _extractMatchingPairs8 = extractMatchingPairs(variantHashMap, key, oldObj.variants, newObj.variants),
|
|
4231
3043
|
oldVariant = _extractMatchingPairs8.oldObj,
|
|
4232
3044
|
newVariant = _extractMatchingPairs8.newObj;
|
|
4233
3045
|
if (variant && variant.prices && (REGEX_UNDERSCORE_NUMBER$2.test(key) || REGEX_NUMBER$2.test(key))) {
|
|
4234
3046
|
var priceHashMap = findMatchingPairs(variant.prices, oldVariant.prices, newVariant.prices);
|
|
4235
|
-
|
|
3047
|
+
forEach(variant.prices, function (price, index) {
|
|
4236
3048
|
var _extractMatchingPairs9 = extractMatchingPairs(priceHashMap, index, oldVariant.prices, newVariant.prices),
|
|
4237
3049
|
oldPrice = _extractMatchingPairs9.oldObj,
|
|
4238
3050
|
newPrice = _extractMatchingPairs9.newObj;
|
|
@@ -4316,12 +3128,12 @@ function createProductMapActions(mapActionGroup, syncActionConfig) {
|
|
|
4316
3128
|
allActions.push(mapActionGroup('assets', function () {
|
|
4317
3129
|
return actionsMapAssets(diff, oldObj, newObj, variantHashMap);
|
|
4318
3130
|
}));
|
|
4319
|
-
if (publish === true || staged === false) return
|
|
3131
|
+
if (publish === true || staged === false) return flatten(allActions).map(function (action) {
|
|
4320
3132
|
return _objectSpread2(_objectSpread2({}, action), {}, {
|
|
4321
3133
|
staged: false
|
|
4322
3134
|
});
|
|
4323
3135
|
});
|
|
4324
|
-
return
|
|
3136
|
+
return flatten(allActions);
|
|
4325
3137
|
};
|
|
4326
3138
|
}
|
|
4327
3139
|
function moveMasterVariantsIntoVariants(before, now) {
|
|
@@ -4404,7 +3216,7 @@ function _buildDeliveryParcelsAction(diffedParcels) {
|
|
|
4404
3216
|
|
|
4405
3217
|
// generate a hashMap to be able to reference the right image from both ends
|
|
4406
3218
|
var matchingParcelPairs = findMatchingPairs(diffedParcels, oldDelivery.parcels, newDelivery.parcels);
|
|
4407
|
-
|
|
3219
|
+
forEach(diffedParcels, function (parcel, key) {
|
|
4408
3220
|
var _extractMatchingPairs = extractMatchingPairs(matchingParcelPairs, key, oldDelivery.parcels, newDelivery.parcels),
|
|
4409
3221
|
oldObj = _extractMatchingPairs.oldObj;
|
|
4410
3222
|
if (isAddAction(key, parcel)) {
|
|
@@ -4446,7 +3258,7 @@ function actionsMapParcels(diff, oldObj, newObj, deliveryHashMap) {
|
|
|
4446
3258
|
if (!deliveries) return [];
|
|
4447
3259
|
var addParcelActions = [];
|
|
4448
3260
|
var removeParcelActions = [];
|
|
4449
|
-
if (deliveries)
|
|
3261
|
+
if (deliveries) forEach(deliveries, function (delivery, key) {
|
|
4450
3262
|
var _extractMatchingPairs2 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
|
|
4451
3263
|
oldDelivery = _extractMatchingPairs2.oldObj,
|
|
4452
3264
|
newDelivery = _extractMatchingPairs2.newObj;
|
|
@@ -4467,7 +3279,7 @@ function actionsMapDeliveryItems(diff, oldObj, newObj, deliveryHashMap) {
|
|
|
4467
3279
|
var deliveries = shippingInfo.deliveries;
|
|
4468
3280
|
if (!deliveries) return [];
|
|
4469
3281
|
var setDeliveryItemsActions = [];
|
|
4470
|
-
|
|
3282
|
+
forEach(deliveries, function (delivery, key) {
|
|
4471
3283
|
var _extractMatchingPairs3 = extractMatchingPairs(deliveryHashMap, key, oldObj.shippingInfo.deliveries, newObj.shippingInfo.deliveries),
|
|
4472
3284
|
newDelivery = _extractMatchingPairs3.newObj;
|
|
4473
3285
|
if (REGEX_UNDERSCORE_NUMBER$1.test(key) || REGEX_NUMBER$1.test(key)) {
|
|
@@ -4536,13 +3348,13 @@ function createOrderMapActions(mapActionGroup, syncActionConfig) {
|
|
|
4536
3348
|
allActions.push(mapActionGroup('items', function () {
|
|
4537
3349
|
return actionsMapDeliveryItems(diff, oldObj, newObj, deliveryHashMap);
|
|
4538
3350
|
}));
|
|
4539
|
-
allActions.push(
|
|
3351
|
+
allActions.push(flatten(mapActionGroup('returnInfo', function () {
|
|
4540
3352
|
return actionsMapReturnsInfo(diff, oldObj, newObj);
|
|
4541
3353
|
})));
|
|
4542
3354
|
allActions.push(mapActionGroup('custom', function () {
|
|
4543
3355
|
return actionsMapCustom(diff, newObj, oldObj);
|
|
4544
3356
|
}));
|
|
4545
|
-
return
|
|
3357
|
+
return flatten(allActions);
|
|
4546
3358
|
};
|
|
4547
3359
|
}
|
|
4548
3360
|
var orders = (function (actionGroupList, syncActionConfig) {
|
|
@@ -4636,7 +3448,7 @@ function createProductDiscountsMapActions(mapActionGroup, syncActionConfig) {
|
|
|
4636
3448
|
allActions.push(mapActionGroup('base', function () {
|
|
4637
3449
|
return actionsMapBase$f(diff, oldObj, newObj, syncActionConfig);
|
|
4638
3450
|
}));
|
|
4639
|
-
return combineValidityActions(
|
|
3451
|
+
return combineValidityActions(flatten(allActions));
|
|
4640
3452
|
};
|
|
4641
3453
|
}
|
|
4642
3454
|
var productDiscounts = (function (actionGroupList) {
|
|
@@ -4705,7 +3517,7 @@ function createDiscountCodesMapActions(mapActionGroup, syncActionConfig) {
|
|
|
4705
3517
|
allActions.push(mapActionGroup('custom', function () {
|
|
4706
3518
|
return actionsMapCustom(diff, newObj, oldObj);
|
|
4707
3519
|
}));
|
|
4708
|
-
return combineValidityActions(
|
|
3520
|
+
return combineValidityActions(flatten(allActions));
|
|
4709
3521
|
};
|
|
4710
3522
|
}
|
|
4711
3523
|
var discountCodes = (function (actionGroupList) {
|
|
@@ -4758,7 +3570,7 @@ function createCustomerGroupMapActions(mapActionGroup, syncActionConfig) {
|
|
|
4758
3570
|
allActions.push(mapActionGroup('custom', function () {
|
|
4759
3571
|
return actionsMapCustom(diff, newObj, oldObj);
|
|
4760
3572
|
}));
|
|
4761
|
-
return
|
|
3573
|
+
return flatten(allActions);
|
|
4762
3574
|
};
|
|
4763
3575
|
}
|
|
4764
3576
|
var customerGroup = (function (actionGroupList) {
|
|
@@ -4830,7 +3642,7 @@ function createCartDiscountsMapActions(mapActionGroup, syncActionConfig) {
|
|
|
4830
3642
|
allActions.push(mapActionGroup('custom', function () {
|
|
4831
3643
|
return actionsMapCustom(diff, newObj, oldObj);
|
|
4832
3644
|
}));
|
|
4833
|
-
return combineValidityActions(
|
|
3645
|
+
return combineValidityActions(flatten(allActions));
|
|
4834
3646
|
};
|
|
4835
3647
|
}
|
|
4836
3648
|
var cartDiscounts = (function (actionGroupList) {
|
|
@@ -4925,8 +3737,8 @@ function createCircularEqualCreator(isEqual) {
|
|
|
4925
3737
|
if (cache === void 0) {
|
|
4926
3738
|
cache = getNewCache();
|
|
4927
3739
|
}
|
|
4928
|
-
var isCacheableA = !!a && _typeof
|
|
4929
|
-
var isCacheableB = !!b && _typeof
|
|
3740
|
+
var isCacheableA = !!a && _typeof(a) === 'object';
|
|
3741
|
+
var isCacheableB = !!b && _typeof(b) === 'object';
|
|
4930
3742
|
if (isCacheableA || isCacheableB) {
|
|
4931
3743
|
var hasA = isCacheableA && cache.has(a);
|
|
4932
3744
|
var hasB = isCacheableB && cache.has(b);
|
|
@@ -5092,7 +3904,7 @@ function createComparator(createIsEqual) {
|
|
|
5092
3904
|
if (a === b) {
|
|
5093
3905
|
return true;
|
|
5094
3906
|
}
|
|
5095
|
-
if (a && b && _typeof
|
|
3907
|
+
if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
|
|
5096
3908
|
if (isPlainObject(a) && isPlainObject(b)) {
|
|
5097
3909
|
return areObjectsEqual(a, b, isEqual, meta);
|
|
5098
3910
|
}
|
|
@@ -5210,7 +4022,7 @@ function createTaxCategoriesMapActions(mapActionGroup, syncActionConfig) {
|
|
|
5210
4022
|
allActions.push(mapActionGroup('rates', function () {
|
|
5211
4023
|
return actionsMapRates(diff, oldObj, newObj);
|
|
5212
4024
|
}));
|
|
5213
|
-
return
|
|
4025
|
+
return flatten(allActions);
|
|
5214
4026
|
};
|
|
5215
4027
|
}
|
|
5216
4028
|
var taxCategories = (function (actionGroupList, syncActionConfig) {
|
|
@@ -5301,10 +4113,10 @@ function createZonesMapActions(mapActionGroup, syncActionConfig) {
|
|
|
5301
4113
|
allActions.push(mapActionGroup('base', function () {
|
|
5302
4114
|
return actionsMapBase$a(diff, oldObj, newObj, syncActionConfig);
|
|
5303
4115
|
}));
|
|
5304
|
-
allActions.push(
|
|
4116
|
+
allActions.push(flatten(mapActionGroup('locations', function () {
|
|
5305
4117
|
return actionsMapLocations(diff, oldObj, newObj);
|
|
5306
4118
|
})));
|
|
5307
|
-
return
|
|
4119
|
+
return flatten(allActions);
|
|
5308
4120
|
};
|
|
5309
4121
|
}
|
|
5310
4122
|
var zones = (function (actionGroupList, syncActionConfig) {
|
|
@@ -5420,7 +4232,7 @@ function actionsMapZoneRates(diff, oldObj, newObj) {
|
|
|
5420
4232
|
if (diff.zoneRates[key].shippingRates) return [].concat(_toConsumableArray(actions), _toConsumableArray(actionsMapZoneRatesShippingRates(diff.zoneRates[key], oldZoneRate, newZoneRate)));
|
|
5421
4233
|
return actions;
|
|
5422
4234
|
}, []);
|
|
5423
|
-
return
|
|
4235
|
+
return flatten(hasZoneActions ? [].concat(_toConsumableArray(shippingRateActions), [{
|
|
5424
4236
|
action: 'removeZone',
|
|
5425
4237
|
zone: oldZoneRate.zone
|
|
5426
4238
|
}, {
|
|
@@ -5437,13 +4249,13 @@ function createShippingMethodsMapActions(mapActionGroup, syncActionConfig) {
|
|
|
5437
4249
|
allActions.push(mapActionGroup('base', function () {
|
|
5438
4250
|
return actionsMapBase$9(diff, oldObj, newObj, syncActionConfig);
|
|
5439
4251
|
}));
|
|
5440
|
-
allActions.push(
|
|
4252
|
+
allActions.push(flatten(mapActionGroup('zoneRates', function () {
|
|
5441
4253
|
return actionsMapZoneRates(diff, oldObj, newObj);
|
|
5442
4254
|
})));
|
|
5443
4255
|
allActions.push(mapActionGroup('custom', function () {
|
|
5444
4256
|
return actionsMapCustom(diff, newObj, oldObj);
|
|
5445
4257
|
}));
|
|
5446
|
-
return
|
|
4258
|
+
return flatten(allActions);
|
|
5447
4259
|
};
|
|
5448
4260
|
}
|
|
5449
4261
|
var shippingMethods = (function (actionGroupList, syncActionConfig) {
|
|
@@ -5575,7 +4387,7 @@ var generateUpdateActionsForAttributeDefinitions = function generateUpdateAction
|
|
|
5575
4387
|
action: 'removeAttributeDefinition',
|
|
5576
4388
|
name: attributeDef.previous.name
|
|
5577
4389
|
};
|
|
5578
|
-
})), _toConsumableArray(
|
|
4390
|
+
})), _toConsumableArray(flatten(updatedAttributeDefinitions.map(function (updatedAttributeDefinition) {
|
|
5579
4391
|
return generateBaseFieldsUpdateActions(updatedAttributeDefinition.previous, updatedAttributeDefinition.next, {
|
|
5580
4392
|
label: {
|
|
5581
4393
|
action: 'changeLabel',
|
|
@@ -5625,7 +4437,7 @@ var generateUpdateActionsForAttributeEnumValues = function generateUpdateActions
|
|
|
5625
4437
|
return _objectSpread2(_objectSpread2({}, nextEnumUpdateActions), {}, _defineProperty({}, removedAttributeEnumValue.hint.attributeName, _objectSpread2(_objectSpread2({}, removedAttributeEnumValueOfSameAttributeName), {}, {
|
|
5626
4438
|
keys: [].concat(_toConsumableArray(removedAttributeEnumValueOfSameAttributeName.keys), [removedAttributeEnumValue.previous.key])
|
|
5627
4439
|
})));
|
|
5628
|
-
}, {}))), _toConsumableArray(
|
|
4440
|
+
}, {}))), _toConsumableArray(flatten(updatedAttributeEnumValues.map(function (updatedAttributeEnumValue) {
|
|
5629
4441
|
var updateActions = generateBaseFieldsUpdateActions(updatedAttributeEnumValue.previous, updatedAttributeEnumValue.next, {
|
|
5630
4442
|
key: {
|
|
5631
4443
|
action: 'changeEnumKey',
|
|
@@ -5699,7 +4511,7 @@ var actionsMapForHints = function actionsMapForHints() {
|
|
|
5699
4511
|
|
|
5700
4512
|
function createProductTypeMapActions(mapActionGroup, syncActionConfig) {
|
|
5701
4513
|
return function doMapActions(diff, next, previous, options) {
|
|
5702
|
-
return
|
|
4514
|
+
return flatten([
|
|
5703
4515
|
// we support only base fields for the product type,
|
|
5704
4516
|
// for attributes, applying hints would be recommended
|
|
5705
4517
|
mapActionGroup('base', function () {
|
|
@@ -5795,7 +4607,7 @@ function createStatesMapActions(mapActionGroup, syncActionConfig) {
|
|
|
5795
4607
|
roleActions.push(mapActionGroup('roles', function () {
|
|
5796
4608
|
return actionsMapRoles(diff, oldObj, newObj);
|
|
5797
4609
|
}));
|
|
5798
|
-
return
|
|
4610
|
+
return flatten([].concat(baseActions, _toConsumableArray(groupRoleActions(roleActions))));
|
|
5799
4611
|
};
|
|
5800
4612
|
}
|
|
5801
4613
|
var states = (function (actionGroupList, syncActionConfig) {
|
|
@@ -5848,7 +4660,7 @@ function createChannelsMapActions$1(mapActionGroup, syncActionConfig) {
|
|
|
5848
4660
|
allActions.push(mapActionGroup('custom', function () {
|
|
5849
4661
|
return actionsMapCustom(diff, newObj, oldObj);
|
|
5850
4662
|
}));
|
|
5851
|
-
return
|
|
4663
|
+
return flatten(allActions);
|
|
5852
4664
|
};
|
|
5853
4665
|
}
|
|
5854
4666
|
var channels = (function (actionGroupList) {
|
|
@@ -5919,7 +4731,7 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
|
|
|
5919
4731
|
var foundPreviousEnum = previous.values.find(function (previousEnum) {
|
|
5920
4732
|
return previousEnum.key === newEnum.key;
|
|
5921
4733
|
});
|
|
5922
|
-
var isLabelEqual =
|
|
4734
|
+
var isLabelEqual = isEqual(foundPreviousEnum.label, newEnum.label);
|
|
5923
4735
|
if (isKeyChanged) {
|
|
5924
4736
|
// these actions is then flatten in the end
|
|
5925
4737
|
changeActions.push({
|
|
@@ -5948,7 +4760,7 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
|
|
|
5948
4760
|
// following lists are necessary to ensure that when we change the
|
|
5949
4761
|
// order of enumValues, we generate one updateAction instead of one at a time.
|
|
5950
4762
|
var newEnumValuesOrder = [];
|
|
5951
|
-
|
|
4763
|
+
flatten(buildArrayActions(attributeDiff, previous, next)).forEach(function (updateAction) {
|
|
5952
4764
|
if (updateAction.action === changeEnumOrderActionName) {
|
|
5953
4765
|
newEnumValuesOrder = next.values.map(function (enumValue) {
|
|
5954
4766
|
return enumValue.key;
|
|
@@ -5963,7 +4775,7 @@ function actionsMapEnums(fieldName, attributeType, attributeDiff, previous, next
|
|
|
5963
4775
|
}
|
|
5964
4776
|
function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPaths) {
|
|
5965
4777
|
var actions = [];
|
|
5966
|
-
|
|
4778
|
+
forEach(fieldDefinitionsDiff, function (diffValue, diffKey) {
|
|
5967
4779
|
var extractedPairs = extractMatchingPairs(diffPaths, diffKey, previous, next);
|
|
5968
4780
|
if (getIsChangedOperation(diffKey)) {
|
|
5969
4781
|
var _diffValue$type;
|
|
@@ -6014,7 +4826,7 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
|
|
|
6014
4826
|
// in order to prevent any eventual removal of `addAction`.
|
|
6015
4827
|
// List of `removeActions` can be found here
|
|
6016
4828
|
// https://docs.commercetools.com/http-api-projects-types.html#change-key
|
|
6017
|
-
var sortedActions =
|
|
4829
|
+
var sortedActions = sortBy(actions, function (action) {
|
|
6018
4830
|
return action.action !== 'removeFieldDefinition';
|
|
6019
4831
|
});
|
|
6020
4832
|
return sortedActions;
|
|
@@ -6028,7 +4840,7 @@ function createTypeMapActions(mapActionGroup, syncActionConfig) {
|
|
|
6028
4840
|
}), mapActionGroup('fieldDefinitions', function () {
|
|
6029
4841
|
return actionsMapFieldDefinitions(diff.fieldDefinitions, previous.fieldDefinitions, next.fieldDefinitions, findMatchingPairs(diff.fieldDefinitions, previous.fieldDefinitions, next.fieldDefinitions, 'name'));
|
|
6030
4842
|
}));
|
|
6031
|
-
return
|
|
4843
|
+
return flatten(allActions);
|
|
6032
4844
|
};
|
|
6033
4845
|
}
|
|
6034
4846
|
var types = (function (actionGroupList, syncActionConfig) {
|
|
@@ -6130,7 +4942,7 @@ function createChannelsMapActions(mapActionGroup, syncActionConfig) {
|
|
|
6130
4942
|
allActions.push(mapActionGroup('searchIndexingConfiguration', function () {
|
|
6131
4943
|
return actionsMapSearchIndexingConfiguration(diff, oldObj, newObj);
|
|
6132
4944
|
}));
|
|
6133
|
-
return
|
|
4945
|
+
return flatten(allActions);
|
|
6134
4946
|
};
|
|
6135
4947
|
}
|
|
6136
4948
|
var projects = (function (actionGroupList) {
|
|
@@ -6178,7 +4990,7 @@ function createStoresMapActions(mapActionGroup) {
|
|
|
6178
4990
|
allActions.push(mapActionGroup('custom', function () {
|
|
6179
4991
|
return actionsMapCustom(diff, next, previous);
|
|
6180
4992
|
}));
|
|
6181
|
-
return
|
|
4993
|
+
return flatten(allActions);
|
|
6182
4994
|
};
|
|
6183
4995
|
}
|
|
6184
4996
|
var stores = (function (actionGroupList) {
|
|
@@ -6221,7 +5033,7 @@ function createProductSelectionsMapActions(mapActionGroup) {
|
|
|
6221
5033
|
allActions.push(mapActionGroup('custom', function () {
|
|
6222
5034
|
return actionsMapCustom(diff, next, previous);
|
|
6223
5035
|
}));
|
|
6224
|
-
return
|
|
5036
|
+
return flatten(allActions);
|
|
6225
5037
|
};
|
|
6226
5038
|
}
|
|
6227
5039
|
var productSelections = (function (actionGroupList) {
|
|
@@ -6356,10 +5168,10 @@ function createAttributeGroupsMapActions(mapActionGroup, syncActionConfig) {
|
|
|
6356
5168
|
allActions.push(mapActionGroup('base', function () {
|
|
6357
5169
|
return actionsMapBase(diff, oldObj, newObj, syncActionConfig);
|
|
6358
5170
|
}));
|
|
6359
|
-
allActions.push(
|
|
5171
|
+
allActions.push(flatten(mapActionGroup('attributes', function () {
|
|
6360
5172
|
return actionsMapAttributes(diff, oldObj, newObj);
|
|
6361
5173
|
})));
|
|
6362
|
-
return
|
|
5174
|
+
return flatten(allActions);
|
|
6363
5175
|
};
|
|
6364
5176
|
}
|
|
6365
5177
|
var attributeGroups = (function (actionGroupList, syncActionConfig) {
|