Merge pull request #11146 from timvandermeij/core-js

Replace our `URL` polyfill with the one from `core-js`
This commit is contained in:
Tim van der Meij 2019-09-19 23:30:08 +02:00 committed by GitHub
commit c289f3a969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 56 additions and 735 deletions

View File

@ -113,10 +113,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": "URL",
"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. ",

View File

@ -1,627 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Polyfill obtained from: https://github.com/Polymer/URL
(function URLConstructorClosure() {
'use strict';
var relative = Object.create(null);
relative['ftp'] = 21;
relative['file'] = 0;
relative['gopher'] = 70;
relative['http'] = 80;
relative['https'] = 443;
relative['ws'] = 80;
relative['wss'] = 443;
var relativePathDotMapping = Object.create(null);
relativePathDotMapping['%2e'] = '.';
relativePathDotMapping['.%2e'] = '..';
relativePathDotMapping['%2e.'] = '..';
relativePathDotMapping['%2e%2e'] = '..';
function isRelativeScheme(scheme) {
return relative[scheme] !== undefined;
}
function invalid() {
clear.call(this);
this._isInvalid = true;
}
function IDNAToASCII(h) {
if (h === '') {
invalid.call(this);
}
// XXX
return h.toLowerCase();
}
function percentEscape(c) {
var unicode = c.charCodeAt(0);
if (unicode > 0x20 &&
unicode < 0x7F &&
// " # < > ? `
[0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1
) {
return c;
}
return encodeURIComponent(c);
}
function percentEscapeQuery(c) {
// XXX This actually needs to encode c using encoding and then
// convert the bytes one-by-one.
var unicode = c.charCodeAt(0);
if (unicode > 0x20 &&
unicode < 0x7F &&
// " # < > ` (do not escape '?')
[0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1
) {
return c;
}
return encodeURIComponent(c);
}
var EOF, ALPHA = /[a-zA-Z]/,
ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
function parse(input, stateOverride, base) {
function err(message) {
errors.push(message);
}
var state = stateOverride || 'scheme start',
cursor = 0,
buffer = '',
seenAt = false,
seenBracket = false,
errors = [];
loop: while ((input[cursor - 1] !== EOF || cursor === 0) &&
!this._isInvalid) {
var c = input[cursor];
switch (state) {
case 'scheme start':
if (c && ALPHA.test(c)) {
buffer += c.toLowerCase(); // ASCII-safe
state = 'scheme';
} else if (!stateOverride) {
buffer = '';
state = 'no scheme';
continue;
} else {
err('Invalid scheme.');
break loop;
}
break;
case 'scheme':
if (c && ALPHANUMERIC.test(c)) {
buffer += c.toLowerCase(); // ASCII-safe
} else if (c === ':') {
this._scheme = buffer;
buffer = '';
if (stateOverride) {
break loop;
}
if (isRelativeScheme(this._scheme)) {
this._isRelative = true;
}
if (this._scheme === 'file') {
state = 'relative';
} else if (this._isRelative && base &&
base._scheme === this._scheme) {
state = 'relative or authority';
} else if (this._isRelative) {
state = 'authority first slash';
} else {
state = 'scheme data';
}
} else if (!stateOverride) {
buffer = '';
cursor = 0;
state = 'no scheme';
continue;
} else if (c === EOF) {
break loop;
} else {
err('Code point not allowed in scheme: ' + c);
break loop;
}
break;
case 'scheme data':
if (c === '?') {
this._query = '?';
state = 'query';
} else if (c === '#') {
this._fragment = '#';
state = 'fragment';
} else {
// XXX error handling
if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
this._schemeData += percentEscape(c);
}
}
break;
case 'no scheme':
if (!base || !(isRelativeScheme(base._scheme))) {
err('Missing scheme.');
invalid.call(this);
} else {
state = 'relative';
continue;
}
break;
case 'relative or authority':
if (c === '/' && input[cursor + 1] === '/') {
state = 'authority ignore slashes';
} else {
err('Expected /, got: ' + c);
state = 'relative';
continue;
}
break;
case 'relative':
this._isRelative = true;
if (this._scheme !== 'file') {
this._scheme = base._scheme;
}
if (c === EOF) {
this._host = base._host;
this._port = base._port;
this._path = base._path.slice();
this._query = base._query;
this._username = base._username;
this._password = base._password;
break loop;
} else if (c === '/' || c === '\\') {
if (c === '\\') {
err('\\ is an invalid code point.');
}
state = 'relative slash';
} else if (c === '?') {
this._host = base._host;
this._port = base._port;
this._path = base._path.slice();
this._query = '?';
this._username = base._username;
this._password = base._password;
state = 'query';
} else if (c === '#') {
this._host = base._host;
this._port = base._port;
this._path = base._path.slice();
this._query = base._query;
this._fragment = '#';
this._username = base._username;
this._password = base._password;
state = 'fragment';
} else {
var nextC = input[cursor + 1];
var nextNextC = input[cursor + 2];
if (this._scheme !== 'file' || !ALPHA.test(c) ||
(nextC !== ':' && nextC !== '|') ||
(nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' &&
nextNextC !== '?' && nextNextC !== '#')) {
this._host = base._host;
this._port = base._port;
this._username = base._username;
this._password = base._password;
this._path = base._path.slice();
this._path.pop();
}
state = 'relative path';
continue;
}
break;
case 'relative slash':
if (c === '/' || c === '\\') {
if (c === '\\') {
err('\\ is an invalid code point.');
}
if (this._scheme === 'file') {
state = 'file host';
} else {
state = 'authority ignore slashes';
}
} else {
if (this._scheme !== 'file') {
this._host = base._host;
this._port = base._port;
this._username = base._username;
this._password = base._password;
}
state = 'relative path';
continue;
}
break;
case 'authority first slash':
if (c === '/') {
state = 'authority second slash';
} else {
err('Expected \'/\', got: ' + c);
state = 'authority ignore slashes';
continue;
}
break;
case 'authority second slash':
state = 'authority ignore slashes';
if (c !== '/') {
err('Expected \'/\', got: ' + c);
continue;
}
break;
case 'authority ignore slashes':
if (c !== '/' && c !== '\\') {
state = 'authority';
continue;
} else {
err('Expected authority, got: ' + c);
}
break;
case 'authority':
if (c === '@') {
if (seenAt) {
err('@ already seen.');
buffer += '%40';
}
seenAt = true;
for (var i = 0; i < buffer.length; i++) {
var cp = buffer[i];
if (cp === '\t' || cp === '\n' || cp === '\r') {
err('Invalid whitespace in authority.');
continue;
}
// XXX check URL code points
if (cp === ':' && this._password === null) {
this._password = '';
continue;
}
var tempC = percentEscape(cp);
if (this._password !== null) {
this._password += tempC;
} else {
this._username += tempC;
}
}
buffer = '';
} else if (c === EOF || c === '/' || c === '\\' ||
c === '?' || c === '#') {
cursor -= buffer.length;
buffer = '';
state = 'host';
continue;
} else {
buffer += c;
}
break;
case 'file host':
if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') {
if (buffer.length === 2 && ALPHA.test(buffer[0]) &&
(buffer[1] === ':' || buffer[1] === '|')) {
state = 'relative path';
} else if (buffer.length === 0) {
state = 'relative path start';
} else {
this._host = IDNAToASCII.call(this, buffer);
buffer = '';
state = 'relative path start';
}
continue;
} else if (c === '\t' || c === '\n' || c === '\r') {
err('Invalid whitespace in file host.');
} else {
buffer += c;
}
break;
case 'host':
case 'hostname':
if (c === ':' && !seenBracket) {
// XXX host parsing
this._host = IDNAToASCII.call(this, buffer);
buffer = '';
state = 'port';
if (stateOverride === 'hostname') {
break loop;
}
} else if (c === EOF || c === '/' ||
c === '\\' || c === '?' || c === '#') {
this._host = IDNAToASCII.call(this, buffer);
buffer = '';
state = 'relative path start';
if (stateOverride) {
break loop;
}
continue;
} else if (c !== '\t' && c !== '\n' && c !== '\r') {
if (c === '[') {
seenBracket = true;
} else if (c === ']') {
seenBracket = false;
}
buffer += c;
} else {
err('Invalid code point in host/hostname: ' + c);
}
break;
case 'port':
if (/[0-9]/.test(c)) {
buffer += c;
} else if (c === EOF || c === '/' || c === '\\' ||
c === '?' || c === '#' || stateOverride) {
if (buffer !== '') {
var temp = parseInt(buffer, 10);
if (temp !== relative[this._scheme]) {
this._port = temp + '';
}
buffer = '';
}
if (stateOverride) {
break loop;
}
state = 'relative path start';
continue;
} else if (c === '\t' || c === '\n' || c === '\r') {
err('Invalid code point in port: ' + c);
} else {
invalid.call(this);
}
break;
case 'relative path start':
if (c === '\\') {
err('\'\\\' not allowed in path.');
}
state = 'relative path';
if (c !== '/' && c !== '\\') {
continue;
}
break;
case 'relative path':
if (c === EOF || c === '/' || c === '\\' ||
(!stateOverride && (c === '?' || c === '#'))) {
if (c === '\\') {
err('\\ not allowed in relative path.');
}
var tmp;
if ((tmp = relativePathDotMapping[buffer.toLowerCase()])) {
buffer = tmp;
}
if (buffer === '..') {
this._path.pop();
if (c !== '/' && c !== '\\') {
this._path.push('');
}
} else if (buffer === '.' && c !== '/' && c !== '\\') {
this._path.push('');
} else if (buffer !== '.') {
if (this._scheme === 'file' && this._path.length === 0 &&
buffer.length === 2 && ALPHA.test(buffer[0]) &&
buffer[1] === '|') {
buffer = buffer[0] + ':';
}
this._path.push(buffer);
}
buffer = '';
if (c === '?') {
this._query = '?';
state = 'query';
} else if (c === '#') {
this._fragment = '#';
state = 'fragment';
}
} else if (c !== '\t' && c !== '\n' && c !== '\r') {
buffer += percentEscape(c);
}
break;
case 'query':
if (!stateOverride && c === '#') {
this._fragment = '#';
state = 'fragment';
} else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
this._query += percentEscapeQuery(c);
}
break;
case 'fragment':
if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') {
this._fragment += c;
}
break;
}
cursor++;
}
}
function clear() {
this._scheme = '';
this._schemeData = '';
this._username = '';
this._password = null;
this._host = '';
this._port = '';
this._path = [];
this._query = '';
this._fragment = '';
this._isInvalid = false;
this._isRelative = false;
}
// Does not process domain names or IP addresses.
// Does not handle encoding for the query parameter.
function JURL(url, base /* , encoding */) {
if (base !== undefined && !(base instanceof JURL)) {
base = new JURL(String(base));
}
this._url = url;
clear.call(this);
var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
// encoding = encoding || 'utf-8'
parse.call(this, input, null, base);
}
JURL.prototype = {
toString() {
return this.href;
},
get href() {
if (this._isInvalid) {
return this._url;
}
var authority = '';
if (this._username !== '' || this._password !== null) {
authority = this._username +
(this._password !== null ? ':' + this._password : '') + '@';
}
return this.protocol +
(this._isRelative ? '//' + authority + this.host : '') +
this.pathname + this._query + this._fragment;
},
// The named parameter should be different from the setter's function name.
// Otherwise Safari 5 will throw an error (see issue 8541)
set href(value) {
clear.call(this);
parse.call(this, value);
},
get protocol() {
return this._scheme + ':';
},
set protocol(value) {
if (this._isInvalid) {
return;
}
parse.call(this, value + ':', 'scheme start');
},
get host() {
return this._isInvalid ? '' : this._port ?
this._host + ':' + this._port : this._host;
},
set host(value) {
if (this._isInvalid || !this._isRelative) {
return;
}
parse.call(this, value, 'host');
},
get hostname() {
return this._host;
},
set hostname(value) {
if (this._isInvalid || !this._isRelative) {
return;
}
parse.call(this, value, 'hostname');
},
get port() {
return this._port;
},
set port(value) {
if (this._isInvalid || !this._isRelative) {
return;
}
parse.call(this, value, 'port');
},
get pathname() {
return this._isInvalid ? '' : this._isRelative ?
'/' + this._path.join('/') : this._schemeData;
},
set pathname(value) {
if (this._isInvalid || !this._isRelative) {
return;
}
this._path = [];
parse.call(this, value, 'relative path start');
},
get search() {
return this._isInvalid || !this._query || this._query === '?' ?
'' : this._query;
},
set search(value) {
if (this._isInvalid || !this._isRelative) {
return;
}
this._query = '?';
if (value[0] === '?') {
value = value.slice(1);
}
parse.call(this, value, 'query');
},
get hash() {
return this._isInvalid || !this._fragment || this._fragment === '#' ?
'' : this._fragment;
},
set hash(value) {
if (this._isInvalid) {
return;
}
this._fragment = '#';
if (value[0] === '#') {
value = value.slice(1);
}
parse.call(this, value, 'fragment');
},
get origin() {
var host;
if (this._isInvalid || !this._scheme) {
return '';
}
// javascript: Gecko returns String(""), WebKit/Blink String("null")
// Gecko throws error for "data://"
// data: Gecko returns "", Blink returns "data://", WebKit returns "null"
// Gecko returns String("") for file: mailto:
// WebKit/Blink returns String("SCHEME://") for file: mailto:
switch (this._scheme) {
case 'data':
case 'file':
case 'javascript':
case 'mailto':
return 'null';
case 'blob':
// Special case of blob: -- returns valid origin of _schemeData.
try {
return new JURL(this._schemeData).origin || 'null';
} catch (_) {
// Invalid _schemeData origin -- ignoring errors.
}
return 'null';
}
host = this.host;
if (!host) {
return '';
}
return this._scheme + '://' + host;
},
};
exports.URL = JURL;
})();

View File

@ -184,8 +184,11 @@ function createWebpackConfig(defines, output) {
rules: [
{
loader: 'babel-loader',
// babel is too slow
exclude: /src[\\\/]core[\\\/](glyphlist|unicode)/,
// `core-js` (see https://github.com/zloirock/core-js/issues/514) 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))/,
options: {
presets: skipBabel ? undefined : ['@babel/preset-env'],
plugins: [
@ -552,7 +555,7 @@ gulp.task('default_preferences-pre', function() {
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR + 'lib/'));
return merge([
buildLib,
gulp.src('external/{streams,url}/*.js', { base: '.', })
gulp.src('external/streams/*.js', { base: '.', })
.pipe(gulp.dest(DEFAULT_PREFERENCES_DIR)),
]);
});
@ -1049,8 +1052,6 @@ gulp.task('lib', gulp.series('buildnumber', 'default_preferences', function() {
buildLib,
gulp.src('external/streams/streams-lib.js', { base: '.', })
.pipe(gulp.dest('build/')),
gulp.src('external/url/url-lib.js', { base: '.', })
.pipe(gulp.dest('build/')),
]);
}));
@ -1370,8 +1371,6 @@ gulp.task('dist-pre', gulp.series('generic', 'components', 'image_decoders',
return merge([
gulp.src('external/streams/streams-lib.js', { base: '.', })
.pipe(gulp.dest('build/dist/')),
gulp.src('external/url/url-lib.js', { base: '.', })
.pipe(gulp.dest('build/dist/')),
packageJsonSrc.pipe(gulp.dest(DIST_DIR)),
bowerJsonSrc.pipe(gulp.dest(DIST_DIR)),
vfs.src('external/dist/**/*',

14
package-lock.json generated
View File

@ -1666,6 +1666,14 @@
"requires": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.11.0"
},
"dependencies": {
"core-js": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz",
"integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==",
"dev": true
}
}
},
"babel-types": {
@ -2521,9 +2529,9 @@
}
},
"core-js": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz",
"integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==",
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.1.tgz",
"integrity": "sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw==",
"dev": true
},
"core-js-compat": {

View File

@ -11,7 +11,7 @@
"autoprefixer": "^9.6.1",
"babel-loader": "^8.0.6",
"canvas": "^2.6.0",
"core-js": "^2.6.9",
"core-js": "^3.2.1",
"escodegen": "^1.12.0",
"eslint": "^6.4.0",
"eslint-config-prettier": "^6.3.0",

View File

@ -20,7 +20,7 @@ import {
InvalidPDFException, isArrayBuffer, isSameOrigin, MissingPDFException,
NativeImageDecoding, PasswordException, setVerbosityLevel, shadow,
stringToBytes, UnexpectedResponseException, UnknownErrorException,
unreachable, URL, warn
unreachable, warn
} from '../shared/util';
import {
deprecated, DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer,

View File

@ -16,7 +16,7 @@
import {
assert, CMapCompressionType, isString, removeNullCharacters, stringToBytes,
unreachable, URL, Util, warn
unreachable, Util, warn
} from '../shared/util';
const DEFAULT_LINK_REL = 'noopener noreferrer nofollow';

View File

@ -107,7 +107,6 @@ exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters;
exports.shadow = pdfjsSharedUtil.shadow;
exports.Util = pdfjsSharedUtil.Util;
exports.ReadableStream = pdfjsSharedUtil.ReadableStream;
exports.URL = pdfjsSharedUtil.URL;
exports.RenderingCancelledException =
pdfjsDisplayDisplayUtils.RenderingCancelledException;
exports.getFilenameFromUrl = pdfjsDisplayDisplayUtils.getFilenameFromUrl;

View File

@ -119,7 +119,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (String.prototype.startsWith) {
return;
}
require('core-js/fn/string/starts-with');
require('core-js/es/string/starts-with');
})();
// Provides support for String.prototype.endsWith in legacy browsers.
@ -128,7 +128,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (String.prototype.endsWith) {
return;
}
require('core-js/fn/string/ends-with');
require('core-js/es/string/ends-with');
})();
// Provides support for String.prototype.includes in legacy browsers.
@ -137,7 +137,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (String.prototype.includes) {
return;
}
require('core-js/fn/string/includes');
require('core-js/es/string/includes');
})();
// Provides support for Array.prototype.includes in legacy browsers.
@ -146,7 +146,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (Array.prototype.includes) {
return;
}
require('core-js/fn/array/includes');
require('core-js/es/array/includes');
})();
// Provides support for Array.from in legacy browsers.
@ -155,7 +155,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (Array.from) {
return;
}
require('core-js/fn/array/from');
require('core-js/es/array/from');
})();
// Provides support for Object.assign in legacy browsers.
@ -164,7 +164,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (Object.assign) {
return;
}
require('core-js/fn/object/assign');
require('core-js/es/object/assign');
})();
// Provides support for Math.log2 in legacy browsers.
@ -173,7 +173,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (Math.log2) {
return;
}
Math.log2 = require('core-js/fn/math/log2');
Math.log2 = require('core-js/es/math/log2');
})();
// Provides support for Number.isNaN in legacy browsers.
@ -182,7 +182,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (Number.isNaN) {
return;
}
Number.isNaN = require('core-js/fn/number/is-nan');
Number.isNaN = require('core-js/es/number/is-nan');
})();
// Provides support for Number.isInteger in legacy browsers.
@ -191,7 +191,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (Number.isInteger) {
return;
}
Number.isInteger = require('core-js/fn/number/is-integer');
Number.isInteger = require('core-js/es/number/is-integer');
})();
// Support: IE, Safari<11, Chrome<63
@ -205,7 +205,21 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
globalScope.Promise.prototype.finally)) {
return;
}
globalScope.Promise = require('core-js/fn/promise');
globalScope.Promise = require('core-js/es/promise/index');
})();
// Support: IE
(function checkURL() {
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('IMAGE_DECODERS')) {
// The current image decoders don't use the `URL` constructor, so it
// doesn't need to be polyfilled for the IMAGE_DECODERS build target.
return;
}
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('GENERIC')) {
// The `URL` constructor is assumed to be available in the extension builds.
return;
}
globalScope.URL = require('core-js/web/url');
})();
// Support: IE<11, Safari<8, Chrome<36
@ -213,7 +227,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (globalScope.WeakMap) {
return;
}
globalScope.WeakMap = require('core-js/fn/weak-map');
globalScope.WeakMap = require('core-js/es/weak-map/index');
})();
// Support: IE11
@ -221,7 +235,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (globalScope.WeakSet) {
return;
}
globalScope.WeakSet = require('core-js/fn/weak-set');
globalScope.WeakSet = require('core-js/es/weak-set/index');
})();
// Provides support for String.codePointAt in legacy browsers.
@ -230,7 +244,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (String.prototype.codePointAt) {
return;
}
require('core-js/fn/string/code-point-at');
require('core-js/es/string/code-point-at');
})();
// Provides support for String.fromCodePoint in legacy browsers.
@ -239,7 +253,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (String.fromCodePoint) {
return;
}
String.fromCodePoint = require('core-js/fn/string/from-code-point');
String.fromCodePoint = require('core-js/es/string/from-code-point');
})();
// Support: IE
@ -247,7 +261,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (globalScope.Symbol) {
return;
}
require('core-js/es6/symbol');
require('core-js/es/symbol/index');
})();
// Provides support for String.prototype.padStart in legacy browsers.
@ -256,7 +270,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (String.prototype.padStart) {
return;
}
require('core-js/fn/string/pad-start');
require('core-js/es/string/pad-start');
})();
// Provides support for String.prototype.padEnd in legacy browsers.
@ -265,7 +279,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (String.prototype.padEnd) {
return;
}
require('core-js/fn/string/pad-end');
require('core-js/es/string/pad-end');
})();
// Provides support for Object.values in legacy browsers.
@ -274,7 +288,7 @@ const hasDOM = typeof window === 'object' && typeof document === 'object';
if (Object.values) {
return;
}
Object.values = require('core-js/fn/object/values');
Object.values = require('core-js/es/object/values');
})();
}

View File

@ -1,62 +0,0 @@
/* Copyright 2018 Mozilla Foundation
*
* 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.
*/
/* eslint-disable no-restricted-globals */
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('GENERIC')) {
// The `URL` constructor is assumed to be available in the extension builds.
exports.URL = URL;
} else {
let isURLSupported = false;
try {
if (typeof URL === 'function' && typeof URL.prototype === 'object' &&
('origin' in URL.prototype)) {
const u = new URL('b', 'http://a');
u.pathname = 'c%20d';
isURLSupported = (u.href === 'http://a/c%20d');
}
} catch (ex) {
// The `URL` constructor cannot be used.
}
if (isURLSupported) {
exports.URL = URL;
} else if (typeof PDFJSDev !== 'undefined' &&
PDFJSDev.test('IMAGE_DECODERS')) {
class DummyURL {
constructor() {
throw new Error('The current image decoders doesn\'t utilize the ' +
'`URL` constructor, hence it shouldn\'t need to be ' +
'polyfilled for the IMAGE_DECODERS build target.');
}
}
exports.URL = DummyURL;
} else {
const PolyfillURL = require('../../external/url/url-lib').URL;
// Attempt to copy over the static methods.
const OriginalURL = require('./global_scope').URL;
if (OriginalURL) {
PolyfillURL.createObjectURL = function(blob) {
// IE extension allows a second optional options argument, see
// http://msdn.microsoft.com/en-us/library/ie/hh772302(v=vs.85).aspx
return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
};
PolyfillURL.revokeObjectURL = function(url) {
OriginalURL.revokeObjectURL(url);
};
}
exports.URL = PolyfillURL;
}
}

View File

@ -16,7 +16,6 @@
import './compatibility';
import { ReadableStream } from './streams_polyfill';
import { URL } from './url_polyfill';
const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
@ -970,7 +969,6 @@ export {
readUint32,
removeNullCharacters,
ReadableStream,
URL,
setVerbosityLevel,
shadow,
string32,

View File

@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-restricted-globals */
'use strict';

View File

@ -17,7 +17,7 @@ import {
bytesToString, createPromiseCapability, createValidAbsoluteUrl, isArrayBuffer,
isBool, isEmptyObj, isNum, isSameOrigin, isSpace, isString, log2,
ReadableStream, removeNullCharacters, string32, stringToBytes,
stringToPDFString, URL
stringToPDFString
} from '../../src/shared/util';
describe('util', function() {

View File

@ -25,8 +25,7 @@ import { AppOptions, OptionKind } from './app_options';
import {
build, createObjectURL, getDocument, getFilenameFromUrl, GlobalWorkerOptions,
InvalidPDFException, LinkTarget, loadScript, MissingPDFException, OPS,
PDFWorker, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, URL,
version
PDFWorker, shadow, UnexpectedResponseException, UNSUPPORTED_FEATURES, version
} from 'pdfjs-lib';
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';

View File

@ -19,7 +19,6 @@ import { AppOptions } from './app_options';
import { BasePreferences } from './preferences';
import { DownloadManager } from './download_manager';
import { GenericL10n } from './genericl10n';
import { URL } from 'pdfjs-lib';
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('CHROME')) {
throw new Error('Module "pdfjs-web/chromecom" shall not be used outside ' +

View File

@ -14,7 +14,7 @@
*/
import {
apiCompatibilityParams, createObjectURL, createValidAbsoluteUrl, URL
apiCompatibilityParams, createObjectURL, createValidAbsoluteUrl
} from 'pdfjs-lib';
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('CHROME || GENERIC')) {

View File

@ -14,7 +14,7 @@
*/
import '../extensions/firefox/tools/l10n';
import { createObjectURL, PDFDataRangeTransport, shadow, URL } from 'pdfjs-lib';
import { createObjectURL, PDFDataRangeTransport, shadow } from 'pdfjs-lib';
import { BasePreferences } from './preferences';
import { DEFAULT_SCALE_VALUE } from './ui_utils';
import { PDFViewerApplication } from './app';

View File

@ -16,7 +16,6 @@
import { CSS_UNITS, NullL10n } from './ui_utils';
import { PDFPrintServiceFactory, PDFViewerApplication } from './app';
import { AppOptions } from './app_options';
import { URL } from 'pdfjs-lib';
let activeService = null;
let overlayManager = null;