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

1 line
6.8 KiB
JavaScript
Raw Normal View History

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("