External Libraries: Update `whatwg-fetch` package to version 3.6.2.
This matches the version used in the Gutenberg project. While WordPress core no longer depends on this polyfill as of [50934], this brings the latest updates of the library to anyone still utilizing it. For a full list of changes in this update, see the `whatwg-fetch` GitHub: https://github.com/github/fetch/compare/v3.0.0...v3.6.2 Follow-up to [43719], [50934]. Props hareesh-pillai, rsiddharth, desrosj. Fixes #53929. Built from https://develop.svn.wordpress.org/trunk@51692 git-svn-id: http://core.svn.wordpress.org/trunk@51298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1ac69fa78e
commit
09f22e5b24
|
@ -4,12 +4,17 @@
|
||||||
(factory((global.WHATWGFetch = {})));
|
(factory((global.WHATWGFetch = {})));
|
||||||
}(this, (function (exports) { 'use strict';
|
}(this, (function (exports) { 'use strict';
|
||||||
|
|
||||||
|
var global =
|
||||||
|
(typeof globalThis !== 'undefined' && globalThis) ||
|
||||||
|
(typeof self !== 'undefined' && self) ||
|
||||||
|
(typeof global !== 'undefined' && global);
|
||||||
|
|
||||||
var support = {
|
var support = {
|
||||||
searchParams: 'URLSearchParams' in self,
|
searchParams: 'URLSearchParams' in global,
|
||||||
iterable: 'Symbol' in self && 'iterator' in Symbol,
|
iterable: 'Symbol' in global && 'iterator' in Symbol,
|
||||||
blob:
|
blob:
|
||||||
'FileReader' in self &&
|
'FileReader' in global &&
|
||||||
'Blob' in self &&
|
'Blob' in global &&
|
||||||
(function() {
|
(function() {
|
||||||
try {
|
try {
|
||||||
new Blob();
|
new Blob();
|
||||||
|
@ -18,8 +23,8 @@
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
formData: 'FormData' in self,
|
formData: 'FormData' in global,
|
||||||
arrayBuffer: 'ArrayBuffer' in self
|
arrayBuffer: 'ArrayBuffer' in global
|
||||||
};
|
};
|
||||||
|
|
||||||
function isDataView(obj) {
|
function isDataView(obj) {
|
||||||
|
@ -50,8 +55,8 @@
|
||||||
if (typeof name !== 'string') {
|
if (typeof name !== 'string') {
|
||||||
name = String(name);
|
name = String(name);
|
||||||
}
|
}
|
||||||
if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) {
|
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
|
||||||
throw new TypeError('Invalid character in header field name')
|
throw new TypeError('Invalid character in header field name: "' + name + '"')
|
||||||
}
|
}
|
||||||
return name.toLowerCase()
|
return name.toLowerCase()
|
||||||
}
|
}
|
||||||
|
@ -215,6 +220,17 @@
|
||||||
this.bodyUsed = false;
|
this.bodyUsed = false;
|
||||||
|
|
||||||
this._initBody = function(body) {
|
this._initBody = function(body) {
|
||||||
|
/*
|
||||||
|
fetch-mock wraps the Response object in an ES6 Proxy to
|
||||||
|
provide useful test harness features such as flush. However, on
|
||||||
|
ES5 browsers without fetch or Proxy support pollyfills must be used;
|
||||||
|
the proxy-pollyfill is unable to proxy an attribute unless it exists
|
||||||
|
on the object before the Proxy is created. This change ensures
|
||||||
|
Response.bodyUsed exists on the instance, while maintaining the
|
||||||
|
semantic of setting Request.bodyUsed in the constructor before
|
||||||
|
_initBody is called.
|
||||||
|
*/
|
||||||
|
this.bodyUsed = this.bodyUsed;
|
||||||
this._bodyInit = body;
|
this._bodyInit = body;
|
||||||
if (!body) {
|
if (!body) {
|
||||||
this._bodyText = '';
|
this._bodyText = '';
|
||||||
|
@ -267,7 +283,20 @@
|
||||||
|
|
||||||
this.arrayBuffer = function() {
|
this.arrayBuffer = function() {
|
||||||
if (this._bodyArrayBuffer) {
|
if (this._bodyArrayBuffer) {
|
||||||
return consumed(this) || Promise.resolve(this._bodyArrayBuffer)
|
var isConsumed = consumed(this);
|
||||||
|
if (isConsumed) {
|
||||||
|
return isConsumed
|
||||||
|
}
|
||||||
|
if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
|
||||||
|
return Promise.resolve(
|
||||||
|
this._bodyArrayBuffer.buffer.slice(
|
||||||
|
this._bodyArrayBuffer.byteOffset,
|
||||||
|
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
return Promise.resolve(this._bodyArrayBuffer)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return this.blob().then(readBlobAsArrayBuffer)
|
return this.blob().then(readBlobAsArrayBuffer)
|
||||||
}
|
}
|
||||||
|
@ -313,6 +342,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function Request(input, options) {
|
function Request(input, options) {
|
||||||
|
if (!(this instanceof Request)) {
|
||||||
|
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
||||||
|
}
|
||||||
|
|
||||||
options = options || {};
|
options = options || {};
|
||||||
var body = options.body;
|
var body = options.body;
|
||||||
|
|
||||||
|
@ -349,6 +382,21 @@
|
||||||
throw new TypeError('Body not allowed for GET or HEAD requests')
|
throw new TypeError('Body not allowed for GET or HEAD requests')
|
||||||
}
|
}
|
||||||
this._initBody(body);
|
this._initBody(body);
|
||||||
|
|
||||||
|
if (this.method === 'GET' || this.method === 'HEAD') {
|
||||||
|
if (options.cache === 'no-store' || options.cache === 'no-cache') {
|
||||||
|
// Search for a '_' parameter in the query string
|
||||||
|
var reParamSearch = /([?&])_=[^&]*/;
|
||||||
|
if (reParamSearch.test(this.url)) {
|
||||||
|
// If it already exists then set the value with the current time
|
||||||
|
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
|
||||||
|
} else {
|
||||||
|
// Otherwise add a new '_' parameter to the end with the current time
|
||||||
|
var reQueryString = /\?/;
|
||||||
|
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Request.prototype.clone = function() {
|
Request.prototype.clone = function() {
|
||||||
|
@ -376,7 +424,15 @@
|
||||||
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
||||||
// https://tools.ietf.org/html/rfc7230#section-3.2
|
// https://tools.ietf.org/html/rfc7230#section-3.2
|
||||||
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
|
||||||
preProcessedHeaders.split(/\r?\n/).forEach(function(line) {
|
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
|
||||||
|
// https://github.com/github/fetch/issues/748
|
||||||
|
// https://github.com/zloirock/core-js/issues/751
|
||||||
|
preProcessedHeaders
|
||||||
|
.split('\r')
|
||||||
|
.map(function(header) {
|
||||||
|
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
|
||||||
|
})
|
||||||
|
.forEach(function(line) {
|
||||||
var parts = line.split(':');
|
var parts = line.split(':');
|
||||||
var key = parts.shift().trim();
|
var key = parts.shift().trim();
|
||||||
if (key) {
|
if (key) {
|
||||||
|
@ -390,6 +446,9 @@
|
||||||
Body.call(Request.prototype);
|
Body.call(Request.prototype);
|
||||||
|
|
||||||
function Response(bodyInit, options) {
|
function Response(bodyInit, options) {
|
||||||
|
if (!(this instanceof Response)) {
|
||||||
|
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
|
||||||
|
}
|
||||||
if (!options) {
|
if (!options) {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
|
@ -397,7 +456,7 @@
|
||||||
this.type = 'default';
|
this.type = 'default';
|
||||||
this.status = options.status === undefined ? 200 : options.status;
|
this.status = options.status === undefined ? 200 : options.status;
|
||||||
this.ok = this.status >= 200 && this.status < 300;
|
this.ok = this.status >= 200 && this.status < 300;
|
||||||
this.statusText = 'statusText' in options ? options.statusText : 'OK';
|
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
|
||||||
this.headers = new Headers(options.headers);
|
this.headers = new Headers(options.headers);
|
||||||
this.url = options.url || '';
|
this.url = options.url || '';
|
||||||
this._initBody(bodyInit);
|
this._initBody(bodyInit);
|
||||||
|
@ -430,7 +489,7 @@
|
||||||
return new Response(null, {status: status, headers: {location: url}})
|
return new Response(null, {status: status, headers: {location: url}})
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.DOMException = self.DOMException;
|
exports.DOMException = global.DOMException;
|
||||||
try {
|
try {
|
||||||
new exports.DOMException();
|
new exports.DOMException();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
@ -466,22 +525,38 @@
|
||||||
};
|
};
|
||||||
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
|
||||||
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
||||||
|
setTimeout(function() {
|
||||||
resolve(new Response(body, options));
|
resolve(new Response(body, options));
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.onerror = function() {
|
xhr.onerror = function() {
|
||||||
|
setTimeout(function() {
|
||||||
reject(new TypeError('Network request failed'));
|
reject(new TypeError('Network request failed'));
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.ontimeout = function() {
|
xhr.ontimeout = function() {
|
||||||
|
setTimeout(function() {
|
||||||
reject(new TypeError('Network request failed'));
|
reject(new TypeError('Network request failed'));
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.onabort = function() {
|
xhr.onabort = function() {
|
||||||
|
setTimeout(function() {
|
||||||
reject(new exports.DOMException('Aborted', 'AbortError'));
|
reject(new exports.DOMException('Aborted', 'AbortError'));
|
||||||
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
xhr.open(request.method, request.url, true);
|
function fixUrl(url) {
|
||||||
|
try {
|
||||||
|
return url === '' && global.location.href ? global.location.href : url
|
||||||
|
} catch (e) {
|
||||||
|
return url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xhr.open(request.method, fixUrl(request.url), true);
|
||||||
|
|
||||||
if (request.credentials === 'include') {
|
if (request.credentials === 'include') {
|
||||||
xhr.withCredentials = true;
|
xhr.withCredentials = true;
|
||||||
|
@ -489,13 +564,27 @@
|
||||||
xhr.withCredentials = false;
|
xhr.withCredentials = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('responseType' in xhr && support.blob) {
|
if ('responseType' in xhr) {
|
||||||
|
if (support.blob) {
|
||||||
xhr.responseType = 'blob';
|
xhr.responseType = 'blob';
|
||||||
|
} else if (
|
||||||
|
support.arrayBuffer &&
|
||||||
|
request.headers.get('Content-Type') &&
|
||||||
|
request.headers.get('Content-Type').indexOf('application/octet-stream') !== -1
|
||||||
|
) {
|
||||||
|
xhr.responseType = 'arraybuffer';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers)) {
|
||||||
|
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
|
||||||
|
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
request.headers.forEach(function(value, name) {
|
request.headers.forEach(function(value, name) {
|
||||||
xhr.setRequestHeader(name, value);
|
xhr.setRequestHeader(name, value);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (request.signal) {
|
if (request.signal) {
|
||||||
request.signal.addEventListener('abort', abortXhr);
|
request.signal.addEventListener('abort', abortXhr);
|
||||||
|
@ -514,11 +603,11 @@
|
||||||
|
|
||||||
fetch.polyfill = true;
|
fetch.polyfill = true;
|
||||||
|
|
||||||
if (!self.fetch) {
|
if (!global.fetch) {
|
||||||
self.fetch = fetch;
|
global.fetch = fetch;
|
||||||
self.Headers = Headers;
|
global.Headers = Headers;
|
||||||
self.Request = Request;
|
global.Request = Request;
|
||||||
self.Response = Response;
|
global.Response = Response;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.Headers = Headers;
|
exports.Headers = Headers;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -101,7 +101,7 @@ function wp_default_packages_vendor( $scripts ) {
|
||||||
'regenerator-runtime' => '0.13.7',
|
'regenerator-runtime' => '0.13.7',
|
||||||
'moment' => '2.29.1',
|
'moment' => '2.29.1',
|
||||||
'lodash' => '4.17.19',
|
'lodash' => '4.17.19',
|
||||||
'wp-polyfill-fetch' => '3.0.0',
|
'wp-polyfill-fetch' => '3.6.2',
|
||||||
'wp-polyfill-formdata' => '4.0.0',
|
'wp-polyfill-formdata' => '4.0.0',
|
||||||
'wp-polyfill-node-contains' => '3.105.0',
|
'wp-polyfill-node-contains' => '3.105.0',
|
||||||
'wp-polyfill-url' => '3.6.4',
|
'wp-polyfill-url' => '3.6.4',
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.9-alpha-51689';
|
$wp_version = '5.9-alpha-51692';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue