Compare commits

...

15 commits

Author SHA1 Message Date
Rodrigo Fernandes
1350740c98
fix artifacts 2024-12-23 23:17:59 +00:00
Rodrigo Fernandes
04640cccbe
force release 2024-12-23 23:08:34 +00:00
Rodrigo Fernandes
babcdb0405
Merge pull request #551 from rtfpessoa/bump-dependencies
Bump dependencies
2024-12-23 22:55:42 +00:00
Rodrigo Fernandes
2f4f41a31d
bump node version 2024-12-23 22:52:07 +00:00
Rodrigo Fernandes
2f8c477f66
fix build 2024-12-23 22:49:18 +00:00
Rodrigo Fernandes
064659a70e
update tests 2024-12-23 22:41:43 +00:00
Rodrigo Fernandes
eef651f0d4
bump more versions 2024-12-23 22:34:58 +00:00
Rodrigo Fernandes
d67d80eb41
fix dark demo theme and bump deps 2024-07-20 22:46:00 +01:00
Rodrigo Fernandes
a88e4b3ba4
bump more versions 2024-07-09 18:35:22 +01:00
Rodrigo Fernandes
dbdd2e9c26
bump bulma 2024-07-09 18:30:45 +01:00
Rodrigo Fernandes
05fbd33a3a
fix output directories 2024-07-09 18:19:04 +01:00
Rodrigo Fernandes
b2e31b6083
bump more dependencies 2024-07-05 23:59:55 +01:00
Rodrigo Fernandes
00a12d11aa
bump dependencies 2024-07-05 23:52:51 +01:00
Rodrigo Fernandes
b517e40e5c
Merge pull request #531 from rtfpessoa/use-npm
use npm instead of yarn
2024-04-19 21:39:35 +01:00
Rodrigo Fernandes
dea1d300b3
use npm instead of yarn 2024-04-19 21:35:17 +01:00
24 changed files with 18481 additions and 9235 deletions

View file

@ -1,58 +0,0 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
env: {
browser: true,
es6: true,
node: true,
},
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
document: 'readonly',
navigator: 'readonly',
window: 'readonly',
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:json/recommended',
'plugin:promise/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:node/recommended',
'plugin:sonarjs/recommended',
'plugin:jest/recommended',
'plugin:jest/style',
'prettier',
],
plugins: ['@typescript-eslint', 'json', 'promise', 'import', 'node', 'sonarjs', 'jest', 'optimize-regex'],
rules: {
// Enable
'optimize-regex/optimize-regex': 'error',
// Hack: For some reason we need pass again the extensions
'node/no-missing-import': [
'error',
{
tryExtensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
},
],
// Disable
// https://github.com/benmosher/eslint-plugin-import/issues/1446
'import/named': 'off',
// We don't need this since we are using transpilation
'node/no-unsupported-features/es-syntax': 'off',
'no-process-exit': 'off',
// Too verbose
'sonarjs/no-duplicate-string': 'off',
// Too verbose
'sonarjs/cognitive-complexity': 'off',
// Too verbose
'sonarjs/no-nested-template-literals': 'off',
},
};

View file

@ -19,7 +19,7 @@ jobs:
environment: 'production'
steps:
- name: Download docs
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: docs
path: docs/

View file

@ -25,7 +25,7 @@ jobs:
run: |
export NEXT_VERSION="$(/bin/git-version --folder=$PWD --release-branch=master)"
echo "Next version is ${NEXT_VERSION}"
echo "${NEXT_VERSION}" > .version
echo "${NEXT_VERSION}" > next-version.txt
echo "version=${NEXT_VERSION}" >> $GITHUB_ENV
- name: Get next npm tag name
run: |
@ -37,22 +37,22 @@ jobs:
export PUBLISH_TAG="pr"
fi
echo "Next tag is ${PUBLISH_TAG}"
echo "${PUBLISH_TAG}" > .tag
echo "${PUBLISH_TAG}" > publish-tag.txt
- name: Upload versions
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: versions
if-no-files-found: error
path: |
.version
.tag
next-version.txt
publish-tag.txt
build:
runs-on: ubuntu-latest
needs: [version]
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v3
with:
@ -61,17 +61,17 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
cache: 'npm'
- name: Log environment setup
run: |
node -v
yarn -v
npm -v
- name: Install dependencies
run: yarn install --ignore-engines
run: npm install
- name: Build templates
run: yarn run build:templates
run: npm run build:templates
- name: Build library
run: yarn run build
run: npm run build
publish:
runs-on: ubuntu-latest
@ -82,11 +82,11 @@ jobs:
with:
fetch-depth: 0
- name: Download versions
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: versions
- name: Store version
run: echo "version=$(cat .version)" >> $GITHUB_ENV
run: echo "version=$(cat next-version.txt)" >> $GITHUB_ENV
- name: Configure Git
run: |
git config user.email "gh-actions@users.noreply.github.com"
@ -94,15 +94,15 @@ jobs:
- name: Tag commit
uses: tvdias/github-tagger@v0.0.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
tag: "${{ env.version }}"
repo-token: '${{ secrets.GITHUB_TOKEN }}'
tag: '${{ env.version }}'
- name: Install dependencies
run: yarn
run: npm install
- uses: actions/setup-node@v3
with:
registry-url: 'https://registry.npmjs.org'
node-version: '18.x'
- name: Configure Yarn version
node-version: '22.x'
- name: Configure NPM version
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
@ -112,19 +112,17 @@ jobs:
echo "registry=https://registry.npmjs.org/" >> .npmrc
echo "access=public" >> .npmrc
echo "save-exact=true" >> .npmrc
yarn config set version-tag-prefix ""
yarn config set version-git-message "Release version %s"
- name: Version package
run: |
# Update version in packages to publish
yarn version --non-interactive --new-version $(cat .version)
npm version $(cat next-version.txt) -m "Release version %s"
- name: Publish to NPM
run: yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
run: npm publish --tag $(cat publish-tag.txt)
- uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '22.x'
registry-url: 'https://npm.pkg.github.com'
- name: Configure Yarn version
- name: Configure NPM version
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
@ -134,22 +132,16 @@ jobs:
echo "@rtfpessoa:registry=https://npm.pkg.github.com/" >> .npmrc
echo "access=public" >> .npmrc
echo "save-exact=true" >> .npmrc
yarn config set version-tag-prefix ""
yarn config set version-git-message "Release version %s"
- name: Version package
run: |
# Update version in packages to publish
yarn version --non-interactive --new-version $(cat .version)
- name: Publish to GPR
run: |
# HACK: Override npm package name to be able to publish in GitHub
sed -i 's/^ "name":.*/ "name": "@rtfpessoa\/diff2html",/g' package.json
echo "Going to publish version $(cat .version) to GitHub"
yarn publish --tag $(cat .tag) --non-interactive --new-version $(cat .version)
echo "Going to publish version $(cat next-version.txt) to GitHub"
npm publish --tag $(cat publish-tag.txt)
# HACK: Restore npm package name
sed -i 's/^ "name":.*/ "name": "diff2html",/g' package.json
- name: Upload docs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docs
if-no-files-found: error

10
.gitignore vendored
View file

@ -29,8 +29,18 @@ bower_components/
# Terraform
/terraform/.terraform
# Compiled templates
/src/diff2html-templates.*
# Compiled website
/docs/
# Bundles temporary typescript files compiled by webpack
/bundles-out/
# Web bundles
/bundles/
# CommonJS library
/lib/
# ESNext library
/lib-esm/

View file

@ -1,4 +1,3 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
npm run lint:staged

View file

@ -10,9 +10,9 @@
- Before sending a pull request make sure your code is tested.
- Before sending a pull request for a feature, be sure to run tests with `yarn test`.
- Before sending a pull request for a feature, be sure to run tests with `npm run test`.
- Use the same coding style as the rest of the codebase, most of the check can be performed with `yarn run lint`.
- Use the same coding style as the rest of the codebase, most of the check can be performed with `npm run run lint`.
- Use `git rebase` (not `git merge`) to sync your work from time to time with the master branch.

View file

@ -321,7 +321,7 @@ import { Controller } from '@hotwired/stimulus';
import { Diff2HtmlUI, Diff2HtmlUIConfig } from 'diff2html/lib/ui/js/diff2html-ui-slim.js';
// Requires `yarn add highlight.js`
// Requires `npm install highlight.js`
import 'highlight.js/styles/github.css';
import 'diff2html/bundles/css/diff2html.min.css';

77
eslint.config.mjs Normal file
View file

@ -0,0 +1,77 @@
import globals from 'globals';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginJest from 'eslint-plugin-jest';
import json from '@eslint/json';
import pluginPromise from 'eslint-plugin-promise';
export default [
{ ...eslint.configs.recommended, files: ['src/**/*.{js,mjs,cjs,ts}'] },
...tseslint.configs.recommended,
// ...tseslint.configs.recommendedTypeChecked,
// ...tseslint.configs.strict,
// ...tseslint.configs.stylistic,
// ...tseslint.configs.strictTypeChecked,
// ...tseslint.configs.stylisticTypeChecked,
{
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'all',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
},
},
pluginPromise.configs['flat/recommended'],
{
plugins: {
json,
},
files: ['**/*.json'],
language: 'json/json',
rules: {
'json/no-duplicate-keys': 'error',
},
},
{
...pluginJest.configs['flat/recommended'],
...pluginJest.configs['flat/style'],
files: ['src/__tests__/**/*tests.ts'],
plugins: { jest: pluginJest },
languageOptions: {
globals: pluginJest.environments.globals.globals,
},
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.es2025,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
document: 'readonly',
navigator: 'readonly',
window: 'readonly',
},
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: './',
},
},
},
{
ignores: ['src/diff2html-templates.*', 'coverage/', 'docs/', 'bundles-out/', 'bundles/', 'lib/', 'lib-esm/'],
},
{
...tseslint.configs.disableTypeChecked,
files: ['**/*.{js,mjs,cjs}'],
},
];

View file

@ -19,4 +19,5 @@ module.exports = {
lines: 93,
},
},
prettierPath: require.resolve('prettier-2'),
};

18121
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -35,35 +35,35 @@
"node": ">=12"
},
"scripts": {
"eslint": "eslint --ignore-path .gitignore \"**/*.{js,jsx,ts,tsx,json}\"",
"lint:check": "yarn run eslint",
"lint:fix": "yarn run eslint --fix",
"lint:staged": "lint-staged",
"lint:check": "eslint",
"lint:fix": "eslint --fix",
"prettier": "prettier --ignore-path .gitignore '**/*.+(js|jsx|ts|tsx|json|css|html|md|mdx)'",
"format:check": "yarn run prettier --check",
"format:fix": "yarn run prettier --write",
"build": "yarn run build:css && yarn run build:templates && yarn run build:commonjs && yarn run build:esm && yarn run build:bundles && yarn run build:website",
"build:commonjs": "rm -rf lib; tsc -p tsconfig.json --outDir lib",
"format:check": "npm run prettier --check",
"format:fix": "npm run prettier --write",
"build": "npm run build:css && npm run build:templates && npm run build:commonjs && npm run build:esm && npm run build:bundles && npm run build:website",
"build:commonjs": "rm -rf lib; tsc -p tsconfig.json -m CommonJS --outDir lib",
"build:esm": "rm -rf lib-esm; tsc -p tsconfig.json -m ESNext --outDir lib-esm",
"build:bundles": "rm -rf ./bundles/js; webpack --mode production --config webpack.bundles.ts",
"build:css": "rm -rf ./bundles/css; postcss --config ./postcss.config.js --no-map -o ./bundles/css/diff2html.min.css ./src/ui/css/diff2html.css",
"build:templates": "ts-node ./scripts/hulk.ts --wrapper ts --variable 'defaultTemplates' ./src/templates/*.mustache > ./src/diff2html-templates.ts",
"build:website": "rm -rf docs; webpack --mode production --config webpack.website.ts",
"gen": "yarn run gen:toc",
"gen": "npm run gen:toc",
"gen:toc-base": "markdown-toc --maxdepth 3 --bullets='-' -i",
"gen:toc": "yarn run gen:toc-base README.md",
"gen:toc": "npm run gen:toc-base README.md",
"test": "is-ci 'test:coverage' 'test:watch'",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch",
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
"coverage:open": "yarn run test:coverage && open ./coverage/index.html",
"coverage:open": "npm run test:coverage && open ./coverage/index.html",
"coverage:push": "curl -Ls https://coverage.codacy.com/get.sh | bash",
"validate": "yarn run build:templates && yarn run format:check && yarn run lint:check && yarn run build && yarn run test:coverage",
"fix": "yarn run format:fix && yarn run lint:fix",
"start": "yarn run start:website",
"validate": "npm run build:templates && npm run format:check && npm run lint:check && npm run build && npm run test:coverage",
"fix": "npm run format:fix && npm run lint:fix",
"start": "npm run start:website",
"start:website": "webpack serve --mode development --config webpack.website.ts",
"preversion": "yarn run validate",
"preversion": "npm run validate",
"version": "git add -A package.json",
"prepare": "husky install"
"prepare": "husky"
},
"main": "./lib/diff2html.js",
"module": "./lib-esm/diff2html.js",
@ -77,67 +77,64 @@
"prettier --write"
],
"README.md": [
"yarn run gen:toc-base"
"npm run gen:toc-base"
]
},
"dependencies": {
"diff": "5.1.0",
"diff": "^7.0.0",
"hogan.js": "3.0.2"
},
"optionalDependencies": {
"highlight.js": "11.9.0"
},
"devDependencies": {
"@types/diff": "5.0.9",
"prettier-2": "npm:prettier@^2",
"@eslint/js": "^9.17.0",
"@eslint/json": "^0.9.0",
"@types/diff": "^6.0.0",
"@types/hogan.js": "3.0.5",
"@types/jest": "29.5.11",
"@types/node": "20.11.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.2",
"@types/nopt": "3.0.32",
"@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1",
"all-contributors-cli": "^6.24.0",
"autoprefixer": "10.4.16",
"bulma": "^0.9.4",
"autoprefixer": "^10.4.20",
"bulma": "^1.0.2",
"clipboard": "2.0.11",
"copy-webpack-plugin": "12.0.1",
"css-loader": "6.9.0",
"cssnano": "6.0.3",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jest": "27.6.3",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-optimize-regex": "1.2.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-sonarjs": "0.23.0",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"cssnano": "^7.0.6",
"eslint": "^9.17.0",
"eslint-plugin-jest": "28.10.0",
"eslint-plugin-promise": "^7.2.1",
"file-loader": "6.2.0",
"globals": "^15.14.0",
"handlebars": "4.7.8",
"handlebars-loader": "1.7.3",
"html-webpack-plugin": "5.6.0",
"husky": "^8.0.1",
"html-webpack-plugin": "^5.6.3",
"husky": "^9.1.7",
"image-webpack-loader": "8.1.0",
"is-ci-cli": "2.2.0",
"jest": "29.7.0",
"lint-staged": "15.2.0",
"lint-staged": "^15.2.11",
"markdown-toc": "^1.2.0",
"mini-css-extract-plugin": "2.7.7",
"mini-css-extract-plugin": "^2.9.2",
"mkdirp": "3.0.1",
"nopt": "7.2.0",
"postcss": "8.4.33",
"nopt": "^8.0.0",
"postcss": "^8.4.49",
"postcss-cli": "11.0.0",
"postcss-import": "16.0.0",
"postcss-loader": "7.3.4",
"postcss-preset-env": "9.3.0",
"prettier": "3.2.1",
"ts-jest": "29.1.1",
"postcss-import": "^16.1.0",
"postcss-loader": "^8.1.1",
"postcss-preset-env": "^10.1.2",
"prettier": "^3.4.2",
"ts-jest": "^29.2.5",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
"typescript": "5.3.3",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2",
"url-loader": "4.1.1",
"webpack": "5.89.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "4.15.1",
"webpack": "^5.97.1",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.2.0",
"whatwg-fetch": "3.6.20"
},
"resolutions": {

View file

@ -67,7 +67,7 @@ function extractFiles(files: string[]): string[] {
`;
if (options.version) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
console.log(require('../package.json').version);
process.exit(0);
}

View file

@ -2,7 +2,6 @@ import { parse } from '../diff-parser';
describe('DiffParser', () => {
describe('generateDiffJson', () => {
// eslint-disable-next-line jest/expect-expect
it('should parse unix with \n diff', () => {
const diff =
'diff --git a/sample b/sample\n' +
@ -52,7 +51,6 @@ describe('DiffParser', () => {
`);
});
// eslint-disable-next-line jest/expect-expect
it('should parse windows with \r\n diff', () => {
const diff =
'diff --git a/sample b/sample\r\n' +
@ -102,7 +100,6 @@ describe('DiffParser', () => {
`);
});
// eslint-disable-next-line jest/expect-expect
it('should parse old os x with \r diff', () => {
const diff =
'diff --git a/sample b/sample\r' +
@ -152,7 +149,6 @@ describe('DiffParser', () => {
`);
});
// eslint-disable-next-line jest/expect-expect
it('should parse mixed eols diff', () => {
const diff =
'diff --git a/sample b/sample\n' +

View file

@ -928,7 +928,7 @@ describe('Diff2Html', () => {
<td class="d2h-del d2h-change">
<div class="d2h-code-line">
<span class="d2h-code-line-prefix">-</span>
<span class="d2h-code-line-ctn"><del>&lt;!-- commented code --&gt;</del></span>
<span class="d2h-code-line-ctn">&lt;<del>!-- commented code --</del>&gt;</span>
</div>
</td>
</tr><tr>
@ -939,7 +939,7 @@ describe('Diff2Html', () => {
<td class="d2h-del d2h-change">
<div class="d2h-code-line">
<span class="d2h-code-line-prefix">-</span>
<span class="d2h-code-line-ctn"><del>&lt;&#x2F;div</del>&gt;</span>
<span class="d2h-code-line-ctn">&lt;<del>&#x2F;div</del>&gt;</span>
</div>
</td>
</tr><tr>
@ -950,7 +950,7 @@ describe('Diff2Html', () => {
<td class="d2h-ins d2h-change">
<div class="d2h-code-line">
<span class="d2h-code-line-prefix">+</span>
<span class="d2h-code-line-ctn"><ins>&lt;html&gt;</ins></span>
<span class="d2h-code-line-ctn">&lt;<ins>html</ins>&gt;</span>
</div>
</td>
</tr><tr>
@ -961,7 +961,7 @@ describe('Diff2Html', () => {
<td class="d2h-ins d2h-change">
<div class="d2h-code-line">
<span class="d2h-code-line-prefix">+</span>
<span class="d2h-code-line-ctn"><ins>&lt;body</ins>&gt;</span>
<span class="d2h-code-line-ctn">&lt;<ins>body</ins>&gt;</span>
</div>
</td>
</tr>

View file

@ -458,18 +458,16 @@ export function parse(diffInput: string, config: DiffParserConfig = {}): DiffFil
} else if ((values = index.exec(line))) {
currentFile.checksumBefore = values[1];
currentFile.checksumAfter = values[2];
values[3] && (currentFile.mode = values[3]);
if (values[3]) currentFile.mode = values[3];
} else if ((values = combinedIndex.exec(line))) {
currentFile.checksumBefore = [values[2], values[3]];
currentFile.checksumAfter = values[1];
} else if ((values = combinedMode.exec(line))) {
currentFile.oldMode = [values[2], values[3]];
currentFile.newMode = values[1];
// eslint-disable-next-line sonarjs/no-duplicated-branches
} else if ((values = combinedNewFile.exec(line))) {
currentFile.newFileMode = values[1];
currentFile.isNew = true;
// eslint-disable-next-line sonarjs/no-duplicated-branches
} else if ((values = combinedDeletedFile.exec(line))) {
currentFile.deletedFileMode = values[1];
currentFile.isDeleted = true;

View file

@ -39,7 +39,7 @@ export default class HoganJsUtils {
try {
const template = this.preCompiledTemplates[templateKey];
return template.render(params, partials, indent);
} catch (e) {
} catch (_e) {
throw new Error(`Could not find template to render '${templateKey}'`);
}
}

View file

@ -153,8 +153,7 @@ export class Diff2HtmlUI {
let hljsLanguage =
language && this.config.highlightLanguages.has(language)
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
this.config.highlightLanguages.get(language)!
? this.config.highlightLanguages.get(language)!
: language
? getLanguage(language)
: 'plaintext';

5
tsconfig.eslint.json Normal file
View file

@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules"],
"include": ["./**/*"]
}

View file

@ -1,8 +1,8 @@
{
"include": ["*env.d.ts", "src/**/*", "./typings/**/*"],
"include": ["src/**/*", "typings/**/*"],
"exclude": ["node_modules", "src/__tests__/**"],
"compilerOptions": {
"outDir": "lib",
"outDir": "bundles-out",
"module": "CommonJS",
"moduleResolution": "Node",
"target": "ES6",

1
typings/merge.d.ts vendored
View file

@ -1,4 +1,3 @@
declare module 'merge' {
// eslint-disable-next-line @typescript-eslint/ban-types
export function recursive(clone: boolean, ...items: object[]): object;
}

View file

@ -3,7 +3,6 @@ import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
// eslint-disable-next-line import/default
import CopyPlugin from 'copy-webpack-plugin';
const pages = ['index', 'demo'];

View file

@ -123,10 +123,16 @@ function prepareRequest(url: string): Request {
function getConfiguration(urlParams: URLParams): Diff2HtmlUIConfig {
// Removing `diff` and `diffTooBigMessage` form `urlParams` to avoid being inserted
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { diff, diffTooBigMessage, ...urlParamsRest } = urlParams;
const defaultColorScheme: ColorSchemeType =
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
? ColorSchemeType.DARK
: ColorSchemeType.LIGHT;
const config: URLParams = {
...defaultDiff2HtmlUIConfig,
colorScheme: defaultColorScheme,
...urlParamsRest,
};
@ -245,6 +251,7 @@ function getHTMLElementById(id: string): HTMLElement {
document.addEventListener('DOMContentLoaded', async () => {
// Improves browser compatibility
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('whatwg-fetch');
const drawAndUpdateUrl = async (
@ -282,13 +289,13 @@ document.addEventListener('DOMContentLoaded', async () => {
let [config, diffString] = await prepareInitialState(elements);
// Update HTML inputs from any changes in URL
config.outputFormat && (elements.options.outputFormat.value = config.outputFormat);
config.colorScheme && (elements.options.colorScheme.value = config.colorScheme);
config.drawFileList && (elements.checkboxes.drawFileList.checked = config.drawFileList);
config.matching && (elements.options.matching.value = config.matching);
config.matchWordsThreshold && (elements.options.wordsThreshold.value = config.matchWordsThreshold.toString());
config.matchingMaxComparisons &&
(elements.options.matchingMaxComparisons.value = config.matchingMaxComparisons.toString());
if (config.outputFormat) elements.options.outputFormat.value = config.outputFormat;
if (config.colorScheme) elements.options.colorScheme.value = config.colorScheme;
if (config.drawFileList) elements.checkboxes.drawFileList.checked = config.drawFileList;
if (config.matching) elements.options.matching.value = config.matching;
if (config.matchWordsThreshold) elements.options.wordsThreshold.value = config.matchWordsThreshold.toString();
if (config.matchingMaxComparisons)
elements.options.matchingMaxComparisons.value = config.matchingMaxComparisons.toString();
Object.entries(elements.options).forEach(([option, element]) =>
element.addEventListener('change', () => {

View file

@ -4,5 +4,4 @@ import '../../../main.ts';
import '../../../main.css';
import './index.css';
// eslint-disable-next-line no-new
new Clipboard(document.getElementsByClassName('clipboard')[0]);

8895
yarn.lock

File diff suppressed because it is too large Load diff