PluginProbe
Gutenberg / trunk
Gutenberg vtrunk
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/scripts/api-fetch/index.min.js +4 -1 23.2.2 → trunk View file →
@@ -1,3 +1,6 @@
1 -"use strict";var wp;(wp||={}).apiFetch=(()=>{var $=Object.create;var w=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var A=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),X=(e,r)=>{for(var a in r)w(e,a,{get:r[a],enumerable:!0})},x=(e,r,a,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of G(r))!K.call(e,n)&&n!==a&&w(e,n,{get:()=>r[n],enumerable:!(t=q(r,n))||t.enumerable});return e};var f=(e,r,a)=>(a=e!=null?$(V(e)):{},x(r||!e||!e.__esModule?w(a,"default",{value:e,enumerable:!0}):a,e)),B=e=>x(w({},"__esModule",{value:!0}),e);var v=A((ge,O)=>{O.exports=window.wp.i18n});var p=A((Pe,j)=>{j.exports=window.wp.url});var ve={};X(ve,{default:()=>g});var P=f(v(),1);function Y(e){let r=(a,t)=>{let{headers:n={}}=a;for(let d in n)if(d.toLowerCase()==="x-wp-nonce"&&n[d]===r.nonce)return t(a);return t({...a,headers:{...n,"X-WP-Nonce":r.nonce}})};return r.nonce=e,r}var R=Y;var Z=(e,r)=>{let a=e.path,t,n;return typeof e.namespace=="string"&&typeof e.endpoint=="string"&&(t=e.namespace.replace(/^\/|\/$/g,""),n=e.endpoint.replace(/^\//,""),n?a=t+"/"+n:a=t),delete e.namespace,delete e.endpoint,r({...e,path:a})},_=Z;var W=e=>(r,a)=>_(r,t=>{let n=t.url,d=t.path,i;return typeof d=="string"&&(i=e,e.indexOf("?")!==-1&&(d=d.replace("?","&")),d=d.replace(/^\//,""),typeof i=="string"&&i.indexOf("?")!==-1&&(d=d.replace("?","&")),n=i+d),a({...t,url:n})}),b=W;var m=f(p(),1);function ee(e){let r=Object.fromEntries(Object.entries(e).map(([a,t])=>[(0,m.normalizePath)(a),t]));return(a,t)=>{let{parse:n=!0}=a,d=a.path;if(!d&&a.url){let{rest_route:s,...o}=(0,m.getQueryArgs)(a.url);typeof s=="string"&&(d=(0,m.addQueryArgs)(s,o))}if(typeof d!="string")return t(a);let i=a.method||"GET",l=(0,m.normalizePath)(d);if(i==="GET"&&r[l]){let s=r[l];return delete r[l],U(s,!!n)}else if(i==="OPTIONS"&&r[i]&&r[i][l]){let s=r[i][l];return delete r[i][l],U(s,!!n)}return t(a)}}function U(e,r){if(r)return Promise.resolve(e.body);try{return Promise.resolve(new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}catch{return Object.entries(e.headers).forEach(([a,t])=>{a.toLowerCase()==="link"&&(e.headers[a]=t.replace(/<([^>]+)>/,(n,d)=>`<${encodeURI(d)}>`))}),Promise.resolve(r?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}}var N=ee;var M=f(p(),1);var re=({path:e,url:r,...a},t)=>({...a,url:r&&(0,M.addQueryArgs)(r,t),path:e&&(0,M.addQueryArgs)(e,t)}),L=e=>e.json?e.json():Promise.reject(e),ae=e=>{if(!e)return{};let r=e.match(/<([^>]+)>; rel="next"/);return r?{next:r[1]}:{}},S=e=>{let{next:r}=ae(e.headers.get("link"));return r},te=e=>{let r=!!e.path&&e.path.indexOf("per_page=-1")!==-1,a=!!e.url&&e.url.indexOf("per_page=-1")!==-1;return r||a},de=async(e,r)=>{if(e.parse===!1||!te(e))return r(e);let a=await g({...re(e,{per_page:100}),parse:!1}),t=await L(a);if(!Array.isArray(t))return t;let n=S(a);if(!n)return t;let d=[].concat(t);for(;n;){let i=await g({...e,path:void 0,url:n,parse:!1}),l=await L(i);d=d.concat(l),n=S(i)}return d},E=de;var ne=new Set(["PATCH","PUT","DELETE"]),ie="GET",le=(e,r)=>{let{method:a=ie}=e;return ne.has(a.toUpperCase())&&(e={...e,headers:{"Content-Type":"application/json",...e.headers,"X-HTTP-Method-Override":a},method:"POST"}),r(e)},H=le;var h=f(p(),1),ce=(e,r)=>(typeof e.url=="string"&&!(0,h.hasQueryArg)(e.url,"_locale")&&(e.url=(0,h.addQueryArgs)(e.url,{_locale:"user"})),typeof e.path=="string"&&!(0,h.hasQueryArg)(e.path,"_locale")&&(e.path=(0,h.addQueryArgs)(e.path,{_locale:"user"})),r(e)),Q=ce;var I=f(v(),1);var C=f(v(),1);async function F(e){try{return await e.json()}catch{throw{code:"invalid_json",message:(0,C.__)("The response is not a valid JSON response.")}}}async function y(e,r=!0){return r?e.status===204?null:await F(e):e}async function T(e,r=!0){throw r?await F(e):e}function oe(e){let r=!!e.method&&e.method==="POST";return(!!e.path&&e.path.indexOf("/wp/v2/media")!==-1||!!e.url&&e.url.indexOf("/wp/v2/media")!==-1)&&r}var ue=(e,r)=>{if(!oe(e))return r(e);let a=0,t=5,n=d=>(a++,r({path:`/wp/v2/media/${d}/post-process`,method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch(()=>a<t?n(d):(r({path:`/wp/v2/media/${d}?force=true`,method:"DELETE"}),Promise.reject())));return r({...e,parse:!1}).catch(d=>{if(!(d instanceof globalThis.Response))return Promise.reject(d);let i=d.headers.get("x-wp-upload-attachment-id");return d.status>=500&&d.status<600&&i?n(i).catch(()=>e.parse!==!1?Promise.reject({code:"post_process",message:(0,I.__)("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(d)):T(d,e.parse)}).then(d=>y(d,e.parse))},z=ue;var u=f(p(),1),se=e=>(r,a)=>{if(typeof r.url=="string"){let t=(0,u.getQueryArg)(r.url,"wp_theme_preview");t===void 0?r.url=(0,u.addQueryArgs)(r.url,{wp_theme_preview:e}):t===""&&(r.url=(0,u.removeQueryArgs)(r.url,"wp_theme_preview"))}if(typeof r.path=="string"){let t=(0,u.getQueryArg)(r.path,"wp_theme_preview");t===void 0?r.path=(0,u.addQueryArgs)(r.path,{wp_theme_preview:e}):t===""&&(r.path=(0,u.removeQueryArgs)(r.path,"wp_theme_preview"))}return a(r)},k=se;var fe={Accept:"application/json, */*;q=0.1"},me={credentials:"include"},J=[Q,_,H,E];function he(e){J.unshift(e)}var pe=e=>{let{url:r,path:a,data:t,parse:n=!0,...d}=e,{body:i,headers:l}=e;return l={...fe,...l},t&&(i=JSON.stringify(t),l["Content-Type"]="application/json"),globalThis.fetch(r||a||window.location.href,{...me,...d,body:i,headers:l}).then(o=>o.ok?y(o,n):T(o,n),o=>{throw o&&o.name==="AbortError"?o:globalThis.navigator.onLine?{code:"fetch_error",message:(0,P.__)("Could not get a valid response from the server.")}:{code:"offline_error",message:(0,P.__)("Unable to connect. Please check your Internet connection.")}})},D=pe;function we(e){D=e}var c=e=>J.reduceRight((a,t)=>n=>t(n,a),D)(e).catch(a=>a.code!=="rest_cookie_invalid_nonce"?Promise.reject(a):globalThis.fetch(c.nonceEndpoint).then(t=>t.ok?t.text():Promise.reject(a)).then(t=>(c.nonceMiddleware.nonce=t,c(e))));c.use=he;c.setFetchHandler=we;c.createNonceMiddleware=R;c.createPreloadingMiddleware=N;c.createRootURLMiddleware=b;c.fetchAllMiddleware=E;c.mediaUploadMiddleware=z;c.createThemePreviewMiddleware=k;var g=c;return B(ve);})();
1 +(function() {
2 +"use strict";var wp;(wp||={}).apiFetch=(()=>{var te=Object.create;var y=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var de=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var P=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),le=(e,r)=>{for(var t in r)y(e,t,{get:r[t],enumerable:!0})},j=(e,r,t,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of ne(r))!ie.call(e,d)&&d!==t&&y(e,d,{get:()=>r[d],enumerable:!(a=ae(r,d))||a.enumerable});return e};var p=(e,r,t)=>(t=e!=null?te(de(e)):{},j(r||!e||!e.__esModule?y(t,"default",{value:e,enumerable:!0}):t,e)),oe=e=>j(y({},"__esModule",{value:!0}),e);var E=P((Se,I)=>{I.exports=window.wp.i18n});var C=P((je,k)=>{k.exports=window.wp.privateApis});var _=P((Ge,z)=>{z.exports=window.wp.url});var Le={};le(Le,{default:()=>A});var N=p(E(),1);var H=p(C(),1),{lock:F,unlock:Ie}=(0,H.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/api-fetch");function se(e){let r=(t,a)=>{let{headers:d={}}=t;for(let n in d)if(n.toLowerCase()==="x-wp-nonce"&&d[n]===r.nonce)return a(t);return a({...t,headers:{...d,"X-WP-Nonce":r.nonce}})};return r.nonce=e,r}var Q=se;var ce=(e,r)=>{let t=e.path,a,d;return typeof e.namespace=="string"&&typeof e.endpoint=="string"&&(a=e.namespace.replace(/^\/|\/$/g,""),d=e.endpoint.replace(/^\//,""),d?t=a+"/"+d:t=a),delete e.namespace,delete e.endpoint,r({...e,path:t})},T=ce;var ue=e=>(r,t)=>T(r,a=>{let d=a.url,n=a.path,l;return typeof n=="string"&&(l=e,e.indexOf("?")!==-1&&(n=n.replace("?","&")),n=n.replace(/^\//,""),typeof l=="string"&&l.indexOf("?")!==-1&&(n=n.replace("?","&")),d=l+n),t({...a,url:d})}),G=ue;var m=p(_(),1),x=Symbol("preloadingEnableMultiUse"),R=Symbol("preloadingClear");function fe(e){let{OPTIONS:r={},...t}=Object.fromEntries(Object.entries(e).map(([i,s])=>[(0,m.normalizePath)(i),s])),a=new Set(Object.keys(t)),d=new Set(Object.keys(r)),n=!1,l=(i,s)=>{let{parse:c=!0}=i,g=i.path;if(!g&&i.url){let{rest_route:h,...re}=(0,m.getQueryArgs)(i.url);typeof h=="string"&&(g=(0,m.addQueryArgs)(h,re))}if(typeof g!="string")return s(i);let S=i.method||"GET",f=(0,m.normalizePath)(g);if(S==="GET"&&t[f]){let h=t[f];return n||delete t[f],a.delete(f),J(h,!!c)}else if(S==="OPTIONS"&&r[f]){let h=r[f];return n||delete r[f],d.delete(f),J(h,!!c)}return s(i)};return l[x]=()=>{n=!0},l[R]=()=>{let i=[...Array.from(a,s=>`GET ${s}`),...Array.from(d,s=>`OPTIONS ${s}`)];i.length?console.warn("[api-fetch][preload] Some preloads were never consumed:",i):console.log("[api-fetch][preload] All preloads consumed."),a.clear(),d.clear();for(let s of Object.keys(t))delete t[s];for(let s of Object.keys(r))delete r[s]},l}function J(e,r){if(r)return Promise.resolve(e.body);try{return Promise.resolve(new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}catch{return Object.entries(e.headers).forEach(([t,a])=>{t.toLowerCase()==="link"&&(e.headers[t]=a.replace(/<([^>]+)>/,(d,n)=>`<${encodeURI(n)}>`))}),Promise.resolve(r?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}}var $=fe;var b=p(_(),1);var pe=({path:e,url:r,...t},a)=>({...t,url:r&&(0,b.addQueryArgs)(r,a),path:e&&(0,b.addQueryArgs)(e,a)}),D=e=>e.json?e.json():Promise.reject(e),me=e=>{if(!e)return{};let r=e.match(/<([^>]+)>; rel="next"/);return r?{next:r[1]}:{}},V=e=>{let{next:r}=me(e.headers.get("link"));return r},he=e=>{let r=!!e.path&&e.path.indexOf("per_page=-1")!==-1,t=!!e.url&&e.url.indexOf("per_page=-1")!==-1;return r||t},we=async(e,r)=>{if(e.parse===!1||!he(e))return r(e);let t=await A({...pe(e,{per_page:100}),parse:!1}),a=await D(t);if(!Array.isArray(a))return a;let d=V(t);if(!d)return a;let n=[].concat(a);for(;d;){let l=await A({...e,path:void 0,url:d,parse:!1}),i=await D(l);n=n.concat(i),d=V(l)}return n},U=we;var ve=new Set(["PATCH","PUT","DELETE"]),_e="GET",ge=(e,r)=>{let{method:t=_e}=e;return ve.has(t.toUpperCase())&&(e={...e,headers:{"Content-Type":"application/json",...e.headers,"X-HTTP-Method-Override":t},method:"POST"}),r(e)},L=ge;var w=p(_(),1),ye=(e,r)=>(typeof e.url=="string"&&!(0,w.hasQueryArg)(e.url,"_locale")&&(e.url=(0,w.addQueryArgs)(e.url,{_locale:"user"})),typeof e.path=="string"&&!(0,w.hasQueryArg)(e.path,"_locale")&&(e.path=(0,w.addQueryArgs)(e.path,{_locale:"user"})),r(e)),q=ye;var X=p(E(),1);var B=p(E(),1);async function K(e,r=!1){try{if(typeof e.text!="function")return await e.json();let t=await e.text();return r&&t===""?null:JSON.parse(t)}catch{throw{code:"invalid_json",message:(0,B.__)("The response is not a valid JSON response.")}}}async function M(e,r=!0){return r?e.status===204?null:await K(e,!0):e}async function O(e,r=!0){throw r?await K(e):e}function Ee(e){let r=!!e.method&&e.method==="POST";return(!!e.path&&e.path.indexOf("/wp/v2/media")!==-1||!!e.url&&e.url.indexOf("/wp/v2/media")!==-1)&&r}var Te=(e,r)=>{if(!Ee(e))return r(e);let t=0,a=5,d=n=>(t++,r({path:`/wp/v2/media/${n}/post-process`,method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch(()=>t<a?d(n):(r({path:`/wp/v2/media/${n}?force=true`,method:"DELETE"}),Promise.reject())));return r({...e,parse:!1}).catch(n=>{if(!(n instanceof globalThis.Response))return Promise.reject(n);let l=n.headers.get("x-wp-upload-attachment-id");return n.status>=500&&n.status<600&&l?d(l).catch(()=>e.parse!==!1?Promise.reject({code:"post_process",message:(0,X.__)("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(n)):O(n,e.parse)}).then(n=>M(n,e.parse))},W=Te;var u=p(_(),1),Ae=e=>(r,t)=>{if(typeof r.url=="string"){let a=(0,u.getQueryArg)(r.url,"wp_theme_preview");a===void 0?r.url=(0,u.addQueryArgs)(r.url,{wp_theme_preview:e}):a===""&&(r.url=(0,u.removeQueryArgs)(r.url,"wp_theme_preview"))}if(typeof r.path=="string"){let a=(0,u.getQueryArg)(r.path,"wp_theme_preview");a===void 0?r.path=(0,u.addQueryArgs)(r.path,{wp_theme_preview:e}):a===""&&(r.path=(0,u.removeQueryArgs)(r.path,"wp_theme_preview"))}return t(r)},Y=Ae;var Me={Accept:"application/json, */*;q=0.1"},Oe={credentials:"include"},v=[q,T,L,U];function Pe(e){v.unshift(e)}function xe(e){let r=v.indexOf(e);return r===-1?!1:(v.splice(r,1),!0)}function Re(){for(let e of v)e[x]?.()}function be(){for(let e of v)e[R]?.()}var Z=e=>{let{url:r,path:t,data:a,parse:d=!0,...n}=e,{body:l,headers:i}=e;return i={...Me,...i},a&&(l=JSON.stringify(a),i["Content-Type"]="application/json"),globalThis.fetch(r||t||window.location.href,{...Oe,...n,body:l,headers:i}).then(c=>c.ok?M(c,d):O(c,d),c=>{throw c&&c.name==="AbortError"?c:globalThis.navigator.onLine?{code:"fetch_error",message:(0,N.__)("Could not get a valid response from the server.")}:{code:"offline_error",message:(0,N.__)("Unable to connect. Please check your Internet connection.")}})},ee=Z;function Ue(e){ee=e}var o=e=>v.reduceRight((t,a)=>d=>a(d,t),ee)(e).catch(t=>t.code!=="rest_cookie_invalid_nonce"?Promise.reject(t):globalThis.fetch(o.nonceEndpoint).then(a=>a.ok?a.text():Promise.reject(t)).then(a=>(o.nonceMiddleware.nonce=a,o(e))));o.use=Pe;o.unregister=xe;o.setFetchHandler=Ue;o.defaultFetchHandler=Z;o.privateApis={};F(o.privateApis,{enablePreloadMultiUse:Re,clearPreloadedData:be});o.createNonceMiddleware=Q;o.createPreloadingMiddleware=$;o.createRootURLMiddleware=G;o.fetchAllMiddleware=U;o.httpV1Middleware=L;o.mediaUploadMiddleware=W;o.createThemePreviewMiddleware=Y;var A=o;return oe(Le);})();
2 3 if (typeof wp.apiFetch === 'object' && wp.apiFetch.default) { wp.apiFetch = wp.apiFetch.default; }
4 +(window.wp ||= {}).apiFetch = wp.apiFetch;
5 +})();
3 6 //# sourceMappingURL=index.min.js.map