WordPress/wp-includes/js/dist/api-fetch.min.js
gziolo 355c05ea71 Build Tools: Integrate DependencyExtractionWebpackPlugin in the JS build.
This patch integrates DependencyExtractionWebpackPlugin which was battle-tested in Gutenberg. 

This will greatly simplify the process of upgrading npm packages which change after every Gutenberg release. It might even useful during the WordPress release cycle as we might need to publish more often as we discover critical bugs and regressions.

Props jonsurrell, adamsilverstein, youknowriad, ocean90, netweb.

Fixes #48154. 


Built from https://develop.svn.wordpress.org/trunk@47035


git-svn-id: http://core.svn.wordpress.org/trunk@46835 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-03 13:17:24 +00:00

2 lines
8.3 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.apiFetch=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=354)}({1:function(e,t){!function(){e.exports=this.wp.i18n}()},10:function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}n.d(t,"a",(function(){return r}))},20:function(e,t){!function(){e.exports=this.regeneratorRuntime}()},21:function(e,t,n){"use strict";function r(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}n.d(t,"a",(function(){return r}))},26:function(e,t){!function(){e.exports=this.wp.url}()},354:function(e,t,n){"use strict";n.r(t);var r=n(7),a=n(21);var o=function(e){function t(e,n){var a=e.headers,o=void 0===a?{}:a;for(var u in o)if("x-wp-nonce"===u.toLowerCase())return n(e);return n(Object(r.a)({},e,{headers:Object(r.a)({},o,{"X-WP-Nonce":t.nonce})}))}return t.nonce=e,t},u=function(e,t){var n,a,o=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(n=e.namespace.replace(/^\/|\/$/g,""),o=(a=e.endpoint.replace(/^\//,""))?n+"/"+a:n),delete e.namespace,delete e.endpoint,t(Object(r.a)({},e,{path:o}))},c=function(e){return function(t,n){return u(t,(function(t){var a,o=t.url,u=t.path;return"string"==typeof u&&(a=e,-1!==e.indexOf("?")&&(u=u.replace("?","&")),u=u.replace(/^\//,""),"string"==typeof a&&-1!==a.indexOf("?")&&(u=u.replace("?","&")),o=a+u),n(Object(r.a)({},t,{url:o}))}))}},i=function(e){return function(t,n){var r=t.parse,a=void 0===r||r;if("string"==typeof t.path){var o=t.method||"GET",u=function(e){var t=e.split("?"),n=t[1],r=t[0];return n?r+"?"+n.split("&").map((function(e){return e.split("=")})).sort((function(e,t){return e[0].localeCompare(t[0])})).map((function(e){return e.join("=")})).join("&"):r}(t.path);if(a&&"GET"===o&&e[u])return Promise.resolve(e[u].body);if("OPTIONS"===o&&e[o]&&e[o][u])return Promise.resolve(e[o][u])}return n(t)}},s=n(20),f=n.n(s),p=n(43),l=n(26),d=function(e,t){var n=e.path,o=e.url,u=Object(a.a)(e,["path","url"]);return Object(r.a)({},u,{url:o&&Object(l.addQueryArgs)(o,t),path:n&&Object(l.addQueryArgs)(n,t)})},h=function(e){return e.json?e.json():Promise.reject(e)},b=function(e){return function(e){if(!e)return{};var t=e.match(/<([^>]+)>; rel="next"/);return t?{next:t[1]}:{}}(e.headers.get("link")).next},v=function(e){var t=e.path&&-1!==e.path.indexOf("per_page=-1"),n=e.url&&-1!==e.url.indexOf("per_page=-1");return t||n},O=function(){var e=Object(p.a)(f.a.mark((function e(t,n){var a,o,u,c,i,s;return f.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==t.parse){e.next=2;break}return e.abrupt("return",n(t));case 2:if(v(t)){e.next=4;break}return e.abrupt("return",n(t));case 4:return e.next=6,n(Object(r.a)({},d(t,{per_page:100}),{parse:!1}));case 6:return a=e.sent,e.next=9,h(a);case 9:if(o=e.sent,Array.isArray(o)){e.next=12;break}return e.abrupt("return",o);case 12:if(u=b(a)){e.next=15;break}return e.abrupt("return",o);case 15:c=[].concat(o);case 16:if(!u){e.next=27;break}return e.next=19,n(Object(r.a)({},t,{path:void 0,url:u,parse:!1}));case 19:return i=e.sent,e.next=22,h(i);case 22:s=e.sent,c=c.concat(s),u=b(i),e.next=16;break;case 27:return e.abrupt("return",c);case 28:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),j=new Set(["PATCH","PUT","DELETE"]),y="GET";var m=function(e,t){var n=e.method,a=void 0===n?y:n;return j.has(a.toUpperCase())&&(e=Object(r.a)({},e,{headers:Object(r.a)({},e.headers,{"X-HTTP-Method-Override":a,"Content-Type":"application/json"}),method:"POST"})),t(e,t)};var g=function(e,t){return"string"!=typeof e.url||Object(l.hasQueryArg)(e.url,"_locale")||(e.url=Object(l.addQueryArgs)(e.url,{_locale:"user"})),"string"!=typeof e.path||Object(l.hasQueryArg)(e.path,"_locale")||(e.path=Object(l.addQueryArgs)(e.path,{_locale:"user"})),t(e,t)},w=n(1),x=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t?204===e.status?null:e.json?e.json():Promise.reject(e):e},P=function(e){var t={code:"invalid_json",message:Object(w.__)("The response is not a valid JSON response.")};if(!e||!e.json)throw t;return e.json().catch((function(){throw t}))},_=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Promise.resolve(x(e,t)).catch((function(e){return T(e,t)}))};function T(e){if(!(!(arguments.length>1&&void 0!==arguments[1])||arguments[1]))throw e;return P(e).then((function(e){var t={code:"unknown_error",message:Object(w.__)("An unknown error occurred.")};throw e||t}))}var S=function(e,t){if(!(e.path&&-1!==e.path.indexOf("/wp/v2/media")||e.url&&-1!==e.url.indexOf("/wp/v2/media")))return t(e,t);var n=0;return t(Object(r.a)({},e,{parse:!1})).catch((function(r){var a=r.headers.get("x-wp-upload-attachment-id");return r.status>=500&&r.status<600&&a?function e(r){return n++,t({path:"/wp/v2/media/".concat(r,"/post-process"),method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch((function(){return n<5?e(r):(t({path:"/wp/v2/media/".concat(r,"?force=true"),method:"DELETE"}),Promise.reject())}))}(a).catch((function(){return!1!==e.parse?Promise.reject({code:"post_process",message:Object(w.__)("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(r)})):T(r,e.parse)})).then((function(t){return _(t,e.parse)}))},k={Accept:"application/json, */*;q=0.1"},A={credentials:"include"},E=[g,u,m,O];var M=function(e){if(e.status>=200&&e.status<300)return e;throw e},C=function(e){var t=e.url,n=e.path,o=e.data,u=e.parse,c=void 0===u||u,i=Object(a.a)(e,["url","path","data","parse"]),s=e.body,f=e.headers;return f=Object(r.a)({},k,f),o&&(s=JSON.stringify(o),f["Content-Type"]="application/json"),window.fetch(t||n,Object(r.a)({},A,i,{body:s,headers:f})).then(M).catch((function(e){return T(e,c)})).then((function(e){return _(e,c)}))};function Q(e){var t=[].concat(E,[C]);return new Promise((function(n,r){(function e(n){return function(r){var a=t[n];return n===t.length-1?a(r):a(r,e(n+1))}})(0)(e).then(n).catch((function(t){if("rest_cookie_invalid_nonce"!==t.code)return r(t);window.fetch(Q.nonceEndpoint).then(M).then((function(e){return e.text()})).then((function(t){Q.nonceMiddleware.nonce=t,Q(e).then(n).catch(r)})).catch(r)}))}))}Q.use=function(e){E.unshift(e)},Q.setFetchHandler=function(e){C=e},Q.createNonceMiddleware=o,Q.createPreloadingMiddleware=i,Q.createRootURLMiddleware=c,Q.fetchAllMiddleware=O,Q.mediaUploadMiddleware=S;t.default=Q},43:function(e,t,n){"use strict";function r(e,t,n,r,a,o,u){try{var c=e[o](u),i=c.value}catch(e){return void n(e)}c.done?t(i):Promise.resolve(i).then(r,a)}function a(e){return function(){var t=this,n=arguments;return new Promise((function(a,o){var u=e.apply(t,n);function c(e){r(u,a,o,c,i,"next",e)}function i(e){r(u,a,o,c,i,"throw",e)}c(void 0)}))}}n.d(t,"a",(function(){return a}))},7:function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(10);function a(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},a=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(a=a.concat(Object.getOwnPropertySymbols(n).filter((function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable})))),a.forEach((function(t){Object(r.a)(e,t,n[t])}))}return e}}}).default;