@forsakringskassan/docs-generator 2.27.1 → 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-B9Y9VYNq.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/processors/selectable-version.mjs +49 -5
- package/dist/{vendor-DiqWVUfS.mjs → vendor-DxEOke6B.mjs} +1096 -949
- package/dist/vendor-DxEOke6B.mjs.map +1 -0
- package/dist/{vue3-BzNzaBbK.mjs → vue3-CwePPTYz.mjs} +2 -2
- package/dist/{vue3-BzNzaBbK.mjs.map → vue3-CwePPTYz.mjs.map} +1 -1
- package/dist/{worker-BnI39lrZ.mjs → worker-BqgLhl2f.mjs} +3 -3
- package/dist/{worker-BnI39lrZ.mjs.map → worker-BqgLhl2f.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/create-markdown-renderer-B9Y9VYNq.mjs.map +0 -1
- package/dist/vendor-DiqWVUfS.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));
|
|
@@ -24468,13 +24468,14 @@ class Translator extends EventEmitter {
|
|
|
24468
24468
|
if (lng) this.language = lng;
|
|
24469
24469
|
}
|
|
24470
24470
|
exists(key) {
|
|
24471
|
-
let
|
|
24471
|
+
let o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
24472
24472
|
interpolation: {}
|
|
24473
24473
|
};
|
|
24474
|
-
|
|
24475
|
-
|
|
24476
|
-
}
|
|
24477
|
-
|
|
24474
|
+
const opt = {
|
|
24475
|
+
...o
|
|
24476
|
+
};
|
|
24477
|
+
if (key == null) return false;
|
|
24478
|
+
const resolved = this.resolve(key, opt);
|
|
24478
24479
|
return resolved?.res !== undefined;
|
|
24479
24480
|
}
|
|
24480
24481
|
extractFromKey(key, opt) {
|
|
@@ -24501,7 +24502,10 @@ class Translator extends EventEmitter {
|
|
|
24501
24502
|
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
24502
24503
|
};
|
|
24503
24504
|
}
|
|
24504
|
-
translate(keys,
|
|
24505
|
+
translate(keys, o, lastKey) {
|
|
24506
|
+
let opt = typeof o === 'object' ? {
|
|
24507
|
+
...o
|
|
24508
|
+
} : o;
|
|
24505
24509
|
if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
24506
24510
|
opt = this.options.overloadTranslationOptionHandler(arguments);
|
|
24507
24511
|
}
|
|
@@ -24679,7 +24683,7 @@ class Translator extends EventEmitter {
|
|
|
24679
24683
|
res = this.extendTranslation(res, keys, opt, resolved, lastKey);
|
|
24680
24684
|
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
|
|
24681
24685
|
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
24682
|
-
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
|
|
24686
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined, opt);
|
|
24683
24687
|
}
|
|
24684
24688
|
}
|
|
24685
24689
|
if (returnDetails) {
|
|
@@ -28554,366 +28558,425 @@ function deflist_plugin (md) {
|
|
|
28554
28558
|
md.block.ruler.before('paragraph', 'deflist', deflist, { alt: ['paragraph', 'reference', 'blockquote'] });
|
|
28555
28559
|
}
|
|
28556
28560
|
|
|
28557
|
-
|
|
28558
|
-
Diff
|
|
28559
|
-
diff: function diff(oldString, newString) {
|
|
28560
|
-
var _options$timeout;
|
|
28561
|
-
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
28562
|
-
var callback = options.callback;
|
|
28563
|
-
if (typeof options === 'function') {
|
|
28564
|
-
callback = options;
|
|
28565
|
-
options = {};
|
|
28566
|
-
}
|
|
28567
|
-
var self = this;
|
|
28568
|
-
function done(value) {
|
|
28569
|
-
value = self.postProcess(value, options);
|
|
28570
|
-
if (callback) {
|
|
28571
|
-
setTimeout(function () {
|
|
28572
|
-
callback(value);
|
|
28573
|
-
}, 0);
|
|
28574
|
-
return true;
|
|
28575
|
-
} else {
|
|
28576
|
-
return value;
|
|
28577
|
-
}
|
|
28561
|
+
var Diff = /** @class */ (function () {
|
|
28562
|
+
function Diff() {
|
|
28578
28563
|
}
|
|
28579
|
-
|
|
28580
|
-
//
|
|
28581
|
-
|
|
28582
|
-
|
|
28583
|
-
|
|
28584
|
-
|
|
28585
|
-
|
|
28586
|
-
|
|
28587
|
-
var editLength = 1;
|
|
28588
|
-
var maxEditLength = newLen + oldLen;
|
|
28589
|
-
if (options.maxEditLength != null) {
|
|
28590
|
-
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
28591
|
-
}
|
|
28592
|
-
var maxExecutionTime = (_options$timeout = options.timeout) !== null && _options$timeout !== void 0 ? _options$timeout : Infinity;
|
|
28593
|
-
var abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
28594
|
-
var bestPath = [{
|
|
28595
|
-
oldPos: -1,
|
|
28596
|
-
lastComponent: undefined
|
|
28597
|
-
}];
|
|
28598
|
-
|
|
28599
|
-
// Seed editLength = 0, i.e. the content starts with the same values
|
|
28600
|
-
var newPos = this.extractCommon(bestPath[0], newString, oldString, 0, options);
|
|
28601
|
-
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
28602
|
-
// Identity per the equality and tokenizer
|
|
28603
|
-
return done(buildValues(self, bestPath[0].lastComponent, newString, oldString, self.useLongestToken));
|
|
28604
|
-
}
|
|
28605
|
-
|
|
28606
|
-
// Once we hit the right edge of the edit graph on some diagonal k, we can
|
|
28607
|
-
// definitely reach the end of the edit graph in no more than k edits, so
|
|
28608
|
-
// there's no point in considering any moves to diagonal k+1 any more (from
|
|
28609
|
-
// which we're guaranteed to need at least k+1 more edits).
|
|
28610
|
-
// Similarly, once we've reached the bottom of the edit graph, there's no
|
|
28611
|
-
// point considering moves to lower diagonals.
|
|
28612
|
-
// We record this fact by setting minDiagonalToConsider and
|
|
28613
|
-
// maxDiagonalToConsider to some finite value once we've hit the edge of
|
|
28614
|
-
// the edit graph.
|
|
28615
|
-
// This optimization is not faithful to the original algorithm presented in
|
|
28616
|
-
// Myers's paper, which instead pointlessly extends D-paths off the end of
|
|
28617
|
-
// the edit graph - see page 7 of Myers's paper which notes this point
|
|
28618
|
-
// explicitly and illustrates it with a diagram. This has major performance
|
|
28619
|
-
// implications for some common scenarios. For instance, to compute a diff
|
|
28620
|
-
// where the new text simply appends d characters on the end of the
|
|
28621
|
-
// original text of length n, the true Myers algorithm will take O(n+d^2)
|
|
28622
|
-
// time while this optimization needs only O(n+d) time.
|
|
28623
|
-
var minDiagonalToConsider = -Infinity,
|
|
28624
|
-
maxDiagonalToConsider = Infinity;
|
|
28625
|
-
|
|
28626
|
-
// Main worker method. checks all permutations of a given edit length for acceptance.
|
|
28627
|
-
function execEditLength() {
|
|
28628
|
-
for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
28629
|
-
var basePath = void 0;
|
|
28630
|
-
var removePath = bestPath[diagonalPath - 1],
|
|
28631
|
-
addPath = bestPath[diagonalPath + 1];
|
|
28632
|
-
if (removePath) {
|
|
28633
|
-
// No one else is going to attempt to use this value, clear it
|
|
28634
|
-
bestPath[diagonalPath - 1] = undefined;
|
|
28635
|
-
}
|
|
28636
|
-
var canAdd = false;
|
|
28637
|
-
if (addPath) {
|
|
28638
|
-
// what newPos will be after we do an insertion:
|
|
28639
|
-
var addPathNewPos = addPath.oldPos - diagonalPath;
|
|
28640
|
-
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
28641
|
-
}
|
|
28642
|
-
var canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
28643
|
-
if (!canAdd && !canRemove) {
|
|
28644
|
-
// If this path is a terminal then prune
|
|
28645
|
-
bestPath[diagonalPath] = undefined;
|
|
28646
|
-
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 = {};
|
|
28647
28572
|
}
|
|
28648
|
-
|
|
28649
|
-
|
|
28650
|
-
// path whose position in the old string is the farthest from the origin
|
|
28651
|
-
// and does not pass the bounds of the diff graph
|
|
28652
|
-
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
28653
|
-
basePath = self.addToPath(addPath, true, false, 0, options);
|
|
28654
|
-
} else {
|
|
28655
|
-
basePath = self.addToPath(removePath, false, true, 1, options);
|
|
28573
|
+
else if ('callback' in options) {
|
|
28574
|
+
callback = options.callback;
|
|
28656
28575
|
}
|
|
28657
|
-
|
|
28658
|
-
|
|
28659
|
-
|
|
28660
|
-
|
|
28661
|
-
|
|
28662
|
-
|
|
28663
|
-
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
|
|
28667
|
-
|
|
28668
|
-
|
|
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
|
+
}());
|
|
28669
28693
|
}
|
|
28670
|
-
|
|
28671
|
-
|
|
28672
|
-
|
|
28673
|
-
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
// in which case it will return undefined.
|
|
28678
|
-
if (callback) {
|
|
28679
|
-
(function exec() {
|
|
28680
|
-
setTimeout(function () {
|
|
28681
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
28682
|
-
return callback();
|
|
28683
|
-
}
|
|
28684
|
-
if (!execEditLength()) {
|
|
28685
|
-
exec();
|
|
28686
|
-
}
|
|
28687
|
-
}, 0);
|
|
28688
|
-
})();
|
|
28689
|
-
} else {
|
|
28690
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
28691
|
-
var ret = execEditLength();
|
|
28692
|
-
if (ret) {
|
|
28693
|
-
return ret;
|
|
28694
|
+
else {
|
|
28695
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
28696
|
+
var ret = execEditLength();
|
|
28697
|
+
if (ret) {
|
|
28698
|
+
return ret;
|
|
28699
|
+
}
|
|
28700
|
+
}
|
|
28694
28701
|
}
|
|
28695
|
-
|
|
28696
|
-
|
|
28697
|
-
|
|
28698
|
-
|
|
28699
|
-
|
|
28700
|
-
|
|
28701
|
-
|
|
28702
|
-
|
|
28703
|
-
lastComponent: {
|
|
28704
|
-
count: last.count + 1,
|
|
28705
|
-
added: added,
|
|
28706
|
-
removed: removed,
|
|
28707
|
-
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
|
+
};
|
|
28708
28710
|
}
|
|
28709
|
-
|
|
28710
|
-
|
|
28711
|
-
|
|
28712
|
-
|
|
28713
|
-
|
|
28714
|
-
count: 1,
|
|
28715
|
-
added: added,
|
|
28716
|
-
removed: removed,
|
|
28717
|
-
previousComponent: last
|
|
28711
|
+
else {
|
|
28712
|
+
return {
|
|
28713
|
+
oldPos: path.oldPos + oldPosInc,
|
|
28714
|
+
lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }
|
|
28715
|
+
};
|
|
28718
28716
|
}
|
|
28719
|
-
|
|
28720
|
-
|
|
28721
|
-
|
|
28722
|
-
|
|
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
|
-
|
|
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;
|
|
28819
28843
|
}
|
|
28820
|
-
|
|
28821
|
-
|
|
28822
|
-
|
|
28844
|
+
return CharacterDiff;
|
|
28845
|
+
}(Diff));
|
|
28846
|
+
new CharacterDiff();
|
|
28823
28847
|
|
|
28824
28848
|
function longestCommonPrefix(str1, str2) {
|
|
28825
|
-
|
|
28826
|
-
|
|
28827
|
-
|
|
28828
|
-
|
|
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
|
+
}
|
|
28829
28854
|
}
|
|
28830
|
-
|
|
28831
|
-
return str1.slice(0, i);
|
|
28855
|
+
return str1.slice(0, i);
|
|
28832
28856
|
}
|
|
28833
28857
|
function longestCommonSuffix(str1, str2) {
|
|
28834
|
-
|
|
28835
|
-
|
|
28836
|
-
|
|
28837
|
-
|
|
28838
|
-
|
|
28839
|
-
|
|
28840
|
-
return '';
|
|
28841
|
-
}
|
|
28842
|
-
for (i = 0; i < str1.length && i < str2.length; i++) {
|
|
28843
|
-
if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
|
|
28844
|
-
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 '';
|
|
28845
28864
|
}
|
|
28846
|
-
|
|
28847
|
-
|
|
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);
|
|
28848
28871
|
}
|
|
28849
28872
|
function replacePrefix(string, oldPrefix, newPrefix) {
|
|
28850
|
-
|
|
28851
|
-
|
|
28852
|
-
|
|
28853
|
-
|
|
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);
|
|
28854
28877
|
}
|
|
28855
28878
|
function replaceSuffix(string, oldSuffix, newSuffix) {
|
|
28856
|
-
|
|
28857
|
-
|
|
28858
|
-
|
|
28859
|
-
|
|
28860
|
-
|
|
28861
|
-
|
|
28862
|
-
|
|
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;
|
|
28863
28886
|
}
|
|
28864
28887
|
function removePrefix(string, oldPrefix) {
|
|
28865
|
-
|
|
28888
|
+
return replacePrefix(string, oldPrefix, '');
|
|
28866
28889
|
}
|
|
28867
28890
|
function removeSuffix(string, oldSuffix) {
|
|
28868
|
-
|
|
28891
|
+
return replaceSuffix(string, oldSuffix, '');
|
|
28869
28892
|
}
|
|
28870
28893
|
function maximumOverlap(string1, string2) {
|
|
28871
|
-
|
|
28894
|
+
return string2.slice(0, overlapCount(string1, string2));
|
|
28872
28895
|
}
|
|
28873
|
-
|
|
28874
28896
|
// Nicked from https://stackoverflow.com/a/60422853/1709587
|
|
28875
28897
|
function overlapCount(a, b) {
|
|
28876
|
-
|
|
28877
|
-
|
|
28878
|
-
|
|
28879
|
-
|
|
28880
|
-
}
|
|
28881
|
-
var endB = b.length;
|
|
28882
|
-
if (a.length < b.length) {
|
|
28883
|
-
endB = a.length;
|
|
28884
|
-
}
|
|
28885
|
-
// Create a back-reference for each index
|
|
28886
|
-
// that should be followed in case of a mismatch.
|
|
28887
|
-
// We only need B to make these references:
|
|
28888
|
-
var map = Array(endB);
|
|
28889
|
-
var k = 0; // Index that lags behind j
|
|
28890
|
-
map[0] = 0;
|
|
28891
|
-
for (var j = 1; j < endB; j++) {
|
|
28892
|
-
if (b[j] == b[k]) {
|
|
28893
|
-
map[j] = map[k]; // skip over the same character (optional optimisation)
|
|
28894
|
-
} else {
|
|
28895
|
-
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;
|
|
28896
28902
|
}
|
|
28897
|
-
|
|
28898
|
-
|
|
28899
|
-
|
|
28900
|
-
|
|
28901
|
-
|
|
28902
|
-
|
|
28903
|
-
|
|
28904
|
-
|
|
28905
|
-
|
|
28906
|
-
|
|
28907
|
-
|
|
28908
|
-
|
|
28909
|
-
|
|
28910
|
-
|
|
28911
|
-
|
|
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
|
+
}
|
|
28912
28956
|
}
|
|
28913
|
-
|
|
28914
|
-
|
|
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] : '';
|
|
28915
28963
|
}
|
|
28916
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
|
+
})();
|
|
28917
28980
|
// Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
|
|
28918
28981
|
//
|
|
28919
28982
|
// Ranges and exceptions:
|
|
@@ -28932,8 +28995,7 @@ function overlapCount(a, b) {
|
|
|
28932
28995
|
// - U+02DC ˜ ˜ Small Tilde
|
|
28933
28996
|
// - U+02DD ˝ ˝ Double Acute Accent
|
|
28934
28997
|
// Latin Extended Additional, 1E00–1EFF
|
|
28935
|
-
var extendedWordChars =
|
|
28936
|
-
|
|
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}';
|
|
28937
28999
|
// Each token is one of the following:
|
|
28938
29000
|
// - A punctuation mark plus the surrounding whitespace
|
|
28939
29001
|
// - A word plus the surrounding whitespace
|
|
@@ -28954,652 +29016,737 @@ var extendedWordChars = "a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6
|
|
|
28954
29016
|
//
|
|
28955
29017
|
// Keeping the surrounding whitespace of course has implications for .equals
|
|
28956
29018
|
// and .join, not just .tokenize.
|
|
28957
|
-
|
|
28958
29019
|
// This regex does NOT fully implement the tokenization rules described above.
|
|
28959
29020
|
// Instead, it gives runs of whitespace their own "token". The tokenize method
|
|
28960
29021
|
// then handles stitching whitespace tokens onto adjacent word or punctuation
|
|
28961
29022
|
// tokens.
|
|
28962
29023
|
var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), 'ug');
|
|
28963
|
-
var
|
|
28964
|
-
|
|
28965
|
-
|
|
28966
|
-
|
|
28967
|
-
right = right.toLowerCase();
|
|
28968
|
-
}
|
|
28969
|
-
return left.trim() === right.trim();
|
|
28970
|
-
};
|
|
28971
|
-
wordDiff.tokenize = function (value) {
|
|
28972
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28973
|
-
var parts;
|
|
28974
|
-
if (options.intlSegmenter) {
|
|
28975
|
-
if (options.intlSegmenter.resolvedOptions().granularity != 'word') {
|
|
28976
|
-
throw new Error('The segmenter passed must have a granularity of "word"');
|
|
28977
|
-
}
|
|
28978
|
-
parts = Array.from(options.intlSegmenter.segment(value), function (segment) {
|
|
28979
|
-
return segment.segment;
|
|
28980
|
-
});
|
|
28981
|
-
} else {
|
|
28982
|
-
parts = value.match(tokenizeIncludingWhitespace) || [];
|
|
28983
|
-
}
|
|
28984
|
-
var tokens = [];
|
|
28985
|
-
var prevPart = null;
|
|
28986
|
-
parts.forEach(function (part) {
|
|
28987
|
-
if (/\s/.test(part)) {
|
|
28988
|
-
if (prevPart == null) {
|
|
28989
|
-
tokens.push(part);
|
|
28990
|
-
} else {
|
|
28991
|
-
tokens.push(tokens.pop() + part);
|
|
28992
|
-
}
|
|
28993
|
-
} else if (/\s/.test(prevPart)) {
|
|
28994
|
-
if (tokens[tokens.length - 1] == prevPart) {
|
|
28995
|
-
tokens.push(tokens.pop() + part);
|
|
28996
|
-
} else {
|
|
28997
|
-
tokens.push(prevPart + part);
|
|
28998
|
-
}
|
|
28999
|
-
} else {
|
|
29000
|
-
tokens.push(part);
|
|
29024
|
+
var WordDiff = /** @class */ (function (_super) {
|
|
29025
|
+
__extends$5(WordDiff, _super);
|
|
29026
|
+
function WordDiff() {
|
|
29027
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
29001
29028
|
}
|
|
29002
|
-
|
|
29003
|
-
|
|
29004
|
-
|
|
29005
|
-
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
29009
|
-
|
|
29010
|
-
|
|
29011
|
-
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29019
|
-
|
|
29020
|
-
|
|
29021
|
-
|
|
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
|
-
|
|
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();
|
|
29049
29123
|
function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
|
|
29050
|
-
|
|
29051
|
-
|
|
29052
|
-
|
|
29053
|
-
|
|
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
|
-
var
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
|
|
29172
|
-
var
|
|
29173
|
-
|
|
29174
|
-
|
|
29175
|
-
|
|
29176
|
-
|
|
29177
|
-
|
|
29178
|
-
|
|
29179
|
-
|
|
29180
|
-
|
|
29181
|
-
|
|
29182
|
-
|
|
29183
|
-
|
|
29184
|
-
|
|
29185
|
-
|
|
29186
|
-
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
|
|
29192
|
-
|
|
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;
|
|
29193
29274
|
}
|
|
29194
|
-
|
|
29195
|
-
|
|
29196
|
-
|
|
29197
|
-
|
|
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
|
-
|
|
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;
|
|
29224
29329
|
}
|
|
29225
29330
|
|
|
29226
|
-
var
|
|
29227
|
-
|
|
29228
|
-
|
|
29229
|
-
};
|
|
29230
|
-
|
|
29231
|
-
|
|
29232
|
-
|
|
29233
|
-
|
|
29234
|
-
|
|
29235
|
-
|
|
29236
|
-
|
|
29237
|
-
|
|
29238
|
-
|
|
29239
|
-
|
|
29240
|
-
|
|
29241
|
-
|
|
29242
|
-
|
|
29243
|
-
|
|
29244
|
-
|
|
29245
|
-
}
|
|
29246
|
-
function
|
|
29247
|
-
|
|
29248
|
-
|
|
29249
|
-
|
|
29250
|
-
|
|
29251
|
-
|
|
29252
|
-
|
|
29253
|
-
|
|
29254
|
-
|
|
29255
|
-
|
|
29256
|
-
}
|
|
29257
|
-
function
|
|
29258
|
-
|
|
29259
|
-
|
|
29260
|
-
|
|
29261
|
-
|
|
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
|
-
|
|
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
|
|
29288
29415
|
});
|
|
29289
|
-
|
|
29290
|
-
|
|
29291
|
-
|
|
29292
|
-
|
|
29293
|
-
|
|
29294
|
-
|
|
29295
|
-
|
|
29296
|
-
|
|
29297
|
-
|
|
29298
|
-
|
|
29299
|
-
}
|
|
29300
|
-
function _iterableToArray(iter) {
|
|
29301
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
29302
|
-
}
|
|
29303
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
29304
|
-
if (!o) return;
|
|
29305
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
29306
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
29307
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
29308
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
29309
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
29310
|
-
}
|
|
29311
|
-
function _arrayLikeToArray(arr, len) {
|
|
29312
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
29313
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
29314
|
-
return arr2;
|
|
29315
|
-
}
|
|
29316
|
-
function _nonIterableSpread() {
|
|
29317
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
29318
|
-
}
|
|
29319
|
-
|
|
29320
|
-
var jsonDiff = new Diff();
|
|
29321
|
-
// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
|
|
29322
|
-
// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
|
|
29323
|
-
jsonDiff.useLongestToken = true;
|
|
29324
|
-
jsonDiff.tokenize = lineDiff.tokenize;
|
|
29325
|
-
jsonDiff.castInput = function (value, options) {
|
|
29326
|
-
var undefinedReplacement = options.undefinedReplacement,
|
|
29327
|
-
_options$stringifyRep = options.stringifyReplacer,
|
|
29328
|
-
stringifyReplacer = _options$stringifyRep === void 0 ? function (k, v) {
|
|
29329
|
-
return typeof v === 'undefined' ? undefinedReplacement : v;
|
|
29330
|
-
} : _options$stringifyRep;
|
|
29331
|
-
return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), stringifyReplacer, ' ');
|
|
29332
|
-
};
|
|
29333
|
-
jsonDiff.equals = function (left, right, options) {
|
|
29334
|
-
return Diff.prototype.equals.call(jsonDiff, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
|
|
29335
|
-
};
|
|
29336
|
-
|
|
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();
|
|
29337
29426
|
// This function handles the presence of circular references by bailing out when encountering an
|
|
29338
29427
|
// object that is already on the "stack" of items being processed. Accepts an optional replacer
|
|
29339
29428
|
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
29340
|
-
|
|
29341
|
-
|
|
29342
|
-
|
|
29343
|
-
|
|
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
|
-
|
|
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();
|
|
29377
29474
|
}
|
|
29378
|
-
|
|
29379
|
-
|
|
29380
|
-
_key = sortedKeys[i];
|
|
29381
|
-
canonicalizedObj[_key] = canonicalize(obj[_key], stack, replacementStack, replacer, _key);
|
|
29475
|
+
else {
|
|
29476
|
+
canonicalizedObj = obj;
|
|
29382
29477
|
}
|
|
29383
|
-
|
|
29384
|
-
replacementStack.pop();
|
|
29385
|
-
} else {
|
|
29386
|
-
canonicalizedObj = obj;
|
|
29387
|
-
}
|
|
29388
|
-
return canonicalizedObj;
|
|
29478
|
+
return canonicalizedObj;
|
|
29389
29479
|
}
|
|
29390
29480
|
|
|
29391
|
-
var
|
|
29392
|
-
|
|
29393
|
-
|
|
29394
|
-
};
|
|
29395
|
-
|
|
29396
|
-
|
|
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);
|
|
29397
29524
|
};
|
|
29398
29525
|
|
|
29399
|
-
|
|
29400
|
-
|
|
29401
|
-
|
|
29402
|
-
|
|
29403
|
-
|
|
29404
|
-
|
|
29405
|
-
|
|
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;
|
|
29406
29534
|
};
|
|
29407
|
-
|
|
29408
|
-
|
|
29409
|
-
options.context = 4;
|
|
29410
|
-
}
|
|
29411
|
-
if (options.newlineIsToken) {
|
|
29412
|
-
throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');
|
|
29413
|
-
}
|
|
29414
|
-
if (!options.callback) {
|
|
29415
|
-
return diffLinesResultToPatch(diffLines(oldStr, newStr, options));
|
|
29416
|
-
} else {
|
|
29417
|
-
var _options = options,
|
|
29418
|
-
_callback = _options.callback;
|
|
29419
|
-
diffLines(oldStr, newStr, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
29420
|
-
callback: function callback(diff) {
|
|
29421
|
-
var patch = diffLinesResultToPatch(diff);
|
|
29422
|
-
_callback(patch);
|
|
29423
|
-
}
|
|
29424
|
-
}));
|
|
29425
|
-
}
|
|
29426
|
-
function diffLinesResultToPatch(diff) {
|
|
29427
|
-
// STEP 1: Build up the patch with no "" lines and with the arrays
|
|
29428
|
-
// of lines containing trailing newline characters. We'll tidy up later...
|
|
29535
|
+
return __assign$1.apply(this, arguments);
|
|
29536
|
+
};
|
|
29429
29537
|
|
|
29430
|
-
|
|
29431
|
-
|
|
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 = {};
|
|
29432
29553
|
}
|
|
29433
|
-
|
|
29434
|
-
|
|
29435
|
-
lines: []
|
|
29436
|
-
}); // Append an empty value to make cleanup easier
|
|
29437
|
-
|
|
29438
|
-
function contextLines(lines) {
|
|
29439
|
-
return lines.map(function (entry) {
|
|
29440
|
-
return ' ' + entry;
|
|
29441
|
-
});
|
|
29554
|
+
else if (typeof options === 'function') {
|
|
29555
|
+
optionsObj = { callback: options };
|
|
29442
29556
|
}
|
|
29443
|
-
|
|
29444
|
-
|
|
29445
|
-
|
|
29446
|
-
|
|
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
|
-
if (current.added) {
|
|
29474
|
-
newLine += lines.length;
|
|
29475
|
-
} else {
|
|
29476
|
-
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;
|
|
29477
29587
|
}
|
|
29478
|
-
|
|
29479
|
-
|
|
29480
|
-
|
|
29481
|
-
|
|
29482
|
-
|
|
29483
|
-
|
|
29484
|
-
|
|
29485
|
-
|
|
29486
|
-
|
|
29487
|
-
|
|
29488
|
-
|
|
29489
|
-
|
|
29490
|
-
|
|
29491
|
-
|
|
29492
|
-
|
|
29493
|
-
|
|
29494
|
-
|
|
29495
|
-
|
|
29496
|
-
|
|
29497
|
-
|
|
29498
|
-
|
|
29499
|
-
|
|
29500
|
-
|
|
29501
|
-
|
|
29502
|
-
|
|
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
|
+
}
|
|
29503
29656
|
}
|
|
29504
|
-
|
|
29505
|
-
|
|
29506
|
-
|
|
29507
|
-
|
|
29508
|
-
|
|
29509
|
-
|
|
29510
|
-
|
|
29511
|
-
|
|
29512
|
-
|
|
29513
|
-
|
|
29514
|
-
|
|
29515
|
-
|
|
29516
|
-
|
|
29517
|
-
if (hunk.lines[_i2].endsWith('\n')) {
|
|
29518
|
-
hunk.lines[_i2] = hunk.lines[_i2].slice(0, -1);
|
|
29519
|
-
} else {
|
|
29520
|
-
hunk.lines.splice(_i2 + 1, 0, '\');
|
|
29521
|
-
_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
|
+
}
|
|
29522
29670
|
}
|
|
29523
|
-
|
|
29671
|
+
return {
|
|
29672
|
+
oldFileName: oldFileName, newFileName: newFileName,
|
|
29673
|
+
oldHeader: oldHeader, newHeader: newHeader,
|
|
29674
|
+
hunks: hunks
|
|
29675
|
+
};
|
|
29524
29676
|
}
|
|
29525
|
-
return {
|
|
29526
|
-
oldFileName: oldFileName,
|
|
29527
|
-
newFileName: newFileName,
|
|
29528
|
-
oldHeader: oldHeader,
|
|
29529
|
-
newHeader: newHeader,
|
|
29530
|
-
hunks: hunks
|
|
29531
|
-
};
|
|
29532
|
-
}
|
|
29533
29677
|
}
|
|
29534
|
-
|
|
29535
|
-
|
|
29536
|
-
|
|
29537
|
-
|
|
29538
|
-
|
|
29539
|
-
|
|
29540
|
-
|
|
29541
|
-
}
|
|
29542
|
-
ret.push('===================================================================');
|
|
29543
|
-
ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader));
|
|
29544
|
-
ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader));
|
|
29545
|
-
for (var i = 0; i < diff.hunks.length; i++) {
|
|
29546
|
-
var hunk = diff.hunks[i];
|
|
29547
|
-
// Unified Diff Format quirk: If the chunk size is 0,
|
|
29548
|
-
// the first number is one lower than one would expect.
|
|
29549
|
-
// https://www.artima.com/weblogs/viewpost.jsp?thread=164293
|
|
29550
|
-
if (hunk.oldLines === 0) {
|
|
29551
|
-
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');
|
|
29552
29685
|
}
|
|
29553
|
-
|
|
29554
|
-
|
|
29686
|
+
var ret = [];
|
|
29687
|
+
if (patch.oldFileName == patch.newFileName) {
|
|
29688
|
+
ret.push('Index: ' + patch.oldFileName);
|
|
29555
29689
|
}
|
|
29556
|
-
ret.push('
|
|
29557
|
-
ret.push.
|
|
29558
|
-
|
|
29559
|
-
|
|
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';
|
|
29560
29713
|
}
|
|
29561
29714
|
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
29562
|
-
|
|
29563
|
-
|
|
29564
|
-
options = {
|
|
29565
|
-
callback: options
|
|
29566
|
-
};
|
|
29567
|
-
}
|
|
29568
|
-
if (!((_options2 = options) !== null && _options2 !== void 0 && _options2.callback)) {
|
|
29569
|
-
var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
29570
|
-
if (!patchObj) {
|
|
29571
|
-
return;
|
|
29715
|
+
if (typeof options === 'function') {
|
|
29716
|
+
options = { callback: options };
|
|
29572
29717
|
}
|
|
29573
|
-
|
|
29574
|
-
|
|
29575
|
-
var _options3 = options,
|
|
29576
|
-
_callback2 = _options3.callback;
|
|
29577
|
-
structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, _objectSpread2(_objectSpread2({}, options), {}, {
|
|
29578
|
-
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);
|
|
29579
29720
|
if (!patchObj) {
|
|
29580
|
-
|
|
29581
|
-
} else {
|
|
29582
|
-
_callback2(formatPatch(patchObj));
|
|
29721
|
+
return;
|
|
29583
29722
|
}
|
|
29584
|
-
|
|
29585
|
-
}
|
|
29586
|
-
|
|
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
|
+
}
|
|
29587
29736
|
}
|
|
29588
|
-
|
|
29589
29737
|
/**
|
|
29590
29738
|
* Split `text` into an array of lines, including the trailing newline character (where present)
|
|
29591
29739
|
*/
|
|
29592
29740
|
function splitLines(text) {
|
|
29593
|
-
|
|
29594
|
-
|
|
29595
|
-
|
|
29596
|
-
|
|
29597
|
-
|
|
29598
|
-
|
|
29599
|
-
|
|
29600
|
-
|
|
29601
|
-
|
|
29602
|
-
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;
|
|
29603
29750
|
}
|
|
29604
29751
|
|
|
29605
29752
|
/* eslint-disable no-multi-assign */
|
|
@@ -56706,4 +56853,4 @@ var srcExports = requireSrc();
|
|
|
56706
56853
|
var tinylr = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
|
|
56707
56854
|
|
|
56708
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 };
|
|
56709
|
-
//# sourceMappingURL=vendor-
|
|
56856
|
+
//# sourceMappingURL=vendor-DxEOke6B.mjs.map
|