diff2html 3.4.37 → 3.4.39
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/README.md +2 -2
- package/bundles/css/diff2html.min.css +1 -1
- package/bundles/js/diff2html-ui-base.min.js +1 -1
- package/bundles/js/diff2html-ui-slim.min.js +1 -1
- package/bundles/js/diff2html-ui.min.js +1 -1
- package/bundles/js/diff2html.min.js +1 -1
- package/lib/diff-parser.js +55 -65
- package/lib/diff-parser.js.map +1 -1
- package/lib/diff2html-templates.d.ts +1 -1
- package/lib/diff2html-templates.d.ts.map +1 -1
- package/lib/diff2html-templates.js +2 -24
- package/lib/diff2html-templates.js.map +1 -1
- package/lib/diff2html.js +16 -54
- package/lib/diff2html.js.map +1 -1
- package/lib/file-list-renderer.js +15 -39
- package/lib/file-list-renderer.js.map +1 -1
- package/lib/hoganjs-utils.js +22 -59
- package/lib/hoganjs-utils.js.map +1 -1
- package/lib/line-by-line-renderer.d.ts +3 -3
- package/lib/line-by-line-renderer.d.ts.map +1 -1
- package/lib/line-by-line-renderer.js +75 -114
- package/lib/line-by-line-renderer.js.map +1 -1
- package/lib/rematch.d.ts +3 -3
- package/lib/rematch.d.ts.map +1 -1
- package/lib/rematch.js +28 -31
- package/lib/rematch.js.map +1 -1
- package/lib/render-utils.d.ts +2 -2
- package/lib/render-utils.d.ts.map +1 -1
- package/lib/render-utils.js +44 -79
- package/lib/render-utils.js.map +1 -1
- package/lib/side-by-side-renderer.d.ts +3 -3
- package/lib/side-by-side-renderer.d.ts.map +1 -1
- package/lib/side-by-side-renderer.js +83 -122
- package/lib/side-by-side-renderer.js.map +1 -1
- package/lib/src/diff-parser.d.ts +10 -0
- package/lib/src/diff-parser.d.ts.map +1 -0
- package/lib/src/diff2html-templates.d.ts +7 -0
- package/lib/src/diff2html-templates.d.ts.map +1 -0
- package/lib/src/diff2html.d.ts +23 -0
- package/lib/src/diff2html.d.ts.map +1 -0
- package/lib/src/file-list-renderer.d.ts +4 -0
- package/lib/src/file-list-renderer.d.ts.map +1 -0
- package/lib/src/hoganjs-utils.d.ts +20 -0
- package/lib/src/hoganjs-utils.d.ts.map +1 -0
- package/lib/src/line-by-line-renderer.d.ts +50 -0
- package/lib/src/line-by-line-renderer.d.ts.map +1 -0
- package/lib/src/rematch.d.ts +11 -0
- package/lib/src/rematch.d.ts.map +1 -0
- package/lib/src/render-utils.d.ts +35 -0
- package/lib/src/render-utils.d.ts.map +1 -0
- package/lib/src/side-by-side-renderer.d.ts +50 -0
- package/lib/src/side-by-side-renderer.d.ts.map +1 -0
- package/lib/src/types.d.ts +75 -0
- package/lib/src/types.d.ts.map +1 -0
- package/lib/src/ui/js/diff2html-ui-base.d.ts +50 -0
- package/lib/src/ui/js/diff2html-ui-base.d.ts.map +1 -0
- package/lib/src/ui/js/diff2html-ui-slim.d.ts +8 -0
- package/lib/src/ui/js/diff2html-ui-slim.d.ts.map +1 -0
- package/lib/src/ui/js/diff2html-ui.d.ts +8 -0
- package/lib/src/ui/js/diff2html-ui.d.ts.map +1 -0
- package/lib/src/ui/js/highlight.js-helpers.d.ts +12 -0
- package/lib/src/ui/js/highlight.js-helpers.d.ts.map +1 -0
- package/lib/src/ui/js/highlight.js-slim.d.ts +3 -0
- package/lib/src/ui/js/highlight.js-slim.d.ts.map +1 -0
- package/lib/src/utils.d.ts +4 -0
- package/lib/src/utils.d.ts.map +1 -0
- package/lib/types.d.ts +6 -6
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/ui/js/diff2html-ui-base.js +61 -75
- package/lib/ui/js/diff2html-ui-base.js.map +1 -1
- package/lib/ui/js/diff2html-ui-slim.d.ts +2 -1
- package/lib/ui/js/diff2html-ui-slim.d.ts.map +1 -1
- package/lib/ui/js/diff2html-ui-slim.js +6 -24
- package/lib/ui/js/diff2html-ui-slim.js.map +1 -1
- package/lib/ui/js/diff2html-ui.d.ts +2 -1
- package/lib/ui/js/diff2html-ui.d.ts.map +1 -1
- package/lib/ui/js/diff2html-ui.js +7 -27
- package/lib/ui/js/diff2html-ui.js.map +1 -1
- package/lib/ui/js/highlight.js-helpers.d.ts +1 -1
- package/lib/ui/js/highlight.js-helpers.d.ts.map +1 -1
- package/lib/ui/js/highlight.js-helpers.js +17 -17
- package/lib/ui/js/highlight.js-helpers.js.map +1 -1
- package/lib/ui/js/highlight.js-slim.js +53 -55
- package/lib/ui/js/highlight.js-slim.js.map +1 -1
- package/lib/utils.js +4 -4
- package/lib/utils.js.map +1 -1
- package/lib/website/main.d.ts +2 -0
- package/lib/website/main.d.ts.map +1 -0
- package/lib/website/templates/pages/demo/demo.d.ts +6 -0
- package/lib/website/templates/pages/demo/demo.d.ts.map +1 -0
- package/lib/website/templates/pages/index/index.d.ts +4 -0
- package/lib/website/templates/pages/index/index.d.ts.map +1 -0
- package/lib-esm/diff-parser.js +53 -63
- package/lib-esm/diff-parser.js.map +1 -1
- package/lib-esm/diff2html-templates.d.ts +1 -1
- package/lib-esm/diff2html-templates.d.ts.map +1 -1
- package/lib-esm/diff2html-templates.js +1 -1
- package/lib-esm/diff2html-templates.js.map +1 -1
- package/lib-esm/diff2html.js +9 -22
- package/lib-esm/diff2html.js.map +1 -1
- package/lib-esm/file-list-renderer.js +13 -15
- package/lib-esm/file-list-renderer.js.map +1 -1
- package/lib-esm/hoganjs-utils.js +19 -35
- package/lib-esm/hoganjs-utils.js.map +1 -1
- package/lib-esm/line-by-line-renderer.d.ts +3 -3
- package/lib-esm/line-by-line-renderer.d.ts.map +1 -1
- package/lib-esm/line-by-line-renderer.js +71 -89
- package/lib-esm/line-by-line-renderer.js.map +1 -1
- package/lib-esm/rematch.d.ts +3 -3
- package/lib-esm/rematch.d.ts.map +1 -1
- package/lib-esm/rematch.js +28 -31
- package/lib-esm/rematch.js.map +1 -1
- package/lib-esm/render-utils.d.ts +2 -2
- package/lib-esm/render-utils.d.ts.map +1 -1
- package/lib-esm/render-utils.js +41 -54
- package/lib-esm/render-utils.js.map +1 -1
- package/lib-esm/side-by-side-renderer.d.ts +3 -3
- package/lib-esm/side-by-side-renderer.d.ts.map +1 -1
- package/lib-esm/side-by-side-renderer.js +79 -97
- package/lib-esm/side-by-side-renderer.js.map +1 -1
- package/lib-esm/types.d.ts +6 -6
- package/lib-esm/types.d.ts.map +1 -1
- package/lib-esm/types.js +3 -3
- package/lib-esm/types.js.map +1 -1
- package/lib-esm/ui/js/diff2html-ui-base.js +59 -74
- package/lib-esm/ui/js/diff2html-ui-base.js.map +1 -1
- package/lib-esm/ui/js/diff2html-ui-slim.d.ts +2 -1
- package/lib-esm/ui/js/diff2html-ui-slim.d.ts.map +1 -1
- package/lib-esm/ui/js/diff2html-ui-slim.js +4 -23
- package/lib-esm/ui/js/diff2html-ui-slim.js.map +1 -1
- package/lib-esm/ui/js/diff2html-ui.d.ts +2 -1
- package/lib-esm/ui/js/diff2html-ui.d.ts.map +1 -1
- package/lib-esm/ui/js/diff2html-ui.js +4 -23
- package/lib-esm/ui/js/diff2html-ui.js.map +1 -1
- package/lib-esm/ui/js/highlight.js-helpers.d.ts +1 -1
- package/lib-esm/ui/js/highlight.js-helpers.d.ts.map +1 -1
- package/lib-esm/ui/js/highlight.js-helpers.js +17 -17
- package/lib-esm/ui/js/highlight.js-helpers.js.map +1 -1
- package/lib-esm/ui/js/highlight.js-slim.js +1 -1
- package/lib-esm/ui/js/highlight.js-slim.js.map +1 -1
- package/lib-esm/utils.js +4 -4
- package/lib-esm/utils.js.map +1 -1
- package/package.json +40 -40
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import * as Rematch from './rematch';
|
|
13
2
|
import * as renderUtils from './render-utils';
|
|
14
3
|
import { LineType, } from './types';
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (config === void 0) { config = {}; }
|
|
4
|
+
export const defaultSideBySideRendererConfig = Object.assign(Object.assign({}, renderUtils.defaultRenderConfig), { renderNothingWhenEmpty: false, matchingMaxComparisons: 2500, maxLineSizeInBlockForComparison: 200 });
|
|
5
|
+
const genericTemplatesPath = 'generic';
|
|
6
|
+
const baseTemplatesPath = 'side-by-side';
|
|
7
|
+
const iconsBaseTemplatesPath = 'icon';
|
|
8
|
+
const tagsBaseTemplatesPath = 'tag';
|
|
9
|
+
export default class SideBySideRenderer {
|
|
10
|
+
constructor(hoganUtils, config = {}) {
|
|
23
11
|
this.hoganUtils = hoganUtils;
|
|
24
|
-
this.config =
|
|
12
|
+
this.config = Object.assign(Object.assign({}, defaultSideBySideRendererConfig), config);
|
|
25
13
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var diffs;
|
|
14
|
+
render(diffFiles) {
|
|
15
|
+
const diffsHtml = diffFiles
|
|
16
|
+
.map(file => {
|
|
17
|
+
let diffs;
|
|
31
18
|
if (file.blocks.length) {
|
|
32
|
-
diffs =
|
|
19
|
+
diffs = this.generateFileHtml(file);
|
|
33
20
|
}
|
|
34
21
|
else {
|
|
35
|
-
diffs =
|
|
22
|
+
diffs = this.generateEmptyDiff();
|
|
36
23
|
}
|
|
37
|
-
return
|
|
24
|
+
return this.makeFileDiffHtml(file, diffs);
|
|
38
25
|
})
|
|
39
26
|
.join('\n');
|
|
40
27
|
return this.hoganUtils.render(genericTemplatesPath, 'wrapper', { content: diffsHtml });
|
|
41
|
-
}
|
|
42
|
-
|
|
28
|
+
}
|
|
29
|
+
makeFileDiffHtml(file, diffs) {
|
|
43
30
|
if (this.config.renderNothingWhenEmpty && Array.isArray(file.blocks) && file.blocks.length === 0)
|
|
44
31
|
return '';
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
const fileDiffTemplate = this.hoganUtils.template(baseTemplatesPath, 'file-diff');
|
|
33
|
+
const filePathTemplate = this.hoganUtils.template(genericTemplatesPath, 'file-path');
|
|
34
|
+
const fileIconTemplate = this.hoganUtils.template(iconsBaseTemplatesPath, 'file');
|
|
35
|
+
const fileTagTemplate = this.hoganUtils.template(tagsBaseTemplatesPath, renderUtils.getFileIcon(file));
|
|
49
36
|
return fileDiffTemplate.render({
|
|
50
37
|
file: file,
|
|
51
38
|
fileHtmlId: renderUtils.getHtmlId(file),
|
|
@@ -57,8 +44,8 @@ var SideBySideRenderer = (function () {
|
|
|
57
44
|
fileTag: fileTagTemplate,
|
|
58
45
|
}),
|
|
59
46
|
});
|
|
60
|
-
}
|
|
61
|
-
|
|
47
|
+
}
|
|
48
|
+
generateEmptyDiff() {
|
|
62
49
|
return {
|
|
63
50
|
right: '',
|
|
64
51
|
left: this.hoganUtils.render(genericTemplatesPath, 'empty-diff', {
|
|
@@ -66,30 +53,27 @@ var SideBySideRenderer = (function () {
|
|
|
66
53
|
CSSLineClass: renderUtils.CSSLineClass,
|
|
67
54
|
}),
|
|
68
55
|
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var matcher = Rematch.newMatcherFn(Rematch.newDistanceFn(function (e) { return renderUtils.deconstructLine(e.content, file.isCombined).content; }));
|
|
56
|
+
}
|
|
57
|
+
generateFileHtml(file) {
|
|
58
|
+
const matcher = Rematch.newMatcherFn(Rematch.newDistanceFn((e) => renderUtils.deconstructLine(e.content, file.isCombined).content));
|
|
73
59
|
return file.blocks
|
|
74
|
-
.map(
|
|
75
|
-
|
|
76
|
-
left:
|
|
77
|
-
right:
|
|
60
|
+
.map(block => {
|
|
61
|
+
const fileHtml = {
|
|
62
|
+
left: this.makeHeaderHtml(block.header, file),
|
|
63
|
+
right: this.makeHeaderHtml(''),
|
|
78
64
|
};
|
|
79
|
-
|
|
80
|
-
var contextLines = _a[0], oldLines = _a[1], newLines = _a[2];
|
|
65
|
+
this.applyLineGroupping(block).forEach(([contextLines, oldLines, newLines]) => {
|
|
81
66
|
if (oldLines.length && newLines.length && !contextLines.length) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var _b = _this.processChangedLines(file.isCombined, oldLines, newLines), left = _b.left, right = _b.right;
|
|
67
|
+
this.applyRematchMatching(oldLines, newLines, matcher).map(([oldLines, newLines]) => {
|
|
68
|
+
const { left, right } = this.processChangedLines(file.isCombined, oldLines, newLines);
|
|
85
69
|
fileHtml.left += left;
|
|
86
70
|
fileHtml.right += right;
|
|
87
71
|
});
|
|
88
72
|
}
|
|
89
73
|
else if (contextLines.length) {
|
|
90
|
-
contextLines.forEach(
|
|
91
|
-
|
|
92
|
-
|
|
74
|
+
contextLines.forEach(line => {
|
|
75
|
+
const { prefix, content } = renderUtils.deconstructLine(line.content, file.isCombined);
|
|
76
|
+
const { left, right } = this.generateLineHtml({
|
|
93
77
|
type: renderUtils.CSSLineClass.CONTEXT,
|
|
94
78
|
prefix: prefix,
|
|
95
79
|
content: content,
|
|
@@ -99,13 +83,13 @@ var SideBySideRenderer = (function () {
|
|
|
99
83
|
prefix: prefix,
|
|
100
84
|
content: content,
|
|
101
85
|
number: line.newNumber,
|
|
102
|
-
})
|
|
86
|
+
});
|
|
103
87
|
fileHtml.left += left;
|
|
104
88
|
fileHtml.right += right;
|
|
105
89
|
});
|
|
106
90
|
}
|
|
107
91
|
else if (oldLines.length || newLines.length) {
|
|
108
|
-
|
|
92
|
+
const { left, right } = this.processChangedLines(file.isCombined, oldLines, newLines);
|
|
109
93
|
fileHtml.left += left;
|
|
110
94
|
fileHtml.right += right;
|
|
111
95
|
}
|
|
@@ -115,16 +99,16 @@ var SideBySideRenderer = (function () {
|
|
|
115
99
|
});
|
|
116
100
|
return fileHtml;
|
|
117
101
|
})
|
|
118
|
-
.reduce(
|
|
102
|
+
.reduce((accomulated, html) => {
|
|
119
103
|
return { left: accomulated.left + html.left, right: accomulated.right + html.right };
|
|
120
104
|
}, { left: '', right: '' });
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (
|
|
127
|
-
|
|
105
|
+
}
|
|
106
|
+
applyLineGroupping(block) {
|
|
107
|
+
const blockLinesGroups = [];
|
|
108
|
+
let oldLines = [];
|
|
109
|
+
let newLines = [];
|
|
110
|
+
for (let i = 0; i < block.lines.length; i++) {
|
|
111
|
+
const diffLine = block.lines[i];
|
|
128
112
|
if ((diffLine.type !== LineType.INSERT && newLines.length) ||
|
|
129
113
|
(diffLine.type === LineType.CONTEXT && oldLines.length > 0)) {
|
|
130
114
|
blockLinesGroups.push([[], oldLines, newLines]);
|
|
@@ -150,76 +134,74 @@ var SideBySideRenderer = (function () {
|
|
|
150
134
|
newLines = [];
|
|
151
135
|
}
|
|
152
136
|
return blockLinesGroups;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
137
|
+
}
|
|
138
|
+
applyRematchMatching(oldLines, newLines, matcher) {
|
|
139
|
+
const comparisons = oldLines.length * newLines.length;
|
|
140
|
+
const maxLineSizeInBlock = Math.max.apply(null, [0].concat(oldLines.concat(newLines).map(elem => elem.content.length)));
|
|
141
|
+
const doMatching = comparisons < this.config.matchingMaxComparisons &&
|
|
158
142
|
maxLineSizeInBlock < this.config.maxLineSizeInBlockForComparison &&
|
|
159
143
|
(this.config.matching === 'lines' || this.config.matching === 'words');
|
|
160
144
|
return doMatching ? matcher(oldLines, newLines) : [[oldLines, newLines]];
|
|
161
|
-
}
|
|
162
|
-
|
|
145
|
+
}
|
|
146
|
+
makeHeaderHtml(blockHeader, file) {
|
|
163
147
|
return this.hoganUtils.render(genericTemplatesPath, 'block-header', {
|
|
164
148
|
CSSLineClass: renderUtils.CSSLineClass,
|
|
165
149
|
blockHeader: (file === null || file === void 0 ? void 0 : file.isTooBig) ? blockHeader : renderUtils.escapeForHtml(blockHeader),
|
|
166
150
|
lineClass: 'd2h-code-side-linenumber',
|
|
167
151
|
contentClass: 'd2h-code-side-line',
|
|
168
152
|
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
153
|
+
}
|
|
154
|
+
processChangedLines(isCombined, oldLines, newLines) {
|
|
155
|
+
const fileHtml = {
|
|
172
156
|
right: '',
|
|
173
157
|
left: '',
|
|
174
158
|
};
|
|
175
|
-
|
|
176
|
-
for (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
159
|
+
const maxLinesNumber = Math.max(oldLines.length, newLines.length);
|
|
160
|
+
for (let i = 0; i < maxLinesNumber; i++) {
|
|
161
|
+
const oldLine = oldLines[i];
|
|
162
|
+
const newLine = newLines[i];
|
|
163
|
+
const diff = oldLine !== undefined && newLine !== undefined
|
|
180
164
|
? renderUtils.diffHighlight(oldLine.content, newLine.content, isCombined, this.config)
|
|
181
165
|
: undefined;
|
|
182
|
-
|
|
183
|
-
?
|
|
166
|
+
const preparedOldLine = oldLine !== undefined && oldLine.oldNumber !== undefined
|
|
167
|
+
? Object.assign(Object.assign({}, (diff !== undefined
|
|
184
168
|
? {
|
|
185
169
|
prefix: diff.oldLine.prefix,
|
|
186
170
|
content: diff.oldLine.content,
|
|
187
171
|
type: renderUtils.CSSLineClass.DELETE_CHANGES,
|
|
188
172
|
}
|
|
189
|
-
:
|
|
190
|
-
|
|
191
|
-
?
|
|
173
|
+
: Object.assign(Object.assign({}, renderUtils.deconstructLine(oldLine.content, isCombined)), { type: renderUtils.toCSSClass(oldLine.type) }))), { number: oldLine.oldNumber }) : undefined;
|
|
174
|
+
const preparedNewLine = newLine !== undefined && newLine.newNumber !== undefined
|
|
175
|
+
? Object.assign(Object.assign({}, (diff !== undefined
|
|
192
176
|
? {
|
|
193
177
|
prefix: diff.newLine.prefix,
|
|
194
178
|
content: diff.newLine.content,
|
|
195
179
|
type: renderUtils.CSSLineClass.INSERT_CHANGES,
|
|
196
180
|
}
|
|
197
|
-
:
|
|
198
|
-
|
|
181
|
+
: Object.assign(Object.assign({}, renderUtils.deconstructLine(newLine.content, isCombined)), { type: renderUtils.toCSSClass(newLine.type) }))), { number: newLine.newNumber }) : undefined;
|
|
182
|
+
const { left, right } = this.generateLineHtml(preparedOldLine, preparedNewLine);
|
|
199
183
|
fileHtml.left += left;
|
|
200
184
|
fileHtml.right += right;
|
|
201
185
|
}
|
|
202
186
|
return fileHtml;
|
|
203
|
-
}
|
|
204
|
-
|
|
187
|
+
}
|
|
188
|
+
generateLineHtml(oldLine, newLine) {
|
|
205
189
|
return {
|
|
206
190
|
left: this.generateSingleHtml(oldLine),
|
|
207
191
|
right: this.generateSingleHtml(newLine),
|
|
208
192
|
};
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
193
|
+
}
|
|
194
|
+
generateSingleHtml(line) {
|
|
195
|
+
const lineClass = 'd2h-code-side-linenumber';
|
|
196
|
+
const contentClass = 'd2h-code-side-line';
|
|
213
197
|
return this.hoganUtils.render(genericTemplatesPath, 'line', {
|
|
214
|
-
type: (line === null || line === void 0 ? void 0 : line.type) ||
|
|
215
|
-
lineClass: line !== undefined ? lineClass :
|
|
216
|
-
contentClass: line !== undefined ? contentClass :
|
|
198
|
+
type: (line === null || line === void 0 ? void 0 : line.type) || `${renderUtils.CSSLineClass.CONTEXT} d2h-emptyplaceholder`,
|
|
199
|
+
lineClass: line !== undefined ? lineClass : `${lineClass} d2h-code-side-emptyplaceholder`,
|
|
200
|
+
contentClass: line !== undefined ? contentClass : `${contentClass} d2h-code-side-emptyplaceholder`,
|
|
217
201
|
prefix: (line === null || line === void 0 ? void 0 : line.prefix) === ' ' ? ' ' : line === null || line === void 0 ? void 0 : line.prefix,
|
|
218
202
|
content: line === null || line === void 0 ? void 0 : line.content,
|
|
219
203
|
lineNumber: line === null || line === void 0 ? void 0 : line.number,
|
|
220
204
|
});
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
}());
|
|
224
|
-
export default SideBySideRenderer;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
225
207
|
//# sourceMappingURL=side-by-side-renderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"side-by-side-renderer.js","sourceRoot":"","sources":["../src/side-by-side-renderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"side-by-side-renderer.js","sourceRoot":"","sources":["../src/side-by-side-renderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AACrC,OAAO,KAAK,WAAW,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAEL,QAAQ,GAOT,MAAM,SAAS,CAAC;AAQjB,MAAM,CAAC,MAAM,+BAA+B,mCACvC,WAAW,CAAC,mBAAmB,KAClC,sBAAsB,EAAE,KAAK,EAC7B,sBAAsB,EAAE,IAAI,EAC5B,+BAA+B,EAAE,GAAG,GACrC,CAAC;AAEF,MAAM,oBAAoB,GAAG,SAAS,CAAC;AACvC,MAAM,iBAAiB,GAAG,cAAc,CAAC;AACzC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AACtC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAIrC,YAAY,UAAwB,EAAE,SAAmC,EAAE;QACzE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,mCAAQ,+BAA+B,GAAK,MAAM,CAAE,CAAC;IAClE,CAAC;IAED,MAAM,CAAC,SAAqB;QAC1B,MAAM,SAAS,GAAG,SAAS;aACxB,GAAG,CAAC,IAAI,CAAC,EAAE;YACV,IAAI,KAAK,CAAC;YACV,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBACtB,K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types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type DiffLineParts = {
|
|
2
2
|
prefix: string;
|
|
3
3
|
content: string;
|
|
4
4
|
};
|
|
@@ -22,10 +22,10 @@ export interface DiffLineContext {
|
|
|
22
22
|
oldNumber: number;
|
|
23
23
|
newNumber: number;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
25
|
+
export type DiffLineContent = {
|
|
26
26
|
content: string;
|
|
27
27
|
};
|
|
28
|
-
export
|
|
28
|
+
export type DiffLine = (DiffLineDeleted | DiffLineInserted | DiffLineContext) & DiffLineContent;
|
|
29
29
|
export interface DiffBlock {
|
|
30
30
|
oldStartLine: number;
|
|
31
31
|
oldStartLine2?: number;
|
|
@@ -60,15 +60,15 @@ export interface DiffFile extends DiffFileName {
|
|
|
60
60
|
checksumAfter?: string;
|
|
61
61
|
mode?: string;
|
|
62
62
|
}
|
|
63
|
-
export
|
|
63
|
+
export type OutputFormatType = 'line-by-line' | 'side-by-side';
|
|
64
64
|
export declare const OutputFormatType: {
|
|
65
65
|
[_: string]: OutputFormatType;
|
|
66
66
|
};
|
|
67
|
-
export
|
|
67
|
+
export type LineMatchingType = 'lines' | 'words' | 'none';
|
|
68
68
|
export declare const LineMatchingType: {
|
|
69
69
|
[_: string]: LineMatchingType;
|
|
70
70
|
};
|
|
71
|
-
export
|
|
71
|
+
export type DiffStyleType = 'word' | 'char';
|
|
72
72
|
export declare const DiffStyleType: {
|
|
73
73
|
[_: string]: DiffStyleType;
|
|
74
74
|
};
|
package/lib-esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAA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,EAAE,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,cAAc,CAAC;AAE/D,eAAO,MAAM,gBAAgB,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAG7D,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAE1D,eAAO,MAAM,gBAAgB,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAI7D,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAAA;CAGvD,CAAC"}
|
package/lib-esm/types.js
CHANGED
|
@@ -4,16 +4,16 @@ export var LineType;
|
|
|
4
4
|
LineType["DELETE"] = "delete";
|
|
5
5
|
LineType["CONTEXT"] = "context";
|
|
6
6
|
})(LineType || (LineType = {}));
|
|
7
|
-
export
|
|
7
|
+
export const OutputFormatType = {
|
|
8
8
|
LINE_BY_LINE: 'line-by-line',
|
|
9
9
|
SIDE_BY_SIDE: 'side-by-side',
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export const LineMatchingType = {
|
|
12
12
|
LINES: 'lines',
|
|
13
13
|
WORDS: 'words',
|
|
14
14
|
NONE: 'none',
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export const DiffStyleType = {
|
|
17
17
|
WORD: 'word',
|
|
18
18
|
CHAR: 'char',
|
|
19
19
|
};
|
package/lib-esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;AACrB,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAiED,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,6BAAiB,CAAA;IACjB,+BAAmB,CAAA;AACrB,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAiED,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,YAAY,EAAE,cAAc;IAC5B,YAAY,EAAE,cAAc;CAC7B,CAAC;AAIF,MAAM,CAAC,MAAM,gBAAgB,GAAsC;IACjE,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;CACb,CAAC;AAIF,MAAM,CAAC,MAAM,aAAa,GAAmC;IAC3D,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;CACb,CAAC"}
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { closeTags, nodeStream, mergeStreams, getLanguage } from './highlight.js-helpers';
|
|
13
2
|
import { html, defaultDiff2HtmlConfig } from '../../diff2html';
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (config === void 0) { config = {}; }
|
|
3
|
+
export const defaultDiff2HtmlUIConfig = Object.assign(Object.assign({}, defaultDiff2HtmlConfig), { synchronisedScroll: true, highlight: true, fileListToggle: true, fileListStartVisible: false, highlightLanguages: new Map(), smartSelection: true, fileContentToggle: true, stickyFileHeaders: true });
|
|
4
|
+
export class Diff2HtmlUI {
|
|
5
|
+
constructor(target, diffInput, config = {}, hljs) {
|
|
18
6
|
this.hljs = null;
|
|
19
7
|
this.currentSelectionColumnId = -1;
|
|
20
|
-
this.config =
|
|
8
|
+
this.config = Object.assign(Object.assign({}, defaultDiff2HtmlUIConfig), config);
|
|
21
9
|
this.diffHtml = diffInput !== undefined ? html(diffInput, this.config) : target.innerHTML;
|
|
22
10
|
this.targetElement = target;
|
|
23
11
|
if (hljs !== undefined)
|
|
24
12
|
this.hljs = hljs;
|
|
25
13
|
}
|
|
26
|
-
|
|
14
|
+
draw() {
|
|
27
15
|
this.targetElement.innerHTML = this.diffHtml;
|
|
28
16
|
if (this.config.synchronisedScroll)
|
|
29
17
|
this.synchronisedScroll();
|
|
@@ -35,13 +23,13 @@ var Diff2HtmlUI = (function () {
|
|
|
35
23
|
this.fileContentToggle();
|
|
36
24
|
if (this.config.stickyFileHeaders)
|
|
37
25
|
this.stickyFileHeaders();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
this.targetElement.querySelectorAll('.d2h-file-wrapper').forEach(
|
|
41
|
-
|
|
26
|
+
}
|
|
27
|
+
synchronisedScroll() {
|
|
28
|
+
this.targetElement.querySelectorAll('.d2h-file-wrapper').forEach(wrapper => {
|
|
29
|
+
const [left, right] = Array().slice.call(wrapper.querySelectorAll('.d2h-file-side-diff'));
|
|
42
30
|
if (left === undefined || right === undefined)
|
|
43
31
|
return;
|
|
44
|
-
|
|
32
|
+
const onScroll = (event) => {
|
|
45
33
|
if (event === null || event.target === null)
|
|
46
34
|
return;
|
|
47
35
|
if (event.target === left) {
|
|
@@ -56,26 +44,26 @@ var Diff2HtmlUI = (function () {
|
|
|
56
44
|
left.addEventListener('scroll', onScroll);
|
|
57
45
|
right.addEventListener('scroll', onScroll);
|
|
58
46
|
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
}
|
|
48
|
+
fileListToggle(startVisible) {
|
|
49
|
+
const showBtn = this.targetElement.querySelector('.d2h-show');
|
|
50
|
+
const hideBtn = this.targetElement.querySelector('.d2h-hide');
|
|
51
|
+
const fileList = this.targetElement.querySelector('.d2h-file-list');
|
|
64
52
|
if (showBtn === null || hideBtn === null || fileList === null)
|
|
65
53
|
return;
|
|
66
|
-
|
|
54
|
+
const show = () => {
|
|
67
55
|
showBtn.style.display = 'none';
|
|
68
56
|
hideBtn.style.display = 'inline';
|
|
69
57
|
fileList.style.display = 'block';
|
|
70
58
|
};
|
|
71
|
-
|
|
59
|
+
const hide = () => {
|
|
72
60
|
showBtn.style.display = 'inline';
|
|
73
61
|
hideBtn.style.display = 'none';
|
|
74
62
|
fileList.style.display = 'none';
|
|
75
63
|
};
|
|
76
|
-
showBtn.addEventListener('click',
|
|
77
|
-
hideBtn.addEventListener('click',
|
|
78
|
-
|
|
64
|
+
showBtn.addEventListener('click', () => show());
|
|
65
|
+
hideBtn.addEventListener('click', () => hide());
|
|
66
|
+
const hashTag = this.getHashTag();
|
|
79
67
|
if (hashTag === 'files-summary-show')
|
|
80
68
|
show();
|
|
81
69
|
else if (hashTag === 'files-summary-hide')
|
|
@@ -84,59 +72,58 @@ var Diff2HtmlUI = (function () {
|
|
|
84
72
|
show();
|
|
85
73
|
else
|
|
86
74
|
hide();
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
this.targetElement.querySelectorAll('.d2h-file-collapse').forEach(
|
|
75
|
+
}
|
|
76
|
+
fileContentToggle() {
|
|
77
|
+
this.targetElement.querySelectorAll('.d2h-file-collapse').forEach(fileContentToggleBtn => {
|
|
90
78
|
fileContentToggleBtn.style.display = 'flex';
|
|
91
|
-
|
|
79
|
+
const toggleFileContents = selector => {
|
|
92
80
|
var _a;
|
|
93
|
-
|
|
81
|
+
const fileContents = (_a = fileContentToggleBtn
|
|
94
82
|
.closest('.d2h-file-wrapper')) === null || _a === void 0 ? void 0 : _a.querySelector(selector);
|
|
95
83
|
if (fileContents !== null && fileContents !== undefined) {
|
|
96
84
|
fileContentToggleBtn.classList.toggle('d2h-selected');
|
|
97
85
|
fileContents.classList.toggle('d2h-d-none');
|
|
98
86
|
}
|
|
99
87
|
};
|
|
100
|
-
|
|
88
|
+
const toggleHandler = e => {
|
|
101
89
|
if (fileContentToggleBtn === e.target)
|
|
102
90
|
return;
|
|
103
91
|
toggleFileContents('.d2h-file-diff');
|
|
104
92
|
toggleFileContents('.d2h-files-diff');
|
|
105
93
|
};
|
|
106
|
-
fileContentToggleBtn.addEventListener('click',
|
|
94
|
+
fileContentToggleBtn.addEventListener('click', e => toggleHandler(e));
|
|
107
95
|
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var hljs = this.hljs;
|
|
96
|
+
}
|
|
97
|
+
highlightCode() {
|
|
98
|
+
const hljs = this.hljs;
|
|
112
99
|
if (hljs === null) {
|
|
113
100
|
throw new Error('Missing a `highlight.js` implementation. Please provide one when instantiating Diff2HtmlUI.');
|
|
114
101
|
}
|
|
115
|
-
|
|
116
|
-
files.forEach(
|
|
117
|
-
|
|
118
|
-
if (!(
|
|
119
|
-
|
|
102
|
+
const files = this.targetElement.querySelectorAll('.d2h-file-wrapper');
|
|
103
|
+
files.forEach(file => {
|
|
104
|
+
const language = file.getAttribute('data-lang');
|
|
105
|
+
if (!(this.config.highlightLanguages instanceof Map)) {
|
|
106
|
+
this.config.highlightLanguages = new Map(Object.entries(this.config.highlightLanguages));
|
|
120
107
|
}
|
|
121
|
-
|
|
108
|
+
const hljsLanguage = language && this.config.highlightLanguages.has(language)
|
|
122
109
|
?
|
|
123
|
-
|
|
110
|
+
this.config.highlightLanguages.get(language)
|
|
124
111
|
: language
|
|
125
112
|
? getLanguage(language)
|
|
126
113
|
: 'plaintext';
|
|
127
|
-
|
|
128
|
-
codeLines.forEach(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (text === null || lineParent === null || !
|
|
114
|
+
const codeLines = file.querySelectorAll('.d2h-code-line-ctn');
|
|
115
|
+
codeLines.forEach(line => {
|
|
116
|
+
const text = line.textContent;
|
|
117
|
+
const lineParent = line.parentNode;
|
|
118
|
+
if (text === null || lineParent === null || !this.isElement(lineParent))
|
|
132
119
|
return;
|
|
133
|
-
|
|
120
|
+
const result = closeTags(hljs.highlight(text, {
|
|
134
121
|
language: hljsLanguage,
|
|
135
122
|
ignoreIllegals: true,
|
|
136
123
|
}));
|
|
137
|
-
|
|
124
|
+
const originalStream = nodeStream(line);
|
|
138
125
|
if (originalStream.length) {
|
|
139
|
-
|
|
126
|
+
const resultNode = document.createElementNS('http://www.w3.org/1999/xhtml', 'div');
|
|
140
127
|
resultNode.innerHTML = result.value;
|
|
141
128
|
result.value = mergeStreams(originalStream, nodeStream(resultNode), text);
|
|
142
129
|
}
|
|
@@ -147,28 +134,26 @@ var Diff2HtmlUI = (function () {
|
|
|
147
134
|
line.innerHTML = result.value;
|
|
148
135
|
});
|
|
149
136
|
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
this.targetElement.querySelectorAll('.d2h-file-header').forEach(
|
|
137
|
+
}
|
|
138
|
+
stickyFileHeaders() {
|
|
139
|
+
this.targetElement.querySelectorAll('.d2h-file-header').forEach(header => {
|
|
153
140
|
header.classList.add('d2h-sticky-header');
|
|
154
141
|
});
|
|
155
|
-
}
|
|
156
|
-
|
|
142
|
+
}
|
|
143
|
+
smartSelection() {
|
|
157
144
|
console.warn('Smart selection is now enabled by default with CSS. No need to call this method anymore.');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
145
|
+
}
|
|
146
|
+
getHashTag() {
|
|
147
|
+
const docUrl = document.URL;
|
|
148
|
+
const hashTagIndex = docUrl.indexOf('#');
|
|
149
|
+
let hashTag = null;
|
|
163
150
|
if (hashTagIndex !== -1) {
|
|
164
151
|
hashTag = docUrl.substr(hashTagIndex + 1);
|
|
165
152
|
}
|
|
166
153
|
return hashTag;
|
|
167
|
-
}
|
|
168
|
-
|
|
154
|
+
}
|
|
155
|
+
isElement(arg) {
|
|
169
156
|
return arg !== null && (arg === null || arg === void 0 ? void 0 : arg.classList) !== undefined;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
}());
|
|
173
|
-
export { Diff2HtmlUI };
|
|
157
|
+
}
|
|
158
|
+
}
|
|
174
159
|
//# sourceMappingURL=diff2html-ui-base.js.map
|