1 line
6.8 KiB
JavaScript
1 line
6.8 KiB
JavaScript
this.wp=this.wp||{},this.wp.apiFetch=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=311)}({1:function(e,t){!function(){e.exports=this.wp.i18n}()},15:function(e,t,r){"use strict";function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.d(t,"a",function(){return n})},20:function(e,t,r){"use strict";function n(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}r.d(t,"a",function(){return n})},23:function(e,t){!function(){e.exports=this.wp.hooks}()},29:function(e,t){!function(){e.exports=this.wp.url}()},311:function(e,t,r){"use strict";r.r(t);var n=r(37),o=r(8),a=r(20),u=r(1),c=r(23),i=function(e){return function(t,r){var n=e;Object(c.addAction)("heartbeat.tick","core/api-fetch/create-nonce-middleware",function(e){e["rest-nonce"]&&(n=e["rest-nonce"])});var a=t.headers||{},u=!0;for(var i in a)if(a.hasOwnProperty(i)&&"x-wp-nonce"===i.toLowerCase()){u=!1;break}return u&&(a=Object(o.a)({},a,{"X-WP-Nonce":n})),r(Object(o.a)({},t,{headers:a}))}},s=function(e,t){var r,n,a=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(r=e.namespace.replace(/^\/|\/$/g,""),a=(n=e.endpoint.replace(/^\//,""))?r+"/"+n:r),delete e.namespace,delete e.endpoint,t(Object(o.a)({},e,{path:a}))},f=function(e){return function(t,r){return s(t,function(t){var n,a=t.url,u=t.path;return"string"==typeof u&&(n=e,-1!==e.indexOf("?")&&(u=u.replace("?","&")),u=u.replace(/^\//,""),"string"==typeof n&&-1!==n.indexOf("?")&&(u=u.replace("?","&")),a=n+u),r(Object(o.a)({},t,{url:a}))})}},p=function(e){return function(t,r){var n=t.parse,o=void 0===n||n;if("string"==typeof t.path&&o){var a=t.method||"GET",u=function(e){var t=e.split("?"),r=t[1],n=t[0];return r?n+"?"+r.split("&").map(function(e){return e.split("=")}).sort(function(e,t){return e[0].localeCompare(t[0])}).map(function(e){return e.join("=")}).join("&"):n}(t.path);if("GET"===a&&e[u])return Promise.resolve(e[u].body)}return r(t)}},l=r(29),d=function(e,t){var r=e.path,n=e.url,u=Object(a.a)(e,["path","url"]);return Object(o.a)({},u,{url:n&&Object(l.addQueryArgs)(n,t),path:r&&Object(l.addQueryArgs)(r,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"),r=e.url&&-1!==e.url.indexOf("per_page=-1");return t||r},O=function(){var e=Object(n.a)(regeneratorRuntime.mark(function e(t,r){var n,a,u,c,i,s;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==t.parse){e.next=2;break}return e.abrupt("return",r(t));case 2:if(v(t)){e.next=4;break}return e.abrupt("return",r(t));case 4:return e.next=6,r(Object(o.a)({},d(t,{per_page:100}),{parse:!1}));case 6:return n=e.sent,e.next=9,h(n);case 9:if(a=e.sent,Array.isArray(a)){e.next=12;break}return e.abrupt("return",a);case 12:if(u=b(n)){e.next=15;break}return e.abrupt("return",a);case 15:c=[].concat(a);case 16:if(!u){e.next=27;break}return e.next=19,r(Object(o.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,this)}));return function(t,r){return e.apply(this,arguments)}}();var y=function(e,t){var r=Object(o.a)({},e);return r.method&&["PATCH","PUT","DELETE"].indexOf(r.method.toUpperCase())>=0&&(r.headers||(r.headers={}),r.headers["X-HTTP-Method-Override"]=r.method,r.headers["Content-Type"]="application/json",r.method="POST"),t(r,t)},j=[];function m(e){if("string"==typeof e&&e.indexOf("Cloudflare Ray ID")>=0)throw{code:"cloudflare_error"}}function w(e){var t=[function(e){var t=e.url,r=e.path,c=e.body,i=e.data,s=e.parse,f=void 0===s||s,p=Object(a.a)(e,["url","path","body","data","parse"]),l=p.headers||{};!l["Content-Type"]&&i&&(l["Content-Type"]="application/json");return window.fetch(t||r,Object(o.a)({},p,{credentials:"include",body:c||JSON.stringify(i),headers:l})).then(function(e){if(e.status>=200&&e.status<300)return e;throw e}).then(function(e){return f?e.json?e.json():Promise.reject(e):e}).catch(function(e){if(!f)throw e;var t={code:"invalid_json",message:Object(u.__)("The response is not a valid JSON response.")};if(!e||!e.json)throw t;var r=e.clone();return e.json().catch(Object(n.a)(regeneratorRuntime.mark(function e(){return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r.text();case 2:throw m(e.sent),t;case 5:case"end":return e.stop()}},e,this)}))).then(function(e){var t={code:"unknown_error",message:Object(u.__)("An unknown error occurred.")};throw m(e),e||t})})},O,y,s].concat(j).reverse();return function e(r){return function(n){return(0,t[r])(n,e(r+1))}}(0)(e)}w.use=function(e){j.push(e)},w.createNonceMiddleware=i,w.createPreloadingMiddleware=p,w.createRootURLMiddleware=f,w.fetchAllMiddleware=O;t.default=w},37:function(e,t,r){"use strict";function n(e,t,r,n,o,a,u){try{var c=e[a](u),i=c.value}catch(e){return void r(e)}c.done?t(i):Promise.resolve(i).then(n,o)}function o(e){return function(){var t=this,r=arguments;return new Promise(function(o,a){var u=e.apply(t,r);function c(e){n(u,o,a,c,i,"next",e)}function i(e){n(u,o,a,c,i,"throw",e)}c(void 0)})}}r.d(t,"a",function(){return o})},8:function(e,t,r){"use strict";r.d(t,"a",function(){return o});var n=r(15);function o(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},o=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),o.forEach(function(t){Object(n.a)(e,t,r[t])})}return e}}}).default; |