mocha 11.3.0 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mocha.js CHANGED
@@ -1,4 +1,4 @@
1
- // mocha@11.3.0 in javascript ES2018
1
+ // mocha@11.5.0 in javascript ES2018
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -5810,56 +5810,47 @@
5810
5810
  value: true
5811
5811
  });
5812
5812
  exports["default"] = Diff;
5813
-
5814
5813
  /*istanbul ignore end*/
5815
5814
  function Diff() {}
5816
-
5817
5815
  Diff.prototype = {
5818
5816
  /*istanbul ignore start*/
5819
-
5820
5817
  /*istanbul ignore end*/
5821
5818
  diff: function diff(oldString, newString) {
5822
5819
  /*istanbul ignore start*/
5823
5820
  var _options$timeout;
5824
-
5825
5821
  var
5826
5822
  /*istanbul ignore end*/
5827
5823
  options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5828
5824
  var callback = options.callback;
5829
-
5830
5825
  if (typeof options === 'function') {
5831
5826
  callback = options;
5832
5827
  options = {};
5833
5828
  }
5834
-
5835
- this.options = options;
5836
5829
  var self = this;
5837
-
5838
5830
  function done(value) {
5831
+ value = self.postProcess(value, options);
5839
5832
  if (callback) {
5840
5833
  setTimeout(function () {
5841
- callback(undefined, value);
5834
+ callback(value);
5842
5835
  }, 0);
5843
5836
  return true;
5844
5837
  } else {
5845
5838
  return value;
5846
5839
  }
5847
- } // Allow subclasses to massage the input prior to running
5848
-
5840
+ }
5849
5841
 
5850
- oldString = this.castInput(oldString);
5851
- newString = this.castInput(newString);
5852
- oldString = this.removeEmpty(this.tokenize(oldString));
5853
- newString = this.removeEmpty(this.tokenize(newString));
5842
+ // Allow subclasses to massage the input prior to running
5843
+ oldString = this.castInput(oldString, options);
5844
+ newString = this.castInput(newString, options);
5845
+ oldString = this.removeEmpty(this.tokenize(oldString, options));
5846
+ newString = this.removeEmpty(this.tokenize(newString, options));
5854
5847
  var newLen = newString.length,
5855
- oldLen = oldString.length;
5848
+ oldLen = oldString.length;
5856
5849
  var editLength = 1;
5857
5850
  var maxEditLength = newLen + oldLen;
5858
-
5859
- if (options.maxEditLength) {
5851
+ if (options.maxEditLength != null) {
5860
5852
  maxEditLength = Math.min(maxEditLength, options.maxEditLength);
5861
5853
  }
5862
-
5863
5854
  var maxExecutionTime =
5864
5855
  /*istanbul ignore start*/
5865
5856
  (_options$timeout =
@@ -5869,17 +5860,16 @@
5869
5860
  var bestPath = [{
5870
5861
  oldPos: -1,
5871
5862
  lastComponent: undefined
5872
- }]; // Seed editLength = 0, i.e. the content starts with the same values
5873
-
5874
- var newPos = this.extractCommon(bestPath[0], newString, oldString, 0);
5863
+ }];
5875
5864
 
5865
+ // Seed editLength = 0, i.e. the content starts with the same values
5866
+ var newPos = this.extractCommon(bestPath[0], newString, oldString, 0, options);
5876
5867
  if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
5877
5868
  // Identity per the equality and tokenizer
5878
- return done([{
5879
- value: this.join(newString),
5880
- count: newString.length
5881
- }]);
5882
- } // Once we hit the right edge of the edit graph on some diagonal k, we can
5869
+ return done(buildValues(self, bestPath[0].lastComponent, newString, oldString, self.useLongestToken));
5870
+ }
5871
+
5872
+ // Once we hit the right edge of the edit graph on some diagonal k, we can
5883
5873
  // definitely reach the end of the edit graph in no more than k edits, so
5884
5874
  // there's no point in considering any moves to diagonal k+1 any more (from
5885
5875
  // which we're guaranteed to need at least k+1 more edits).
@@ -5896,11 +5886,10 @@
5896
5886
  // where the new text simply appends d characters on the end of the
5897
5887
  // original text of length n, the true Myers algorithm will take O(n+d^2)
5898
5888
  // time while this optimization needs only O(n+d) time.
5899
-
5900
-
5901
5889
  var minDiagonalToConsider = -Infinity,
5902
- maxDiagonalToConsider = Infinity; // Main worker method. checks all permutations of a given edit length for acceptance.
5890
+ maxDiagonalToConsider = Infinity;
5903
5891
 
5892
+ // Main worker method. checks all permutations of a given edit length for acceptance.
5904
5893
  function execEditLength() {
5905
5894
  for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
5906
5895
  var basePath =
@@ -5909,72 +5898,59 @@
5909
5898
  /*istanbul ignore end*/
5910
5899
  ;
5911
5900
  var removePath = bestPath[diagonalPath - 1],
5912
- addPath = bestPath[diagonalPath + 1];
5913
-
5901
+ addPath = bestPath[diagonalPath + 1];
5914
5902
  if (removePath) {
5915
5903
  // No one else is going to attempt to use this value, clear it
5916
5904
  bestPath[diagonalPath - 1] = undefined;
5917
5905
  }
5918
-
5919
5906
  var canAdd = false;
5920
-
5921
5907
  if (addPath) {
5922
5908
  // what newPos will be after we do an insertion:
5923
5909
  var addPathNewPos = addPath.oldPos - diagonalPath;
5924
5910
  canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
5925
5911
  }
5926
-
5927
5912
  var canRemove = removePath && removePath.oldPos + 1 < oldLen;
5928
-
5929
5913
  if (!canAdd && !canRemove) {
5930
5914
  // If this path is a terminal then prune
5931
5915
  bestPath[diagonalPath] = undefined;
5932
5916
  continue;
5933
- } // Select the diagonal that we want to branch from. We select the prior
5917
+ }
5918
+
5919
+ // Select the diagonal that we want to branch from. We select the prior
5934
5920
  // path whose position in the old string is the farthest from the origin
5935
5921
  // and does not pass the bounds of the diff graph
5936
- // TODO: Remove the `+ 1` here to make behavior match Myers algorithm
5937
- // and prefer to order removals before insertions.
5938
-
5939
-
5940
- if (!canRemove || canAdd && removePath.oldPos + 1 < addPath.oldPos) {
5941
- basePath = self.addToPath(addPath, true, undefined, 0);
5922
+ if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
5923
+ basePath = self.addToPath(addPath, true, false, 0, options);
5942
5924
  } else {
5943
- basePath = self.addToPath(removePath, undefined, true, 1);
5925
+ basePath = self.addToPath(removePath, false, true, 1, options);
5944
5926
  }
5945
-
5946
- newPos = self.extractCommon(basePath, newString, oldString, diagonalPath);
5947
-
5927
+ newPos = self.extractCommon(basePath, newString, oldString, diagonalPath, options);
5948
5928
  if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
5949
5929
  // If we have hit the end of both strings, then we are done
5950
5930
  return done(buildValues(self, basePath.lastComponent, newString, oldString, self.useLongestToken));
5951
5931
  } else {
5952
5932
  bestPath[diagonalPath] = basePath;
5953
-
5954
5933
  if (basePath.oldPos + 1 >= oldLen) {
5955
5934
  maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
5956
5935
  }
5957
-
5958
5936
  if (newPos + 1 >= newLen) {
5959
5937
  minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
5960
5938
  }
5961
5939
  }
5962
5940
  }
5963
-
5964
5941
  editLength++;
5965
- } // Performs the length of edit iteration. Is a bit fugly as this has to support the
5942
+ }
5943
+
5944
+ // Performs the length of edit iteration. Is a bit fugly as this has to support the
5966
5945
  // sync and async mode which is never fun. Loops over execEditLength until a value
5967
5946
  // is produced, or until the edit length exceeds options.maxEditLength (if given),
5968
5947
  // in which case it will return undefined.
5969
-
5970
-
5971
5948
  if (callback) {
5972
5949
  (function exec() {
5973
5950
  setTimeout(function () {
5974
5951
  if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
5975
5952
  return callback();
5976
5953
  }
5977
-
5978
5954
  if (!execEditLength()) {
5979
5955
  exec();
5980
5956
  }
@@ -5983,21 +5959,17 @@
5983
5959
  } else {
5984
5960
  while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
5985
5961
  var ret = execEditLength();
5986
-
5987
5962
  if (ret) {
5988
5963
  return ret;
5989
5964
  }
5990
5965
  }
5991
5966
  }
5992
5967
  },
5993
-
5994
5968
  /*istanbul ignore start*/
5995
-
5996
5969
  /*istanbul ignore end*/
5997
- addToPath: function addToPath(path, added, removed, oldPosInc) {
5970
+ addToPath: function addToPath(path, added, removed, oldPosInc, options) {
5998
5971
  var last = path.lastComponent;
5999
-
6000
- if (last && last.added === added && last.removed === removed) {
5972
+ if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
6001
5973
  return {
6002
5974
  oldPos: path.oldPos + oldPosInc,
6003
5975
  lastComponent: {
@@ -6019,104 +5991,97 @@
6019
5991
  };
6020
5992
  }
6021
5993
  },
6022
-
6023
5994
  /*istanbul ignore start*/
6024
-
6025
5995
  /*istanbul ignore end*/
6026
- extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
5996
+ extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath, options) {
6027
5997
  var newLen = newString.length,
6028
- oldLen = oldString.length,
6029
- oldPos = basePath.oldPos,
6030
- newPos = oldPos - diagonalPath,
6031
- commonCount = 0;
6032
-
6033
- while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
5998
+ oldLen = oldString.length,
5999
+ oldPos = basePath.oldPos,
6000
+ newPos = oldPos - diagonalPath,
6001
+ commonCount = 0;
6002
+ while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldString[oldPos + 1], newString[newPos + 1], options)) {
6034
6003
  newPos++;
6035
6004
  oldPos++;
6036
6005
  commonCount++;
6006
+ if (options.oneChangePerToken) {
6007
+ basePath.lastComponent = {
6008
+ count: 1,
6009
+ previousComponent: basePath.lastComponent,
6010
+ added: false,
6011
+ removed: false
6012
+ };
6013
+ }
6037
6014
  }
6038
-
6039
- if (commonCount) {
6015
+ if (commonCount && !options.oneChangePerToken) {
6040
6016
  basePath.lastComponent = {
6041
6017
  count: commonCount,
6042
- previousComponent: basePath.lastComponent
6018
+ previousComponent: basePath.lastComponent,
6019
+ added: false,
6020
+ removed: false
6043
6021
  };
6044
6022
  }
6045
-
6046
6023
  basePath.oldPos = oldPos;
6047
6024
  return newPos;
6048
6025
  },
6049
-
6050
6026
  /*istanbul ignore start*/
6051
-
6052
6027
  /*istanbul ignore end*/
6053
- equals: function equals(left, right) {
6054
- if (this.options.comparator) {
6055
- return this.options.comparator(left, right);
6028
+ equals: function equals(left, right, options) {
6029
+ if (options.comparator) {
6030
+ return options.comparator(left, right);
6056
6031
  } else {
6057
- return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
6032
+ return left === right || options.ignoreCase && left.toLowerCase() === right.toLowerCase();
6058
6033
  }
6059
6034
  },
6060
-
6061
6035
  /*istanbul ignore start*/
6062
-
6063
6036
  /*istanbul ignore end*/
6064
6037
  removeEmpty: function removeEmpty(array) {
6065
6038
  var ret = [];
6066
-
6067
6039
  for (var i = 0; i < array.length; i++) {
6068
6040
  if (array[i]) {
6069
6041
  ret.push(array[i]);
6070
6042
  }
6071
6043
  }
6072
-
6073
6044
  return ret;
6074
6045
  },
6075
-
6076
6046
  /*istanbul ignore start*/
6077
-
6078
6047
  /*istanbul ignore end*/
6079
6048
  castInput: function castInput(value) {
6080
6049
  return value;
6081
6050
  },
6082
-
6083
6051
  /*istanbul ignore start*/
6084
-
6085
6052
  /*istanbul ignore end*/
6086
6053
  tokenize: function tokenize(value) {
6087
- return value.split('');
6054
+ return Array.from(value);
6088
6055
  },
6089
-
6090
6056
  /*istanbul ignore start*/
6091
-
6092
6057
  /*istanbul ignore end*/
6093
6058
  join: function join(chars) {
6094
6059
  return chars.join('');
6060
+ },
6061
+ /*istanbul ignore start*/
6062
+ /*istanbul ignore end*/
6063
+ postProcess: function postProcess(changeObjects) {
6064
+ return changeObjects;
6095
6065
  }
6096
6066
  };
6097
-
6098
6067
  function buildValues(diff, lastComponent, newString, oldString, useLongestToken) {
6099
6068
  // First we convert our linked list of components in reverse order to an
6100
6069
  // array in the right order:
6101
6070
  var components = [];
6102
6071
  var nextComponent;
6103
-
6104
6072
  while (lastComponent) {
6105
6073
  components.push(lastComponent);
6106
6074
  nextComponent = lastComponent.previousComponent;
6107
6075
  delete lastComponent.previousComponent;
6108
6076
  lastComponent = nextComponent;
6109
6077
  }
6110
-
6111
6078
  components.reverse();
6112
6079
  var componentPos = 0,
6113
- componentLen = components.length,
6114
- newPos = 0,
6115
- oldPos = 0;
6116
-
6080
+ componentLen = components.length,
6081
+ newPos = 0,
6082
+ oldPos = 0;
6117
6083
  for (; componentPos < componentLen; componentPos++) {
6118
6084
  var component = components[componentPos];
6119
-
6120
6085
  if (!component.removed) {
6121
6086
  if (!component.added && useLongestToken) {
6122
6087
  var value = newString.slice(newPos, newPos + component.count);
@@ -6128,36 +6093,17 @@
6128
6093
  } else {
6129
6094
  component.value = diff.join(newString.slice(newPos, newPos + component.count));
6130
6095
  }
6096
+ newPos += component.count;
6131
6097
 
6132
- newPos += component.count; // Common case
6133
-
6098
+ // Common case
6134
6099
  if (!component.added) {
6135
6100
  oldPos += component.count;
6136
6101
  }
6137
6102
  } else {
6138
6103
  component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
6139
- oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
6140
- // The diffing algorithm is tied to add then remove output and this is the simplest
6141
- // route to get the desired output with minimal overhead.
6142
-
6143
- if (componentPos && components[componentPos - 1].added) {
6144
- var tmp = components[componentPos - 1];
6145
- components[componentPos - 1] = components[componentPos];
6146
- components[componentPos] = tmp;
6147
- }
6104
+ oldPos += component.count;
6148
6105
  }
6149
- } // Special case handle for when one terminal is ignored (i.e. whitespace).
6150
- // For this case we merge the terminal into the prior string and drop the change.
6151
- // This is only available for string mode.
6152
-
6153
-
6154
- var finalComponent = components[componentLen - 1];
6155
-
6156
- if (componentLen > 1 && typeof finalComponent.value === 'string' && (finalComponent.added || finalComponent.removed) && diff.equals('', finalComponent.value)) {
6157
- components[componentLen - 2].value += finalComponent.value;
6158
- components.pop();
6159
6106
  }
6160
-
6161
6107
  return components;
6162
6108
  }
6163
6109
 
@@ -6170,20 +6116,21 @@
6170
6116
  Object.defineProperty(character, "__esModule", {
6171
6117
  value: true
6172
6118
  });
6173
- character.diffChars = diffChars;
6174
6119
  character.characterDiff = void 0;
6175
-
6120
+ character.diffChars = diffChars;
6176
6121
  /*istanbul ignore end*/
6177
6122
  var
6178
6123
  /*istanbul ignore start*/
6179
6124
  _base$6 = _interopRequireDefault$7(base)
6180
6125
  /*istanbul ignore end*/
6181
6126
  ;
6182
-
6183
6127
  /*istanbul ignore start*/ function _interopRequireDefault$7(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6184
-
6185
6128
  /*istanbul ignore end*/
6186
- var characterDiff = new
6129
+ var characterDiff =
6130
+ /*istanbul ignore start*/
6131
+ character.characterDiff =
6132
+ /*istanbul ignore end*/
6133
+ new
6187
6134
  /*istanbul ignore start*/
6188
6135
  _base$6
6189
6136
  /*istanbul ignore end*/
@@ -6192,40 +6139,142 @@
6192
6139
  "default"
6193
6140
  /*istanbul ignore end*/
6194
6141
  ]();
6195
-
6196
- /*istanbul ignore start*/
6197
- character.characterDiff = characterDiff;
6198
-
6199
- /*istanbul ignore end*/
6200
6142
  function diffChars(oldStr, newStr, options) {
6201
6143
  return characterDiff.diff(oldStr, newStr, options);
6202
6144
  }
6203
6145
 
6204
6146
  var word = {};
6205
6147
 
6206
- var params = {};
6148
+ var string = {};
6207
6149
 
6208
6150
  /*istanbul ignore start*/
6209
6151
 
6210
- Object.defineProperty(params, "__esModule", {
6152
+ Object.defineProperty(string, "__esModule", {
6211
6153
  value: true
6212
6154
  });
6213
- params.generateOptions = generateOptions;
6214
-
6155
+ string.hasOnlyUnixLineEndings = hasOnlyUnixLineEndings;
6156
+ string.hasOnlyWinLineEndings = hasOnlyWinLineEndings;
6157
+ string.longestCommonPrefix = longestCommonPrefix;
6158
+ string.longestCommonSuffix = longestCommonSuffix;
6159
+ string.maximumOverlap = maximumOverlap;
6160
+ string.removePrefix = removePrefix;
6161
+ string.removeSuffix = removeSuffix;
6162
+ string.replacePrefix = replacePrefix;
6163
+ string.replaceSuffix = replaceSuffix;
6215
6164
  /*istanbul ignore end*/
6216
- function generateOptions(options, defaults) {
6217
- if (typeof options === 'function') {
6218
- defaults.callback = options;
6219
- } else if (options) {
6220
- for (var name in options) {
6221
- /* istanbul ignore else */
6222
- if (options.hasOwnProperty(name)) {
6223
- defaults[name] = options[name];
6224
- }
6165
+ function longestCommonPrefix(str1, str2) {
6166
+ var i;
6167
+ for (i = 0; i < str1.length && i < str2.length; i++) {
6168
+ if (str1[i] != str2[i]) {
6169
+ return str1.slice(0, i);
6225
6170
  }
6226
6171
  }
6172
+ return str1.slice(0, i);
6173
+ }
6174
+ function longestCommonSuffix(str1, str2) {
6175
+ var i;
6227
6176
 
6228
- return defaults;
6177
+ // Unlike longestCommonPrefix, we need a special case to handle all scenarios
6178
+ // where we return the empty string since str1.slice(-0) will return the
6179
+ // entire string.
6180
+ if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
6181
+ return '';
6182
+ }
6183
+ for (i = 0; i < str1.length && i < str2.length; i++) {
6184
+ if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
6185
+ return str1.slice(-i);
6186
+ }
6187
+ }
6188
+ return str1.slice(-i);
6189
+ }
6190
+ function replacePrefix(string, oldPrefix, newPrefix) {
6191
+ if (string.slice(0, oldPrefix.length) != oldPrefix) {
6192
+ throw Error(
6193
+ /*istanbul ignore start*/
6194
+ "string ".concat(
6195
+ /*istanbul ignore end*/
6196
+ JSON.stringify(string), " doesn't start with prefix ").concat(JSON.stringify(oldPrefix), "; this is a bug"));
6197
+ }
6198
+ return newPrefix + string.slice(oldPrefix.length);
6199
+ }
6200
+ function replaceSuffix(string, oldSuffix, newSuffix) {
6201
+ if (!oldSuffix) {
6202
+ return string + newSuffix;
6203
+ }
6204
+ if (string.slice(-oldSuffix.length) != oldSuffix) {
6205
+ throw Error(
6206
+ /*istanbul ignore start*/
6207
+ "string ".concat(
6208
+ /*istanbul ignore end*/
6209
+ JSON.stringify(string), " doesn't end with suffix ").concat(JSON.stringify(oldSuffix), "; this is a bug"));
6210
+ }
6211
+ return string.slice(0, -oldSuffix.length) + newSuffix;
6212
+ }
6213
+ function removePrefix(string, oldPrefix) {
6214
+ return replacePrefix(string, oldPrefix, '');
6215
+ }
6216
+ function removeSuffix(string, oldSuffix) {
6217
+ return replaceSuffix(string, oldSuffix, '');
6218
+ }
6219
+ function maximumOverlap(string1, string2) {
6220
+ return string2.slice(0, overlapCount(string1, string2));
6221
+ }
6222
+
6223
+ // Nicked from https://stackoverflow.com/a/60422853/1709587
6224
+ function overlapCount(a, b) {
6225
+ // Deal with cases where the strings differ in length
6226
+ var startA = 0;
6227
+ if (a.length > b.length) {
6228
+ startA = a.length - b.length;
6229
+ }
6230
+ var endB = b.length;
6231
+ if (a.length < b.length) {
6232
+ endB = a.length;
6233
+ }
6234
+ // Create a back-reference for each index
6235
+ // that should be followed in case of a mismatch.
6236
+ // We only need B to make these references:
6237
+ var map = Array(endB);
6238
+ var k = 0; // Index that lags behind j
6239
+ map[0] = 0;
6240
+ for (var j = 1; j < endB; j++) {
6241
+ if (b[j] == b[k]) {
6242
+ map[j] = map[k]; // skip over the same character (optional optimisation)
6243
+ } else {
6244
+ map[j] = k;
6245
+ }
6246
+ while (k > 0 && b[j] != b[k]) {
6247
+ k = map[k];
6248
+ }
6249
+ if (b[j] == b[k]) {
6250
+ k++;
6251
+ }
6252
+ }
6253
+ // Phase 2: use these references while iterating over A
6254
+ k = 0;
6255
+ for (var i = startA; i < a.length; i++) {
6256
+ while (k > 0 && a[i] != b[k]) {
6257
+ k = map[k];
6258
+ }
6259
+ if (a[i] == b[k]) {
6260
+ k++;
6261
+ }
6262
+ }
6263
+ return k;
6264
+ }
6265
+
6266
+ /**
6267
+ * Returns true if the string consistently uses Windows line endings.
6268
+ */
6269
+ function hasOnlyWinLineEndings(string) {
6270
+ return string.includes('\r\n') && !string.startsWith('\n') && !string.match(/[^\r]\n/);
6271
+ }
6272
+
6273
+ /**
6274
+ * Returns true if the string consistently uses Unix line endings.
6275
+ */
6276
+ function hasOnlyUnixLineEndings(string) {
6277
+ return !string.includes('\r\n') && string.includes('\n');
6229
6278
  }
6230
6279
 
6231
6280
  /*istanbul ignore start*/
@@ -6235,23 +6284,19 @@
6235
6284
  });
6236
6285
  word.diffWords = diffWords;
6237
6286
  word.diffWordsWithSpace = diffWordsWithSpace;
6238
- word.wordDiff = void 0;
6239
-
6287
+ word.wordWithSpaceDiff = word.wordDiff = void 0;
6240
6288
  /*istanbul ignore end*/
6241
6289
  var
6242
6290
  /*istanbul ignore start*/
6243
6291
  _base$5 = _interopRequireDefault$6(base)
6244
6292
  /*istanbul ignore end*/
6245
6293
  ;
6246
-
6247
6294
  var
6248
6295
  /*istanbul ignore start*/
6249
- _params$1 = params
6296
+ _string$1 = string
6250
6297
  /*istanbul ignore end*/
6251
6298
  ;
6252
-
6253
6299
  /*istanbul ignore start*/ function _interopRequireDefault$6(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6254
-
6255
6300
  /*istanbul ignore end*/
6256
6301
  // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
6257
6302
  //
@@ -6271,9 +6316,43 @@
6271
6316
  // - U+02DC ˜ &#732; Small Tilde
6272
6317
  // - U+02DD ˝ &#733; Double Acute Accent
6273
6318
  // Latin Extended Additional, 1E00–1EFF
6274
- var extendedWordChars = /^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/;
6275
- var reWhitespace = /\S/;
6276
- var wordDiff = new
6319
+ var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";
6320
+
6321
+ // Each token is one of the following:
6322
+ // - A punctuation mark plus the surrounding whitespace
6323
+ // - A word plus the surrounding whitespace
6324
+ // - Pure whitespace (but only in the special case where this the entire text
6325
+ // is just whitespace)
6326
+ //
6327
+ // We have to include surrounding whitespace in the tokens because the two
6328
+ // alternative approaches produce horribly broken results:
6329
+ // * If we just discard the whitespace, we can't fully reproduce the original
6330
+ // text from the sequence of tokens and any attempt to render the diff will
6331
+ // get the whitespace wrong.
6332
+ // * If we have separate tokens for whitespace, then in a typical text every
6333
+ // second token will be a single space character. But this often results in
6334
+ // the optimal diff between two texts being a perverse one that preserves
6335
+ // the spaces between words but deletes and reinserts actual common words.
6336
+ // See https://github.com/kpdecker/jsdiff/issues/160#issuecomment-1866099640
6337
+ // for an example.
6338
+ //
6339
+ // Keeping the surrounding whitespace of course has implications for .equals
6340
+ // and .join, not just .tokenize.
6341
+
6342
+ // This regex does NOT fully implement the tokenization rules described above.
6343
+ // Instead, it gives runs of whitespace their own "token". The tokenize method
6344
+ // then handles stitching whitespace tokens onto adjacent word or punctuation
6345
+ // tokens.
6346
+ var tokenizeIncludingWhitespace = new RegExp(
6347
+ /*istanbul ignore start*/
6348
+ "[".concat(
6349
+ /*istanbul ignore end*/
6350
+ extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), 'ug');
6351
+ var wordDiff =
6352
+ /*istanbul ignore start*/
6353
+ word.wordDiff =
6354
+ /*istanbul ignore end*/
6355
+ new
6277
6356
  /*istanbul ignore start*/
6278
6357
  _base$5
6279
6358
  /*istanbul ignore end*/
@@ -6282,139 +6361,576 @@
6282
6361
  "default"
6283
6362
  /*istanbul ignore end*/
6284
6363
  ]();
6285
-
6286
- /*istanbul ignore start*/
6287
- word.wordDiff = wordDiff;
6288
-
6289
- /*istanbul ignore end*/
6290
- wordDiff.equals = function (left, right) {
6291
- if (this.options.ignoreCase) {
6364
+ wordDiff.equals = function (left, right, options) {
6365
+ if (options.ignoreCase) {
6292
6366
  left = left.toLowerCase();
6293
6367
  right = right.toLowerCase();
6294
6368
  }
6295
-
6296
- return left === right || this.options.ignoreWhitespace && !reWhitespace.test(left) && !reWhitespace.test(right);
6369
+ return left.trim() === right.trim();
6297
6370
  };
6298
-
6299
6371
  wordDiff.tokenize = function (value) {
6300
- // All whitespace symbols except newline group into one token, each newline - in separate token
6301
- var tokens = value.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/); // Join the boundary splits that we do not consider to be boundaries. This is primarily the extended Latin character set.
6302
-
6303
- for (var i = 0; i < tokens.length - 1; i++) {
6304
- // If we have an empty string in the next field and we have only word chars before and after, merge
6305
- if (!tokens[i + 1] && tokens[i + 2] && extendedWordChars.test(tokens[i]) && extendedWordChars.test(tokens[i + 2])) {
6306
- tokens[i] += tokens[i + 2];
6307
- tokens.splice(i + 1, 2);
6308
- i--;
6309
- }
6310
- }
6311
-
6312
- return tokens;
6313
- };
6314
-
6315
- function diffWords(oldStr, newStr, options) {
6316
- options =
6317
- /*istanbul ignore start*/
6318
- (/*istanbul ignore end*/
6319
-
6320
- /*istanbul ignore start*/
6321
- 0, _params$1
6322
- /*istanbul ignore end*/
6323
- .
6324
6372
  /*istanbul ignore start*/
6325
- generateOptions)
6373
+ var
6326
6374
  /*istanbul ignore end*/
6327
- (options, {
6328
- ignoreWhitespace: true
6375
+ options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6376
+ var parts;
6377
+ if (options.intlSegmenter) {
6378
+ if (options.intlSegmenter.resolvedOptions().granularity != 'word') {
6379
+ throw new Error('The segmenter passed must have a granularity of "word"');
6380
+ }
6381
+ parts = Array.from(options.intlSegmenter.segment(value), function (segment)
6382
+ /*istanbul ignore start*/
6383
+ {
6384
+ return (
6385
+ /*istanbul ignore end*/
6386
+ segment.segment
6387
+ );
6388
+ });
6389
+ } else {
6390
+ parts = value.match(tokenizeIncludingWhitespace) || [];
6391
+ }
6392
+ var tokens = [];
6393
+ var prevPart = null;
6394
+ parts.forEach(function (part) {
6395
+ if (/\s/.test(part)) {
6396
+ if (prevPart == null) {
6397
+ tokens.push(part);
6398
+ } else {
6399
+ tokens.push(tokens.pop() + part);
6400
+ }
6401
+ } else if (/\s/.test(prevPart)) {
6402
+ if (tokens[tokens.length - 1] == prevPart) {
6403
+ tokens.push(tokens.pop() + part);
6404
+ } else {
6405
+ tokens.push(prevPart + part);
6406
+ }
6407
+ } else {
6408
+ tokens.push(part);
6409
+ }
6410
+ prevPart = part;
6329
6411
  });
6330
- return wordDiff.diff(oldStr, newStr, options);
6331
- }
6332
-
6333
- function diffWordsWithSpace(oldStr, newStr, options) {
6334
- return wordDiff.diff(oldStr, newStr, options);
6335
- }
6336
-
6337
- var line = {};
6338
-
6339
- /*istanbul ignore start*/
6340
-
6341
- Object.defineProperty(line, "__esModule", {
6342
- value: true
6343
- });
6344
- line.diffLines = diffLines;
6345
- line.diffTrimmedLines = diffTrimmedLines;
6346
- line.lineDiff = void 0;
6347
-
6348
- /*istanbul ignore end*/
6349
- var
6350
- /*istanbul ignore start*/
6351
- _base$4 = _interopRequireDefault$5(base)
6352
- /*istanbul ignore end*/
6353
- ;
6354
-
6355
- var
6356
- /*istanbul ignore start*/
6357
- _params = params
6358
- /*istanbul ignore end*/
6359
- ;
6360
-
6361
- /*istanbul ignore start*/ function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6362
-
6363
- /*istanbul ignore end*/
6364
- var lineDiff = new
6365
- /*istanbul ignore start*/
6366
- _base$4
6367
- /*istanbul ignore end*/
6368
- [
6369
- /*istanbul ignore start*/
6370
- "default"
6371
- /*istanbul ignore end*/
6372
- ]();
6373
-
6374
- /*istanbul ignore start*/
6375
- line.lineDiff = lineDiff;
6376
-
6377
- /*istanbul ignore end*/
6378
- lineDiff.tokenize = function (value) {
6379
- if (this.options.stripTrailingCr) {
6380
- // remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
6381
- value = value.replace(/\r\n/g, '\n');
6412
+ return tokens;
6413
+ };
6414
+ wordDiff.join = function (tokens) {
6415
+ // Tokens being joined here will always have appeared consecutively in the
6416
+ // same text, so we can simply strip off the leading whitespace from all the
6417
+ // tokens except the first (and except any whitespace-only tokens - but such
6418
+ // a token will always be the first and only token anyway) and then join them
6419
+ // and the whitespace around words and punctuation will end up correct.
6420
+ return tokens.map(function (token, i) {
6421
+ if (i == 0) {
6422
+ return token;
6423
+ } else {
6424
+ return token.replace(/^\s+/, '');
6425
+ }
6426
+ }).join('');
6427
+ };
6428
+ wordDiff.postProcess = function (changes, options) {
6429
+ if (!changes || options.oneChangePerToken) {
6430
+ return changes;
6382
6431
  }
6383
-
6384
- var retLines = [],
6385
- linesAndNewlines = value.split(/(\n|\r\n)/); // Ignore the final empty token that occurs if the string ends with a new line
6386
-
6387
- if (!linesAndNewlines[linesAndNewlines.length - 1]) {
6388
- linesAndNewlines.pop();
6389
- } // Merge the content and line separators into single tokens
6390
-
6391
-
6392
- for (var i = 0; i < linesAndNewlines.length; i++) {
6393
- var line = linesAndNewlines[i];
6394
-
6395
- if (i % 2 && !this.options.newlineIsToken) {
6396
- retLines[retLines.length - 1] += line;
6432
+ var lastKeep = null;
6433
+ // Change objects representing any insertion or deletion since the last
6434
+ // "keep" change object. There can be at most one of each.
6435
+ var insertion = null;
6436
+ var deletion = null;
6437
+ changes.forEach(function (change) {
6438
+ if (change.added) {
6439
+ insertion = change;
6440
+ } else if (change.removed) {
6441
+ deletion = change;
6397
6442
  } else {
6398
- if (this.options.ignoreWhitespace) {
6399
- line = line.trim();
6443
+ if (insertion || deletion) {
6444
+ // May be false at start of text
6445
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
6400
6446
  }
6401
-
6402
- retLines.push(line);
6447
+ lastKeep = change;
6448
+ insertion = null;
6449
+ deletion = null;
6403
6450
  }
6451
+ });
6452
+ if (insertion || deletion) {
6453
+ dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
6404
6454
  }
6405
-
6406
- return retLines;
6455
+ return changes;
6456
+ };
6457
+ function diffWords(oldStr, newStr, options) {
6458
+ // This option has never been documented and never will be (it's clearer to
6459
+ // just call `diffWordsWithSpace` directly if you need that behavior), but
6460
+ // has existed in jsdiff for a long time, so we retain support for it here
6461
+ // for the sake of backwards compatibility.
6462
+ if (
6463
+ /*istanbul ignore start*/
6464
+ (
6465
+ /*istanbul ignore end*/
6466
+ options === null || options === void 0 ? void 0 : options.ignoreWhitespace) != null && !options.ignoreWhitespace) {
6467
+ return diffWordsWithSpace(oldStr, newStr, options);
6468
+ }
6469
+ return wordDiff.diff(oldStr, newStr, options);
6470
+ }
6471
+ function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
6472
+ // Before returning, we tidy up the leading and trailing whitespace of the
6473
+ // change objects to eliminate cases where trailing whitespace in one object
6474
+ // is repeated as leading whitespace in the next.
6475
+ // Below are examples of the outcomes we want here to explain the code.
6476
+ // I=insert, K=keep, D=delete
6477
+ // 1. diffing 'foo bar baz' vs 'foo baz'
6478
+ // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
6479
+ // After cleanup, we want: K:'foo ' D:'bar ' K:'baz'
6480
+ //
6481
+ // 2. Diffing 'foo bar baz' vs 'foo qux baz'
6482
+ // Prior to cleanup, we have K:'foo ' D:' bar ' I:' qux ' K:' baz'
6483
+ // After cleanup, we want K:'foo ' D:'bar' I:'qux' K:' baz'
6484
+ //
6485
+ // 3. Diffing 'foo\nbar baz' vs 'foo baz'
6486
+ // Prior to cleanup, we have K:'foo ' D:'\nbar ' K:' baz'
6487
+ // After cleanup, we want K'foo' D:'\nbar' K:' baz'
6488
+ //
6489
+ // 4. Diffing 'foo baz' vs 'foo\nbar baz'
6490
+ // Prior to cleanup, we have K:'foo\n' I:'\nbar ' K:' baz'
6491
+ // After cleanup, we ideally want K'foo' I:'\nbar' K:' baz'
6492
+ // but don't actually manage this currently (the pre-cleanup change
6493
+ // objects don't contain enough information to make it possible).
6494
+ //
6495
+ // 5. Diffing 'foo bar baz' vs 'foo baz'
6496
+ // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
6497
+ // After cleanup, we want K:'foo ' D:' bar ' K:'baz'
6498
+ //
6499
+ // Our handling is unavoidably imperfect in the case where there's a single
6500
+ // indel between keeps and the whitespace has changed. For instance, consider
6501
+ // diffing 'foo\tbar\nbaz' vs 'foo baz'. Unless we create an extra change
6502
+ // object to represent the insertion of the space character (which isn't even
6503
+ // a token), we have no way to avoid losing information about the texts'
6504
+ // original whitespace in the result we return. Still, we do our best to
6505
+ // output something that will look sensible if we e.g. print it with
6506
+ // insertions in green and deletions in red.
6507
+
6508
+ // Between two "keep" change objects (or before the first or after the last
6509
+ // change object), we can have either:
6510
+ // * A "delete" followed by an "insert"
6511
+ // * Just an "insert"
6512
+ // * Just a "delete"
6513
+ // We handle the three cases separately.
6514
+ if (deletion && insertion) {
6515
+ var oldWsPrefix = deletion.value.match(/^\s*/)[0];
6516
+ var oldWsSuffix = deletion.value.match(/\s*$/)[0];
6517
+ var newWsPrefix = insertion.value.match(/^\s*/)[0];
6518
+ var newWsSuffix = insertion.value.match(/\s*$/)[0];
6519
+ if (startKeep) {
6520
+ var commonWsPrefix =
6521
+ /*istanbul ignore start*/
6522
+ (/*istanbul ignore end*/
6523
+ /*istanbul ignore start*/
6524
+ 0, _string$1
6525
+ /*istanbul ignore end*/
6526
+ .
6527
+ /*istanbul ignore start*/
6528
+ longestCommonPrefix)
6529
+ /*istanbul ignore end*/
6530
+ (oldWsPrefix, newWsPrefix);
6531
+ startKeep.value =
6532
+ /*istanbul ignore start*/
6533
+ (/*istanbul ignore end*/
6534
+ /*istanbul ignore start*/
6535
+ 0, _string$1
6536
+ /*istanbul ignore end*/
6537
+ .
6538
+ /*istanbul ignore start*/
6539
+ replaceSuffix)
6540
+ /*istanbul ignore end*/
6541
+ (startKeep.value, newWsPrefix, commonWsPrefix);
6542
+ deletion.value =
6543
+ /*istanbul ignore start*/
6544
+ (/*istanbul ignore end*/
6545
+ /*istanbul ignore start*/
6546
+ 0, _string$1
6547
+ /*istanbul ignore end*/
6548
+ .
6549
+ /*istanbul ignore start*/
6550
+ removePrefix)
6551
+ /*istanbul ignore end*/
6552
+ (deletion.value, commonWsPrefix);
6553
+ insertion.value =
6554
+ /*istanbul ignore start*/
6555
+ (/*istanbul ignore end*/
6556
+ /*istanbul ignore start*/
6557
+ 0, _string$1
6558
+ /*istanbul ignore end*/
6559
+ .
6560
+ /*istanbul ignore start*/
6561
+ removePrefix)
6562
+ /*istanbul ignore end*/
6563
+ (insertion.value, commonWsPrefix);
6564
+ }
6565
+ if (endKeep) {
6566
+ var commonWsSuffix =
6567
+ /*istanbul ignore start*/
6568
+ (/*istanbul ignore end*/
6569
+ /*istanbul ignore start*/
6570
+ 0, _string$1
6571
+ /*istanbul ignore end*/
6572
+ .
6573
+ /*istanbul ignore start*/
6574
+ longestCommonSuffix)
6575
+ /*istanbul ignore end*/
6576
+ (oldWsSuffix, newWsSuffix);
6577
+ endKeep.value =
6578
+ /*istanbul ignore start*/
6579
+ (/*istanbul ignore end*/
6580
+ /*istanbul ignore start*/
6581
+ 0, _string$1
6582
+ /*istanbul ignore end*/
6583
+ .
6584
+ /*istanbul ignore start*/
6585
+ replacePrefix)
6586
+ /*istanbul ignore end*/
6587
+ (endKeep.value, newWsSuffix, commonWsSuffix);
6588
+ deletion.value =
6589
+ /*istanbul ignore start*/
6590
+ (/*istanbul ignore end*/
6591
+ /*istanbul ignore start*/
6592
+ 0, _string$1
6593
+ /*istanbul ignore end*/
6594
+ .
6595
+ /*istanbul ignore start*/
6596
+ removeSuffix)
6597
+ /*istanbul ignore end*/
6598
+ (deletion.value, commonWsSuffix);
6599
+ insertion.value =
6600
+ /*istanbul ignore start*/
6601
+ (/*istanbul ignore end*/
6602
+ /*istanbul ignore start*/
6603
+ 0, _string$1
6604
+ /*istanbul ignore end*/
6605
+ .
6606
+ /*istanbul ignore start*/
6607
+ removeSuffix)
6608
+ /*istanbul ignore end*/
6609
+ (insertion.value, commonWsSuffix);
6610
+ }
6611
+ } else if (insertion) {
6612
+ // The whitespaces all reflect what was in the new text rather than
6613
+ // the old, so we essentially have no information about whitespace
6614
+ // insertion or deletion. We just want to dedupe the whitespace.
6615
+ // We do that by having each change object keep its trailing
6616
+ // whitespace and deleting duplicate leading whitespace where
6617
+ // present.
6618
+ if (startKeep) {
6619
+ insertion.value = insertion.value.replace(/^\s*/, '');
6620
+ }
6621
+ if (endKeep) {
6622
+ endKeep.value = endKeep.value.replace(/^\s*/, '');
6623
+ }
6624
+ // otherwise we've got a deletion and no insertion
6625
+ } else if (startKeep && endKeep) {
6626
+ var newWsFull = endKeep.value.match(/^\s*/)[0],
6627
+ delWsStart = deletion.value.match(/^\s*/)[0],
6628
+ delWsEnd = deletion.value.match(/\s*$/)[0];
6629
+
6630
+ // Any whitespace that comes straight after startKeep in both the old and
6631
+ // new texts, assign to startKeep and remove from the deletion.
6632
+ var newWsStart =
6633
+ /*istanbul ignore start*/
6634
+ (/*istanbul ignore end*/
6635
+ /*istanbul ignore start*/
6636
+ 0, _string$1
6637
+ /*istanbul ignore end*/
6638
+ .
6639
+ /*istanbul ignore start*/
6640
+ longestCommonPrefix)
6641
+ /*istanbul ignore end*/
6642
+ (newWsFull, delWsStart);
6643
+ deletion.value =
6644
+ /*istanbul ignore start*/
6645
+ (/*istanbul ignore end*/
6646
+ /*istanbul ignore start*/
6647
+ 0, _string$1
6648
+ /*istanbul ignore end*/
6649
+ .
6650
+ /*istanbul ignore start*/
6651
+ removePrefix)
6652
+ /*istanbul ignore end*/
6653
+ (deletion.value, newWsStart);
6654
+
6655
+ // Any whitespace that comes straight before endKeep in both the old and
6656
+ // new texts, and hasn't already been assigned to startKeep, assign to
6657
+ // endKeep and remove from the deletion.
6658
+ var newWsEnd =
6659
+ /*istanbul ignore start*/
6660
+ (/*istanbul ignore end*/
6661
+ /*istanbul ignore start*/
6662
+ 0, _string$1
6663
+ /*istanbul ignore end*/
6664
+ .
6665
+ /*istanbul ignore start*/
6666
+ longestCommonSuffix)
6667
+ /*istanbul ignore end*/
6668
+ (
6669
+ /*istanbul ignore start*/
6670
+ (/*istanbul ignore end*/
6671
+ /*istanbul ignore start*/
6672
+ 0, _string$1
6673
+ /*istanbul ignore end*/
6674
+ .
6675
+ /*istanbul ignore start*/
6676
+ removePrefix)
6677
+ /*istanbul ignore end*/
6678
+ (newWsFull, newWsStart), delWsEnd);
6679
+ deletion.value =
6680
+ /*istanbul ignore start*/
6681
+ (/*istanbul ignore end*/
6682
+ /*istanbul ignore start*/
6683
+ 0, _string$1
6684
+ /*istanbul ignore end*/
6685
+ .
6686
+ /*istanbul ignore start*/
6687
+ removeSuffix)
6688
+ /*istanbul ignore end*/
6689
+ (deletion.value, newWsEnd);
6690
+ endKeep.value =
6691
+ /*istanbul ignore start*/
6692
+ (/*istanbul ignore end*/
6693
+ /*istanbul ignore start*/
6694
+ 0, _string$1
6695
+ /*istanbul ignore end*/
6696
+ .
6697
+ /*istanbul ignore start*/
6698
+ replacePrefix)
6699
+ /*istanbul ignore end*/
6700
+ (endKeep.value, newWsFull, newWsEnd);
6701
+
6702
+ // If there's any whitespace from the new text that HASN'T already been
6703
+ // assigned, assign it to the start:
6704
+ startKeep.value =
6705
+ /*istanbul ignore start*/
6706
+ (/*istanbul ignore end*/
6707
+ /*istanbul ignore start*/
6708
+ 0, _string$1
6709
+ /*istanbul ignore end*/
6710
+ .
6711
+ /*istanbul ignore start*/
6712
+ replaceSuffix)
6713
+ /*istanbul ignore end*/
6714
+ (startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
6715
+ } else if (endKeep) {
6716
+ // We are at the start of the text. Preserve all the whitespace on
6717
+ // endKeep, and just remove whitespace from the end of deletion to the
6718
+ // extent that it overlaps with the start of endKeep.
6719
+ var endKeepWsPrefix = endKeep.value.match(/^\s*/)[0];
6720
+ var deletionWsSuffix = deletion.value.match(/\s*$/)[0];
6721
+ var overlap =
6722
+ /*istanbul ignore start*/
6723
+ (/*istanbul ignore end*/
6724
+ /*istanbul ignore start*/
6725
+ 0, _string$1
6726
+ /*istanbul ignore end*/
6727
+ .
6728
+ /*istanbul ignore start*/
6729
+ maximumOverlap)
6730
+ /*istanbul ignore end*/
6731
+ (deletionWsSuffix, endKeepWsPrefix);
6732
+ deletion.value =
6733
+ /*istanbul ignore start*/
6734
+ (/*istanbul ignore end*/
6735
+ /*istanbul ignore start*/
6736
+ 0, _string$1
6737
+ /*istanbul ignore end*/
6738
+ .
6739
+ /*istanbul ignore start*/
6740
+ removeSuffix)
6741
+ /*istanbul ignore end*/
6742
+ (deletion.value, overlap);
6743
+ } else if (startKeep) {
6744
+ // We are at the END of the text. Preserve all the whitespace on
6745
+ // startKeep, and just remove whitespace from the start of deletion to
6746
+ // the extent that it overlaps with the end of startKeep.
6747
+ var startKeepWsSuffix = startKeep.value.match(/\s*$/)[0];
6748
+ var deletionWsPrefix = deletion.value.match(/^\s*/)[0];
6749
+ var _overlap =
6750
+ /*istanbul ignore start*/
6751
+ (/*istanbul ignore end*/
6752
+ /*istanbul ignore start*/
6753
+ 0, _string$1
6754
+ /*istanbul ignore end*/
6755
+ .
6756
+ /*istanbul ignore start*/
6757
+ maximumOverlap)
6758
+ /*istanbul ignore end*/
6759
+ (startKeepWsSuffix, deletionWsPrefix);
6760
+ deletion.value =
6761
+ /*istanbul ignore start*/
6762
+ (/*istanbul ignore end*/
6763
+ /*istanbul ignore start*/
6764
+ 0, _string$1
6765
+ /*istanbul ignore end*/
6766
+ .
6767
+ /*istanbul ignore start*/
6768
+ removePrefix)
6769
+ /*istanbul ignore end*/
6770
+ (deletion.value, _overlap);
6771
+ }
6772
+ }
6773
+ var wordWithSpaceDiff =
6774
+ /*istanbul ignore start*/
6775
+ word.wordWithSpaceDiff =
6776
+ /*istanbul ignore end*/
6777
+ new
6778
+ /*istanbul ignore start*/
6779
+ _base$5
6780
+ /*istanbul ignore end*/
6781
+ [
6782
+ /*istanbul ignore start*/
6783
+ "default"
6784
+ /*istanbul ignore end*/
6785
+ ]();
6786
+ wordWithSpaceDiff.tokenize = function (value) {
6787
+ // Slightly different to the tokenizeIncludingWhitespace regex used above in
6788
+ // that this one treats each individual newline as a distinct tokens, rather
6789
+ // than merging them into other surrounding whitespace. This was requested
6790
+ // in https://github.com/kpdecker/jsdiff/issues/180 &
6791
+ // https://github.com/kpdecker/jsdiff/issues/211
6792
+ var regex = new RegExp(
6793
+ /*istanbul ignore start*/
6794
+ "(\\r?\\n)|[".concat(
6795
+ /*istanbul ignore end*/
6796
+ extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), 'ug');
6797
+ return value.match(regex) || [];
6407
6798
  };
6799
+ function diffWordsWithSpace(oldStr, newStr, options) {
6800
+ return wordWithSpaceDiff.diff(oldStr, newStr, options);
6801
+ }
6802
+
6803
+ var line = {};
6408
6804
 
6805
+ var params = {};
6806
+
6807
+ /*istanbul ignore start*/
6808
+
6809
+ Object.defineProperty(params, "__esModule", {
6810
+ value: true
6811
+ });
6812
+ params.generateOptions = generateOptions;
6813
+ /*istanbul ignore end*/
6814
+ function generateOptions(options, defaults) {
6815
+ if (typeof options === 'function') {
6816
+ defaults.callback = options;
6817
+ } else if (options) {
6818
+ for (var name in options) {
6819
+ /* istanbul ignore else */
6820
+ if (options.hasOwnProperty(name)) {
6821
+ defaults[name] = options[name];
6822
+ }
6823
+ }
6824
+ }
6825
+ return defaults;
6826
+ }
6827
+
6828
+ /*istanbul ignore start*/
6829
+
6830
+ Object.defineProperty(line, "__esModule", {
6831
+ value: true
6832
+ });
6833
+ line.diffLines = diffLines;
6834
+ line.diffTrimmedLines = diffTrimmedLines;
6835
+ line.lineDiff = void 0;
6836
+ /*istanbul ignore end*/
6837
+ var
6838
+ /*istanbul ignore start*/
6839
+ _base$4 = _interopRequireDefault$5(base)
6840
+ /*istanbul ignore end*/
6841
+ ;
6842
+ var
6843
+ /*istanbul ignore start*/
6844
+ _params = params
6845
+ /*istanbul ignore end*/
6846
+ ;
6847
+ /*istanbul ignore start*/ function _interopRequireDefault$5(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6848
+ /*istanbul ignore end*/
6849
+ var lineDiff =
6850
+ /*istanbul ignore start*/
6851
+ line.lineDiff =
6852
+ /*istanbul ignore end*/
6853
+ new
6854
+ /*istanbul ignore start*/
6855
+ _base$4
6856
+ /*istanbul ignore end*/
6857
+ [
6858
+ /*istanbul ignore start*/
6859
+ "default"
6860
+ /*istanbul ignore end*/
6861
+ ]();
6862
+ lineDiff.tokenize = function (value, options) {
6863
+ if (options.stripTrailingCr) {
6864
+ // remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
6865
+ value = value.replace(/\r\n/g, '\n');
6866
+ }
6867
+ var retLines = [],
6868
+ linesAndNewlines = value.split(/(\n|\r\n)/);
6869
+
6870
+ // Ignore the final empty token that occurs if the string ends with a new line
6871
+ if (!linesAndNewlines[linesAndNewlines.length - 1]) {
6872
+ linesAndNewlines.pop();
6873
+ }
6874
+
6875
+ // Merge the content and line separators into single tokens
6876
+ for (var i = 0; i < linesAndNewlines.length; i++) {
6877
+ var line = linesAndNewlines[i];
6878
+ if (i % 2 && !options.newlineIsToken) {
6879
+ retLines[retLines.length - 1] += line;
6880
+ } else {
6881
+ retLines.push(line);
6882
+ }
6883
+ }
6884
+ return retLines;
6885
+ };
6886
+ lineDiff.equals = function (left, right, options) {
6887
+ // If we're ignoring whitespace, we need to normalise lines by stripping
6888
+ // whitespace before checking equality. (This has an annoying interaction
6889
+ // with newlineIsToken that requires special handling: if newlines get their
6890
+ // own token, then we DON'T want to trim the *newline* tokens down to empty
6891
+ // strings, since this would cause us to treat whitespace-only line content
6892
+ // as equal to a separator between lines, which would be weird and
6893
+ // inconsistent with the documented behavior of the options.)
6894
+ if (options.ignoreWhitespace) {
6895
+ if (!options.newlineIsToken || !left.includes('\n')) {
6896
+ left = left.trim();
6897
+ }
6898
+ if (!options.newlineIsToken || !right.includes('\n')) {
6899
+ right = right.trim();
6900
+ }
6901
+ } else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
6902
+ if (left.endsWith('\n')) {
6903
+ left = left.slice(0, -1);
6904
+ }
6905
+ if (right.endsWith('\n')) {
6906
+ right = right.slice(0, -1);
6907
+ }
6908
+ }
6909
+ return (
6910
+ /*istanbul ignore start*/
6911
+ _base$4
6912
+ /*istanbul ignore end*/
6913
+ [
6914
+ /*istanbul ignore start*/
6915
+ "default"
6916
+ /*istanbul ignore end*/
6917
+ ].prototype.equals.call(this, left, right, options)
6918
+ );
6919
+ };
6409
6920
  function diffLines(oldStr, newStr, callback) {
6410
6921
  return lineDiff.diff(oldStr, newStr, callback);
6411
6922
  }
6412
6923
 
6924
+ // Kept for backwards compatibility. This is a rather arbitrary wrapper method
6925
+ // that just calls `diffLines` with `ignoreWhitespace: true`. It's confusing to
6926
+ // have two ways to do exactly the same thing in the API, so we no longer
6927
+ // document this one (library users should explicitly use `diffLines` with
6928
+ // `ignoreWhitespace: true` instead) but we keep it around to maintain
6929
+ // compatibility with code that used old versions.
6413
6930
  function diffTrimmedLines(oldStr, newStr, callback) {
6414
6931
  var options =
6415
6932
  /*istanbul ignore start*/
6416
6933
  (/*istanbul ignore end*/
6417
-
6418
6934
  /*istanbul ignore start*/
6419
6935
  0, _params
6420
6936
  /*istanbul ignore end*/
@@ -6437,18 +6953,19 @@
6437
6953
  });
6438
6954
  sentence.diffSentences = diffSentences;
6439
6955
  sentence.sentenceDiff = void 0;
6440
-
6441
6956
  /*istanbul ignore end*/
6442
6957
  var
6443
6958
  /*istanbul ignore start*/
6444
6959
  _base$3 = _interopRequireDefault$4(base)
6445
6960
  /*istanbul ignore end*/
6446
6961
  ;
6447
-
6448
6962
  /*istanbul ignore start*/ function _interopRequireDefault$4(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6449
-
6450
6963
  /*istanbul ignore end*/
6451
- var sentenceDiff = new
6964
+ var sentenceDiff =
6965
+ /*istanbul ignore start*/
6966
+ sentence.sentenceDiff =
6967
+ /*istanbul ignore end*/
6968
+ new
6452
6969
  /*istanbul ignore start*/
6453
6970
  _base$3
6454
6971
  /*istanbul ignore end*/
@@ -6457,15 +6974,9 @@
6457
6974
  "default"
6458
6975
  /*istanbul ignore end*/
6459
6976
  ]();
6460
-
6461
- /*istanbul ignore start*/
6462
- sentence.sentenceDiff = sentenceDiff;
6463
-
6464
- /*istanbul ignore end*/
6465
6977
  sentenceDiff.tokenize = function (value) {
6466
6978
  return value.split(/(\S.+?[.!?])(?=\s+|$)/);
6467
6979
  };
6468
-
6469
6980
  function diffSentences(oldStr, newStr, callback) {
6470
6981
  return sentenceDiff.diff(oldStr, newStr, callback);
6471
6982
  }
@@ -6477,20 +6988,21 @@
6477
6988
  Object.defineProperty(css, "__esModule", {
6478
6989
  value: true
6479
6990
  });
6480
- css.diffCss = diffCss;
6481
6991
  css.cssDiff = void 0;
6482
-
6992
+ css.diffCss = diffCss;
6483
6993
  /*istanbul ignore end*/
6484
6994
  var
6485
6995
  /*istanbul ignore start*/
6486
6996
  _base$2 = _interopRequireDefault$3(base)
6487
6997
  /*istanbul ignore end*/
6488
6998
  ;
6489
-
6490
6999
  /*istanbul ignore start*/ function _interopRequireDefault$3(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6491
-
6492
7000
  /*istanbul ignore end*/
6493
- var cssDiff = new
7001
+ var cssDiff =
7002
+ /*istanbul ignore start*/
7003
+ css.cssDiff =
7004
+ /*istanbul ignore end*/
7005
+ new
6494
7006
  /*istanbul ignore start*/
6495
7007
  _base$2
6496
7008
  /*istanbul ignore end*/
@@ -6499,15 +7011,9 @@
6499
7011
  "default"
6500
7012
  /*istanbul ignore end*/
6501
7013
  ]();
6502
-
6503
- /*istanbul ignore start*/
6504
- css.cssDiff = cssDiff;
6505
-
6506
- /*istanbul ignore end*/
6507
7014
  cssDiff.tokenize = function (value) {
6508
7015
  return value.split(/([{}:;,]|\s+)/);
6509
7016
  };
6510
-
6511
7017
  function diffCss(oldStr, newStr, callback) {
6512
7018
  return cssDiff.diff(oldStr, newStr, callback);
6513
7019
  }
@@ -6519,30 +7025,28 @@
6519
7025
  Object.defineProperty(json$1, "__esModule", {
6520
7026
  value: true
6521
7027
  });
6522
- json$1.diffJson = diffJson;
6523
7028
  json$1.canonicalize = canonicalize;
7029
+ json$1.diffJson = diffJson;
6524
7030
  json$1.jsonDiff = void 0;
6525
-
6526
7031
  /*istanbul ignore end*/
6527
7032
  var
6528
7033
  /*istanbul ignore start*/
6529
7034
  _base$1 = _interopRequireDefault$2(base)
6530
7035
  /*istanbul ignore end*/
6531
7036
  ;
6532
-
6533
7037
  var
6534
7038
  /*istanbul ignore start*/
6535
7039
  _line$1 = line
6536
7040
  /*istanbul ignore end*/
6537
7041
  ;
6538
-
6539
7042
  /*istanbul ignore start*/ function _interopRequireDefault$2(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6540
-
6541
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
6542
-
7043
+ function _typeof$3(o) { "@babel/helpers - typeof"; return _typeof$3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$3(o); }
6543
7044
  /*istanbul ignore end*/
6544
- var objectPrototypeToString = Object.prototype.toString;
6545
- var jsonDiff = new
7045
+ var jsonDiff =
7046
+ /*istanbul ignore start*/
7047
+ json$1.jsonDiff =
7048
+ /*istanbul ignore end*/
7049
+ new
6546
7050
  /*istanbul ignore start*/
6547
7051
  _base$1
6548
7052
  /*istanbul ignore end*/
@@ -6550,13 +7054,9 @@
6550
7054
  /*istanbul ignore start*/
6551
7055
  "default"
6552
7056
  /*istanbul ignore end*/
6553
- ](); // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
7057
+ ]();
7058
+ // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
6554
7059
  // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
6555
-
6556
- /*istanbul ignore start*/
6557
- json$1.jsonDiff = jsonDiff;
6558
-
6559
- /*istanbul ignore end*/
6560
7060
  jsonDiff.useLongestToken = true;
6561
7061
  jsonDiff.tokenize =
6562
7062
  /*istanbul ignore start*/
@@ -6567,26 +7067,28 @@
6567
7067
  lineDiff
6568
7068
  /*istanbul ignore end*/
6569
7069
  .tokenize;
6570
-
6571
- jsonDiff.castInput = function (value) {
6572
- /*istanbul ignore start*/
6573
- var _this$options =
6574
- /*istanbul ignore end*/
6575
- this.options,
6576
- undefinedReplacement = _this$options.undefinedReplacement,
6577
- _this$options$stringi = _this$options.stringifyReplacer,
6578
- stringifyReplacer = _this$options$stringi === void 0 ? function (k, v)
6579
- /*istanbul ignore start*/
6580
- {
6581
- return (
6582
- /*istanbul ignore end*/
6583
- typeof v === 'undefined' ? undefinedReplacement : v
6584
- );
6585
- } : _this$options$stringi;
7070
+ jsonDiff.castInput = function (value, options) {
7071
+ var
7072
+ /*istanbul ignore start*/
7073
+ /*istanbul ignore end*/
7074
+ undefinedReplacement = options.undefinedReplacement,
7075
+ /*istanbul ignore start*/
7076
+ _options$stringifyRep =
7077
+ /*istanbul ignore end*/
7078
+ options.stringifyReplacer,
7079
+ /*istanbul ignore start*/
7080
+ /*istanbul ignore end*/
7081
+ stringifyReplacer = _options$stringifyRep === void 0 ? function (k, v)
7082
+ /*istanbul ignore start*/
7083
+ {
7084
+ return (
7085
+ /*istanbul ignore end*/
7086
+ typeof v === 'undefined' ? undefinedReplacement : v
7087
+ );
7088
+ } : _options$stringifyRep;
6586
7089
  return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
6587
7090
  };
6588
-
6589
- jsonDiff.equals = function (left, right) {
7091
+ jsonDiff.equals = function (left, right, options) {
6590
7092
  return (
6591
7093
  /*istanbul ignore start*/
6592
7094
  _base$1
@@ -6595,84 +7097,68 @@
6595
7097
  /*istanbul ignore start*/
6596
7098
  "default"
6597
7099
  /*istanbul ignore end*/
6598
- ].prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'))
7100
+ ].prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options)
6599
7101
  );
6600
7102
  };
6601
-
6602
7103
  function diffJson(oldObj, newObj, options) {
6603
7104
  return jsonDiff.diff(oldObj, newObj, options);
6604
- } // This function handles the presence of circular references by bailing out when encountering an
6605
- // object that is already on the "stack" of items being processed. Accepts an optional replacer
6606
-
7105
+ }
6607
7106
 
7107
+ // This function handles the presence of circular references by bailing out when encountering an
7108
+ // object that is already on the "stack" of items being processed. Accepts an optional replacer
6608
7109
  function canonicalize(obj, stack, replacementStack, replacer, key) {
6609
7110
  stack = stack || [];
6610
7111
  replacementStack = replacementStack || [];
6611
-
6612
7112
  if (replacer) {
6613
7113
  obj = replacer(key, obj);
6614
7114
  }
6615
-
6616
7115
  var i;
6617
-
6618
7116
  for (i = 0; i < stack.length; i += 1) {
6619
7117
  if (stack[i] === obj) {
6620
7118
  return replacementStack[i];
6621
7119
  }
6622
7120
  }
6623
-
6624
7121
  var canonicalizedObj;
6625
-
6626
- if ('[object Array]' === objectPrototypeToString.call(obj)) {
7122
+ if ('[object Array]' === Object.prototype.toString.call(obj)) {
6627
7123
  stack.push(obj);
6628
7124
  canonicalizedObj = new Array(obj.length);
6629
7125
  replacementStack.push(canonicalizedObj);
6630
-
6631
7126
  for (i = 0; i < obj.length; i += 1) {
6632
7127
  canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, key);
6633
7128
  }
6634
-
6635
7129
  stack.pop();
6636
7130
  replacementStack.pop();
6637
7131
  return canonicalizedObj;
6638
7132
  }
6639
-
6640
7133
  if (obj && obj.toJSON) {
6641
7134
  obj = obj.toJSON();
6642
7135
  }
6643
-
6644
7136
  if (
6645
7137
  /*istanbul ignore start*/
6646
- _typeof(
7138
+ _typeof$3(
6647
7139
  /*istanbul ignore end*/
6648
7140
  obj) === 'object' && obj !== null) {
6649
7141
  stack.push(obj);
6650
7142
  canonicalizedObj = {};
6651
7143
  replacementStack.push(canonicalizedObj);
6652
-
6653
7144
  var sortedKeys = [],
6654
- _key;
6655
-
7145
+ _key;
6656
7146
  for (_key in obj) {
6657
7147
  /* istanbul ignore else */
6658
- if (obj.hasOwnProperty(_key)) {
7148
+ if (Object.prototype.hasOwnProperty.call(obj, _key)) {
6659
7149
  sortedKeys.push(_key);
6660
7150
  }
6661
7151
  }
6662
-
6663
7152
  sortedKeys.sort();
6664
-
6665
7153
  for (i = 0; i < sortedKeys.length; i += 1) {
6666
7154
  _key = sortedKeys[i];
6667
7155
  canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
6668
7156
  }
6669
-
6670
7157
  stack.pop();
6671
7158
  replacementStack.pop();
6672
7159
  } else {
6673
7160
  canonicalizedObj = obj;
6674
7161
  }
6675
-
6676
7162
  return canonicalizedObj;
6677
7163
  }
6678
7164
 
@@ -6683,20 +7169,21 @@
6683
7169
  Object.defineProperty(array$1, "__esModule", {
6684
7170
  value: true
6685
7171
  });
6686
- array$1.diffArrays = diffArrays;
6687
7172
  array$1.arrayDiff = void 0;
6688
-
7173
+ array$1.diffArrays = diffArrays;
6689
7174
  /*istanbul ignore end*/
6690
7175
  var
6691
7176
  /*istanbul ignore start*/
6692
7177
  _base = _interopRequireDefault$1(base)
6693
7178
  /*istanbul ignore end*/
6694
7179
  ;
6695
-
6696
7180
  /*istanbul ignore start*/ function _interopRequireDefault$1(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6697
-
6698
7181
  /*istanbul ignore end*/
6699
- var arrayDiff = new
7182
+ var arrayDiff =
7183
+ /*istanbul ignore start*/
7184
+ array$1.arrayDiff =
7185
+ /*istanbul ignore end*/
7186
+ new
6700
7187
  /*istanbul ignore start*/
6701
7188
  _base
6702
7189
  /*istanbul ignore end*/
@@ -6705,25 +7192,195 @@
6705
7192
  "default"
6706
7193
  /*istanbul ignore end*/
6707
7194
  ]();
6708
-
6709
- /*istanbul ignore start*/
6710
- array$1.arrayDiff = arrayDiff;
6711
-
6712
- /*istanbul ignore end*/
6713
7195
  arrayDiff.tokenize = function (value) {
6714
7196
  return value.slice();
6715
7197
  };
6716
-
6717
7198
  arrayDiff.join = arrayDiff.removeEmpty = function (value) {
6718
7199
  return value;
6719
7200
  };
6720
-
6721
7201
  function diffArrays(oldArr, newArr, callback) {
6722
7202
  return arrayDiff.diff(oldArr, newArr, callback);
6723
7203
  }
6724
7204
 
6725
7205
  var apply = {};
6726
7206
 
7207
+ var lineEndings = {};
7208
+
7209
+ /*istanbul ignore start*/
7210
+
7211
+ Object.defineProperty(lineEndings, "__esModule", {
7212
+ value: true
7213
+ });
7214
+ lineEndings.isUnix = isUnix;
7215
+ lineEndings.isWin = isWin;
7216
+ lineEndings.unixToWin = unixToWin;
7217
+ lineEndings.winToUnix = winToUnix;
7218
+ function _typeof$2(o) { "@babel/helpers - typeof"; return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$2(o); }
7219
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7220
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7221
+ function _defineProperty$2(obj, key, value) { key = _toPropertyKey$2(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7222
+ function _toPropertyKey$2(t) { var i = _toPrimitive$2(t, "string"); return "symbol" == _typeof$2(i) ? i : i + ""; }
7223
+ function _toPrimitive$2(t, r) { if ("object" != _typeof$2(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$2(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7224
+ /*istanbul ignore end*/
7225
+ function unixToWin(patch) {
7226
+ if (Array.isArray(patch)) {
7227
+ return patch.map(unixToWin);
7228
+ }
7229
+ return (
7230
+ /*istanbul ignore start*/
7231
+ _objectSpread$2(_objectSpread$2({},
7232
+ /*istanbul ignore end*/
7233
+ patch), {}, {
7234
+ hunks: patch.hunks.map(function (hunk)
7235
+ /*istanbul ignore start*/
7236
+ {
7237
+ return _objectSpread$2(_objectSpread$2({},
7238
+ /*istanbul ignore end*/
7239
+ hunk), {}, {
7240
+ lines: hunk.lines.map(function (line, i)
7241
+ /*istanbul ignore start*/
7242
+ {
7243
+ var _hunk$lines;
7244
+ return (
7245
+ /*istanbul ignore end*/
7246
+ line.startsWith('\\') || line.endsWith('\r') ||
7247
+ /*istanbul ignore start*/
7248
+ (_hunk$lines =
7249
+ /*istanbul ignore end*/
7250
+ hunk.lines[i + 1]) !== null && _hunk$lines !== void 0 &&
7251
+ /*istanbul ignore start*/
7252
+ _hunk$lines
7253
+ /*istanbul ignore end*/
7254
+ .startsWith('\\') ? line : line + '\r'
7255
+ );
7256
+ })
7257
+ });
7258
+ })
7259
+ })
7260
+ );
7261
+ }
7262
+ function winToUnix(patch) {
7263
+ if (Array.isArray(patch)) {
7264
+ return patch.map(winToUnix);
7265
+ }
7266
+ return (
7267
+ /*istanbul ignore start*/
7268
+ _objectSpread$2(_objectSpread$2({},
7269
+ /*istanbul ignore end*/
7270
+ patch), {}, {
7271
+ hunks: patch.hunks.map(function (hunk)
7272
+ /*istanbul ignore start*/
7273
+ {
7274
+ return _objectSpread$2(_objectSpread$2({},
7275
+ /*istanbul ignore end*/
7276
+ hunk), {}, {
7277
+ lines: hunk.lines.map(function (line)
7278
+ /*istanbul ignore start*/
7279
+ {
7280
+ return (
7281
+ /*istanbul ignore end*/
7282
+ line.endsWith('\r') ? line.substring(0, line.length - 1) : line
7283
+ );
7284
+ })
7285
+ });
7286
+ })
7287
+ })
7288
+ );
7289
+ }
7290
+
7291
+ /**
7292
+ * Returns true if the patch consistently uses Unix line endings (or only involves one line and has
7293
+ * no line endings).
7294
+ */
7295
+ function isUnix(patch) {
7296
+ if (!Array.isArray(patch)) {
7297
+ patch = [patch];
7298
+ }
7299
+ return !patch.some(function (index)
7300
+ /*istanbul ignore start*/
7301
+ {
7302
+ return (
7303
+ /*istanbul ignore end*/
7304
+ index.hunks.some(function (hunk)
7305
+ /*istanbul ignore start*/
7306
+ {
7307
+ return (
7308
+ /*istanbul ignore end*/
7309
+ hunk.lines.some(function (line)
7310
+ /*istanbul ignore start*/
7311
+ {
7312
+ return (
7313
+ /*istanbul ignore end*/
7314
+ !line.startsWith('\\') && line.endsWith('\r')
7315
+ );
7316
+ })
7317
+ );
7318
+ })
7319
+ );
7320
+ });
7321
+ }
7322
+
7323
+ /**
7324
+ * Returns true if the patch uses Windows line endings and only Windows line endings.
7325
+ */
7326
+ function isWin(patch) {
7327
+ if (!Array.isArray(patch)) {
7328
+ patch = [patch];
7329
+ }
7330
+ return patch.some(function (index)
7331
+ /*istanbul ignore start*/
7332
+ {
7333
+ return (
7334
+ /*istanbul ignore end*/
7335
+ index.hunks.some(function (hunk)
7336
+ /*istanbul ignore start*/
7337
+ {
7338
+ return (
7339
+ /*istanbul ignore end*/
7340
+ hunk.lines.some(function (line)
7341
+ /*istanbul ignore start*/
7342
+ {
7343
+ return (
7344
+ /*istanbul ignore end*/
7345
+ line.endsWith('\r')
7346
+ );
7347
+ })
7348
+ );
7349
+ })
7350
+ );
7351
+ }) && patch.every(function (index)
7352
+ /*istanbul ignore start*/
7353
+ {
7354
+ return (
7355
+ /*istanbul ignore end*/
7356
+ index.hunks.every(function (hunk)
7357
+ /*istanbul ignore start*/
7358
+ {
7359
+ return (
7360
+ /*istanbul ignore end*/
7361
+ hunk.lines.every(function (line, i)
7362
+ /*istanbul ignore start*/
7363
+ {
7364
+ var _hunk$lines2;
7365
+ return (
7366
+ /*istanbul ignore end*/
7367
+ line.startsWith('\\') || line.endsWith('\r') ||
7368
+ /*istanbul ignore start*/
7369
+ ((_hunk$lines2 =
7370
+ /*istanbul ignore end*/
7371
+ hunk.lines[i + 1]) === null || _hunk$lines2 === void 0 ? void 0 :
7372
+ /*istanbul ignore start*/
7373
+ _hunk$lines2
7374
+ /*istanbul ignore end*/
7375
+ .startsWith('\\'))
7376
+ );
7377
+ })
7378
+ );
7379
+ })
7380
+ );
7381
+ });
7382
+ }
7383
+
6727
7384
  var parse$2 = {};
6728
7385
 
6729
7386
  /*istanbul ignore start*/
@@ -6732,123 +7389,110 @@
6732
7389
  value: true
6733
7390
  });
6734
7391
  parse$2.parsePatch = parsePatch;
6735
-
6736
7392
  /*istanbul ignore end*/
6737
7393
  function parsePatch(uniDiff) {
6738
- /*istanbul ignore start*/
6739
- var
6740
- /*istanbul ignore end*/
6741
- options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6742
- var diffstr = uniDiff.split(/\r\n|[\n\v\f\r\x85]/),
6743
- delimiters = uniDiff.match(/\r\n|[\n\v\f\r\x85]/g) || [],
6744
- list = [],
6745
- i = 0;
6746
-
7394
+ var diffstr = uniDiff.split(/\n/),
7395
+ list = [],
7396
+ i = 0;
6747
7397
  function parseIndex() {
6748
7398
  var index = {};
6749
- list.push(index); // Parse diff metadata
7399
+ list.push(index);
6750
7400
 
7401
+ // Parse diff metadata
6751
7402
  while (i < diffstr.length) {
6752
- var line = diffstr[i]; // File header found, end parsing diff metadata
7403
+ var line = diffstr[i];
6753
7404
 
7405
+ // File header found, end parsing diff metadata
6754
7406
  if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
6755
7407
  break;
6756
- } // Diff index
6757
-
7408
+ }
6758
7409
 
7410
+ // Diff index
6759
7411
  var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
6760
-
6761
7412
  if (header) {
6762
7413
  index.index = header[1];
6763
7414
  }
6764
-
6765
7415
  i++;
6766
- } // Parse file headers if they are defined. Unified diff requires them, but
6767
- // there's no technical issues to have an isolated hunk without file header
6768
-
7416
+ }
6769
7417
 
7418
+ // Parse file headers if they are defined. Unified diff requires them, but
7419
+ // there's no technical issues to have an isolated hunk without file header
7420
+ parseFileHeader(index);
6770
7421
  parseFileHeader(index);
6771
- parseFileHeader(index); // Parse hunks
6772
7422
 
7423
+ // Parse hunks
6773
7424
  index.hunks = [];
6774
-
6775
7425
  while (i < diffstr.length) {
6776
7426
  var _line = diffstr[i];
6777
-
6778
- if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
7427
+ if (/^(Index:\s|diff\s|\-\-\-\s|\+\+\+\s|===================================================================)/.test(_line)) {
6779
7428
  break;
6780
7429
  } else if (/^@@/.test(_line)) {
6781
7430
  index.hunks.push(parseHunk());
6782
- } else if (_line && options.strict) {
6783
- // Ignore unexpected content unless in strict mode
7431
+ } else if (_line) {
6784
7432
  throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
6785
7433
  } else {
6786
7434
  i++;
6787
7435
  }
6788
7436
  }
6789
- } // Parses the --- and +++ headers, if none are found, no lines
6790
- // are consumed.
6791
-
7437
+ }
6792
7438
 
7439
+ // Parses the --- and +++ headers, if none are found, no lines
7440
+ // are consumed.
6793
7441
  function parseFileHeader(index) {
6794
- var fileHeader = /^(---|\+\+\+)\s+(.*)$/.exec(diffstr[i]);
6795
-
7442
+ var fileHeader = /^(---|\+\+\+)\s+(.*)\r?$/.exec(diffstr[i]);
6796
7443
  if (fileHeader) {
6797
7444
  var keyPrefix = fileHeader[1] === '---' ? 'old' : 'new';
6798
7445
  var data = fileHeader[2].split('\t', 2);
6799
7446
  var fileName = data[0].replace(/\\\\/g, '\\');
6800
-
6801
7447
  if (/^".*"$/.test(fileName)) {
6802
7448
  fileName = fileName.substr(1, fileName.length - 2);
6803
7449
  }
6804
-
6805
7450
  index[keyPrefix + 'FileName'] = fileName;
6806
7451
  index[keyPrefix + 'Header'] = (data[1] || '').trim();
6807
7452
  i++;
6808
7453
  }
6809
- } // Parses a hunk
6810
- // This assumes that we are at the start of a hunk.
6811
-
7454
+ }
6812
7455
 
7456
+ // Parses a hunk
7457
+ // This assumes that we are at the start of a hunk.
6813
7458
  function parseHunk() {
6814
7459
  var chunkHeaderIndex = i,
6815
- chunkHeaderLine = diffstr[i++],
6816
- chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
7460
+ chunkHeaderLine = diffstr[i++],
7461
+ chunkHeader = chunkHeaderLine.split(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);
6817
7462
  var hunk = {
6818
7463
  oldStart: +chunkHeader[1],
6819
7464
  oldLines: typeof chunkHeader[2] === 'undefined' ? 1 : +chunkHeader[2],
6820
7465
  newStart: +chunkHeader[3],
6821
7466
  newLines: typeof chunkHeader[4] === 'undefined' ? 1 : +chunkHeader[4],
6822
- lines: [],
6823
- linedelimiters: []
6824
- }; // Unified Diff Format quirk: If the chunk size is 0,
7467
+ lines: []
7468
+ };
7469
+
7470
+ // Unified Diff Format quirk: If the chunk size is 0,
6825
7471
  // the first number is one lower than one would expect.
6826
7472
  // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
6827
-
6828
7473
  if (hunk.oldLines === 0) {
6829
7474
  hunk.oldStart += 1;
6830
7475
  }
6831
-
6832
7476
  if (hunk.newLines === 0) {
6833
7477
  hunk.newStart += 1;
6834
7478
  }
6835
-
6836
7479
  var addCount = 0,
6837
- removeCount = 0;
6838
-
6839
- for (; i < diffstr.length; i++) {
6840
- // Lines starting with '---' could be mistaken for the "remove line" operation
6841
- // But they could be the header for the next file. Therefore prune such cases out.
6842
- if (diffstr[i].indexOf('--- ') === 0 && i + 2 < diffstr.length && diffstr[i + 1].indexOf('+++ ') === 0 && diffstr[i + 2].indexOf('@@') === 0) {
6843
- break;
6844
- }
6845
-
7480
+ removeCount = 0;
7481
+ for (; i < diffstr.length && (removeCount < hunk.oldLines || addCount < hunk.newLines ||
7482
+ /*istanbul ignore start*/
7483
+ (_diffstr$i =
7484
+ /*istanbul ignore end*/
7485
+ diffstr[i]) !== null && _diffstr$i !== void 0 &&
7486
+ /*istanbul ignore start*/
7487
+ _diffstr$i
7488
+ /*istanbul ignore end*/
7489
+ .startsWith('\\')); i++) {
7490
+ /*istanbul ignore start*/
7491
+ var _diffstr$i;
7492
+ /*istanbul ignore end*/
6846
7493
  var operation = diffstr[i].length == 0 && i != diffstr.length - 1 ? ' ' : diffstr[i][0];
6847
-
6848
7494
  if (operation === '+' || operation === '-' || operation === ' ' || operation === '\\') {
6849
7495
  hunk.lines.push(diffstr[i]);
6850
- hunk.linedelimiters.push(delimiters[i] || '\n');
6851
-
6852
7496
  if (operation === '+') {
6853
7497
  addCount++;
6854
7498
  } else if (operation === '-') {
@@ -6858,37 +7502,34 @@
6858
7502
  removeCount++;
6859
7503
  }
6860
7504
  } else {
6861
- break;
7505
+ throw new Error(
7506
+ /*istanbul ignore start*/
7507
+ "Hunk at line ".concat(
7508
+ /*istanbul ignore end*/
7509
+ chunkHeaderIndex + 1, " contained invalid line ").concat(diffstr[i]));
6862
7510
  }
6863
- } // Handle the empty block count case
6864
-
7511
+ }
6865
7512
 
7513
+ // Handle the empty block count case
6866
7514
  if (!addCount && hunk.newLines === 1) {
6867
7515
  hunk.newLines = 0;
6868
7516
  }
6869
-
6870
7517
  if (!removeCount && hunk.oldLines === 1) {
6871
7518
  hunk.oldLines = 0;
6872
- } // Perform optional sanity checking
6873
-
6874
-
6875
- if (options.strict) {
6876
- if (addCount !== hunk.newLines) {
6877
- throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
6878
- }
6879
-
6880
- if (removeCount !== hunk.oldLines) {
6881
- throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
6882
- }
6883
7519
  }
6884
7520
 
7521
+ // Perform sanity checking
7522
+ if (addCount !== hunk.newLines) {
7523
+ throw new Error('Added line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
7524
+ }
7525
+ if (removeCount !== hunk.oldLines) {
7526
+ throw new Error('Removed line count did not match for hunk at line ' + (chunkHeaderIndex + 1));
7527
+ }
6885
7528
  return hunk;
6886
7529
  }
6887
-
6888
7530
  while (i < diffstr.length) {
6889
7531
  parseIndex();
6890
7532
  }
6891
-
6892
7533
  return list;
6893
7534
  }
6894
7535
 
@@ -6902,7 +7543,6 @@
6902
7543
  value: true
6903
7544
  });
6904
7545
  exports["default"] = _default;
6905
-
6906
7546
  /*istanbul ignore end*/
6907
7547
  // Iterator that traverses in the range of [min, max], stepping
6908
7548
  // by distance from a given start position. I.e. for [0, 4], with
@@ -6913,42 +7553,40 @@
6913
7553
  /*istanbul ignore end*/
6914
7554
  (start, minLine, maxLine) {
6915
7555
  var wantForward = true,
6916
- backwardExhausted = false,
6917
- forwardExhausted = false,
6918
- localOffset = 1;
7556
+ backwardExhausted = false,
7557
+ forwardExhausted = false,
7558
+ localOffset = 1;
6919
7559
  return function iterator() {
6920
7560
  if (wantForward && !forwardExhausted) {
6921
7561
  if (backwardExhausted) {
6922
7562
  localOffset++;
6923
7563
  } else {
6924
7564
  wantForward = false;
6925
- } // Check if trying to fit beyond text length, and if not, check it fits
6926
- // after offset location (or desired location on first iteration)
6927
-
7565
+ }
6928
7566
 
7567
+ // Check if trying to fit beyond text length, and if not, check it fits
7568
+ // after offset location (or desired location on first iteration)
6929
7569
  if (start + localOffset <= maxLine) {
6930
- return localOffset;
7570
+ return start + localOffset;
6931
7571
  }
6932
-
6933
7572
  forwardExhausted = true;
6934
7573
  }
6935
-
6936
7574
  if (!backwardExhausted) {
6937
7575
  if (!forwardExhausted) {
6938
7576
  wantForward = true;
6939
- } // Check if trying to fit before text beginning, and if not, check it fits
6940
- // before offset location
6941
-
7577
+ }
6942
7578
 
7579
+ // Check if trying to fit before text beginning, and if not, check it fits
7580
+ // before offset location
6943
7581
  if (minLine <= start - localOffset) {
6944
- return -localOffset++;
7582
+ return start - localOffset++;
6945
7583
  }
6946
-
6947
7584
  backwardExhausted = true;
6948
7585
  return iterator();
6949
- } // We tried to fit hunk before text beginning and beyond text length, then
6950
- // hunk can't fit on the text. Return undefined
7586
+ }
6951
7587
 
7588
+ // We tried to fit hunk before text beginning and beyond text length, then
7589
+ // hunk can't fit on the text. Return undefined
6952
7590
  };
6953
7591
  }
6954
7592
 
@@ -6961,34 +7599,38 @@
6961
7599
  });
6962
7600
  apply.applyPatch = applyPatch;
6963
7601
  apply.applyPatches = applyPatches;
6964
-
6965
7602
  /*istanbul ignore end*/
6966
7603
  var
6967
7604
  /*istanbul ignore start*/
7605
+ _string = string
7606
+ /*istanbul ignore end*/
7607
+ ;
7608
+ var
7609
+ /*istanbul ignore start*/
7610
+ _lineEndings = lineEndings
7611
+ /*istanbul ignore end*/
7612
+ ;
7613
+ var
7614
+ /*istanbul ignore start*/
6968
7615
  _parse$1 = parse$2
6969
7616
  /*istanbul ignore end*/
6970
7617
  ;
6971
-
6972
7618
  var
6973
7619
  /*istanbul ignore start*/
6974
7620
  _distanceIterator = _interopRequireDefault(distanceIterator)
6975
7621
  /*istanbul ignore end*/
6976
7622
  ;
6977
-
6978
7623
  /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
6979
-
6980
7624
  /*istanbul ignore end*/
6981
7625
  function applyPatch(source, uniDiff) {
6982
7626
  /*istanbul ignore start*/
6983
7627
  var
6984
7628
  /*istanbul ignore end*/
6985
7629
  options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
6986
-
6987
7630
  if (typeof uniDiff === 'string') {
6988
7631
  uniDiff =
6989
7632
  /*istanbul ignore start*/
6990
7633
  (/*istanbul ignore end*/
6991
-
6992
7634
  /*istanbul ignore start*/
6993
7635
  0, _parse$1
6994
7636
  /*istanbul ignore end*/
@@ -6998,158 +7640,310 @@
6998
7640
  /*istanbul ignore end*/
6999
7641
  (uniDiff);
7000
7642
  }
7001
-
7002
7643
  if (Array.isArray(uniDiff)) {
7003
7644
  if (uniDiff.length > 1) {
7004
7645
  throw new Error('applyPatch only works with a single input.');
7005
7646
  }
7006
-
7007
7647
  uniDiff = uniDiff[0];
7008
- } // Apply the diff to the input
7648
+ }
7649
+ if (options.autoConvertLineEndings || options.autoConvertLineEndings == null) {
7650
+ if (
7651
+ /*istanbul ignore start*/
7652
+ (/*istanbul ignore end*/
7653
+ /*istanbul ignore start*/
7654
+ 0, _string
7655
+ /*istanbul ignore end*/
7656
+ .
7657
+ /*istanbul ignore start*/
7658
+ hasOnlyWinLineEndings)
7659
+ /*istanbul ignore end*/
7660
+ (source) &&
7661
+ /*istanbul ignore start*/
7662
+ (/*istanbul ignore end*/
7663
+ /*istanbul ignore start*/
7664
+ 0, _lineEndings
7665
+ /*istanbul ignore end*/
7666
+ .
7667
+ /*istanbul ignore start*/
7668
+ isUnix)
7669
+ /*istanbul ignore end*/
7670
+ (uniDiff)) {
7671
+ uniDiff =
7672
+ /*istanbul ignore start*/
7673
+ (/*istanbul ignore end*/
7674
+ /*istanbul ignore start*/
7675
+ 0, _lineEndings
7676
+ /*istanbul ignore end*/
7677
+ .
7678
+ /*istanbul ignore start*/
7679
+ unixToWin)
7680
+ /*istanbul ignore end*/
7681
+ (uniDiff);
7682
+ } else if (
7683
+ /*istanbul ignore start*/
7684
+ (/*istanbul ignore end*/
7685
+ /*istanbul ignore start*/
7686
+ 0, _string
7687
+ /*istanbul ignore end*/
7688
+ .
7689
+ /*istanbul ignore start*/
7690
+ hasOnlyUnixLineEndings)
7691
+ /*istanbul ignore end*/
7692
+ (source) &&
7693
+ /*istanbul ignore start*/
7694
+ (/*istanbul ignore end*/
7695
+ /*istanbul ignore start*/
7696
+ 0, _lineEndings
7697
+ /*istanbul ignore end*/
7698
+ .
7699
+ /*istanbul ignore start*/
7700
+ isWin)
7701
+ /*istanbul ignore end*/
7702
+ (uniDiff)) {
7703
+ uniDiff =
7704
+ /*istanbul ignore start*/
7705
+ (/*istanbul ignore end*/
7706
+ /*istanbul ignore start*/
7707
+ 0, _lineEndings
7708
+ /*istanbul ignore end*/
7709
+ .
7710
+ /*istanbul ignore start*/
7711
+ winToUnix)
7712
+ /*istanbul ignore end*/
7713
+ (uniDiff);
7714
+ }
7715
+ }
7009
7716
 
7717
+ // Apply the diff to the input
7718
+ var lines = source.split('\n'),
7719
+ hunks = uniDiff.hunks,
7720
+ compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
7721
+ /*istanbul ignore start*/
7722
+ {
7723
+ return (
7724
+ /*istanbul ignore end*/
7725
+ line === patchContent
7726
+ );
7727
+ },
7728
+ fuzzFactor = options.fuzzFactor || 0,
7729
+ minLine = 0;
7730
+ if (fuzzFactor < 0 || !Number.isInteger(fuzzFactor)) {
7731
+ throw new Error('fuzzFactor must be a non-negative integer');
7732
+ }
7733
+
7734
+ // Special case for empty patch.
7735
+ if (!hunks.length) {
7736
+ return source;
7737
+ }
7738
+
7739
+ // Before anything else, handle EOFNL insertion/removal. If the patch tells us to make a change
7740
+ // to the EOFNL that is redundant/impossible - i.e. to remove a newline that's not there, or add a
7741
+ // newline that already exists - then we either return false and fail to apply the patch (if
7742
+ // fuzzFactor is 0) or simply ignore the problem and do nothing (if fuzzFactor is >0).
7743
+ // If we do need to remove/add a newline at EOF, this will always be in the final hunk:
7744
+ var prevLine = '',
7745
+ removeEOFNL = false,
7746
+ addEOFNL = false;
7747
+ for (var i = 0; i < hunks[hunks.length - 1].lines.length; i++) {
7748
+ var line = hunks[hunks.length - 1].lines[i];
7749
+ if (line[0] == '\\') {
7750
+ if (prevLine[0] == '+') {
7751
+ removeEOFNL = true;
7752
+ } else if (prevLine[0] == '-') {
7753
+ addEOFNL = true;
7754
+ }
7755
+ }
7756
+ prevLine = line;
7757
+ }
7758
+ if (removeEOFNL) {
7759
+ if (addEOFNL) {
7760
+ // This means the final line gets changed but doesn't have a trailing newline in either the
7761
+ // original or patched version. In that case, we do nothing if fuzzFactor > 0, and if
7762
+ // fuzzFactor is 0, we simply validate that the source file has no trailing newline.
7763
+ if (!fuzzFactor && lines[lines.length - 1] == '') {
7764
+ return false;
7765
+ }
7766
+ } else if (lines[lines.length - 1] == '') {
7767
+ lines.pop();
7768
+ } else if (!fuzzFactor) {
7769
+ return false;
7770
+ }
7771
+ } else if (addEOFNL) {
7772
+ if (lines[lines.length - 1] != '') {
7773
+ lines.push('');
7774
+ } else if (!fuzzFactor) {
7775
+ return false;
7776
+ }
7777
+ }
7010
7778
 
7011
- var lines = source.split(/\r\n|[\n\v\f\r\x85]/),
7012
- delimiters = source.match(/\r\n|[\n\v\f\r\x85]/g) || [],
7013
- hunks = uniDiff.hunks,
7014
- compareLine = options.compareLine || function (lineNumber, line, operation, patchContent)
7015
- /*istanbul ignore start*/
7016
- {
7017
- return (
7018
- /*istanbul ignore end*/
7019
- line === patchContent
7020
- );
7021
- },
7022
- errorCount = 0,
7023
- fuzzFactor = options.fuzzFactor || 0,
7024
- minLine = 0,
7025
- offset = 0,
7026
- removeEOFNL,
7027
- addEOFNL;
7028
7779
  /**
7029
- * Checks if the hunk exactly fits on the provided location
7780
+ * Checks if the hunk can be made to fit at the provided location with at most `maxErrors`
7781
+ * insertions, substitutions, or deletions, while ensuring also that:
7782
+ * - lines deleted in the hunk match exactly, and
7783
+ * - wherever an insertion operation or block of insertion operations appears in the hunk, the
7784
+ * immediately preceding and following lines of context match exactly
7785
+ *
7786
+ * `toPos` should be set such that lines[toPos] is meant to match hunkLines[0].
7787
+ *
7788
+ * If the hunk can be applied, returns an object with properties `oldLineLastI` and
7789
+ * `replacementLines`. Otherwise, returns null.
7030
7790
  */
7031
-
7032
-
7033
- function hunkFits(hunk, toPos) {
7034
- for (var j = 0; j < hunk.lines.length; j++) {
7035
- var line = hunk.lines[j],
7036
- operation = line.length > 0 ? line[0] : ' ',
7037
- content = line.length > 0 ? line.substr(1) : line;
7038
-
7039
- if (operation === ' ' || operation === '-') {
7040
- // Context sanity check
7041
- if (!compareLine(toPos + 1, lines[toPos], operation, content)) {
7042
- errorCount++;
7043
-
7044
- if (errorCount > fuzzFactor) {
7045
- return false;
7791
+ function applyHunk(hunkLines, toPos, maxErrors) {
7792
+ /*istanbul ignore start*/
7793
+ var
7794
+ /*istanbul ignore end*/
7795
+ hunkLinesI = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
7796
+ /*istanbul ignore start*/
7797
+ var
7798
+ /*istanbul ignore end*/
7799
+ lastContextLineMatched = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
7800
+ /*istanbul ignore start*/
7801
+ var
7802
+ /*istanbul ignore end*/
7803
+ patchedLines = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
7804
+ /*istanbul ignore start*/
7805
+ var
7806
+ /*istanbul ignore end*/
7807
+ patchedLinesLength = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
7808
+ var nConsecutiveOldContextLines = 0;
7809
+ var nextContextLineMustMatch = false;
7810
+ for (; hunkLinesI < hunkLines.length; hunkLinesI++) {
7811
+ var hunkLine = hunkLines[hunkLinesI],
7812
+ operation = hunkLine.length > 0 ? hunkLine[0] : ' ',
7813
+ content = hunkLine.length > 0 ? hunkLine.substr(1) : hunkLine;
7814
+ if (operation === '-') {
7815
+ if (compareLine(toPos + 1, lines[toPos], operation, content)) {
7816
+ toPos++;
7817
+ nConsecutiveOldContextLines = 0;
7818
+ } else {
7819
+ if (!maxErrors || lines[toPos] == null) {
7820
+ return null;
7046
7821
  }
7822
+ patchedLines[patchedLinesLength] = lines[toPos];
7823
+ return applyHunk(hunkLines, toPos + 1, maxErrors - 1, hunkLinesI, false, patchedLines, patchedLinesLength + 1);
7824
+ }
7825
+ }
7826
+ if (operation === '+') {
7827
+ if (!lastContextLineMatched) {
7828
+ return null;
7047
7829
  }
7830
+ patchedLines[patchedLinesLength] = content;
7831
+ patchedLinesLength++;
7832
+ nConsecutiveOldContextLines = 0;
7833
+ nextContextLineMustMatch = true;
7834
+ }
7835
+ if (operation === ' ') {
7836
+ nConsecutiveOldContextLines++;
7837
+ patchedLines[patchedLinesLength] = lines[toPos];
7838
+ if (compareLine(toPos + 1, lines[toPos], operation, content)) {
7839
+ patchedLinesLength++;
7840
+ lastContextLineMatched = true;
7841
+ nextContextLineMustMatch = false;
7842
+ toPos++;
7843
+ } else {
7844
+ if (nextContextLineMustMatch || !maxErrors) {
7845
+ return null;
7846
+ }
7048
7847
 
7049
- toPos++;
7848
+ // Consider 3 possibilities in sequence:
7849
+ // 1. lines contains a *substitution* not included in the patch context, or
7850
+ // 2. lines contains an *insertion* not included in the patch context, or
7851
+ // 3. lines contains a *deletion* not included in the patch context
7852
+ // The first two options are of course only possible if the line from lines is non-null -
7853
+ // i.e. only option 3 is possible if we've overrun the end of the old file.
7854
+ return lines[toPos] && (applyHunk(hunkLines, toPos + 1, maxErrors - 1, hunkLinesI + 1, false, patchedLines, patchedLinesLength + 1) || applyHunk(hunkLines, toPos + 1, maxErrors - 1, hunkLinesI, false, patchedLines, patchedLinesLength + 1)) || applyHunk(hunkLines, toPos, maxErrors - 1, hunkLinesI + 1, false, patchedLines, patchedLinesLength);
7855
+ }
7050
7856
  }
7051
7857
  }
7052
7858
 
7053
- return true;
7054
- } // Search best fit offsets for each hunk based on the previous ones
7055
-
7056
-
7057
- for (var i = 0; i < hunks.length; i++) {
7058
- var hunk = hunks[i],
7059
- maxLine = lines.length - hunk.oldLines,
7060
- localOffset = 0,
7061
- toPos = offset + hunk.oldStart - 1;
7062
- var iterator =
7063
- /*istanbul ignore start*/
7064
- (/*istanbul ignore end*/
7859
+ // Before returning, trim any unmodified context lines off the end of patchedLines and reduce
7860
+ // toPos (and thus oldLineLastI) accordingly. This allows later hunks to be applied to a region
7861
+ // that starts in this hunk's trailing context.
7862
+ patchedLinesLength -= nConsecutiveOldContextLines;
7863
+ toPos -= nConsecutiveOldContextLines;
7864
+ patchedLines.length = patchedLinesLength;
7865
+ return {
7866
+ patchedLines: patchedLines,
7867
+ oldLineLastI: toPos - 1
7868
+ };
7869
+ }
7870
+ var resultLines = [];
7065
7871
 
7872
+ // Search best fit offsets for each hunk based on the previous ones
7873
+ var prevHunkOffset = 0;
7874
+ for (var _i = 0; _i < hunks.length; _i++) {
7875
+ var hunk = hunks[_i];
7876
+ var hunkResult =
7066
7877
  /*istanbul ignore start*/
7067
- 0, _distanceIterator
7878
+ void 0
7068
7879
  /*istanbul ignore end*/
7069
- [
7880
+ ;
7881
+ var maxLine = lines.length - hunk.oldLines + fuzzFactor;
7882
+ var toPos =
7070
7883
  /*istanbul ignore start*/
7071
- "default"
7884
+ void 0
7072
7885
  /*istanbul ignore end*/
7073
- ])(toPos, minLine, maxLine);
7074
-
7075
- for (; localOffset !== undefined; localOffset = iterator()) {
7076
- if (hunkFits(hunk, toPos + localOffset)) {
7077
- hunk.offset = offset += localOffset;
7886
+ ;
7887
+ for (var maxErrors = 0; maxErrors <= fuzzFactor; maxErrors++) {
7888
+ toPos = hunk.oldStart + prevHunkOffset - 1;
7889
+ var iterator =
7890
+ /*istanbul ignore start*/
7891
+ (/*istanbul ignore end*/
7892
+ /*istanbul ignore start*/
7893
+ 0, _distanceIterator
7894
+ /*istanbul ignore end*/
7895
+ [
7896
+ /*istanbul ignore start*/
7897
+ "default"
7898
+ /*istanbul ignore end*/
7899
+ ])(toPos, minLine, maxLine);
7900
+ for (; toPos !== undefined; toPos = iterator()) {
7901
+ hunkResult = applyHunk(hunk.lines, toPos, maxErrors);
7902
+ if (hunkResult) {
7903
+ break;
7904
+ }
7905
+ }
7906
+ if (hunkResult) {
7078
7907
  break;
7079
7908
  }
7080
7909
  }
7081
-
7082
- if (localOffset === undefined) {
7910
+ if (!hunkResult) {
7083
7911
  return false;
7084
- } // Set lower text limit to end of the current hunk, so next ones don't try
7085
- // to fit over already patched text
7086
-
7087
-
7088
- minLine = hunk.offset + hunk.oldStart + hunk.oldLines;
7089
- } // Apply patch hunks
7090
-
7091
-
7092
- var diffOffset = 0;
7093
-
7094
- for (var _i = 0; _i < hunks.length; _i++) {
7095
- var _hunk = hunks[_i],
7096
- _toPos = _hunk.oldStart + _hunk.offset + diffOffset - 1;
7097
-
7098
- diffOffset += _hunk.newLines - _hunk.oldLines;
7912
+ }
7099
7913
 
7100
- for (var j = 0; j < _hunk.lines.length; j++) {
7101
- var line = _hunk.lines[j],
7102
- operation = line.length > 0 ? line[0] : ' ',
7103
- content = line.length > 0 ? line.substr(1) : line,
7104
- delimiter = _hunk.linedelimiters && _hunk.linedelimiters[j] || '\n';
7914
+ // Copy everything from the end of where we applied the last hunk to the start of this hunk
7915
+ for (var _i2 = minLine; _i2 < toPos; _i2++) {
7916
+ resultLines.push(lines[_i2]);
7917
+ }
7105
7918
 
7106
- if (operation === ' ') {
7107
- _toPos++;
7108
- } else if (operation === '-') {
7109
- lines.splice(_toPos, 1);
7110
- delimiters.splice(_toPos, 1);
7111
- /* istanbul ignore else */
7112
- } else if (operation === '+') {
7113
- lines.splice(_toPos, 0, content);
7114
- delimiters.splice(_toPos, 0, delimiter);
7115
- _toPos++;
7116
- } else if (operation === '\\') {
7117
- var previousOperation = _hunk.lines[j - 1] ? _hunk.lines[j - 1][0] : null;
7118
-
7119
- if (previousOperation === '+') {
7120
- removeEOFNL = true;
7121
- } else if (previousOperation === '-') {
7122
- addEOFNL = true;
7123
- }
7124
- }
7919
+ // Add the lines produced by applying the hunk:
7920
+ for (var _i3 = 0; _i3 < hunkResult.patchedLines.length; _i3++) {
7921
+ var _line = hunkResult.patchedLines[_i3];
7922
+ resultLines.push(_line);
7125
7923
  }
7126
- } // Handle EOFNL insertion/removal
7127
7924
 
7925
+ // Set lower text limit to end of the current hunk, so next ones don't try
7926
+ // to fit over already patched text
7927
+ minLine = hunkResult.oldLineLastI + 1;
7128
7928
 
7129
- if (removeEOFNL) {
7130
- while (!lines[lines.length - 1]) {
7131
- lines.pop();
7132
- delimiters.pop();
7133
- }
7134
- } else if (addEOFNL) {
7135
- lines.push('');
7136
- delimiters.push('\n');
7929
+ // Note the offset between where the patch said the hunk should've applied and where we
7930
+ // applied it, so we can adjust future hunks accordingly:
7931
+ prevHunkOffset = toPos + 1 - hunk.oldStart;
7137
7932
  }
7138
7933
 
7139
- for (var _k = 0; _k < lines.length - 1; _k++) {
7140
- lines[_k] = lines[_k] + delimiters[_k];
7934
+ // Copy over the rest of the lines from the old text
7935
+ for (var _i4 = minLine; _i4 < lines.length; _i4++) {
7936
+ resultLines.push(lines[_i4]);
7141
7937
  }
7938
+ return resultLines.join('\n');
7939
+ }
7142
7940
 
7143
- return lines.join('');
7144
- } // Wrapper that supports multiple file patches via callbacks.
7145
-
7146
-
7941
+ // Wrapper that supports multiple file patches via callbacks.
7147
7942
  function applyPatches(uniDiff, options) {
7148
7943
  if (typeof uniDiff === 'string') {
7149
7944
  uniDiff =
7150
7945
  /*istanbul ignore start*/
7151
7946
  (/*istanbul ignore end*/
7152
-
7153
7947
  /*istanbul ignore start*/
7154
7948
  0, _parse$1
7155
7949
  /*istanbul ignore end*/
@@ -7159,32 +7953,25 @@
7159
7953
  /*istanbul ignore end*/
7160
7954
  (uniDiff);
7161
7955
  }
7162
-
7163
7956
  var currentIndex = 0;
7164
-
7165
7957
  function processIndex() {
7166
7958
  var index = uniDiff[currentIndex++];
7167
-
7168
7959
  if (!index) {
7169
7960
  return options.complete();
7170
7961
  }
7171
-
7172
7962
  options.loadFile(index, function (err, data) {
7173
7963
  if (err) {
7174
7964
  return options.complete(err);
7175
7965
  }
7176
-
7177
7966
  var updatedContent = applyPatch(data, index, options);
7178
7967
  options.patched(index, updatedContent, function (err) {
7179
7968
  if (err) {
7180
7969
  return options.complete(err);
7181
7970
  }
7182
-
7183
7971
  processIndex();
7184
7972
  });
7185
7973
  });
7186
7974
  }
7187
-
7188
7975
  processIndex();
7189
7976
  }
7190
7977
 
@@ -7197,275 +7984,367 @@
7197
7984
  Object.defineProperty(create, "__esModule", {
7198
7985
  value: true
7199
7986
  });
7200
- create.structuredPatch = structuredPatch;
7201
- create.formatPatch = formatPatch;
7202
- create.createTwoFilesPatch = createTwoFilesPatch;
7203
7987
  create.createPatch = createPatch;
7204
-
7988
+ create.createTwoFilesPatch = createTwoFilesPatch;
7989
+ create.formatPatch = formatPatch;
7990
+ create.structuredPatch = structuredPatch;
7205
7991
  /*istanbul ignore end*/
7206
7992
  var
7207
7993
  /*istanbul ignore start*/
7208
7994
  _line = line
7209
7995
  /*istanbul ignore end*/
7210
7996
  ;
7211
-
7212
- /*istanbul ignore start*/ function _toConsumableArray$1(arr) { return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1(); }
7213
-
7997
+ /*istanbul ignore start*/ function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); }
7998
+ function _toConsumableArray$1(arr) { return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1(); }
7214
7999
  function _nonIterableSpread$1() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7215
-
7216
8000
  function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
7217
-
7218
- function _iterableToArray$1(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
7219
-
8001
+ function _iterableToArray$1(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7220
8002
  function _arrayWithoutHoles$1(arr) { if (Array.isArray(arr)) return _arrayLikeToArray$1(arr); }
7221
-
7222
- function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7223
-
8003
+ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8004
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8005
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8006
+ function _defineProperty$1(obj, key, value) { key = _toPropertyKey$1(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8007
+ function _toPropertyKey$1(t) { var i = _toPrimitive$1(t, "string"); return "symbol" == _typeof$1(i) ? i : i + ""; }
8008
+ function _toPrimitive$1(t, r) { if ("object" != _typeof$1(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof$1(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7224
8009
  /*istanbul ignore end*/
7225
8010
  function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
7226
8011
  if (!options) {
7227
8012
  options = {};
7228
8013
  }
7229
-
8014
+ if (typeof options === 'function') {
8015
+ options = {
8016
+ callback: options
8017
+ };
8018
+ }
7230
8019
  if (typeof options.context === 'undefined') {
7231
8020
  options.context = 4;
7232
8021
  }
7233
-
7234
- var diff =
7235
- /*istanbul ignore start*/
7236
- (/*istanbul ignore end*/
7237
-
7238
- /*istanbul ignore start*/
7239
- 0, _line
7240
- /*istanbul ignore end*/
7241
- .
7242
- /*istanbul ignore start*/
7243
- diffLines)
7244
- /*istanbul ignore end*/
7245
- (oldStr, newStr, options);
7246
-
7247
- if (!diff) {
7248
- return;
7249
- }
7250
-
7251
- diff.push({
7252
- value: '',
7253
- lines: []
7254
- }); // Append an empty value to make cleanup easier
7255
-
7256
- function contextLines(lines) {
7257
- return lines.map(function (entry) {
7258
- return ' ' + entry;
7259
- });
8022
+ if (options.newlineIsToken) {
8023
+ throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');
7260
8024
  }
7261
-
7262
- var hunks = [];
7263
- var oldRangeStart = 0,
7264
- newRangeStart = 0,
7265
- curRange = [],
7266
- oldLine = 1,
7267
- newLine = 1;
7268
-
7269
- /*istanbul ignore start*/
7270
- var _loop = function _loop(
7271
- /*istanbul ignore end*/
7272
- i) {
7273
- var current = diff[i],
7274
- lines = current.lines || current.value.replace(/\n$/, '').split('\n');
7275
- current.lines = lines;
7276
-
7277
- if (current.added || current.removed) {
7278
- /*istanbul ignore start*/
7279
- var _curRange;
7280
-
7281
- /*istanbul ignore end*/
7282
- // If we have previous context, start with that
7283
- if (!oldRangeStart) {
7284
- var prev = diff[i - 1];
7285
- oldRangeStart = oldLine;
7286
- newRangeStart = newLine;
7287
-
7288
- if (prev) {
7289
- curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
7290
- oldRangeStart -= curRange.length;
7291
- newRangeStart -= curRange.length;
7292
- }
7293
- } // Output our changes
7294
-
7295
-
7296
- /*istanbul ignore start*/
7297
-
7298
- /*istanbul ignore end*/
7299
-
8025
+ if (!options.callback) {
8026
+ return diffLinesResultToPatch(
8027
+ /*istanbul ignore start*/
8028
+ (/*istanbul ignore end*/
8029
+ /*istanbul ignore start*/
8030
+ 0, _line
8031
+ /*istanbul ignore end*/
8032
+ .
8033
+ /*istanbul ignore start*/
8034
+ diffLines)
8035
+ /*istanbul ignore end*/
8036
+ (oldStr, newStr, options));
8037
+ } else {
8038
+ var
7300
8039
  /*istanbul ignore start*/
7301
- (_curRange =
8040
+ _options =
7302
8041
  /*istanbul ignore end*/
7303
- curRange).push.apply(
8042
+ options,
7304
8043
  /*istanbul ignore start*/
7305
- _curRange
7306
8044
  /*istanbul ignore end*/
7307
- ,
8045
+ _callback = _options.callback;
8046
+ /*istanbul ignore start*/
8047
+ (/*istanbul ignore end*/
8048
+ /*istanbul ignore start*/
8049
+ 0, _line
8050
+ /*istanbul ignore end*/
8051
+ .
8052
+ /*istanbul ignore start*/
8053
+ diffLines)
8054
+ /*istanbul ignore end*/
8055
+ (oldStr, newStr,
8056
+ /*istanbul ignore start*/
8057
+ _objectSpread$1(_objectSpread$1({},
8058
+ /*istanbul ignore end*/
8059
+ options), {}, {
8060
+ callback: function
7308
8061
  /*istanbul ignore start*/
7309
- _toConsumableArray$1(
8062
+ callback
7310
8063
  /*istanbul ignore end*/
7311
- lines.map(function (entry) {
7312
- return (current.added ? '+' : '-') + entry;
7313
- }))); // Track the updated file position
7314
-
7315
-
7316
- if (current.added) {
7317
- newLine += lines.length;
7318
- } else {
7319
- oldLine += lines.length;
8064
+ (diff) {
8065
+ var patch = diffLinesResultToPatch(diff);
8066
+ _callback(patch);
7320
8067
  }
7321
- } else {
7322
- // Identical context lines. Track line changes
7323
- if (oldRangeStart) {
7324
- // Close out any changes that have been output (or join overlapping)
7325
- if (lines.length <= options.context * 2 && i < diff.length - 2) {
7326
- /*istanbul ignore start*/
7327
- var _curRange2;
8068
+ }));
8069
+ }
8070
+ function diffLinesResultToPatch(diff) {
8071
+ // STEP 1: Build up the patch with no "" lines and with the arrays
8072
+ // of lines containing trailing newline characters. We'll tidy up later...
7328
8073
 
7329
- /*istanbul ignore end*/
7330
- // Overlapping
8074
+ if (!diff) {
8075
+ return;
8076
+ }
8077
+ diff.push({
8078
+ value: '',
8079
+ lines: []
8080
+ }); // Append an empty value to make cleanup easier
7331
8081
 
7332
- /*istanbul ignore start*/
8082
+ function contextLines(lines) {
8083
+ return lines.map(function (entry) {
8084
+ return ' ' + entry;
8085
+ });
8086
+ }
8087
+ var hunks = [];
8088
+ var oldRangeStart = 0,
8089
+ newRangeStart = 0,
8090
+ curRange = [],
8091
+ oldLine = 1,
8092
+ newLine = 1;
8093
+ /*istanbul ignore start*/
8094
+ var _loop = function _loop()
8095
+ /*istanbul ignore end*/
8096
+ {
8097
+ var current = diff[i],
8098
+ lines = current.lines || splitLines(current.value);
8099
+ current.lines = lines;
8100
+ if (current.added || current.removed) {
8101
+ /*istanbul ignore start*/
8102
+ var _curRange;
8103
+ /*istanbul ignore end*/
8104
+ // If we have previous context, start with that
8105
+ if (!oldRangeStart) {
8106
+ var prev = diff[i - 1];
8107
+ oldRangeStart = oldLine;
8108
+ newRangeStart = newLine;
8109
+ if (prev) {
8110
+ curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
8111
+ oldRangeStart -= curRange.length;
8112
+ newRangeStart -= curRange.length;
8113
+ }
8114
+ }
7333
8115
 
7334
- /*istanbul ignore end*/
8116
+ // Output our changes
8117
+ /*istanbul ignore start*/
8118
+ /*istanbul ignore end*/
8119
+ /*istanbul ignore start*/
8120
+ (_curRange =
8121
+ /*istanbul ignore end*/
8122
+ curRange).push.apply(
8123
+ /*istanbul ignore start*/
8124
+ _curRange
8125
+ /*istanbul ignore end*/
8126
+ ,
8127
+ /*istanbul ignore start*/
8128
+ _toConsumableArray$1(
8129
+ /*istanbul ignore end*/
8130
+ lines.map(function (entry) {
8131
+ return (current.added ? '+' : '-') + entry;
8132
+ })));
7335
8133
 
7336
- /*istanbul ignore start*/
7337
- (_curRange2 =
7338
- /*istanbul ignore end*/
7339
- curRange).push.apply(
7340
- /*istanbul ignore start*/
7341
- _curRange2
7342
- /*istanbul ignore end*/
7343
- ,
7344
- /*istanbul ignore start*/
7345
- _toConsumableArray$1(
7346
- /*istanbul ignore end*/
7347
- contextLines(lines)));
8134
+ // Track the updated file position
8135
+ if (current.added) {
8136
+ newLine += lines.length;
7348
8137
  } else {
7349
- /*istanbul ignore start*/
7350
- var _curRange3;
7351
-
7352
- /*istanbul ignore end*/
7353
- // end the range and output
7354
- var contextSize = Math.min(lines.length, options.context);
7355
-
7356
- /*istanbul ignore start*/
7357
-
7358
- /*istanbul ignore end*/
7359
-
7360
- /*istanbul ignore start*/
7361
- (_curRange3 =
7362
- /*istanbul ignore end*/
7363
- curRange).push.apply(
7364
- /*istanbul ignore start*/
7365
- _curRange3
7366
- /*istanbul ignore end*/
7367
- ,
7368
- /*istanbul ignore start*/
7369
- _toConsumableArray$1(
7370
- /*istanbul ignore end*/
7371
- contextLines(lines.slice(0, contextSize))));
7372
-
7373
- var hunk = {
7374
- oldStart: oldRangeStart,
7375
- oldLines: oldLine - oldRangeStart + contextSize,
7376
- newStart: newRangeStart,
7377
- newLines: newLine - newRangeStart + contextSize,
7378
- lines: curRange
7379
- };
7380
-
7381
- if (i >= diff.length - 2 && lines.length <= options.context) {
7382
- // EOF is inside this hunk
7383
- var oldEOFNewline = /\n$/.test(oldStr);
7384
- var newEOFNewline = /\n$/.test(newStr);
7385
- var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
7386
-
7387
- if (!oldEOFNewline && noNlBeforeAdds && oldStr.length > 0) {
7388
- // special case: old has no eol and no trailing context; no-nl can end up before adds
7389
- // however, if the old file is empty, do not output the no-nl line
7390
- curRange.splice(hunk.oldLines, 0, '\');
7391
- }
7392
-
7393
- if (!oldEOFNewline && !noNlBeforeAdds || !newEOFNewline) {
7394
- curRange.push('\');
7395
- }
8138
+ oldLine += lines.length;
8139
+ }
8140
+ } else {
8141
+ // Identical context lines. Track line changes
8142
+ if (oldRangeStart) {
8143
+ // Close out any changes that have been output (or join overlapping)
8144
+ if (lines.length <= options.context * 2 && i < diff.length - 2) {
8145
+ /*istanbul ignore start*/
8146
+ var _curRange2;
8147
+ /*istanbul ignore end*/
8148
+ // Overlapping
8149
+ /*istanbul ignore start*/
8150
+ /*istanbul ignore end*/
8151
+ /*istanbul ignore start*/
8152
+ (_curRange2 =
8153
+ /*istanbul ignore end*/
8154
+ curRange).push.apply(
8155
+ /*istanbul ignore start*/
8156
+ _curRange2
8157
+ /*istanbul ignore end*/
8158
+ ,
8159
+ /*istanbul ignore start*/
8160
+ _toConsumableArray$1(
8161
+ /*istanbul ignore end*/
8162
+ contextLines(lines)));
8163
+ } else {
8164
+ /*istanbul ignore start*/
8165
+ var _curRange3;
8166
+ /*istanbul ignore end*/
8167
+ // end the range and output
8168
+ var contextSize = Math.min(lines.length, options.context);
8169
+ /*istanbul ignore start*/
8170
+ /*istanbul ignore end*/
8171
+ /*istanbul ignore start*/
8172
+ (_curRange3 =
8173
+ /*istanbul ignore end*/
8174
+ curRange).push.apply(
8175
+ /*istanbul ignore start*/
8176
+ _curRange3
8177
+ /*istanbul ignore end*/
8178
+ ,
8179
+ /*istanbul ignore start*/
8180
+ _toConsumableArray$1(
8181
+ /*istanbul ignore end*/
8182
+ contextLines(lines.slice(0, contextSize))));
8183
+ var _hunk = {
8184
+ oldStart: oldRangeStart,
8185
+ oldLines: oldLine - oldRangeStart + contextSize,
8186
+ newStart: newRangeStart,
8187
+ newLines: newLine - newRangeStart + contextSize,
8188
+ lines: curRange
8189
+ };
8190
+ hunks.push(_hunk);
8191
+ oldRangeStart = 0;
8192
+ newRangeStart = 0;
8193
+ curRange = [];
7396
8194
  }
7397
-
7398
- hunks.push(hunk);
7399
- oldRangeStart = 0;
7400
- newRangeStart = 0;
7401
- curRange = [];
7402
8195
  }
8196
+ oldLine += lines.length;
8197
+ newLine += lines.length;
7403
8198
  }
7404
-
7405
- oldLine += lines.length;
7406
- newLine += lines.length;
8199
+ };
8200
+ for (var i = 0; i < diff.length; i++)
8201
+ /*istanbul ignore start*/
8202
+ {
8203
+ _loop();
7407
8204
  }
7408
- };
7409
8205
 
7410
- for (var i = 0; i < diff.length; i++) {
8206
+ // Step 2: eliminate the trailing `\n` from each line of each hunk, and, where needed, add
8207
+ // "".
8208
+ /*istanbul ignore end*/
8209
+ for (
8210
+ /*istanbul ignore start*/
8211
+ var _i = 0, _hunks =
8212
+ /*istanbul ignore end*/
8213
+ hunks;
8214
+ /*istanbul ignore start*/
8215
+ _i < _hunks.length
8216
+ /*istanbul ignore end*/
8217
+ ;
7411
8218
  /*istanbul ignore start*/
7412
- _loop(
8219
+ _i++
7413
8220
  /*istanbul ignore end*/
7414
- i);
8221
+ ) {
8222
+ var hunk =
8223
+ /*istanbul ignore start*/
8224
+ _hunks[_i]
8225
+ /*istanbul ignore end*/
8226
+ ;
8227
+ for (var _i2 = 0; _i2 < hunk.lines.length; _i2++) {
8228
+ if (hunk.lines[_i2].endsWith('\n')) {
8229
+ hunk.lines[_i2] = hunk.lines[_i2].slice(0, -1);
8230
+ } else {
8231
+ hunk.lines.splice(_i2 + 1, 0, '\');
8232
+ _i2++; // Skip the line we just added, then continue iterating
8233
+ }
8234
+ }
8235
+ }
8236
+ return {
8237
+ oldFileName: oldFileName,
8238
+ newFileName: newFileName,
8239
+ oldHeader: oldHeader,
8240
+ newHeader: newHeader,
8241
+ hunks: hunks
8242
+ };
7415
8243
  }
7416
-
7417
- return {
7418
- oldFileName: oldFileName,
7419
- newFileName: newFileName,
7420
- oldHeader: oldHeader,
7421
- newHeader: newHeader,
7422
- hunks: hunks
7423
- };
7424
8244
  }
7425
-
7426
8245
  function formatPatch(diff) {
7427
8246
  if (Array.isArray(diff)) {
7428
8247
  return diff.map(formatPatch).join('\n');
7429
8248
  }
7430
-
7431
8249
  var ret = [];
7432
-
7433
8250
  if (diff.oldFileName == diff.newFileName) {
7434
8251
  ret.push('Index: ' + diff.oldFileName);
7435
8252
  }
7436
-
7437
8253
  ret.push('===================================================================');
7438
8254
  ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
7439
8255
  ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
7440
-
7441
8256
  for (var i = 0; i < diff.hunks.length; i++) {
7442
- var hunk = diff.hunks[i]; // Unified Diff Format quirk: If the chunk size is 0,
8257
+ var hunk = diff.hunks[i];
8258
+ // Unified Diff Format quirk: If the chunk size is 0,
7443
8259
  // the first number is one lower than one would expect.
7444
8260
  // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
7445
-
7446
8261
  if (hunk.oldLines === 0) {
7447
8262
  hunk.oldStart -= 1;
7448
8263
  }
7449
-
7450
8264
  if (hunk.newLines === 0) {
7451
8265
  hunk.newStart -= 1;
7452
8266
  }
7453
-
7454
8267
  ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines + ' +' + hunk.newStart + ',' + hunk.newLines + ' @@');
7455
8268
  ret.push.apply(ret, hunk.lines);
7456
8269
  }
7457
-
7458
- return ret.join('\n') + '\n';
7459
- }
7460
-
7461
- function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
7462
- return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
8270
+ return ret.join('\n') + '\n';
8271
+ }
8272
+ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
8273
+ /*istanbul ignore start*/
8274
+ var _options2;
8275
+ /*istanbul ignore end*/
8276
+ if (typeof options === 'function') {
8277
+ options = {
8278
+ callback: options
8279
+ };
8280
+ }
8281
+ if (!
8282
+ /*istanbul ignore start*/
8283
+ ((_options2 =
8284
+ /*istanbul ignore end*/
8285
+ options) !== null && _options2 !== void 0 &&
8286
+ /*istanbul ignore start*/
8287
+ _options2
8288
+ /*istanbul ignore end*/
8289
+ .callback)) {
8290
+ var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
8291
+ if (!patchObj) {
8292
+ return;
8293
+ }
8294
+ return formatPatch(patchObj);
8295
+ } else {
8296
+ var
8297
+ /*istanbul ignore start*/
8298
+ _options3 =
8299
+ /*istanbul ignore end*/
8300
+ options,
8301
+ /*istanbul ignore start*/
8302
+ /*istanbul ignore end*/
8303
+ _callback2 = _options3.callback;
8304
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader,
8305
+ /*istanbul ignore start*/
8306
+ _objectSpread$1(_objectSpread$1({},
8307
+ /*istanbul ignore end*/
8308
+ options), {}, {
8309
+ callback: function
8310
+ /*istanbul ignore start*/
8311
+ callback
8312
+ /*istanbul ignore end*/
8313
+ (patchObj) {
8314
+ if (!patchObj) {
8315
+ _callback2();
8316
+ } else {
8317
+ _callback2(formatPatch(patchObj));
8318
+ }
8319
+ }
8320
+ }));
8321
+ }
7463
8322
  }
7464
-
7465
8323
  function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
7466
8324
  return createTwoFilesPatch(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
7467
8325
  }
7468
8326
 
8327
+ /**
8328
+ * Split `text` into an array of lines, including the trailing newline character (where present)
8329
+ */
8330
+ function splitLines(text) {
8331
+ var hasTrailingNl = text.endsWith('\n');
8332
+ var result = text.split('\n').map(function (line)
8333
+ /*istanbul ignore start*/
8334
+ {
8335
+ return (
8336
+ /*istanbul ignore end*/
8337
+ line + '\n'
8338
+ );
8339
+ });
8340
+ if (hasTrailingNl) {
8341
+ result.pop();
8342
+ } else {
8343
+ result.push(result.pop().slice(0, -1));
8344
+ }
8345
+ return result;
8346
+ }
8347
+
7469
8348
  var array = {};
7470
8349
 
7471
8350
  /*istanbul ignore start*/
@@ -7475,27 +8354,22 @@
7475
8354
  });
7476
8355
  array.arrayEqual = arrayEqual;
7477
8356
  array.arrayStartsWith = arrayStartsWith;
7478
-
7479
8357
  /*istanbul ignore end*/
7480
8358
  function arrayEqual(a, b) {
7481
8359
  if (a.length !== b.length) {
7482
8360
  return false;
7483
8361
  }
7484
-
7485
8362
  return arrayStartsWith(a, b);
7486
8363
  }
7487
-
7488
8364
  function arrayStartsWith(array, start) {
7489
8365
  if (start.length > array.length) {
7490
8366
  return false;
7491
8367
  }
7492
-
7493
8368
  for (var i = 0; i < start.length; i++) {
7494
8369
  if (start[i] !== array[i]) {
7495
8370
  return false;
7496
8371
  }
7497
8372
  }
7498
-
7499
8373
  return true;
7500
8374
  }
7501
8375
 
@@ -7506,71 +8380,63 @@
7506
8380
  });
7507
8381
  merge$1.calcLineCount = calcLineCount;
7508
8382
  merge$1.merge = merge;
7509
-
7510
8383
  /*istanbul ignore end*/
7511
8384
  var
7512
8385
  /*istanbul ignore start*/
7513
8386
  _create = create
7514
8387
  /*istanbul ignore end*/
7515
8388
  ;
7516
-
7517
8389
  var
7518
8390
  /*istanbul ignore start*/
7519
8391
  _parse = parse$2
7520
8392
  /*istanbul ignore end*/
7521
8393
  ;
7522
-
7523
8394
  var
7524
8395
  /*istanbul ignore start*/
7525
8396
  _array = array
7526
8397
  /*istanbul ignore end*/
7527
8398
  ;
7528
-
7529
8399
  /*istanbul ignore start*/ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7530
-
7531
8400
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7532
-
7533
8401
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7534
-
7535
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
7536
-
8402
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
7537
8403
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7538
-
7539
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
7540
-
8404
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7541
8405
  /*istanbul ignore end*/
7542
8406
  function calcLineCount(hunk) {
7543
- /*istanbul ignore start*/
7544
- var _calcOldNewLineCount =
7545
- /*istanbul ignore end*/
7546
- calcOldNewLineCount(hunk.lines),
7547
- oldLines = _calcOldNewLineCount.oldLines,
7548
- newLines = _calcOldNewLineCount.newLines;
7549
-
8407
+ var
8408
+ /*istanbul ignore start*/
8409
+ _calcOldNewLineCount =
8410
+ /*istanbul ignore end*/
8411
+ calcOldNewLineCount(hunk.lines),
8412
+ /*istanbul ignore start*/
8413
+ /*istanbul ignore end*/
8414
+ oldLines = _calcOldNewLineCount.oldLines,
8415
+ /*istanbul ignore start*/
8416
+ /*istanbul ignore end*/
8417
+ newLines = _calcOldNewLineCount.newLines;
7550
8418
  if (oldLines !== undefined) {
7551
8419
  hunk.oldLines = oldLines;
7552
8420
  } else {
7553
8421
  delete hunk.oldLines;
7554
8422
  }
7555
-
7556
8423
  if (newLines !== undefined) {
7557
8424
  hunk.newLines = newLines;
7558
8425
  } else {
7559
8426
  delete hunk.newLines;
7560
8427
  }
7561
8428
  }
7562
-
7563
8429
  function merge(mine, theirs, base) {
7564
8430
  mine = loadPatch(mine, base);
7565
8431
  theirs = loadPatch(theirs, base);
7566
- var ret = {}; // For index we just let it pass through as it doesn't have any necessary meaning.
8432
+ var ret = {};
8433
+
8434
+ // For index we just let it pass through as it doesn't have any necessary meaning.
7567
8435
  // Leaving sanity checks on this to the API consumer that may know more about the
7568
8436
  // meaning in their own context.
7569
-
7570
8437
  if (mine.index || theirs.index) {
7571
8438
  ret.index = mine.index || theirs.index;
7572
8439
  }
7573
-
7574
8440
  if (mine.newFileName || theirs.newFileName) {
7575
8441
  if (!fileNameChanged(mine)) {
7576
8442
  // No header or no change in ours, use theirs (and ours if theirs does not exist)
@@ -7592,21 +8458,18 @@
7592
8458
  ret.newHeader = selectField(ret, mine.newHeader, theirs.newHeader);
7593
8459
  }
7594
8460
  }
7595
-
7596
8461
  ret.hunks = [];
7597
8462
  var mineIndex = 0,
7598
- theirsIndex = 0,
7599
- mineOffset = 0,
7600
- theirsOffset = 0;
7601
-
8463
+ theirsIndex = 0,
8464
+ mineOffset = 0,
8465
+ theirsOffset = 0;
7602
8466
  while (mineIndex < mine.hunks.length || theirsIndex < theirs.hunks.length) {
7603
8467
  var mineCurrent = mine.hunks[mineIndex] || {
7604
- oldStart: Infinity
7605
- },
7606
- theirsCurrent = theirs.hunks[theirsIndex] || {
7607
- oldStart: Infinity
7608
- };
7609
-
8468
+ oldStart: Infinity
8469
+ },
8470
+ theirsCurrent = theirs.hunks[theirsIndex] || {
8471
+ oldStart: Infinity
8472
+ };
7610
8473
  if (hunkBefore(mineCurrent, theirsCurrent)) {
7611
8474
  // This patch does not overlap with any of the others, yay.
7612
8475
  ret.hunks.push(cloneHunk(mineCurrent, mineOffset));
@@ -7632,17 +8495,14 @@
7632
8495
  ret.hunks.push(mergedHunk);
7633
8496
  }
7634
8497
  }
7635
-
7636
8498
  return ret;
7637
8499
  }
7638
-
7639
8500
  function loadPatch(param, base) {
7640
8501
  if (typeof param === 'string') {
7641
8502
  if (/^@@/m.test(param) || /^Index:/m.test(param)) {
7642
8503
  return (
7643
8504
  /*istanbul ignore start*/
7644
8505
  (/*istanbul ignore end*/
7645
-
7646
8506
  /*istanbul ignore start*/
7647
8507
  0, _parse
7648
8508
  /*istanbul ignore end*/
@@ -7653,15 +8513,12 @@
7653
8513
  (param)[0]
7654
8514
  );
7655
8515
  }
7656
-
7657
8516
  if (!base) {
7658
8517
  throw new Error('Must provide a base reference or pass in a patch');
7659
8518
  }
7660
-
7661
8519
  return (
7662
8520
  /*istanbul ignore start*/
7663
8521
  (/*istanbul ignore end*/
7664
-
7665
8522
  /*istanbul ignore start*/
7666
8523
  0, _create
7667
8524
  /*istanbul ignore end*/
@@ -7672,14 +8529,11 @@
7672
8529
  (undefined, undefined, base, param)
7673
8530
  );
7674
8531
  }
7675
-
7676
8532
  return param;
7677
8533
  }
7678
-
7679
8534
  function fileNameChanged(patch) {
7680
8535
  return patch.newFileName && patch.newFileName !== patch.oldFileName;
7681
8536
  }
7682
-
7683
8537
  function selectField(index, mine, theirs) {
7684
8538
  if (mine === theirs) {
7685
8539
  return mine;
@@ -7691,11 +8545,9 @@
7691
8545
  };
7692
8546
  }
7693
8547
  }
7694
-
7695
8548
  function hunkBefore(test, check) {
7696
8549
  return test.oldStart < check.oldStart && test.oldStart + test.oldLines < check.oldStart;
7697
8550
  }
7698
-
7699
8551
  function cloneHunk(hunk, offset) {
7700
8552
  return {
7701
8553
  oldStart: hunk.oldStart,
@@ -7705,42 +8557,38 @@
7705
8557
  lines: hunk.lines
7706
8558
  };
7707
8559
  }
7708
-
7709
8560
  function mergeLines(hunk, mineOffset, mineLines, theirOffset, theirLines) {
7710
8561
  // This will generally result in a conflicted hunk, but there are cases where the context
7711
8562
  // is the only overlap where we can successfully merge the content here.
7712
8563
  var mine = {
7713
- offset: mineOffset,
7714
- lines: mineLines,
7715
- index: 0
7716
- },
7717
- their = {
7718
- offset: theirOffset,
7719
- lines: theirLines,
7720
- index: 0
7721
- }; // Handle any leading content
8564
+ offset: mineOffset,
8565
+ lines: mineLines,
8566
+ index: 0
8567
+ },
8568
+ their = {
8569
+ offset: theirOffset,
8570
+ lines: theirLines,
8571
+ index: 0
8572
+ };
7722
8573
 
8574
+ // Handle any leading content
7723
8575
  insertLeading(hunk, mine, their);
7724
- insertLeading(hunk, their, mine); // Now in the overlap content. Scan through and select the best changes from each.
8576
+ insertLeading(hunk, their, mine);
7725
8577
 
8578
+ // Now in the overlap content. Scan through and select the best changes from each.
7726
8579
  while (mine.index < mine.lines.length && their.index < their.lines.length) {
7727
8580
  var mineCurrent = mine.lines[mine.index],
7728
- theirCurrent = their.lines[their.index];
7729
-
8581
+ theirCurrent = their.lines[their.index];
7730
8582
  if ((mineCurrent[0] === '-' || mineCurrent[0] === '+') && (theirCurrent[0] === '-' || theirCurrent[0] === '+')) {
7731
8583
  // Both modified ...
7732
8584
  mutualChange(hunk, mine, their);
7733
8585
  } else if (mineCurrent[0] === '+' && theirCurrent[0] === ' ') {
7734
8586
  /*istanbul ignore start*/
7735
8587
  var _hunk$lines;
7736
-
7737
8588
  /*istanbul ignore end*/
7738
8589
  // Mine inserted
7739
-
7740
8590
  /*istanbul ignore start*/
7741
-
7742
8591
  /*istanbul ignore end*/
7743
-
7744
8592
  /*istanbul ignore start*/
7745
8593
  (_hunk$lines =
7746
8594
  /*istanbul ignore end*/
@@ -7756,14 +8604,10 @@
7756
8604
  } else if (theirCurrent[0] === '+' && mineCurrent[0] === ' ') {
7757
8605
  /*istanbul ignore start*/
7758
8606
  var _hunk$lines2;
7759
-
7760
8607
  /*istanbul ignore end*/
7761
8608
  // Theirs inserted
7762
-
7763
8609
  /*istanbul ignore start*/
7764
-
7765
8610
  /*istanbul ignore end*/
7766
-
7767
8611
  /*istanbul ignore start*/
7768
8612
  (_hunk$lines2 =
7769
8613
  /*istanbul ignore end*/
@@ -7791,24 +8635,21 @@
7791
8635
  // Context mismatch
7792
8636
  conflict(hunk, collectChange(mine), collectChange(their));
7793
8637
  }
7794
- } // Now push anything that may be remaining
7795
-
8638
+ }
7796
8639
 
8640
+ // Now push anything that may be remaining
7797
8641
  insertTrailing(hunk, mine);
7798
8642
  insertTrailing(hunk, their);
7799
8643
  calcLineCount(hunk);
7800
8644
  }
7801
-
7802
8645
  function mutualChange(hunk, mine, their) {
7803
8646
  var myChanges = collectChange(mine),
7804
- theirChanges = collectChange(their);
7805
-
8647
+ theirChanges = collectChange(their);
7806
8648
  if (allRemoves(myChanges) && allRemoves(theirChanges)) {
7807
8649
  // Special case for remove changes that are supersets of one another
7808
8650
  if (
7809
8651
  /*istanbul ignore start*/
7810
8652
  (/*istanbul ignore end*/
7811
-
7812
8653
  /*istanbul ignore start*/
7813
8654
  0, _array
7814
8655
  /*istanbul ignore end*/
@@ -7819,13 +8660,9 @@
7819
8660
  (myChanges, theirChanges) && skipRemoveSuperset(their, myChanges, myChanges.length - theirChanges.length)) {
7820
8661
  /*istanbul ignore start*/
7821
8662
  var _hunk$lines3;
7822
-
7823
8663
  /*istanbul ignore end*/
7824
-
7825
8664
  /*istanbul ignore start*/
7826
-
7827
8665
  /*istanbul ignore end*/
7828
-
7829
8666
  /*istanbul ignore start*/
7830
8667
  (_hunk$lines3 =
7831
8668
  /*istanbul ignore end*/
@@ -7838,12 +8675,10 @@
7838
8675
  _toConsumableArray(
7839
8676
  /*istanbul ignore end*/
7840
8677
  myChanges));
7841
-
7842
8678
  return;
7843
8679
  } else if (
7844
8680
  /*istanbul ignore start*/
7845
8681
  (/*istanbul ignore end*/
7846
-
7847
8682
  /*istanbul ignore start*/
7848
8683
  0, _array
7849
8684
  /*istanbul ignore end*/
@@ -7854,13 +8689,9 @@
7854
8689
  (theirChanges, myChanges) && skipRemoveSuperset(mine, theirChanges, theirChanges.length - myChanges.length)) {
7855
8690
  /*istanbul ignore start*/
7856
8691
  var _hunk$lines4;
7857
-
7858
8692
  /*istanbul ignore end*/
7859
-
7860
8693
  /*istanbul ignore start*/
7861
-
7862
8694
  /*istanbul ignore end*/
7863
-
7864
8695
  /*istanbul ignore start*/
7865
8696
  (_hunk$lines4 =
7866
8697
  /*istanbul ignore end*/
@@ -7873,13 +8704,11 @@
7873
8704
  _toConsumableArray(
7874
8705
  /*istanbul ignore end*/
7875
8706
  theirChanges));
7876
-
7877
8707
  return;
7878
8708
  }
7879
8709
  } else if (
7880
8710
  /*istanbul ignore start*/
7881
8711
  (/*istanbul ignore end*/
7882
-
7883
8712
  /*istanbul ignore start*/
7884
8713
  0, _array
7885
8714
  /*istanbul ignore end*/
@@ -7890,13 +8719,9 @@
7890
8719
  (myChanges, theirChanges)) {
7891
8720
  /*istanbul ignore start*/
7892
8721
  var _hunk$lines5;
7893
-
7894
8722
  /*istanbul ignore end*/
7895
-
7896
8723
  /*istanbul ignore start*/
7897
-
7898
8724
  /*istanbul ignore end*/
7899
-
7900
8725
  /*istanbul ignore start*/
7901
8726
  (_hunk$lines5 =
7902
8727
  /*istanbul ignore end*/
@@ -7909,27 +8734,19 @@
7909
8734
  _toConsumableArray(
7910
8735
  /*istanbul ignore end*/
7911
8736
  myChanges));
7912
-
7913
8737
  return;
7914
8738
  }
7915
-
7916
8739
  conflict(hunk, myChanges, theirChanges);
7917
8740
  }
7918
-
7919
8741
  function removal(hunk, mine, their, swap) {
7920
8742
  var myChanges = collectChange(mine),
7921
- theirChanges = collectContext(their, myChanges);
7922
-
8743
+ theirChanges = collectContext(their, myChanges);
7923
8744
  if (theirChanges.merged) {
7924
8745
  /*istanbul ignore start*/
7925
8746
  var _hunk$lines6;
7926
-
7927
8747
  /*istanbul ignore end*/
7928
-
7929
8748
  /*istanbul ignore start*/
7930
-
7931
8749
  /*istanbul ignore end*/
7932
-
7933
8750
  /*istanbul ignore start*/
7934
8751
  (_hunk$lines6 =
7935
8752
  /*istanbul ignore end*/
@@ -7946,7 +8763,6 @@
7946
8763
  conflict(hunk, swap ? theirChanges : myChanges, swap ? myChanges : theirChanges);
7947
8764
  }
7948
8765
  }
7949
-
7950
8766
  function conflict(hunk, mine, their) {
7951
8767
  hunk.conflict = true;
7952
8768
  hunk.lines.push({
@@ -7955,7 +8771,6 @@
7955
8771
  theirs: their
7956
8772
  });
7957
8773
  }
7958
-
7959
8774
  function insertLeading(hunk, insert, their) {
7960
8775
  while (insert.offset < their.offset && insert.index < insert.lines.length) {
7961
8776
  var line = insert.lines[insert.index++];
@@ -7963,25 +8778,22 @@
7963
8778
  insert.offset++;
7964
8779
  }
7965
8780
  }
7966
-
7967
8781
  function insertTrailing(hunk, insert) {
7968
8782
  while (insert.index < insert.lines.length) {
7969
8783
  var line = insert.lines[insert.index++];
7970
8784
  hunk.lines.push(line);
7971
8785
  }
7972
8786
  }
7973
-
7974
8787
  function collectChange(state) {
7975
8788
  var ret = [],
7976
- operation = state.lines[state.index][0];
7977
-
8789
+ operation = state.lines[state.index][0];
7978
8790
  while (state.index < state.lines.length) {
7979
- var line = state.lines[state.index]; // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
8791
+ var line = state.lines[state.index];
7980
8792
 
8793
+ // Group additions that are immediately after subtractions and treat them as one "atomic" modify change.
7981
8794
  if (operation === '-' && line[0] === '+') {
7982
8795
  operation = '+';
7983
8796
  }
7984
-
7985
8797
  if (operation === line[0]) {
7986
8798
  ret.push(line);
7987
8799
  state.index++;
@@ -7989,39 +8801,35 @@
7989
8801
  break;
7990
8802
  }
7991
8803
  }
7992
-
7993
8804
  return ret;
7994
8805
  }
7995
-
7996
8806
  function collectContext(state, matchChanges) {
7997
8807
  var changes = [],
7998
- merged = [],
7999
- matchIndex = 0,
8000
- contextChanges = false,
8001
- conflicted = false;
8002
-
8808
+ merged = [],
8809
+ matchIndex = 0,
8810
+ contextChanges = false,
8811
+ conflicted = false;
8003
8812
  while (matchIndex < matchChanges.length && state.index < state.lines.length) {
8004
8813
  var change = state.lines[state.index],
8005
- match = matchChanges[matchIndex]; // Once we've hit our add, then we are done
8814
+ match = matchChanges[matchIndex];
8006
8815
 
8816
+ // Once we've hit our add, then we are done
8007
8817
  if (match[0] === '+') {
8008
8818
  break;
8009
8819
  }
8010
-
8011
8820
  contextChanges = contextChanges || change[0] !== ' ';
8012
8821
  merged.push(match);
8013
- matchIndex++; // Consume any additions in the other block as a conflict to attempt
8014
- // to pull in the remaining context after this
8822
+ matchIndex++;
8015
8823
 
8824
+ // Consume any additions in the other block as a conflict to attempt
8825
+ // to pull in the remaining context after this
8016
8826
  if (change[0] === '+') {
8017
8827
  conflicted = true;
8018
-
8019
8828
  while (change[0] === '+') {
8020
8829
  changes.push(change);
8021
8830
  change = state.lines[++state.index];
8022
8831
  }
8023
8832
  }
8024
-
8025
8833
  if (match.substr(1) === change.substr(1)) {
8026
8834
  changes.push(change);
8027
8835
  state.index++;
@@ -8029,44 +8837,35 @@
8029
8837
  conflicted = true;
8030
8838
  }
8031
8839
  }
8032
-
8033
8840
  if ((matchChanges[matchIndex] || '')[0] === '+' && contextChanges) {
8034
8841
  conflicted = true;
8035
8842
  }
8036
-
8037
8843
  if (conflicted) {
8038
8844
  return changes;
8039
8845
  }
8040
-
8041
8846
  while (matchIndex < matchChanges.length) {
8042
8847
  merged.push(matchChanges[matchIndex++]);
8043
8848
  }
8044
-
8045
8849
  return {
8046
8850
  merged: merged,
8047
8851
  changes: changes
8048
8852
  };
8049
8853
  }
8050
-
8051
8854
  function allRemoves(changes) {
8052
8855
  return changes.reduce(function (prev, change) {
8053
8856
  return prev && change[0] === '-';
8054
8857
  }, true);
8055
8858
  }
8056
-
8057
8859
  function skipRemoveSuperset(state, removeChanges, delta) {
8058
8860
  for (var i = 0; i < delta; i++) {
8059
8861
  var changeContent = removeChanges[removeChanges.length - delta + i].substr(1);
8060
-
8061
8862
  if (state.lines[state.index + i] !== ' ' + changeContent) {
8062
8863
  return false;
8063
8864
  }
8064
8865
  }
8065
-
8066
8866
  state.index += delta;
8067
8867
  return true;
8068
8868
  }
8069
-
8070
8869
  function calcOldNewLineCount(lines) {
8071
8870
  var oldLines = 0;
8072
8871
  var newLines = 0;
@@ -8074,7 +8873,6 @@
8074
8873
  if (typeof line !== 'string') {
8075
8874
  var myCount = calcOldNewLineCount(line.mine);
8076
8875
  var theirCount = calcOldNewLineCount(line.theirs);
8077
-
8078
8876
  if (oldLines !== undefined) {
8079
8877
  if (myCount.oldLines === theirCount.oldLines) {
8080
8878
  oldLines += myCount.oldLines;
@@ -8082,7 +8880,6 @@
8082
8880
  oldLines = undefined;
8083
8881
  }
8084
8882
  }
8085
-
8086
8883
  if (newLines !== undefined) {
8087
8884
  if (myCount.newLines === theirCount.newLines) {
8088
8885
  newLines += myCount.newLines;
@@ -8094,7 +8891,6 @@
8094
8891
  if (newLines !== undefined && (line[0] === '+' || line[0] === ' ')) {
8095
8892
  newLines++;
8096
8893
  }
8097
-
8098
8894
  if (oldLines !== undefined && (line[0] === '-' || line[0] === ' ')) {
8099
8895
  oldLines++;
8100
8896
  }
@@ -8114,19 +8910,17 @@
8114
8910
  value: true
8115
8911
  });
8116
8912
  reverse.reversePatch = reversePatch;
8117
-
8118
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
8119
-
8120
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
8121
-
8122
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8123
-
8913
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8914
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8915
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8916
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8917
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8918
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8124
8919
  /*istanbul ignore end*/
8125
8920
  function reversePatch(structuredPatch) {
8126
8921
  if (Array.isArray(structuredPatch)) {
8127
8922
  return structuredPatch.map(reversePatch).reverse();
8128
8923
  }
8129
-
8130
8924
  return (
8131
8925
  /*istanbul ignore start*/
8132
8926
  _objectSpread(_objectSpread({},
@@ -8142,7 +8936,6 @@
8142
8936
  oldStart: hunk.newStart,
8143
8937
  newLines: hunk.oldLines,
8144
8938
  newStart: hunk.oldStart,
8145
- linedelimiters: hunk.linedelimiters,
8146
8939
  lines: hunk.lines.map(function (l) {
8147
8940
  if (l.startsWith('-')) {
8148
8941
  return (
@@ -8152,7 +8945,6 @@
8152
8945
  l.slice(1))
8153
8946
  );
8154
8947
  }
8155
-
8156
8948
  if (l.startsWith('+')) {
8157
8949
  return (
8158
8950
  /*istanbul ignore start*/
@@ -8161,7 +8953,6 @@
8161
8953
  l.slice(1))
8162
8954
  );
8163
8955
  }
8164
-
8165
8956
  return l;
8166
8957
  })
8167
8958
  };
@@ -8178,17 +8969,14 @@
8178
8969
  value: true
8179
8970
  });
8180
8971
  dmp.convertChangesToDMP = convertChangesToDMP;
8181
-
8182
8972
  /*istanbul ignore end*/
8183
8973
  // See: http://code.google.com/p/google-diff-match-patch/wiki/API
8184
8974
  function convertChangesToDMP(changes) {
8185
8975
  var ret = [],
8186
- change,
8187
- operation;
8188
-
8976
+ change,
8977
+ operation;
8189
8978
  for (var i = 0; i < changes.length; i++) {
8190
8979
  change = changes[i];
8191
-
8192
8980
  if (change.added) {
8193
8981
  operation = 1;
8194
8982
  } else if (change.removed) {
@@ -8196,10 +8984,8 @@
8196
8984
  } else {
8197
8985
  operation = 0;
8198
8986
  }
8199
-
8200
8987
  ret.push([operation, change.value]);
8201
8988
  }
8202
-
8203
8989
  return ret;
8204
8990
  }
8205
8991
 
@@ -8211,32 +8997,25 @@
8211
8997
  value: true
8212
8998
  });
8213
8999
  xml.convertChangesToXML = convertChangesToXML;
8214
-
8215
9000
  /*istanbul ignore end*/
8216
9001
  function convertChangesToXML(changes) {
8217
9002
  var ret = [];
8218
-
8219
9003
  for (var i = 0; i < changes.length; i++) {
8220
9004
  var change = changes[i];
8221
-
8222
9005
  if (change.added) {
8223
9006
  ret.push('<ins>');
8224
9007
  } else if (change.removed) {
8225
9008
  ret.push('<del>');
8226
9009
  }
8227
-
8228
9010
  ret.push(escapeHTML(change.value));
8229
-
8230
9011
  if (change.added) {
8231
9012
  ret.push('</ins>');
8232
9013
  } else if (change.removed) {
8233
9014
  ret.push('</del>');
8234
9015
  }
8235
9016
  }
8236
-
8237
9017
  return ret.join('');
8238
9018
  }
8239
-
8240
9019
  function escapeHTML(s) {
8241
9020
  var n = s;
8242
9021
  n = n.replace(/&/g, '&amp;');
@@ -8259,226 +9038,209 @@
8259
9038
  return _base["default"];
8260
9039
  }
8261
9040
  });
8262
- Object.defineProperty(exports, "diffChars", {
9041
+ Object.defineProperty(exports, "applyPatch", {
8263
9042
  enumerable: true,
8264
9043
  get: function get() {
8265
- return _character.diffChars;
9044
+ return _apply.applyPatch;
8266
9045
  }
8267
9046
  });
8268
- Object.defineProperty(exports, "diffWords", {
9047
+ Object.defineProperty(exports, "applyPatches", {
8269
9048
  enumerable: true,
8270
9049
  get: function get() {
8271
- return _word.diffWords;
9050
+ return _apply.applyPatches;
8272
9051
  }
8273
9052
  });
8274
- Object.defineProperty(exports, "diffWordsWithSpace", {
9053
+ Object.defineProperty(exports, "canonicalize", {
8275
9054
  enumerable: true,
8276
9055
  get: function get() {
8277
- return _word.diffWordsWithSpace;
9056
+ return _json.canonicalize;
8278
9057
  }
8279
9058
  });
8280
- Object.defineProperty(exports, "diffLines", {
9059
+ Object.defineProperty(exports, "convertChangesToDMP", {
8281
9060
  enumerable: true,
8282
9061
  get: function get() {
8283
- return _line.diffLines;
9062
+ return _dmp.convertChangesToDMP;
8284
9063
  }
8285
9064
  });
8286
- Object.defineProperty(exports, "diffTrimmedLines", {
9065
+ Object.defineProperty(exports, "convertChangesToXML", {
8287
9066
  enumerable: true,
8288
9067
  get: function get() {
8289
- return _line.diffTrimmedLines;
9068
+ return _xml.convertChangesToXML;
8290
9069
  }
8291
9070
  });
8292
- Object.defineProperty(exports, "diffSentences", {
9071
+ Object.defineProperty(exports, "createPatch", {
8293
9072
  enumerable: true,
8294
9073
  get: function get() {
8295
- return _sentence.diffSentences;
9074
+ return _create.createPatch;
8296
9075
  }
8297
9076
  });
8298
- Object.defineProperty(exports, "diffCss", {
9077
+ Object.defineProperty(exports, "createTwoFilesPatch", {
8299
9078
  enumerable: true,
8300
9079
  get: function get() {
8301
- return _css.diffCss;
9080
+ return _create.createTwoFilesPatch;
8302
9081
  }
8303
9082
  });
8304
- Object.defineProperty(exports, "diffJson", {
9083
+ Object.defineProperty(exports, "diffArrays", {
8305
9084
  enumerable: true,
8306
9085
  get: function get() {
8307
- return _json.diffJson;
9086
+ return _array.diffArrays;
8308
9087
  }
8309
9088
  });
8310
- Object.defineProperty(exports, "canonicalize", {
9089
+ Object.defineProperty(exports, "diffChars", {
8311
9090
  enumerable: true,
8312
9091
  get: function get() {
8313
- return _json.canonicalize;
9092
+ return _character.diffChars;
8314
9093
  }
8315
9094
  });
8316
- Object.defineProperty(exports, "diffArrays", {
9095
+ Object.defineProperty(exports, "diffCss", {
8317
9096
  enumerable: true,
8318
9097
  get: function get() {
8319
- return _array.diffArrays;
9098
+ return _css.diffCss;
8320
9099
  }
8321
9100
  });
8322
- Object.defineProperty(exports, "applyPatch", {
9101
+ Object.defineProperty(exports, "diffJson", {
8323
9102
  enumerable: true,
8324
9103
  get: function get() {
8325
- return _apply.applyPatch;
9104
+ return _json.diffJson;
8326
9105
  }
8327
9106
  });
8328
- Object.defineProperty(exports, "applyPatches", {
9107
+ Object.defineProperty(exports, "diffLines", {
8329
9108
  enumerable: true,
8330
9109
  get: function get() {
8331
- return _apply.applyPatches;
9110
+ return _line.diffLines;
8332
9111
  }
8333
9112
  });
8334
- Object.defineProperty(exports, "parsePatch", {
9113
+ Object.defineProperty(exports, "diffSentences", {
8335
9114
  enumerable: true,
8336
9115
  get: function get() {
8337
- return _parse.parsePatch;
9116
+ return _sentence.diffSentences;
8338
9117
  }
8339
9118
  });
8340
- Object.defineProperty(exports, "merge", {
9119
+ Object.defineProperty(exports, "diffTrimmedLines", {
8341
9120
  enumerable: true,
8342
9121
  get: function get() {
8343
- return _merge.merge;
9122
+ return _line.diffTrimmedLines;
8344
9123
  }
8345
9124
  });
8346
- Object.defineProperty(exports, "reversePatch", {
9125
+ Object.defineProperty(exports, "diffWords", {
8347
9126
  enumerable: true,
8348
9127
  get: function get() {
8349
- return _reverse.reversePatch;
9128
+ return _word.diffWords;
8350
9129
  }
8351
9130
  });
8352
- Object.defineProperty(exports, "structuredPatch", {
9131
+ Object.defineProperty(exports, "diffWordsWithSpace", {
8353
9132
  enumerable: true,
8354
9133
  get: function get() {
8355
- return _create.structuredPatch;
9134
+ return _word.diffWordsWithSpace;
8356
9135
  }
8357
9136
  });
8358
- Object.defineProperty(exports, "createTwoFilesPatch", {
9137
+ Object.defineProperty(exports, "formatPatch", {
8359
9138
  enumerable: true,
8360
9139
  get: function get() {
8361
- return _create.createTwoFilesPatch;
9140
+ return _create.formatPatch;
8362
9141
  }
8363
9142
  });
8364
- Object.defineProperty(exports, "createPatch", {
9143
+ Object.defineProperty(exports, "merge", {
8365
9144
  enumerable: true,
8366
9145
  get: function get() {
8367
- return _create.createPatch;
9146
+ return _merge.merge;
8368
9147
  }
8369
9148
  });
8370
- Object.defineProperty(exports, "formatPatch", {
9149
+ Object.defineProperty(exports, "parsePatch", {
8371
9150
  enumerable: true,
8372
9151
  get: function get() {
8373
- return _create.formatPatch;
9152
+ return _parse.parsePatch;
8374
9153
  }
8375
9154
  });
8376
- Object.defineProperty(exports, "convertChangesToDMP", {
9155
+ Object.defineProperty(exports, "reversePatch", {
8377
9156
  enumerable: true,
8378
9157
  get: function get() {
8379
- return _dmp.convertChangesToDMP;
9158
+ return _reverse.reversePatch;
8380
9159
  }
8381
9160
  });
8382
- Object.defineProperty(exports, "convertChangesToXML", {
9161
+ Object.defineProperty(exports, "structuredPatch", {
8383
9162
  enumerable: true,
8384
9163
  get: function get() {
8385
- return _xml.convertChangesToXML;
9164
+ return _create.structuredPatch;
8386
9165
  }
8387
9166
  });
8388
-
8389
9167
  /*istanbul ignore end*/
8390
9168
  var
8391
9169
  /*istanbul ignore start*/
8392
9170
  _base = _interopRequireDefault(base)
8393
9171
  /*istanbul ignore end*/
8394
9172
  ;
8395
-
8396
9173
  var
8397
9174
  /*istanbul ignore start*/
8398
9175
  _character = character
8399
9176
  /*istanbul ignore end*/
8400
9177
  ;
8401
-
8402
9178
  var
8403
9179
  /*istanbul ignore start*/
8404
9180
  _word = word
8405
9181
  /*istanbul ignore end*/
8406
9182
  ;
8407
-
8408
9183
  var
8409
9184
  /*istanbul ignore start*/
8410
9185
  _line = line
8411
9186
  /*istanbul ignore end*/
8412
9187
  ;
8413
-
8414
9188
  var
8415
9189
  /*istanbul ignore start*/
8416
9190
  _sentence = sentence
8417
9191
  /*istanbul ignore end*/
8418
9192
  ;
8419
-
8420
9193
  var
8421
9194
  /*istanbul ignore start*/
8422
9195
  _css = css
8423
9196
  /*istanbul ignore end*/
8424
9197
  ;
8425
-
8426
9198
  var
8427
9199
  /*istanbul ignore start*/
8428
9200
  _json = json$1
8429
9201
  /*istanbul ignore end*/
8430
9202
  ;
8431
-
8432
9203
  var
8433
9204
  /*istanbul ignore start*/
8434
9205
  _array = array$1
8435
9206
  /*istanbul ignore end*/
8436
9207
  ;
8437
-
8438
9208
  var
8439
9209
  /*istanbul ignore start*/
8440
9210
  _apply = apply
8441
9211
  /*istanbul ignore end*/
8442
9212
  ;
8443
-
8444
9213
  var
8445
9214
  /*istanbul ignore start*/
8446
9215
  _parse = parse$2
8447
9216
  /*istanbul ignore end*/
8448
9217
  ;
8449
-
8450
9218
  var
8451
9219
  /*istanbul ignore start*/
8452
9220
  _merge = merge$1
8453
9221
  /*istanbul ignore end*/
8454
9222
  ;
8455
-
8456
9223
  var
8457
9224
  /*istanbul ignore start*/
8458
9225
  _reverse = reverse
8459
9226
  /*istanbul ignore end*/
8460
9227
  ;
8461
-
8462
9228
  var
8463
9229
  /*istanbul ignore start*/
8464
9230
  _create = create
8465
9231
  /*istanbul ignore end*/
8466
9232
  ;
8467
-
8468
9233
  var
8469
9234
  /*istanbul ignore start*/
8470
9235
  _dmp = dmp
8471
9236
  /*istanbul ignore end*/
8472
9237
  ;
8473
-
8474
9238
  var
8475
9239
  /*istanbul ignore start*/
8476
9240
  _xml = xml
8477
9241
  /*istanbul ignore end*/
8478
9242
  ;
8479
-
8480
9243
  /*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8481
-
8482
9244
  /*istanbul ignore end*/
8483
9245
 
8484
9246
  }(lib));
@@ -19256,7 +20018,7 @@
19256
20018
  };
19257
20019
 
19258
20020
  var name = "mocha";
19259
- var version = "11.3.0";
20021
+ var version = "11.5.0";
19260
20022
  var homepage = "https://mochajs.org/";
19261
20023
  var notifyLogo = "https://ibin.co/4QuRuGjXvl36.png";
19262
20024
  var require$$17 = {