Replace the bundled ReadableStream
polyfill with the web-streams-polyfill
npm package (issue 11157)
Compared to the recently replaced `URL` polyfill, the new `ReadableStream` polyfill isn't being exported globally for two reasons: - We're currently checking for the existence of a global `ReadableStream` implementation when determining if the Fetch API will be used; please see `isFetchSupported` in the src/display/display_utils.js file. - Given that it's much newer functionality (compared to `URL`) and that not all browsers may implement all parts of the specification yet, not exposing the `ReadableStream` globally seems safer for now.
This commit is contained in:
parent
9596d702a9
commit
0ee373f9cc
@ -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/
|
||||
|
@ -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",
|
||||
|
21
external/streams/LICENSE.md
vendored
21
external/streams/LICENSE.md
vendored
@ -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) 2013–2015 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.
|
9
external/streams/README.md
vendored
9
external/streams/README.md
vendored
@ -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.
|
3962
external/streams/streams-lib.js
vendored
3962
external/streams/streams-lib.js
vendored
File diff suppressed because it is too large
Load Diff
21
gulpfile.js
21
gulpfile.js
@ -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
6
package-lock.json
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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: {
|
||||
'*': {
|
||||
|
Loading…
Reference in New Issue
Block a user