Parse5 update (#2140)

* Update build-libs.js

* Add a test for build-libs.js

* Update parse5

* Rebuild parse5

* Update build-libs.js to generate consistent path names

* Rebuild
This commit is contained in:
toasted-nutbread 2022-05-16 21:25:05 -04:00 committed by GitHub
parent 5a723034b8
commit 9941d583a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7069 additions and 6484 deletions

View File

@ -62,7 +62,7 @@ submitting issues on GitHub, try the *testing* version; otherwise, the *stable*
<sup>*</sup>Unlike Chrome, Firefox does not allow extensions meant for testing to be hosted in the marketplace. <sup>*</sup>Unlike Chrome, Firefox does not allow extensions meant for testing to be hosted in the marketplace.
You will have to download a desired version and side-load it yourself. You only need to do this once and will get You will have to download a desired version and side-load it yourself. You only need to do this once and will get
updates automatically. updates automatically.
## Dictionaries ## Dictionaries
There are several free Japanese dictionaries available for Yomichan, with two of them having glossaries available in There are several free Japanese dictionaries available for Yomichan, with two of them having glossaries available in
@ -344,4 +344,4 @@ versions packaged.
* Handlebars: [homepage](https://handlebarsjs.com/) - [snapshot](https://s3.amazonaws.com/builds.handlebarsjs.com/handlebars.min-v4.7.7.js) - [license](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.7/LICENSE) * Handlebars: [homepage](https://handlebarsjs.com/) - [snapshot](https://s3.amazonaws.com/builds.handlebarsjs.com/handlebars.min-v4.7.7.js) - [license](https://github.com/handlebars-lang/handlebars.js/blob/v4.7.7/LICENSE)
* JSZip: [homepage](https://stuk.github.io/jszip/) - [snapshot](https://github.com/Stuk/jszip/blob/v3.7.1/dist/jszip.min.js) - [license](https://github.com/Stuk/jszip/blob/v3.7.1/LICENSE.markdown) * JSZip: [homepage](https://stuk.github.io/jszip/) - [snapshot](https://github.com/Stuk/jszip/blob/v3.7.1/dist/jszip.min.js) - [license](https://github.com/Stuk/jszip/blob/v3.7.1/LICENSE.markdown)
* WanaKana: [homepage](https://wanakana.com/) - [snapshot](https://unpkg.com/wanakana@4.0.2/umd/wanakana.min.js) - [license](https://github.com/WaniKani/WanaKana/blob/4.0.2/LICENSE) * WanaKana: [homepage](https://wanakana.com/) - [snapshot](https://unpkg.com/wanakana@4.0.2/umd/wanakana.min.js) - [license](https://github.com/WaniKani/WanaKana/blob/4.0.2/LICENSE)
* parse5: [homepage](https://github.com/inikulin/parse5) - [snapshot](https://github.com/inikulin/parse5/tree/v6.0.1/packages/parse5) - [license](https://github.com/inikulin/parse5/blob/v6.0.1/LICENSE) _(Only used in MV3 build)_ * parse5: [homepage](https://github.com/inikulin/parse5) - [snapshot](https://github.com/inikulin/parse5/tree/v7.0.0/packages/parse5) - [license](https://github.com/inikulin/parse5/blob/v7.0.0/LICENSE) _(Only used in MV3 build)_

View File

@ -19,21 +19,47 @@ const fs = require('fs');
const path = require('path'); const path = require('path');
const browserify = require('browserify'); const browserify = require('browserify');
async function main() { async function buildParse5() {
const extLibPath = path.join(__dirname, '..', 'ext', 'lib');
const parse5Path = require.resolve('parse5'); const parse5Path = require.resolve('parse5');
const cwd = process.cwd();
const content = await new Promise((resolve, reject) => { try {
browserify([parse5Path], {standalone: 'parse5', debug: true}).bundle((error, result) => { const baseDir = path.dirname(parse5Path);
if (error) { process.chdir(baseDir); // This is necessary to ensure relative source map file names are consistent
reject(error); return await new Promise((resolve, reject) => {
} else { browserify({
resolve(result); entries: [parse5Path],
} standalone: 'parse5',
debug: true,
baseDir
}).bundle((error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
}); });
}); } finally {
process.chdir(cwd);
fs.writeFileSync(path.join(extLibPath, 'parse5.js'), content); }
} }
main(); function getBuildTargets() {
const extLibPath = path.join(__dirname, '..', 'ext', 'lib');
return [
{path: path.join(extLibPath, 'parse5.js'), build: buildParse5}
];
}
async function main() {
for (const {path: path2, build} of getBuildTargets()) {
const content = await build();
fs.writeFileSync(path2, content);
}
}
if (require.main === module) { main(); }
module.exports = {
getBuildTargets
};

View File

@ -119,7 +119,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
</div></div></div></div></div> </div></div></div></div></div>
<div data-show-for-manifest-version="3"> <div data-show-for-manifest-version="3">
<h2><a href="https://github.com/inikulin/parse5/blob/v6.0.1/LICENSE" target="_blank" rel="noopener noreferrer">parse5 v6.0.1</a></h2> <h2><a href="https://github.com/inikulin/parse5/blob/v7.0.0/LICENSE" target="_blank" rel="noopener noreferrer">parse5 v7.0.0</a></h2>
<div class="settings-group"><div class="settings-item"><div class="settings-item-inner"><div class="settings-item-left"><div class="settings-item-label"> <div class="settings-group"><div class="settings-item"><div class="settings-item-inner"><div class="settings-item-left"><div class="settings-item-label">
<pre> <pre>
Copyright (c) 2013-2019 Ivan Nikulin (ifaaan@gmail.com, https://github.com/inikulin) Copyright (c) 2013-2019 Ivan Nikulin (ifaaan@gmail.com, https://github.com/inikulin)

File diff suppressed because one or more lines are too long

89
package-lock.json generated
View File

@ -19,7 +19,7 @@
"fake-indexeddb": "^3.1.7", "fake-indexeddb": "^3.1.7",
"html-validate": "^6.6.1", "html-validate": "^6.6.1",
"jsdom": "^19.0.0", "jsdom": "^19.0.0",
"parse5": "^6.0.1", "parse5": "^7.0.0",
"stylelint": "^14.6.1", "stylelint": "^14.6.1",
"stylelint-config-recommended": "^7.0.0", "stylelint-config-recommended": "^7.0.0",
"web-ext": "^6.8.0" "web-ext": "^6.8.0"
@ -1627,6 +1627,12 @@
"url": "https://github.com/sponsors/fb55" "url": "https://github.com/sponsors/fb55"
} }
}, },
"node_modules/cheerio/node_modules/parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==",
"dev": true
},
"node_modules/chrome-launcher": { "node_modules/chrome-launcher": {
"version": "0.15.0", "version": "0.15.0",
"resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.0.tgz", "resolved": "https://registry.npmjs.org/chrome-launcher/-/chrome-launcher-0.15.0.tgz",
@ -5369,6 +5375,12 @@
} }
} }
}, },
"node_modules/jsdom/node_modules/parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==",
"dev": true
},
"node_modules/json-buffer": { "node_modules/json-buffer": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.0.tgz",
@ -6841,10 +6853,16 @@
} }
}, },
"node_modules/parse5": { "node_modules/parse5": {
"version": "6.0.1", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.0.0.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", "integrity": "sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g==",
"dev": true "dev": true,
"dependencies": {
"entities": "^4.3.0"
},
"funding": {
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
}, },
"node_modules/parse5-htmlparser2-tree-adapter": { "node_modules/parse5-htmlparser2-tree-adapter": {
"version": "6.0.1", "version": "6.0.1",
@ -6855,6 +6873,24 @@
"parse5": "^6.0.1" "parse5": "^6.0.1"
} }
}, },
"node_modules/parse5-htmlparser2-tree-adapter/node_modules/parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==",
"dev": true
},
"node_modules/parse5/node_modules/entities": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.3.0.tgz",
"integrity": "sha512-/iP1rZrSEJ0DTlPiX+jbzlA3eVkY/e8L8SozroF395fIqE3TYF/Nz7YOMAawta+vLmyJ/hkGNNPcSbMADCCXbg==",
"dev": true,
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/parseurl": { "node_modules/parseurl": {
"version": "1.3.3", "version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
@ -11387,6 +11423,14 @@
"parse5": "^6.0.1", "parse5": "^6.0.1",
"parse5-htmlparser2-tree-adapter": "^6.0.1", "parse5-htmlparser2-tree-adapter": "^6.0.1",
"tslib": "^2.2.0" "tslib": "^2.2.0"
},
"dependencies": {
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==",
"dev": true
}
} }
}, },
"cheerio-select": { "cheerio-select": {
@ -14336,6 +14380,14 @@
"whatwg-url": "^10.0.0", "whatwg-url": "^10.0.0",
"ws": "^8.2.3", "ws": "^8.2.3",
"xml-name-validator": "^4.0.0" "xml-name-validator": "^4.0.0"
},
"dependencies": {
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==",
"dev": true
}
} }
}, },
"json-buffer": { "json-buffer": {
@ -15519,10 +15571,21 @@
} }
}, },
"parse5": { "parse5": {
"version": "6.0.1", "version": "7.0.0",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.0.0.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", "integrity": "sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g==",
"dev": true "dev": true,
"requires": {
"entities": "^4.3.0"
},
"dependencies": {
"entities": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-4.3.0.tgz",
"integrity": "sha512-/iP1rZrSEJ0DTlPiX+jbzlA3eVkY/e8L8SozroF395fIqE3TYF/Nz7YOMAawta+vLmyJ/hkGNNPcSbMADCCXbg==",
"dev": true
}
}
}, },
"parse5-htmlparser2-tree-adapter": { "parse5-htmlparser2-tree-adapter": {
"version": "6.0.1", "version": "6.0.1",
@ -15531,6 +15594,14 @@
"dev": true, "dev": true,
"requires": { "requires": {
"parse5": "^6.0.1" "parse5": "^6.0.1"
},
"dependencies": {
"parse5": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==",
"dev": true
}
} }
}, },
"parseurl": { "parseurl": {

View File

@ -45,7 +45,7 @@
"fake-indexeddb": "^3.1.7", "fake-indexeddb": "^3.1.7",
"html-validate": "^6.6.1", "html-validate": "^6.6.1",
"jsdom": "^19.0.0", "jsdom": "^19.0.0",
"parse5": "^6.0.1", "parse5": "^7.0.0",
"stylelint": "^14.6.1", "stylelint": "^14.6.1",
"stylelint-config-recommended": "^7.0.0", "stylelint-config-recommended": "^7.0.0",
"web-ext": "^6.8.0" "web-ext": "^6.8.0"

41
test/test-build-libs.js Normal file
View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2022 Yomichan Authors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
const fs = require('fs');
const assert = require('assert');
const {getBuildTargets} = require('../dev/build-libs');
async function main() {
try {
for (const {path: path2, build} of getBuildTargets()) {
let expectedContent = await build();
if (typeof expectedContent !== 'string') {
// Buffer
expectedContent = expectedContent.toString('utf8');
}
const actualContent = fs.readFileSync(path2, {encoding: 'utf8'});
assert.strictEqual(actualContent, expectedContent);
}
} catch (e) {
console.error(e);
process.exit(-1);
return;
}
process.exit(0);
}
if (require.main === module) { main(); }