@visulima/ono 2.0.0-alpha.34 → 2.0.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var Yt=Object.defineProperty;var T=(s,a)=>Yt(s,"name",{value:a,configurable:!0});import{createRequire as en}from"node:module";import rn from"launch-editor-middleware";import{a as be}from"../packem_shared/process-BO_aZsiL.js";const tn=en(import.meta.url),H=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,nn=T(s=>{if(typeof H<"u"&&H.versions&&H.versions.node){const[a,i]=H.versions.node.split(".").map(Number);if(a>22||a===22&&i>=3||a===20&&i>=16)return H.getBuiltinModule(s)}return tn(s)},"__cjs_getBuiltinModule"),{realpathSync:ye}=nn("node:fs");var on=Object.defineProperty,sn=T((s,a)=>on(s,"name",{value:a,configurable:!0}),"$e"),an=Object.defineProperty,te=sn((s,a)=>an(s,"name",{value:a,configurable:!0}),"W"),ln=Object.defineProperty,c=te((s,a)=>ln(s,"name",{value:a,configurable:!0}),"u$1");let ve=c(()=>{var s=(()=>{var a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,g=c((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},"ne"),x=c((e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of u(t))!d.call(e,r)&&r!==n&&a(e,r,{get:c(()=>t[r],"get"),enumerable:!(o=i(t,r))||o.enumerable});return e},"ae"),m=c(e=>x(a({},"__esModule",{value:!0}),e),"oe"),b={};g(b,{zeptomatch:c(()=>we,"zeptomatch")});var v=c(e=>{const t=new Set,n=[e];for(let o=0;o<n.length;o++){const r=n[o];if(t.has(r))continue;t.add(r);const{children:l}=r;if(l?.length)for(let f=0,h=l.length;f<h;f++)n.push(l[f])}return Array.from(t)},"M"),O=c(e=>{let t="";const n=v(e);for(let o=0,r=n.length;o<r;o++){const l=n[o];if(!l.regex)continue;const f=l.regex.flags;if(t||(t=f),t!==f)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${f}"`)}return t},"se"),E=c((e,t,n)=>{const o=n.get(e);if(o!==void 0)return o;const r=e.partial??t;let l="";if(e.regex&&(l+=r?"(?:$|":"",l+=e.regex.source),e.children?.length){const f=J(e.children.map(h=>E(h,t,n)).filter(Boolean));if(f?.length){const h=e.children.some(L=>!L.regex||!(L.partial??t)),w=f.length>1||r&&(!l.length||h);l+=w?r?"(?:$|":"(?:":"",l+=f.join("|"),l+=w?")":""}}return e.regex&&(l+=r?")":""),n.set(e,l),l},"O"),D=c((e,t)=>{const n=new Map,o=v(e);for(let r=o.length-1;r>=0;r--){const l=E(o[r],t,n);if(!(r>0))return l}return""},"ie"),J=c(e=>Array.from(new Set(e)),"ue"),I=c((e,t,n)=>I.compile(e,n).test(t),"R");I.compile=(e,t)=>{const n=t?.partial??!1,o=D(e,n),r=O(e);return new RegExp(`^(?:${o})$`,r)};var ze=I,Ae=c((e,t)=>{const n=ze.compile(e,t),o=`${n.source.slice(0,-1)}[\\\\/]?$`,r=n.flags;return new RegExp(o,r)},"le"),Re=Ae,ke=c(e=>{const t=e.map(o=>o.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),Se=ke,ne=c(e=>Array.isArray(e),"j"),q=c(e=>typeof e=="function","_"),Ie=c(e=>e.length===0,"he"),Be=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),We=c(e=>typeof e=="number","de"),Ce=c(e=>typeof e=="object"&&e!==null,"xe"),qe=c(e=>e instanceof RegExp,"me"),Ne=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Le=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),re=c(e=>typeof e=="string","A"),_=c(e=>e===void 0,"f"),Ze=c(e=>{const t=new Map;return n=>{const o=t.get(n);if(o!==void 0)return o;const r=e(n);return t.set(n,r),r}},"ye"),oe=c((e,t,n={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},r=z(t)(o),l=Math.max(o.index,o.indexBacktrackMax);if(r&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${l}`)},"I"),p=c((e,t)=>ne(e)?He(e,t):re(e)?se(e,t):Fe(e,t),"i"),He=c((e,t)=>{const n={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const r=o.charCodeAt(0);n[r]=!0}return o=>{const r=o.input;let l=o.index,f=l;for(;f<r.length&&r.charCodeAt(f)in n;)f+=1;if(f>l){if(!_(t)&&!o.options.silent){const h=r.slice(l,f),w=q(t)?t(h,r,`${l}`):t;_(w)||o.output.push(w)}o.index=f}return!0}},"we"),Fe=c((e,t)=>{if(Le(e))return se(e.source,t);{const n=e.source,o=e.flags.replace(/y|$/,"y"),r=new RegExp(n,o);return Ne(e)&&q(t)&&!Be(t)?Te(r,t):Ue(r,t)}},"$e"),Te=c((e,t)=>n=>{const o=n.index,r=n.input;e.lastIndex=o;const l=e.exec(r);if(l){const f=e.lastIndex;if(!n.options.silent){const h=t(...l,r,`${o}`);_(h)||n.output.push(h)}return n.index=f,!0}else return!1},"Ee"),Ue=c((e,t)=>n=>{const o=n.index,r=n.input;if(e.lastIndex=o,e.test(r)){const l=e.lastIndex;if(!_(t)&&!n.options.silent){const f=q(t)?t(r.slice(o,l),r,`${o}`):t;_(f)||n.output.push(f)}return n.index=l,!0}else return!1},"Ce"),se=c((e,t)=>n=>{const o=n.index,r=n.input;if(r.startsWith(e,o)){if(!_(t)&&!n.options.silent){const l=q(t)?t(e,r,`${o}`):t;_(l)||n.output.push(l)}return n.index+=e.length,!0}else return!1},"F"),V=c((e,t,n,o)=>{const r=z(e),l=t>1;return Q(K(ie(f=>{let h=0;for(;h<n;){const w=f.index;if(!r(f)||(h+=1,f.index===w))break}return h>=t},l),o))},"k"),ae=c((e,t)=>V(e,0,1,t),"L"),F=c((e,t)=>V(e,0,1/0,t),"$"),Ge=c((e,t)=>V(e,1,1/0,t),"Re"),B=c((e,t)=>{const n=e.map(z);return Q(K(ie(o=>{for(let r=0,l=n.length;r<l;r++)if(!n[r](o))return!1;return!0}),t))},"x"),j=c((e,t)=>{const n=e.map(z);return Q(K(o=>{for(let r=0,l=n.length;r<l;r++)if(n[r](o))return!0;return!1},t))},"p"),ie=c((e,t=!0,n=!1)=>{const o=z(e);return t?r=>{const l=r.index,f=r.output.length,h=o(r);return!h&&!n&&(r.indexBacktrackMax=Math.max(r.indexBacktrackMax,r.index)),(!h||n)&&(r.index=l,r.output.length!==f&&(r.output.length=f)),h}:o},"q"),K=c((e,t)=>{const n=z(e);return t?o=>{if(o.options.silent)return n(o);const r=o.output.length;if(n(o)){const l=o.output.splice(r,1/0),f=t(l);return _(f)||o.output.push(f),!0}else return!1}:n},"B"),Q=(()=>{let e=0;return t=>{const n=z(t),o=e+=1;return r=>{var l;if(r.options.memoization===!1)return n(r);const f=r.index,h=(l=r.cache)[o]||(l[o]={indexMax:-1,queue:[]}),w=h.queue;if(f<=h.indexMax){const Z=h.store||(h.store=new Map);if(w.length){for(let C=0,Kt=w.length;C<Kt;C+=2){const Qt=w[C*2],Xt=w[C*2+1];Z.set(Qt,Xt)}w.length=0}const P=Z.get(f);if(P===!1)return!1;if(We(P))return r.index=P,!0;if(P)return r.index=P.index,P.output?.length&&r.output.push(...P.output),!0}const L=r.output.length,Vt=n(r);if(h.indexMax=Math.max(h.indexMax,f),Vt){const Z=r.index,P=r.output.length;if(P>L){const C=r.output.slice(L,P);w.push(f,{index:Z,output:C})}else w.push(f,Z);return!0}else return w.push(f,!1),!1}}})(),le=c(e=>{let t;return n=>(t||(t=z(e())),t(n))},"G"),z=Ze(e=>{if(q(e))return Ie(e)?le(e):e;if(re(e)||qe(e))return p(e);if(ne(e))return B(e);if(Ce(e))return j(Object.values(e));throw new Error("Invalid rule")}),R=c(e=>e,"d"),De=c(e=>typeof e=="string","ke"),Je=c(e=>{const t=new WeakMap,n=new WeakMap;return(o,r)=>{const l=r?.partial?n:t,f=l.get(o);if(f!==void 0)return f;const h=e(o,r);return l.set(o,h),h}},"Be"),Ve=c(e=>{const t={},n={};return(o,r)=>{const l=r?.partial?n:t;return l[o]??(l[o]=e(o,r))}},"Pe"),Ke=p(/\\./,R),Qe=p(/./,R),Xe=p(/\*\*\*+/,"*"),Ye=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),et=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),tt=F(j([Ke,Xe,Ye,et,Qe])),nt=tt,rt=c(e=>oe(e,nt,{memoization:!1}).join(""),"Ie"),ot=rt,ce="abcdefghijklmnopqrstuvwxyz",st=c(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ce[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),ue=c(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t=t*26+ce.indexOf(e[n])+1;return t},"V"),X=c((e,t)=>{if(t<e)return X(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),at=c((e,t,n)=>X(e,t).map(o=>String(o).padStart(n,"0")),"qe"),fe=c((e,t)=>X(ue(e),ue(t)).map(st),"W"),$=c(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),N=c(e=>({children:e}),"y"),W=(()=>{const e=c((t,n,o)=>{if(o.has(t))return;o.add(t);const{children:r}=t;if(!r.length)r.push(n);else for(let l=0,f=r.length;l<f;l++)e(r[l],n,o)},"e");return t=>{if(!t.length)return N([]);for(let n=t.length-1;n>=1;n--){const o=new Set,r=t[n-1],l=t[n];e(r,l,o)}return t[0]}})(),A=c(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),it=p(/\\./,$),lt=p(/[$.*+?^(){}[\]\|]/,e=>$(`\\${e}`)),ct=p(/[\\\/]/,A),ut=p(/[^$.*+?^(){}[\]\|\\\/]+/,$),ft=p(/^(?:!!)*!(.*)$/,(e,t)=>$(`(?!^${we.compile(t).source}$).*?`)),pt=p(/^(!!)+/),dt=j([ft,pt]),ht=p(/\/(\*\*\/)+/,()=>N([W([A(),$(".+?"),A()]),A()])),gt=p(/^(\*\*\/)+/,()=>N([$("^"),W([$(".*?"),A()])])),xt=p(/\/(\*\*)$/,()=>N([W([A(),$(".*?")]),$("$")])),mt=p(/\*\*/,()=>$(".*?")),pe=j([ht,gt,xt,mt]),$t=p(/\*\/(?!\*\*\/|\*$)/,()=>W([$("[^\\\\/]*?"),A()])),wt=p(/\*/,()=>$("[^\\\\/]*")),de=j([$t,wt]),he=p("?",()=>$("[^\\\\/]")),yt=p("[",R),bt=p("]",R),vt=p(/[!^]/,"^\\\\/"),jt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,R),Pt=p(/\\./,R),Mt=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ot=p(/[\\\/]/,"\\\\/"),Et=p(/[^$.*+?^(){}[\]\|\\\/]+/,R),_t=j([Pt,Mt,Ot,jt,Et]),ge=B([yt,ae(vt),F(_t),bt],e=>$(e.join(""))),zt=p("{","(?:"),At=p("}",")"),Rt=p(/(\d+)\.\.(\d+)/,(e,t,n)=>at(+t,+n,Math.min(t.length,n.length)).join("|")),kt=p(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>fe(t,n).join("|")),St=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>fe(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),It=j([Rt,kt,St]),xe=B([zt,It,At],e=>$(e.join(""))),Bt=p("{"),Wt=p("}"),Ct=p(","),qt=p(/\\./,$),Nt=p(/[$.*+?^(){[\]\|]/,e=>$(`\\${e}`)),Lt=p(/[\\\/]/,A),Zt=p(/[^$.*+?^(){}[\]\|\\\/,]+/,$),Ht=le(()=>$e),Ft=p("",()=>$("(?:)")),Tt=Ge(j([pe,de,he,ge,xe,Ht,qt,Nt,Lt,Zt]),W),me=j([Tt,Ft]),$e=B([Bt,ae(B([me,F(B([Ct,me]))])),Wt],N),Ut=F(j([dt,pe,de,he,ge,xe,$e,it,lt,ct,ut]),W),Gt=Ut,Dt=c(e=>oe(e,Gt,{memoization:!1})[0],"kr"),Jt=Dt,Y=c((e,t,n)=>Y.compile(e,n).test(t),"N");Y.compile=(()=>{const e=Ve((n,o)=>Re(Jt(ot(n)),o)),t=Je((n,o)=>Se(n.map(r=>e(r,o))));return(n,o)=>De(n)?e(n,o):t(n,o)})();var we=Y;return m(b)})();return s.default||s},"_lazyMatch"),ee;const cn=c((s,a)=>(ee||(ee=ve(),ve=null),ee(s,a)),"default");var un=Object.defineProperty,fn=te((s,a)=>un(s,"name",{value:a,configurable:!0}),"t$1");const pn=/^[A-Z]:\//i,S=fn((s="")=>s&&s.replaceAll("\\","/").replace(pn,a=>a.toUpperCase()),"normalizeWindowsPath");var dn=Object.defineProperty,y=te((s,a)=>dn(s,"name",{value:a,configurable:!0}),"r");const hn=/^[/\\]{2}/,gn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Oe=/^[A-Z]:$/i,je=/^\/([A-Z]:)?$/i,xn=/.(\.[^./]+)$/,mn=/^[/\\]|^[a-z]:[/\\]/i,$n=/\/$/,wn=y(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),Pe="/",Ee=y((s,a)=>{let i="",u=0,d=-1,g=0,x;for(let m=0;m<=s.length;++m){if(m<s.length)x=s[m];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===m-1||g===1))if(g===2){if(i.length<2||u!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const b=i.lastIndexOf("/");b===-1?(i="",u=0):(i=i.slice(0,b),u=i.length-1-i.lastIndexOf("/")),d=m,g=0;continue}else if(i.length>0){i="",u=0,d=m,g=0;continue}}a&&(i+=i.length>0?"/..":"..",u=2)}else i.length>0?i+=`/${s.slice(d+1,m)}`:i=s.slice(d+1,m),u=m-d-1;d=m,g=0}else x==="."&&g!==-1?++g:g=-1}return i},"normalizeString"),k=y(s=>gn.test(s),"isAbsolute"),U=y(function(s){if(s.length===0)return".";s=S(s);const a=hn.exec(s),i=k(s),u=s.at(-1)==="/";return s=Ee(s,!i),s.length===0?i?"/":u?"./":".":(u&&(s+="/"),Oe.test(s)&&(s+="/"),a?i?`//${s}`:`//./${s}`:i&&!k(s)?`/${s}`:s)},"normalize");y((...s)=>{let a="";for(const i of s)if(i)if(a.length>0){const u=a.at(-1)==="/",d=i[0]==="/";u&&d?a+=i.slice(1):a+=u||d?i:`/${i}`}else a+=i;return U(a)},"join");const G=y(function(...s){s=s.map(u=>S(u));let a="",i=!1;for(let u=s.length-1;u>=-1&&!i;u--){const d=u>=0?s[u]:wn();!d||d.length===0||(a=`${d}/${a}`,i=k(d))}return a=Ee(a,!i),i&&!k(a)?`/${a}`:a.length>0?a:"."},"resolve");y(function(s){return S(s)},"toNamespacedPath");const yn=y(function(s){return xn.exec(S(s))?.[1]??""},"extname"),bn=y(function(s,a){const i=G(s).replace(je,"$1").split("/"),u=G(a).replace(je,"$1").split("/");if(u[0][1]===":"&&i[0][1]===":"&&i[0]!==u[0])return u.join("/");const d=[...i];for(const g of d){if(u[0]!==g)break;i.shift(),u.shift()}return[...i.map(()=>".."),...u].join("/")},"relative"),vn=y(s=>{const a=S(s).replace($n,"").split("/").slice(0,-1);return a.length===1&&Oe.test(a[0])&&(a[0]=`${a[0]}/`),a.join("/")||(k(s)?"/":".")},"dirname");y(function(s){const a=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return S(s.root?G(...a):a.join("/"))},"format");const jn=y((s,a)=>{const i=S(s).split("/").pop();return a&&i.endsWith(a)?i.slice(0,-a.length):i},"basename");y(function(s){const a=mn.exec(s)?.[0]?.replaceAll("\\","/")??"",i=jn(s),u=yn(i);return{base:i,dir:vn(s),ext:u,name:i.slice(0,i.length-u.length),root:a}},"parse");y((s,a)=>cn(a,U(s)),"matchesGlob");var Pn=Object.defineProperty,M=T((s,a)=>Pn(s,"name",{value:a,configurable:!0}),"i");const Me=M(s=>{if(typeof s.status=="function"){s.status(400).send("Failed to open editor");return}s.statusCode=400,s.end("Failed to open editor")},"respond400"),_e=M((s={})=>{const a=M(async u=>{if((u.method??"GET").toUpperCase()==="POST")return u.body&&typeof u.body=="object"?u.body:new Promise(g=>{try{let x="";const m=M(v=>{x+=String(v)},"onData"),b=M(()=>{try{g(x?JSON.parse(x):{})}catch{g({})}},"onEnd");u.on("data",m),u.on("end",b),u.on("error",()=>{g({})})}catch{g({})}});const d=new URL(u.url??"","http://localhost");return{column:Number(d.searchParams.get("column")??1),editor:d.searchParams.get("editor")??void 0,file:d.searchParams.get("file")??void 0,line:Number(d.searchParams.get("line")??1)}},"parseRequestBody"),i=M((u,d,g)=>{if(!u)return;const x=k(u)?u:G(d,u);if(!g)try{const m=ye(d),b=ye(x),v=U(m),O=U(b),E=be()==="win32"||be()==="darwin",D=E?v.toLowerCase():v,J=E?O.toLowerCase():O,I=bn(v,O);if(I.startsWith("..")||k(I)||E&&!J.startsWith(D))return}catch{const m=d.endsWith(Pe)?d:d+Pe;if(!x.startsWith(m))return}return x},"validateFilePath");return M(async function(u,d,g){try{const x=await a(u),m=s.projectRoot??process.cwd(),b=i(x.file,m,s.allowOutsideProject??!1);if(!b){Me(d);return}const v=rn(x.editor,m),O=new URLSearchParams({column:String(x.column??1),file:b,line:String(x.line??1)});if(x.editor&&O.set("editor",x.editor),u.url=`/?${O.toString()}`,typeof g=="function"){v(u,d,g);return}await new Promise(E=>{v(u,d,()=>{E()})})}catch{Me(d)}},"universalHandler")},"createOpenInEditorMiddleware"),zn=M((s={})=>{const a=_e(s);return async(i,u)=>a(i,u)},"createNodeHttpHandler"),An=M((s={})=>_e(s),"createExpressHandler");export{An as createExpressHandler,zn as createNodeHttpHandler,_e as createOpenInEditorMiddleware};
1
+ var Yt=Object.defineProperty;var G=(s,a)=>Yt(s,"name",{value:a,configurable:!0});import{createRequire as en}from"node:module";import rn from"launch-editor-middleware";import{a as ve}from"../packem_shared/process-BO_aZsiL.js";const tn=en(import.meta.url),T=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,nn=G(s=>{if(typeof T<"u"&&T.versions&&T.versions.node){const[a,i]=T.versions.node.split(".").map(Number);if(a>22||a===22&&i>=3||a===20&&i>=16)return T.getBuiltinModule(s)}return tn(s)},"__cjs_getBuiltinModule"),{realpathSync:ye}=nn("node:fs");var on=Object.defineProperty,sn=G((s,a)=>on(s,"name",{value:a,configurable:!0}),"$e"),an=Object.defineProperty,te=sn((s,a)=>an(s,"name",{value:a,configurable:!0}),"W"),ln=Object.defineProperty,u=te((s,a)=>ln(s,"name",{value:a,configurable:!0}),"u$1");let be=u(()=>{var s=(()=>{var a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,d=Object.prototype.hasOwnProperty,m=u((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},"ne"),x=u((e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of c(t))!d.call(e,r)&&r!==n&&a(e,r,{get:u(()=>t[r],"get"),enumerable:!(o=i(t,r))||o.enumerable});return e},"ae"),g=u(e=>x(a({},"__esModule",{value:!0}),e),"oe"),v={};m(v,{zeptomatch:u(()=>we,"zeptomatch")});var b=u(e=>{const t=new Set,n=[e];for(let o=0;o<n.length;o++){const r=n[o];if(t.has(r))continue;t.add(r);const{children:l}=r;if(l?.length)for(let f=0,h=l.length;f<h;f++)n.push(l[f])}return Array.from(t)},"M"),j=u(e=>{let t="";const n=b(e);for(let o=0,r=n.length;o<r;o++){const l=n[o];if(!l.regex)continue;const f=l.regex.flags;if(t||(t=f),t!==f)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${f}"`)}return t},"se"),P=u((e,t,n)=>{const o=n.get(e);if(o!==void 0)return o;const r=e.partial??t;let l="";if(e.regex&&(l+=r?"(?:$|":"",l+=e.regex.source),e.children?.length){const f=J(e.children.map(h=>P(h,t,n)).filter(Boolean));if(f?.length){const h=e.children.some(H=>!H.regex||!(H.partial??t)),w=f.length>1||r&&(!l.length||h);l+=w?r?"(?:$|":"(?:":"",l+=f.join("|"),l+=w?")":""}}return e.regex&&(l+=r?")":""),n.set(e,l),l},"O"),q=u((e,t)=>{const n=new Map,o=b(e);for(let r=o.length-1;r>=0;r--){const l=P(o[r],t,n);if(!(r>0))return l}return""},"ie"),J=u(e=>Array.from(new Set(e)),"ue"),I=u((e,t,n)=>I.compile(e,n).test(t),"R");I.compile=(e,t)=>{const n=t?.partial??!1,o=q(e,n),r=j(e);return new RegExp(`^(?:${o})$`,r)};var ze=I,Ae=u((e,t)=>{const n=ze.compile(e,t),o=`${n.source.slice(0,-1)}[\\\\/]?$`,r=n.flags;return new RegExp(o,r)},"le"),ke=Ae,Re=u(e=>{const t=e.map(o=>o.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),Se=Re,ne=u(e=>Array.isArray(e),"j"),N=u(e=>typeof e=="function","_"),Ie=u(e=>e.length===0,"he"),Be=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return n=>(n.length===0||n.length===1)&&t.test(e.call(n))})(),Le=u(e=>typeof e=="number","de"),Ce=u(e=>typeof e=="object"&&e!==null,"xe"),We=u(e=>e instanceof RegExp,"me"),qe=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Ne=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),re=u(e=>typeof e=="string","A"),_=u(e=>e===void 0,"f"),Ze=u(e=>{const t=new Map;return n=>{const o=t.get(n);if(o!==void 0)return o;const r=e(n);return t.set(n,r),r}},"ye"),oe=u((e,t,n={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},r=z(t)(o),l=Math.max(o.index,o.indexBacktrackMax);if(r&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${l}`)},"I"),p=u((e,t)=>ne(e)?He(e,t):re(e)?se(e,t):Fe(e,t),"i"),He=u((e,t)=>{const n={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const r=o.charCodeAt(0);n[r]=!0}return o=>{const r=o.input;let l=o.index,f=l;for(;f<r.length&&r.charCodeAt(f)in n;)f+=1;if(f>l){if(!_(t)&&!o.options.silent){const h=r.slice(l,f),w=N(t)?t(h,r,`${l}`):t;_(w)||o.output.push(w)}o.index=f}return!0}},"we"),Fe=u((e,t)=>{if(Ne(e))return se(e.source,t);{const n=e.source,o=e.flags.replace(/y|$/,"y"),r=new RegExp(n,o);return qe(e)&&N(t)&&!Be(t)?Te(r,t):Ue(r,t)}},"$e"),Te=u((e,t)=>n=>{const o=n.index,r=n.input;e.lastIndex=o;const l=e.exec(r);if(l){const f=e.lastIndex;if(!n.options.silent){const h=t(...l,r,`${o}`);_(h)||n.output.push(h)}return n.index=f,!0}else return!1},"Ee"),Ue=u((e,t)=>n=>{const o=n.index,r=n.input;if(e.lastIndex=o,e.test(r)){const l=e.lastIndex;if(!_(t)&&!n.options.silent){const f=N(t)?t(r.slice(o,l),r,`${o}`):t;_(f)||n.output.push(f)}return n.index=l,!0}else return!1},"Ce"),se=u((e,t)=>n=>{const o=n.index,r=n.input;if(r.startsWith(e,o)){if(!_(t)&&!n.options.silent){const l=N(t)?t(e,r,`${o}`):t;_(l)||n.output.push(l)}return n.index+=e.length,!0}else return!1},"F"),V=u((e,t,n,o)=>{const r=z(e),l=t>1;return Q(K(ie(f=>{let h=0;for(;h<n;){const w=f.index;if(!r(f)||(h+=1,f.index===w))break}return h>=t},l),o))},"k"),ae=u((e,t)=>V(e,0,1,t),"L"),U=u((e,t)=>V(e,0,1/0,t),"$"),Ge=u((e,t)=>V(e,1,1/0,t),"Re"),B=u((e,t)=>{const n=e.map(z);return Q(K(ie(o=>{for(let r=0,l=n.length;r<l;r++)if(!n[r](o))return!1;return!0}),t))},"x"),O=u((e,t)=>{const n=e.map(z);return Q(K(o=>{for(let r=0,l=n.length;r<l;r++)if(n[r](o))return!0;return!1},t))},"p"),ie=u((e,t=!0,n=!1)=>{const o=z(e);return t?r=>{const l=r.index,f=r.output.length,h=o(r);return!h&&!n&&(r.indexBacktrackMax=Math.max(r.indexBacktrackMax,r.index)),(!h||n)&&(r.index=l,r.output.length!==f&&(r.output.length=f)),h}:o},"q"),K=u((e,t)=>{const n=z(e);return t?o=>{if(o.options.silent)return n(o);const r=o.output.length;if(n(o)){const l=o.output.splice(r,1/0),f=t(l);return _(f)||o.output.push(f),!0}else return!1}:n},"B"),Q=(()=>{let e=0;return t=>{const n=z(t),o=e+=1;return r=>{var l;if(r.options.memoization===!1)return n(r);const f=r.index,h=(l=r.cache)[o]||(l[o]={indexMax:-1,queue:[]}),w=h.queue;if(f<=h.indexMax){const F=h.store||(h.store=new Map);if(w.length){for(let C=0,Kt=w.length;C<Kt;C+=2){const Qt=w[C*2],Xt=w[C*2+1];F.set(Qt,Xt)}w.length=0}const E=F.get(f);if(E===!1)return!1;if(Le(E))return r.index=E,!0;if(E)return r.index=E.index,E.output?.length&&r.output.push(...E.output),!0}const H=r.output.length,Vt=n(r);if(h.indexMax=Math.max(h.indexMax,f),Vt){const F=r.index,E=r.output.length;if(E>H){const C=r.output.slice(H,E);w.push(f,{index:F,output:C})}else w.push(f,F);return!0}else return w.push(f,!1),!1}}})(),le=u(e=>{let t;return n=>(t||(t=z(e())),t(n))},"G"),z=Ze(e=>{if(N(e))return Ie(e)?le(e):e;if(re(e)||We(e))return p(e);if(ne(e))return B(e);if(Ce(e))return O(Object.values(e));throw new Error("Invalid rule")}),R=u(e=>e,"d"),De=u(e=>typeof e=="string","ke"),Je=u(e=>{const t=new WeakMap,n=new WeakMap;return(o,r)=>{const l=r?.partial?n:t,f=l.get(o);if(f!==void 0)return f;const h=e(o,r);return l.set(o,h),h}},"Be"),Ve=u(e=>{const t={},n={};return(o,r)=>{const l=r?.partial?n:t;return l[o]??(l[o]=e(o,r))}},"Pe"),Ke=p(/\\./,R),Qe=p(/./,R),Xe=p(/\*\*\*+/,"*"),Ye=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),et=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),tt=U(O([Ke,Xe,Ye,et,Qe])),nt=tt,rt=u(e=>oe(e,nt,{memoization:!1}).join(""),"Ie"),ot=rt,ce="abcdefghijklmnopqrstuvwxyz",st=u(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ce[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),ue=u(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t=t*26+ce.indexOf(e[n])+1;return t},"V"),X=u((e,t)=>{if(t<e)return X(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),at=u((e,t,n)=>X(e,t).map(o=>String(o).padStart(n,"0")),"qe"),fe=u((e,t)=>X(ue(e),ue(t)).map(st),"W"),$=u(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),Z=u(e=>({children:e}),"y"),L=(()=>{const e=u((t,n,o)=>{if(o.has(t))return;o.add(t);const{children:r}=t;if(!r.length)r.push(n);else for(let l=0,f=r.length;l<f;l++)e(r[l],n,o)},"e");return t=>{if(!t.length)return Z([]);for(let n=t.length-1;n>=1;n--){const o=new Set,r=t[n-1],l=t[n];e(r,l,o)}return t[0]}})(),A=u(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),it=p(/\\./,$),lt=p(/[$.*+?^(){}[\]\|]/,e=>$(`\\${e}`)),ct=p(/[\\\/]/,A),ut=p(/[^$.*+?^(){}[\]\|\\\/]+/,$),ft=p(/^(?:!!)*!(.*)$/,(e,t)=>$(`(?!^${we.compile(t).source}$).*?`)),pt=p(/^(!!)+/),dt=O([ft,pt]),ht=p(/\/(\*\*\/)+/,()=>Z([L([A(),$(".+?"),A()]),A()])),gt=p(/^(\*\*\/)+/,()=>Z([$("^"),L([$(".*?"),A()])])),mt=p(/\/(\*\*)$/,()=>Z([L([A(),$(".*?")]),$("$")])),xt=p(/\*\*/,()=>$(".*?")),pe=O([ht,gt,mt,xt]),$t=p(/\*\/(?!\*\*\/|\*$)/,()=>L([$("[^\\\\/]*?"),A()])),wt=p(/\*/,()=>$("[^\\\\/]*")),de=O([$t,wt]),he=p("?",()=>$("[^\\\\/]")),yt=p("[",R),vt=p("]",R),bt=p(/[!^]/,"^\\\\/"),jt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,R),Pt=p(/\\./,R),Mt=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ot=p(/[\\\/]/,"\\\\/"),Et=p(/[^$.*+?^(){}[\]\|\\\/]+/,R),_t=O([Pt,Mt,Ot,jt,Et]),ge=B([yt,ae(bt),U(_t),vt],e=>$(e.join(""))),zt=p("{","(?:"),At=p("}",")"),kt=p(/(\d+)\.\.(\d+)/,(e,t,n)=>at(+t,+n,Math.min(t.length,n.length)).join("|")),Rt=p(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>fe(t,n).join("|")),St=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>fe(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),It=O([kt,Rt,St]),me=B([zt,It,At],e=>$(e.join(""))),Bt=p("{"),Lt=p("}"),Ct=p(","),Wt=p(/\\./,$),qt=p(/[$.*+?^(){[\]\|]/,e=>$(`\\${e}`)),Nt=p(/[\\\/]/,A),Zt=p(/[^$.*+?^(){}[\]\|\\\/,]+/,$),Ht=le(()=>$e),Ft=p("",()=>$("(?:)")),Tt=Ge(O([pe,de,he,ge,me,Ht,Wt,qt,Nt,Zt]),L),xe=O([Tt,Ft]),$e=B([Bt,ae(B([xe,U(B([Ct,xe]))])),Lt],Z),Ut=U(O([dt,pe,de,he,ge,me,$e,it,lt,ct,ut]),L),Gt=Ut,Dt=u(e=>oe(e,Gt,{memoization:!1})[0],"kr"),Jt=Dt,Y=u((e,t,n)=>Y.compile(e,n).test(t),"N");Y.compile=(()=>{const e=Ve((n,o)=>ke(Jt(ot(n)),o)),t=Je((n,o)=>Se(n.map(r=>e(r,o))));return(n,o)=>De(n)?e(n,o):t(n,o)})();var we=Y;return g(v)})();return s.default||s},"_lazyMatch"),ee;const cn=u((s,a)=>(ee||(ee=be(),be=null),ee(s,a)),"default");var un=Object.defineProperty,fn=te((s,a)=>un(s,"name",{value:a,configurable:!0}),"t$1");const pn=/^[A-Z]:\//i,S=fn((s="")=>s&&s.replaceAll("\\","/").replace(pn,a=>a.toUpperCase()),"normalizeWindowsPath");var dn=Object.defineProperty,y=te((s,a)=>dn(s,"name",{value:a,configurable:!0}),"r");const hn=/^[/\\]{2}/,gn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Oe=/^[A-Z]:$/i,je=/^\/([A-Z]:)?$/i,mn=/.(\.[^./]+)$/,xn=/^[/\\]|^[a-z]:[/\\]/i,$n=/\/$/,wn=y(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),Ee=y((s,a)=>{let i="",c=0,d=-1,m=0,x;for(let g=0;g<=s.length;++g){if(g<s.length)x=s[g];else{if(x==="/")break;x="/"}if(x==="/"){if(!(d===g-1||m===1))if(m===2){if(i.length<2||c!==2||!i.endsWith(".")||i.at(-2)!=="."){if(i.length>2){const v=i.lastIndexOf("/");v===-1?(i="",c=0):(i=i.slice(0,v),c=i.length-1-i.lastIndexOf("/")),d=g,m=0;continue}else if(i.length>0){i="",c=0,d=g,m=0;continue}}a&&(i+=i.length>0?"/..":"..",c=2)}else i.length>0?i+=`/${s.slice(d+1,g)}`:i=s.slice(d+1,g),c=g-d-1;d=g,m=0}else x==="."&&m!==-1?++m:m=-1}return i},"normalizeString"),k=y(s=>gn.test(s),"isAbsolute"),W=y(function(s){if(s.length===0)return".";s=S(s);const a=hn.exec(s),i=k(s),c=s.at(-1)==="/";return s=Ee(s,!i),s.length===0?i?"/":c?"./":".":(c&&(s+="/"),Oe.test(s)&&(s+="/"),a?i?`//${s}`:`//./${s}`:i&&!k(s)?`/${s}`:s)},"normalize");y((...s)=>{let a="";for(const i of s)if(i)if(a.length>0){const c=a.at(-1)==="/",d=i[0]==="/";c&&d?a+=i.slice(1):a+=c||d?i:`/${i}`}else a+=i;return W(a)},"join");const D=y(function(...s){s=s.map(c=>S(c));let a="",i=!1;for(let c=s.length-1;c>=-1&&!i;c--){const d=c>=0?s[c]:wn();!d||d.length===0||(a=`${d}/${a}`,i=k(d))}return a=Ee(a,!i),i&&!k(a)?`/${a}`:a.length>0?a:"."},"resolve");y(function(s){return S(s)},"toNamespacedPath");const yn=y(function(s){return mn.exec(S(s))?.[1]??""},"extname"),Pe=y(function(s,a){const i=D(s).replace(je,"$1").split("/"),c=D(a).replace(je,"$1").split("/");if(c[0][1]===":"&&i[0][1]===":"&&i[0]!==c[0])return c.join("/");const d=[...i];for(const m of d){if(c[0]!==m)break;i.shift(),c.shift()}return[...i.map(()=>".."),...c].join("/")},"relative"),vn=y(s=>{const a=S(s).replace($n,"").split("/").slice(0,-1);return a.length===1&&Oe.test(a[0])&&(a[0]=`${a[0]}/`),a.join("/")||(k(s)?"/":".")},"dirname");y(function(s){const a=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return S(s.root?D(...a):a.join("/"))},"format");const bn=y((s,a)=>{const i=S(s).split("/").pop();return a&&i.endsWith(a)?i.slice(0,-a.length):i},"basename");y(function(s){const a=xn.exec(s)?.[0]?.replaceAll("\\","/")??"",i=bn(s),c=yn(i);return{base:i,dir:vn(s),ext:c,name:i.slice(0,i.length-c.length),root:a}},"parse");y((s,a)=>cn(a,W(s)),"matchesGlob");var jn=Object.defineProperty,M=G((s,a)=>jn(s,"name",{value:a,configurable:!0}),"r");const Me=M(s=>{if(typeof s.status=="function"){s.status(400).send("Failed to open editor");return}s.statusCode=400,s.end("Failed to open editor")},"respond400"),_e=M((s={})=>{const a=M(async c=>{if((c.method??"GET").toUpperCase()==="POST")return c.body&&typeof c.body=="object"?c.body:new Promise(m=>{try{let x="";const g=M(()=>{typeof c.removeListener=="function"&&(c.removeListener("data",v),c.removeListener("end",b),c.removeListener("error",j))},"cleanup"),v=M(P=>{x+=String(P),x.length>1e6&&(g(),m({}))},"onData"),b=M(()=>{g();try{m(x?JSON.parse(x):{})}catch{m({})}},"onEnd"),j=M(()=>{g(),m({})},"onError");c.on("data",v),c.on("end",b),c.on("error",j)}catch{m({})}});const d=new URL(c.url??"","http://localhost");return{column:Number(d.searchParams.get("column")??1),editor:d.searchParams.get("editor")??void 0,file:d.searchParams.get("file")??void 0,line:Number(d.searchParams.get("line")??1)}},"parseRequestBody"),i=M((c,d,m)=>{if(!c)return;const x=k(c)?c:D(d,c);if(!m)try{const g=ye(d),v=ye(x),b=W(g),j=W(v),P=ve()==="win32"||ve()==="darwin",q=P?b.toLowerCase():b,J=P?j.toLowerCase():j,I=Pe(b,j);if(I.startsWith("..")||k(I)||P&&!J.startsWith(q))return}catch{const g=Pe(W(d),W(x));if(g.startsWith("..")||k(g))return}return x},"validateFilePath");return M(async function(c,d,m){try{const x=await a(c),g=s.projectRoot??process.cwd(),v=i(x.file,g,s.allowOutsideProject??!1);if(!v){Me(d);return}const b=x.editor&&/^[\w.+-]+$/.test(x.editor)?x.editor:void 0,j=rn(b,g),P=new URLSearchParams({column:String(x.column??1),file:v,line:String(x.line??1)});if(b&&P.set("editor",b),c.url=`/?${P.toString()}`,typeof m=="function"){j(c,d,m);return}await new Promise(q=>{j(c,d,()=>{q()})})}catch{Me(d)}},"universalHandler")},"createOpenInEditorMiddleware"),_n=M((s={})=>{const a=_e(s);return async(i,c)=>a(i,c)},"createNodeHttpHandler"),zn=M((s={})=>_e(s),"createExpressHandler");export{zn as createExpressHandler,_n as createNodeHttpHandler,_e as createOpenInEditorMiddleware};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/ono",
3
- "version": "2.0.0-alpha.34",
3
+ "version": "2.0.0-alpha.35",
4
4
  "description": "Ono is an error-parsing library that pretty prints JavaScript errors on a web page or the terminal.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -94,7 +94,7 @@
94
94
  },
95
95
  "dependencies": {
96
96
  "@shikijs/langs": "catalog:prod",
97
- "@visulima/error": "6.0.0-alpha.31",
97
+ "@visulima/error": "6.0.0-alpha.32",
98
98
  "isomorphic-dompurify": "catalog:prod",
99
99
  "launch-editor-middleware": "catalog:prod",
100
100
  "shiki": "catalog:syntax"
@@ -114,7 +114,7 @@
114
114
  "@types/http-errors": "catalog:types",
115
115
  "@types/node": "catalog:types",
116
116
  "@visulima/packem": "catalog:dev",
117
- "@visulima/path": "3.0.0-alpha.11",
117
+ "@visulima/path": "3.0.0-alpha.12",
118
118
  "@vitest/coverage-v8": "catalog:test",
119
119
  "cssnano": "catalog:dev",
120
120
  "esbuild": "catalog:build",