From 466576038b7c72d999db607e572da8f47336bdad Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Thu, 11 Jan 2024 21:47:21 +0000 Subject: [PATCH] Bug 1871140 - Vendor Readability Library. r=cmkm - Adds a moz.yaml to vendor the files from the Readability library on Github to `toolkit/components/reader/readability`. - Updates includes to point to the new library location. Differential Revision: https://phabricator.services.mozilla.com/D196998 --- .eslintignore | 5 ---- .prettierignore | 6 +---- toolkit/components/reader/Reader.worker.js | 2 +- toolkit/components/reader/Readerable.js | 2 +- toolkit/components/reader/Readerable.sys.mjs | 2 +- toolkit/components/reader/moz.build | 4 +-- toolkit/components/reader/moz.yaml | 26 +++++++++++++++++++ .../reader/{ => readability}/JSDOMParser.js | 8 ------ .../components/reader/readability/LICENSE.md | 13 ++++++++++ .../Readability-readerable.js | 9 ------- .../reader/{ => readability}/Readability.js | 8 ------ tools/rewriting/ThirdPartyPaths.txt | 1 + 12 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 toolkit/components/reader/moz.yaml rename toolkit/components/reader/{ => readability}/JSDOMParser.js (99%) create mode 100644 toolkit/components/reader/readability/LICENSE.md rename toolkit/components/reader/{ => readability}/Readability-readerable.js (95%) rename toolkit/components/reader/{ => readability}/Readability.js (99%) diff --git a/.eslintignore b/.eslintignore index 72cd109828be..b11848f7acbd 100644 --- a/.eslintignore +++ b/.eslintignore @@ -241,11 +241,6 @@ toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_fail.json toolkit/components/pdfjs/content/build toolkit/components/pdfjs/content/web -# External code: -toolkit/components/reader/Readability.js -toolkit/components/reader/Readability-readerable.js -toolkit/components/reader/JSDOMParser.js - # Uses preprocessing toolkit/components/reader/Readerable.sys.mjs diff --git a/.prettierignore b/.prettierignore index 98840ff92e84..421e659b5adf 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1211,11 +1211,6 @@ toolkit/mozapps/extensions/test/xpcshell/data/test_AddonRepository_fail.json toolkit/components/pdfjs/content/build toolkit/components/pdfjs/content/web -# External code: -toolkit/components/reader/Readability.js -toolkit/components/reader/Readability-readerable.js -toolkit/components/reader/JSDOMParser.js - # Uses preprocessing toolkit/components/reader/Readerable.sys.mjs @@ -1432,6 +1427,7 @@ toolkit/components/jsoncpp/ toolkit/components/normandy/vendor/ toolkit/components/passwordmgr/PasswordRulesParser.sys.mjs toolkit/components/protobuf/ +toolkit/components/reader/readability/ toolkit/components/translation/cld2/ toolkit/components/translations/bergamot-translator/thirdparty toolkit/components/translations/bergamot-translator/bergamot-translator.js diff --git a/toolkit/components/reader/Reader.worker.js b/toolkit/components/reader/Reader.worker.js index f7973760cf41..148c57534c86 100644 --- a/toolkit/components/reader/Reader.worker.js +++ b/toolkit/components/reader/Reader.worker.js @@ -10,7 +10,7 @@ /* import-globals-from /toolkit/components/workerloader/require.js */ /* global JSDOMParser */ -/* import-globals-from /toolkit/components/reader/Readability.js */ +/* import-globals-from /toolkit/components/reader/readability/Readability.js */ importScripts( "resource://gre/modules/workers/require.js", "resource://gre/modules/reader/JSDOMParser.js", diff --git a/toolkit/components/reader/Readerable.js b/toolkit/components/reader/Readerable.js index addca3ebfaa8..828b4f507c66 100644 --- a/toolkit/components/reader/Readerable.js +++ b/toolkit/components/reader/Readerable.js @@ -8,7 +8,7 @@ // Readerable.sys.mjs. /* exported Readerable */ -/* import-globals-from Readability-readerable.js */ +/* import-globals-from readability/Readability-readerable.js */ const { XPCOMUtils } = ChromeUtils.importESModule( "resource://gre/modules/XPCOMUtils.sys.mjs" diff --git a/toolkit/components/reader/Readerable.sys.mjs b/toolkit/components/reader/Readerable.sys.mjs index 5412171ae379..200fa48a48c1 100644 --- a/toolkit/components/reader/Readerable.sys.mjs +++ b/toolkit/components/reader/Readerable.sys.mjs @@ -3,7 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include Readability-readerable.js +#include readability/Readability-readerable.js #include Readerable.js export { Readerable }; diff --git a/toolkit/components/reader/moz.build b/toolkit/components/reader/moz.build index 57b3d6bbbbd3..e57a0fe705c9 100644 --- a/toolkit/components/reader/moz.build +++ b/toolkit/components/reader/moz.build @@ -16,8 +16,8 @@ EXTRA_PP_JS_MODULES += [ ] EXTRA_JS_MODULES.reader = [ - "JSDOMParser.js", - "Readability.js", + "readability/JSDOMParser.js", + "readability/Readability.js", "Reader.worker.js", "ReaderWorker.sys.mjs", ] diff --git a/toolkit/components/reader/moz.yaml b/toolkit/components/reader/moz.yaml new file mode 100644 index 000000000000..104038d0a41e --- /dev/null +++ b/toolkit/components/reader/moz.yaml @@ -0,0 +1,26 @@ +schema: 1 + +bugzilla: + product: Toolkit + component: Reader Mode + +origin: + name: Readability + description: Readability library used for Firefox Reader View + url: https://github.com/mozilla/readability + license: Apache-2.0 + release: 0.5.0 (2023-12-15T17:20:28+00:00). + revision: 0.5.0 + +vendoring: + url: https://github.com/mozilla/readability + source-hosting: github + tracking: tag + vendor-directory: toolkit/components/reader/readability + exclude: + - "**" + include: + - LICENSE.md + - Readability.js + - Readability-readerable.js + - JSDOMParser.js diff --git a/toolkit/components/reader/JSDOMParser.js b/toolkit/components/reader/readability/JSDOMParser.js similarity index 99% rename from toolkit/components/reader/JSDOMParser.js rename to toolkit/components/reader/readability/JSDOMParser.js index f67c96f9ac2c..7b6d241b4361 100644 --- a/toolkit/components/reader/JSDOMParser.js +++ b/toolkit/components/reader/readability/JSDOMParser.js @@ -1,11 +1,3 @@ -/*eslint-env es6:false*/ -/* - * DO NOT MODIFY THIS FILE DIRECTLY! - * - * This is a shared library that is maintained in an external repo: - * https://github.com/mozilla/readability - */ - /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ diff --git a/toolkit/components/reader/readability/LICENSE.md b/toolkit/components/reader/readability/LICENSE.md new file mode 100644 index 000000000000..ca8e58b203b6 --- /dev/null +++ b/toolkit/components/reader/readability/LICENSE.md @@ -0,0 +1,13 @@ +Copyright (c) 2010 Arc90 Inc + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/toolkit/components/reader/Readability-readerable.js b/toolkit/components/reader/readability/Readability-readerable.js similarity index 95% rename from toolkit/components/reader/Readability-readerable.js rename to toolkit/components/reader/readability/Readability-readerable.js index cbfecc6cd3e3..892169fb9499 100644 --- a/toolkit/components/reader/Readability-readerable.js +++ b/toolkit/components/reader/readability/Readability-readerable.js @@ -1,12 +1,3 @@ -/* eslint-env es6:false */ -/* globals exports */ -/* - * DO NOT MODIFY THIS FILE DIRECTLY! - * - * This is a shared library that is maintained in an external repo: - * https://github.com/mozilla/readability - */ - /* * Copyright (c) 2010 Arc90 Inc * diff --git a/toolkit/components/reader/Readability.js b/toolkit/components/reader/readability/Readability.js similarity index 99% rename from toolkit/components/reader/Readability.js rename to toolkit/components/reader/readability/Readability.js index 1a1ca47387a5..b745aa01d8ea 100644 --- a/toolkit/components/reader/Readability.js +++ b/toolkit/components/reader/readability/Readability.js @@ -1,11 +1,3 @@ -/*eslint-env es6:false*/ -/* - * DO NOT MODIFY THIS FILE DIRECTLY! - * - * This is a shared library that is maintained in an external repo: - * https://github.com/mozilla/readability - */ - /* * Copyright (c) 2010 Arc90 Inc * diff --git a/tools/rewriting/ThirdPartyPaths.txt b/tools/rewriting/ThirdPartyPaths.txt index 4baa34934d0d..5101d4093c4e 100644 --- a/tools/rewriting/ThirdPartyPaths.txt +++ b/tools/rewriting/ThirdPartyPaths.txt @@ -182,6 +182,7 @@ toolkit/components/jsoncpp/ toolkit/components/normandy/vendor/ toolkit/components/passwordmgr/PasswordRulesParser.sys.mjs toolkit/components/protobuf/ +toolkit/components/reader/readability/ toolkit/components/translation/cld2/ toolkit/components/translations/bergamot-translator/thirdparty toolkit/components/translations/bergamot-translator/bergamot-translator.js