WordPress/wp-includes/js/dist/api-fetch.min.js
desrosj cf023b82bd Build/Test Tools: Support NodeJS 14.x in the 5.2 branch.
This updates the 5.2 branch to support the latest LTS version of NodeJS (currently 14.x), allowing the same version to be used across all WordPress branches that receive security updates as a courtesy.

In addition to backporting the package updates that happened after branching 5.2, dependencies that were removed in future releases have also been updated to their latest versions.

Props desrosj, dd32, netweb, jorbin, whyisjake.
Merges [45321,45765,45826,45875,46403-46404,46408-46409,47404,47867,47872-47873,48213,48705,49636,49933,49937,49939-49940,49983,49989,50017,50126,50176,50185] to the 5.2 branch.
See #52341.
Built from https://develop.svn.wordpress.org/branches/5.2@50191


git-svn-id: http://core.svn.wordpress.org/branches/5.2@49869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-05 03:20:06 +00:00

1 line
13 KiB
JavaScript

this.wp=this.wp||{},this.wp.apiFetch=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=369)}({1:function(t,e){!function(){t.exports=this.wp.i18n}()},15:function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}r.d(e,"a",(function(){return n}))},21:function(t,e,r){"use strict";function n(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}r.d(e,"a",(function(){return n}))},23:function(t,e,r){t.exports=r(54)},25:function(t,e){!function(){t.exports=this.wp.url}()},369:function(t,e,r){"use strict";r.r(e);var n=r(7),o=r(21),i=r(1);var a=function(t){function e(t,r){var o=t.headers,i=void 0===o?{}:o;for(var a in i)if("x-wp-nonce"===a.toLowerCase())return r(t);return r(Object(n.a)({},t,{headers:Object(n.a)({},i,{"X-WP-Nonce":e.nonce})}))}return e.nonce=t,e},u=function(t,e){var r,o,i=t.path;return"string"==typeof t.namespace&&"string"==typeof t.endpoint&&(r=t.namespace.replace(/^\/|\/$/g,""),i=(o=t.endpoint.replace(/^\//,""))?r+"/"+o:r),delete t.namespace,delete t.endpoint,e(Object(n.a)({},t,{path:i}))},c=function(t){return function(e,r){return u(e,(function(e){var o,i=e.url,a=e.path;return"string"==typeof a&&(o=t,-1!==t.indexOf("?")&&(a=a.replace("?","&")),a=a.replace(/^\//,""),"string"==typeof o&&-1!==o.indexOf("?")&&(a=a.replace("?","&")),i=o+a),r(Object(n.a)({},e,{url:i}))}))}},s=function(t){return function(e,r){var n=e.parse,o=void 0===n||n;if("string"==typeof e.path){var i=e.method||"GET",a=function(t){var e=t.split("?"),r=e[1],n=e[0];return r?n+"?"+r.split("&").map((function(t){return t.split("=")})).sort((function(t,e){return t[0].localeCompare(e[0])})).map((function(t){return t.join("=")})).join("&"):n}(e.path);if(o&&"GET"===i&&t[a])return Promise.resolve(t[a].body);if("OPTIONS"===i&&t[i]&&t[i][a])return Promise.resolve(t[i][a])}return r(e)}},f=r(23),l=r.n(f),p=r(44),h=r(25),d=function(t,e){var r=t.path,i=t.url,a=Object(o.a)(t,["path","url"]);return Object(n.a)({},a,{url:i&&Object(h.addQueryArgs)(i,e),path:r&&Object(h.addQueryArgs)(r,e)})},v=function(t){return t.json?t.json():Promise.reject(t)},y=function(t){return function(t){if(!t)return{};var e=t.match(/<([^>]+)>; rel="next"/);return e?{next:e[1]}:{}}(t.headers.get("link")).next},g=function(t){var e=t.path&&-1!==t.path.indexOf("per_page=-1"),r=t.url&&-1!==t.url.indexOf("per_page=-1");return e||r},m=function(){var t=Object(p.a)(l.a.mark((function t(e,r){var o,i,a,u,c,s;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!1!==e.parse){t.next=2;break}return t.abrupt("return",r(e));case 2:if(g(e)){t.next=4;break}return t.abrupt("return",r(e));case 4:return t.next=6,r(Object(n.a)({},d(e,{per_page:100}),{parse:!1}));case 6:return o=t.sent,t.next=9,v(o);case 9:if(i=t.sent,Array.isArray(i)){t.next=12;break}return t.abrupt("return",i);case 12:if(a=y(o)){t.next=15;break}return t.abrupt("return",i);case 15:u=[].concat(i);case 16:if(!a){t.next=27;break}return t.next=19,r(Object(n.a)({},e,{path:void 0,url:a,parse:!1}));case 19:return c=t.sent,t.next=22,v(c);case 22:s=t.sent,u=u.concat(s),a=y(c),t.next=16;break;case 27:return t.abrupt("return",u);case 28:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),b=new Set(["PATCH","PUT","DELETE"]);var w={Accept:"application/json, */*;q=0.1"},O={credentials:"include"},j=[function(t,e){return"string"!=typeof t.url||Object(h.hasQueryArg)(t.url,"_locale")||(t.url=Object(h.addQueryArgs)(t.url,{_locale:"user"})),"string"!=typeof t.path||Object(h.hasQueryArg)(t.path,"_locale")||(t.path=Object(h.addQueryArgs)(t.path,{_locale:"user"})),e(t,e)},u,function(t,e){var r=t.method,o=void 0===r?"GET":r;return b.has(o.toUpperCase())&&(t=Object(n.a)({},t,{headers:Object(n.a)({},t.headers,{"X-HTTP-Method-Override":o,"Content-Type":"application/json"}),method:"POST"})),e(t,e)},m];var x=function(t){var e=t.url,r=t.path,a=t.data,u=t.parse,c=void 0===u||u,s=Object(o.a)(t,["url","path","data","parse"]),f=t.body,l=t.headers;l=Object(n.a)({},w,l),a&&(f=JSON.stringify(a),l["Content-Type"]="application/json");return window.fetch(e||r,Object(n.a)({},O,s,{body:f,headers:l})).then((function(t){if(t.status>=200&&t.status<300)return t;throw t})).then((function(t){return c?204===t.status?null:t.json?t.json():Promise.reject(t):t})).catch((function(t){if(!c)throw t;var e={code:"invalid_json",message:Object(i.__)("The response is not a valid JSON response.")};if(!t||!t.json)throw e;return t.json().catch((function(){throw e})).then((function(t){var e={code:"unknown_error",message:Object(i.__)("An unknown error occurred.")};throw t||e}))}))};function _(t){var e=[].concat(j,[x]);return function t(r){return function(n){var o=e[r];return r===e.length-1?o(n):o(n,t(r+1))}}(0)(t)}_.use=function(t){j.unshift(t)},_.setFetchHandler=function(t){x=t},_.createNonceMiddleware=a,_.createPreloadingMiddleware=s,_.createRootURLMiddleware=c,_.fetchAllMiddleware=m;e.default=_},44:function(t,e,r){"use strict";function n(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function o(t){return function(){var e=this,r=arguments;return new Promise((function(o,i){var a=t.apply(e,r);function u(t){n(a,o,i,u,c,"next",t)}function c(t){n(a,o,i,u,c,"throw",t)}u(void 0)}))}}r.d(e,"a",(function(){return o}))},54:function(t,e,r){var n=function(){return this||"object"==typeof self&&self}()||Function("return this")(),o=n.regeneratorRuntime&&Object.getOwnPropertyNames(n).indexOf("regeneratorRuntime")>=0,i=o&&n.regeneratorRuntime;if(n.regeneratorRuntime=void 0,t.exports=r(55),o)n.regeneratorRuntime=i;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}},55:function(t,e){!function(e){"use strict";var r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag",c="object"==typeof t,s=e.regeneratorRuntime;if(s)c&&(t.exports=s);else{(s=e.regeneratorRuntime=c?t.exports:{}).wrap=v;var f={},l={};l[i]=function(){return this};var p=Object.getPrototypeOf,h=p&&p(p(L([])));h&&h!==r&&n.call(h,i)&&(l=h);var d=b.prototype=g.prototype=Object.create(l);m.prototype=d.constructor=b,b.constructor=m,b[u]=m.displayName="GeneratorFunction",s.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===m||"GeneratorFunction"===(e.displayName||e.name))},s.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,u in t||(t[u]="GeneratorFunction")),t.prototype=Object.create(d),t},s.awrap=function(t){return{__await:t}},w(O.prototype),O.prototype[a]=function(){return this},s.AsyncIterator=O,s.async=function(t,e,r,n){var o=new O(v(t,e,r,n));return s.isGeneratorFunction(e)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},w(d),d[u]="Generator",d[i]=function(){return this},d.toString=function(){return"[object Generator]"},s.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},s.values=L,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return r("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),c=n.call(i,"finallyLoc");if(u&&c){if(this.prev<i.catchLoc)return r(i.catchLoc,!0);if(this.prev<i.finallyLoc)return r(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return r(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return r(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:L(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}}}function v(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,i=Object.create(o.prototype),a=new P(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return E()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=j(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=y(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function y(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function g(){}function m(){}function b(){}function w(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function O(t){var e;this._invoke=function(r,o){function i(){return new Promise((function(e,i){!function e(r,o,i,a){var u=y(t[r],t,o);if("throw"!==u.type){var c=u.arg,s=c.value;return s&&"object"==typeof s&&n.call(s,"__await")?Promise.resolve(s.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(s).then((function(t){c.value=t,i(c)}),(function(t){return e("throw",t,i,a)}))}a(u.arg)}(r,o,e,i)}))}return e=e?e.then(i,i):i()}}function j(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=y(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:E}}function E(){return{value:void 0,done:!0}}}(function(){return this||"object"==typeof self&&self}()||Function("return this")())},7:function(t,e,r){"use strict";r.d(e,"a",(function(){return o}));var n=r(15);function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),o.forEach((function(e){Object(n.a)(t,e,r[e])}))}return t}}}).default;