8000 bump: Update dependencies · rtfpessoa/diff2html@ce2e668 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce2e668

Browse files
committed
bump: Update dependencies
1 parent ed506ef commit ce2e668

File tree

7 files changed

+1547
-1598
lines changed

7 files changed

+1547
-1598
lines changed

package.json

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -89,34 +89,32 @@
8989
"hogan.js": "3.0.2"
9090
},
9191
"optionalDependencies": {
92-
"highlight.js": "10.0.2"
92+
"highlight.js": "10.1.2"
9393
},
9494
"devDependencies": {
9595
"@types/clipboard": "2.0.1",
96-
"@types/copy-webpack-plugin": "5.0.0",
96+
"@types/copy-webpack-plugin": "6.0.0",
9797
"@types/diff": "4.0.2",
98-
"@types/highlight.js": "9.12.3",
9998
"@types/hogan.js": "3.0.0",
100-
"@types/html-webpack-plugin": "3.2.2",
101-
"@types/jest": "25.2.1",
99+
"@types/html-webpack-plugin": "3.2.3",
100+
"@types/jest": "26.0.10",
102101
"@types/mini-css-extract-plugin": "0.9.1",
103-
"@types/mkdirp": "1.0.0",
104-
"@types/node": "13.13.5",
102+
"@types/mkdirp": "1.0.1",
103+
"@types/node": "14.0.27",
105104
"@types/nopt": "3.0.29",
106-
"@types/webpack": "4.41.12",
107-
"@typescript-eslint/eslint-plugin": "2.31.0",
108-
"@typescript-eslint/parser": "2.31.0",
109-
"autoprefixer": "9.7.6",
110-
"bulma": "^0.8.0",
105+
"@typescript-eslint/eslint-plugin": "3.9.0",
106+
"@typescript-eslint/parser": "3.9.0",
107+
"autoprefixer": "9.8.6",
108+
"bulma": "^0.9.0",
111109
"clipboard": "2.0.6",
112-
"copy-webpack-plugin": "5.1.1",
113-
"css-loader": "3.5.3",
110+
"copy-webpack-plugin": "6.0.3",
111+
"css-loader": "4.2.1",
114112
"cssnano": "4.1.10",
115-
"eslint": "7.0.0",
113+
"eslint": "7.7.0",
116114
"eslint-config-prettier": "6.11.0",
117-
"eslint-plugin-import": "2.20.2",
118-
"eslint-plugin-jest": "23.10.0",
119-
"eslint-plugin-json": "2.1.1",
115+
"eslint-plugin-import": "2.22.0",
116+
"eslint-plugin-jest": "23.20.0",
117+
"eslint-plugin-json": "2.1.2",
120118
"eslint-plugin-node": "11.1.0",
121119
"eslint-plugin-optimize-regex": "1.2.0",
122120
"eslint-plugin-promise": "4.2.1",
@@ -127,28 +125,28 @@
127125
"html-webpack-plugin": "4.3.0",
128126
"husky": "4.2.5",
129127
"image-webpack-loader": "6.0.0",
130-
"is-ci-cli": "2.0.0",
131-
"jest": "26.0.1",
132-
"lint-staged": "10.2.2",
128+
"is-ci-cli": "2.1.2",
129+
"jest": "26.4.0",
130+
"lint-staged": "10.2.11",
133131
"markdown-toc": "^1.2.0",
134-
"mini-css-extract-plugin": "0.9.0",
132+
"mini-css-extract-plugin": "0.10.0",
135133
"mkdirp": "1.0.4",
136134
"nopt": "4.0.3",
137-
"postcss": "7.0.29",
135+
"postcss": "7.0.32",
138136
"postcss-cli": "7.1.1",
139137
"postcss-import": "12.0.1",
140138
"postcss-loader": "3.0.0",
141139
"postcss-preset-env": "6.7.0",
142140
"prettier": "2.0.5",
143-
"ts-jest": "25.5.1",
144-
"ts-loader": "7.0.3",
145-
"ts-node": "8.10.1",
146-
"typescript": "3.8.3",
141+
"ts-jest": "26.2.0",
142+
"ts-loader": "8.0.2",
143+
"ts-node": "8.10.2",
144+
"typescript": "3.9.7",
147145
"url-loader": "4.1.0",
148-
"webpack": "4.43.0",
149-
"webpack-cli": "3.3.11",
146+
"webpack": "4.44.1",
147+
"webpack-cli": "3.3.12",
150148
"webpack-dev-server": "3.11.0",
151-
"whatwg-fetch": "3.0.0"
149+
"whatwg-fetch": "3.4.0"
152150
},
153151
"resolutions": {
154152
"lodash": ">=4.17.15",

src/ui/js/diff2html-ui-base.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as HighlightJS from 'highlight.js/lib/core';
2-
import { ICompiledMode, IHighlightResult, IAutoHighlightResult } from 'highlight.js';
2+
// import { CompiledMode, HighlightResult, AutoHighlightResult } from 'highlight.js/lib/core.js';
33
import { nodeStream, mergeStreams } from './highlight.js-helpers';
44

55
import { html, Diff2HtmlConfig, defaultDiff2HtmlConfig } from '../../diff2html';
@@ -116,8 +116,8 @@ export class Diff2HtmlUI {
116116
// Collect all the diff files and execute the highlight on their lines
117117
const files = this.targetElement.querySelectorAll('.d2h-file-wrapper');
118118
files.forEach(file => {
119-
let oldLinesState: ICompiledMode;
120-
let newLinesState: ICompiledMode;
119+
let oldLinesState: CompiledMode | Language | undefined;
120+
let newLinesState: CompiledMode | Language | undefined;
121121

122122
// Collect all the code lines and execute the highlight on them
123123
const codeLines = file.querySelectorAll('.d2h-code-line-ctn');
@@ -133,12 +133,12 @@ export class Diff2HtmlUI {
133133
const lineState = lineParent.classList.contains('d2h-del') ? oldLinesState : newLinesState;
134134

135135
const language = file.getAttribute('data-lang');
136-
const result =
136+
const result: HighlightResult =
137137
language && this.hljs.getLanguage(language)
138138
? this.hljs.highlight(language, text, true, lineState)
139139
: this.hljs.highlightAuto(text);
140140

141-
if (this.instanceOfIHighlightResult(result)) {
141+
if (this.instanceOfHighlightResult(result)) {
142142
if (lineParent.classList.contains('d2h-del')) {
143143
oldLinesState = result.top;
144144
} else if (lineParent.classList.contains('d2h-ins')) {
@@ -157,7 +157,9 @@ export class Diff2HtmlUI {
157157
}
158158

159159
line.classList.add('hljs');
160-
line.classList.add(result.language);
160+
if (result.language) {
161+
line.classList.add(result.language);
162+
}
161163
line.innerHTML = result.value;
162164
});
163165
});
@@ -170,7 +172,7 @@ export class Diff2HtmlUI {
170172
console.warn('Smart selection is now enabled by default with CSS. No need to call this method anymore.');
171173
}
172174

173-
private instanceOfIHighlightResult(object: IHighlightResult | IAutoHighlightResult): object is IHighlightResult {
175+
private instanceOfHighlightResult(object: HighlightResult | AutoHighlightResult): object is HighlightResult {
174176
return 'top' in object;
175177
}
176178

typings/highlight.js/highlight.js.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

typings/highlight.js/languages.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

webpack.website.ts

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,44 @@ import CopyWebpackPlugin from 'copy-webpack-plugin';
77

88
const pages = ['index', 'demo'];
99

10+
function plugins(page: string): webpack.Plugin[] {
11+
return [
12+
new MiniCssExtractPlugin({
13+
filename: '[name].css',
14+
chunkFilename: '[id].css',
15+
}),
16+
new HtmlWebpackPlugin({
17+
hash: true,
18+
inject: true,
19+
title: `${page} page`,
20+
filename: `${page}.html`,
21+
template: `./website/templates/pages/${page}/${page}.handlebars`,
22+
minify: {
23+
html5: true,
24+
collapseWhitespace: true,
25+
caseSensitive: true,
26+
removeEmptyElements: false,
27+
removeComments: true,
28+
removeRedundantAttributes: true,
29+
useShortDoctype: true,
30+
removeEmptyAttributes: true,
31+
removeStyleLinkTypeAttributes: true,
32+
keepClosingSlash: true,
33+
minifyJS: true,
34+
minifyCSS: true,
35+
minifyURLs: true,
36+
},
37+
}),
38+
new CopyWebpackPlugin({
39+
patterns: [
40+
{ from: 'website/favicon.ico', to: 'favicon.ico' },
41+
{ from: 'website/robots.txt', to: 'robots.txt' },
42+
{ from: 'website/sitemap.xml', to: 'sitemap.xml' },
43+
],
44+
}),
45+
];
46+
}
47+
1048
const config: webpack.Configuration[] = pages.map(page => {
1149
return {
1250
devServer: {
@@ -108,39 +146,7 @@ const config: webpack.Configuration[] = pages.map(page => {
108146
},
109147
],
110148
},
111-
plugins: [
112-
new MiniCssExtractPlugin({
113-
filename: '[name].css',
114-
chunkFilename: '[id].css',
115-
}),
116-
new HtmlWebpackPlugin({
117-
hash: true,
118-
inject: true,
119-
title: `${page} page`,
120-
filename: `${page}.html`,
121-
template: `./website/templates/pages/${page}/${page}.handlebars`,
122-
minify: {
123-
html5: true,
124< F438 code class="diff-text syntax-highlighted-line deletion">-
collapseWhitespace: true,
125-
caseSensitive: true,
126-
removeEmptyElements: false,
127-
removeComments: true,
128-
removeRedundantAttributes: true,
129-
useShortDoctype: true,
130-
removeEmptyAttributes: true,
131-
removeStyleLinkTypeAttributes: true,
132-
keepClosingSlash: true,
133-
minifyJS: true,
134-
minifyCSS: true,
135-
minifyURLs: true,
136-
},
137-
}),
138-
new CopyWebpackPlugin([
139-
{ from: 'website/favicon.ico', to: 'favicon.ico' },
140-
{ from: 'website/robots.txt', to: 'robots.txt' },
141-
{ from: 'website/sitemap.xml', to: 'sitemap.xml' },
142-
]),
143-
],
149+
plugins: plugins(page),
144150
};
145151
});
146152

website/templates/pages/demo/demo.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,21 @@ async function prepareInitialState(elements: Elements): Promise<[Diff2HtmlUIConf
170170
}
171171

172172
function updateBrowserUrl(config: Diff2HtmlUIConfig, newDiffUrl: string): void {
173-
if (history.pushState) {
174-
const paramString = Object.entries(config)
175-
.map(([k, v]) => k + '=' + v)
176-
.join('&');
177-
const newPageUrl =
178-
window.location.protocol +
179-
'//' +
180-
window.location.host +
181-
window.location.pathname +
182-
'?' +
183-
paramString +
184-
'&' +
185-
searchParam +
186-
'=' +
187-
newDiffUrl;
188-
window.history.pushState({ path: newPageUrl }, '', newPageUrl);
189-
}
173+
const paramString = Object.entries(config)
174+
.map(([k, v]) => k + '=' + v)
175+
.join('&');
176+
const newPageUrl =
177+
window.location.protocol +
178+
'//' +
179+
window.location.host +
180+
window.location.pathname +
181+
'?' +
182+
paramString +
183+
'&' +
184+
searchParam +
185+
'=' +
186+
newDiffUrl;
187+
window.history.pushState({ path: newPageUrl }, '', newPageUrl);
190188
}
191189

192190
type Elements = {

0 commit comments

Comments
 (0)
0