Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Catch and log exceptions #64

Merged
merged 10 commits into from
Jan 28, 2025
Merged

feat: Catch and log exceptions #64

merged 10 commits into from
Jan 28, 2025

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Jan 25, 2025

Related:

What?

Communicate exception details to host apps. The approach is heavily inspired by prior art in wordpress-mobile/gutenberg-mobile#6655.

Why?

Allow host apps to act on exceptions, like sending them to a observability service.

How?

Implement error parsing and bridging logic to forward exceptions to the host app.

Testing Instructions

See the test steps for each of iOS and Android:

Accessibility Testing Instructions

N/A, no user-facing changes.

Screenshots or screencast

N/A, no user-facing changes.

Catch render errors with Gutenberg's default error boundary component.
Allow the host app to act on errors.
Allow the iOS host app to act on errors.
Extract relevant attributes for logging to monitoring services.
@dcalhoun dcalhoun added the [Type] Enhancement A suggestion for improvement. label Jan 25, 2025
Catch errors within the editor component.
Enable parsing stringified JSON objects sent from WebViews to the host
Android app.
Enable the Android host app to act upon editor exceptions.
@@ -0,0 +1,3 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./layout-nZjJAiRL.js","./layout-6w9yLuYZ.css"])))=>i.map(i=>d[i]);
import we from"@wordpress/block-editor/build-style/default-editor-styles.css?inline";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();const ge="modulepreload",me=function(e,t){return new URL(e,t).href},q={},ye=function(t,r,n){let s=Promise.resolve();if(r&&r.length>0){const a=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");s=Promise.allSettled(r.map(l=>{if(l=me(l,n),l in q)return;q[l]=!0;const w=l.endsWith(".css"),o=w?'[rel="stylesheet"]':"";if(!!n)for(let _=a.length-1;_>=0;_--){const f=a[_];if(f.href===l&&(!w||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${o}`))return;const h=document.createElement("link");if(h.rel=w?"stylesheet":ge,w||(h.as="script"),h.crossOrigin="",h.href=l,u&&h.setAttribute("nonce",u),document.head.appendChild(h),w)return new Promise((_,f)=>{h.addEventListener("load",_),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return s.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var H={},K;function _e(){return K||(K=1,function(e){(function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function r(c){return s(a(c),arguments)}function n(c,u){return r.apply(null,[c].concat(u||[]))}function s(c,u){var l=1,w=c.length,o,m="",h,_,f,S,A,k,P,d;for(h=0;h<w;h++)if(typeof c[h]=="string")m+=c[h];else if(typeof c[h]=="object"){if(f=c[h],f.keys)for(o=u[l],_=0;_<f.keys.length;_++){if(o==null)throw new Error(r('[sprintf] Cannot access property "%s" of undefined value "%s"',f.keys[_],f.keys[_-1]));o=o[f.keys[_]]}else f.param_no?o=u[f.param_no]:o=u[l++];if(t.not_type.test(f.type)&&t.not_primitive.test(f.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(f.type)&&typeof o!="number"&&isNaN(o))throw new TypeError(r("[sprintf] expecting number but found %T",o));switch(t.number.test(f.type)&&(P=o>=0),f.type){case"b":o=parseInt(o,10).toString(2);break;case"c":o=String.fromCharCode(parseInt(o,10));break;case"d":case"i":o=parseInt(o,10);break;case"j":o=JSON.stringify(o,null,f.width?parseInt(f.width):0);break;case"e":o=f.precision?parseFloat(o).toExponential(f.precision):parseFloat(o).toExponential();break;case"f":o=f.precision?parseFloat(o).toFixed(f.precision):parseFloat(o);break;case"g":o=f.precision?String(Number(o.toPrecision(f.precision))):parseFloat(o);break;case"o":o=(parseInt(o,10)>>>0).toString(8);break;case"s":o=String(o),o=f.precision?o.substring(0,f.precision):o;break;case"t":o=String(!!o),o=f.precision?o.substring(0,f.precision):o;break;case"T":o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=f.precision?o.substring(0,f.precision):o;break;case"u":o=parseInt(o,10)>>>0;break;case"v":o=o.valueOf(),o=f.precision?o.substring(0,f.precision):o;break;case"x":o=(parseInt(o,10)>>>0).toString(16);break;case"X":o=(parseInt(o,10)>>>0).toString(16).toUpperCase();break}t.json.test(f.type)?m+=o:(t.number.test(f.type)&&(!P||f.sign)?(d=P?"+":"-",o=o.toString().replace(t.sign,"")):d="",A=f.pad_char?f.pad_char==="0"?"0":f.pad_char.charAt(1):" ",k=f.width-(d+o).length,S=f.width&&k>0?A.repeat(k):"",m+=f.align?d+o+S:A==="0"?d+S+o:S+d+o)}return m}var i=Object.create(null);function a(c){if(i[c])return i[c];for(var u=c,l,w=[],o=0;u;){if((l=t.text.exec(u))!==null)w.push(l[0]);else if((l=t.modulo.exec(u))!==null)w.push("%");else if((l=t.placeholder.exec(u))!==null){if(l[2]){o|=1;var m=[],h=l[2],_=[];if((_=t.key.exec(h))!==null)for(m.push(_[1]);(h=h.substring(_[0].length))!=="";)if((_=t.key_access.exec(h))!==null)m.push(_[1]);else if((_=t.index_access.exec(h))!==null)m.push(_[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=m}else o|=2;if(o===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");w.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");u=u.substring(l[0].length)}return i[c]=w}e.sprintf=r,e.vsprintf=n,typeof window<"u"&&(window.sprintf=r,window.vsprintf=n)})()}(H)),H}_e();var I,ie,O,ae;I={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1};ie=["(","?"];O={")":["("],":":["?","?:"]};ae=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;function be(e){for(var t=[],r=[],n,s,i,a;n=e.match(ae);){for(s=n[0],i=e.substr(0,n.index).trim(),i&&t.push(i);a=r.pop();){if(O[s]){if(O[s][0]===a){s=O[s][1]||s;break}}else if(ie.indexOf(a)>=0||I[a]<I[s]){r.push(a);break}t.push(a)}O[s]||r.push(s),e=e.substr(n.index+s.length)}return e=e.trim(),e&&t.push(e),t.concat(r.reverse())}var ve={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,r){if(e)throw t;return r}};function Ee(e,t){var r=[],n,s,i,a,c,u;for(n=0;n<e.length;n++){if(c=e[n],a=ve[c],a){for(s=a.length,i=Array(s);s--;)i[s]=r.pop();try{u=a.apply(null,i)}catch(l){return l}}else t.hasOwnProperty(c)?u=t[c]:u=+c;r.push(u)}return r[0]}function xe(e){var t=be(e);return function(r){return Ee(t,r)}}function Se(e){var t=xe(e);return function(r){return+t({n:r})}}var B={contextDelimiter:"",onMissingKey:null};function Ae(e){var t,r,n;for(t=e.split(";"),r=0;r<t.length;r++)if(n=t[r].trim(),n.indexOf("plural=")===0)return n.substr(7)}function N(e,t){var r;this.data=e,this.pluralForms={},this.options={};for(r in B)this.options[r]=t!==void 0&&r in t?t[r]:B[r]}N.prototype.getPluralForm=function(e,t){var r=this.pluralForms[e],n,s,i;return r||(n=this.data[e][""],i=n["Plural-Forms"]||n["plural-forms"]||n.plural_forms,typeof i!="function"&&(s=Ae(n["Plural-Forms"]||n["plural-forms"]||n.plural_forms),i=Se(s)),r=this.pluralForms[e]=i),r(t)};N.prototype.dcnpgettext=function(e,t,r,n,s){var i,a,c;return s===void 0?i=0:i=this.getPluralForm(e,s),a=r,t&&(a=t+this.options.contextDelimiter+r),c=this.data[e][a],c&&c[i]?c[i]:(this.options.onMissingKey&&this.options.onMissingKey(r,e),i===0?r:n)};const G={"":{plural_forms(e){return e===1?0:1}}},ke=/^i18n\.(n?gettext|has_translation)(_|$)/,Pe=(e,t,r)=>{const n=new N({}),s=new Set,i=()=>{s.forEach(d=>d())},a=d=>(s.add(d),()=>s.delete(d)),c=(d="default")=>n.data[d],u=(d,p="default")=>{n.data[p]={...n.data[p],...d},n.data[p][""]={...G[""],...n.data[p]?.[""]},delete n.pluralForms[p]},l=(d,p)=>{u(d,p),i()},w=(d,p="default")=>{n.data[p]={...n.data[p],...d,"":{...G[""],...n.data[p]?.[""],...d?.[""]}},delete n.pluralForms[p],i()},o=(d,p)=>{n.data={},n.pluralForms={},l(d,p)},m=(d="default",p,g,v,E)=>(n.data[d]||u(void 0,d),n.dcnpgettext(d,p,g,v,E)),h=(d="default")=>d,_=(d,p)=>{let g=m(p,void 0,d);return r?(g=r.applyFilters("i18n.gettext",g,d,p),r.applyFilters("i18n.gettext_"+h(p),g,d,p)):g},f=(d,p,g)=>{let v=m(g,p,d);return r?(v=r.applyFilters("i18n.gettext_with_context",v,d,p,g),r.applyFilters("i18n.gettext_with_context_"+h(g),v,d,p,g)):v},S=(d,p,g,v)=>{let E=m(v,void 0,d,p,g);return r?(E=r.applyFilters("i18n.ngettext",E,d,p,g,v),r.applyFilters("i18n.ngettext_"+h(v),E,d,p,g,v)):E},A=(d,p,g,v,E)=>{let T=m(E,v,d,p,g);return r?(T=r.applyFilters("i18n.ngettext_with_context",T,d,p,g,v,E),r.applyFilters("i18n.ngettext_with_context_"+h(E),T,d,p,g,v,E)):T},k=()=>f("ltr","text direction")==="rtl",P=(d,p,g)=>{const v=p?p+""+d:d;let E=!!n.data?.[g??"default"]?.[v];return r&&(E=r.applyFilters("i18n.has_translation",E,d,p,g),E=r.applyFilters("i18n.has_translation_"+h(g),E,d,p,g)),E};if(r){const d=p=>{ke.test(p)&&i()};r.addAction("hookAdded","core/i18n",d),r.addAction("hookRemoved","core/i18n",d)}return{getLocaleData:c,setLocaleData:l,addLocaleData:w,resetLocaleData:o,subscribe:a,__:_,_x:f,_n:S,_nx:A,isRTL:k,hasTranslation:P}};function oe(e){return typeof e!="string"||e===""?(console.error("The namespace must be a non-empty string."),!1):/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e)?!0:(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)}function $(e){return typeof e!="string"||e===""?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(e)?(console.error("The hook name cannot begin with `__`."),!1):/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e)?!0:(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)}function J(e,t){return function(n,s,i,a=10){const c=e[t];if(!$(n)||!oe(s))return;if(typeof i!="function"){console.error("The hook callback must be a function.");return}if(typeof a!="number"){console.error("If specified, the hook priority must be a number.");return}const u={callback:i,priority:a,namespace:s};if(c[n]){const l=c[n].handlers;let w;for(w=l.length;w>0&&!(a>=l[w-1].priority);w--);w===l.length?l[w]=u:l.splice(w,0,u),c.__current.forEach(o=>{o.name===n&&o.currentIndex>=w&&o.currentIndex++})}else c[n]={handlers:[u],runs:0};n!=="hookAdded"&&e.doAction("hookAdded",n,s,i,a)}}function M(e,t,r=!1){return function(s,i){const a=e[t];if(!$(s)||!r&&!oe(i))return;if(!a[s])return 0;let c=0;if(r)c=a[s].handlers.length,a[s]={runs:a[s].runs,handlers:[]};else{const u=a[s].handlers;for(let l=u.length-1;l>=0;l--)u[l].namespace===i&&(u.splice(l,1),c++,a.__current.forEach(w=>{w.name===s&&w.currentIndex>=l&&w.currentIndex--}))}return s!=="hookRemoved"&&e.doAction("hookRemoved",s,i),c}}function Q(e,t){return function(n,s){const i=e[t];return typeof s<"u"?n in i&&i[n].handlers.some(a=>a.namespace===s):n in i}}function D(e,t,r,n){return function(i,...a){const c=e[t];c[i]||(c[i]={handlers:[],runs:0}),c[i].runs++;const u=c[i].handlers;if(!u||!u.length)return r?a[0]:void 0;const l={name:i,currentIndex:0};async function w(){try{c.__current.add(l);let m=r?a[0]:void 0;for(;l.currentIndex<u.length;)m=await u[l.currentIndex].callback.apply(null,a),r&&(a[0]=m),l.currentIndex++;return r?m:void 0}finally{c.__current.delete(l)}}function o(){try{c.__current.add(l);let m=r?a[0]:void 0;for(;l.currentIndex<u.length;)m=u[l.currentIndex].callback.apply(null,a),r&&(a[0]=m),l.currentIndex++;return r?m:void 0}finally{c.__current.delete(l)}}return(n?w:o)()}}function X(e,t){return function(){var n;const s=e[t];return(n=Array.from(s.__current).at(-1)?.name)!==null&&n!==void 0?n:null}}function V(e,t){return function(n){const s=e[t];return typeof n>"u"?s.__current.size>0:Array.from(s.__current).some(i=>i.name===n)}}function Z(e,t){return function(n){const s=e[t];if($(n))return s[n]&&s[n].runs?s[n].runs:0}}class Oe{constructor(){this.actions=Object.create(null),this.actions.__current=new Set,this.filters=Object.create(null),this.filters.__current=new Set,this.addAction=J(this,"actions"),this.addFilter=J(this,"filters"),this.removeAction=M(this,"actions"),this.removeFilter=M(this,"filters"),this.hasAction=Q(this,"actions"),this.hasFilter=Q(this,"filters"),this.removeAllActions=M(this,"actions",!0),this.removeAllFilters=M(this,"filters",!0),this.doAction=D(this,"actions",!1,!1),this.doActionAsync=D(this,"actions",!1,!0),this.applyFilters=D(this,"filters",!0,!1),this.applyFiltersAsync=D(this,"filters",!0,!0),this.currentAction=X(this,"actions"),this.currentFilter=X(this,"filters"),this.doingAction=V(this,"actions"),this.doingFilter=V(this,"filters"),this.didAction=Z(this,"actions"),this.didFilter=Z(this,"filters")}}function Re(){return new Oe}const Te=Re(),b=Pe(void 0,void 0,Te);b.getLocaleData.bind(b);b.setLocaleData.bind(b);b.resetLocaleData.bind(b);b.subscribe.bind(b);const F=b.__.bind(b);b._x.bind(b);b._n.bind(b);b._nx.bind(b);b.isRTL.bind(b);b.hasTranslation.bind(b);function Me(e){const t=(r,n)=>{const{headers:s={}}=r;for(const i in s)if(i.toLowerCase()==="x-wp-nonce"&&s[i]===t.nonce)return n(r);return n({...r,headers:{...s,"X-WP-Nonce":t.nonce}})};return t.nonce=e,t}const ce=(e,t)=>{let r=e.path,n,s;return typeof e.namespace=="string"&&typeof e.endpoint=="string"&&(n=e.namespace.replace(/^\/|\/$/g,""),s=e.endpoint.replace(/^\//,""),s?r=n+"/"+s:r=n),delete e.namespace,delete e.endpoint,t({...e,path:r})},De=e=>(t,r)=>ce(t,n=>{let s=n.url,i=n.path,a;return typeof i=="string"&&(a=e,e.indexOf("?")!==-1&&(i=i.replace("?","&")),i=i.replace(/^\//,""),typeof a=="string"&&a.indexOf("?")!==-1&&(i=i.replace("?","&")),s=a+i),r({...n,url:s})});function Le(e){let t;try{t=new URL(e,"http://example.com").search.substring(1)}catch{}if(t)return t}function le(e){let t="";const r=Object.entries(e);let n;for(;n=r.shift();){let[s,i]=n;if(Array.isArray(i)||i&&i.constructor===Object){const c=Object.entries(i).reverse();for(const[u,l]of c)r.unshift([`${s}[${u}]`,l])}else i!==void 0&&(i===null&&(i=""),t+="&"+[s,i].map(encodeURIComponent).join("="))}return t.substr(1)}function Fe(e){try{return decodeURIComponent(e)}catch{return e}}function Ce(e,t,r){const n=t.length,s=n-1;for(let i=0;i<n;i++){let a=t[i];!a&&Array.isArray(e)&&(a=e.length.toString()),a=["__proto__","constructor","prototype"].includes(a)?a.toUpperCase():a;const c=!isNaN(Number(t[i+1]));e[a]=i===s?r:e[a]||(c?[]:{}),Array.isArray(e[a])&&!c&&(e[a]={...e[a]}),e=e[a]}}function C(e){return(Le(e)||"").replace(/\+/g,"%20").split("&").reduce((t,r)=>{const[n,s=""]=r.split("=").filter(Boolean).map(Fe);if(n){const i=n.replace(/\]/g,"").split("[");Ce(t,i,s)}return t},Object.create(null))}function x(e="",t){if(!t||!Object.keys(t).length)return e;let r=e;const n=e.indexOf("?");return n!==-1&&(t=Object.assign(C(e),t),r=r.substr(0,n)),r+"?"+le(t)}function j(e,t){return C(e)[t]}function W(e,t){return j(e,t)!==void 0}function Y(e,...t){const r=e.indexOf("?");if(r===-1)return e;const n=C(e),s=e.substr(0,r);t.forEach(a=>delete n[a]);const i=le(n);return i?s+"?"+i:s}function ee(e){const t=e.split("?"),r=t[1],n=t[0];return r?n+"?"+r.split("&").map(s=>s.split("=")).map(s=>s.map(decodeURIComponent)).sort((s,i)=>s[0].localeCompare(i[0])).map(s=>s.map(encodeURIComponent)).map(s=>s.join("=")).join("&"):n}function He(e){const t=Object.fromEntries(Object.entries(e).map(([r,n])=>[ee(r),n]));return(r,n)=>{const{parse:s=!0}=r;let i=r.path;if(!i&&r.url){const{rest_route:u,...l}=C(r.url);typeof u=="string"&&(i=x(u,l))}if(typeof i!="string")return n(r);const a=r.method||"GET",c=ee(i);if(a==="GET"&&t[c]){const u=t[c];return delete t[c],te(u,!!s)}else if(a==="OPTIONS"&&t[a]&&t[a][c]){const u=t[a][c];return delete t[a][c],te(u,!!s)}return n(r)}}function te(e,t){return Promise.resolve(t?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}const Ie=({path:e,url:t,...r},n)=>({...r,url:t&&x(t,n),path:e&&x(e,n)}),re=e=>e.json?e.json():Promise.reject(e),je=e=>{if(!e)return{};const t=e.match(/<([^>]+)>; rel="next"/);return t?{next:t[1]}:{}},ne=e=>{const{next:t}=je(e.headers.get("link"));return t},Ue=e=>{const t=!!e.path&&e.path.indexOf("per_page=-1")!==-1,r=!!e.url&&e.url.indexOf("per_page=-1")!==-1;return t||r},ue=async(e,t)=>{if(e.parse===!1||!Ue(e))return t(e);const r=await y({...Ie(e,{per_page:100}),parse:!1}),n=await re(r);if(!Array.isArray(n))return n;let s=ne(r);if(!s)return n;let i=[].concat(n);for(;s;){const a=await y({...e,path:void 0,url:s,parse:!1}),c=await re(a);i=i.concat(c),s=ne(a)}return i},Ne=new Set(["PATCH","PUT","DELETE"]),$e="GET",ze=(e,t)=>{const{method:r=$e}=e;return Ne.has(r.toUpperCase())&&(e={...e,headers:{...e.headers,"X-HTTP-Method-Override":r,"Content-Type":"application/json"},method:"POST"}),t(e)},qe=(e,t)=>(typeof e.url=="string"&&!W(e.url,"_locale")&&(e.url=x(e.url,{_locale:"user"})),typeof e.path=="string"&&!W(e.path,"_locale")&&(e.path=x(e.path,{_locale:"user"})),t(e)),Ke=(e,t=!0)=>t?e.status===204?null:e.json?e.json():Promise.reject(e):e,Be=e=>{const t={code:"invalid_json",message:F("The response is not a valid JSON response.")};if(!e||!e.json)throw t;return e.json().catch(()=>{throw t})},de=(e,t=!0)=>Promise.resolve(Ke(e,t)).catch(r=>z(r,t));function z(e,t=!0){if(!t)throw e;return Be(e).then(r=>{const n={code:"unknown_error",message:F("An unknown error occurred.")};throw r||n})}function Ge(e){const t=!!e.method&&e.method==="POST";return(!!e.path&&e.path.indexOf("/wp/v2/media")!==-1||!!e.url&&e.url.indexOf("/wp/v2/media")!==-1)&&t}const Je=(e,t)=>{if(!Ge(e))return t(e);let r=0;const n=5,s=i=>(r++,t({path:`/wp/v2/media/${i}/post-process`,method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch(()=>r<n?s(i):(t({path:`/wp/v2/media/${i}?force=true`,method:"DELETE"}),Promise.reject())));return t({...e,parse:!1}).catch(i=>{if(!i.headers)return Promise.reject(i);const a=i.headers.get("x-wp-upload-attachment-id");return i.status>=500&&i.status<600&&a?s(a).catch(()=>e.parse!==!1?Promise.reject({code:"post_process",message:F("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(i)):z(i,e.parse)}).then(i=>de(i,e.parse))},Qe=e=>(t,r)=>{if(typeof t.url=="string"){const n=j(t.url,"wp_theme_preview");n===void 0?t.url=x(t.url,{wp_theme_preview:e}):n===""&&(t.url=Y(t.url,"wp_theme_preview"))}if(typeof t.path=="string"){const n=j(t.path,"wp_theme_preview");n===void 0?t.path=x(t.path,{wp_theme_preview:e}):n===""&&(t.path=Y(t.path,"wp_theme_preview"))}return r(t)},Xe={Accept:"application/json, */*;q=0.1"},Ve={credentials:"include"},fe=[qe,ce,ze,ue];function Ze(e){fe.unshift(e)}const pe=e=>{if(e.status>=200&&e.status<300)return e;throw e},We=e=>{const{url:t,path:r,data:n,parse:s=!0,...i}=e;let{body:a,headers:c}=e;return c={...Xe,...c},n&&(a=JSON.stringify(n),c["Content-Type"]="application/json"),window.fetch(t||r||window.location.href,{...Ve,...i,body:a,headers:c}).then(l=>Promise.resolve(l).then(pe).catch(w=>z(w,s)).then(w=>de(w,s)),l=>{throw l&&l.name==="AbortError"?l:{code:"fetch_error",message:F("You are probably offline.")}})};let he=We;function Ye(e){he=e}function y(e){return fe.reduceRight((r,n)=>s=>n(s,r),he)(e).catch(r=>r.code!=="rest_cookie_invalid_nonce"?Promise.reject(r):window.fetch(y.nonceEndpoint).then(pe).then(n=>n.text()).then(n=>(y.nonceMiddleware.nonce=n,y(e))))}y.use=Ze;y.setFetchHandler=Ye;y.createNonceMiddleware=Me;y.createPreloadingMiddleware=He;y.createRootURLMiddleware=De;y.fetchAllMiddleware=ue;y.mediaUploadMiddleware=Je;y.createThemePreviewMiddleware=Qe;const et="0.0.3",L="?";function U(e,t,r,n){const s={filename:e,function:t==="<anonymous>"?L:t,in_app:!0};return r!==void 0&&(s.lineno=r),n!==void 0&&(s.colno=n),s}const tt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,rt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,nt=/\((\S*)(?::(\d+))(?::(\d+))\)/,st=e=>{const t=tt.exec(e);if(t){const[,n,s,i]=t;return U(n,L,+s,+i)}const r=rt.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){const a=nt.exec(r[2]);a&&(r[2]=a[1],r[3]=a[2],r[4]=a[3])}const s=r[1]||L,i=r[2];return U(i,s,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},it=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,at=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ot=e=>{const t=it.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const i=at.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}const n=t[3],s=t[1]||L;return U(n,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},se=50,ct=[st,ot],lt=e=>{const t=e.stacktrace||e.stack||"",r=[],n=t.split(`
`);for(let i=0;i<n.length;i++){const a=n[i];if(!(a.length>1024)&&!a.match(/\S*Error: /)){for(const c of ct){const u=c(a);if(u){r.push(u);break}}if(r.length>=se)break}}const s=Array.from(r).reverse();return s.slice(0,se).map(i=>({...i,filename:i.filename||s[s.length-1].filename}))},ut=e=>{const t=e?.message;return t?typeof t.error?.message=="string"?t.error.message:t:"No error message"},dt=e=>{const t={type:e?.name,message:ut(e)},r=lt(e);return r.length&&(t.stacktrace=r),t.type===void 0&&t.message===""&&(t.message="Unknown error"),t},ft=(e,{context:t,tags:r}={})=>({...dt(e),context:{...t},tags:{...r,gutenberg_kit_version:et}});function kt(){window.editorDelegate&&window.editorDelegate.onEditorLoaded(),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorLoaded",body:{}})}function Pt(){window.editorDelegate&&window.editorDelegate.onEditorContentChanged(),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorContentChanged"})}function Ot(e,t){window.editorDelegate&&window.editorDelegate.onEditorHistoryChanged(e,t),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorHistoryChanged",body:{hasUndo:e,hasRedo:t}})}function Rt(e){window.editorDelegate&&window.editorDelegate.openMediaLibrary(JSON.stringify(e)),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"openMediaLibrary",body:e})}function R(){if(window.GBKit)return window.GBKit;if(window.editorDelegate)try{return JSON.parse(window.editorDelegate.getEditorConfiguration())}catch{return{}}try{return JSON.parse(localStorage.getItem("GBKit"))||{}}catch{return{}}}function pt(){const{post:e}=R();return e?{id:e.id,title:{raw:decodeURIComponent(e.title)},content:{raw:decodeURIComponent(e.content)},type:e.type||"post"}:{type:"post",status:"draft",id:-1}}function Tt(e,{context:t,tags:r,isHandled:n,handledBy:s}={context:{},tags:{},isHandled:!1,handledBy:"Unknown"}){const i={...ft(e,{context:t,tags:r}),isHandled:n,handledBy:s};window.editorDelegate&&window.editorDelegate.onEditorExceptionLogged(JSON.stringify(i)),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorExceptionLogged",body:i})}function ht(){const{siteApiRoot:e="",authHeader:t}=R();y.use(y.createRootURLMiddleware(e)),y.use(wt),y.use(gt),y.use(mt(t)),y.use(yt),y.use(_t),y.use(y.createPreloadingMiddleware({"/wp/v2/types?context=view":{body:{post:{description:"",hierarchical:!1,has_archive:!1,name:"Posts",slug:"post",taxonomies:["category","post_tag"],rest_base:"posts",rest_namespace:"wp/v2",template:[],template_lock:!1,_links:{}},page:{description:"",hierarchical:!0,has_archive:!1,name:"Pages",slug:"page",taxonomies:[],rest_base:"pages",rest_namespace:"wp/v2",template:[],template_lock:!1,_links:{}}}},"/wp/v2/types/post?context=edit":{body:{name:"Posts",slug:"post",supports:{title:!0,editor:!0,author:!0,thumbnail:!0,excerpt:!0,trackbacks:!0,"custom-fields":!0,comments:!0,revisions:!0,"post-formats":!0,autosave:!0},taxonomies:["category","post_tag"],rest_base:"posts",rest_namespace:"wp/v2",template:[],template_lock:!1}}}))}function wt(e,t){return e.mode="cors",delete e.headers["x-wp-api-fetch-from-editor"],t(e)}function gt(e,t){const{siteApiNamespace:r}=R();return e.path&&r&&!e.path.includes(r)&&(e.path=e.path.replace(/^(?<apiPath>\/?(?:[\w.-]+\/){2})/,`$<apiPath>${r}/`)),t(e)}function mt(e){return(t,r)=>(t.headers=t.headers||{},e&&(t.headers.Authorization=e),r(t))}function yt(e,t){return[/^\/wp\/v2\/posts\/-?\d+/,/^\/wp\/v2\/pages\/-?\d+/].some(s=>s.test(e.path))?Promise.resolve([]):t(e)}function _t(e,t){return e.path&&e.path.startsWith("/wp/v2/media")&&e.method==="POST"&&e.body instanceof FormData&&e.body.get("post")==="-1"&&e.body.delete("post"),t(e)}window.GBKit=R();window.wp=window.wp||{};window.wp.apiFetch=y;ht();bt();async function bt(){try{const{themeStyles:e,siteURL:t}=R(),{styles:r,scripts:n}=await y({url:`${t}/wp-json/__experimental/wp-block-editor/v1/editor-assets`});await vt([...r,...n].join(""));const{dispatch:s}=window.wp.data,{store:i}=window.wp.editor,{store:a}=window.wp.preferences;y({path:"/wp-block-editor/v1/settings"}).then(h=>{s(i).updateEditorSettings(h)}).catch(()=>{const h={defaultEditorStyles:[{css:we}]};s(i).updateEditorSettings(h)}),s(a).setDefaults("core/edit-post",{themeStyles:e});const u={post:pt()},{default:l}=await ye(async()=>{const{default:h}=await import("./layout-nZjJAiRL.js");return{default:h}},__vite__mapDeps([0,1]),import.meta.url),{createRoot:w,createElement:o,StrictMode:m}=window.wp.element;w(document.getElementById("root")).render(o(m,null,o(l,u)))}catch{window.location.href="index.html?error=remote_editor_load_error"}}async function vt(e){const t=new window.DOMParser().parseFromString(e,"text/html"),r=Array.from(t.querySelectorAll('link[rel="stylesheet"],script')).filter(n=>n.id&&!xt.test(n.src));for(const n of r)await St(n)}const Et=["api-fetch"],xt=new RegExp(Et.flatMap(e=>[`wp-content/plugins/gutenberg/build/${e.replace(/\//g,"\\/")}\\b`,`wp-includes/js/dist/${e.replace(/\//g,"\\/")}\\b`]).join("|"));function St(e){return new Promise(t=>{const r=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach(n=>{e[n]&&(r[n]=e[n])}),e.innerHTML&&r.appendChild(document.createTextNode(e.innerHTML)),r.onload=()=>t(!0),r.onerror=()=>{t(!1)},document.body.appendChild(r),(r.nodeName.toLowerCase()==="link"||r.nodeName.toLowerCase()==="script"&&!r.src)&&t()})}export{Pt as a,Rt as b,kt as e,Tt as l,Ot as o};

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.

Copilot Autofix AI about 1 month ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@@ -0,0 +1,3 @@
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./layout-nZjJAiRL.js","./layout-6w9yLuYZ.css"])))=>i.map(i=>d[i]);
import we from"@wordpress/block-editor/build-style/default-editor-styles.css?inline";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();const ge="modulepreload",me=function(e,t){return new URL(e,t).href},q={},ye=function(t,r,n){let s=Promise.resolve();if(r&&r.length>0){const a=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),u=c?.nonce||c?.getAttribute("nonce");s=Promise.allSettled(r.map(l=>{if(l=me(l,n),l in q)return;q[l]=!0;const w=l.endsWith(".css"),o=w?'[rel="stylesheet"]':"";if(!!n)for(let _=a.length-1;_>=0;_--){const f=a[_];if(f.href===l&&(!w||f.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${o}`))return;const h=document.createElement("link");if(h.rel=w?"stylesheet":ge,w||(h.as="script"),h.crossOrigin="",h.href=l,u&&h.setAttribute("nonce",u),document.head.appendChild(h),w)return new Promise((_,f)=>{h.addEventListener("load",_),h.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(a){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=a,window.dispatchEvent(c),!c.defaultPrevented)throw a}return s.then(a=>{for(const c of a||[])c.status==="rejected"&&i(c.reason);return t().catch(i)})};var H={},K;function _e(){return K||(K=1,function(e){(function(){var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function r(c){return s(a(c),arguments)}function n(c,u){return r.apply(null,[c].concat(u||[]))}function s(c,u){var l=1,w=c.length,o,m="",h,_,f,S,A,k,P,d;for(h=0;h<w;h++)if(typeof c[h]=="string")m+=c[h];else if(typeof c[h]=="object"){if(f=c[h],f.keys)for(o=u[l],_=0;_<f.keys.length;_++){if(o==null)throw new Error(r('[sprintf] Cannot access property "%s" of undefined value "%s"',f.keys[_],f.keys[_-1]));o=o[f.keys[_]]}else f.param_no?o=u[f.param_no]:o=u[l++];if(t.not_type.test(f.type)&&t.not_primitive.test(f.type)&&o instanceof Function&&(o=o()),t.numeric_arg.test(f.type)&&typeof o!="number"&&isNaN(o))throw new TypeError(r("[sprintf] expecting number but found %T",o));switch(t.number.test(f.type)&&(P=o>=0),f.type){case"b":o=parseInt(o,10).toString(2);break;case"c":o=String.fromCharCode(parseInt(o,10));break;case"d":case"i":o=parseInt(o,10);break;case"j":o=JSON.stringify(o,null,f.width?parseInt(f.width):0);break;case"e":o=f.precision?parseFloat(o).toExponential(f.precision):parseFloat(o).toExponential();break;case"f":o=f.precision?parseFloat(o).toFixed(f.precision):parseFloat(o);break;case"g":o=f.precision?String(Number(o.toPrecision(f.precision))):parseFloat(o);break;case"o":o=(parseInt(o,10)>>>0).toString(8);break;case"s":o=String(o),o=f.precision?o.substring(0,f.precision):o;break;case"t":o=String(!!o),o=f.precision?o.substring(0,f.precision):o;break;case"T":o=Object.prototype.toString.call(o).slice(8,-1).toLowerCase(),o=f.precision?o.substring(0,f.precision):o;break;case"u":o=parseInt(o,10)>>>0;break;case"v":o=o.valueOf(),o=f.precision?o.substring(0,f.precision):o;break;case"x":o=(parseInt(o,10)>>>0).toString(16);break;case"X":o=(parseInt(o,10)>>>0).toString(16).toUpperCase();break}t.json.test(f.type)?m+=o:(t.number.test(f.type)&&(!P||f.sign)?(d=P?"+":"-",o=o.toString().replace(t.sign,"")):d="",A=f.pad_char?f.pad_char==="0"?"0":f.pad_char.charAt(1):" ",k=f.width-(d+o).length,S=f.width&&k>0?A.repeat(k):"",m+=f.align?d+o+S:A==="0"?d+S+o:S+d+o)}return m}var i=Object.create(null);function a(c){if(i[c])return i[c];for(var u=c,l,w=[],o=0;u;){if((l=t.text.exec(u))!==null)w.push(l[0]);else if((l=t.modulo.exec(u))!==null)w.push("%");else if((l=t.placeholder.exec(u))!==null){if(l[2]){o|=1;var m=[],h=l[2],_=[];if((_=t.key.exec(h))!==null)for(m.push(_[1]);(h=h.substring(_[0].length))!=="";)if((_=t.key_access.exec(h))!==null)m.push(_[1]);else if((_=t.index_access.exec(h))!==null)m.push(_[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=m}else o|=2;if(o===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");w.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");u=u.substring(l[0].length)}return i[c]=w}e.sprintf=r,e.vsprintf=n,typeof window<"u"&&(window.sprintf=r,window.vsprintf=n)})()}(H)),H}_e();var I,ie,O,ae;I={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1};ie=["(","?"];O={")":["("],":":["?","?:"]};ae=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;function be(e){for(var t=[],r=[],n,s,i,a;n=e.match(ae);){for(s=n[0],i=e.substr(0,n.index).trim(),i&&t.push(i);a=r.pop();){if(O[s]){if(O[s][0]===a){s=O[s][1]||s;break}}else if(ie.indexOf(a)>=0||I[a]<I[s]){r.push(a);break}t.push(a)}O[s]||r.push(s),e=e.substr(n.index+s.length)}return e=e.trim(),e&&t.push(e),t.concat(r.reverse())}var ve={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,r){if(e)throw t;return r}};function Ee(e,t){var r=[],n,s,i,a,c,u;for(n=0;n<e.length;n++){if(c=e[n],a=ve[c],a){for(s=a.length,i=Array(s);s--;)i[s]=r.pop();try{u=a.apply(null,i)}catch(l){return l}}else t.hasOwnProperty(c)?u=t[c]:u=+c;r.push(u)}return r[0]}function xe(e){var t=be(e);return function(r){return Ee(t,r)}}function Se(e){var t=xe(e);return function(r){return+t({n:r})}}var B={contextDelimiter:"",onMissingKey:null};function Ae(e){var t,r,n;for(t=e.split(";"),r=0;r<t.length;r++)if(n=t[r].trim(),n.indexOf("plural=")===0)return n.substr(7)}function N(e,t){var r;this.data=e,this.pluralForms={},this.options={};for(r in B)this.options[r]=t!==void 0&&r in t?t[r]:B[r]}N.prototype.getPluralForm=function(e,t){var r=this.pluralForms[e],n,s,i;return r||(n=this.data[e][""],i=n["Plural-Forms"]||n["plural-forms"]||n.plural_forms,typeof i!="function"&&(s=Ae(n["Plural-Forms"]||n["plural-forms"]||n.plural_forms),i=Se(s)),r=this.pluralForms[e]=i),r(t)};N.prototype.dcnpgettext=function(e,t,r,n,s){var i,a,c;return s===void 0?i=0:i=this.getPluralForm(e,s),a=r,t&&(a=t+this.options.contextDelimiter+r),c=this.data[e][a],c&&c[i]?c[i]:(this.options.onMissingKey&&this.options.onMissingKey(r,e),i===0?r:n)};const G={"":{plural_forms(e){return e===1?0:1}}},ke=/^i18n\.(n?gettext|has_translation)(_|$)/,Pe=(e,t,r)=>{const n=new N({}),s=new Set,i=()=>{s.forEach(d=>d())},a=d=>(s.add(d),()=>s.delete(d)),c=(d="default")=>n.data[d],u=(d,p="default")=>{n.data[p]={...n.data[p],...d},n.data[p][""]={...G[""],...n.data[p]?.[""]},delete n.pluralForms[p]},l=(d,p)=>{u(d,p),i()},w=(d,p="default")=>{n.data[p]={...n.data[p],...d,"":{...G[""],...n.data[p]?.[""],...d?.[""]}},delete n.pluralForms[p],i()},o=(d,p)=>{n.data={},n.pluralForms={},l(d,p)},m=(d="default",p,g,v,E)=>(n.data[d]||u(void 0,d),n.dcnpgettext(d,p,g,v,E)),h=(d="default")=>d,_=(d,p)=>{let g=m(p,void 0,d);return r?(g=r.applyFilters("i18n.gettext",g,d,p),r.applyFilters("i18n.gettext_"+h(p),g,d,p)):g},f=(d,p,g)=>{let v=m(g,p,d);return r?(v=r.applyFilters("i18n.gettext_with_context",v,d,p,g),r.applyFilters("i18n.gettext_with_context_"+h(g),v,d,p,g)):v},S=(d,p,g,v)=>{let E=m(v,void 0,d,p,g);return r?(E=r.applyFilters("i18n.ngettext",E,d,p,g,v),r.applyFilters("i18n.ngettext_"+h(v),E,d,p,g,v)):E},A=(d,p,g,v,E)=>{let T=m(E,v,d,p,g);return r?(T=r.applyFilters("i18n.ngettext_with_context",T,d,p,g,v,E),r.applyFilters("i18n.ngettext_with_context_"+h(E),T,d,p,g,v,E)):T},k=()=>f("ltr","text direction")==="rtl",P=(d,p,g)=>{const v=p?p+""+d:d;let E=!!n.data?.[g??"default"]?.[v];return r&&(E=r.applyFilters("i18n.has_translation",E,d,p,g),E=r.applyFilters("i18n.has_translation_"+h(g),E,d,p,g)),E};if(r){const d=p=>{ke.test(p)&&i()};r.addAction("hookAdded","core/i18n",d),r.addAction("hookRemoved","core/i18n",d)}return{getLocaleData:c,setLocaleData:l,addLocaleData:w,resetLocaleData:o,subscribe:a,__:_,_x:f,_n:S,_nx:A,isRTL:k,hasTranslation:P}};function oe(e){return typeof e!="string"||e===""?(console.error("The namespace must be a non-empty string."),!1):/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e)?!0:(console.error("The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."),!1)}function $(e){return typeof e!="string"||e===""?(console.error("The hook name must be a non-empty string."),!1):/^__/.test(e)?(console.error("The hook name cannot begin with `__`."),!1):/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e)?!0:(console.error("The hook name can only contain numbers, letters, dashes, periods and underscores."),!1)}function J(e,t){return function(n,s,i,a=10){const c=e[t];if(!$(n)||!oe(s))return;if(typeof i!="function"){console.error("The hook callback must be a function.");return}if(typeof a!="number"){console.error("If specified, the hook priority must be a number.");return}const u={callback:i,priority:a,namespace:s};if(c[n]){const l=c[n].handlers;let w;for(w=l.length;w>0&&!(a>=l[w-1].priority);w--);w===l.length?l[w]=u:l.splice(w,0,u),c.__current.forEach(o=>{o.name===n&&o.currentIndex>=w&&o.currentIndex++})}else c[n]={handlers:[u],runs:0};n!=="hookAdded"&&e.doAction("hookAdded",n,s,i,a)}}function M(e,t,r=!1){return function(s,i){const a=e[t];if(!$(s)||!r&&!oe(i))return;if(!a[s])return 0;let c=0;if(r)c=a[s].handlers.length,a[s]={runs:a[s].runs,handlers:[]};else{const u=a[s].handlers;for(let l=u.length-1;l>=0;l--)u[l].namespace===i&&(u.splice(l,1),c++,a.__current.forEach(w=>{w.name===s&&w.currentIndex>=l&&w.currentIndex--}))}return s!=="hookRemoved"&&e.doAction("hookRemoved",s,i),c}}function Q(e,t){return function(n,s){const i=e[t];return typeof s<"u"?n in i&&i[n].handlers.some(a=>a.namespace===s):n in i}}function D(e,t,r,n){return function(i,...a){const c=e[t];c[i]||(c[i]={handlers:[],runs:0}),c[i].runs++;const u=c[i].handlers;if(!u||!u.length)return r?a[0]:void 0;const l={name:i,currentIndex:0};async function w(){try{c.__current.add(l);let m=r?a[0]:void 0;for(;l.currentIndex<u.length;)m=await u[l.currentIndex].callback.apply(null,a),r&&(a[0]=m),l.currentIndex++;return r?m:void 0}finally{c.__current.delete(l)}}function o(){try{c.__current.add(l);let m=r?a[0]:void 0;for(;l.currentIndex<u.length;)m=u[l.currentIndex].callback.apply(null,a),r&&(a[0]=m),l.currentIndex++;return r?m:void 0}finally{c.__current.delete(l)}}return(n?w:o)()}}function X(e,t){return function(){var n;const s=e[t];return(n=Array.from(s.__current).at(-1)?.name)!==null&&n!==void 0?n:null}}function V(e,t){return function(n){const s=e[t];return typeof n>"u"?s.__current.size>0:Array.from(s.__current).some(i=>i.name===n)}}function Z(e,t){return function(n){const s=e[t];if($(n))return s[n]&&s[n].runs?s[n].runs:0}}class Oe{constructor(){this.actions=Object.create(null),this.actions.__current=new Set,this.filters=Object.create(null),this.filters.__current=new Set,this.addAction=J(this,"actions"),this.addFilter=J(this,"filters"),this.removeAction=M(this,"actions"),this.removeFilter=M(this,"filters"),this.hasAction=Q(this,"actions"),this.hasFilter=Q(this,"filters"),this.removeAllActions=M(this,"actions",!0),this.removeAllFilters=M(this,"filters",!0),this.doAction=D(this,"actions",!1,!1),this.doActionAsync=D(this,"actions",!1,!0),this.applyFilters=D(this,"filters",!0,!1),this.applyFiltersAsync=D(this,"filters",!0,!0),this.currentAction=X(this,"actions"),this.currentFilter=X(this,"filters"),this.doingAction=V(this,"actions"),this.doingFilter=V(this,"filters"),this.didAction=Z(this,"actions"),this.didFilter=Z(this,"filters")}}function Re(){return new Oe}const Te=Re(),b=Pe(void 0,void 0,Te);b.getLocaleData.bind(b);b.setLocaleData.bind(b);b.resetLocaleData.bind(b);b.subscribe.bind(b);const F=b.__.bind(b);b._x.bind(b);b._n.bind(b);b._nx.bind(b);b.isRTL.bind(b);b.hasTranslation.bind(b);function Me(e){const t=(r,n)=>{const{headers:s={}}=r;for(const i in s)if(i.toLowerCase()==="x-wp-nonce"&&s[i]===t.nonce)return n(r);return n({...r,headers:{...s,"X-WP-Nonce":t.nonce}})};return t.nonce=e,t}const ce=(e,t)=>{let r=e.path,n,s;return typeof e.namespace=="string"&&typeof e.endpoint=="string"&&(n=e.namespace.replace(/^\/|\/$/g,""),s=e.endpoint.replace(/^\//,""),s?r=n+"/"+s:r=n),delete e.namespace,delete e.endpoint,t({...e,path:r})},De=e=>(t,r)=>ce(t,n=>{let s=n.url,i=n.path,a;return typeof i=="string"&&(a=e,e.indexOf("?")!==-1&&(i=i.replace("?","&")),i=i.replace(/^\//,""),typeof a=="string"&&a.indexOf("?")!==-1&&(i=i.replace("?","&")),s=a+i),r({...n,url:s})});function Le(e){let t;try{t=new URL(e,"http://example.com").search.substring(1)}catch{}if(t)return t}function le(e){let t="";const r=Object.entries(e);let n;for(;n=r.shift();){let[s,i]=n;if(Array.isArray(i)||i&&i.constructor===Object){const c=Object.entries(i).reverse();for(const[u,l]of c)r.unshift([`${s}[${u}]`,l])}else i!==void 0&&(i===null&&(i=""),t+="&"+[s,i].map(encodeURIComponent).join("="))}return t.substr(1)}function Fe(e){try{return decodeURIComponent(e)}catch{return e}}function Ce(e,t,r){const n=t.length,s=n-1;for(let i=0;i<n;i++){let a=t[i];!a&&Array.isArray(e)&&(a=e.length.toString()),a=["__proto__","constructor","prototype"].includes(a)?a.toUpperCase():a;const c=!isNaN(Number(t[i+1]));e[a]=i===s?r:e[a]||(c?[]:{}),Array.isArray(e[a])&&!c&&(e[a]={...e[a]}),e=e[a]}}function C(e){return(Le(e)||"").replace(/\+/g,"%20").split("&").reduce((t,r)=>{const[n,s=""]=r.split("=").filter(Boolean).map(Fe);if(n){const i=n.replace(/\]/g,"").split("[");Ce(t,i,s)}return t},Object.create(null))}function x(e="",t){if(!t||!Object.keys(t).length)return e;let r=e;const n=e.indexOf("?");return n!==-1&&(t=Object.assign(C(e),t),r=r.substr(0,n)),r+"?"+le(t)}function j(e,t){return C(e)[t]}function W(e,t){return j(e,t)!==void 0}function Y(e,...t){const r=e.indexOf("?");if(r===-1)return e;const n=C(e),s=e.substr(0,r);t.forEach(a=>delete n[a]);const i=le(n);return i?s+"?"+i:s}function ee(e){const t=e.split("?"),r=t[1],n=t[0];return r?n+"?"+r.split("&").map(s=>s.split("=")).map(s=>s.map(decodeURIComponent)).sort((s,i)=>s[0].localeCompare(i[0])).map(s=>s.map(encodeURIComponent)).map(s=>s.join("=")).join("&"):n}function He(e){const t=Object.fromEntries(Object.entries(e).map(([r,n])=>[ee(r),n]));return(r,n)=>{const{parse:s=!0}=r;let i=r.path;if(!i&&r.url){const{rest_route:u,...l}=C(r.url);typeof u=="string"&&(i=x(u,l))}if(typeof i!="string")return n(r);const a=r.method||"GET",c=ee(i);if(a==="GET"&&t[c]){const u=t[c];return delete t[c],te(u,!!s)}else if(a==="OPTIONS"&&t[a]&&t[a][c]){const u=t[a][c];return delete t[a][c],te(u,!!s)}return n(r)}}function te(e,t){return Promise.resolve(t?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}const Ie=({path:e,url:t,...r},n)=>({...r,url:t&&x(t,n),path:e&&x(e,n)}),re=e=>e.json?e.json():Promise.reject(e),je=e=>{if(!e)return{};const t=e.match(/<([^>]+)>; rel="next"/);return t?{next:t[1]}:{}},ne=e=>{const{next:t}=je(e.headers.get("link"));return t},Ue=e=>{const t=!!e.path&&e.path.indexOf("per_page=-1")!==-1,r=!!e.url&&e.url.indexOf("per_page=-1")!==-1;return t||r},ue=async(e,t)=>{if(e.parse===!1||!Ue(e))return t(e);const r=await y({...Ie(e,{per_page:100}),parse:!1}),n=await re(r);if(!Array.isArray(n))return n;let s=ne(r);if(!s)return n;let i=[].concat(n);for(;s;){const a=await y({...e,path:void 0,url:s,parse:!1}),c=await re(a);i=i.concat(c),s=ne(a)}return i},Ne=new Set(["PATCH","PUT","DELETE"]),$e="GET",ze=(e,t)=>{const{method:r=$e}=e;return Ne.has(r.toUpperCase())&&(e={...e,headers:{...e.headers,"X-HTTP-Method-Override":r,"Content-Type":"application/json"},method:"POST"}),t(e)},qe=(e,t)=>(typeof e.url=="string"&&!W(e.url,"_locale")&&(e.url=x(e.url,{_locale:"user"})),typeof e.path=="string"&&!W(e.path,"_locale")&&(e.path=x(e.path,{_locale:"user"})),t(e)),Ke=(e,t=!0)=>t?e.status===204?null:e.json?e.json():Promise.reject(e):e,Be=e=>{const t={code:"invalid_json",message:F("The response is not a valid JSON response.")};if(!e||!e.json)throw t;return e.json().catch(()=>{throw t})},de=(e,t=!0)=>Promise.resolve(Ke(e,t)).catch(r=>z(r,t));function z(e,t=!0){if(!t)throw e;return Be(e).then(r=>{const n={code:"unknown_error",message:F("An unknown error occurred.")};throw r||n})}function Ge(e){const t=!!e.method&&e.method==="POST";return(!!e.path&&e.path.indexOf("/wp/v2/media")!==-1||!!e.url&&e.url.indexOf("/wp/v2/media")!==-1)&&t}const Je=(e,t)=>{if(!Ge(e))return t(e);let r=0;const n=5,s=i=>(r++,t({path:`/wp/v2/media/${i}/post-process`,method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch(()=>r<n?s(i):(t({path:`/wp/v2/media/${i}?force=true`,method:"DELETE"}),Promise.reject())));return t({...e,parse:!1}).catch(i=>{if(!i.headers)return Promise.reject(i);const a=i.headers.get("x-wp-upload-attachment-id");return i.status>=500&&i.status<600&&a?s(a).catch(()=>e.parse!==!1?Promise.reject({code:"post_process",message:F("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(i)):z(i,e.parse)}).then(i=>de(i,e.parse))},Qe=e=>(t,r)=>{if(typeof t.url=="string"){const n=j(t.url,"wp_theme_preview");n===void 0?t.url=x(t.url,{wp_theme_preview:e}):n===""&&(t.url=Y(t.url,"wp_theme_preview"))}if(typeof t.path=="string"){const n=j(t.path,"wp_theme_preview");n===void 0?t.path=x(t.path,{wp_theme_preview:e}):n===""&&(t.path=Y(t.path,"wp_theme_preview"))}return r(t)},Xe={Accept:"application/json, */*;q=0.1"},Ve={credentials:"include"},fe=[qe,ce,ze,ue];function Ze(e){fe.unshift(e)}const pe=e=>{if(e.status>=200&&e.status<300)return e;throw e},We=e=>{const{url:t,path:r,data:n,parse:s=!0,...i}=e;let{body:a,headers:c}=e;return c={...Xe,...c},n&&(a=JSON.stringify(n),c["Content-Type"]="application/json"),window.fetch(t||r||window.location.href,{...Ve,...i,body:a,headers:c}).then(l=>Promise.resolve(l).then(pe).catch(w=>z(w,s)).then(w=>de(w,s)),l=>{throw l&&l.name==="AbortError"?l:{code:"fetch_error",message:F("You are probably offline.")}})};let he=We;function Ye(e){he=e}function y(e){return fe.reduceRight((r,n)=>s=>n(s,r),he)(e).catch(r=>r.code!=="rest_cookie_invalid_nonce"?Promise.reject(r):window.fetch(y.nonceEndpoint).then(pe).then(n=>n.text()).then(n=>(y.nonceMiddleware.nonce=n,y(e))))}y.use=Ze;y.setFetchHandler=Ye;y.createNonceMiddleware=Me;y.createPreloadingMiddleware=He;y.createRootURLMiddleware=De;y.fetchAllMiddleware=ue;y.mediaUploadMiddleware=Je;y.createThemePreviewMiddleware=Qe;const et="0.0.3",L="?";function U(e,t,r,n){const s={filename:e,function:t==="<anonymous>"?L:t,in_app:!0};return r!==void 0&&(s.lineno=r),n!==void 0&&(s.colno=n),s}const tt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,rt=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,nt=/\((\S*)(?::(\d+))(?::(\d+))\)/,st=e=>{const t=tt.exec(e);if(t){const[,n,s,i]=t;return U(n,L,+s,+i)}const r=rt.exec(e);if(r){if(r[2]&&r[2].indexOf("eval")===0){const a=nt.exec(r[2]);a&&(r[2]=a[1],r[3]=a[2],r[4]=a[3])}const s=r[1]||L,i=r[2];return U(i,s,r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},it=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,at=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ot=e=>{const t=it.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){const i=at.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}const n=t[3],s=t[1]||L;return U(n,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},se=50,ct=[st,ot],lt=e=>{const t=e.stacktrace||e.stack||"",r=[],n=t.split(`
`);for(let i=0;i<n.length;i++){const a=n[i];if(!(a.length>1024)&&!a.match(/\S*Error: /)){for(const c of ct){const u=c(a);if(u){r.push(u);break}}if(r.length>=se)break}}const s=Array.from(r).reverse();return s.slice(0,se).map(i=>({...i,filename:i.filename||s[s.length-1].filename}))},ut=e=>{const t=e?.message;return t?typeof t.error?.message=="string"?t.error.message:t:"No error message"},dt=e=>{const t={type:e?.name,message:ut(e)},r=lt(e);return r.length&&(t.stacktrace=r),t.type===void 0&&t.message===""&&(t.message="Unknown error"),t},ft=(e,{context:t,tags:r}={})=>({...dt(e),context:{...t},tags:{...r,gutenberg_kit_version:et}});function kt(){window.editorDelegate&&window.editorDelegate.onEditorLoaded(),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorLoaded",body:{}})}function Pt(){window.editorDelegate&&window.editorDelegate.onEditorContentChanged(),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorContentChanged"})}function Ot(e,t){window.editorDelegate&&window.editorDelegate.onEditorHistoryChanged(e,t),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorHistoryChanged",body:{hasUndo:e,hasRedo:t}})}function Rt(e){window.editorDelegate&&window.editorDelegate.openMediaLibrary(JSON.stringify(e)),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"openMediaLibrary",body:e})}function R(){if(window.GBKit)return window.GBKit;if(window.editorDelegate)try{return JSON.parse(window.editorDelegate.getEditorConfiguration())}catch{return{}}try{return JSON.parse(localStorage.getItem("GBKit"))||{}}catch{return{}}}function pt(){const{post:e}=R();return e?{id:e.id,title:{raw:decodeURIComponent(e.title)},content:{raw:decodeURIComponent(e.content)},type:e.type||"post"}:{type:"post",status:"draft",id:-1}}function Tt(e,{context:t,tags:r,isHandled:n,handledBy:s}={context:{},tags:{},isHandled:!1,handledBy:"Unknown"}){const i={...ft(e,{context:t,tags:r}),isHandled:n,handledBy:s};window.editorDelegate&&window.editorDelegate.onEditorExceptionLogged(JSON.stringify(i)),window.webkit&&window.webkit.messageHandlers.editorDelegate.postMessage({message:"onEditorExceptionLogged",body:i})}function ht(){const{siteApiRoot:e="",authHeader:t}=R();y.use(y.createRootURLMiddleware(e)),y.use(wt),y.use(gt),y.use(mt(t)),y.use(yt),y.use(_t),y.use(y.createPreloadingMiddleware({"/wp/v2/types?context=view":{body:{post:{description:"",hierarchical:!1,has_archive:!1,name:"Posts",slug:"post",taxonomies:["category","post_tag"],rest_base:"posts",rest_namespace:"wp/v2",template:[],template_lock:!1,_links:{}},page:{description:"",hierarchical:!0,has_archive:!1,name:"Pages",slug:"page",taxonomies:[],rest_base:"pages",rest_namespace:"wp/v2",template:[],template_lock:!1,_links:{}}}},"/wp/v2/types/post?context=edit":{body:{name:"Posts",slug:"post",supports:{title:!0,editor:!0,author:!0,thumbnail:!0,excerpt:!0,trackbacks:!0,"custom-fields":!0,comments:!0,revisions:!0,"post-formats":!0,autosave:!0},taxonomies:["category","post_tag"],rest_base:"posts",rest_namespace:"wp/v2",template:[],template_lock:!1}}}))}function wt(e,t){return e.mode="cors",delete e.headers["x-wp-api-fetch-from-editor"],t(e)}function gt(e,t){const{siteApiNamespace:r}=R();return e.path&&r&&!e.path.includes(r)&&(e.path=e.path.replace(/^(?<apiPath>\/?(?:[\w.-]+\/){2})/,`$<apiPath>${r}/`)),t(e)}function mt(e){return(t,r)=>(t.headers=t.headers||{},e&&(t.headers.Authorization=e),r(t))}function yt(e,t){return[/^\/wp\/v2\/posts\/-?\d+/,/^\/wp\/v2\/pages\/-?\d+/].some(s=>s.test(e.path))?Promise.resolve([]):t(e)}function _t(e,t){return e.path&&e.path.startsWith("/wp/v2/media")&&e.method==="POST"&&e.body instanceof FormData&&e.body.get("post")==="-1"&&e.body.delete("post"),t(e)}window.GBKit=R();window.wp=window.wp||{};window.wp.apiFetch=y;ht();bt();async function bt(){try{const{themeStyles:e,siteURL:t}=R(),{styles:r,scripts:n}=await y({url:`${t}/wp-json/__experimental/wp-block-editor/v1/editor-assets`});await vt([...r,...n].join(""));const{dispatch:s}=window.wp.data,{store:i}=window.wp.editor,{store:a}=window.wp.preferences;y({path:"/wp-block-editor/v1/settings"}).then(h=>{s(i).updateEditorSettings(h)}).catch(()=>{const h={defaultEditorStyles:[{css:we}]};s(i).updateEditorSettings(h)}),s(a).setDefaults("core/edit-post",{themeStyles:e});const u={post:pt()},{default:l}=await ye(async()=>{const{default:h}=await import("./layout-nZjJAiRL.js");return{default:h}},__vite__mapDeps([0,1]),import.meta.url),{createRoot:w,createElement:o,StrictMode:m}=window.wp.element;w(document.getElementById("root")).render(o(m,null,o(l,u)))}catch{window.location.href="index.html?error=remote_editor_load_error"}}async function vt(e){const t=new window.DOMParser().parseFromString(e,"text/html"),r=Array.from(t.querySelectorAll('link[rel="stylesheet"],script')).filter(n=>n.id&&!xt.test(n.src));for(const n of r)await St(n)}const Et=["api-fetch"],xt=new RegExp(Et.flatMap(e=>[`wp-content/plugins/gutenberg/build/${e.replace(/\//g,"\\/")}\\b`,`wp-includes/js/dist/${e.replace(/\//g,"\\/")}\\b`]).join("|"));function St(e){return new Promise(t=>{const r=document.createElement(e.nodeName);["id","rel","src","href","type"].forEach(n=>{e[n]&&(r[n]=e[n])}),e.innerHTML&&r.appendChild(document.createTextNode(e.innerHTML)),r.onload=()=>t(!0),r.onerror=()=>{t(!1)},document.body.appendChild(r),(r.nodeName.toLowerCase()==="link"||r.nodeName.toLowerCase()==="script"&&!r.src)&&t()})}export{Pt as a,Rt as b,kt as e,Tt as l,Ot as o};

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.

Copilot Autofix AI about 1 month ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@dcalhoun dcalhoun marked this pull request as ready for review January 27, 2025 22:32
@dcalhoun dcalhoun requested review from kean and nbradbury January 27, 2025 22:32
@dcalhoun dcalhoun merged commit fb31301 into trunk Jan 28, 2025
8 of 9 checks passed
@dcalhoun dcalhoun deleted the feat/error-reporting branch January 28, 2025 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants