@forsakringskassan/docs-generator 2.27.2 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{create-markdown-renderer-YqKvt1km.mjs → create-markdown-renderer-CWekmBMu.mjs} +16 -6
- package/dist/create-markdown-renderer-CWekmBMu.mjs.map +1 -0
- package/dist/index.mjs +3 -3
- package/dist/markdown.mjs +3 -3
- package/dist/{vendor-DmS_A2Yc.mjs → vendor-DxEOke6B.mjs} +1085 -942
- package/dist/vendor-DxEOke6B.mjs.map +1 -0
- package/dist/{vue3-B3wFqisN.mjs → vue3-CwePPTYz.mjs} +2 -2
- package/dist/{vue3-B3wFqisN.mjs.map → vue3-CwePPTYz.mjs.map} +1 -1
- package/dist/{worker-CsTO-ve1.mjs → worker-BqgLhl2f.mjs} +3 -3
- package/dist/{worker-CsTO-ve1.mjs.map → worker-BqgLhl2f.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/create-markdown-renderer-YqKvt1km.mjs.map +0 -1
- package/dist/vendor-DmS_A2Yc.mjs.map +0 -1
|
@@ -16325,11 +16325,11 @@ function requireRegisterTs () {
|
|
|
16325
16325
|
|
|
16326
16326
|
requireRegisterTs();
|
|
16327
16327
|
|
|
16328
|
-
function ownKeys
|
|
16329
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys
|
|
16330
|
-
function _defineProperty
|
|
16331
|
-
function _toPropertyKey
|
|
16332
|
-
function _toPrimitive
|
|
16328
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16329
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16330
|
+
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; }
|
|
16331
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
16332
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16333
16333
|
const dedent = createDedent({});
|
|
16334
16334
|
function createDedent(options) {
|
|
16335
16335
|
dedent.withOptions = newOptions => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
|
|
@@ -28558,366 +28558,425 @@ function deflist_plugin (md) {
|
|
|
28558
28558
|
md.block.ruler.before('paragraph', 'deflist', deflist, { alt: ['paragraph', 'reference', 'blockquote'] });
|
|
28559
28559
|
}
|
|
28560
28560
|
|
|
28561
|
-
|
|
28562
|
-
Diff
|
|
28563
|
-
diff: function diff(oldString, newString) {
|
|
28564
|
-
var _options$timeout;
|
|
28565
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
28566
|
-
var callback = options.callback;
|
|
28567
|
-
if (typeof options === 'function') {
|
|
28568
|
-
callback = options;
|
|
28569
|
-
options = {};
|
|
28570
|
-
}
|
|
28571
|
-
var self = this;
|
|
28572
|
-
function done(value) {
|
|
28573
|
-
value = self.postProcess(value, options);
|
|
28574
|
-
if (callback) {
|
|
28575
|
-
setTimeout(function () {
|
|
28576
|
-
callback(value);
|
|
28577
|
-
}, 0);
|
|
28578
|
-
return true;
|
|
28579
|
-
} else {
|
|
28580
|
-
return value;
|
|
28581
|
-
}
|
|
28561
|
+
var Diff = /** @class */ (function () {
|
|
28562
|
+
function Diff() {
|
|
28582
28563
|
}
|
|
28583
|
-
|
|
28584
|
-
//
|
|
28585
|
-
|
|
28586
|
-
|
|
28587
|
-
|
|
28588
|
-
|
|
28589
|
-
|
|
28590
|
-
|
|
28591
|
-
var editLength = 1;
|
|
28592
|
-
var maxEditLength = newLen + oldLen;
|
|
28593
|
-
if (options.maxEditLength != null) {
|
|
28594
|
-
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
28595
|
-
}
|
|
28596
|
-
var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity;
|
|
28597
|
-
var abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
28598
|
-
var bestPath = [{
|
|
28599
|
-
oldPos: -1,
|
|
28600
|
-
lastComponent: undefined
|
|
28601
|
-
}];
|
|
28602
|
-
|
|
28603
|
-
// Seed editLength = 0, i.e. the content starts with the same values
|
|
28604
|
-
var newPos = this.extractCommon(bestPath[0], newString, oldString, 0, options);
|
|
28605
|
-
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
28606
|
-
// Identity per the equality and tokenizer
|
|
28607
|
-
return done(buildValues(self, bestPath[0].lastComponent, newString, oldString, self.useLongestToken));
|
|
28608
|
-
}
|
|
28609
|
-
|
|
28610
|
-
// Once we hit the right edge of the edit graph on some diagonal k, we can
|
|
28611
|
-
// definitely reach the end of the edit graph in no more than k edits, so
|
|
28612
|
-
// there's no point in considering any moves to diagonal k+1 any more (from
|
|
28613
|
-
// which we're guaranteed to need at least k+1 more edits).
|
|
28614
|
-
// Similarly, once we've reached the bottom of the edit graph, there's no
|
|
28615
|
-
// point considering moves to lower diagonals.
|
|
28616
|
-
// We record this fact by setting minDiagonalToConsider and
|
|
28617
|
-
// maxDiagonalToConsider to some finite value once we've hit the edge of
|
|
28618
|
-
// the edit graph.
|
|
28619
|
-
// This optimization is not faithful to the original algorithm presented in
|
|
28620
|
-
// Myers's paper, which instead pointlessly extends D-paths off the end of
|
|
28621
|
-
// the edit graph - see page 7 of Myers's paper which notes this point
|
|
28622
|
-
// explicitly and illustrates it with a diagram. This has major performance
|
|
28623
|
-
// implications for some common scenarios. For instance, to compute a diff
|
|
28624
|
-
// where the new text simply appends d characters on the end of the
|
|
28625
|
-
// original text of length n, the true Myers algorithm will take O(n+d^2)
|
|
28626
|
-
// time while this optimization needs only O(n+d) time.
|
|
28627
|
-
var minDiagonalToConsider = -Infinity,
|
|
28628
|
-
maxDiagonalToConsider = Infinity;
|
|
28629
|
-
|
|
28630
|
-
// Main worker method. checks all permutations of a given edit length for acceptance.
|
|
28631
|
-
function execEditLength() {
|
|
28632
|
-
for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
28633
|
-
var basePath = void 0;
|
|
28634
|
-
var removePath = bestPath[diagonalPath - 1],
|
|
28635
|
-
addPath = bestPath[diagonalPath + 1];
|
|
28636
|
-
if (removePath) {
|
|
28637
|
-
// No one else is going to attempt to use this value, clear it
|
|
28638
|
-
bestPath[diagonalPath - 1] = undefined;
|
|
28639
|
-
}
|
|
28640
|
-
var canAdd = false;
|
|
28641
|
-
if (addPath) {
|
|
28642
|
-
// what newPos will be after we do an insertion:
|
|
28643
|
-
var addPathNewPos = addPath.oldPos - diagonalPath;
|
|
28644
|
-
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
28645
|
-
}
|
|
28646
|
-
var canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
28647
|
-
if (!canAdd && !canRemove) {
|
|
28648
|
-
// If this path is a terminal then prune
|
|
28649
|
-
bestPath[diagonalPath] = undefined;
|
|
28650
|
-
continue;
|
|
28564
|
+
Diff.prototype.diff = function (oldString, newString,
|
|
28565
|
+
// Type below is not accurate/complete - see above for full possibilities - but it compiles
|
|
28566
|
+
options) {
|
|
28567
|
+
if (options === void 0) { options = {}; }
|
|
28568
|
+
var callback;
|
|
28569
|
+
if (typeof options === 'function') {
|
|
28570
|
+
callback = options;
|
|
28571
|
+
options = {};
|
|
28651
28572
|
}
|
|
28652
|
-
|
|
28653
|
-
|
|
28654
|
-
// path whose position in the old string is the farthest from the origin
|
|
28655
|
-
// and does not pass the bounds of the diff graph
|
|
28656
|
-
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
28657
|
-
basePath = self.addToPath(addPath, true, false, 0, options);
|
|
28658
|
-
} else {
|
|
28659
|
-
basePath = self.addToPath(removePath, false, true, 1, options);
|
|
28573
|
+
else if ('callback' in options) {
|
|
28574
|
+
callback = options.callback;
|
|
28660
28575
|
}
|
|
28661
|
-
|
|
28662
|
-
|
|
28663
|
-
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
|
|
28667
|
-
|
|
28668
|
-
|
|
28669
|
-
|
|
28670
|
-
|
|
28671
|
-
|
|
28672
|
-
|
|
28576
|
+
// Allow subclasses to massage the input prior to running
|
|
28577
|
+
oldString = this.castInput(oldString, options);
|
|
28578
|
+
newString = this.castInput(newString, options);
|
|
28579
|
+
var oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
28580
|
+
var newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
28581
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
28582
|
+
};
|
|
28583
|
+
Diff.prototype.diffWithOptionsObj = function (oldTokens, newTokens, options, callback) {
|
|
28584
|
+
var _this = this;
|
|
28585
|
+
var _a;
|
|
28586
|
+
var done = function (value) {
|
|
28587
|
+
value = _this.postProcess(value, options);
|
|
28588
|
+
if (callback) {
|
|
28589
|
+
setTimeout(function () { callback(value); }, 0);
|
|
28590
|
+
return undefined;
|
|
28591
|
+
}
|
|
28592
|
+
else {
|
|
28593
|
+
return value;
|
|
28594
|
+
}
|
|
28595
|
+
};
|
|
28596
|
+
var newLen = newTokens.length, oldLen = oldTokens.length;
|
|
28597
|
+
var editLength = 1;
|
|
28598
|
+
var maxEditLength = newLen + oldLen;
|
|
28599
|
+
if (options.maxEditLength != null) {
|
|
28600
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
28601
|
+
}
|
|
28602
|
+
var maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
28603
|
+
var abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
28604
|
+
var bestPath = [{ oldPos: -1, lastComponent: undefined }];
|
|
28605
|
+
// Seed editLength = 0, i.e. the content starts with the same values
|
|
28606
|
+
var newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
28607
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
28608
|
+
// Identity per the equality and tokenizer
|
|
28609
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
28610
|
+
}
|
|
28611
|
+
// Once we hit the right edge of the edit graph on some diagonal k, we can
|
|
28612
|
+
// definitely reach the end of the edit graph in no more than k edits, so
|
|
28613
|
+
// there's no point in considering any moves to diagonal k+1 any more (from
|
|
28614
|
+
// which we're guaranteed to need at least k+1 more edits).
|
|
28615
|
+
// Similarly, once we've reached the bottom of the edit graph, there's no
|
|
28616
|
+
// point considering moves to lower diagonals.
|
|
28617
|
+
// We record this fact by setting minDiagonalToConsider and
|
|
28618
|
+
// maxDiagonalToConsider to some finite value once we've hit the edge of
|
|
28619
|
+
// the edit graph.
|
|
28620
|
+
// This optimization is not faithful to the original algorithm presented in
|
|
28621
|
+
// Myers's paper, which instead pointlessly extends D-paths off the end of
|
|
28622
|
+
// the edit graph - see page 7 of Myers's paper which notes this point
|
|
28623
|
+
// explicitly and illustrates it with a diagram. This has major performance
|
|
28624
|
+
// implications for some common scenarios. For instance, to compute a diff
|
|
28625
|
+
// where the new text simply appends d characters on the end of the
|
|
28626
|
+
// original text of length n, the true Myers algorithm will take O(n+d^2)
|
|
28627
|
+
// time while this optimization needs only O(n+d) time.
|
|
28628
|
+
var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
28629
|
+
// Main worker method. checks all permutations of a given edit length for acceptance.
|
|
28630
|
+
var execEditLength = function () {
|
|
28631
|
+
for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
28632
|
+
var basePath = void 0;
|
|
28633
|
+
var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
28634
|
+
if (removePath) {
|
|
28635
|
+
// No one else is going to attempt to use this value, clear it
|
|
28636
|
+
// @ts-expect-error - perf optimisation. This type-violating value will never be read.
|
|
28637
|
+
bestPath[diagonalPath - 1] = undefined;
|
|
28638
|
+
}
|
|
28639
|
+
var canAdd = false;
|
|
28640
|
+
if (addPath) {
|
|
28641
|
+
// what newPos will be after we do an insertion:
|
|
28642
|
+
var addPathNewPos = addPath.oldPos - diagonalPath;
|
|
28643
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
28644
|
+
}
|
|
28645
|
+
var canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
28646
|
+
if (!canAdd && !canRemove) {
|
|
28647
|
+
// If this path is a terminal then prune
|
|
28648
|
+
// @ts-expect-error - perf optimisation. This type-violating value will never be read.
|
|
28649
|
+
bestPath[diagonalPath] = undefined;
|
|
28650
|
+
continue;
|
|
28651
|
+
}
|
|
28652
|
+
// Select the diagonal that we want to branch from. We select the prior
|
|
28653
|
+
// path whose position in the old string is the farthest from the origin
|
|
28654
|
+
// and does not pass the bounds of the diff graph
|
|
28655
|
+
if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {
|
|
28656
|
+
basePath = _this.addToPath(addPath, true, false, 0, options);
|
|
28657
|
+
}
|
|
28658
|
+
else {
|
|
28659
|
+
basePath = _this.addToPath(removePath, false, true, 1, options);
|
|
28660
|
+
}
|
|
28661
|
+
newPos = _this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
28662
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
28663
|
+
// If we have hit the end of both strings, then we are done
|
|
28664
|
+
return done(_this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
28665
|
+
}
|
|
28666
|
+
else {
|
|
28667
|
+
bestPath[diagonalPath] = basePath;
|
|
28668
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
28669
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
28670
|
+
}
|
|
28671
|
+
if (newPos + 1 >= newLen) {
|
|
28672
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
28673
|
+
}
|
|
28674
|
+
}
|
|
28675
|
+
}
|
|
28676
|
+
editLength++;
|
|
28677
|
+
};
|
|
28678
|
+
// Performs the length of edit iteration. Is a bit fugly as this has to support the
|
|
28679
|
+
// sync and async mode which is never fun. Loops over execEditLength until a value
|
|
28680
|
+
// is produced, or until the edit length exceeds options.maxEditLength (if given),
|
|
28681
|
+
// in which case it will return undefined.
|
|
28682
|
+
if (callback) {
|
|
28683
|
+
(function exec() {
|
|
28684
|
+
setTimeout(function () {
|
|
28685
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
28686
|
+
return callback(undefined);
|
|
28687
|
+
}
|
|
28688
|
+
if (!execEditLength()) {
|
|
28689
|
+
exec();
|
|
28690
|
+
}
|
|
28691
|
+
}, 0);
|
|
28692
|
+
}());
|
|
28673
28693
|
}
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
// in which case it will return undefined.
|
|
28682
|
-
if (callback) {
|
|
28683
|
-
(function exec() {
|
|
28684
|
-
setTimeout(function () {
|
|
28685
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
28686
|
-
return callback();
|
|
28687
|
-
}
|
|
28688
|
-
if (!execEditLength()) {
|
|
28689
|
-
exec();
|
|
28690
|
-
}
|
|
28691
|
-
}, 0);
|
|
28692
|
-
})();
|
|
28693
|
-
} else {
|
|
28694
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
28695
|
-
var ret = execEditLength();
|
|
28696
|
-
if (ret) {
|
|
28697
|
-
return ret;
|
|
28694
|
+
else {
|
|
28695
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
28696
|
+
var ret = execEditLength();
|
|
28697
|
+
if (ret) {
|
|
28698
|
+
return ret;
|
|
28699
|
+
}
|
|
28700
|
+
}
|
|
28698
28701
|
}
|
|
28699
|
-
|
|
28700
|
-
|
|
28701
|
-
|
|
28702
|
-
|
|
28703
|
-
|
|
28704
|
-
|
|
28705
|
-
|
|
28706
|
-
|
|
28707
|
-
lastComponent: {
|
|
28708
|
-
count: last.count + 1,
|
|
28709
|
-
added: added,
|
|
28710
|
-
removed: removed,
|
|
28711
|
-
previousComponent: last.previousComponent
|
|
28702
|
+
};
|
|
28703
|
+
Diff.prototype.addToPath = function (path, added, removed, oldPosInc, options) {
|
|
28704
|
+
var last = path.lastComponent;
|
|
28705
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
28706
|
+
return {
|
|
28707
|
+
oldPos: path.oldPos + oldPosInc,
|
|
28708
|
+
lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }
|
|
28709
|
+
};
|
|
28712
28710
|
}
|
|
28713
|
-
|
|
28714
|
-
|
|
28715
|
-
|
|
28716
|
-
|
|
28717
|
-
|
|
28718
|
-
count: 1,
|
|
28719
|
-
added: added,
|
|
28720
|
-
removed: removed,
|
|
28721
|
-
previousComponent: last
|
|
28711
|
+
else {
|
|
28712
|
+
return {
|
|
28713
|
+
oldPos: path.oldPos + oldPosInc,
|
|
28714
|
+
lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }
|
|
28715
|
+
};
|
|
28722
28716
|
}
|
|
28723
|
-
|
|
28724
|
-
|
|
28725
|
-
|
|
28726
|
-
|
|
28727
|
-
|
|
28728
|
-
|
|
28729
|
-
|
|
28730
|
-
|
|
28731
|
-
|
|
28732
|
-
|
|
28733
|
-
|
|
28734
|
-
|
|
28735
|
-
|
|
28736
|
-
|
|
28737
|
-
|
|
28738
|
-
|
|
28739
|
-
|
|
28740
|
-
|
|
28741
|
-
|
|
28742
|
-
|
|
28743
|
-
|
|
28744
|
-
|
|
28745
|
-
|
|
28746
|
-
|
|
28747
|
-
|
|
28748
|
-
|
|
28749
|
-
|
|
28750
|
-
|
|
28751
|
-
|
|
28752
|
-
|
|
28753
|
-
|
|
28754
|
-
|
|
28755
|
-
|
|
28756
|
-
|
|
28757
|
-
|
|
28758
|
-
|
|
28759
|
-
|
|
28760
|
-
|
|
28761
|
-
|
|
28762
|
-
|
|
28763
|
-
|
|
28764
|
-
|
|
28765
|
-
|
|
28766
|
-
|
|
28767
|
-
|
|
28768
|
-
|
|
28769
|
-
|
|
28770
|
-
|
|
28771
|
-
|
|
28772
|
-
|
|
28773
|
-
|
|
28774
|
-
|
|
28775
|
-
|
|
28776
|
-
|
|
28777
|
-
|
|
28778
|
-
|
|
28779
|
-
|
|
28780
|
-
|
|
28781
|
-
|
|
28782
|
-
|
|
28783
|
-
|
|
28784
|
-
|
|
28785
|
-
|
|
28786
|
-
|
|
28787
|
-
|
|
28788
|
-
|
|
28789
|
-
|
|
28790
|
-
|
|
28791
|
-
|
|
28792
|
-
|
|
28793
|
-
|
|
28794
|
-
|
|
28795
|
-
|
|
28796
|
-
|
|
28797
|
-
|
|
28798
|
-
|
|
28799
|
-
|
|
28800
|
-
|
|
28801
|
-
|
|
28802
|
-
|
|
28803
|
-
|
|
28804
|
-
|
|
28805
|
-
|
|
28806
|
-
|
|
28807
|
-
|
|
28808
|
-
|
|
28809
|
-
|
|
28810
|
-
|
|
28811
|
-
|
|
28812
|
-
|
|
28813
|
-
|
|
28814
|
-
|
|
28815
|
-
|
|
28816
|
-
|
|
28817
|
-
|
|
28818
|
-
|
|
28819
|
-
|
|
28820
|
-
|
|
28821
|
-
|
|
28822
|
-
|
|
28717
|
+
};
|
|
28718
|
+
Diff.prototype.extractCommon = function (basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
28719
|
+
var newLen = newTokens.length, oldLen = oldTokens.length;
|
|
28720
|
+
var oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
28721
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
28722
|
+
newPos++;
|
|
28723
|
+
oldPos++;
|
|
28724
|
+
commonCount++;
|
|
28725
|
+
if (options.oneChangePerToken) {
|
|
28726
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
28727
|
+
}
|
|
28728
|
+
}
|
|
28729
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
28730
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
28731
|
+
}
|
|
28732
|
+
basePath.oldPos = oldPos;
|
|
28733
|
+
return newPos;
|
|
28734
|
+
};
|
|
28735
|
+
Diff.prototype.equals = function (left, right, options) {
|
|
28736
|
+
if (options.comparator) {
|
|
28737
|
+
return options.comparator(left, right);
|
|
28738
|
+
}
|
|
28739
|
+
else {
|
|
28740
|
+
return left === right
|
|
28741
|
+
|| (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());
|
|
28742
|
+
}
|
|
28743
|
+
};
|
|
28744
|
+
Diff.prototype.removeEmpty = function (array) {
|
|
28745
|
+
var ret = [];
|
|
28746
|
+
for (var i = 0; i < array.length; i++) {
|
|
28747
|
+
if (array[i]) {
|
|
28748
|
+
ret.push(array[i]);
|
|
28749
|
+
}
|
|
28750
|
+
}
|
|
28751
|
+
return ret;
|
|
28752
|
+
};
|
|
28753
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28754
|
+
Diff.prototype.castInput = function (value, options) {
|
|
28755
|
+
return value;
|
|
28756
|
+
};
|
|
28757
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28758
|
+
Diff.prototype.tokenize = function (value, options) {
|
|
28759
|
+
return Array.from(value);
|
|
28760
|
+
};
|
|
28761
|
+
Diff.prototype.join = function (chars) {
|
|
28762
|
+
// Assumes ValueT is string, which is the case for most subclasses.
|
|
28763
|
+
// When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)
|
|
28764
|
+
// Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF
|
|
28765
|
+
// assume tokens and values are strings, but not completely - is weird and janky.
|
|
28766
|
+
return chars.join('');
|
|
28767
|
+
};
|
|
28768
|
+
Diff.prototype.postProcess = function (changeObjects,
|
|
28769
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28770
|
+
options) {
|
|
28771
|
+
return changeObjects;
|
|
28772
|
+
};
|
|
28773
|
+
Object.defineProperty(Diff.prototype, "useLongestToken", {
|
|
28774
|
+
get: function () {
|
|
28775
|
+
return false;
|
|
28776
|
+
},
|
|
28777
|
+
enumerable: false,
|
|
28778
|
+
configurable: true
|
|
28779
|
+
});
|
|
28780
|
+
Diff.prototype.buildValues = function (lastComponent, newTokens, oldTokens) {
|
|
28781
|
+
// First we convert our linked list of components in reverse order to an
|
|
28782
|
+
// array in the right order:
|
|
28783
|
+
var components = [];
|
|
28784
|
+
var nextComponent;
|
|
28785
|
+
while (lastComponent) {
|
|
28786
|
+
components.push(lastComponent);
|
|
28787
|
+
nextComponent = lastComponent.previousComponent;
|
|
28788
|
+
delete lastComponent.previousComponent;
|
|
28789
|
+
lastComponent = nextComponent;
|
|
28790
|
+
}
|
|
28791
|
+
components.reverse();
|
|
28792
|
+
var componentLen = components.length;
|
|
28793
|
+
var componentPos = 0, newPos = 0, oldPos = 0;
|
|
28794
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
28795
|
+
var component = components[componentPos];
|
|
28796
|
+
if (!component.removed) {
|
|
28797
|
+
if (!component.added && this.useLongestToken) {
|
|
28798
|
+
var value = newTokens.slice(newPos, newPos + component.count);
|
|
28799
|
+
value = value.map(function (value, i) {
|
|
28800
|
+
var oldValue = oldTokens[oldPos + i];
|
|
28801
|
+
return oldValue.length > value.length ? oldValue : value;
|
|
28802
|
+
});
|
|
28803
|
+
component.value = this.join(value);
|
|
28804
|
+
}
|
|
28805
|
+
else {
|
|
28806
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
28807
|
+
}
|
|
28808
|
+
newPos += component.count;
|
|
28809
|
+
// Common case
|
|
28810
|
+
if (!component.added) {
|
|
28811
|
+
oldPos += component.count;
|
|
28812
|
+
}
|
|
28813
|
+
}
|
|
28814
|
+
else {
|
|
28815
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
28816
|
+
oldPos += component.count;
|
|
28817
|
+
}
|
|
28818
|
+
}
|
|
28819
|
+
return components;
|
|
28820
|
+
};
|
|
28821
|
+
return Diff;
|
|
28822
|
+
}());
|
|
28823
|
+
|
|
28824
|
+
var __extends$6 = (undefined && undefined.__extends) || (function () {
|
|
28825
|
+
var extendStatics = function (d, b) {
|
|
28826
|
+
extendStatics = Object.setPrototypeOf ||
|
|
28827
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
28828
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
28829
|
+
return extendStatics(d, b);
|
|
28830
|
+
};
|
|
28831
|
+
return function (d, b) {
|
|
28832
|
+
if (typeof b !== "function" && b !== null)
|
|
28833
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
28834
|
+
extendStatics(d, b);
|
|
28835
|
+
function __() { this.constructor = d; }
|
|
28836
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
28837
|
+
};
|
|
28838
|
+
})();
|
|
28839
|
+
var CharacterDiff = /** @class */ (function (_super) {
|
|
28840
|
+
__extends$6(CharacterDiff, _super);
|
|
28841
|
+
function CharacterDiff() {
|
|
28842
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
28823
28843
|
}
|
|
28824
|
-
|
|
28825
|
-
|
|
28826
|
-
|
|
28844
|
+
return CharacterDiff;
|
|
28845
|
+
}(Diff));
|
|
28846
|
+
new CharacterDiff();
|
|
28827
28847
|
|
|
28828
28848
|
function longestCommonPrefix(str1, str2) {
|
|
28829
|
-
|
|
28830
|
-
|
|
28831
|
-
|
|
28832
|
-
|
|
28849
|
+
var i;
|
|
28850
|
+
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
28851
|
+
if (str1[i] != str2[i]) {
|
|
28852
|
+
return str1.slice(0, i);
|
|
28853
|
+
}
|
|
28833
28854
|
}
|
|
28834
|
-
|
|
28835
|
-
return str1.slice(0, i);
|
|
28855
|
+
return str1.slice(0, i);
|
|
28836
28856
|
}
|
|
28837
28857
|
function longestCommonSuffix(str1, str2) {
|
|
28838
|
-
|
|
28839
|
-
|
|
28840
|
-
|
|
28841
|
-
|
|
28842
|
-
|
|
28843
|
-
|
|
28844
|
-
return '';
|
|
28845
|
-
}
|
|
28846
|
-
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
28847
|
-
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
28848
|
-
return str1.slice(-i);
|
|
28858
|
+
var i;
|
|
28859
|
+
// Unlike longestCommonPrefix, we need a special case to handle all scenarios
|
|
28860
|
+
// where we return the empty string since str1.slice(-0) will return the
|
|
28861
|
+
// entire string.
|
|
28862
|
+
if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
|
|
28863
|
+
return '';
|
|
28849
28864
|
}
|
|
28850
|
-
|
|
28851
|
-
|
|
28865
|
+
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
28866
|
+
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
28867
|
+
return str1.slice(-i);
|
|
28868
|
+
}
|
|
28869
|
+
}
|
|
28870
|
+
return str1.slice(-i);
|
|
28852
28871
|
}
|
|
28853
28872
|
function replacePrefix(string, oldPrefix, newPrefix) {
|
|
28854
|
-
|
|
28855
|
-
|
|
28856
|
-
|
|
28857
|
-
|
|
28873
|
+
if (string.slice(0, oldPrefix.length) != oldPrefix) {
|
|
28874
|
+
throw Error("string ".concat(JSON.stringify(string), " doesn't start with prefix ").concat(JSON.stringify(oldPrefix), "; this is a bug"));
|
|
28875
|
+
}
|
|
28876
|
+
return newPrefix + string.slice(oldPrefix.length);
|
|
28858
28877
|
}
|
|
28859
28878
|
function replaceSuffix(string, oldSuffix, newSuffix) {
|
|
28860
|
-
|
|
28861
|
-
|
|
28862
|
-
|
|
28863
|
-
|
|
28864
|
-
|
|
28865
|
-
|
|
28866
|
-
|
|
28879
|
+
if (!oldSuffix) {
|
|
28880
|
+
return string + newSuffix;
|
|
28881
|
+
}
|
|
28882
|
+
if (string.slice(-oldSuffix.length) != oldSuffix) {
|
|
28883
|
+
throw Error("string ".concat(JSON.stringify(string), " doesn't end with suffix ").concat(JSON.stringify(oldSuffix), "; this is a bug"));
|
|
28884
|
+
}
|
|
28885
|
+
return string.slice(0, -oldSuffix.length) + newSuffix;
|
|
28867
28886
|
}
|
|
28868
28887
|
function removePrefix(string, oldPrefix) {
|
|
28869
|
-
|
|
28888
|
+
return replacePrefix(string, oldPrefix, '');
|
|
28870
28889
|
}
|
|
28871
28890
|
function removeSuffix(string, oldSuffix) {
|
|
28872
|
-
|
|
28891
|
+
return replaceSuffix(string, oldSuffix, '');
|
|
28873
28892
|
}
|
|
28874
28893
|
function maximumOverlap(string1, string2) {
|
|
28875
|
-
|
|
28894
|
+
return string2.slice(0, overlapCount(string1, string2));
|
|
28876
28895
|
}
|
|
28877
|
-
|
|
28878
28896
|
// Nicked from https://stackoverflow.com/a/60422853/1709587
|
|
28879
28897
|
function overlapCount(a, b) {
|
|
28880
|
-
|
|
28881
|
-
|
|
28882
|
-
|
|
28883
|
-
|
|
28884
|
-
}
|
|
28885
|
-
var endB = b.length;
|
|
28886
|
-
if (a.length < b.length) {
|
|
28887
|
-
endB = a.length;
|
|
28888
|
-
}
|
|
28889
|
-
// Create a back-reference for each index
|
|
28890
|
-
// that should be followed in case of a mismatch.
|
|
28891
|
-
// We only need B to make these references:
|
|
28892
|
-
var map = Array(endB);
|
|
28893
|
-
var k = 0; // Index that lags behind j
|
|
28894
|
-
map[0] = 0;
|
|
28895
|
-
for (var j = 1; j < endB; j++) {
|
|
28896
|
-
if (b[j] == b[k]) {
|
|
28897
|
-
map[j] = map[k]; // skip over the same character (optional optimisation)
|
|
28898
|
-
} else {
|
|
28899
|
-
map[j] = k;
|
|
28898
|
+
// Deal with cases where the strings differ in length
|
|
28899
|
+
var startA = 0;
|
|
28900
|
+
if (a.length > b.length) {
|
|
28901
|
+
startA = a.length - b.length;
|
|
28900
28902
|
}
|
|
28901
|
-
|
|
28902
|
-
|
|
28903
|
-
|
|
28904
|
-
|
|
28905
|
-
|
|
28906
|
-
|
|
28907
|
-
|
|
28908
|
-
|
|
28909
|
-
|
|
28910
|
-
|
|
28911
|
-
|
|
28912
|
-
|
|
28913
|
-
|
|
28914
|
-
|
|
28915
|
-
|
|
28903
|
+
var endB = b.length;
|
|
28904
|
+
if (a.length < b.length) {
|
|
28905
|
+
endB = a.length;
|
|
28906
|
+
}
|
|
28907
|
+
// Create a back-reference for each index
|
|
28908
|
+
// that should be followed in case of a mismatch.
|
|
28909
|
+
// We only need B to make these references:
|
|
28910
|
+
var map = Array(endB);
|
|
28911
|
+
var k = 0; // Index that lags behind j
|
|
28912
|
+
map[0] = 0;
|
|
28913
|
+
for (var j = 1; j < endB; j++) {
|
|
28914
|
+
if (b[j] == b[k]) {
|
|
28915
|
+
map[j] = map[k]; // skip over the same character (optional optimisation)
|
|
28916
|
+
}
|
|
28917
|
+
else {
|
|
28918
|
+
map[j] = k;
|
|
28919
|
+
}
|
|
28920
|
+
while (k > 0 && b[j] != b[k]) {
|
|
28921
|
+
k = map[k];
|
|
28922
|
+
}
|
|
28923
|
+
if (b[j] == b[k]) {
|
|
28924
|
+
k++;
|
|
28925
|
+
}
|
|
28926
|
+
}
|
|
28927
|
+
// Phase 2: use these references while iterating over A
|
|
28928
|
+
k = 0;
|
|
28929
|
+
for (var i = startA; i < a.length; i++) {
|
|
28930
|
+
while (k > 0 && a[i] != b[k]) {
|
|
28931
|
+
k = map[k];
|
|
28932
|
+
}
|
|
28933
|
+
if (a[i] == b[k]) {
|
|
28934
|
+
k++;
|
|
28935
|
+
}
|
|
28936
|
+
}
|
|
28937
|
+
return k;
|
|
28938
|
+
}
|
|
28939
|
+
function trailingWs(string) {
|
|
28940
|
+
// Yes, this looks overcomplicated and dumb - why not replace the whole function with
|
|
28941
|
+
// return string match(/\s*$/)[0]
|
|
28942
|
+
// you ask? Because:
|
|
28943
|
+
// 1. the trap described at https://markamery.com/blog/quadratic-time-regexes/ would mean doing
|
|
28944
|
+
// this would cause this function to take O(n²) time in the worst case (specifically when
|
|
28945
|
+
// there is a massive run of NON-TRAILING whitespace in `string`), and
|
|
28946
|
+
// 2. the fix proposed in the same blog post, of using a negative lookbehind, is incompatible
|
|
28947
|
+
// with old Safari versions that we'd like to not break if possible (see
|
|
28948
|
+
// https://github.com/kpdecker/jsdiff/pull/550)
|
|
28949
|
+
// It feels absurd to do this with an explicit loop instead of a regex, but I really can't see a
|
|
28950
|
+
// better way that doesn't result in broken behaviour.
|
|
28951
|
+
var i;
|
|
28952
|
+
for (i = string.length - 1; i >= 0; i--) {
|
|
28953
|
+
if (!string[i].match(/\s/)) {
|
|
28954
|
+
break;
|
|
28955
|
+
}
|
|
28916
28956
|
}
|
|
28917
|
-
|
|
28918
|
-
|
|
28957
|
+
return string.substring(i + 1);
|
|
28958
|
+
}
|
|
28959
|
+
function leadingWs(string) {
|
|
28960
|
+
// Thankfully the annoying considerations described in trailingWs don't apply here:
|
|
28961
|
+
var match = string.match(/^\s*/);
|
|
28962
|
+
return match ? match[0] : '';
|
|
28919
28963
|
}
|
|
28920
28964
|
|
|
28965
|
+
var __extends$5 = (undefined && undefined.__extends) || (function () {
|
|
28966
|
+
var extendStatics = function (d, b) {
|
|
28967
|
+
extendStatics = Object.setPrototypeOf ||
|
|
28968
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
28969
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
28970
|
+
return extendStatics(d, b);
|
|
28971
|
+
};
|
|
28972
|
+
return function (d, b) {
|
|
28973
|
+
if (typeof b !== "function" && b !== null)
|
|
28974
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
28975
|
+
extendStatics(d, b);
|
|
28976
|
+
function __() { this.constructor = d; }
|
|
28977
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
28978
|
+
};
|
|
28979
|
+
})();
|
|
28921
28980
|
// Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
|
|
28922
28981
|
//
|
|
28923
28982
|
// Ranges and exceptions:
|
|
@@ -28936,8 +28995,7 @@ function overlapCount(a, b) {
|
|
|
28936
28995
|
// - U+02DC ˜ ˜ Small Tilde
|
|
28937
28996
|
// - U+02DD ˝ ˝ Double Acute Accent
|
|
28938
28997
|
// Latin Extended Additional, 1E00–1EFF
|
|
28939
|
-
var extendedWordChars =
|
|
28940
|
-
|
|
28998
|
+
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}';
|
|
28941
28999
|
// Each token is one of the following:
|
|
28942
29000
|
// - A punctuation mark plus the surrounding whitespace
|
|
28943
29001
|
// - A word plus the surrounding whitespace
|
|
@@ -28958,652 +29016,737 @@ var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6
|
|
|
28958
29016
|
//
|
|
28959
29017
|
// Keeping the surrounding whitespace of course has implications for .equals
|
|
28960
29018
|
// and .join, not just .tokenize.
|
|
28961
|
-
|
|
28962
29019
|
// This regex does NOT fully implement the tokenization rules described above.
|
|
28963
29020
|
// Instead, it gives runs of whitespace their own "token". The tokenize method
|
|
28964
29021
|
// then handles stitching whitespace tokens onto adjacent word or punctuation
|
|
28965
29022
|
// tokens.
|
|
28966
29023
|
var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), 'ug');
|
|
28967
|
-
var
|
|
28968
|
-
|
|
28969
|
-
|
|
28970
|
-
|
|
28971
|
-
right = right.toLowerCase();
|
|
28972
|
-
}
|
|
28973
|
-
return left.trim() === right.trim();
|
|
28974
|
-
};
|
|
28975
|
-
wordDiff.tokenize = function (value) {
|
|
28976
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28977
|
-
var parts;
|
|
28978
|
-
if (options.intlSegmenter) {
|
|
28979
|
-
if (options.intlSegmenter.resolvedOptions().granularity != 'word') {
|
|
28980
|
-
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
28981
|
-
}
|
|
28982
|
-
parts = Array.from(options.intlSegmenter.segment(value), function (segment) {
|
|
28983
|
-
return segment.segment;
|
|
28984
|
-
});
|
|
28985
|
-
} else {
|
|
28986
|
-
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
28987
|
-
}
|
|
28988
|
-
var tokens = [];
|
|
28989
|
-
var prevPart = null;
|
|
28990
|
-
parts.forEach(function (part) {
|
|
28991
|
-
if (/\s/.test(part)) {
|
|
28992
|
-
if (prevPart == null) {
|
|
28993
|
-
tokens.push(part);
|
|
28994
|
-
} else {
|
|
28995
|
-
tokens.push(tokens.pop() + part);
|
|
28996
|
-
}
|
|
28997
|
-
} else if (/\s/.test(prevPart)) {
|
|
28998
|
-
if (tokens[tokens.length - 1] == prevPart) {
|
|
28999
|
-
tokens.push(tokens.pop() + part);
|
|
29000
|
-
} else {
|
|
29001
|
-
tokens.push(prevPart + part);
|
|
29002
|
-
}
|
|
29003
|
-
} else {
|
|
29004
|
-
tokens.push(part);
|
|
29005
|
-
}
|
|
29006
|
-
prevPart = part;
|
|
29007
|
-
});
|
|
29008
|
-
return tokens;
|
|
29009
|
-
};
|
|
29010
|
-
wordDiff.join = function (tokens) {
|
|
29011
|
-
// Tokens being joined here will always have appeared consecutively in the
|
|
29012
|
-
// same text, so we can simply strip off the leading whitespace from all the
|
|
29013
|
-
// tokens except the first (and except any whitespace-only tokens - but such
|
|
29014
|
-
// a token will always be the first and only token anyway) and then join them
|
|
29015
|
-
// and the whitespace around words and punctuation will end up correct.
|
|
29016
|
-
return tokens.map(function (token, i) {
|
|
29017
|
-
if (i == 0) {
|
|
29018
|
-
return token;
|
|
29019
|
-
} else {
|
|
29020
|
-
return token.replace(/^\s+/, '');
|
|
29024
|
+
var WordDiff = /** @class */ (function (_super) {
|
|
29025
|
+
__extends$5(WordDiff, _super);
|
|
29026
|
+
function WordDiff() {
|
|
29027
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
29021
29028
|
}
|
|
29022
|
-
|
|
29023
|
-
|
|
29024
|
-
|
|
29025
|
-
|
|
29026
|
-
|
|
29027
|
-
|
|
29028
|
-
|
|
29029
|
-
|
|
29030
|
-
|
|
29031
|
-
|
|
29032
|
-
|
|
29033
|
-
|
|
29034
|
-
|
|
29035
|
-
|
|
29036
|
-
|
|
29037
|
-
|
|
29038
|
-
|
|
29039
|
-
|
|
29040
|
-
|
|
29041
|
-
|
|
29042
|
-
|
|
29043
|
-
|
|
29044
|
-
|
|
29045
|
-
|
|
29046
|
-
|
|
29047
|
-
|
|
29048
|
-
|
|
29049
|
-
|
|
29050
|
-
|
|
29051
|
-
|
|
29052
|
-
}
|
|
29029
|
+
WordDiff.prototype.equals = function (left, right, options) {
|
|
29030
|
+
if (options.ignoreCase) {
|
|
29031
|
+
left = left.toLowerCase();
|
|
29032
|
+
right = right.toLowerCase();
|
|
29033
|
+
}
|
|
29034
|
+
return left.trim() === right.trim();
|
|
29035
|
+
};
|
|
29036
|
+
WordDiff.prototype.tokenize = function (value, options) {
|
|
29037
|
+
if (options === void 0) { options = {}; }
|
|
29038
|
+
var parts;
|
|
29039
|
+
if (options.intlSegmenter) {
|
|
29040
|
+
var segmenter = options.intlSegmenter;
|
|
29041
|
+
if (segmenter.resolvedOptions().granularity != 'word') {
|
|
29042
|
+
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
29043
|
+
}
|
|
29044
|
+
parts = Array.from(segmenter.segment(value), function (segment) { return segment.segment; });
|
|
29045
|
+
}
|
|
29046
|
+
else {
|
|
29047
|
+
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
29048
|
+
}
|
|
29049
|
+
var tokens = [];
|
|
29050
|
+
var prevPart = null;
|
|
29051
|
+
parts.forEach(function (part) {
|
|
29052
|
+
if ((/\s/).test(part)) {
|
|
29053
|
+
if (prevPart == null) {
|
|
29054
|
+
tokens.push(part);
|
|
29055
|
+
}
|
|
29056
|
+
else {
|
|
29057
|
+
tokens.push(tokens.pop() + part);
|
|
29058
|
+
}
|
|
29059
|
+
}
|
|
29060
|
+
else if (prevPart != null && (/\s/).test(prevPart)) {
|
|
29061
|
+
if (tokens[tokens.length - 1] == prevPart) {
|
|
29062
|
+
tokens.push(tokens.pop() + part);
|
|
29063
|
+
}
|
|
29064
|
+
else {
|
|
29065
|
+
tokens.push(prevPart + part);
|
|
29066
|
+
}
|
|
29067
|
+
}
|
|
29068
|
+
else {
|
|
29069
|
+
tokens.push(part);
|
|
29070
|
+
}
|
|
29071
|
+
prevPart = part;
|
|
29072
|
+
});
|
|
29073
|
+
return tokens;
|
|
29074
|
+
};
|
|
29075
|
+
WordDiff.prototype.join = function (tokens) {
|
|
29076
|
+
// Tokens being joined here will always have appeared consecutively in the
|
|
29077
|
+
// same text, so we can simply strip off the leading whitespace from all the
|
|
29078
|
+
// tokens except the first (and except any whitespace-only tokens - but such
|
|
29079
|
+
// a token will always be the first and only token anyway) and then join them
|
|
29080
|
+
// and the whitespace around words and punctuation will end up correct.
|
|
29081
|
+
return tokens.map(function (token, i) {
|
|
29082
|
+
if (i == 0) {
|
|
29083
|
+
return token;
|
|
29084
|
+
}
|
|
29085
|
+
else {
|
|
29086
|
+
return token.replace((/^\s+/), '');
|
|
29087
|
+
}
|
|
29088
|
+
}).join('');
|
|
29089
|
+
};
|
|
29090
|
+
WordDiff.prototype.postProcess = function (changes, options) {
|
|
29091
|
+
if (!changes || options.oneChangePerToken) {
|
|
29092
|
+
return changes;
|
|
29093
|
+
}
|
|
29094
|
+
var lastKeep = null;
|
|
29095
|
+
// Change objects representing any insertion or deletion since the last
|
|
29096
|
+
// "keep" change object. There can be at most one of each.
|
|
29097
|
+
var insertion = null;
|
|
29098
|
+
var deletion = null;
|
|
29099
|
+
changes.forEach(function (change) {
|
|
29100
|
+
if (change.added) {
|
|
29101
|
+
insertion = change;
|
|
29102
|
+
}
|
|
29103
|
+
else if (change.removed) {
|
|
29104
|
+
deletion = change;
|
|
29105
|
+
}
|
|
29106
|
+
else {
|
|
29107
|
+
if (insertion || deletion) { // May be false at start of text
|
|
29108
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
|
|
29109
|
+
}
|
|
29110
|
+
lastKeep = change;
|
|
29111
|
+
insertion = null;
|
|
29112
|
+
deletion = null;
|
|
29113
|
+
}
|
|
29114
|
+
});
|
|
29115
|
+
if (insertion || deletion) {
|
|
29116
|
+
dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
|
|
29117
|
+
}
|
|
29118
|
+
return changes;
|
|
29119
|
+
};
|
|
29120
|
+
return WordDiff;
|
|
29121
|
+
}(Diff));
|
|
29122
|
+
new WordDiff();
|
|
29053
29123
|
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
29054
|
-
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
|
|
29068
|
-
|
|
29069
|
-
|
|
29070
|
-
|
|
29071
|
-
|
|
29072
|
-
|
|
29073
|
-
|
|
29074
|
-
|
|
29075
|
-
|
|
29076
|
-
|
|
29077
|
-
|
|
29078
|
-
|
|
29079
|
-
|
|
29080
|
-
|
|
29081
|
-
|
|
29082
|
-
|
|
29083
|
-
|
|
29084
|
-
|
|
29085
|
-
|
|
29086
|
-
|
|
29087
|
-
|
|
29088
|
-
|
|
29089
|
-
|
|
29090
|
-
|
|
29091
|
-
|
|
29092
|
-
|
|
29093
|
-
|
|
29094
|
-
|
|
29095
|
-
|
|
29096
|
-
|
|
29097
|
-
|
|
29098
|
-
|
|
29099
|
-
|
|
29100
|
-
|
|
29101
|
-
|
|
29102
|
-
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
|
|
29107
|
-
|
|
29108
|
-
|
|
29109
|
-
|
|
29110
|
-
|
|
29111
|
-
|
|
29112
|
-
}
|
|
29113
|
-
|
|
29114
|
-
|
|
29115
|
-
|
|
29116
|
-
|
|
29117
|
-
|
|
29118
|
-
|
|
29119
|
-
|
|
29120
|
-
|
|
29121
|
-
|
|
29122
|
-
|
|
29123
|
-
|
|
29124
|
-
|
|
29125
|
-
|
|
29126
|
-
|
|
29127
|
-
|
|
29128
|
-
|
|
29129
|
-
|
|
29130
|
-
|
|
29131
|
-
|
|
29132
|
-
|
|
29133
|
-
|
|
29134
|
-
|
|
29135
|
-
|
|
29136
|
-
|
|
29137
|
-
|
|
29138
|
-
|
|
29139
|
-
|
|
29140
|
-
|
|
29141
|
-
|
|
29142
|
-
|
|
29143
|
-
|
|
29144
|
-
|
|
29145
|
-
|
|
29146
|
-
|
|
29147
|
-
|
|
29148
|
-
|
|
29149
|
-
|
|
29150
|
-
|
|
29151
|
-
|
|
29152
|
-
|
|
29153
|
-
|
|
29154
|
-
|
|
29155
|
-
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
}
|
|
29165
|
-
var
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
|
|
29172
|
-
|
|
29173
|
-
|
|
29174
|
-
|
|
29175
|
-
|
|
29176
|
-
var
|
|
29177
|
-
|
|
29178
|
-
|
|
29179
|
-
|
|
29180
|
-
|
|
29181
|
-
|
|
29182
|
-
|
|
29183
|
-
|
|
29184
|
-
|
|
29185
|
-
|
|
29186
|
-
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
|
|
29192
|
-
|
|
29193
|
-
|
|
29194
|
-
|
|
29195
|
-
|
|
29196
|
-
|
|
29124
|
+
// Before returning, we tidy up the leading and trailing whitespace of the
|
|
29125
|
+
// change objects to eliminate cases where trailing whitespace in one object
|
|
29126
|
+
// is repeated as leading whitespace in the next.
|
|
29127
|
+
// Below are examples of the outcomes we want here to explain the code.
|
|
29128
|
+
// I=insert, K=keep, D=delete
|
|
29129
|
+
// 1. diffing 'foo bar baz' vs 'foo baz'
|
|
29130
|
+
// Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
|
|
29131
|
+
// After cleanup, we want: K:'foo ' D:'bar ' K:'baz'
|
|
29132
|
+
//
|
|
29133
|
+
// 2. Diffing 'foo bar baz' vs 'foo qux baz'
|
|
29134
|
+
// Prior to cleanup, we have K:'foo ' D:' bar ' I:' qux ' K:' baz'
|
|
29135
|
+
// After cleanup, we want K:'foo ' D:'bar' I:'qux' K:' baz'
|
|
29136
|
+
//
|
|
29137
|
+
// 3. Diffing 'foo\nbar baz' vs 'foo baz'
|
|
29138
|
+
// Prior to cleanup, we have K:'foo ' D:'\nbar ' K:' baz'
|
|
29139
|
+
// After cleanup, we want K'foo' D:'\nbar' K:' baz'
|
|
29140
|
+
//
|
|
29141
|
+
// 4. Diffing 'foo baz' vs 'foo\nbar baz'
|
|
29142
|
+
// Prior to cleanup, we have K:'foo\n' I:'\nbar ' K:' baz'
|
|
29143
|
+
// After cleanup, we ideally want K'foo' I:'\nbar' K:' baz'
|
|
29144
|
+
// but don't actually manage this currently (the pre-cleanup change
|
|
29145
|
+
// objects don't contain enough information to make it possible).
|
|
29146
|
+
//
|
|
29147
|
+
// 5. Diffing 'foo bar baz' vs 'foo baz'
|
|
29148
|
+
// Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
|
|
29149
|
+
// After cleanup, we want K:'foo ' D:' bar ' K:'baz'
|
|
29150
|
+
//
|
|
29151
|
+
// Our handling is unavoidably imperfect in the case where there's a single
|
|
29152
|
+
// indel between keeps and the whitespace has changed. For instance, consider
|
|
29153
|
+
// diffing 'foo\tbar\nbaz' vs 'foo baz'. Unless we create an extra change
|
|
29154
|
+
// object to represent the insertion of the space character (which isn't even
|
|
29155
|
+
// a token), we have no way to avoid losing information about the texts'
|
|
29156
|
+
// original whitespace in the result we return. Still, we do our best to
|
|
29157
|
+
// output something that will look sensible if we e.g. print it with
|
|
29158
|
+
// insertions in green and deletions in red.
|
|
29159
|
+
// Between two "keep" change objects (or before the first or after the last
|
|
29160
|
+
// change object), we can have either:
|
|
29161
|
+
// * A "delete" followed by an "insert"
|
|
29162
|
+
// * Just an "insert"
|
|
29163
|
+
// * Just a "delete"
|
|
29164
|
+
// We handle the three cases separately.
|
|
29165
|
+
if (deletion && insertion) {
|
|
29166
|
+
var oldWsPrefix = leadingWs(deletion.value);
|
|
29167
|
+
var oldWsSuffix = trailingWs(deletion.value);
|
|
29168
|
+
var newWsPrefix = leadingWs(insertion.value);
|
|
29169
|
+
var newWsSuffix = trailingWs(insertion.value);
|
|
29170
|
+
if (startKeep) {
|
|
29171
|
+
var commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
|
|
29172
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
|
|
29173
|
+
deletion.value = removePrefix(deletion.value, commonWsPrefix);
|
|
29174
|
+
insertion.value = removePrefix(insertion.value, commonWsPrefix);
|
|
29175
|
+
}
|
|
29176
|
+
if (endKeep) {
|
|
29177
|
+
var commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
|
|
29178
|
+
endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
|
|
29179
|
+
deletion.value = removeSuffix(deletion.value, commonWsSuffix);
|
|
29180
|
+
insertion.value = removeSuffix(insertion.value, commonWsSuffix);
|
|
29181
|
+
}
|
|
29182
|
+
}
|
|
29183
|
+
else if (insertion) {
|
|
29184
|
+
// The whitespaces all reflect what was in the new text rather than
|
|
29185
|
+
// the old, so we essentially have no information about whitespace
|
|
29186
|
+
// insertion or deletion. We just want to dedupe the whitespace.
|
|
29187
|
+
// We do that by having each change object keep its trailing
|
|
29188
|
+
// whitespace and deleting duplicate leading whitespace where
|
|
29189
|
+
// present.
|
|
29190
|
+
if (startKeep) {
|
|
29191
|
+
var ws = leadingWs(insertion.value);
|
|
29192
|
+
insertion.value = insertion.value.substring(ws.length);
|
|
29193
|
+
}
|
|
29194
|
+
if (endKeep) {
|
|
29195
|
+
var ws = leadingWs(endKeep.value);
|
|
29196
|
+
endKeep.value = endKeep.value.substring(ws.length);
|
|
29197
|
+
}
|
|
29198
|
+
// otherwise we've got a deletion and no insertion
|
|
29199
|
+
}
|
|
29200
|
+
else if (startKeep && endKeep) {
|
|
29201
|
+
var newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
|
|
29202
|
+
// Any whitespace that comes straight after startKeep in both the old and
|
|
29203
|
+
// new texts, assign to startKeep and remove from the deletion.
|
|
29204
|
+
var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
|
|
29205
|
+
deletion.value = removePrefix(deletion.value, newWsStart);
|
|
29206
|
+
// Any whitespace that comes straight before endKeep in both the old and
|
|
29207
|
+
// new texts, and hasn't already been assigned to startKeep, assign to
|
|
29208
|
+
// endKeep and remove from the deletion.
|
|
29209
|
+
var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
|
|
29210
|
+
deletion.value = removeSuffix(deletion.value, newWsEnd);
|
|
29211
|
+
endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
|
|
29212
|
+
// If there's any whitespace from the new text that HASN'T already been
|
|
29213
|
+
// assigned, assign it to the start:
|
|
29214
|
+
startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
|
|
29215
|
+
}
|
|
29216
|
+
else if (endKeep) {
|
|
29217
|
+
// We are at the start of the text. Preserve all the whitespace on
|
|
29218
|
+
// endKeep, and just remove whitespace from the end of deletion to the
|
|
29219
|
+
// extent that it overlaps with the start of endKeep.
|
|
29220
|
+
var endKeepWsPrefix = leadingWs(endKeep.value);
|
|
29221
|
+
var deletionWsSuffix = trailingWs(deletion.value);
|
|
29222
|
+
var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
|
|
29223
|
+
deletion.value = removeSuffix(deletion.value, overlap);
|
|
29224
|
+
}
|
|
29225
|
+
else if (startKeep) {
|
|
29226
|
+
// We are at the END of the text. Preserve all the whitespace on
|
|
29227
|
+
// startKeep, and just remove whitespace from the start of deletion to
|
|
29228
|
+
// the extent that it overlaps with the end of startKeep.
|
|
29229
|
+
var startKeepWsSuffix = trailingWs(startKeep.value);
|
|
29230
|
+
var deletionWsPrefix = leadingWs(deletion.value);
|
|
29231
|
+
var overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
|
|
29232
|
+
deletion.value = removePrefix(deletion.value, overlap);
|
|
29233
|
+
}
|
|
29234
|
+
}
|
|
29235
|
+
var WordsWithSpaceDiff = /** @class */ (function (_super) {
|
|
29236
|
+
__extends$5(WordsWithSpaceDiff, _super);
|
|
29237
|
+
function WordsWithSpaceDiff() {
|
|
29238
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
29239
|
+
}
|
|
29240
|
+
WordsWithSpaceDiff.prototype.tokenize = function (value) {
|
|
29241
|
+
// Slightly different to the tokenizeIncludingWhitespace regex used above in
|
|
29242
|
+
// that this one treats each individual newline as a distinct tokens, rather
|
|
29243
|
+
// than merging them into other surrounding whitespace. This was requested
|
|
29244
|
+
// in https://github.com/kpdecker/jsdiff/issues/180 &
|
|
29245
|
+
// https://github.com/kpdecker/jsdiff/issues/211
|
|
29246
|
+
var regex = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), 'ug');
|
|
29247
|
+
return value.match(regex) || [];
|
|
29248
|
+
};
|
|
29249
|
+
return WordsWithSpaceDiff;
|
|
29250
|
+
}(Diff));
|
|
29251
|
+
new WordsWithSpaceDiff();
|
|
29252
|
+
|
|
29253
|
+
var __extends$4 = (undefined && undefined.__extends) || (function () {
|
|
29254
|
+
var extendStatics = function (d, b) {
|
|
29255
|
+
extendStatics = Object.setPrototypeOf ||
|
|
29256
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29257
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
29258
|
+
return extendStatics(d, b);
|
|
29259
|
+
};
|
|
29260
|
+
return function (d, b) {
|
|
29261
|
+
if (typeof b !== "function" && b !== null)
|
|
29262
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29263
|
+
extendStatics(d, b);
|
|
29264
|
+
function __() { this.constructor = d; }
|
|
29265
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29266
|
+
};
|
|
29267
|
+
})();
|
|
29268
|
+
var LineDiff = /** @class */ (function (_super) {
|
|
29269
|
+
__extends$4(LineDiff, _super);
|
|
29270
|
+
function LineDiff() {
|
|
29271
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
29272
|
+
_this.tokenize = tokenize;
|
|
29273
|
+
return _this;
|
|
29197
29274
|
}
|
|
29198
|
-
|
|
29199
|
-
|
|
29200
|
-
|
|
29201
|
-
|
|
29202
|
-
|
|
29203
|
-
|
|
29204
|
-
|
|
29205
|
-
|
|
29206
|
-
|
|
29207
|
-
|
|
29208
|
-
|
|
29209
|
-
|
|
29210
|
-
|
|
29211
|
-
|
|
29212
|
-
|
|
29213
|
-
|
|
29214
|
-
|
|
29215
|
-
|
|
29216
|
-
|
|
29217
|
-
|
|
29218
|
-
|
|
29219
|
-
|
|
29220
|
-
|
|
29221
|
-
|
|
29222
|
-
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
};
|
|
29226
|
-
|
|
29227
|
-
|
|
29275
|
+
LineDiff.prototype.equals = function (left, right, options) {
|
|
29276
|
+
// If we're ignoring whitespace, we need to normalise lines by stripping
|
|
29277
|
+
// whitespace before checking equality. (This has an annoying interaction
|
|
29278
|
+
// with newlineIsToken that requires special handling: if newlines get their
|
|
29279
|
+
// own token, then we DON'T want to trim the *newline* tokens down to empty
|
|
29280
|
+
// strings, since this would cause us to treat whitespace-only line content
|
|
29281
|
+
// as equal to a separator between lines, which would be weird and
|
|
29282
|
+
// inconsistent with the documented behavior of the options.)
|
|
29283
|
+
if (options.ignoreWhitespace) {
|
|
29284
|
+
if (!options.newlineIsToken || !left.includes('\n')) {
|
|
29285
|
+
left = left.trim();
|
|
29286
|
+
}
|
|
29287
|
+
if (!options.newlineIsToken || !right.includes('\n')) {
|
|
29288
|
+
right = right.trim();
|
|
29289
|
+
}
|
|
29290
|
+
}
|
|
29291
|
+
else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
29292
|
+
if (left.endsWith('\n')) {
|
|
29293
|
+
left = left.slice(0, -1);
|
|
29294
|
+
}
|
|
29295
|
+
if (right.endsWith('\n')) {
|
|
29296
|
+
right = right.slice(0, -1);
|
|
29297
|
+
}
|
|
29298
|
+
}
|
|
29299
|
+
return _super.prototype.equals.call(this, left, right, options);
|
|
29300
|
+
};
|
|
29301
|
+
return LineDiff;
|
|
29302
|
+
}(Diff));
|
|
29303
|
+
var lineDiff = new LineDiff();
|
|
29304
|
+
function diffLines(oldStr, newStr, options) {
|
|
29305
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
29306
|
+
}
|
|
29307
|
+
// Exported standalone so it can be used from jsonDiff too.
|
|
29308
|
+
function tokenize(value, options) {
|
|
29309
|
+
if (options.stripTrailingCr) {
|
|
29310
|
+
// remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
|
|
29311
|
+
value = value.replace(/\r\n/g, '\n');
|
|
29312
|
+
}
|
|
29313
|
+
var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
29314
|
+
// Ignore the final empty token that occurs if the string ends with a new line
|
|
29315
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
29316
|
+
linesAndNewlines.pop();
|
|
29317
|
+
}
|
|
29318
|
+
// Merge the content and line separators into single tokens
|
|
29319
|
+
for (var i = 0; i < linesAndNewlines.length; i++) {
|
|
29320
|
+
var line = linesAndNewlines[i];
|
|
29321
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
29322
|
+
retLines[retLines.length - 1] += line;
|
|
29323
|
+
}
|
|
29324
|
+
else {
|
|
29325
|
+
retLines.push(line);
|
|
29326
|
+
}
|
|
29327
|
+
}
|
|
29328
|
+
return retLines;
|
|
29228
29329
|
}
|
|
29229
29330
|
|
|
29230
|
-
var
|
|
29231
|
-
|
|
29232
|
-
|
|
29233
|
-
};
|
|
29234
|
-
|
|
29235
|
-
|
|
29236
|
-
|
|
29237
|
-
|
|
29238
|
-
|
|
29239
|
-
|
|
29240
|
-
|
|
29241
|
-
|
|
29242
|
-
|
|
29243
|
-
|
|
29244
|
-
|
|
29245
|
-
|
|
29246
|
-
|
|
29247
|
-
|
|
29248
|
-
|
|
29249
|
-
}
|
|
29250
|
-
function
|
|
29251
|
-
|
|
29252
|
-
|
|
29253
|
-
|
|
29254
|
-
|
|
29255
|
-
|
|
29256
|
-
|
|
29257
|
-
|
|
29258
|
-
|
|
29259
|
-
|
|
29260
|
-
}
|
|
29261
|
-
function
|
|
29262
|
-
|
|
29263
|
-
|
|
29264
|
-
|
|
29265
|
-
|
|
29266
|
-
|
|
29267
|
-
|
|
29268
|
-
|
|
29269
|
-
|
|
29270
|
-
}
|
|
29271
|
-
|
|
29272
|
-
|
|
29273
|
-
|
|
29274
|
-
|
|
29275
|
-
|
|
29276
|
-
|
|
29277
|
-
|
|
29278
|
-
|
|
29279
|
-
|
|
29280
|
-
|
|
29281
|
-
|
|
29282
|
-
|
|
29283
|
-
|
|
29284
|
-
|
|
29285
|
-
|
|
29286
|
-
|
|
29287
|
-
|
|
29288
|
-
|
|
29289
|
-
|
|
29290
|
-
|
|
29291
|
-
|
|
29331
|
+
var __extends$3 = (undefined && undefined.__extends) || (function () {
|
|
29332
|
+
var extendStatics = function (d, b) {
|
|
29333
|
+
extendStatics = Object.setPrototypeOf ||
|
|
29334
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29335
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
29336
|
+
return extendStatics(d, b);
|
|
29337
|
+
};
|
|
29338
|
+
return function (d, b) {
|
|
29339
|
+
if (typeof b !== "function" && b !== null)
|
|
29340
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29341
|
+
extendStatics(d, b);
|
|
29342
|
+
function __() { this.constructor = d; }
|
|
29343
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29344
|
+
};
|
|
29345
|
+
})();
|
|
29346
|
+
var SentenceDiff = /** @class */ (function (_super) {
|
|
29347
|
+
__extends$3(SentenceDiff, _super);
|
|
29348
|
+
function SentenceDiff() {
|
|
29349
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
29350
|
+
}
|
|
29351
|
+
SentenceDiff.prototype.tokenize = function (value) {
|
|
29352
|
+
return value.split(/(?<=[.!?])(\s+|$)/);
|
|
29353
|
+
};
|
|
29354
|
+
return SentenceDiff;
|
|
29355
|
+
}(Diff));
|
|
29356
|
+
new SentenceDiff();
|
|
29357
|
+
|
|
29358
|
+
var __extends$2 = (undefined && undefined.__extends) || (function () {
|
|
29359
|
+
var extendStatics = function (d, b) {
|
|
29360
|
+
extendStatics = Object.setPrototypeOf ||
|
|
29361
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29362
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
29363
|
+
return extendStatics(d, b);
|
|
29364
|
+
};
|
|
29365
|
+
return function (d, b) {
|
|
29366
|
+
if (typeof b !== "function" && b !== null)
|
|
29367
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29368
|
+
extendStatics(d, b);
|
|
29369
|
+
function __() { this.constructor = d; }
|
|
29370
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29371
|
+
};
|
|
29372
|
+
})();
|
|
29373
|
+
var CssDiff = /** @class */ (function (_super) {
|
|
29374
|
+
__extends$2(CssDiff, _super);
|
|
29375
|
+
function CssDiff() {
|
|
29376
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
29377
|
+
}
|
|
29378
|
+
CssDiff.prototype.tokenize = function (value) {
|
|
29379
|
+
return value.split(/([{}:;,]|\s+)/);
|
|
29380
|
+
};
|
|
29381
|
+
return CssDiff;
|
|
29382
|
+
}(Diff));
|
|
29383
|
+
new CssDiff();
|
|
29384
|
+
|
|
29385
|
+
var __extends$1 = (undefined && undefined.__extends) || (function () {
|
|
29386
|
+
var extendStatics = function (d, b) {
|
|
29387
|
+
extendStatics = Object.setPrototypeOf ||
|
|
29388
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29389
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
29390
|
+
return extendStatics(d, b);
|
|
29391
|
+
};
|
|
29392
|
+
return function (d, b) {
|
|
29393
|
+
if (typeof b !== "function" && b !== null)
|
|
29394
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29395
|
+
extendStatics(d, b);
|
|
29396
|
+
function __() { this.constructor = d; }
|
|
29397
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29398
|
+
};
|
|
29399
|
+
})();
|
|
29400
|
+
var JsonDiff = /** @class */ (function (_super) {
|
|
29401
|
+
__extends$1(JsonDiff, _super);
|
|
29402
|
+
function JsonDiff() {
|
|
29403
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
29404
|
+
_this.tokenize = tokenize;
|
|
29405
|
+
return _this;
|
|
29406
|
+
}
|
|
29407
|
+
Object.defineProperty(JsonDiff.prototype, "useLongestToken", {
|
|
29408
|
+
get: function () {
|
|
29409
|
+
// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
|
|
29410
|
+
// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
|
|
29411
|
+
return true;
|
|
29412
|
+
},
|
|
29413
|
+
enumerable: false,
|
|
29414
|
+
configurable: true
|
|
29292
29415
|
});
|
|
29293
|
-
|
|
29294
|
-
|
|
29295
|
-
|
|
29296
|
-
|
|
29297
|
-
|
|
29298
|
-
|
|
29299
|
-
|
|
29300
|
-
|
|
29301
|
-
|
|
29302
|
-
|
|
29303
|
-
}
|
|
29304
|
-
function _iterableToArray(iter) {
|
|
29305
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
29306
|
-
}
|
|
29307
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
29308
|
-
if (!o) return;
|
|
29309
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
29310
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
29311
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
29312
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
29313
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
29314
|
-
}
|
|
29315
|
-
function _arrayLikeToArray(arr, len) {
|
|
29316
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
29317
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
29318
|
-
return arr2;
|
|
29319
|
-
}
|
|
29320
|
-
function _nonIterableSpread() {
|
|
29321
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29322
|
-
}
|
|
29323
|
-
|
|
29324
|
-
var jsonDiff = new Diff();
|
|
29325
|
-
// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
|
|
29326
|
-
// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
|
|
29327
|
-
jsonDiff.useLongestToken = true;
|
|
29328
|
-
jsonDiff.tokenize = lineDiff.tokenize;
|
|
29329
|
-
jsonDiff.castInput = function (value, options) {
|
|
29330
|
-
var undefinedReplacement = options.undefinedReplacement,
|
|
29331
|
-
_options$stringifyRep = options.stringifyReplacer,
|
|
29332
|
-
stringifyReplacer = _options$stringifyRep === void 0 ? function (k, v) {
|
|
29333
|
-
return typeof v === 'undefined' ? undefinedReplacement : v;
|
|
29334
|
-
} : _options$stringifyRep;
|
|
29335
|
-
return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
|
|
29336
|
-
};
|
|
29337
|
-
jsonDiff.equals = function (left, right, options) {
|
|
29338
|
-
return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
|
|
29339
|
-
};
|
|
29340
|
-
|
|
29416
|
+
JsonDiff.prototype.castInput = function (value, options) {
|
|
29417
|
+
var undefinedReplacement = options.undefinedReplacement, _a = options.stringifyReplacer, stringifyReplacer = _a === void 0 ? function (k, v) { return typeof v === 'undefined' ? undefinedReplacement : v; } : _a;
|
|
29418
|
+
return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, ' ');
|
|
29419
|
+
};
|
|
29420
|
+
JsonDiff.prototype.equals = function (left, right, options) {
|
|
29421
|
+
return _super.prototype.equals.call(this, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
|
|
29422
|
+
};
|
|
29423
|
+
return JsonDiff;
|
|
29424
|
+
}(Diff));
|
|
29425
|
+
new JsonDiff();
|
|
29341
29426
|
// This function handles the presence of circular references by bailing out when encountering an
|
|
29342
29427
|
// object that is already on the "stack" of items being processed. Accepts an optional replacer
|
|
29343
29428
|
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
29344
|
-
|
|
29345
|
-
|
|
29346
|
-
|
|
29347
|
-
|
|
29348
|
-
|
|
29349
|
-
|
|
29350
|
-
|
|
29351
|
-
|
|
29352
|
-
|
|
29353
|
-
|
|
29354
|
-
|
|
29355
|
-
|
|
29356
|
-
|
|
29357
|
-
|
|
29358
|
-
|
|
29359
|
-
|
|
29360
|
-
|
|
29361
|
-
|
|
29362
|
-
|
|
29363
|
-
|
|
29364
|
-
|
|
29365
|
-
|
|
29366
|
-
|
|
29367
|
-
|
|
29368
|
-
|
|
29369
|
-
|
|
29370
|
-
|
|
29371
|
-
|
|
29372
|
-
|
|
29373
|
-
|
|
29374
|
-
|
|
29375
|
-
|
|
29376
|
-
|
|
29377
|
-
|
|
29378
|
-
|
|
29379
|
-
|
|
29380
|
-
|
|
29429
|
+
stack = stack || [];
|
|
29430
|
+
replacementStack = replacementStack || [];
|
|
29431
|
+
if (replacer) {
|
|
29432
|
+
obj = replacer(key === undefined ? '' : key, obj);
|
|
29433
|
+
}
|
|
29434
|
+
var i;
|
|
29435
|
+
for (i = 0; i < stack.length; i += 1) {
|
|
29436
|
+
if (stack[i] === obj) {
|
|
29437
|
+
return replacementStack[i];
|
|
29438
|
+
}
|
|
29439
|
+
}
|
|
29440
|
+
var canonicalizedObj;
|
|
29441
|
+
if ('[object Array]' === Object.prototype.toString.call(obj)) {
|
|
29442
|
+
stack.push(obj);
|
|
29443
|
+
canonicalizedObj = new Array(obj.length);
|
|
29444
|
+
replacementStack.push(canonicalizedObj);
|
|
29445
|
+
for (i = 0; i < obj.length; i += 1) {
|
|
29446
|
+
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
|
|
29447
|
+
}
|
|
29448
|
+
stack.pop();
|
|
29449
|
+
replacementStack.pop();
|
|
29450
|
+
return canonicalizedObj;
|
|
29451
|
+
}
|
|
29452
|
+
if (obj && obj.toJSON) {
|
|
29453
|
+
obj = obj.toJSON();
|
|
29454
|
+
}
|
|
29455
|
+
if (typeof obj === 'object' && obj !== null) {
|
|
29456
|
+
stack.push(obj);
|
|
29457
|
+
canonicalizedObj = {};
|
|
29458
|
+
replacementStack.push(canonicalizedObj);
|
|
29459
|
+
var sortedKeys = [];
|
|
29460
|
+
var key_1;
|
|
29461
|
+
for (key_1 in obj) {
|
|
29462
|
+
/* istanbul ignore else */
|
|
29463
|
+
if (Object.prototype.hasOwnProperty.call(obj, key_1)) {
|
|
29464
|
+
sortedKeys.push(key_1);
|
|
29465
|
+
}
|
|
29466
|
+
}
|
|
29467
|
+
sortedKeys.sort();
|
|
29468
|
+
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
29469
|
+
key_1 = sortedKeys[i];
|
|
29470
|
+
canonicalizedObj[key_1] = canonicalize(obj[key_1], stack, replacementStack, replacer, key_1);
|
|
29471
|
+
}
|
|
29472
|
+
stack.pop();
|
|
29473
|
+
replacementStack.pop();
|
|
29381
29474
|
}
|
|
29382
|
-
|
|
29383
|
-
|
|
29384
|
-
_key = sortedKeys[i];
|
|
29385
|
-
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
29475
|
+
else {
|
|
29476
|
+
canonicalizedObj = obj;
|
|
29386
29477
|
}
|
|
29387
|
-
|
|
29388
|
-
replacementStack.pop();
|
|
29389
|
-
} else {
|
|
29390
|
-
canonicalizedObj = obj;
|
|
29391
|
-
}
|
|
29392
|
-
return canonicalizedObj;
|
|
29478
|
+
return canonicalizedObj;
|
|
29393
29479
|
}
|
|
29394
29480
|
|
|
29395
|
-
var
|
|
29396
|
-
|
|
29397
|
-
|
|
29398
|
-
};
|
|
29399
|
-
|
|
29400
|
-
|
|
29481
|
+
var __extends = (undefined && undefined.__extends) || (function () {
|
|
29482
|
+
var extendStatics = function (d, b) {
|
|
29483
|
+
extendStatics = Object.setPrototypeOf ||
|
|
29484
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
29485
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
29486
|
+
return extendStatics(d, b);
|
|
29487
|
+
};
|
|
29488
|
+
return function (d, b) {
|
|
29489
|
+
if (typeof b !== "function" && b !== null)
|
|
29490
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
29491
|
+
extendStatics(d, b);
|
|
29492
|
+
function __() { this.constructor = d; }
|
|
29493
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
29494
|
+
};
|
|
29495
|
+
})();
|
|
29496
|
+
var ArrayDiff = /** @class */ (function (_super) {
|
|
29497
|
+
__extends(ArrayDiff, _super);
|
|
29498
|
+
function ArrayDiff() {
|
|
29499
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
29500
|
+
}
|
|
29501
|
+
ArrayDiff.prototype.tokenize = function (value) {
|
|
29502
|
+
return value.slice();
|
|
29503
|
+
};
|
|
29504
|
+
ArrayDiff.prototype.join = function (value) {
|
|
29505
|
+
return value;
|
|
29506
|
+
};
|
|
29507
|
+
ArrayDiff.prototype.removeEmpty = function (value) {
|
|
29508
|
+
return value;
|
|
29509
|
+
};
|
|
29510
|
+
return ArrayDiff;
|
|
29511
|
+
}(Diff));
|
|
29512
|
+
new ArrayDiff();
|
|
29513
|
+
|
|
29514
|
+
var __assign$2 = (undefined && undefined.__assign) || function () {
|
|
29515
|
+
__assign$2 = Object.assign || function(t) {
|
|
29516
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29517
|
+
s = arguments[i];
|
|
29518
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29519
|
+
t[p] = s[p];
|
|
29520
|
+
}
|
|
29521
|
+
return t;
|
|
29522
|
+
};
|
|
29523
|
+
return __assign$2.apply(this, arguments);
|
|
29401
29524
|
};
|
|
29402
29525
|
|
|
29403
|
-
|
|
29404
|
-
|
|
29405
|
-
|
|
29406
|
-
|
|
29407
|
-
|
|
29408
|
-
|
|
29409
|
-
|
|
29526
|
+
var __assign$1 = (undefined && undefined.__assign) || function () {
|
|
29527
|
+
__assign$1 = Object.assign || function(t) {
|
|
29528
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29529
|
+
s = arguments[i];
|
|
29530
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29531
|
+
t[p] = s[p];
|
|
29532
|
+
}
|
|
29533
|
+
return t;
|
|
29410
29534
|
};
|
|
29411
|
-
|
|
29412
|
-
|
|
29413
|
-
options.context = 4;
|
|
29414
|
-
}
|
|
29415
|
-
if (options.newlineIsToken) {
|
|
29416
|
-
throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');
|
|
29417
|
-
}
|
|
29418
|
-
if (!options.callback) {
|
|
29419
|
-
return diffLinesResultToPatch(diffLines(oldStr, newStr, options));
|
|
29420
|
-
} else {
|
|
29421
|
-
var _options = options,
|
|
29422
|
-
_callback = _options.callback;
|
|
29423
|
-
diffLines(oldStr, newStr, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
29424
|
-
callback: function callback(diff) {
|
|
29425
|
-
var patch = diffLinesResultToPatch(diff);
|
|
29426
|
-
_callback(patch);
|
|
29427
|
-
}
|
|
29428
|
-
}));
|
|
29429
|
-
}
|
|
29430
|
-
function diffLinesResultToPatch(diff) {
|
|
29431
|
-
// STEP 1: Build up the patch with no "" lines and with the arrays
|
|
29432
|
-
// of lines containing trailing newline characters. We'll tidy up later...
|
|
29535
|
+
return __assign$1.apply(this, arguments);
|
|
29536
|
+
};
|
|
29433
29537
|
|
|
29434
|
-
|
|
29435
|
-
|
|
29538
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
29539
|
+
__assign = Object.assign || function(t) {
|
|
29540
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
29541
|
+
s = arguments[i];
|
|
29542
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
29543
|
+
t[p] = s[p];
|
|
29544
|
+
}
|
|
29545
|
+
return t;
|
|
29546
|
+
};
|
|
29547
|
+
return __assign.apply(this, arguments);
|
|
29548
|
+
};
|
|
29549
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
29550
|
+
var optionsObj;
|
|
29551
|
+
if (!options) {
|
|
29552
|
+
optionsObj = {};
|
|
29436
29553
|
}
|
|
29437
|
-
|
|
29438
|
-
|
|
29439
|
-
lines: []
|
|
29440
|
-
}); // Append an empty value to make cleanup easier
|
|
29441
|
-
|
|
29442
|
-
function contextLines(lines) {
|
|
29443
|
-
return lines.map(function (entry) {
|
|
29444
|
-
return ' ' + entry;
|
|
29445
|
-
});
|
|
29554
|
+
else if (typeof options === 'function') {
|
|
29555
|
+
optionsObj = { callback: options };
|
|
29446
29556
|
}
|
|
29447
|
-
|
|
29448
|
-
|
|
29449
|
-
|
|
29450
|
-
|
|
29451
|
-
|
|
29452
|
-
|
|
29453
|
-
|
|
29454
|
-
|
|
29455
|
-
|
|
29456
|
-
|
|
29457
|
-
|
|
29458
|
-
|
|
29459
|
-
|
|
29460
|
-
|
|
29461
|
-
|
|
29462
|
-
|
|
29463
|
-
|
|
29464
|
-
|
|
29465
|
-
|
|
29466
|
-
|
|
29467
|
-
|
|
29468
|
-
|
|
29469
|
-
|
|
29470
|
-
|
|
29471
|
-
|
|
29472
|
-
|
|
29473
|
-
|
|
29474
|
-
|
|
29475
|
-
|
|
29476
|
-
|
|
29477
|
-
if (current.added) {
|
|
29478
|
-
newLine += lines.length;
|
|
29479
|
-
} else {
|
|
29480
|
-
oldLine += lines.length;
|
|
29557
|
+
else {
|
|
29558
|
+
optionsObj = options;
|
|
29559
|
+
}
|
|
29560
|
+
if (typeof optionsObj.context === 'undefined') {
|
|
29561
|
+
optionsObj.context = 4;
|
|
29562
|
+
}
|
|
29563
|
+
// We copy this into its own variable to placate TypeScript, which thinks
|
|
29564
|
+
// optionsObj.context might be undefined in the callbacks below.
|
|
29565
|
+
var context = optionsObj.context;
|
|
29566
|
+
// @ts-expect-error (runtime check for something that is correctly a static type error)
|
|
29567
|
+
if (optionsObj.newlineIsToken) {
|
|
29568
|
+
throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');
|
|
29569
|
+
}
|
|
29570
|
+
if (!optionsObj.callback) {
|
|
29571
|
+
return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
|
|
29572
|
+
}
|
|
29573
|
+
else {
|
|
29574
|
+
var callback_1 = optionsObj.callback;
|
|
29575
|
+
diffLines(oldStr, newStr, __assign(__assign({}, optionsObj), { callback: function (diff) {
|
|
29576
|
+
var patch = diffLinesResultToPatch(diff);
|
|
29577
|
+
// TypeScript is unhappy without the cast because it does not understand that `patch` may
|
|
29578
|
+
// be undefined here only if `callback` is StructuredPatchCallbackAbortable:
|
|
29579
|
+
callback_1(patch);
|
|
29580
|
+
} }));
|
|
29581
|
+
}
|
|
29582
|
+
function diffLinesResultToPatch(diff) {
|
|
29583
|
+
// STEP 1: Build up the patch with no "" lines and with the arrays
|
|
29584
|
+
// of lines containing trailing newline characters. We'll tidy up later...
|
|
29585
|
+
if (!diff) {
|
|
29586
|
+
return;
|
|
29481
29587
|
}
|
|
29482
|
-
|
|
29483
|
-
|
|
29484
|
-
|
|
29485
|
-
|
|
29486
|
-
|
|
29487
|
-
|
|
29488
|
-
|
|
29489
|
-
|
|
29490
|
-
|
|
29491
|
-
|
|
29492
|
-
|
|
29493
|
-
|
|
29494
|
-
|
|
29495
|
-
|
|
29496
|
-
|
|
29497
|
-
|
|
29498
|
-
|
|
29499
|
-
|
|
29500
|
-
|
|
29501
|
-
|
|
29502
|
-
|
|
29503
|
-
|
|
29504
|
-
|
|
29505
|
-
|
|
29506
|
-
|
|
29588
|
+
diff.push({ value: '', lines: [] }); // Append an empty value to make cleanup easier
|
|
29589
|
+
function contextLines(lines) {
|
|
29590
|
+
return lines.map(function (entry) { return ' ' + entry; });
|
|
29591
|
+
}
|
|
29592
|
+
var hunks = [];
|
|
29593
|
+
var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
29594
|
+
for (var i = 0; i < diff.length; i++) {
|
|
29595
|
+
var current = diff[i], lines = current.lines || splitLines(current.value);
|
|
29596
|
+
current.lines = lines;
|
|
29597
|
+
if (current.added || current.removed) {
|
|
29598
|
+
// If we have previous context, start with that
|
|
29599
|
+
if (!oldRangeStart) {
|
|
29600
|
+
var prev = diff[i - 1];
|
|
29601
|
+
oldRangeStart = oldLine;
|
|
29602
|
+
newRangeStart = newLine;
|
|
29603
|
+
if (prev) {
|
|
29604
|
+
curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
|
|
29605
|
+
oldRangeStart -= curRange.length;
|
|
29606
|
+
newRangeStart -= curRange.length;
|
|
29607
|
+
}
|
|
29608
|
+
}
|
|
29609
|
+
// Output our changes
|
|
29610
|
+
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
|
|
29611
|
+
var line = lines_1[_i];
|
|
29612
|
+
curRange.push((current.added ? '+' : '-') + line);
|
|
29613
|
+
}
|
|
29614
|
+
// Track the updated file position
|
|
29615
|
+
if (current.added) {
|
|
29616
|
+
newLine += lines.length;
|
|
29617
|
+
}
|
|
29618
|
+
else {
|
|
29619
|
+
oldLine += lines.length;
|
|
29620
|
+
}
|
|
29621
|
+
}
|
|
29622
|
+
else {
|
|
29623
|
+
// Identical context lines. Track line changes
|
|
29624
|
+
if (oldRangeStart) {
|
|
29625
|
+
// Close out any changes that have been output (or join overlapping)
|
|
29626
|
+
if (lines.length <= context * 2 && i < diff.length - 2) {
|
|
29627
|
+
// Overlapping
|
|
29628
|
+
for (var _a = 0, _b = contextLines(lines); _a < _b.length; _a++) {
|
|
29629
|
+
var line = _b[_a];
|
|
29630
|
+
curRange.push(line);
|
|
29631
|
+
}
|
|
29632
|
+
}
|
|
29633
|
+
else {
|
|
29634
|
+
// end the range and output
|
|
29635
|
+
var contextSize = Math.min(lines.length, context);
|
|
29636
|
+
for (var _c = 0, _d = contextLines(lines.slice(0, contextSize)); _c < _d.length; _c++) {
|
|
29637
|
+
var line = _d[_c];
|
|
29638
|
+
curRange.push(line);
|
|
29639
|
+
}
|
|
29640
|
+
var hunk = {
|
|
29641
|
+
oldStart: oldRangeStart,
|
|
29642
|
+
oldLines: (oldLine - oldRangeStart + contextSize),
|
|
29643
|
+
newStart: newRangeStart,
|
|
29644
|
+
newLines: (newLine - newRangeStart + contextSize),
|
|
29645
|
+
lines: curRange
|
|
29646
|
+
};
|
|
29647
|
+
hunks.push(hunk);
|
|
29648
|
+
oldRangeStart = 0;
|
|
29649
|
+
newRangeStart = 0;
|
|
29650
|
+
curRange = [];
|
|
29651
|
+
}
|
|
29652
|
+
}
|
|
29653
|
+
oldLine += lines.length;
|
|
29654
|
+
newLine += lines.length;
|
|
29655
|
+
}
|
|
29507
29656
|
}
|
|
29508
|
-
|
|
29509
|
-
|
|
29510
|
-
|
|
29511
|
-
|
|
29512
|
-
|
|
29513
|
-
|
|
29514
|
-
|
|
29515
|
-
|
|
29516
|
-
|
|
29517
|
-
|
|
29518
|
-
|
|
29519
|
-
|
|
29520
|
-
|
|
29521
|
-
if (hunk.lines[_i2].endsWith('\n')) {
|
|
29522
|
-
hunk.lines[_i2] = hunk.lines[_i2].slice(0, -1);
|
|
29523
|
-
} else {
|
|
29524
|
-
hunk.lines.splice(_i2 + 1, 0, '\');
|
|
29525
|
-
_i2++; // Skip the line we just added, then continue iterating
|
|
29657
|
+
// Step 2: eliminate the trailing `\n` from each line of each hunk, and, where needed, add
|
|
29658
|
+
// "".
|
|
29659
|
+
for (var _e = 0, hunks_1 = hunks; _e < hunks_1.length; _e++) {
|
|
29660
|
+
var hunk = hunks_1[_e];
|
|
29661
|
+
for (var i = 0; i < hunk.lines.length; i++) {
|
|
29662
|
+
if (hunk.lines[i].endsWith('\n')) {
|
|
29663
|
+
hunk.lines[i] = hunk.lines[i].slice(0, -1);
|
|
29664
|
+
}
|
|
29665
|
+
else {
|
|
29666
|
+
hunk.lines.splice(i + 1, 0, '\');
|
|
29667
|
+
i++; // Skip the line we just added, then continue iterating
|
|
29668
|
+
}
|
|
29669
|
+
}
|
|
29526
29670
|
}
|
|
29527
|
-
|
|
29671
|
+
return {
|
|
29672
|
+
oldFileName: oldFileName, newFileName: newFileName,
|
|
29673
|
+
oldHeader: oldHeader, newHeader: newHeader,
|
|
29674
|
+
hunks: hunks
|
|
29675
|
+
};
|
|
29528
29676
|
}
|
|
29529
|
-
return {
|
|
29530
|
-
oldFileName: oldFileName,
|
|
29531
|
-
newFileName: newFileName,
|
|
29532
|
-
oldHeader: oldHeader,
|
|
29533
|
-
newHeader: newHeader,
|
|
29534
|
-
hunks: hunks
|
|
29535
|
-
};
|
|
29536
|
-
}
|
|
29537
29677
|
}
|
|
29538
|
-
|
|
29539
|
-
|
|
29540
|
-
|
|
29541
|
-
|
|
29542
|
-
|
|
29543
|
-
|
|
29544
|
-
|
|
29545
|
-
}
|
|
29546
|
-
ret.push('===================================================================');
|
|
29547
|
-
ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
|
|
29548
|
-
ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
|
|
29549
|
-
for (var i = 0; i < diff.hunks.length; i++) {
|
|
29550
|
-
var hunk = diff.hunks[i];
|
|
29551
|
-
// Unified Diff Format quirk: If the chunk size is 0,
|
|
29552
|
-
// the first number is one lower than one would expect.
|
|
29553
|
-
// https://www.artima.com/weblogs/viewpost.jsp?thread=164293
|
|
29554
|
-
if (hunk.oldLines === 0) {
|
|
29555
|
-
hunk.oldStart -= 1;
|
|
29678
|
+
/**
|
|
29679
|
+
* creates a unified diff patch.
|
|
29680
|
+
* @param patch either a single structured patch object (as returned by `structuredPatch`) or an array of them (as returned by `parsePatch`)
|
|
29681
|
+
*/
|
|
29682
|
+
function formatPatch(patch) {
|
|
29683
|
+
if (Array.isArray(patch)) {
|
|
29684
|
+
return patch.map(formatPatch).join('\n');
|
|
29556
29685
|
}
|
|
29557
|
-
|
|
29558
|
-
|
|
29686
|
+
var ret = [];
|
|
29687
|
+
if (patch.oldFileName == patch.newFileName) {
|
|
29688
|
+
ret.push('Index: ' + patch.oldFileName);
|
|
29559
29689
|
}
|
|
29560
|
-
ret.push('
|
|
29561
|
-
ret.push.
|
|
29562
|
-
|
|
29563
|
-
|
|
29690
|
+
ret.push('===================================================================');
|
|
29691
|
+
ret.push('--- ' + patch.oldFileName + (typeof patch.oldHeader === 'undefined' ? '' : '\t' + patch.oldHeader));
|
|
29692
|
+
ret.push('+++ ' + patch.newFileName + (typeof patch.newHeader === 'undefined' ? '' : '\t' + patch.newHeader));
|
|
29693
|
+
for (var i = 0; i < patch.hunks.length; i++) {
|
|
29694
|
+
var hunk = patch.hunks[i];
|
|
29695
|
+
// Unified Diff Format quirk: If the chunk size is 0,
|
|
29696
|
+
// the first number is one lower than one would expect.
|
|
29697
|
+
// https://www.artima.com/weblogs/viewpost.jsp?thread=164293
|
|
29698
|
+
if (hunk.oldLines === 0) {
|
|
29699
|
+
hunk.oldStart -= 1;
|
|
29700
|
+
}
|
|
29701
|
+
if (hunk.newLines === 0) {
|
|
29702
|
+
hunk.newStart -= 1;
|
|
29703
|
+
}
|
|
29704
|
+
ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines
|
|
29705
|
+
+ ' +' + hunk.newStart + ',' + hunk.newLines
|
|
29706
|
+
+ ' @@');
|
|
29707
|
+
for (var _i = 0, _a = hunk.lines; _i < _a.length; _i++) {
|
|
29708
|
+
var line = _a[_i];
|
|
29709
|
+
ret.push(line);
|
|
29710
|
+
}
|
|
29711
|
+
}
|
|
29712
|
+
return ret.join('\n') + '\n';
|
|
29564
29713
|
}
|
|
29565
29714
|
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
29566
|
-
|
|
29567
|
-
|
|
29568
|
-
options = {
|
|
29569
|
-
callback: options
|
|
29570
|
-
};
|
|
29571
|
-
}
|
|
29572
|
-
if (!((_options2 = options) !== null && _options2 !== void 0 && _options2.callback)) {
|
|
29573
|
-
var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
29574
|
-
if (!patchObj) {
|
|
29575
|
-
return;
|
|
29715
|
+
if (typeof options === 'function') {
|
|
29716
|
+
options = { callback: options };
|
|
29576
29717
|
}
|
|
29577
|
-
|
|
29578
|
-
|
|
29579
|
-
var _options3 = options,
|
|
29580
|
-
_callback2 = _options3.callback;
|
|
29581
|
-
structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
29582
|
-
callback: function callback(patchObj) {
|
|
29718
|
+
if (!(options === null || options === void 0 ? void 0 : options.callback)) {
|
|
29719
|
+
var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
29583
29720
|
if (!patchObj) {
|
|
29584
|
-
|
|
29585
|
-
} else {
|
|
29586
|
-
_callback2(formatPatch(patchObj));
|
|
29721
|
+
return;
|
|
29587
29722
|
}
|
|
29588
|
-
|
|
29589
|
-
}
|
|
29590
|
-
|
|
29723
|
+
return formatPatch(patchObj);
|
|
29724
|
+
}
|
|
29725
|
+
else {
|
|
29726
|
+
var callback_2 = options.callback;
|
|
29727
|
+
structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, __assign(__assign({}, options), { callback: function (patchObj) {
|
|
29728
|
+
if (!patchObj) {
|
|
29729
|
+
callback_2(undefined);
|
|
29730
|
+
}
|
|
29731
|
+
else {
|
|
29732
|
+
callback_2(formatPatch(patchObj));
|
|
29733
|
+
}
|
|
29734
|
+
} }));
|
|
29735
|
+
}
|
|
29591
29736
|
}
|
|
29592
|
-
|
|
29593
29737
|
/**
|
|
29594
29738
|
* Split `text` into an array of lines, including the trailing newline character (where present)
|
|
29595
29739
|
*/
|
|
29596
29740
|
function splitLines(text) {
|
|
29597
|
-
|
|
29598
|
-
|
|
29599
|
-
|
|
29600
|
-
|
|
29601
|
-
|
|
29602
|
-
|
|
29603
|
-
|
|
29604
|
-
|
|
29605
|
-
|
|
29606
|
-
return result;
|
|
29741
|
+
var hasTrailingNl = text.endsWith('\n');
|
|
29742
|
+
var result = text.split('\n').map(function (line) { return line + '\n'; });
|
|
29743
|
+
if (hasTrailingNl) {
|
|
29744
|
+
result.pop();
|
|
29745
|
+
}
|
|
29746
|
+
else {
|
|
29747
|
+
result.push(result.pop().slice(0, -1));
|
|
29748
|
+
}
|
|
29749
|
+
return result;
|
|
29607
29750
|
}
|
|
29608
29751
|
|
|
29609
29752
|
/* eslint-disable no-multi-assign */
|
|
@@ -56710,4 +56853,4 @@ var srcExports = requireSrc();
|
|
|
56710
56853
|
var tinylr = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
|
|
56711
56854
|
|
|
56712
56855
|
export { HighlightJS as H, MarkdownIt as M, deflist_plugin as a, closest as b, createTwoFilesPatch as c, dedent as d, distance as e, fm as f, globSync as g, glob as h, isCI as i, moduleImporter as j, cliProgress as k, createInstance as l, minimatch as m, fse as n, tinylr as t, watch$1 as w };
|
|
56713
|
-
//# sourceMappingURL=vendor-
|
|
56856
|
+
//# sourceMappingURL=vendor-DxEOke6B.mjs.map
|