@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.
@@ -1,13 +1,11 @@
1
1
  import flatten from 'lodash.flatten';
2
2
  import isEqual from 'lodash.isequal';
3
3
  import isNil from 'lodash.isnil';
4
- import dmp from 'diff-match-patch';
5
- import chalk from 'chalk';
6
4
  import forEach from 'lodash.foreach';
7
5
  import uniqWith from 'lodash.uniqwith';
8
6
  import intersection from 'lodash.intersection';
9
7
  import without from 'lodash.without';
10
- import sortBy$1 from 'lodash.sortby';
8
+ import sortBy from 'lodash.sortby';
11
9
 
12
10
  function _arrayLikeToArray(r, a) {
13
11
  (null == a || a > r.length) && (a = r.length);
@@ -20,14 +18,69 @@ function _arrayWithHoles(r) {
20
18
  function _arrayWithoutHoles(r) {
21
19
  if (Array.isArray(r)) return _arrayLikeToArray(r);
22
20
  }
21
+ function _assertThisInitialized(e) {
22
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
23
+ return e;
24
+ }
25
+ function _callSuper(t, o, e) {
26
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, [], _getPrototypeOf(t).constructor) : o.apply(t, e));
27
+ }
28
+ function _classCallCheck(a, n) {
29
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
30
+ }
31
+ function _defineProperties(e, r) {
32
+ for (var t = 0; t < r.length; t++) {
33
+ var o = r[t];
34
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
35
+ }
36
+ }
37
+ function _createClass(e, r, t) {
38
+ return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
39
+ writable: false
40
+ }), e;
41
+ }
23
42
  function _defineProperty(e, r, t) {
24
43
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
25
44
  value: t,
26
- enumerable: !0,
27
- configurable: !0,
28
- writable: !0
45
+ enumerable: true,
46
+ configurable: true,
47
+ writable: true
29
48
  }) : e[r] = t, e;
30
49
  }
50
+ function _get() {
51
+ return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
52
+ var p = _superPropBase(e, t);
53
+ if (p) {
54
+ var n = Object.getOwnPropertyDescriptor(p, t);
55
+ return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
56
+ }
57
+ }, _get.apply(null, arguments);
58
+ }
59
+ function _getPrototypeOf(t) {
60
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
61
+ return t.__proto__ || Object.getPrototypeOf(t);
62
+ }, _getPrototypeOf(t);
63
+ }
64
+ function _inherits(t, e) {
65
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
66
+ t.prototype = Object.create(e && e.prototype, {
67
+ constructor: {
68
+ value: t,
69
+ writable: true,
70
+ configurable: true
71
+ }
72
+ }), Object.defineProperty(t, "prototype", {
73
+ writable: false
74
+ }), e && _setPrototypeOf(t, e);
75
+ }
76
+ function _isNativeReflectConstruct() {
77
+ try {
78
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
79
+ } catch (t) {}
80
+ return (_isNativeReflectConstruct = function () {
81
+ return !!t;
82
+ })();
83
+ }
31
84
  function _iterableToArray(r) {
32
85
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
33
86
  }
@@ -39,15 +92,15 @@ function _iterableToArrayLimit(r, l) {
39
92
  i,
40
93
  u,
41
94
  a = [],
42
- f = !0,
43
- o = !1;
95
+ f = true,
96
+ o = false;
44
97
  try {
45
98
  if (i = (t = t.call(r)).next, 0 === l) {
46
99
  if (Object(t) !== t) return;
47
100
  f = !1;
48
101
  } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
49
102
  } catch (r) {
50
- o = !0, n = r;
103
+ o = true, n = r;
51
104
  } finally {
52
105
  try {
53
106
  if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
@@ -77,7 +130,7 @@ function ownKeys(e, r) {
77
130
  function _objectSpread2(e) {
78
131
  for (var r = 1; r < arguments.length; r++) {
79
132
  var t = null != arguments[r] ? arguments[r] : {};
80
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
133
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
81
134
  _defineProperty(e, r, t[r]);
82
135
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
83
136
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
@@ -91,8 +144,8 @@ function _objectWithoutProperties(e, t) {
91
144
  r,
92
145
  i = _objectWithoutPropertiesLoose(e, t);
93
146
  if (Object.getOwnPropertySymbols) {
94
- var s = Object.getOwnPropertySymbols(e);
95
- for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
147
+ var n = Object.getOwnPropertySymbols(e);
148
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
96
149
  }
97
150
  return i;
98
151
  }
@@ -100,14 +153,34 @@ function _objectWithoutPropertiesLoose(r, e) {
100
153
  if (null == r) return {};
101
154
  var t = {};
102
155
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
103
- if (e.includes(n)) continue;
156
+ if (-1 !== e.indexOf(n)) continue;
104
157
  t[n] = r[n];
105
158
  }
106
159
  return t;
107
160
  }
161
+ function _possibleConstructorReturn(t, e) {
162
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
163
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
164
+ return _assertThisInitialized(t);
165
+ }
166
+ function _setPrototypeOf(t, e) {
167
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
168
+ return t.__proto__ = e, t;
169
+ }, _setPrototypeOf(t, e);
170
+ }
108
171
  function _slicedToArray(r, e) {
109
172
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
110
173
  }
174
+ function _superPropBase(t, o) {
175
+ for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)););
176
+ return t;
177
+ }
178
+ function _superPropGet(t, o, e, r) {
179
+ var p = _get(_getPrototypeOf(t.prototype ), o, e);
180
+ return 2 & r && "function" == typeof p ? function (t) {
181
+ return p.apply(e, t);
182
+ } : p;
183
+ }
111
184
  function _toConsumableArray(r) {
112
185
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
113
186
  }
@@ -115,24 +188,24 @@ function _toPrimitive(t, r) {
115
188
  if ("object" != typeof t || !t) return t;
116
189
  var e = t[Symbol.toPrimitive];
117
190
  if (void 0 !== e) {
118
- var i = e.call(t, r || "default");
191
+ var i = e.call(t, r);
119
192
  if ("object" != typeof i) return i;
120
193
  throw new TypeError("@@toPrimitive must return a primitive value.");
121
194
  }
122
- return ("string" === r ? String : Number)(t);
195
+ return (String )(t);
123
196
  }
124
197
  function _toPropertyKey(t) {
125
198
  var i = _toPrimitive(t, "string");
126
199
  return "symbol" == typeof i ? i : i + "";
127
200
  }
128
- function _typeof$1(o) {
201
+ function _typeof(o) {
129
202
  "@babel/helpers - typeof";
130
203
 
131
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
204
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
132
205
  return typeof o;
133
206
  } : function (o) {
134
207
  return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
135
- }, _typeof$1(o);
208
+ }, _typeof(o);
136
209
  }
137
210
  function _unsupportedIterableToArray(r, a) {
138
211
  if (r) {
@@ -233,129 +306,23 @@ function createMapActionGroup() {
233
306
  };
234
307
  }
235
308
 
236
- var _typeof = typeof Symbol === "function" && _typeof$1(Symbol.iterator) === "symbol" ? function (obj) {
237
- return _typeof$1(obj);
238
- } : function (obj) {
239
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof$1(obj);
240
- };
241
- var classCallCheck = function classCallCheck(instance, Constructor) {
242
- if (!(instance instanceof Constructor)) {
243
- throw new TypeError("Cannot call a class as a function");
244
- }
245
- };
246
- var createClass = function () {
247
- function defineProperties(target, props) {
248
- for (var i = 0; i < props.length; i++) {
249
- var descriptor = props[i];
250
- descriptor.enumerable = descriptor.enumerable || false;
251
- descriptor.configurable = true;
252
- if ("value" in descriptor) descriptor.writable = true;
253
- Object.defineProperty(target, descriptor.key, descriptor);
254
- }
255
- }
256
- return function (Constructor, protoProps, staticProps) {
257
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
258
- if (staticProps) defineProperties(Constructor, staticProps);
259
- return Constructor;
260
- };
261
- }();
262
- var get = function get(object, property, receiver) {
263
- if (object === null) object = Function.prototype;
264
- var desc = Object.getOwnPropertyDescriptor(object, property);
265
- if (desc === undefined) {
266
- var parent = Object.getPrototypeOf(object);
267
- if (parent === null) {
268
- return undefined;
269
- } else {
270
- return get(parent, property, receiver);
271
- }
272
- } else if ("value" in desc) {
273
- return desc.value;
274
- } else {
275
- var getter = desc.get;
276
- if (getter === undefined) {
277
- return undefined;
278
- }
279
- return getter.call(receiver);
280
- }
281
- };
282
- var inherits = function inherits(subClass, superClass) {
283
- if (typeof superClass !== "function" && superClass !== null) {
284
- throw new TypeError("Super expression must either be null or a function, not " + _typeof$1(superClass));
285
- }
286
- subClass.prototype = Object.create(superClass && superClass.prototype, {
287
- constructor: {
288
- value: subClass,
289
- enumerable: false,
290
- writable: true,
291
- configurable: true
292
- }
293
- });
294
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
295
- };
296
- var possibleConstructorReturn = function possibleConstructorReturn(self, call) {
297
- if (!self) {
298
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
299
- }
300
- return call && (_typeof$1(call) === "object" || typeof call === "function") ? call : self;
301
- };
302
- var slicedToArray = function () {
303
- function sliceIterator(arr, i) {
304
- var _arr = [];
305
- var _n = true;
306
- var _d = false;
307
- var _e = undefined;
308
- try {
309
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
310
- _arr.push(_s.value);
311
- if (i && _arr.length === i) break;
312
- }
313
- } catch (err) {
314
- _d = true;
315
- _e = err;
316
- } finally {
317
- try {
318
- if (!_n && _i["return"]) _i["return"]();
319
- } finally {
320
- if (_d) throw _e;
321
- }
322
- }
323
- return _arr;
324
- }
325
- return function (arr, i) {
326
- if (Array.isArray(arr)) {
327
- return arr;
328
- } else if (Symbol.iterator in Object(arr)) {
329
- return sliceIterator(arr, i);
330
- } else {
331
- throw new TypeError("Invalid attempt to destructure non-iterable instance");
332
- }
333
- };
334
- }();
335
- var toConsumableArray = function toConsumableArray(arr) {
336
- if (Array.isArray(arr)) {
337
- for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
338
- return arr2;
339
- } else {
340
- return Array.from(arr);
341
- }
342
- };
343
- var Processor = function () {
309
+ var Processor = /*#__PURE__*/function () {
344
310
  function Processor(options) {
345
- classCallCheck(this, Processor);
311
+ _classCallCheck(this, Processor);
346
312
  this.selfOptions = options || {};
347
313
  this.pipes = {};
348
314
  }
349
- createClass(Processor, [{
350
- key: 'options',
315
+ return _createClass(Processor, [{
316
+ key: "options",
351
317
  value: function options(_options) {
352
318
  if (_options) {
353
319
  this.selfOptions = _options;
354
320
  }
355
321
  return this.selfOptions;
356
322
  }
323
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
357
324
  }, {
358
- key: 'pipe',
325
+ key: "pipe",
359
326
  value: function pipe(name, pipeArg) {
360
327
  var pipe = pipeArg;
361
328
  if (typeof name === 'string') {
@@ -366,6 +333,7 @@ var Processor = function () {
366
333
  }
367
334
  }
368
335
  if (name && name.name) {
336
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
369
337
  pipe = name;
370
338
  if (pipe.processor === this) {
371
339
  return pipe;
@@ -375,14 +343,14 @@ var Processor = function () {
375
343
  pipe.processor = this;
376
344
  return pipe;
377
345
  }
346
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
378
347
  }, {
379
- key: 'process',
348
+ key: "process",
380
349
  value: function process(input, pipe) {
381
350
  var context = input;
382
351
  context.options = this.options();
383
352
  var nextPipe = pipe || input.pipe || 'default';
384
- var lastPipe = void 0;
385
- var lastContext = void 0;
353
+ var lastPipe;
386
354
  while (nextPipe) {
387
355
  if (typeof context.nextAfterChildren !== 'undefined') {
388
356
  // children processed and coming back to parent
@@ -393,29 +361,30 @@ var Processor = function () {
393
361
  nextPipe = this.pipe(nextPipe);
394
362
  }
395
363
  nextPipe.process(context);
396
- lastContext = context;
397
364
  lastPipe = nextPipe;
398
365
  nextPipe = null;
399
366
  if (context) {
400
367
  if (context.next) {
401
368
  context = context.next;
402
- nextPipe = lastContext.nextPipe || context.pipe || lastPipe;
369
+ nextPipe = context.pipe || lastPipe;
403
370
  }
404
371
  }
405
372
  }
373
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
406
374
  return context.hasResult ? context.result : undefined;
407
375
  }
408
376
  }]);
409
- return Processor;
410
377
  }();
411
- var Pipe = function () {
378
+
379
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
380
+ var Pipe = /*#__PURE__*/function () {
412
381
  function Pipe(name) {
413
- classCallCheck(this, Pipe);
382
+ _classCallCheck(this, Pipe);
414
383
  this.name = name;
415
384
  this.filters = [];
416
385
  }
417
- createClass(Pipe, [{
418
- key: 'process',
386
+ return _createClass(Pipe, [{
387
+ key: "process",
419
388
  value: function process(input) {
420
389
  if (!this.processor) {
421
390
  throw new Error('add this pipe to a processor before using it');
@@ -426,10 +395,10 @@ var Pipe = function () {
426
395
  for (var index = 0; index < length; index++) {
427
396
  var filter = this.filters[index];
428
397
  if (debug) {
429
- this.log('filter: ' + filter.filterName);
398
+ this.log("filter: ".concat(filter.filterName));
430
399
  }
431
400
  filter(context);
432
- if ((typeof context === 'undefined' ? 'undefined' : _typeof(context)) === 'object' && context.exiting) {
401
+ if (_typeof(context) === 'object' && context.exiting) {
433
402
  context.exiting = false;
434
403
  break;
435
404
  }
@@ -439,26 +408,26 @@ var Pipe = function () {
439
408
  }
440
409
  }
441
410
  }, {
442
- key: 'log',
411
+ key: "log",
443
412
  value: function log(msg) {
444
- console.log('[jsondiffpatch] ' + this.name + ' pipe, ' + msg);
413
+ console.log("[jsondiffpatch] ".concat(this.name, " pipe, ").concat(msg));
445
414
  }
446
415
  }, {
447
- key: 'append',
416
+ key: "append",
448
417
  value: function append() {
449
- var _filters;
450
- (_filters = this.filters).push.apply(_filters, arguments);
418
+ var _this$filters;
419
+ (_this$filters = this.filters).push.apply(_this$filters, arguments);
451
420
  return this;
452
421
  }
453
422
  }, {
454
- key: 'prepend',
423
+ key: "prepend",
455
424
  value: function prepend() {
456
- var _filters2;
457
- (_filters2 = this.filters).unshift.apply(_filters2, arguments);
425
+ var _this$filters2;
426
+ (_this$filters2 = this.filters).unshift.apply(_this$filters2, arguments);
458
427
  return this;
459
428
  }
460
429
  }, {
461
- key: 'indexOf',
430
+ key: "indexOf",
462
431
  value: function indexOf(filterName) {
463
432
  if (!filterName) {
464
433
  throw new Error('a filter name is required');
@@ -469,67 +438,65 @@ var Pipe = function () {
469
438
  return index;
470
439
  }
471
440
  }
472
- throw new Error('filter not found: ' + filterName);
441
+ throw new Error("filter not found: ".concat(filterName));
473
442
  }
474
443
  }, {
475
- key: 'list',
444
+ key: "list",
476
445
  value: function list() {
477
446
  return this.filters.map(function (f) {
478
447
  return f.filterName;
479
448
  });
480
449
  }
481
450
  }, {
482
- key: 'after',
451
+ key: "after",
483
452
  value: function after(filterName) {
453
+ var _this$filters3;
484
454
  var index = this.indexOf(filterName);
485
- var params = Array.prototype.slice.call(arguments, 1);
486
- if (!params.length) {
487
- throw new Error('a filter is required');
455
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
456
+ params[_key - 1] = arguments[_key];
488
457
  }
489
- params.unshift(index + 1, 0);
490
- Array.prototype.splice.apply(this.filters, params);
458
+ (_this$filters3 = this.filters).splice.apply(_this$filters3, [index + 1, 0].concat(params));
491
459
  return this;
492
460
  }
493
461
  }, {
494
- key: 'before',
462
+ key: "before",
495
463
  value: function before(filterName) {
464
+ var _this$filters4;
496
465
  var index = this.indexOf(filterName);
497
- var params = Array.prototype.slice.call(arguments, 1);
498
- if (!params.length) {
499
- throw new Error('a filter is required');
466
+ for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
467
+ params[_key2 - 1] = arguments[_key2];
500
468
  }
501
- params.unshift(index, 0);
502
- Array.prototype.splice.apply(this.filters, params);
469
+ (_this$filters4 = this.filters).splice.apply(_this$filters4, [index, 0].concat(params));
503
470
  return this;
504
471
  }
505
472
  }, {
506
- key: 'replace',
473
+ key: "replace",
507
474
  value: function replace(filterName) {
475
+ var _this$filters5;
508
476
  var index = this.indexOf(filterName);
509
- var params = Array.prototype.slice.call(arguments, 1);
510
- if (!params.length) {
511
- throw new Error('a filter is required');
477
+ for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
478
+ params[_key3 - 1] = arguments[_key3];
512
479
  }
513
- params.unshift(index, 1);
514
- Array.prototype.splice.apply(this.filters, params);
480
+ (_this$filters5 = this.filters).splice.apply(_this$filters5, [index, 1].concat(params));
515
481
  return this;
516
482
  }
517
483
  }, {
518
- key: 'remove',
484
+ key: "remove",
519
485
  value: function remove(filterName) {
520
486
  var index = this.indexOf(filterName);
521
487
  this.filters.splice(index, 1);
522
488
  return this;
523
489
  }
524
490
  }, {
525
- key: 'clear',
491
+ key: "clear",
526
492
  value: function clear() {
527
493
  this.filters.length = 0;
528
494
  return this;
529
495
  }
530
496
  }, {
531
- key: 'shouldHaveResult',
497
+ key: "shouldHaveResult",
532
498
  value: function shouldHaveResult(should) {
499
+ var _this = this;
533
500
  if (should === false) {
534
501
  this.resultCheck = null;
535
502
  return;
@@ -537,11 +504,10 @@ var Pipe = function () {
537
504
  if (this.resultCheck) {
538
505
  return;
539
506
  }
540
- var pipe = this;
541
507
  this.resultCheck = function (context) {
542
508
  if (!context.hasResult) {
543
509
  console.log(context);
544
- var error = new Error(pipe.name + ' failed');
510
+ var error = new Error("".concat(_this.name, " failed"));
545
511
  error.noResult = true;
546
512
  throw error;
547
513
  }
@@ -549,40 +515,27 @@ var Pipe = function () {
549
515
  return this;
550
516
  }
551
517
  }]);
552
- return Pipe;
553
518
  }();
554
- var Context = function () {
519
+
520
+ var Context = /*#__PURE__*/function () {
555
521
  function Context() {
556
- classCallCheck(this, Context);
522
+ _classCallCheck(this, Context);
557
523
  }
558
- createClass(Context, [{
559
- key: 'setResult',
524
+ return _createClass(Context, [{
525
+ key: "setResult",
560
526
  value: function setResult(result) {
561
527
  this.result = result;
562
528
  this.hasResult = true;
563
529
  return this;
564
530
  }
565
531
  }, {
566
- key: 'exit',
532
+ key: "exit",
567
533
  value: function exit() {
568
534
  this.exiting = true;
569
535
  return this;
570
536
  }
571
537
  }, {
572
- key: 'switchTo',
573
- value: function switchTo(next, pipe) {
574
- if (typeof next === 'string' || next instanceof Pipe) {
575
- this.nextPipe = next;
576
- } else {
577
- this.next = next;
578
- if (pipe) {
579
- this.nextPipe = pipe;
580
- }
581
- }
582
- return this;
583
- }
584
- }, {
585
- key: 'push',
538
+ key: "push",
586
539
  value: function push(child, name) {
587
540
  child.parent = this;
588
541
  if (typeof name !== 'undefined') {
@@ -602,23 +555,20 @@ var Context = function () {
602
555
  return this;
603
556
  }
604
557
  }]);
605
- return Context;
606
558
  }();
607
- var isArray = typeof Array.isArray === 'function' ? Array.isArray : function (a) {
608
- return a instanceof Array;
609
- };
559
+
610
560
  function cloneRegExp(re) {
611
561
  var regexMatch = /^\/(.*)\/([gimyu]*)$/.exec(re.toString());
612
562
  return new RegExp(regexMatch[1], regexMatch[2]);
613
563
  }
614
564
  function clone$1(arg) {
615
- if ((typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) !== 'object') {
565
+ if (_typeof(arg) !== 'object') {
616
566
  return arg;
617
567
  }
618
568
  if (arg === null) {
619
569
  return null;
620
570
  }
621
- if (isArray(arg)) {
571
+ if (Array.isArray(arg)) {
622
572
  return arg.map(clone$1);
623
573
  }
624
574
  if (arg instanceof Date) {
@@ -635,60 +585,63 @@ function clone$1(arg) {
635
585
  }
636
586
  return cloned;
637
587
  }
638
- var DiffContext = function (_Context) {
639
- inherits(DiffContext, _Context);
588
+
589
+ var DiffContext = /*#__PURE__*/function (_Context) {
640
590
  function DiffContext(left, right) {
641
- classCallCheck(this, DiffContext);
642
- var _this = possibleConstructorReturn(this, (DiffContext.__proto__ || Object.getPrototypeOf(DiffContext)).call(this));
591
+ var _this;
592
+ _classCallCheck(this, DiffContext);
593
+ _this = _callSuper(this, DiffContext);
643
594
  _this.left = left;
644
595
  _this.right = right;
645
596
  _this.pipe = 'diff';
646
597
  return _this;
647
598
  }
648
- createClass(DiffContext, [{
649
- key: 'setResult',
599
+ _inherits(DiffContext, _Context);
600
+ return _createClass(DiffContext, [{
601
+ key: "setResult",
650
602
  value: function setResult(result) {
651
- if (this.options.cloneDiffValues && (typeof result === 'undefined' ? 'undefined' : _typeof(result)) === 'object') {
652
- var clone$$1 = typeof this.options.cloneDiffValues === 'function' ? this.options.cloneDiffValues : clone$1;
603
+ if (this.options.cloneDiffValues && _typeof(result) === 'object') {
604
+ var clone = typeof this.options.cloneDiffValues === 'function' ? this.options.cloneDiffValues : clone$1;
653
605
  if (_typeof(result[0]) === 'object') {
654
- result[0] = clone$$1(result[0]);
606
+ result[0] = clone(result[0]);
655
607
  }
656
608
  if (_typeof(result[1]) === 'object') {
657
- result[1] = clone$$1(result[1]);
609
+ result[1] = clone(result[1]);
658
610
  }
659
611
  }
660
- return Context.prototype.setResult.apply(this, arguments);
612
+ return _superPropGet(DiffContext, "setResult", this, 3)([result]);
661
613
  }
662
614
  }]);
663
- return DiffContext;
664
615
  }(Context);
665
- var PatchContext = function (_Context) {
666
- inherits(PatchContext, _Context);
616
+
617
+ var PatchContext = /*#__PURE__*/function (_Context) {
667
618
  function PatchContext(left, delta) {
668
- classCallCheck(this, PatchContext);
669
- var _this = possibleConstructorReturn(this, (PatchContext.__proto__ || Object.getPrototypeOf(PatchContext)).call(this));
619
+ var _this;
620
+ _classCallCheck(this, PatchContext);
621
+ _this = _callSuper(this, PatchContext);
670
622
  _this.left = left;
671
623
  _this.delta = delta;
672
624
  _this.pipe = 'patch';
673
625
  return _this;
674
626
  }
675
- return PatchContext;
627
+ _inherits(PatchContext, _Context);
628
+ return _createClass(PatchContext);
676
629
  }(Context);
677
- var ReverseContext = function (_Context) {
678
- inherits(ReverseContext, _Context);
630
+
631
+ var ReverseContext = /*#__PURE__*/function (_Context) {
679
632
  function ReverseContext(delta) {
680
- classCallCheck(this, ReverseContext);
681
- var _this = possibleConstructorReturn(this, (ReverseContext.__proto__ || Object.getPrototypeOf(ReverseContext)).call(this));
633
+ var _this;
634
+ _classCallCheck(this, ReverseContext);
635
+ _this = _callSuper(this, ReverseContext);
682
636
  _this.delta = delta;
683
637
  _this.pipe = 'reverse';
684
638
  return _this;
685
639
  }
686
- return ReverseContext;
640
+ _inherits(ReverseContext, _Context);
641
+ return _createClass(ReverseContext);
687
642
  }(Context);
688
- var isArray$1 = typeof Array.isArray === 'function' ? Array.isArray : function (a) {
689
- return a instanceof Array;
690
- };
691
- var diffFilter = function trivialMatchesDiffFilter(context) {
643
+
644
+ var diffFilter$3 = function trivialMatchesDiffFilter(context) {
692
645
  if (context.left === context.right) {
693
646
  context.setResult(undefined).exit();
694
647
  return;
@@ -718,10 +671,10 @@ var diffFilter = function trivialMatchesDiffFilter(context) {
718
671
  return;
719
672
  }
720
673
  if (context.leftType === 'object') {
721
- context.leftIsArray = isArray$1(context.left);
674
+ context.leftIsArray = Array.isArray(context.left);
722
675
  }
723
676
  if (context.rightType === 'object') {
724
- context.rightIsArray = isArray$1(context.right);
677
+ context.rightIsArray = Array.isArray(context.right);
725
678
  }
726
679
  if (context.leftIsArray !== context.rightIsArray) {
727
680
  context.setResult([context.left, context.right]).exit();
@@ -735,64 +688,67 @@ var diffFilter = function trivialMatchesDiffFilter(context) {
735
688
  }
736
689
  }
737
690
  };
738
- diffFilter.filterName = 'trivial';
739
- var patchFilter = function trivialMatchesPatchFilter(context) {
691
+ diffFilter$3.filterName = 'trivial';
692
+ var patchFilter$3 = function trivialMatchesPatchFilter(context) {
740
693
  if (typeof context.delta === 'undefined') {
741
694
  context.setResult(context.left).exit();
742
695
  return;
743
696
  }
744
- context.nested = !isArray$1(context.delta);
697
+ context.nested = !Array.isArray(context.delta);
745
698
  if (context.nested) {
746
699
  return;
747
700
  }
748
- if (context.delta.length === 1) {
749
- context.setResult(context.delta[0]).exit();
701
+ var nonNestedDelta = context.delta;
702
+ if (nonNestedDelta.length === 1) {
703
+ context.setResult(nonNestedDelta[0]).exit();
750
704
  return;
751
705
  }
752
- if (context.delta.length === 2) {
706
+ if (nonNestedDelta.length === 2) {
753
707
  if (context.left instanceof RegExp) {
754
- var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(context.delta[1]);
708
+ var regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(nonNestedDelta[1]);
755
709
  if (regexArgs) {
756
710
  context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
757
711
  return;
758
712
  }
759
713
  }
760
- context.setResult(context.delta[1]).exit();
714
+ context.setResult(nonNestedDelta[1]).exit();
761
715
  return;
762
716
  }
763
- if (context.delta.length === 3 && context.delta[2] === 0) {
717
+ if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
764
718
  context.setResult(undefined).exit();
765
719
  }
766
720
  };
767
- patchFilter.filterName = 'trivial';
768
- var reverseFilter = function trivialReferseFilter(context) {
721
+ patchFilter$3.filterName = 'trivial';
722
+ var reverseFilter$3 = function trivialReferseFilter(context) {
769
723
  if (typeof context.delta === 'undefined') {
770
724
  context.setResult(context.delta).exit();
771
725
  return;
772
726
  }
773
- context.nested = !isArray$1(context.delta);
727
+ context.nested = !Array.isArray(context.delta);
774
728
  if (context.nested) {
775
729
  return;
776
730
  }
777
- if (context.delta.length === 1) {
778
- context.setResult([context.delta[0], 0, 0]).exit();
731
+ var nonNestedDelta = context.delta;
732
+ if (nonNestedDelta.length === 1) {
733
+ context.setResult([nonNestedDelta[0], 0, 0]).exit();
779
734
  return;
780
735
  }
781
- if (context.delta.length === 2) {
782
- context.setResult([context.delta[1], context.delta[0]]).exit();
736
+ if (nonNestedDelta.length === 2) {
737
+ context.setResult([nonNestedDelta[1], nonNestedDelta[0]]).exit();
783
738
  return;
784
739
  }
785
- if (context.delta.length === 3 && context.delta[2] === 0) {
786
- context.setResult([context.delta[0]]).exit();
740
+ if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
741
+ context.setResult([nonNestedDelta[0]]).exit();
787
742
  }
788
743
  };
789
- reverseFilter.filterName = 'trivial';
790
- function collectChildrenDiffFilter(context) {
744
+ reverseFilter$3.filterName = 'trivial';
745
+
746
+ var collectChildrenDiffFilter = function collectChildrenDiffFilter(context) {
791
747
  if (!context || !context.children) {
792
748
  return;
793
749
  }
794
750
  var length = context.children.length;
795
- var child = void 0;
751
+ var child;
796
752
  var result = context.result;
797
753
  for (var index = 0; index < length; index++) {
798
754
  child = context.children[index];
@@ -806,34 +762,36 @@ function collectChildrenDiffFilter(context) {
806
762
  result._t = 'a';
807
763
  }
808
764
  context.setResult(result).exit();
809
- }
765
+ };
810
766
  collectChildrenDiffFilter.filterName = 'collectChildren';
811
- function objectsDiffFilter(context) {
767
+ var objectsDiffFilter = function objectsDiffFilter(context) {
812
768
  if (context.leftIsArray || context.leftType !== 'object') {
813
769
  return;
814
770
  }
815
- var name = void 0;
816
- var child = void 0;
771
+ var left = context.left;
772
+ var right = context.right;
773
+ var name;
774
+ var child;
817
775
  var propertyFilter = context.options.propertyFilter;
818
- for (name in context.left) {
819
- if (!Object.prototype.hasOwnProperty.call(context.left, name)) {
776
+ for (name in left) {
777
+ if (!Object.prototype.hasOwnProperty.call(left, name)) {
820
778
  continue;
821
779
  }
822
780
  if (propertyFilter && !propertyFilter(name, context)) {
823
781
  continue;
824
782
  }
825
- child = new DiffContext(context.left[name], context.right[name]);
783
+ child = new DiffContext(left[name], right[name]);
826
784
  context.push(child, name);
827
785
  }
828
- for (name in context.right) {
829
- if (!Object.prototype.hasOwnProperty.call(context.right, name)) {
786
+ for (name in right) {
787
+ if (!Object.prototype.hasOwnProperty.call(right, name)) {
830
788
  continue;
831
789
  }
832
790
  if (propertyFilter && !propertyFilter(name, context)) {
833
791
  continue;
834
792
  }
835
- if (typeof context.left[name] === 'undefined') {
836
- child = new DiffContext(undefined, context.right[name]);
793
+ if (typeof left[name] === 'undefined') {
794
+ child = new DiffContext(undefined, right[name]);
837
795
  context.push(child, name);
838
796
  }
839
797
  }
@@ -842,79 +800,88 @@ function objectsDiffFilter(context) {
842
800
  return;
843
801
  }
844
802
  context.exit();
845
- }
803
+ };
846
804
  objectsDiffFilter.filterName = 'objects';
847
- var patchFilter$1 = function nestedPatchFilter(context) {
805
+ var patchFilter$2 = function nestedPatchFilter(context) {
848
806
  if (!context.nested) {
849
807
  return;
850
808
  }
851
- if (context.delta._t) {
809
+ var nestedDelta = context.delta;
810
+ if (nestedDelta._t) {
852
811
  return;
853
812
  }
854
- var name = void 0;
855
- var child = void 0;
856
- for (name in context.delta) {
857
- child = new PatchContext(context.left[name], context.delta[name]);
813
+ var objectDelta = nestedDelta;
814
+ var name;
815
+ var child;
816
+ for (name in objectDelta) {
817
+ child = new PatchContext(context.left[name], objectDelta[name]);
858
818
  context.push(child, name);
859
819
  }
860
820
  context.exit();
861
821
  };
862
- patchFilter$1.filterName = 'objects';
863
- var collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
822
+ patchFilter$2.filterName = 'objects';
823
+ var collectChildrenPatchFilter$1 = function collectChildrenPatchFilter(context) {
864
824
  if (!context || !context.children) {
865
825
  return;
866
826
  }
867
- if (context.delta._t) {
827
+ var deltaWithChildren = context.delta;
828
+ if (deltaWithChildren._t) {
868
829
  return;
869
830
  }
831
+ var object = context.left;
870
832
  var length = context.children.length;
871
- var child = void 0;
833
+ var child;
872
834
  for (var index = 0; index < length; index++) {
873
835
  child = context.children[index];
874
- if (Object.prototype.hasOwnProperty.call(context.left, child.childName) && child.result === undefined) {
875
- delete context.left[child.childName];
876
- } else if (context.left[child.childName] !== child.result) {
877
- context.left[child.childName] = child.result;
836
+ var property = child.childName;
837
+ if (Object.prototype.hasOwnProperty.call(context.left, property) && child.result === undefined) {
838
+ delete object[property];
839
+ } else if (object[property] !== child.result) {
840
+ object[property] = child.result;
878
841
  }
879
842
  }
880
- context.setResult(context.left).exit();
843
+ context.setResult(object).exit();
881
844
  };
882
- collectChildrenPatchFilter.filterName = 'collectChildren';
883
- var reverseFilter$1 = function nestedReverseFilter(context) {
845
+ collectChildrenPatchFilter$1.filterName = 'collectChildren';
846
+ var reverseFilter$2 = function nestedReverseFilter(context) {
884
847
  if (!context.nested) {
885
848
  return;
886
849
  }
887
- if (context.delta._t) {
850
+ var nestedDelta = context.delta;
851
+ if (nestedDelta._t) {
888
852
  return;
889
853
  }
890
- var name = void 0;
891
- var child = void 0;
892
- for (name in context.delta) {
893
- child = new ReverseContext(context.delta[name]);
854
+ var objectDelta = context.delta;
855
+ var name;
856
+ var child;
857
+ for (name in objectDelta) {
858
+ child = new ReverseContext(objectDelta[name]);
894
859
  context.push(child, name);
895
860
  }
896
861
  context.exit();
897
862
  };
898
- reverseFilter$1.filterName = 'objects';
899
- function collectChildrenReverseFilter(context) {
863
+ reverseFilter$2.filterName = 'objects';
864
+ var collectChildrenReverseFilter$1 = function collectChildrenReverseFilter(context) {
900
865
  if (!context || !context.children) {
901
866
  return;
902
867
  }
903
- if (context.delta._t) {
868
+ var deltaWithChildren = context.delta;
869
+ if (deltaWithChildren._t) {
904
870
  return;
905
871
  }
906
872
  var length = context.children.length;
907
- var child = void 0;
873
+ var child;
908
874
  var delta = {};
909
875
  for (var index = 0; index < length; index++) {
910
876
  child = context.children[index];
911
- if (delta[child.childName] !== child.result) {
912
- delta[child.childName] = child.result;
877
+ var property = child.childName;
878
+ if (delta[property] !== child.result) {
879
+ delta[property] = child.result;
913
880
  }
914
881
  }
915
882
  context.setResult(delta).exit();
916
- }
917
- collectChildrenReverseFilter.filterName = 'collectChildren';
883
+ };
884
+ collectChildrenReverseFilter$1.filterName = 'collectChildren';
918
885
 
919
886
  /*
920
887
 
@@ -923,20 +890,17 @@ LCS implementation that supports arrays or strings
923
890
  reference: http://en.wikipedia.org/wiki/Longest_common_subsequence_problem
924
891
 
925
892
  */
926
-
927
893
  var defaultMatch = function defaultMatch(array1, array2, index1, index2) {
928
894
  return array1[index1] === array2[index2];
929
895
  };
930
896
  var lengthMatrix = function lengthMatrix(array1, array2, match, context) {
931
897
  var len1 = array1.length;
932
898
  var len2 = array2.length;
933
- var x = void 0,
934
- y = void 0;
935
-
899
+ var x, y;
936
900
  // initialize empty matrix of len1+1 x len2+1
937
- var matrix = [len1 + 1];
901
+ var matrix = new Array(len1 + 1);
938
902
  for (x = 0; x < len1 + 1; x++) {
939
- matrix[x] = [len2 + 1];
903
+ matrix[x] = new Array(len2 + 1);
940
904
  for (y = 0; y < len2 + 1; y++) {
941
905
  matrix[x][y] = 0;
942
906
  }
@@ -982,33 +946,16 @@ var backtrack = function backtrack(matrix, array1, array2, context) {
982
946
  }
983
947
  return subsequence;
984
948
  };
985
- var get$1 = function get(array1, array2, match, context) {
949
+ var get = function get(array1, array2, match, context) {
986
950
  var innerContext = context || {};
987
951
  var matrix = lengthMatrix(array1, array2, match || defaultMatch, innerContext);
988
- var result = backtrack(matrix, array1, array2, innerContext);
989
- if (typeof array1 === 'string' && typeof array2 === 'string') {
990
- result.sequence = result.sequence.join('');
991
- }
992
- return result;
952
+ return backtrack(matrix, array1, array2, innerContext);
993
953
  };
994
954
  var lcs = {
995
- get: get$1
955
+ get: get
996
956
  };
957
+
997
958
  var ARRAY_MOVE = 3;
998
- var isArray$2 = typeof Array.isArray === 'function' ? Array.isArray : function (a) {
999
- return a instanceof Array;
1000
- };
1001
- var arrayIndexOf = typeof Array.prototype.indexOf === 'function' ? function (array, item) {
1002
- return array.indexOf(item);
1003
- } : function (array, item) {
1004
- var length = array.length;
1005
- for (var i = 0; i < length; i++) {
1006
- if (array[i] === item) {
1007
- return i;
1008
- }
1009
- }
1010
- return -1;
1011
- };
1012
959
  function arraysHaveMatchByRef(array1, array2, len1, len2) {
1013
960
  for (var index1 = 0; index1 < len1; index1++) {
1014
961
  var val1 = array1[index1];
@@ -1026,7 +973,7 @@ function matchItems(array1, array2, index1, index2, context) {
1026
973
  if (value1 === value2) {
1027
974
  return true;
1028
975
  }
1029
- if ((typeof value1 === 'undefined' ? 'undefined' : _typeof(value1)) !== 'object' || (typeof value2 === 'undefined' ? 'undefined' : _typeof(value2)) !== 'object') {
976
+ if (_typeof(value1) !== 'object' || _typeof(value2) !== 'object') {
1030
977
  return false;
1031
978
  }
1032
979
  var objectHash = context.objectHash;
@@ -1034,35 +981,25 @@ function matchItems(array1, array2, index1, index2, context) {
1034
981
  // no way to match objects was provided, try match by position
1035
982
  return context.matchByPosition && index1 === index2;
1036
983
  }
1037
- var hash1 = void 0;
1038
- var hash2 = void 0;
1039
- if (typeof index1 === 'number') {
1040
- context.hashCache1 = context.hashCache1 || [];
1041
- hash1 = context.hashCache1[index1];
1042
- if (typeof hash1 === 'undefined') {
1043
- context.hashCache1[index1] = hash1 = objectHash(value1, index1);
1044
- }
1045
- } else {
1046
- hash1 = objectHash(value1);
984
+ context.hashCache1 = context.hashCache1 || [];
985
+ var hash1 = context.hashCache1[index1];
986
+ if (typeof hash1 === 'undefined') {
987
+ context.hashCache1[index1] = hash1 = objectHash(value1, index1);
1047
988
  }
1048
989
  if (typeof hash1 === 'undefined') {
1049
990
  return false;
1050
991
  }
1051
- if (typeof index2 === 'number') {
1052
- context.hashCache2 = context.hashCache2 || [];
1053
- hash2 = context.hashCache2[index2];
1054
- if (typeof hash2 === 'undefined') {
1055
- context.hashCache2[index2] = hash2 = objectHash(value2, index2);
1056
- }
1057
- } else {
1058
- hash2 = objectHash(value2);
992
+ context.hashCache2 = context.hashCache2 || [];
993
+ var hash2 = context.hashCache2[index2];
994
+ if (typeof hash2 === 'undefined') {
995
+ context.hashCache2[index2] = hash2 = objectHash(value2, index2);
1059
996
  }
1060
997
  if (typeof hash2 === 'undefined') {
1061
998
  return false;
1062
999
  }
1063
1000
  return hash1 === hash2;
1064
1001
  }
1065
- var diffFilter$1 = function arraysDiffFilter(context) {
1002
+ var diffFilter$2 = function arraysDiffFilter(context) {
1066
1003
  if (!context.leftIsArray) {
1067
1004
  return;
1068
1005
  }
@@ -1072,22 +1009,21 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1072
1009
  };
1073
1010
  var commonHead = 0;
1074
1011
  var commonTail = 0;
1075
- var index = void 0;
1076
- var index1 = void 0;
1077
- var index2 = void 0;
1012
+ var index;
1013
+ var index1;
1014
+ var index2;
1078
1015
  var array1 = context.left;
1079
1016
  var array2 = context.right;
1080
1017
  var len1 = array1.length;
1081
1018
  var len2 = array2.length;
1082
- var child = void 0;
1019
+ var child;
1083
1020
  if (len1 > 0 && len2 > 0 && !matchContext.objectHash && typeof matchContext.matchByPosition !== 'boolean') {
1084
1021
  matchContext.matchByPosition = !arraysHaveMatchByRef(array1, array2, len1, len2);
1085
1022
  }
1086
-
1087
1023
  // separate common head
1088
1024
  while (commonHead < len1 && commonHead < len2 && matchItems(array1, array2, commonHead, commonHead, matchContext)) {
1089
1025
  index = commonHead;
1090
- child = new DiffContext(context.left[index], context.right[index]);
1026
+ child = new DiffContext(array1[index], array2[index]);
1091
1027
  context.push(child, index);
1092
1028
  commonHead++;
1093
1029
  }
@@ -1095,11 +1031,11 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1095
1031
  while (commonTail + commonHead < len1 && commonTail + commonHead < len2 && matchItems(array1, array2, len1 - 1 - commonTail, len2 - 1 - commonTail, matchContext)) {
1096
1032
  index1 = len1 - 1 - commonTail;
1097
1033
  index2 = len2 - 1 - commonTail;
1098
- child = new DiffContext(context.left[index1], context.right[index2]);
1034
+ child = new DiffContext(array1[index1], array2[index2]);
1099
1035
  context.push(child, index2);
1100
1036
  commonTail++;
1101
1037
  }
1102
- var result = void 0;
1038
+ var result;
1103
1039
  if (commonHead + commonTail === len1) {
1104
1040
  if (len1 === len2) {
1105
1041
  // arrays are identical
@@ -1122,7 +1058,7 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1122
1058
  _t: 'a'
1123
1059
  };
1124
1060
  for (index = commonHead; index < len1 - commonTail; index++) {
1125
- result['_' + index] = [array1[index], 0, 0];
1061
+ result["_".concat(index)] = [array1[index], 0, 0];
1126
1062
  }
1127
1063
  context.setResult(result).exit();
1128
1064
  return;
@@ -1130,7 +1066,6 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1130
1066
  // reset hash cache
1131
1067
  delete matchContext.hashCache1;
1132
1068
  delete matchContext.hashCache2;
1133
-
1134
1069
  // diff is not trivial, find the LCS (Longest Common Subsequence)
1135
1070
  var trimmed1 = array1.slice(commonHead, len1 - commonTail);
1136
1071
  var trimmed2 = array2.slice(commonHead, len2 - commonTail);
@@ -1140,9 +1075,9 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1140
1075
  _t: 'a'
1141
1076
  };
1142
1077
  for (index = commonHead; index < len1 - commonTail; index++) {
1143
- if (arrayIndexOf(seq.indices1, index - commonHead) < 0) {
1078
+ if (seq.indices1.indexOf(index - commonHead) < 0) {
1144
1079
  // removed
1145
- result['_' + index] = [array1[index], 0, 0];
1080
+ result["_".concat(index)] = [array1[index], 0, 0];
1146
1081
  removedItems.push(index);
1147
1082
  }
1148
1083
  }
@@ -1156,7 +1091,7 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1156
1091
  }
1157
1092
  var removedItemsLength = removedItems.length;
1158
1093
  for (index = commonHead; index < len2 - commonTail; index++) {
1159
- var indexOnArray2 = arrayIndexOf(seq.indices2, index - commonHead);
1094
+ var indexOnArray2 = seq.indices2.indexOf(index - commonHead);
1160
1095
  if (indexOnArray2 < 0) {
1161
1096
  // added, try to match with a removed item and register as position move
1162
1097
  var isMove = false;
@@ -1165,13 +1100,13 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1165
1100
  index1 = removedItems[removeItemIndex1];
1166
1101
  if (matchItems(trimmed1, trimmed2, index1 - commonHead, index - commonHead, matchContext)) {
1167
1102
  // store position move as: [originalValue, newPosition, ARRAY_MOVE]
1168
- result['_' + index1].splice(1, 2, index, ARRAY_MOVE);
1103
+ result["_".concat(index1)].splice(1, 2, index, ARRAY_MOVE);
1169
1104
  if (!includeValueOnMove) {
1170
1105
  // don't include moved value on diff, to save bytes
1171
- result['_' + index1][0] = '';
1106
+ result["_".concat(index1)][0] = '';
1172
1107
  }
1173
1108
  index2 = index;
1174
- child = new DiffContext(context.left[index1], context.right[index2]);
1109
+ child = new DiffContext(array1[index1], array2[index2]);
1175
1110
  context.push(child, index2);
1176
1111
  removedItems.splice(removeItemIndex1, 1);
1177
1112
  isMove = true;
@@ -1187,13 +1122,13 @@ var diffFilter$1 = function arraysDiffFilter(context) {
1187
1122
  // match, do inner diff
1188
1123
  index1 = seq.indices1[indexOnArray2] + commonHead;
1189
1124
  index2 = seq.indices2[indexOnArray2] + commonHead;
1190
- child = new DiffContext(context.left[index1], context.right[index2]);
1125
+ child = new DiffContext(array1[index1], array2[index2]);
1191
1126
  context.push(child, index2);
1192
1127
  }
1193
1128
  }
1194
1129
  context.setResult(result).exit();
1195
1130
  };
1196
- diffFilter$1.filterName = 'arrays';
1131
+ diffFilter$2.filterName = 'arrays';
1197
1132
  var compare = {
1198
1133
  numerically: function numerically(a, b) {
1199
1134
  return a - b;
@@ -1204,18 +1139,18 @@ var compare = {
1204
1139
  };
1205
1140
  }
1206
1141
  };
1207
- var patchFilter$2 = function nestedPatchFilter(context) {
1142
+ var patchFilter$1 = function nestedPatchFilter(context) {
1208
1143
  if (!context.nested) {
1209
1144
  return;
1210
1145
  }
1211
- if (context.delta._t !== 'a') {
1146
+ var nestedDelta = context.delta;
1147
+ if (nestedDelta._t !== 'a') {
1212
1148
  return;
1213
1149
  }
1214
- var index = void 0;
1215
- var index1 = void 0;
1216
- var delta = context.delta;
1150
+ var index;
1151
+ var index1;
1152
+ var delta = nestedDelta;
1217
1153
  var array = context.left;
1218
-
1219
1154
  // first, separate removals, insertions and modifications
1220
1155
  var toRemove = [];
1221
1156
  var toInsert = [];
@@ -1223,35 +1158,36 @@ var patchFilter$2 = function nestedPatchFilter(context) {
1223
1158
  for (index in delta) {
1224
1159
  if (index !== '_t') {
1225
1160
  if (index[0] === '_') {
1161
+ var removedOrMovedIndex = index;
1226
1162
  // removed item from original array
1227
- if (delta[index][2] === 0 || delta[index][2] === ARRAY_MOVE) {
1163
+ if (delta[removedOrMovedIndex][2] === 0 || delta[removedOrMovedIndex][2] === ARRAY_MOVE) {
1228
1164
  toRemove.push(parseInt(index.slice(1), 10));
1229
1165
  } else {
1230
- throw new Error('only removal or move can be applied at original array indices,' + (' invalid diff type: ' + delta[index][2]));
1166
+ throw new Error('only removal or move can be applied at original array indices,' + " invalid diff type: ".concat(delta[removedOrMovedIndex][2]));
1231
1167
  }
1232
1168
  } else {
1233
- if (delta[index].length === 1) {
1169
+ var numberIndex = index;
1170
+ if (delta[numberIndex].length === 1) {
1234
1171
  // added item at new array
1235
1172
  toInsert.push({
1236
- index: parseInt(index, 10),
1237
- value: delta[index][0]
1173
+ index: parseInt(numberIndex, 10),
1174
+ value: delta[numberIndex][0]
1238
1175
  });
1239
1176
  } else {
1240
1177
  // modified item at new array
1241
1178
  toModify.push({
1242
- index: parseInt(index, 10),
1243
- delta: delta[index]
1179
+ index: parseInt(numberIndex, 10),
1180
+ delta: delta[numberIndex]
1244
1181
  });
1245
1182
  }
1246
1183
  }
1247
1184
  }
1248
1185
  }
1249
-
1250
1186
  // remove items, in reverse order to avoid sawing our own floor
1251
1187
  toRemove = toRemove.sort(compare.numerically);
1252
1188
  for (index = toRemove.length - 1; index >= 0; index--) {
1253
1189
  index1 = toRemove[index];
1254
- var indexDiff = delta['_' + index1];
1190
+ var indexDiff = delta["_".concat(index1)];
1255
1191
  var removedValue = array.splice(index1, 1)[0];
1256
1192
  if (indexDiff[2] === ARRAY_MOVE) {
1257
1193
  // reinsert later
@@ -1261,7 +1197,6 @@ var patchFilter$2 = function nestedPatchFilter(context) {
1261
1197
  });
1262
1198
  }
1263
1199
  }
1264
-
1265
1200
  // insert items, in reverse order to avoid moving our own floor
1266
1201
  toInsert = toInsert.sort(compare.numericallyBy('index'));
1267
1202
  var toInsertLength = toInsert.length;
@@ -1269,75 +1204,81 @@ var patchFilter$2 = function nestedPatchFilter(context) {
1269
1204
  var insertion = toInsert[index];
1270
1205
  array.splice(insertion.index, 0, insertion.value);
1271
1206
  }
1272
-
1273
1207
  // apply modifications
1274
1208
  var toModifyLength = toModify.length;
1275
- var child = void 0;
1209
+ var child;
1276
1210
  if (toModifyLength > 0) {
1277
1211
  for (index = 0; index < toModifyLength; index++) {
1278
1212
  var modification = toModify[index];
1279
- child = new PatchContext(context.left[modification.index], modification.delta);
1213
+ child = new PatchContext(array[modification.index], modification.delta);
1280
1214
  context.push(child, modification.index);
1281
1215
  }
1282
1216
  }
1283
1217
  if (!context.children) {
1284
- context.setResult(context.left).exit();
1218
+ context.setResult(array).exit();
1285
1219
  return;
1286
1220
  }
1287
1221
  context.exit();
1288
1222
  };
1289
- patchFilter$2.filterName = 'arrays';
1290
- var collectChildrenPatchFilter$1 = function collectChildrenPatchFilter(context) {
1223
+ patchFilter$1.filterName = 'arrays';
1224
+ var collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
1291
1225
  if (!context || !context.children) {
1292
1226
  return;
1293
1227
  }
1294
- if (context.delta._t !== 'a') {
1228
+ var deltaWithChildren = context.delta;
1229
+ if (deltaWithChildren._t !== 'a') {
1295
1230
  return;
1296
1231
  }
1232
+ var array = context.left;
1297
1233
  var length = context.children.length;
1298
- var child = void 0;
1234
+ var child;
1299
1235
  for (var index = 0; index < length; index++) {
1300
1236
  child = context.children[index];
1301
- context.left[child.childName] = child.result;
1237
+ var arrayIndex = child.childName;
1238
+ array[arrayIndex] = child.result;
1302
1239
  }
1303
- context.setResult(context.left).exit();
1240
+ context.setResult(array).exit();
1304
1241
  };
1305
- collectChildrenPatchFilter$1.filterName = 'arraysCollectChildren';
1306
- var reverseFilter$2 = function arraysReverseFilter(context) {
1242
+ collectChildrenPatchFilter.filterName = 'arraysCollectChildren';
1243
+ var reverseFilter$1 = function arraysReverseFilter(context) {
1307
1244
  if (!context.nested) {
1308
- if (context.delta[2] === ARRAY_MOVE) {
1309
- context.newName = '_' + context.delta[1];
1310
- context.setResult([context.delta[0], parseInt(context.childName.substr(1), 10), ARRAY_MOVE]).exit();
1245
+ var nonNestedDelta = context.delta;
1246
+ if (nonNestedDelta[2] === ARRAY_MOVE) {
1247
+ var arrayMoveDelta = nonNestedDelta;
1248
+ context.newName = "_".concat(arrayMoveDelta[1]);
1249
+ context.setResult([arrayMoveDelta[0], parseInt(context.childName.substring(1), 10), ARRAY_MOVE]).exit();
1311
1250
  }
1312
1251
  return;
1313
1252
  }
1314
- if (context.delta._t !== 'a') {
1253
+ var nestedDelta = context.delta;
1254
+ if (nestedDelta._t !== 'a') {
1315
1255
  return;
1316
1256
  }
1317
- var name = void 0;
1318
- var child = void 0;
1319
- for (name in context.delta) {
1257
+ var arrayDelta = nestedDelta;
1258
+ var name;
1259
+ var child;
1260
+ for (name in arrayDelta) {
1320
1261
  if (name === '_t') {
1321
1262
  continue;
1322
1263
  }
1323
- child = new ReverseContext(context.delta[name]);
1264
+ child = new ReverseContext(arrayDelta[name]);
1324
1265
  context.push(child, name);
1325
1266
  }
1326
1267
  context.exit();
1327
1268
  };
1328
- reverseFilter$2.filterName = 'arrays';
1269
+ reverseFilter$1.filterName = 'arrays';
1329
1270
  var reverseArrayDeltaIndex = function reverseArrayDeltaIndex(delta, index, itemDelta) {
1330
1271
  if (typeof index === 'string' && index[0] === '_') {
1331
- return parseInt(index.substr(1), 10);
1332
- } else if (isArray$2(itemDelta) && itemDelta[2] === 0) {
1333
- return '_' + index;
1272
+ return parseInt(index.substring(1), 10);
1273
+ } else if (Array.isArray(itemDelta) && itemDelta[2] === 0) {
1274
+ return "_".concat(index);
1334
1275
  }
1335
1276
  var reverseIndex = +index;
1336
1277
  for (var deltaIndex in delta) {
1337
1278
  var deltaItem = delta[deltaIndex];
1338
- if (isArray$2(deltaItem)) {
1279
+ if (Array.isArray(deltaItem)) {
1339
1280
  if (deltaItem[2] === ARRAY_MOVE) {
1340
- var moveFromIndex = parseInt(deltaIndex.substr(1), 10);
1281
+ var moveFromIndex = parseInt(deltaIndex.substring(1), 10);
1341
1282
  var moveToIndex = deltaItem[1];
1342
1283
  if (moveToIndex === +index) {
1343
1284
  return moveFromIndex;
@@ -1348,26 +1289,28 @@ var reverseArrayDeltaIndex = function reverseArrayDeltaIndex(delta, index, itemD
1348
1289
  reverseIndex--;
1349
1290
  }
1350
1291
  } else if (deltaItem[2] === 0) {
1351
- var deleteIndex = parseInt(deltaIndex.substr(1), 10);
1292
+ var deleteIndex = parseInt(deltaIndex.substring(1), 10);
1352
1293
  if (deleteIndex <= reverseIndex) {
1353
1294
  reverseIndex++;
1354
1295
  }
1355
- } else if (deltaItem.length === 1 && deltaIndex <= reverseIndex) {
1296
+ } else if (deltaItem.length === 1 && parseInt(deltaIndex, 10) <= reverseIndex) {
1356
1297
  reverseIndex--;
1357
1298
  }
1358
1299
  }
1359
1300
  }
1360
1301
  return reverseIndex;
1361
1302
  };
1362
- function collectChildrenReverseFilter$1(context) {
1303
+ var collectChildrenReverseFilter = function collectChildrenReverseFilter(context) {
1363
1304
  if (!context || !context.children) {
1364
1305
  return;
1365
1306
  }
1366
- if (context.delta._t !== 'a') {
1307
+ var deltaWithChildren = context.delta;
1308
+ if (deltaWithChildren._t !== 'a') {
1367
1309
  return;
1368
1310
  }
1311
+ var arrayDelta = deltaWithChildren;
1369
1312
  var length = context.children.length;
1370
- var child = void 0;
1313
+ var child;
1371
1314
  var delta = {
1372
1315
  _t: 'a'
1373
1316
  };
@@ -1375,16 +1318,18 @@ function collectChildrenReverseFilter$1(context) {
1375
1318
  child = context.children[index];
1376
1319
  var name = child.newName;
1377
1320
  if (typeof name === 'undefined') {
1378
- name = reverseArrayDeltaIndex(context.delta, child.childName, child.result);
1321
+ name = reverseArrayDeltaIndex(arrayDelta, child.childName, child.result);
1379
1322
  }
1380
1323
  if (delta[name] !== child.result) {
1324
+ // There's no way to type this well.
1381
1325
  delta[name] = child.result;
1382
1326
  }
1383
1327
  }
1384
1328
  context.setResult(delta).exit();
1385
- }
1386
- collectChildrenReverseFilter$1.filterName = 'arraysCollectChildren';
1387
- var diffFilter$2 = function datesDiffFilter(context) {
1329
+ };
1330
+ collectChildrenReverseFilter.filterName = 'arraysCollectChildren';
1331
+
1332
+ var diffFilter$1 = function datesDiffFilter(context) {
1388
1333
  if (context.left instanceof Date) {
1389
1334
  if (context.right instanceof Date) {
1390
1335
  if (context.left.getTime() !== context.right.getTime()) {
@@ -1400,34 +1345,22 @@ var diffFilter$2 = function datesDiffFilter(context) {
1400
1345
  context.setResult([context.left, context.right]).exit();
1401
1346
  }
1402
1347
  };
1403
- diffFilter$2.filterName = 'dates';
1348
+ diffFilter$1.filterName = 'dates';
1404
1349
 
1405
- /* global diff_match_patch */
1406
1350
  var TEXT_DIFF = 2;
1407
1351
  var DEFAULT_MIN_LENGTH = 60;
1408
1352
  var cachedDiffPatch = null;
1409
- var getDiffMatchPatch = function getDiffMatchPatch(required) {
1410
- /* jshint camelcase: false */
1411
-
1353
+ function getDiffMatchPatch(options, required) {
1354
+ var _a;
1412
1355
  if (!cachedDiffPatch) {
1413
- var instance = void 0;
1414
- /* eslint-disable camelcase, new-cap */
1415
- if (typeof diff_match_patch !== 'undefined') {
1416
- // already loaded, probably a browser
1417
- instance = typeof diff_match_patch === 'function' ? new diff_match_patch() : new diff_match_patch.diff_match_patch();
1418
- } else if (dmp) {
1419
- try {
1420
- instance = dmp && new dmp();
1421
- } catch (err) {
1422
- instance = null;
1423
- }
1424
- }
1425
- /* eslint-enable camelcase, new-cap */
1426
- if (!instance) {
1356
+ var instance;
1357
+ if ((_a = options === null || options === void 0 ? void 0 : options.textDiff) === null || _a === void 0 ? void 0 : _a.diffMatchPatch) {
1358
+ instance = new options.textDiff.diffMatchPatch();
1359
+ } else {
1427
1360
  if (!required) {
1428
1361
  return null;
1429
1362
  }
1430
- var error = new Error('text diff_match_patch library not found');
1363
+ 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.');
1431
1364
  // eslint-disable-next-line camelcase
1432
1365
  error.diff_match_patch_not_found = true;
1433
1366
  throw error;
@@ -1449,58 +1382,59 @@ var getDiffMatchPatch = function getDiffMatchPatch(required) {
1449
1382
  };
1450
1383
  }
1451
1384
  return cachedDiffPatch;
1452
- };
1453
- var diffFilter$3 = function textsDiffFilter(context) {
1385
+ }
1386
+ var diffFilter = function textsDiffFilter(context) {
1454
1387
  if (context.leftType !== 'string') {
1455
1388
  return;
1456
1389
  }
1390
+ var left = context.left;
1391
+ var right = context.right;
1457
1392
  var minLength = context.options && context.options.textDiff && context.options.textDiff.minLength || DEFAULT_MIN_LENGTH;
1458
- if (context.left.length < minLength || context.right.length < minLength) {
1459
- context.setResult([context.left, context.right]).exit();
1393
+ if (left.length < minLength || right.length < minLength) {
1394
+ context.setResult([left, right]).exit();
1460
1395
  return;
1461
1396
  }
1462
1397
  // large text, try to use a text-diff algorithm
1463
- var diffMatchPatch = getDiffMatchPatch();
1398
+ var diffMatchPatch = getDiffMatchPatch(context.options);
1464
1399
  if (!diffMatchPatch) {
1465
1400
  // diff-match-patch library not available,
1466
1401
  // fallback to regular string replace
1467
- context.setResult([context.left, context.right]).exit();
1402
+ context.setResult([left, right]).exit();
1468
1403
  return;
1469
1404
  }
1470
1405
  var diff = diffMatchPatch.diff;
1471
- context.setResult([diff(context.left, context.right), 0, TEXT_DIFF]).exit();
1406
+ context.setResult([diff(left, right), 0, TEXT_DIFF]).exit();
1472
1407
  };
1473
- diffFilter$3.filterName = 'texts';
1474
- var patchFilter$3 = function textsPatchFilter(context) {
1408
+ diffFilter.filterName = 'texts';
1409
+ var patchFilter = function textsPatchFilter(context) {
1475
1410
  if (context.nested) {
1476
1411
  return;
1477
1412
  }
1478
- if (context.delta[2] !== TEXT_DIFF) {
1413
+ var nonNestedDelta = context.delta;
1414
+ if (nonNestedDelta[2] !== TEXT_DIFF) {
1479
1415
  return;
1480
1416
  }
1481
-
1417
+ var textDiffDelta = nonNestedDelta;
1482
1418
  // text-diff, use a text-patch algorithm
1483
- var patch = getDiffMatchPatch(true).patch;
1484
- context.setResult(patch(context.left, context.delta[0])).exit();
1419
+ var patch = getDiffMatchPatch(context.options, true).patch;
1420
+ context.setResult(patch(context.left, textDiffDelta[0])).exit();
1485
1421
  };
1486
- patchFilter$3.filterName = 'texts';
1422
+ patchFilter.filterName = 'texts';
1487
1423
  var textDeltaReverse = function textDeltaReverse(delta) {
1488
- var i = void 0;
1489
- var l = void 0;
1490
- var lines = void 0;
1491
- var line = void 0;
1492
- var lineTmp = void 0;
1424
+ var i;
1425
+ var l;
1426
+ var line;
1427
+ var lineTmp;
1493
1428
  var header = null;
1494
1429
  var headerRegex = /^@@ +-(\d+),(\d+) +\+(\d+),(\d+) +@@$/;
1495
- var lineHeader = void 0;
1496
- lines = delta.split('\n');
1430
+ var lineHeader;
1431
+ var lines = delta.split('\n');
1497
1432
  for (i = 0, l = lines.length; i < l; i++) {
1498
1433
  line = lines[i];
1499
1434
  var lineStart = line.slice(0, 1);
1500
1435
  if (lineStart === '@') {
1501
1436
  header = headerRegex.exec(line);
1502
1437
  lineHeader = i;
1503
-
1504
1438
  // fix header
1505
1439
  lines[lineHeader] = '@@ -' + header[3] + ',' + header[4] + ' +' + header[1] + ',' + header[2] + ' @@';
1506
1440
  } else if (lineStart === '+') {
@@ -1517,1167 +1451,64 @@ var textDeltaReverse = function textDeltaReverse(delta) {
1517
1451
  }
1518
1452
  return lines.join('\n');
1519
1453
  };
1520
- var reverseFilter$3 = function textsReverseFilter(context) {
1454
+ var reverseFilter = function textsReverseFilter(context) {
1521
1455
  if (context.nested) {
1522
1456
  return;
1523
1457
  }
1524
- if (context.delta[2] !== TEXT_DIFF) {
1458
+ var nonNestedDelta = context.delta;
1459
+ if (nonNestedDelta[2] !== TEXT_DIFF) {
1525
1460
  return;
1526
1461
  }
1527
-
1462
+ var textDiffDelta = nonNestedDelta;
1528
1463
  // text-diff, use a text-diff algorithm
1529
- context.setResult([textDeltaReverse(context.delta[0]), 0, TEXT_DIFF]).exit();
1464
+ context.setResult([textDeltaReverse(textDiffDelta[0]), 0, TEXT_DIFF]).exit();
1530
1465
  };
1531
- reverseFilter$3.filterName = 'texts';
1532
- var DiffPatcher = function () {
1466
+ reverseFilter.filterName = 'texts';
1467
+
1468
+ var DiffPatcher = /*#__PURE__*/function () {
1533
1469
  function DiffPatcher(options) {
1534
- classCallCheck(this, DiffPatcher);
1470
+ _classCallCheck(this, DiffPatcher);
1535
1471
  this.processor = new Processor(options);
1536
- this.processor.pipe(new Pipe('diff').append(collectChildrenDiffFilter, diffFilter, diffFilter$2, diffFilter$3, objectsDiffFilter, diffFilter$1).shouldHaveResult());
1537
- this.processor.pipe(new Pipe('patch').append(collectChildrenPatchFilter, collectChildrenPatchFilter$1, patchFilter, patchFilter$3, patchFilter$1, patchFilter$2).shouldHaveResult());
1538
- this.processor.pipe(new Pipe('reverse').append(collectChildrenReverseFilter, collectChildrenReverseFilter$1, reverseFilter, reverseFilter$3, reverseFilter$1, reverseFilter$2).shouldHaveResult());
1539
- }
1540
- createClass(DiffPatcher, [{
1541
- key: 'options',
1542
- value: function options() {
1543
- var _processor;
1544
- return (_processor = this.processor).options.apply(_processor, arguments);
1472
+ this.processor.pipe(new Pipe('diff').append(collectChildrenDiffFilter, diffFilter$3, diffFilter$1, diffFilter, objectsDiffFilter, diffFilter$2).shouldHaveResult());
1473
+ this.processor.pipe(new Pipe('patch').append(collectChildrenPatchFilter$1, collectChildrenPatchFilter, patchFilter$3, patchFilter, patchFilter$2, patchFilter$1).shouldHaveResult());
1474
+ this.processor.pipe(new Pipe('reverse').append(collectChildrenReverseFilter$1, collectChildrenReverseFilter, reverseFilter$3, reverseFilter, reverseFilter$2, reverseFilter$1).shouldHaveResult());
1475
+ }
1476
+ return _createClass(DiffPatcher, [{
1477
+ key: "options",
1478
+ value: function options(_options) {
1479
+ return this.processor.options(_options);
1545
1480
  }
1546
1481
  }, {
1547
- key: 'diff',
1482
+ key: "diff",
1548
1483
  value: function diff(left, right) {
1549
1484
  return this.processor.process(new DiffContext(left, right));
1550
1485
  }
1551
1486
  }, {
1552
- key: 'patch',
1487
+ key: "patch",
1553
1488
  value: function patch(left, delta) {
1554
1489
  return this.processor.process(new PatchContext(left, delta));
1555
1490
  }
1556
1491
  }, {
1557
- key: 'reverse',
1492
+ key: "reverse",
1558
1493
  value: function reverse(delta) {
1559
1494
  return this.processor.process(new ReverseContext(delta));
1560
1495
  }
1561
1496
  }, {
1562
- key: 'unpatch',
1497
+ key: "unpatch",
1563
1498
  value: function unpatch(right, delta) {
1564
1499
  return this.patch(right, this.reverse(delta));
1565
1500
  }
1566
1501
  }, {
1567
- key: 'clone',
1568
- value: function clone$$1(value) {
1502
+ key: "clone",
1503
+ value: function clone(value) {
1569
1504
  return clone$1(value);
1570
1505
  }
1571
1506
  }]);
1572
- return DiffPatcher;
1573
- }();
1574
- var isArray$3 = typeof Array.isArray === 'function' ? Array.isArray : function (a) {
1575
- return a instanceof Array;
1576
- };
1577
- var getObjectKeys = typeof Object.keys === 'function' ? function (obj) {
1578
- return Object.keys(obj);
1579
- } : function (obj) {
1580
- var names = [];
1581
- for (var property in obj) {
1582
- if (Object.prototype.hasOwnProperty.call(obj, property)) {
1583
- names.push(property);
1584
- }
1585
- }
1586
- return names;
1587
- };
1588
- var trimUnderscore = function trimUnderscore(str) {
1589
- if (str.substr(0, 1) === '_') {
1590
- return str.slice(1);
1591
- }
1592
- return str;
1593
- };
1594
- var arrayKeyToSortNumber = function arrayKeyToSortNumber(key) {
1595
- if (key === '_t') {
1596
- return -1;
1597
- } else {
1598
- if (key.substr(0, 1) === '_') {
1599
- return parseInt(key.slice(1), 10);
1600
- } else {
1601
- return parseInt(key, 10) + 0.1;
1602
- }
1603
- }
1604
- };
1605
- var arrayKeyComparer = function arrayKeyComparer(key1, key2) {
1606
- return arrayKeyToSortNumber(key1) - arrayKeyToSortNumber(key2);
1607
- };
1608
- var BaseFormatter = function () {
1609
- function BaseFormatter() {
1610
- classCallCheck(this, BaseFormatter);
1611
- }
1612
- createClass(BaseFormatter, [{
1613
- key: 'format',
1614
- value: function format(delta, left) {
1615
- var context = {};
1616
- this.prepareContext(context);
1617
- this.recurse(context, delta, left);
1618
- return this.finalize(context);
1619
- }
1620
- }, {
1621
- key: 'prepareContext',
1622
- value: function prepareContext(context) {
1623
- context.buffer = [];
1624
- context.out = function () {
1625
- var _buffer;
1626
- (_buffer = this.buffer).push.apply(_buffer, arguments);
1627
- };
1628
- }
1629
- }, {
1630
- key: 'typeFormattterNotFound',
1631
- value: function typeFormattterNotFound(context, deltaType) {
1632
- throw new Error('cannot format delta type: ' + deltaType);
1633
- }
1634
- }, {
1635
- key: 'typeFormattterErrorFormatter',
1636
- value: function typeFormattterErrorFormatter(context, err) {
1637
- return err.toString();
1638
- }
1639
- }, {
1640
- key: 'finalize',
1641
- value: function finalize(_ref) {
1642
- var buffer = _ref.buffer;
1643
- if (isArray$3(buffer)) {
1644
- return buffer.join('');
1645
- }
1646
- }
1647
- }, {
1648
- key: 'recurse',
1649
- value: function recurse(context, delta, left, key, leftKey, movedFrom, isLast) {
1650
- var useMoveOriginHere = delta && movedFrom;
1651
- var leftValue = useMoveOriginHere ? movedFrom.value : left;
1652
- if (typeof delta === 'undefined' && typeof key === 'undefined') {
1653
- return undefined;
1654
- }
1655
- var type = this.getDeltaType(delta, movedFrom);
1656
- var nodeType = type === 'node' ? delta._t === 'a' ? 'array' : 'object' : '';
1657
- if (typeof key !== 'undefined') {
1658
- this.nodeBegin(context, key, leftKey, type, nodeType, isLast);
1659
- } else {
1660
- this.rootBegin(context, type, nodeType);
1661
- }
1662
- var typeFormattter = void 0;
1663
- try {
1664
- typeFormattter = this['format_' + type] || this.typeFormattterNotFound(context, type);
1665
- typeFormattter.call(this, context, delta, leftValue, key, leftKey, movedFrom);
1666
- } catch (err) {
1667
- this.typeFormattterErrorFormatter(context, err, delta, leftValue, key, leftKey, movedFrom);
1668
- if (typeof console !== 'undefined' && console.error) {
1669
- console.error(err.stack);
1670
- }
1671
- }
1672
- if (typeof key !== 'undefined') {
1673
- this.nodeEnd(context, key, leftKey, type, nodeType, isLast);
1674
- } else {
1675
- this.rootEnd(context, type, nodeType);
1676
- }
1677
- }
1678
- }, {
1679
- key: 'formatDeltaChildren',
1680
- value: function formatDeltaChildren(context, delta, left) {
1681
- var self = this;
1682
- this.forEachDeltaKey(delta, left, function (key, leftKey, movedFrom, isLast) {
1683
- self.recurse(context, delta[key], left ? left[leftKey] : undefined, key, leftKey, movedFrom, isLast);
1684
- });
1685
- }
1686
- }, {
1687
- key: 'forEachDeltaKey',
1688
- value: function forEachDeltaKey(delta, left, fn) {
1689
- var keys = getObjectKeys(delta);
1690
- var arrayKeys = delta._t === 'a';
1691
- var moveDestinations = {};
1692
- var name = void 0;
1693
- if (typeof left !== 'undefined') {
1694
- for (name in left) {
1695
- if (Object.prototype.hasOwnProperty.call(left, name)) {
1696
- if (typeof delta[name] === 'undefined' && (!arrayKeys || typeof delta['_' + name] === 'undefined')) {
1697
- keys.push(name);
1698
- }
1699
- }
1700
- }
1701
- }
1702
- // look for move destinations
1703
- for (name in delta) {
1704
- if (Object.prototype.hasOwnProperty.call(delta, name)) {
1705
- var value = delta[name];
1706
- if (isArray$3(value) && value[2] === 3) {
1707
- moveDestinations[value[1].toString()] = {
1708
- key: name,
1709
- value: left && left[parseInt(name.substr(1))]
1710
- };
1711
- if (this.includeMoveDestinations !== false) {
1712
- if (typeof left === 'undefined' && typeof delta[value[1]] === 'undefined') {
1713
- keys.push(value[1].toString());
1714
- }
1715
- }
1716
- }
1717
- }
1718
- }
1719
- if (arrayKeys) {
1720
- keys.sort(arrayKeyComparer);
1721
- } else {
1722
- keys.sort();
1723
- }
1724
- for (var index = 0, length = keys.length; index < length; index++) {
1725
- var key = keys[index];
1726
- if (arrayKeys && key === '_t') {
1727
- continue;
1728
- }
1729
- var leftKey = arrayKeys ? typeof key === 'number' ? key : parseInt(trimUnderscore(key), 10) : key;
1730
- var isLast = index === length - 1;
1731
- fn(key, leftKey, moveDestinations[leftKey], isLast);
1732
- }
1733
- }
1734
- }, {
1735
- key: 'getDeltaType',
1736
- value: function getDeltaType(delta, movedFrom) {
1737
- if (typeof delta === 'undefined') {
1738
- if (typeof movedFrom !== 'undefined') {
1739
- return 'movedestination';
1740
- }
1741
- return 'unchanged';
1742
- }
1743
- if (isArray$3(delta)) {
1744
- if (delta.length === 1) {
1745
- return 'added';
1746
- }
1747
- if (delta.length === 2) {
1748
- return 'modified';
1749
- }
1750
- if (delta.length === 3 && delta[2] === 0) {
1751
- return 'deleted';
1752
- }
1753
- if (delta.length === 3 && delta[2] === 2) {
1754
- return 'textdiff';
1755
- }
1756
- if (delta.length === 3 && delta[2] === 3) {
1757
- return 'moved';
1758
- }
1759
- } else if ((typeof delta === 'undefined' ? 'undefined' : _typeof(delta)) === 'object') {
1760
- return 'node';
1761
- }
1762
- return 'unknown';
1763
- }
1764
- }, {
1765
- key: 'parseTextDiff',
1766
- value: function parseTextDiff(value) {
1767
- var output = [];
1768
- var lines = value.split('\n@@ ');
1769
- for (var i = 0, l = lines.length; i < l; i++) {
1770
- var line = lines[i];
1771
- var lineOutput = {
1772
- pieces: []
1773
- };
1774
- var location = /^(?:@@ )?[-+]?(\d+),(\d+)/.exec(line).slice(1);
1775
- lineOutput.location = {
1776
- line: location[0],
1777
- chr: location[1]
1778
- };
1779
- var pieces = line.split('\n').slice(1);
1780
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
1781
- var piece = pieces[pieceIndex];
1782
- if (!piece.length) {
1783
- continue;
1784
- }
1785
- var pieceOutput = {
1786
- type: 'context'
1787
- };
1788
- if (piece.substr(0, 1) === '+') {
1789
- pieceOutput.type = 'added';
1790
- } else if (piece.substr(0, 1) === '-') {
1791
- pieceOutput.type = 'deleted';
1792
- }
1793
- pieceOutput.text = piece.slice(1);
1794
- lineOutput.pieces.push(pieceOutput);
1795
- }
1796
- output.push(lineOutput);
1797
- }
1798
- return output;
1799
- }
1800
- }]);
1801
- return BaseFormatter;
1802
1507
  }();
1803
- var base = Object.freeze({
1804
- default: BaseFormatter
1805
- });
1806
- var HtmlFormatter = function (_BaseFormatter) {
1807
- inherits(HtmlFormatter, _BaseFormatter);
1808
- function HtmlFormatter() {
1809
- classCallCheck(this, HtmlFormatter);
1810
- return possibleConstructorReturn(this, (HtmlFormatter.__proto__ || Object.getPrototypeOf(HtmlFormatter)).apply(this, arguments));
1811
- }
1812
- createClass(HtmlFormatter, [{
1813
- key: 'typeFormattterErrorFormatter',
1814
- value: function typeFormattterErrorFormatter(context, err) {
1815
- context.out('<pre class="jsondiffpatch-error">' + err + '</pre>');
1816
- }
1817
- }, {
1818
- key: 'formatValue',
1819
- value: function formatValue(context, value) {
1820
- context.out('<pre>' + htmlEscape(JSON.stringify(value, null, 2)) + '</pre>');
1821
- }
1822
- }, {
1823
- key: 'formatTextDiffString',
1824
- value: function formatTextDiffString(context, value) {
1825
- var lines = this.parseTextDiff(value);
1826
- context.out('<ul class="jsondiffpatch-textdiff">');
1827
- for (var i = 0, l = lines.length; i < l; i++) {
1828
- var line = lines[i];
1829
- 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">'));
1830
- var pieces = line.pieces;
1831
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
1832
- /* global decodeURI */
1833
- var piece = pieces[pieceIndex];
1834
- context.out('<span class="jsondiffpatch-textdiff-' + piece.type + '">' + htmlEscape(decodeURI(piece.text)) + '</span>');
1835
- }
1836
- context.out('</div></li>');
1837
- }
1838
- context.out('</ul>');
1839
- }
1840
- }, {
1841
- key: 'rootBegin',
1842
- value: function rootBegin(context, type, nodeType) {
1843
- var nodeClass = 'jsondiffpatch-' + type + (nodeType ? ' jsondiffpatch-child-node-type-' + nodeType : '');
1844
- context.out('<div class="jsondiffpatch-delta ' + nodeClass + '">');
1845
- }
1846
- }, {
1847
- key: 'rootEnd',
1848
- value: function rootEnd(context) {
1849
- context.out('</div>' + (context.hasArrows ? '<script type="text/javascript">setTimeout(' + (adjustArrows.toString() + ',10);</script>') : ''));
1850
- }
1851
- }, {
1852
- key: 'nodeBegin',
1853
- value: function nodeBegin(context, key, leftKey, type, nodeType) {
1854
- var nodeClass = 'jsondiffpatch-' + type + (nodeType ? ' jsondiffpatch-child-node-type-' + nodeType : '');
1855
- context.out('<li class="' + nodeClass + '" data-key="' + leftKey + '">' + ('<div class="jsondiffpatch-property-name">' + leftKey + '</div>'));
1856
- }
1857
- }, {
1858
- key: 'nodeEnd',
1859
- value: function nodeEnd(context) {
1860
- context.out('</li>');
1861
- }
1862
-
1863
- /* jshint camelcase: false */
1864
- /* eslint-disable camelcase */
1865
- }, {
1866
- key: 'format_unchanged',
1867
- value: function format_unchanged(context, delta, left) {
1868
- if (typeof left === 'undefined') {
1869
- return;
1870
- }
1871
- context.out('<div class="jsondiffpatch-value">');
1872
- this.formatValue(context, left);
1873
- context.out('</div>');
1874
- }
1875
- }, {
1876
- key: 'format_movedestination',
1877
- value: function format_movedestination(context, delta, left) {
1878
- if (typeof left === 'undefined') {
1879
- return;
1880
- }
1881
- context.out('<div class="jsondiffpatch-value">');
1882
- this.formatValue(context, left);
1883
- context.out('</div>');
1884
- }
1885
- }, {
1886
- key: 'format_node',
1887
- value: function format_node(context, delta, left) {
1888
- // recurse
1889
- var nodeType = delta._t === 'a' ? 'array' : 'object';
1890
- context.out('<ul class="jsondiffpatch-node jsondiffpatch-node-type-' + nodeType + '">');
1891
- this.formatDeltaChildren(context, delta, left);
1892
- context.out('</ul>');
1893
- }
1894
- }, {
1895
- key: 'format_added',
1896
- value: function format_added(context, delta) {
1897
- context.out('<div class="jsondiffpatch-value">');
1898
- this.formatValue(context, delta[0]);
1899
- context.out('</div>');
1900
- }
1901
- }, {
1902
- key: 'format_modified',
1903
- value: function format_modified(context, delta) {
1904
- context.out('<div class="jsondiffpatch-value jsondiffpatch-left-value">');
1905
- this.formatValue(context, delta[0]);
1906
- context.out('</div>' + '<div class="jsondiffpatch-value jsondiffpatch-right-value">');
1907
- this.formatValue(context, delta[1]);
1908
- context.out('</div>');
1909
- }
1910
- }, {
1911
- key: 'format_deleted',
1912
- value: function format_deleted(context, delta) {
1913
- context.out('<div class="jsondiffpatch-value">');
1914
- this.formatValue(context, delta[0]);
1915
- context.out('</div>');
1916
- }
1917
- }, {
1918
- key: 'format_moved',
1919
- value: function format_moved(context, delta) {
1920
- context.out('<div class="jsondiffpatch-value">');
1921
- this.formatValue(context, delta[0]);
1922
- context.out('</div><div class="jsondiffpatch-moved-destination">' + delta[1] + '</div>');
1923
-
1924
- // draw an SVG arrow from here to move destination
1925
- context.out( /* jshint multistr: true */
1926
- '<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>');
1927
- context.hasArrows = true;
1928
- }
1929
- }, {
1930
- key: 'format_textdiff',
1931
- value: function format_textdiff(context, delta) {
1932
- context.out('<div class="jsondiffpatch-value">');
1933
- this.formatTextDiffString(context, delta[0]);
1934
- context.out('</div>');
1935
- }
1936
- }]);
1937
- return HtmlFormatter;
1938
- }(BaseFormatter);
1939
- function htmlEscape(text) {
1940
- var html = text;
1941
- var replacements = [[/&/g, '&amp;'], [/</g, '&lt;'], [/>/g, '&gt;'], [/'/g, '&apos;'], [/"/g, '&quot;']];
1942
- for (var i = 0; i < replacements.length; i++) {
1943
- html = html.replace(replacements[i][0], replacements[i][1]);
1944
- }
1945
- return html;
1946
- }
1947
- var adjustArrows = function jsondiffpatchHtmlFormatterAdjustArrows(nodeArg) {
1948
- var node = nodeArg || document;
1949
- var getElementText = function getElementText(_ref) {
1950
- var textContent = _ref.textContent,
1951
- innerText = _ref.innerText;
1952
- return textContent || innerText;
1953
- };
1954
- var eachByQuery = function eachByQuery(el, query, fn) {
1955
- var elems = el.querySelectorAll(query);
1956
- for (var i = 0, l = elems.length; i < l; i++) {
1957
- fn(elems[i]);
1958
- }
1959
- };
1960
- var eachChildren = function eachChildren(_ref2, fn) {
1961
- var children = _ref2.children;
1962
- for (var i = 0, l = children.length; i < l; i++) {
1963
- fn(children[i], i);
1964
- }
1965
- };
1966
- eachByQuery(node, '.jsondiffpatch-arrow', function (_ref3) {
1967
- var parentNode = _ref3.parentNode,
1968
- children = _ref3.children,
1969
- style = _ref3.style;
1970
- var arrowParent = parentNode;
1971
- var svg = children[0];
1972
- var path = svg.children[1];
1973
- svg.style.display = 'none';
1974
- var destination = getElementText(arrowParent.querySelector('.jsondiffpatch-moved-destination'));
1975
- var container = arrowParent.parentNode;
1976
- var destinationElem = void 0;
1977
- eachChildren(container, function (child) {
1978
- if (child.getAttribute('data-key') === destination) {
1979
- destinationElem = child;
1980
- }
1981
- });
1982
- if (!destinationElem) {
1983
- return;
1984
- }
1985
- try {
1986
- var distance = destinationElem.offsetTop - arrowParent.offsetTop;
1987
- svg.setAttribute('height', Math.abs(distance) + 6);
1988
- style.top = -8 + (distance > 0 ? 0 : distance) + 'px';
1989
- 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';
1990
- path.setAttribute('d', curve);
1991
- svg.style.display = '';
1992
- } catch (err) {}
1993
- });
1994
- };
1995
-
1996
- /* jshint camelcase: true */
1997
- /* eslint-enable camelcase */
1998
-
1999
- var showUnchanged = function showUnchanged(show, node, delay) {
2000
- var el = node || document.body;
2001
- var prefix = 'jsondiffpatch-unchanged-';
2002
- var classes = {
2003
- showing: prefix + 'showing',
2004
- hiding: prefix + 'hiding',
2005
- visible: prefix + 'visible',
2006
- hidden: prefix + 'hidden'
2007
- };
2008
- var list = el.classList;
2009
- if (!list) {
2010
- return;
2011
- }
2012
- if (!delay) {
2013
- list.remove(classes.showing);
2014
- list.remove(classes.hiding);
2015
- list.remove(classes.visible);
2016
- list.remove(classes.hidden);
2017
- if (show === false) {
2018
- list.add(classes.hidden);
2019
- }
2020
- return;
2021
- }
2022
- if (show === false) {
2023
- list.remove(classes.showing);
2024
- list.add(classes.visible);
2025
- setTimeout(function () {
2026
- list.add(classes.hiding);
2027
- }, 10);
2028
- } else {
2029
- list.remove(classes.hiding);
2030
- list.add(classes.showing);
2031
- list.remove(classes.hidden);
2032
- }
2033
- var intervalId = setInterval(function () {
2034
- adjustArrows(el);
2035
- }, 100);
2036
- setTimeout(function () {
2037
- list.remove(classes.showing);
2038
- list.remove(classes.hiding);
2039
- if (show === false) {
2040
- list.add(classes.hidden);
2041
- list.remove(classes.visible);
2042
- } else {
2043
- list.add(classes.visible);
2044
- list.remove(classes.hidden);
2045
- }
2046
- setTimeout(function () {
2047
- list.remove(classes.visible);
2048
- clearInterval(intervalId);
2049
- }, delay + 400);
2050
- }, delay);
2051
- };
2052
- var hideUnchanged = function hideUnchanged(node, delay) {
2053
- return showUnchanged(false, node, delay);
2054
- };
2055
- var defaultInstance = void 0;
2056
- function format(delta, left) {
2057
- if (!defaultInstance) {
2058
- defaultInstance = new HtmlFormatter();
2059
- }
2060
- return defaultInstance.format(delta, left);
2061
- }
2062
- var html = Object.freeze({
2063
- showUnchanged: showUnchanged,
2064
- hideUnchanged: hideUnchanged,
2065
- default: HtmlFormatter,
2066
- format: format
2067
- });
2068
- var AnnotatedFormatter = function (_BaseFormatter) {
2069
- inherits(AnnotatedFormatter, _BaseFormatter);
2070
- function AnnotatedFormatter() {
2071
- classCallCheck(this, AnnotatedFormatter);
2072
- var _this = possibleConstructorReturn(this, (AnnotatedFormatter.__proto__ || Object.getPrototypeOf(AnnotatedFormatter)).call(this));
2073
- _this.includeMoveDestinations = false;
2074
- return _this;
2075
- }
2076
- createClass(AnnotatedFormatter, [{
2077
- key: 'prepareContext',
2078
- value: function prepareContext(context) {
2079
- get(AnnotatedFormatter.prototype.__proto__ || Object.getPrototypeOf(AnnotatedFormatter.prototype), 'prepareContext', this).call(this, context);
2080
- context.indent = function (levels) {
2081
- this.indentLevel = (this.indentLevel || 0) + (typeof levels === 'undefined' ? 1 : levels);
2082
- this.indentPad = new Array(this.indentLevel + 1).join('&nbsp;&nbsp;');
2083
- };
2084
- context.row = function (json, htmlNote) {
2085
- context.out('<tr><td style="white-space: nowrap;">' + '<pre class="jsondiffpatch-annotated-indent"' + ' style="display: inline-block">');
2086
- context.out(context.indentPad);
2087
- context.out('</pre><pre style="display: inline-block">');
2088
- context.out(json);
2089
- context.out('</pre></td><td class="jsondiffpatch-delta-note"><div>');
2090
- context.out(htmlNote);
2091
- context.out('</div></td></tr>');
2092
- };
2093
- }
2094
- }, {
2095
- key: 'typeFormattterErrorFormatter',
2096
- value: function typeFormattterErrorFormatter(context, err) {
2097
- context.row('', '<pre class="jsondiffpatch-error">' + err + '</pre>');
2098
- }
2099
- }, {
2100
- key: 'formatTextDiffString',
2101
- value: function formatTextDiffString(context, value) {
2102
- var lines = this.parseTextDiff(value);
2103
- context.out('<ul class="jsondiffpatch-textdiff">');
2104
- for (var i = 0, l = lines.length; i < l; i++) {
2105
- var line = lines[i];
2106
- 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">'));
2107
- var pieces = line.pieces;
2108
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
2109
- var piece = pieces[pieceIndex];
2110
- context.out('<span class="jsondiffpatch-textdiff-' + piece.type + '">' + piece.text + '</span>');
2111
- }
2112
- context.out('</div></li>');
2113
- }
2114
- context.out('</ul>');
2115
- }
2116
- }, {
2117
- key: 'rootBegin',
2118
- value: function rootBegin(context, type, nodeType) {
2119
- context.out('<table class="jsondiffpatch-annotated-delta">');
2120
- if (type === 'node') {
2121
- context.row('{');
2122
- context.indent();
2123
- }
2124
- if (nodeType === 'array') {
2125
- context.row('"_t": "a",', 'Array delta (member names indicate array indices)');
2126
- }
2127
- }
2128
- }, {
2129
- key: 'rootEnd',
2130
- value: function rootEnd(context, type) {
2131
- if (type === 'node') {
2132
- context.indent(-1);
2133
- context.row('}');
2134
- }
2135
- context.out('</table>');
2136
- }
2137
- }, {
2138
- key: 'nodeBegin',
2139
- value: function nodeBegin(context, key, leftKey, type, nodeType) {
2140
- context.row('&quot;' + key + '&quot;: {');
2141
- if (type === 'node') {
2142
- context.indent();
2143
- }
2144
- if (nodeType === 'array') {
2145
- context.row('"_t": "a",', 'Array delta (member names indicate array indices)');
2146
- }
2147
- }
2148
- }, {
2149
- key: 'nodeEnd',
2150
- value: function nodeEnd(context, key, leftKey, type, nodeType, isLast) {
2151
- if (type === 'node') {
2152
- context.indent(-1);
2153
- }
2154
- context.row('}' + (isLast ? '' : ','));
2155
- }
2156
-
2157
- /* jshint camelcase: false */
2158
-
2159
- /* eslint-disable camelcase */
2160
- }, {
2161
- key: 'format_unchanged',
2162
- value: function format_unchanged() {}
2163
- }, {
2164
- key: 'format_movedestination',
2165
- value: function format_movedestination() {}
2166
- }, {
2167
- key: 'format_node',
2168
- value: function format_node(context, delta, left) {
2169
- // recurse
2170
- this.formatDeltaChildren(context, delta, left);
2171
- }
2172
- }]);
2173
- return AnnotatedFormatter;
2174
- }(BaseFormatter);
2175
-
2176
- /* eslint-enable camelcase */
2177
-
2178
- var wrapPropertyName = function wrapPropertyName(name) {
2179
- return '<pre style="display:inline-block">&quot;' + name + '&quot;</pre>';
2180
- };
2181
- var deltaAnnotations = {
2182
- added: function added(delta, left, key, leftKey) {
2183
- var formatLegend = ' <pre>([newValue])</pre>';
2184
- if (typeof leftKey === 'undefined') {
2185
- return 'new value' + formatLegend;
2186
- }
2187
- if (typeof leftKey === 'number') {
2188
- return 'insert at index ' + leftKey + formatLegend;
2189
- }
2190
- return 'add property ' + wrapPropertyName(leftKey) + formatLegend;
2191
- },
2192
- modified: function modified(delta, left, key, leftKey) {
2193
- var formatLegend = ' <pre>([previousValue, newValue])</pre>';
2194
- if (typeof leftKey === 'undefined') {
2195
- return 'modify value' + formatLegend;
2196
- }
2197
- if (typeof leftKey === 'number') {
2198
- return 'modify at index ' + leftKey + formatLegend;
2199
- }
2200
- return 'modify property ' + wrapPropertyName(leftKey) + formatLegend;
2201
- },
2202
- deleted: function deleted(delta, left, key, leftKey) {
2203
- var formatLegend = ' <pre>([previousValue, 0, 0])</pre>';
2204
- if (typeof leftKey === 'undefined') {
2205
- return 'delete value' + formatLegend;
2206
- }
2207
- if (typeof leftKey === 'number') {
2208
- return 'remove index ' + leftKey + formatLegend;
2209
- }
2210
- return 'delete property ' + wrapPropertyName(leftKey) + formatLegend;
2211
- },
2212
- moved: function moved(delta, left, key, leftKey) {
2213
- 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>');
2214
- },
2215
- textdiff: function textdiff(delta, left, key, leftKey) {
2216
- var location = typeof leftKey === 'undefined' ? '' : typeof leftKey === 'number' ? ' at index ' + leftKey : ' at property ' + wrapPropertyName(leftKey);
2217
- return 'text diff' + location + ', format is <a href="https://code.google.com/' + 'p/google-diff-match-patch/wiki/Unidiff">a variation of Unidiff</a>';
2218
- }
2219
- };
2220
- var formatAnyChange = function formatAnyChange(context, delta) {
2221
- var deltaType = this.getDeltaType(delta);
2222
- var annotator = deltaAnnotations[deltaType];
2223
- var htmlNote = annotator && annotator.apply(annotator, Array.prototype.slice.call(arguments, 1));
2224
- var json = JSON.stringify(delta, null, 2);
2225
- if (deltaType === 'textdiff') {
2226
- // split text diffs lines
2227
- json = json.split('\\n').join('\\n"+\n "');
2228
- }
2229
- context.indent();
2230
- context.row(json, htmlNote);
2231
- context.indent(-1);
2232
- };
2233
-
2234
- /* eslint-disable camelcase */
2235
- AnnotatedFormatter.prototype.format_added = formatAnyChange;
2236
- AnnotatedFormatter.prototype.format_modified = formatAnyChange;
2237
- AnnotatedFormatter.prototype.format_deleted = formatAnyChange;
2238
- AnnotatedFormatter.prototype.format_moved = formatAnyChange;
2239
- AnnotatedFormatter.prototype.format_textdiff = formatAnyChange;
2240
- var defaultInstance$1 = void 0;
2241
- function format$1(delta, left) {
2242
- if (!defaultInstance$1) {
2243
- defaultInstance$1 = new AnnotatedFormatter();
2244
- }
2245
- return defaultInstance$1.format(delta, left);
2246
- }
2247
- var annotated = Object.freeze({
2248
- default: AnnotatedFormatter,
2249
- format: format$1
2250
- });
2251
- var OPERATIONS = {
2252
- add: 'add',
2253
- remove: 'remove',
2254
- replace: 'replace',
2255
- move: 'move'
2256
- };
2257
- var JSONFormatter = function (_BaseFormatter) {
2258
- inherits(JSONFormatter, _BaseFormatter);
2259
- function JSONFormatter() {
2260
- classCallCheck(this, JSONFormatter);
2261
- var _this = possibleConstructorReturn(this, (JSONFormatter.__proto__ || Object.getPrototypeOf(JSONFormatter)).call(this));
2262
- _this.includeMoveDestinations = true;
2263
- return _this;
2264
- }
2265
- createClass(JSONFormatter, [{
2266
- key: 'prepareContext',
2267
- value: function prepareContext(context) {
2268
- get(JSONFormatter.prototype.__proto__ || Object.getPrototypeOf(JSONFormatter.prototype), 'prepareContext', this).call(this, context);
2269
- context.result = [];
2270
- context.path = [];
2271
- context.pushCurrentOp = function (obj) {
2272
- var op = obj.op,
2273
- value = obj.value;
2274
- var val = {
2275
- op: op,
2276
- path: this.currentPath()
2277
- };
2278
- if (typeof value !== 'undefined') {
2279
- val.value = value;
2280
- }
2281
- this.result.push(val);
2282
- };
2283
- context.pushMoveOp = function (to) {
2284
- var from = this.currentPath();
2285
- this.result.push({
2286
- op: OPERATIONS.move,
2287
- from: from,
2288
- path: this.toPath(to)
2289
- });
2290
- };
2291
- context.currentPath = function () {
2292
- return '/' + this.path.join('/');
2293
- };
2294
- context.toPath = function (toPath) {
2295
- var to = this.path.slice();
2296
- to[to.length - 1] = toPath;
2297
- return '/' + to.join('/');
2298
- };
2299
- }
2300
- }, {
2301
- key: 'typeFormattterErrorFormatter',
2302
- value: function typeFormattterErrorFormatter(context, err) {
2303
- context.out('[ERROR] ' + err);
2304
- }
2305
- }, {
2306
- key: 'rootBegin',
2307
- value: function rootBegin() {}
2308
- }, {
2309
- key: 'rootEnd',
2310
- value: function rootEnd() {}
2311
- }, {
2312
- key: 'nodeBegin',
2313
- value: function nodeBegin(_ref, key, leftKey) {
2314
- var path = _ref.path;
2315
- path.push(leftKey);
2316
- }
2317
- }, {
2318
- key: 'nodeEnd',
2319
- value: function nodeEnd(_ref2) {
2320
- var path = _ref2.path;
2321
- path.pop();
2322
- }
2323
-
2324
- /* jshint camelcase: false */
2325
- /* eslint-disable camelcase */
2326
- }, {
2327
- key: 'format_unchanged',
2328
- value: function format_unchanged() {}
2329
- }, {
2330
- key: 'format_movedestination',
2331
- value: function format_movedestination() {}
2332
- }, {
2333
- key: 'format_node',
2334
- value: function format_node(context, delta, left) {
2335
- this.formatDeltaChildren(context, delta, left);
2336
- }
2337
- }, {
2338
- key: 'format_added',
2339
- value: function format_added(context, delta) {
2340
- context.pushCurrentOp({
2341
- op: OPERATIONS.add,
2342
- value: delta[0]
2343
- });
2344
- }
2345
- }, {
2346
- key: 'format_modified',
2347
- value: function format_modified(context, delta) {
2348
- context.pushCurrentOp({
2349
- op: OPERATIONS.replace,
2350
- value: delta[1]
2351
- });
2352
- }
2353
- }, {
2354
- key: 'format_deleted',
2355
- value: function format_deleted(context) {
2356
- context.pushCurrentOp({
2357
- op: OPERATIONS.remove
2358
- });
2359
- }
2360
- }, {
2361
- key: 'format_moved',
2362
- value: function format_moved(context, delta) {
2363
- var to = delta[1];
2364
- context.pushMoveOp(to);
2365
- }
2366
- }, {
2367
- key: 'format_textdiff',
2368
- value: function format_textdiff() {
2369
- throw new Error('Not implemented');
2370
- }
2371
- }, {
2372
- key: 'format',
2373
- value: function format(delta, left) {
2374
- var context = {};
2375
- this.prepareContext(context);
2376
- this.recurse(context, delta, left);
2377
- return context.result;
2378
- }
2379
- }]);
2380
- return JSONFormatter;
2381
- }(BaseFormatter);
2382
- var last = function last(arr) {
2383
- return arr[arr.length - 1];
2384
- };
2385
- var sortBy = function sortBy(arr, pred) {
2386
- arr.sort(pred);
2387
- return arr;
2388
- };
2389
- var compareByIndexDesc = function compareByIndexDesc(indexA, indexB) {
2390
- var lastA = parseInt(indexA, 10);
2391
- var lastB = parseInt(indexB, 10);
2392
- if (!(isNaN(lastA) || isNaN(lastB))) {
2393
- return lastB - lastA;
2394
- } else {
2395
- return 0;
2396
- }
2397
- };
2398
- var opsByDescendingOrder = function opsByDescendingOrder(removeOps) {
2399
- return sortBy(removeOps, function (a, b) {
2400
- var splitA = a.path.split('/');
2401
- var splitB = b.path.split('/');
2402
- if (splitA.length !== splitB.length) {
2403
- return splitA.length - splitB.length;
2404
- } else {
2405
- return compareByIndexDesc(last(splitA), last(splitB));
2406
- }
2407
- });
2408
- };
2409
- var partitionOps = function partitionOps(arr, fns) {
2410
- var initArr = Array(fns.length + 1).fill().map(function () {
2411
- return [];
2412
- });
2413
- return arr.map(function (item) {
2414
- var position = fns.map(function (fn) {
2415
- return fn(item);
2416
- }).indexOf(true);
2417
- if (position < 0) {
2418
- position = fns.length;
2419
- }
2420
- return {
2421
- item: item,
2422
- position: position
2423
- };
2424
- }).reduce(function (acc, item) {
2425
- acc[item.position].push(item.item);
2426
- return acc;
2427
- }, initArr);
2428
- };
2429
- var isMoveOp = function isMoveOp(_ref3) {
2430
- var op = _ref3.op;
2431
- return op === 'move';
2432
- };
2433
- var isRemoveOp = function isRemoveOp(_ref4) {
2434
- var op = _ref4.op;
2435
- return op === 'remove';
2436
- };
2437
- var reorderOps = function reorderOps(diff) {
2438
- var _partitionOps = partitionOps(diff, [isMoveOp, isRemoveOp]),
2439
- _partitionOps2 = slicedToArray(_partitionOps, 3),
2440
- moveOps = _partitionOps2[0],
2441
- removedOps = _partitionOps2[1],
2442
- restOps = _partitionOps2[2];
2443
- var removeOpsReverse = opsByDescendingOrder(removedOps);
2444
- return [].concat(toConsumableArray(removeOpsReverse), toConsumableArray(moveOps), toConsumableArray(restOps));
2445
- };
2446
- var defaultInstance$2 = void 0;
2447
- var format$2 = function format(delta, left) {
2448
- if (!defaultInstance$2) {
2449
- defaultInstance$2 = new JSONFormatter();
2450
- }
2451
- return reorderOps(defaultInstance$2.format(delta, left));
2452
- };
2453
- var log = function log(delta, left) {
2454
- console.log(format$2(delta, left));
2455
- };
2456
- var jsonpatch = Object.freeze({
2457
- default: JSONFormatter,
2458
- partitionOps: partitionOps,
2459
- format: format$2,
2460
- log: log
2461
- });
2462
- function chalkColor(name) {
2463
- return chalk && chalk[name] || function () {
2464
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
2465
- args[_key] = arguments[_key];
2466
- }
2467
- return args;
2468
- };
2469
- }
2470
- var colors = {
2471
- added: chalkColor('green'),
2472
- deleted: chalkColor('red'),
2473
- movedestination: chalkColor('gray'),
2474
- moved: chalkColor('yellow'),
2475
- unchanged: chalkColor('gray'),
2476
- error: chalkColor('white.bgRed'),
2477
- textDiffLine: chalkColor('gray')
2478
- };
2479
- var ConsoleFormatter = function (_BaseFormatter) {
2480
- inherits(ConsoleFormatter, _BaseFormatter);
2481
- function ConsoleFormatter() {
2482
- classCallCheck(this, ConsoleFormatter);
2483
- var _this = possibleConstructorReturn(this, (ConsoleFormatter.__proto__ || Object.getPrototypeOf(ConsoleFormatter)).call(this));
2484
- _this.includeMoveDestinations = false;
2485
- return _this;
2486
- }
2487
- createClass(ConsoleFormatter, [{
2488
- key: 'prepareContext',
2489
- value: function prepareContext(context) {
2490
- get(ConsoleFormatter.prototype.__proto__ || Object.getPrototypeOf(ConsoleFormatter.prototype), 'prepareContext', this).call(this, context);
2491
- context.indent = function (levels) {
2492
- this.indentLevel = (this.indentLevel || 0) + (typeof levels === 'undefined' ? 1 : levels);
2493
- this.indentPad = new Array(this.indentLevel + 1).join(' ');
2494
- this.outLine();
2495
- };
2496
- context.outLine = function () {
2497
- this.buffer.push('\n' + (this.indentPad || ''));
2498
- };
2499
- context.out = function () {
2500
- for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2501
- args[_key2] = arguments[_key2];
2502
- }
2503
- for (var i = 0, l = args.length; i < l; i++) {
2504
- var lines = args[i].split('\n');
2505
- var text = lines.join('\n' + (this.indentPad || ''));
2506
- if (this.color && this.color[0]) {
2507
- text = this.color[0](text);
2508
- }
2509
- this.buffer.push(text);
2510
- }
2511
- };
2512
- context.pushColor = function (color) {
2513
- this.color = this.color || [];
2514
- this.color.unshift(color);
2515
- };
2516
- context.popColor = function () {
2517
- this.color = this.color || [];
2518
- this.color.shift();
2519
- };
2520
- }
2521
- }, {
2522
- key: 'typeFormattterErrorFormatter',
2523
- value: function typeFormattterErrorFormatter(context, err) {
2524
- context.pushColor(colors.error);
2525
- context.out('[ERROR]' + err);
2526
- context.popColor();
2527
- }
2528
- }, {
2529
- key: 'formatValue',
2530
- value: function formatValue(context, value) {
2531
- context.out(JSON.stringify(value, null, 2));
2532
- }
2533
- }, {
2534
- key: 'formatTextDiffString',
2535
- value: function formatTextDiffString(context, value) {
2536
- var lines = this.parseTextDiff(value);
2537
- context.indent();
2538
- for (var i = 0, l = lines.length; i < l; i++) {
2539
- var line = lines[i];
2540
- context.pushColor(colors.textDiffLine);
2541
- context.out(line.location.line + ',' + line.location.chr + ' ');
2542
- context.popColor();
2543
- var pieces = line.pieces;
2544
- for (var pieceIndex = 0, piecesLength = pieces.length; pieceIndex < piecesLength; pieceIndex++) {
2545
- var piece = pieces[pieceIndex];
2546
- context.pushColor(colors[piece.type]);
2547
- context.out(piece.text);
2548
- context.popColor();
2549
- }
2550
- if (i < l - 1) {
2551
- context.outLine();
2552
- }
2553
- }
2554
- context.indent(-1);
2555
- }
2556
- }, {
2557
- key: 'rootBegin',
2558
- value: function rootBegin(context, type, nodeType) {
2559
- context.pushColor(colors[type]);
2560
- if (type === 'node') {
2561
- context.out(nodeType === 'array' ? '[' : '{');
2562
- context.indent();
2563
- }
2564
- }
2565
- }, {
2566
- key: 'rootEnd',
2567
- value: function rootEnd(context, type, nodeType) {
2568
- if (type === 'node') {
2569
- context.indent(-1);
2570
- context.out(nodeType === 'array' ? ']' : '}');
2571
- }
2572
- context.popColor();
2573
- }
2574
- }, {
2575
- key: 'nodeBegin',
2576
- value: function nodeBegin(context, key, leftKey, type, nodeType) {
2577
- context.pushColor(colors[type]);
2578
- context.out(leftKey + ': ');
2579
- if (type === 'node') {
2580
- context.out(nodeType === 'array' ? '[' : '{');
2581
- context.indent();
2582
- }
2583
- }
2584
- }, {
2585
- key: 'nodeEnd',
2586
- value: function nodeEnd(context, key, leftKey, type, nodeType, isLast) {
2587
- if (type === 'node') {
2588
- context.indent(-1);
2589
- context.out(nodeType === 'array' ? ']' : '}' + (isLast ? '' : ','));
2590
- }
2591
- if (!isLast) {
2592
- context.outLine();
2593
- }
2594
- context.popColor();
2595
- }
2596
-
2597
- /* jshint camelcase: false */
2598
- /* eslint-disable camelcase */
2599
- }, {
2600
- key: 'format_unchanged',
2601
- value: function format_unchanged(context, delta, left) {
2602
- if (typeof left === 'undefined') {
2603
- return;
2604
- }
2605
- this.formatValue(context, left);
2606
- }
2607
- }, {
2608
- key: 'format_movedestination',
2609
- value: function format_movedestination(context, delta, left) {
2610
- if (typeof left === 'undefined') {
2611
- return;
2612
- }
2613
- this.formatValue(context, left);
2614
- }
2615
- }, {
2616
- key: 'format_node',
2617
- value: function format_node(context, delta, left) {
2618
- // recurse
2619
- this.formatDeltaChildren(context, delta, left);
2620
- }
2621
- }, {
2622
- key: 'format_added',
2623
- value: function format_added(context, delta) {
2624
- this.formatValue(context, delta[0]);
2625
- }
2626
- }, {
2627
- key: 'format_modified',
2628
- value: function format_modified(context, delta) {
2629
- context.pushColor(colors.deleted);
2630
- this.formatValue(context, delta[0]);
2631
- context.popColor();
2632
- context.out(' => ');
2633
- context.pushColor(colors.added);
2634
- this.formatValue(context, delta[1]);
2635
- context.popColor();
2636
- }
2637
- }, {
2638
- key: 'format_deleted',
2639
- value: function format_deleted(context, delta) {
2640
- this.formatValue(context, delta[0]);
2641
- }
2642
- }, {
2643
- key: 'format_moved',
2644
- value: function format_moved(context, delta) {
2645
- context.out('==> ' + delta[1]);
2646
- }
2647
- }, {
2648
- key: 'format_textdiff',
2649
- value: function format_textdiff(context, delta) {
2650
- this.formatTextDiffString(context, delta[0]);
2651
- }
2652
- }]);
2653
- return ConsoleFormatter;
2654
- }(BaseFormatter);
2655
- var defaultInstance$3 = void 0;
2656
- var format$3 = function format(delta, left) {
2657
- if (!defaultInstance$3) {
2658
- defaultInstance$3 = new ConsoleFormatter();
2659
- }
2660
- return defaultInstance$3.format(delta, left);
2661
- };
2662
- function log$1(delta, left) {
2663
- console.log(format$3(delta, left));
2664
- }
2665
- var console$1 = Object.freeze({
2666
- default: ConsoleFormatter,
2667
- format: format$3,
2668
- log: log$1
2669
- });
2670
- Object.freeze({
2671
- base: base,
2672
- html: html,
2673
- annotated: annotated,
2674
- jsonpatch: jsonpatch,
2675
- console: console$1
2676
- });
2677
1508
 
2678
1509
  function objectHash(obj, index) {
2679
1510
  var objIndex = "$$index:".concat(index);
2680
- return _typeof$1(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
1511
+ return _typeof(obj) === 'object' && obj !== null ? obj.id || obj.name || obj.url || objIndex : objIndex;
2681
1512
  }
2682
1513
  var diffpatcher = new DiffPatcher({
2683
1514
  objectHash: objectHash,
@@ -2841,7 +1672,7 @@ function isCreateAction(obj, key) {
2841
1672
  * false otherwise
2842
1673
  */
2843
1674
  function isChangeAction(obj, key) {
2844
- return REGEX_NUMBER$4.test(key) && (_typeof$1(obj[key]) === 'object' || typeof obj[key] === 'string');
1675
+ return REGEX_NUMBER$4.test(key) && (_typeof(obj[key]) === 'object' || typeof obj[key] === 'string');
2845
1676
  }
2846
1677
 
2847
1678
  /**
@@ -2857,7 +1688,7 @@ function isChangeAction(obj, key) {
2857
1688
  * false otherwise
2858
1689
  */
2859
1690
  function isRemoveAction$1(obj, key) {
2860
- return REGEX_UNDERSCORE_NUMBER$4.test(key) && Array.isArray(obj[key]) && obj[key].length === 3 && (_typeof$1(obj[key][0]) === 'object' || typeof obj[key][0] === 'string') && obj[key][1] === 0 && obj[key][2] === 0;
1691
+ 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;
2861
1692
  }
2862
1693
 
2863
1694
  /**
@@ -3116,7 +1947,6 @@ function actionsMapReferences$3(diff, oldObj, newObj) {
3116
1947
  return buildReferenceActions({
3117
1948
  actions: referenceActionsList$3,
3118
1949
  diff: diff,
3119
- oldObj: oldObj,
3120
1950
  newObj: newObj
3121
1951
  });
3122
1952
  }
@@ -3157,7 +1987,7 @@ function copyEmptyArrayProps() {
3157
1987
  return acc;
3158
1988
  }, {});
3159
1989
  for (var i = 0; i < newObj[key].length; i++) {
3160
- if (!isNil(newObj[key][i]) && _typeof$1(newObj[key][i]) === 'object' && !isNil(newObj[key][i].id)) {
1990
+ if (!isNil(newObj[key][i]) && _typeof(newObj[key][i]) === 'object' && !isNil(newObj[key][i].id)) {
3161
1991
  // Since its unordered array elements then check if the element on `oldObj` exists by id
3162
1992
  var foundObject = hashMapValue[newObj[key][i].id];
3163
1993
  if (!isNil(foundObject)) {
@@ -3179,7 +2009,7 @@ function copyEmptyArrayProps() {
3179
2009
  merged[key] = isNil(newObj[key]) ? [] : newObj[key];
3180
2010
  return merged;
3181
2011
  }
3182
- if (!isNil(newObj[key]) && _typeof$1(value) === 'object' &&
2012
+ if (!isNil(newObj[key]) && _typeof(value) === 'object' &&
3183
2013
  // Ignore Date as this will create invalid object since typeof date === 'object' return true
3184
2014
  // ex: {date: new Date()} will result {date: {}}
3185
2015
  !(value instanceof Date)) {
@@ -3332,7 +2162,6 @@ function actionsMapReferences$2(diff, oldObj, newObj) {
3332
2162
  return buildReferenceActions({
3333
2163
  actions: referenceActionsList$2,
3334
2164
  diff: diff,
3335
- oldObj: oldObj,
3336
2165
  newObj: newObj
3337
2166
  });
3338
2167
  }
@@ -3530,7 +2359,6 @@ function actionsMapReferences$1(diff, oldObj, newObj) {
3530
2359
  return buildReferenceActions({
3531
2360
  actions: referenceActionsList$1,
3532
2361
  diff: diff,
3533
- oldObj: oldObj,
3534
2362
  newObj: newObj
3535
2363
  });
3536
2364
  }
@@ -3773,7 +2601,7 @@ function _buildSetAttributeAction(diffedValue, oldVariant, attribute, sameForAll
3773
2601
  currencyCode: diffedValue.currencyCode ? getDeltaValue(diffedValue.currencyCode) : attribute.value.currencyCode
3774
2602
  };else if (diffedValue.key)
3775
2603
  // Enum / LEnum (use only the key)
3776
- action.value = getDeltaValue(diffedValue.key);else if (_typeof$1(diffedValue) === 'object') if ({}.hasOwnProperty.call(diffedValue, '_t') && diffedValue._t === 'a') {
2604
+ action.value = getDeltaValue(diffedValue.key);else if (_typeof(diffedValue) === 'object') if ({}.hasOwnProperty.call(diffedValue, '_t') && diffedValue._t === 'a') {
3777
2605
  // set-typed attribute
3778
2606
  action = _objectSpread2(_objectSpread2({}, action), {}, {
3779
2607
  value: attribute.value
@@ -3805,7 +2633,7 @@ function _buildVariantImagesAction(diffedImages) {
3805
2633
  action: 'addExternalImage',
3806
2634
  variantId: oldVariant.id,
3807
2635
  image: getDeltaValue(image)
3808
- });else if (_typeof$1(image) === 'object') if ({}.hasOwnProperty.call(image, 'url') && image.url.length === 2) {
2636
+ });else if (_typeof(image) === 'object') if ({}.hasOwnProperty.call(image, 'url') && image.url.length === 2) {
3809
2637
  // There is a new image, remove the old one first.
3810
2638
  actions.push({
3811
2639
  action: 'removeImage',
@@ -4077,7 +2905,6 @@ function actionsMapReferences(diff, oldObj, newObj) {
4077
2905
  return buildReferenceActions({
4078
2906
  actions: referenceActionsList,
4079
2907
  diff: diff,
4080
- oldObj: oldObj,
4081
2908
  newObj: newObj
4082
2909
  });
4083
2910
  }
@@ -4908,8 +3735,8 @@ function createCircularEqualCreator(isEqual) {
4908
3735
  if (cache === void 0) {
4909
3736
  cache = getNewCache();
4910
3737
  }
4911
- var isCacheableA = !!a && _typeof$1(a) === 'object';
4912
- var isCacheableB = !!b && _typeof$1(b) === 'object';
3738
+ var isCacheableA = !!a && _typeof(a) === 'object';
3739
+ var isCacheableB = !!b && _typeof(b) === 'object';
4913
3740
  if (isCacheableA || isCacheableB) {
4914
3741
  var hasA = isCacheableA && cache.has(a);
4915
3742
  var hasB = isCacheableB && cache.has(b);
@@ -5075,7 +3902,7 @@ function createComparator(createIsEqual) {
5075
3902
  if (a === b) {
5076
3903
  return true;
5077
3904
  }
5078
- if (a && b && _typeof$1(a) === 'object' && _typeof$1(b) === 'object') {
3905
+ if (a && b && _typeof(a) === 'object' && _typeof(b) === 'object') {
5079
3906
  if (isPlainObject(a) && isPlainObject(b)) {
5080
3907
  return areObjectsEqual(a, b, isEqual, meta);
5081
3908
  }
@@ -5997,7 +4824,7 @@ function actionsMapFieldDefinitions(fieldDefinitionsDiff, previous, next, diffPa
5997
4824
  // in order to prevent any eventual removal of `addAction`.
5998
4825
  // List of `removeActions` can be found here
5999
4826
  // https://docs.commercetools.com/http-api-projects-types.html#change-key
6000
- var sortedActions = sortBy$1(actions, function (action) {
4827
+ var sortedActions = sortBy(actions, function (action) {
6001
4828
  return action.action !== 'removeFieldDefinition';
6002
4829
  });
6003
4830
  return sortedActions;