@xyne/xyne-cli-linux-x64 0.4.3 → 0.4.5
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/node_modules/@opentui/core/index-4kfx7p6q.js +47 -9
- package/package.json +1 -1
- package/xyne-linux-x64 +0 -0
- package/node_modules/@opentui/core/node_modules/diff/CONTRIBUTING.md +0 -28
- package/node_modules/@opentui/core/node_modules/diff/LICENSE +0 -29
- package/node_modules/@opentui/core/node_modules/diff/README.md +0 -378
- package/node_modules/@opentui/core/node_modules/diff/dist/diff.js +0 -1674
- package/node_modules/@opentui/core/node_modules/diff/dist/diff.min.js +0 -1
- package/node_modules/@opentui/core/node_modules/diff/eslint.config.mjs +0 -182
- package/node_modules/@opentui/core/node_modules/diff/libcjs/convert/dmp.d.ts +0 -8
- package/node_modules/@opentui/core/node_modules/diff/libcjs/convert/dmp.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/convert/dmp.js +0 -24
- package/node_modules/@opentui/core/node_modules/diff/libcjs/convert/xml.d.ts +0 -6
- package/node_modules/@opentui/core/node_modules/diff/libcjs/convert/xml.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/convert/xml.js +0 -34
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/array.d.ts +0 -19
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/array.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/array.js +0 -40
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/base.d.ts +0 -20
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/base.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/base.js +0 -265
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/character.d.ts +0 -19
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/character.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/character.js +0 -31
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/css.d.ts +0 -18
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/css.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/css.js +0 -34
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/json.d.ts +0 -24
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/json.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/json.js +0 -105
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/line.d.ts +0 -24
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/line.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/line.js +0 -89
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/sentence.d.ts +0 -21
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/sentence.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/sentence.js +0 -67
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/word.d.ts +0 -35
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/word.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/diff/word.js +0 -307
- package/node_modules/@opentui/core/node_modules/diff/libcjs/index.d.ts +0 -20
- package/node_modules/@opentui/core/node_modules/diff/libcjs/index.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/index.js +0 -61
- package/node_modules/@opentui/core/node_modules/diff/libcjs/package.json +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/apply.d.ts +0 -62
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/apply.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/apply.js +0 -267
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/create.d.ts +0 -100
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/create.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/create.js +0 -223
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/line-endings.d.ts +0 -17
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/line-endings.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/line-endings.js +0 -61
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/parse.d.ts +0 -8
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/parse.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/parse.js +0 -133
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/reverse.d.ts +0 -9
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/reverse.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/patch/reverse.js +0 -37
- package/node_modules/@opentui/core/node_modules/diff/libcjs/types.d.ts +0 -213
- package/node_modules/@opentui/core/node_modules/diff/libcjs/types.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/types.js +0 -2
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/array.d.ts +0 -3
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/array.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/array.js +0 -21
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/distance-iterator.d.ts +0 -2
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/distance-iterator.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/distance-iterator.js +0 -40
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/params.d.ts +0 -4
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/params.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/params.js +0 -17
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/string.d.ts +0 -18
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/string.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libcjs/util/string.js +0 -141
- package/node_modules/@opentui/core/node_modules/diff/libesm/convert/dmp.d.ts +0 -8
- package/node_modules/@opentui/core/node_modules/diff/libesm/convert/dmp.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/convert/dmp.js +0 -21
- package/node_modules/@opentui/core/node_modules/diff/libesm/convert/xml.d.ts +0 -6
- package/node_modules/@opentui/core/node_modules/diff/libesm/convert/xml.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/convert/xml.js +0 -31
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/array.d.ts +0 -19
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/array.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/array.js +0 -16
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/base.d.ts +0 -20
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/base.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/base.js +0 -253
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/character.d.ts +0 -19
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/character.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/character.js +0 -7
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/css.d.ts +0 -18
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/css.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/css.js +0 -10
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/json.d.ts +0 -24
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/json.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/json.js +0 -78
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/line.d.ts +0 -24
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/line.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/line.js +0 -65
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/sentence.d.ts +0 -21
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/sentence.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/sentence.js +0 -43
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/word.d.ts +0 -35
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/word.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/diff/word.js +0 -276
- package/node_modules/@opentui/core/node_modules/diff/libesm/index.d.ts +0 -20
- package/node_modules/@opentui/core/node_modules/diff/libesm/index.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/index.js +0 -30
- package/node_modules/@opentui/core/node_modules/diff/libesm/package.json +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/apply.d.ts +0 -62
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/apply.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/apply.js +0 -257
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/create.d.ts +0 -100
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/create.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/create.js +0 -201
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/line-endings.d.ts +0 -17
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/line-endings.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/line-endings.js +0 -44
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/parse.d.ts +0 -8
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/parse.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/parse.js +0 -130
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/reverse.d.ts +0 -9
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/reverse.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/patch/reverse.js +0 -23
- package/node_modules/@opentui/core/node_modules/diff/libesm/types.d.ts +0 -213
- package/node_modules/@opentui/core/node_modules/diff/libesm/types.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/types.js +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/array.d.ts +0 -3
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/array.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/array.js +0 -17
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/distance-iterator.d.ts +0 -2
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/distance-iterator.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/distance-iterator.js +0 -37
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/params.d.ts +0 -4
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/params.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/params.js +0 -14
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/string.d.ts +0 -18
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/string.d.ts.map +0 -1
- package/node_modules/@opentui/core/node_modules/diff/libesm/util/string.js +0 -128
- package/node_modules/@opentui/core/node_modules/diff/package.json +0 -131
- package/node_modules/@opentui/core/node_modules/diff/release-notes.md +0 -397
- package/node_modules/@opentui/core/node_modules/marked/LICENSE.md +0 -44
- package/node_modules/@opentui/core/node_modules/marked/README.md +0 -107
- package/node_modules/@opentui/core/node_modules/marked/bin/main.js +0 -283
- package/node_modules/@opentui/core/node_modules/marked/bin/marked.js +0 -16
- package/node_modules/@opentui/core/node_modules/marked/lib/marked.d.ts +0 -756
- package/node_modules/@opentui/core/node_modules/marked/lib/marked.esm.js +0 -72
- package/node_modules/@opentui/core/node_modules/marked/lib/marked.esm.js.map +0 -7
- package/node_modules/@opentui/core/node_modules/marked/lib/marked.umd.js +0 -74
- package/node_modules/@opentui/core/node_modules/marked/lib/marked.umd.js.map +0 -7
- package/node_modules/@opentui/core/node_modules/marked/man/marked.1 +0 -113
- package/node_modules/@opentui/core/node_modules/marked/man/marked.1.md +0 -93
- package/node_modules/@opentui/core/node_modules/marked/package.json +0 -103
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Diff = /** @class */ (function () {
|
|
4
|
-
function Diff() {
|
|
5
|
-
}
|
|
6
|
-
Diff.prototype.diff = function (oldStr, newStr,
|
|
7
|
-
// Type below is not accurate/complete - see above for full possibilities - but it compiles
|
|
8
|
-
options) {
|
|
9
|
-
if (options === void 0) { options = {}; }
|
|
10
|
-
var callback;
|
|
11
|
-
if (typeof options === 'function') {
|
|
12
|
-
callback = options;
|
|
13
|
-
options = {};
|
|
14
|
-
}
|
|
15
|
-
else if ('callback' in options) {
|
|
16
|
-
callback = options.callback;
|
|
17
|
-
}
|
|
18
|
-
// Allow subclasses to massage the input prior to running
|
|
19
|
-
var oldString = this.castInput(oldStr, options);
|
|
20
|
-
var newString = this.castInput(newStr, options);
|
|
21
|
-
var oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
22
|
-
var newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
23
|
-
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
24
|
-
};
|
|
25
|
-
Diff.prototype.diffWithOptionsObj = function (oldTokens, newTokens, options, callback) {
|
|
26
|
-
var _this = this;
|
|
27
|
-
var _a;
|
|
28
|
-
var done = function (value) {
|
|
29
|
-
value = _this.postProcess(value, options);
|
|
30
|
-
if (callback) {
|
|
31
|
-
setTimeout(function () { callback(value); }, 0);
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
return value;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var newLen = newTokens.length, oldLen = oldTokens.length;
|
|
39
|
-
var editLength = 1;
|
|
40
|
-
var maxEditLength = newLen + oldLen;
|
|
41
|
-
if (options.maxEditLength != null) {
|
|
42
|
-
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
43
|
-
}
|
|
44
|
-
var maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
45
|
-
var abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
46
|
-
var bestPath = [{ oldPos: -1, lastComponent: undefined }];
|
|
47
|
-
// Seed editLength = 0, i.e. the content starts with the same values
|
|
48
|
-
var newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
49
|
-
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
50
|
-
// Identity per the equality and tokenizer
|
|
51
|
-
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
52
|
-
}
|
|
53
|
-
// Once we hit the right edge of the edit graph on some diagonal k, we can
|
|
54
|
-
// definitely reach the end of the edit graph in no more than k edits, so
|
|
55
|
-
// there's no point in considering any moves to diagonal k+1 any more (from
|
|
56
|
-
// which we're guaranteed to need at least k+1 more edits).
|
|
57
|
-
// Similarly, once we've reached the bottom of the edit graph, there's no
|
|
58
|
-
// point considering moves to lower diagonals.
|
|
59
|
-
// We record this fact by setting minDiagonalToConsider and
|
|
60
|
-
// maxDiagonalToConsider to some finite value once we've hit the edge of
|
|
61
|
-
// the edit graph.
|
|
62
|
-
// This optimization is not faithful to the original algorithm presented in
|
|
63
|
-
// Myers's paper, which instead pointlessly extends D-paths off the end of
|
|
64
|
-
// the edit graph - see page 7 of Myers's paper which notes this point
|
|
65
|
-
// explicitly and illustrates it with a diagram. This has major performance
|
|
66
|
-
// implications for some common scenarios. For instance, to compute a diff
|
|
67
|
-
// where the new text simply appends d characters on the end of the
|
|
68
|
-
// original text of length n, the true Myers algorithm will take O(n+d^2)
|
|
69
|
-
// time while this optimization needs only O(n+d) time.
|
|
70
|
-
var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
71
|
-
// Main worker method. checks all permutations of a given edit length for acceptance.
|
|
72
|
-
var execEditLength = function () {
|
|
73
|
-
for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
74
|
-
var basePath = void 0;
|
|
75
|
-
var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
76
|
-
if (removePath) {
|
|
77
|
-
// No one else is going to attempt to use this value, clear it
|
|
78
|
-
// @ts-expect-error - perf optimisation. This type-violating value will never be read.
|
|
79
|
-
bestPath[diagonalPath - 1] = undefined;
|
|
80
|
-
}
|
|
81
|
-
var canAdd = false;
|
|
82
|
-
if (addPath) {
|
|
83
|
-
// what newPos will be after we do an insertion:
|
|
84
|
-
var addPathNewPos = addPath.oldPos - diagonalPath;
|
|
85
|
-
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
86
|
-
}
|
|
87
|
-
var canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
88
|
-
if (!canAdd && !canRemove) {
|
|
89
|
-
// If this path is a terminal then prune
|
|
90
|
-
// @ts-expect-error - perf optimisation. This type-violating value will never be read.
|
|
91
|
-
bestPath[diagonalPath] = undefined;
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
// Select the diagonal that we want to branch from. We select the prior
|
|
95
|
-
// path whose position in the old string is the farthest from the origin
|
|
96
|
-
// and does not pass the bounds of the diff graph
|
|
97
|
-
if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {
|
|
98
|
-
basePath = _this.addToPath(addPath, true, false, 0, options);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
basePath = _this.addToPath(removePath, false, true, 1, options);
|
|
102
|
-
}
|
|
103
|
-
newPos = _this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
104
|
-
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
105
|
-
// If we have hit the end of both strings, then we are done
|
|
106
|
-
return done(_this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
bestPath[diagonalPath] = basePath;
|
|
110
|
-
if (basePath.oldPos + 1 >= oldLen) {
|
|
111
|
-
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
112
|
-
}
|
|
113
|
-
if (newPos + 1 >= newLen) {
|
|
114
|
-
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
editLength++;
|
|
119
|
-
};
|
|
120
|
-
// Performs the length of edit iteration. Is a bit fugly as this has to support the
|
|
121
|
-
// sync and async mode which is never fun. Loops over execEditLength until a value
|
|
122
|
-
// is produced, or until the edit length exceeds options.maxEditLength (if given),
|
|
123
|
-
// in which case it will return undefined.
|
|
124
|
-
if (callback) {
|
|
125
|
-
(function exec() {
|
|
126
|
-
setTimeout(function () {
|
|
127
|
-
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
128
|
-
return callback(undefined);
|
|
129
|
-
}
|
|
130
|
-
if (!execEditLength()) {
|
|
131
|
-
exec();
|
|
132
|
-
}
|
|
133
|
-
}, 0);
|
|
134
|
-
}());
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
138
|
-
var ret = execEditLength();
|
|
139
|
-
if (ret) {
|
|
140
|
-
return ret;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
Diff.prototype.addToPath = function (path, added, removed, oldPosInc, options) {
|
|
146
|
-
var last = path.lastComponent;
|
|
147
|
-
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
148
|
-
return {
|
|
149
|
-
oldPos: path.oldPos + oldPosInc,
|
|
150
|
-
lastComponent: { count: last.count + 1, added: added, removed: removed, previousComponent: last.previousComponent }
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
return {
|
|
155
|
-
oldPos: path.oldPos + oldPosInc,
|
|
156
|
-
lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
Diff.prototype.extractCommon = function (basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
161
|
-
var newLen = newTokens.length, oldLen = oldTokens.length;
|
|
162
|
-
var oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
163
|
-
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
164
|
-
newPos++;
|
|
165
|
-
oldPos++;
|
|
166
|
-
commonCount++;
|
|
167
|
-
if (options.oneChangePerToken) {
|
|
168
|
-
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (commonCount && !options.oneChangePerToken) {
|
|
172
|
-
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
173
|
-
}
|
|
174
|
-
basePath.oldPos = oldPos;
|
|
175
|
-
return newPos;
|
|
176
|
-
};
|
|
177
|
-
Diff.prototype.equals = function (left, right, options) {
|
|
178
|
-
if (options.comparator) {
|
|
179
|
-
return options.comparator(left, right);
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
return left === right
|
|
183
|
-
|| (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
Diff.prototype.removeEmpty = function (array) {
|
|
187
|
-
var ret = [];
|
|
188
|
-
for (var i = 0; i < array.length; i++) {
|
|
189
|
-
if (array[i]) {
|
|
190
|
-
ret.push(array[i]);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return ret;
|
|
194
|
-
};
|
|
195
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
196
|
-
Diff.prototype.castInput = function (value, options) {
|
|
197
|
-
return value;
|
|
198
|
-
};
|
|
199
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
200
|
-
Diff.prototype.tokenize = function (value, options) {
|
|
201
|
-
return Array.from(value);
|
|
202
|
-
};
|
|
203
|
-
Diff.prototype.join = function (chars) {
|
|
204
|
-
// Assumes ValueT is string, which is the case for most subclasses.
|
|
205
|
-
// When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)
|
|
206
|
-
// Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF
|
|
207
|
-
// assume tokens and values are strings, but not completely - is weird and janky.
|
|
208
|
-
return chars.join('');
|
|
209
|
-
};
|
|
210
|
-
Diff.prototype.postProcess = function (changeObjects,
|
|
211
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
212
|
-
options) {
|
|
213
|
-
return changeObjects;
|
|
214
|
-
};
|
|
215
|
-
Object.defineProperty(Diff.prototype, "useLongestToken", {
|
|
216
|
-
get: function () {
|
|
217
|
-
return false;
|
|
218
|
-
},
|
|
219
|
-
enumerable: false,
|
|
220
|
-
configurable: true
|
|
221
|
-
});
|
|
222
|
-
Diff.prototype.buildValues = function (lastComponent, newTokens, oldTokens) {
|
|
223
|
-
// First we convert our linked list of components in reverse order to an
|
|
224
|
-
// array in the right order:
|
|
225
|
-
var components = [];
|
|
226
|
-
var nextComponent;
|
|
227
|
-
while (lastComponent) {
|
|
228
|
-
components.push(lastComponent);
|
|
229
|
-
nextComponent = lastComponent.previousComponent;
|
|
230
|
-
delete lastComponent.previousComponent;
|
|
231
|
-
lastComponent = nextComponent;
|
|
232
|
-
}
|
|
233
|
-
components.reverse();
|
|
234
|
-
var componentLen = components.length;
|
|
235
|
-
var componentPos = 0, newPos = 0, oldPos = 0;
|
|
236
|
-
for (; componentPos < componentLen; componentPos++) {
|
|
237
|
-
var component = components[componentPos];
|
|
238
|
-
if (!component.removed) {
|
|
239
|
-
if (!component.added && this.useLongestToken) {
|
|
240
|
-
var value = newTokens.slice(newPos, newPos + component.count);
|
|
241
|
-
value = value.map(function (value, i) {
|
|
242
|
-
var oldValue = oldTokens[oldPos + i];
|
|
243
|
-
return oldValue.length > value.length ? oldValue : value;
|
|
244
|
-
});
|
|
245
|
-
component.value = this.join(value);
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
249
|
-
}
|
|
250
|
-
newPos += component.count;
|
|
251
|
-
// Common case
|
|
252
|
-
if (!component.added) {
|
|
253
|
-
oldPos += component.count;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
else {
|
|
257
|
-
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
258
|
-
oldPos += component.count;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return components;
|
|
262
|
-
};
|
|
263
|
-
return Diff;
|
|
264
|
-
}());
|
|
265
|
-
exports.default = Diff;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Diff from './base.js';
|
|
2
|
-
import type { ChangeObject, CallbackOptionAbortable, CallbackOptionNonabortable, DiffCallbackNonabortable, DiffCharsOptionsAbortable, DiffCharsOptionsNonabortable } from '../types.js';
|
|
3
|
-
declare class CharacterDiff extends Diff<string, string> {
|
|
4
|
-
}
|
|
5
|
-
export declare const characterDiff: CharacterDiff;
|
|
6
|
-
/**
|
|
7
|
-
* diffs two blocks of text, treating each character as a token.
|
|
8
|
-
*
|
|
9
|
-
* ("Characters" here means Unicode code points - the elements you get when you loop over a string with a `for ... of ...` loop.)
|
|
10
|
-
*
|
|
11
|
-
* @returns a list of change objects.
|
|
12
|
-
*/
|
|
13
|
-
export declare function diffChars(oldStr: string, newStr: string, options: DiffCallbackNonabortable<string>): undefined;
|
|
14
|
-
export declare function diffChars(oldStr: string, newStr: string, options: DiffCharsOptionsAbortable & CallbackOptionAbortable<string>): undefined;
|
|
15
|
-
export declare function diffChars(oldStr: string, newStr: string, options: DiffCharsOptionsNonabortable & CallbackOptionNonabortable<string>): undefined;
|
|
16
|
-
export declare function diffChars(oldStr: string, newStr: string, options: DiffCharsOptionsAbortable): ChangeObject<string>[] | undefined;
|
|
17
|
-
export declare function diffChars(oldStr: string, newStr: string, options?: DiffCharsOptionsNonabortable): ChangeObject<string>[];
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=character.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"character.d.ts","sourceRoot":"","sources":["../../src/diff/character.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,4BAA4B,EAAC,MAAM,aAAa,CAAC;AAEvL,cAAM,aAAc,SAAQ,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;CAAG;AAEnD,eAAO,MAAM,aAAa,eAAsB,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACxC,SAAS,CAAC;AACb,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yBAAyB,GAAG,uBAAuB,CAAC,MAAM,CAAC,GACnE,SAAS,CAAA;AACZ,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,4BAA4B,GAAG,0BAA0B,CAAC,MAAM,CAAC,GACzE,SAAS,CAAA;AACZ,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yBAAyB,GACjC,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAA;AACrC,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,4BAA4B,GACrC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAA"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.characterDiff = void 0;
|
|
19
|
-
exports.diffChars = diffChars;
|
|
20
|
-
var base_js_1 = require("./base.js");
|
|
21
|
-
var CharacterDiff = /** @class */ (function (_super) {
|
|
22
|
-
__extends(CharacterDiff, _super);
|
|
23
|
-
function CharacterDiff() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
-
}
|
|
26
|
-
return CharacterDiff;
|
|
27
|
-
}(base_js_1.default));
|
|
28
|
-
exports.characterDiff = new CharacterDiff();
|
|
29
|
-
function diffChars(oldStr, newStr, options) {
|
|
30
|
-
return exports.characterDiff.diff(oldStr, newStr, options);
|
|
31
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import Diff from './base.js';
|
|
2
|
-
import type { ChangeObject, CallbackOptionAbortable, CallbackOptionNonabortable, DiffCallbackNonabortable, DiffCssOptionsAbortable, DiffCssOptionsNonabortable } from '../types.js';
|
|
3
|
-
declare class CssDiff extends Diff<string, string> {
|
|
4
|
-
tokenize(value: string): string[];
|
|
5
|
-
}
|
|
6
|
-
export declare const cssDiff: CssDiff;
|
|
7
|
-
/**
|
|
8
|
-
* diffs two blocks of text, comparing CSS tokens.
|
|
9
|
-
*
|
|
10
|
-
* @returns a list of change objects.
|
|
11
|
-
*/
|
|
12
|
-
export declare function diffCss(oldStr: string, newStr: string, options: DiffCallbackNonabortable<string>): undefined;
|
|
13
|
-
export declare function diffCss(oldStr: string, newStr: string, options: DiffCssOptionsAbortable & CallbackOptionAbortable<string>): undefined;
|
|
14
|
-
export declare function diffCss(oldStr: string, newStr: string, options: DiffCssOptionsNonabortable & CallbackOptionNonabortable<string>): undefined;
|
|
15
|
-
export declare function diffCss(oldStr: string, newStr: string, options: DiffCssOptionsAbortable): ChangeObject<string>[] | undefined;
|
|
16
|
-
export declare function diffCss(oldStr: string, newStr: string, options?: DiffCssOptionsNonabortable): ChangeObject<string>[];
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=css.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/diff/css.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,0BAA0B,EAAC,MAAM,aAAa,CAAC;AAEnL,cAAM,OAAQ,SAAQ,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM;CAGvB;AAED,eAAO,MAAM,OAAO,SAAgB,CAAC;AAErC;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACxC,SAAS,CAAC;AACb,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,GAAG,uBAAuB,CAAC,MAAM,CAAC,GACjE,SAAS,CAAA;AACZ,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,0BAA0B,GAAG,0BAA0B,CAAC,MAAM,CAAC,GACvE,SAAS,CAAA;AACZ,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,uBAAuB,GAC/B,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAA;AACrC,wBAAgB,OAAO,CACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,0BAA0B,GACnC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.cssDiff = void 0;
|
|
19
|
-
exports.diffCss = diffCss;
|
|
20
|
-
var base_js_1 = require("./base.js");
|
|
21
|
-
var CssDiff = /** @class */ (function (_super) {
|
|
22
|
-
__extends(CssDiff, _super);
|
|
23
|
-
function CssDiff() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
-
}
|
|
26
|
-
CssDiff.prototype.tokenize = function (value) {
|
|
27
|
-
return value.split(/([{}:;,]|\s+)/);
|
|
28
|
-
};
|
|
29
|
-
return CssDiff;
|
|
30
|
-
}(base_js_1.default));
|
|
31
|
-
exports.cssDiff = new CssDiff();
|
|
32
|
-
function diffCss(oldStr, newStr, options) {
|
|
33
|
-
return exports.cssDiff.diff(oldStr, newStr, options);
|
|
34
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Diff from './base.js';
|
|
2
|
-
import type { ChangeObject, CallbackOptionAbortable, CallbackOptionNonabortable, DiffCallbackNonabortable, DiffJsonOptionsAbortable, DiffJsonOptionsNonabortable } from '../types.js';
|
|
3
|
-
import { tokenize } from './line.js';
|
|
4
|
-
declare class JsonDiff extends Diff<string, string, string | object> {
|
|
5
|
-
get useLongestToken(): boolean;
|
|
6
|
-
tokenize: typeof tokenize;
|
|
7
|
-
castInput(value: string | object, options: DiffJsonOptionsNonabortable | DiffJsonOptionsAbortable): string;
|
|
8
|
-
equals(left: string, right: string, options: DiffJsonOptionsNonabortable | DiffJsonOptionsAbortable): boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const jsonDiff: JsonDiff;
|
|
11
|
-
/**
|
|
12
|
-
* diffs two JSON-serializable objects by first serializing them to prettily-formatted JSON and then treating each line of the JSON as a token.
|
|
13
|
-
* Object properties are ordered alphabetically in the serialized JSON, so the order of properties in the objects being compared doesn't affect the result.
|
|
14
|
-
*
|
|
15
|
-
* @returns a list of change objects.
|
|
16
|
-
*/
|
|
17
|
-
export declare function diffJson(oldStr: string | object, newStr: string | object, options: DiffCallbackNonabortable<string>): undefined;
|
|
18
|
-
export declare function diffJson(oldStr: string | object, newStr: string | object, options: DiffJsonOptionsAbortable & CallbackOptionAbortable<string>): undefined;
|
|
19
|
-
export declare function diffJson(oldStr: string | object, newStr: string | object, options: DiffJsonOptionsNonabortable & CallbackOptionNonabortable<string>): undefined;
|
|
20
|
-
export declare function diffJson(oldStr: string | object, newStr: string | object, options: DiffJsonOptionsAbortable): ChangeObject<string>[] | undefined;
|
|
21
|
-
export declare function diffJson(oldStr: string | object, newStr: string | object, options?: DiffJsonOptionsNonabortable): ChangeObject<string>[];
|
|
22
|
-
export declare function canonicalize(obj: any, stack: Array<any> | null, replacementStack: Array<any> | null, replacer: (k: string, v: any) => any, key?: string): any;
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=json.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/diff/json.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AACrL,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,cAAM,QAAS,SAAQ,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1D,IAAI,eAAe,YAIlB;IAED,QAAQ,kBAAY;IAEpB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,2BAA2B,GAAG,wBAAwB;IAMjG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,2BAA2B,GAAG,wBAAwB;CAGpG;AAED,eAAO,MAAM,QAAQ,UAAiB,CAAC;AAEvC;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACxC,SAAS,CAAC;AACb,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,OAAO,EAAE,wBAAwB,GAAG,uBAAuB,CAAC,MAAM,CAAC,GAClE,SAAS,CAAA;AACZ,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,OAAO,EAAE,2BAA2B,GAAG,0BAA0B,CAAC,MAAM,CAAC,GACxE,SAAS,CAAA;AACZ,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,OAAO,EAAE,wBAAwB,GAChC,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAA;AACrC,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,OAAO,CAAC,EAAE,2BAA2B,GACpC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAA;AAQzB,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,gBAAgB,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAC7D,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,KAAK,GAAG,EACpC,GAAG,CAAC,EAAE,MAAM,OA0Db"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.jsonDiff = void 0;
|
|
19
|
-
exports.diffJson = diffJson;
|
|
20
|
-
exports.canonicalize = canonicalize;
|
|
21
|
-
var base_js_1 = require("./base.js");
|
|
22
|
-
var line_js_1 = require("./line.js");
|
|
23
|
-
var JsonDiff = /** @class */ (function (_super) {
|
|
24
|
-
__extends(JsonDiff, _super);
|
|
25
|
-
function JsonDiff() {
|
|
26
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
-
_this.tokenize = line_js_1.tokenize;
|
|
28
|
-
return _this;
|
|
29
|
-
}
|
|
30
|
-
Object.defineProperty(JsonDiff.prototype, "useLongestToken", {
|
|
31
|
-
get: function () {
|
|
32
|
-
// Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
|
|
33
|
-
// dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
|
|
34
|
-
return true;
|
|
35
|
-
},
|
|
36
|
-
enumerable: false,
|
|
37
|
-
configurable: true
|
|
38
|
-
});
|
|
39
|
-
JsonDiff.prototype.castInput = function (value, options) {
|
|
40
|
-
var undefinedReplacement = options.undefinedReplacement, _a = options.stringifyReplacer, stringifyReplacer = _a === void 0 ? function (k, v) { return typeof v === 'undefined' ? undefinedReplacement : v; } : _a;
|
|
41
|
-
return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, ' ');
|
|
42
|
-
};
|
|
43
|
-
JsonDiff.prototype.equals = function (left, right, options) {
|
|
44
|
-
return _super.prototype.equals.call(this, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
|
|
45
|
-
};
|
|
46
|
-
return JsonDiff;
|
|
47
|
-
}(base_js_1.default));
|
|
48
|
-
exports.jsonDiff = new JsonDiff();
|
|
49
|
-
function diffJson(oldStr, newStr, options) {
|
|
50
|
-
return exports.jsonDiff.diff(oldStr, newStr, options);
|
|
51
|
-
}
|
|
52
|
-
// This function handles the presence of circular references by bailing out when encountering an
|
|
53
|
-
// object that is already on the "stack" of items being processed. Accepts an optional replacer
|
|
54
|
-
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
55
|
-
stack = stack || [];
|
|
56
|
-
replacementStack = replacementStack || [];
|
|
57
|
-
if (replacer) {
|
|
58
|
-
obj = replacer(key === undefined ? '' : key, obj);
|
|
59
|
-
}
|
|
60
|
-
var i;
|
|
61
|
-
for (i = 0; i < stack.length; i += 1) {
|
|
62
|
-
if (stack[i] === obj) {
|
|
63
|
-
return replacementStack[i];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
var canonicalizedObj;
|
|
67
|
-
if ('[object Array]' === Object.prototype.toString.call(obj)) {
|
|
68
|
-
stack.push(obj);
|
|
69
|
-
canonicalizedObj = new Array(obj.length);
|
|
70
|
-
replacementStack.push(canonicalizedObj);
|
|
71
|
-
for (i = 0; i < obj.length; i += 1) {
|
|
72
|
-
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
|
|
73
|
-
}
|
|
74
|
-
stack.pop();
|
|
75
|
-
replacementStack.pop();
|
|
76
|
-
return canonicalizedObj;
|
|
77
|
-
}
|
|
78
|
-
if (obj && obj.toJSON) {
|
|
79
|
-
obj = obj.toJSON();
|
|
80
|
-
}
|
|
81
|
-
if (typeof obj === 'object' && obj !== null) {
|
|
82
|
-
stack.push(obj);
|
|
83
|
-
canonicalizedObj = {};
|
|
84
|
-
replacementStack.push(canonicalizedObj);
|
|
85
|
-
var sortedKeys = [];
|
|
86
|
-
var key_1;
|
|
87
|
-
for (key_1 in obj) {
|
|
88
|
-
/* istanbul ignore else */
|
|
89
|
-
if (Object.prototype.hasOwnProperty.call(obj, key_1)) {
|
|
90
|
-
sortedKeys.push(key_1);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
sortedKeys.sort();
|
|
94
|
-
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
95
|
-
key_1 = sortedKeys[i];
|
|
96
|
-
canonicalizedObj[key_1] = canonicalize(obj[key_1], stack, replacementStack, replacer, key_1);
|
|
97
|
-
}
|
|
98
|
-
stack.pop();
|
|
99
|
-
replacementStack.pop();
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
canonicalizedObj = obj;
|
|
103
|
-
}
|
|
104
|
-
return canonicalizedObj;
|
|
105
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import Diff from './base.js';
|
|
2
|
-
import type { ChangeObject, CallbackOptionAbortable, CallbackOptionNonabortable, DiffCallbackNonabortable, DiffLinesOptionsAbortable, DiffLinesOptionsNonabortable } from '../types.js';
|
|
3
|
-
declare class LineDiff extends Diff<string, string> {
|
|
4
|
-
tokenize: typeof tokenize;
|
|
5
|
-
equals(left: string, right: string, options: DiffLinesOptionsAbortable | DiffLinesOptionsNonabortable): boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare const lineDiff: LineDiff;
|
|
8
|
-
/**
|
|
9
|
-
* diffs two blocks of text, treating each line as a token.
|
|
10
|
-
* @returns a list of change objects.
|
|
11
|
-
*/
|
|
12
|
-
export declare function diffLines(oldStr: string, newStr: string, options: DiffCallbackNonabortable<string>): undefined;
|
|
13
|
-
export declare function diffLines(oldStr: string, newStr: string, options: DiffLinesOptionsAbortable & CallbackOptionAbortable<string>): undefined;
|
|
14
|
-
export declare function diffLines(oldStr: string, newStr: string, options: DiffLinesOptionsNonabortable & CallbackOptionNonabortable<string>): undefined;
|
|
15
|
-
export declare function diffLines(oldStr: string, newStr: string, options: DiffLinesOptionsAbortable): ChangeObject<string>[] | undefined;
|
|
16
|
-
export declare function diffLines(oldStr: string, newStr: string, options?: DiffLinesOptionsNonabortable): ChangeObject<string>[];
|
|
17
|
-
export declare function diffTrimmedLines(oldStr: string, newStr: string, options: DiffCallbackNonabortable<string>): undefined;
|
|
18
|
-
export declare function diffTrimmedLines(oldStr: string, newStr: string, options: DiffLinesOptionsAbortable & CallbackOptionAbortable<string>): undefined;
|
|
19
|
-
export declare function diffTrimmedLines(oldStr: string, newStr: string, options: DiffLinesOptionsNonabortable & CallbackOptionNonabortable<string>): undefined;
|
|
20
|
-
export declare function diffTrimmedLines(oldStr: string, newStr: string, options: DiffLinesOptionsAbortable): ChangeObject<string>[] | undefined;
|
|
21
|
-
export declare function diffTrimmedLines(oldStr: string, newStr: string, options?: DiffLinesOptionsNonabortable): ChangeObject<string>[];
|
|
22
|
-
export declare function tokenize(value: string, options: DiffLinesOptionsAbortable | DiffLinesOptionsNonabortable): string[];
|
|
23
|
-
export {};
|
|
24
|
-
//# sourceMappingURL=line.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../src/diff/line.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,EAAE,YAAY,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,4BAA4B,EAAC,MAAM,aAAa,CAAC;AAGvL,cAAM,QAAS,SAAQ,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;IACzC,QAAQ,kBAAY;IAEpB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,4BAA4B;CAyBtG;AAED,eAAO,MAAM,QAAQ,UAAiB,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACxC,SAAS,CAAC;AACb,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yBAAyB,GAAG,uBAAuB,CAAC,MAAM,CAAC,GACnE,SAAS,CAAA;AACZ,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,4BAA4B,GAAG,0BAA0B,CAAC,MAAM,CAAC,GACzE,SAAS,CAAA;AACZ,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yBAAyB,GACjC,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAA;AACrC,wBAAgB,SAAS,CACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,4BAA4B,GACrC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAA;AAWzB,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACxC,SAAS,CAAC;AACb,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yBAAyB,GAAG,uBAAuB,CAAC,MAAM,CAAC,GACnE,SAAS,CAAA;AACZ,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,4BAA4B,GAAG,0BAA0B,CAAC,MAAM,CAAC,GACzE,SAAS,CAAA;AACZ,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,yBAAyB,GACjC,YAAY,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,CAAA;AACrC,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,4BAA4B,GACrC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAA;AAOzB,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB,GAAG,4BAA4B,YA0BxG"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.lineDiff = void 0;
|
|
19
|
-
exports.diffLines = diffLines;
|
|
20
|
-
exports.diffTrimmedLines = diffTrimmedLines;
|
|
21
|
-
exports.tokenize = tokenize;
|
|
22
|
-
var base_js_1 = require("./base.js");
|
|
23
|
-
var params_js_1 = require("../util/params.js");
|
|
24
|
-
var LineDiff = /** @class */ (function (_super) {
|
|
25
|
-
__extends(LineDiff, _super);
|
|
26
|
-
function LineDiff() {
|
|
27
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
28
|
-
_this.tokenize = tokenize;
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
LineDiff.prototype.equals = function (left, right, options) {
|
|
32
|
-
// If we're ignoring whitespace, we need to normalise lines by stripping
|
|
33
|
-
// whitespace before checking equality. (This has an annoying interaction
|
|
34
|
-
// with newlineIsToken that requires special handling: if newlines get their
|
|
35
|
-
// own token, then we DON'T want to trim the *newline* tokens down to empty
|
|
36
|
-
// strings, since this would cause us to treat whitespace-only line content
|
|
37
|
-
// as equal to a separator between lines, which would be weird and
|
|
38
|
-
// inconsistent with the documented behavior of the options.)
|
|
39
|
-
if (options.ignoreWhitespace) {
|
|
40
|
-
if (!options.newlineIsToken || !left.includes('\n')) {
|
|
41
|
-
left = left.trim();
|
|
42
|
-
}
|
|
43
|
-
if (!options.newlineIsToken || !right.includes('\n')) {
|
|
44
|
-
right = right.trim();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
48
|
-
if (left.endsWith('\n')) {
|
|
49
|
-
left = left.slice(0, -1);
|
|
50
|
-
}
|
|
51
|
-
if (right.endsWith('\n')) {
|
|
52
|
-
right = right.slice(0, -1);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return _super.prototype.equals.call(this, left, right, options);
|
|
56
|
-
};
|
|
57
|
-
return LineDiff;
|
|
58
|
-
}(base_js_1.default));
|
|
59
|
-
exports.lineDiff = new LineDiff();
|
|
60
|
-
function diffLines(oldStr, newStr, options) {
|
|
61
|
-
return exports.lineDiff.diff(oldStr, newStr, options);
|
|
62
|
-
}
|
|
63
|
-
function diffTrimmedLines(oldStr, newStr, options) {
|
|
64
|
-
options = (0, params_js_1.generateOptions)(options, { ignoreWhitespace: true });
|
|
65
|
-
return exports.lineDiff.diff(oldStr, newStr, options);
|
|
66
|
-
}
|
|
67
|
-
// Exported standalone so it can be used from jsonDiff too.
|
|
68
|
-
function tokenize(value, options) {
|
|
69
|
-
if (options.stripTrailingCr) {
|
|
70
|
-
// remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
|
|
71
|
-
value = value.replace(/\r\n/g, '\n');
|
|
72
|
-
}
|
|
73
|
-
var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
74
|
-
// Ignore the final empty token that occurs if the string ends with a new line
|
|
75
|
-
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
76
|
-
linesAndNewlines.pop();
|
|
77
|
-
}
|
|
78
|
-
// Merge the content and line separators into single tokens
|
|
79
|
-
for (var i = 0; i < linesAndNewlines.length; i++) {
|
|
80
|
-
var line = linesAndNewlines[i];
|
|
81
|
-
if (i % 2 && !options.newlineIsToken) {
|
|
82
|
-
retLines[retLines.length - 1] += line;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
retLines.push(line);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return retLines;
|
|
89
|
-
}
|