Merge pull request #11173 from Snuffleupagus/ReadableStream-polyfill

Replace the bundled `ReadableStream` polyfill with the `web-streams-polyfill` npm package (issue 11157)
This commit is contained in:
Tim van der Meij 2019-09-24 23:22:17 +02:00 committed by GitHub
commit f762d59ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 4014 deletions

View File

@ -7,7 +7,6 @@ external/webL10n/
external/cmapscompress/
external/builder/fixtures/
external/builder/fixtures_esprima/
external/streams/
src/shared/cffStandardStrings.js
src/shared/fonts_utils.js
test/tmp/

View File

@ -115,10 +115,6 @@
"name": "ReadableStream",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
{
"name": "WritableStream",
"message": "Import it from `src/shared/util.js` or `pdfjsLib` instead; outside of the `/src` and `/web` folders, the rule may be disabled as needed. ",
},
],
"no-shadow-restricted-names": "error",
"no-shadow": "off",

View File

@ -1,21 +0,0 @@
# WHATWG Streams Reference Implementation Licensing
For the reference implementation and tests for the WHATWG Streams Standard.
This code is dual-licensed under CC0 and the MIT license. You can choose which one you want to use.
## CC0
To the extent possible under law, the authors have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see https://creativecommons.org/publicdomain/zero/1.0/.
## MIT
Copyright (c) 20132015 Streams Standard Reference Implementation Authors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,9 +0,0 @@
# Streams API polyfill for PDF.js
This folder contains streams-lib.js file that works as a polyfill for `Streams API
in PDF.js` project.
## Steps to create streams-lib.js file
- Fork [Streams API](https://github.com/whatwg/streams/tree/master/reference-implementation) reference implementation.
- Bundle and port to es5 ref-implementation files using webpack to create commonjs module.

File diff suppressed because it is too large Load Diff

View File

@ -184,11 +184,12 @@ function createWebpackConfig(defines, output) {
rules: [
{
loader: 'babel-loader',
// `core-js` (see https://github.com/zloirock/core-js/issues/514) and
// `core-js` (see https://github.com/zloirock/core-js/issues/514),
// `web-streams-polyfill` (already using a transpiled file), and
// `src/core/{glyphlist,unicode}.js` (Babel is too slow for those)
// should be excluded from processing.
// eslint-disable-next-line max-len
exclude: /(node_modules[\\\/]core-js|src[\\\/]core[\\\/](glyphlist|unicode))/,
exclude: /(node_modules[\\\/]core-js|node_modules[\\\/]web-streams-polyfill|src[\\\/]core[\\\/](glyphlist|unicode))/,
options: {
presets: skipBabel ? undefined : ['@babel/preset-env'],
plugins: [
@ -541,7 +542,7 @@ gulp.task('default_preferences-pre', function() {
},
};
var preprocessor2 = require('./external/builder/preprocessor2.js');
var buildLib = merge([
return merge([
gulp.src([
'src/{display,shared}/*.js',
'!src/shared/{cffStandardStrings,fonts_utils}.js',
@ -553,11 +554,6 @@ gulp.task('default_preferences-pre', function() {
], { base: '.', }),
]).pipe(transform('utf8', preprocess))
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + 'lib/'));
return merge([
buildLib,
gulp.src('external/streams/*.js', { base: '.', })
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR)),
]);
});
gulp.task('default_preferences', gulp.series('default_preferences-pre',
@ -1034,7 +1030,7 @@ gulp.task('lib', gulp.series('buildnumber', 'default_preferences', function() {
var licenseHeaderLibre =
fs.readFileSync('./src/license_header_libre.js').toString();
var preprocessor2 = require('./external/builder/preprocessor2.js');
var buildLib = merge([
return merge([
gulp.src([
'src/{core,display,shared}/*.js',
'!src/shared/{cffStandardStrings,fonts_utils}.js',
@ -1048,11 +1044,6 @@ gulp.task('lib', gulp.series('buildnumber', 'default_preferences', function() {
gulp.src('test/unit/*.js', { base: '.', }),
]).pipe(transform('utf8', preprocess))
.pipe(gulp.dest('build/lib/'));
return merge([
buildLib,
gulp.src('external/streams/streams-lib.js', { base: '.', })
.pipe(gulp.dest('build/')),
]);
}));
gulp.task('publish', gulp.series('generic', function (done) {
@ -1369,8 +1360,6 @@ gulp.task('dist-pre', gulp.series('generic', 'components', 'image_decoders',
createStringSource('bower.json', JSON.stringify(bowerManifest, null, 2));
return merge([
gulp.src('external/streams/streams-lib.js', { base: '.', })
.pipe(gulp.dest('build/dist/')),
packageJsonSrc.pipe(gulp.dest(DIST_DIR)),
bowerJsonSrc.pipe(gulp.dest(DIST_DIR)),
vfs.src('external/dist/**/*',

6
package-lock.json generated
View File

@ -12704,6 +12704,12 @@
"neo-async": "^2.5.0"
}
},
"web-streams-polyfill": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-2.0.4.tgz",
"integrity": "sha512-hsLbiIZou2pZoht4VxfITEbCUz09YhZaaYFNICaZo7SOJrtW3/35LsJoAXeB8HITOlKpuWU0tFvtItOS2PpbsA==",
"dev": true
},
"webpack": {
"version": "4.40.2",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.40.2.tgz",

View File

@ -47,6 +47,7 @@
"typogr": "^0.6.8",
"vinyl": "^2.2.0",
"vinyl-fs": "^3.0.3",
"web-streams-polyfill": "^2.0.4",
"webpack": "^4.40.2",
"webpack-stream": "^4.0.3",
"wintersmith": "^2.5.0",

View File

@ -50,6 +50,6 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {
exports.ReadableStream = DummyReadableStream;
} else {
exports.ReadableStream =
require('../../external/streams/streams-lib').ReadableStream;
require('web-streams-polyfill/dist/ponyfill').ReadableStream;
}
}

View File

@ -68,6 +68,8 @@
'pdfjs-test': new URL('test', baseLocation).href,
'pdfjs-lib': new URL('src/pdf', baseLocation).href,
'core-js': new URL('node_modules/core-js', baseLocation).href,
'web-streams-polyfill':
new URL('node_modules/web-streams-polyfill', baseLocation).href,
},
meta: {
'*': {