WordPress/wp-includes/js/dist/api-fetch.min.js

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=324)}({1:function(t,e){!function(){t.exports=this.wp.i18n}()},10: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}))},20:function(t,e,r){t.exports=r(47)},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}))},26:function(t,e){!function(){t.exports=this.wp.url}()},324: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},c=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}))},u=function(t){return function(e,r){return c(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}))}))}},f=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)}},s=r(20),l=r.n(s),h=r(43),p=r(26),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(p.addQueryArgs)(i,e),path:r&&Object(p.addQueryArgs)(r,e)})},y=function(t){return t.json?t.json():Promise.reject(t)},v=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},b=function(){var t=Object(h.a)(l.a.mark((function t(e,r){var o,i,a,c,u,f;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,y(o);case 9:if(i=t.sent,Array.isArray(i)){t.next=12;break}return t.abrupt("return",i);case 12:if(a=v(o)){t.next=15;break}return t.abrupt("return",i);case 15:c=[].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 u=t.sent,t.next=22,y(u);case 22:f=t.sent,c=c.concat(f),a=v(u),t.next=16;break;case 27:return t.abrupt("return",c);case 28:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),m=new Set(["PATCH","PUT","DELETE"]),w="GET";var O={Accept:"application/json, */*;q=0.1"},j={credentials:"include"},x=[function(t,e){return"string"!=typeof t.url||Object(p.hasQueryArg)(t.url,"_locale")||(t.url=Object(p.addQueryArgs)(t.url,{_locale:"user"})),"string"!=typeof t.path||Object(p.hasQueryArg)(t.path,"_locale")||(t.path=Object(p.addQueryArgs)(t.path,{_locale:"user"})),e(t,e)},c,function(t,e){var r=t.method,o=void 0===r?w:r;return m.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)},b];var _=function(t){if(t.status>=200&&t.status<300)return t;throw t},P=function(t){var e=t.url,r=t.path,a=t.data,c=t.parse,u=void 0===c||c,f=Object(o.a)(t,["url","path","data","parse"]),s=t.body,l=t.headers;l=Object(n.a)({},O,l),a&&(s=JSON.stringify(a),l["Content-Type"]="application/json");return window.fetch(e||r,Object(n.a)({},j,f,{body:s,headers:l})).then(_).then((function(t){return u?204===t.status?null:t.json?t.json():Promise.reject(t):t})).catch((function(t){if(!u)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 E(t){var e=[].concat(x,[P]);return new Promise((function(r,n){(function t(r){return function(n){var o=e[r];return r===e.length-1?o(n):o(n,t(r+1))}})(0)(t).then(r).catch((function(e){if("rest_cookie_invalid_nonce"!==e.code)return n(e);window.fetch(E.nonceEndpoint).then(_).then((function(t){return t.text()})).then((function(e){E.nonceMiddleware.nonce=e,E(t).then(r).catch(n)})).catch(n)}))}))}E.use=function(t){x.unshift(t)},E.setFetchHandler=function(t){P=t},E.createNonceMiddleware=a,E.createPreloadingMiddleware=f,E.createRootURLMiddleware=u,E.fetchAllMiddleware=b;e.default=E},43:function(t,e,r){"use strict";function n(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).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 c(t){n(a,o,i,c,u,"next",t)}function u(t){n(a,o,i,c,u,"throw",t)}c(void 0)}))}}r.d(e,"a",(function(){return o}))},47:function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function u(t,e,r,n){var o=e&&e.prototype instanceof y?e:y,i=Object.create(o.prototype),a=new L(n||[]);return i._invoke=function(t,e,r){var n=s;return function(o,i){if(n===h)throw new Error("Generator is already running");if(n===p){if("throw"===o)throw i;return S()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=_(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===s)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=h;var u=f(t,e,r);if("normal"===u.type){if(n=r.done?p:l,u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=p,r.method="throw",r.arg=u.arg)}}}(t,r,a),i}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var s="suspendedStart",l="suspendedYield",h="executing",p="completed",d={};function y(){}function v(){}function g(){}var b={};b[i]=function(){return this};var m=Object.getPrototypeOf,w=m&&m(m(k([])));w&&w!==r&&n.call(w,i)&&(b=w);var O=g.prototype=y.prototype=Object.create(b);function j(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function x(t){var e;this._invoke=function(r,o){function i(){return new Promise((function(e,i){!function e(r,o,i,a){var c=f(t[r],t,o);if("throw"!==c.type){var u=c.arg,s=u.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){u.value=t,i(u)}),(function(t){return e("throw",t,i,a)}))}a(c.arg)}(r,o,e,i)}))}return e=e?e.then(i,i):i()}}function _(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,_(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=f(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,d;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function P(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 E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(P,this),this.reset(!0)}function k(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:S}}function S(){return{value:e,done:!0}}return v.prototype=O.constructor=g,g.constructor=v,g[c]=v.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,c in t||(t[c]="GeneratorFunction")),t.prototype=Object.create(O),t},t.awrap=function(t){return{__await:t}},j(x.prototype),x.prototype[a]=function(){return this},t.AsyncIterator=x,t.async=function(e,r,n,o){var i=new x(u(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},j(O),O[c]="Generator",O[i]=function(){return this},O.toString=function(){return"[object Generator]"},t.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}},t.values=k,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(E),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},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 r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),f=n.call(a,"finallyLoc");if(u&&f){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!f)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.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,d):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),d},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),E(r),d}},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;E(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},7:function(t,e,r){"use strict";r.d(e,"a",(function(){return o}));var n=r(10);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;