@visulima/source-map
Version:
Provides functionality related to source maps.
5 lines (4 loc) • 13.5 kB
JavaScript
var Xt=Object.defineProperty;var L=(s,a)=>Xt(s,"name",{value:a,configurable:!0});import{createRequire as Yt}from"node:module";import{AnyMap as nn}from"@jridgewell/trace-mapping";const en=Yt(import.meta.url),q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,tn=L(s=>{if(typeof q<"u"&&q.versions&&q.versions.node){const[a,l]=q.versions.node.split(".").map(Number);if(a>22||a===22&&l>=3||a===20&&l>=16)return q.getBuiltinModule(s)}return en(s)},"__cjs_getBuiltinModule"),{readFileSync:me}=tn("node:fs");var rn=Object.defineProperty,on=L((s,a)=>rn(s,"name",{value:a,configurable:!0}),"$e"),sn=Object.defineProperty,K=on((s,a)=>sn(s,"name",{value:a,configurable:!0}),"W"),an=Object.defineProperty,i=K((s,a)=>an(s,"name",{value:a,configurable:!0}),"u$1");let $e=i(()=>{var s=(()=>{var a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,f=Object.getOwnPropertyNames,g=Object.prototype.hasOwnProperty,x=i((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},"ne"),A=i((e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!g.call(e,r)&&r!==n&&a(e,r,{get:i(()=>t[r],"get"),enumerable:!(o=l(t,r))||o.enumerable});return e},"ae"),b=i(e=>A(a({},"__esModule",{value:!0}),e),"oe"),I={};x(I,{zeptomatch:i(()=>xe,"zeptomatch")});var Q=i(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:u}=r;if(u?.length)for(let c=0,h=u.length;c<h;c++)n.push(u[c])}return Array.from(t)},"M"),Ae=i(e=>{let t="";const n=Q(e);for(let o=0,r=n.length;o<r;o++){const u=n[o];if(!u.regex)continue;const c=u.regex.flags;if(t||(t=c),t!==c)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${c}"`)}return t},"se"),X=i((e,t,n)=>{const o=n.get(e);if(o!==void 0)return o;const r=e.partial??t;let u="";if(e.regex&&(u+=r?"(?:$|":"",u+=e.regex.source),e.children?.length){const c=ze(e.children.map(h=>X(h,t,n)).filter(Boolean));if(c?.length){const h=e.children.some(B=>!B.regex||!(B.partial??t)),m=c.length>1||r&&(!u.length||h);u+=m?r?"(?:$|":"(?:":"",u+=c.join("|"),u+=m?")":""}}return e.regex&&(u+=r?")":""),n.set(e,u),u},"O"),_e=i((e,t)=>{const n=new Map,o=Q(e);for(let r=o.length-1;r>=0;r--){const u=X(o[r],t,n);if(!(r>0))return u}return""},"ie"),ze=i(e=>Array.from(new Set(e)),"ue"),N=i((e,t,n)=>N.compile(e,n).test(t),"R");N.compile=(e,t)=>{const n=t?.partial??!1,o=_e(e,n),r=Ae(e);return new RegExp(`^(?:${o})$`,r)};var Oe=N,Ee=i((e,t)=>{const n=Oe.compile(e,t),o=`${n.source.slice(0,-1)}[\\\\/]?$`,r=n.flags;return new RegExp(o,r)},"le"),ke=Ee,Ie=i(e=>{const t=e.map(o=>o.source).join("|")||"$^",n=e[0]?.flags;return new RegExp(t,n)},"ve"),Re=Ie,Y=i(e=>Array.isArray(e),"j"),R=i(e=>typeof e=="function","_"),Pe=i(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))})(),Se=i(e=>typeof e=="number","de"),qe=i(e=>typeof e=="object"&&e!==null,"xe"),We=i(e=>e instanceof RegExp,"me"),Ze=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),Ce=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),ee=i(e=>typeof e=="string","A"),w=i(e=>e===void 0,"f"),Le=i(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"),te=i((e,t,n={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:n,output:[]},r=j(t)(o),u=Math.max(o.index,o.indexBacktrackMax);if(r&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${u}`)},"I"),p=i((e,t)=>Y(e)?Ue(e,t):ee(e)?ne(e,t):Fe(e,t),"i"),Ue=i((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 u=o.index,c=u;for(;c<r.length&&r.charCodeAt(c)in n;)c+=1;if(c>u){if(!w(t)&&!o.options.silent){const h=r.slice(u,c),m=R(t)?t(h,r,`${u}`):t;w(m)||o.output.push(m)}o.index=c}return!0}},"we"),Fe=i((e,t)=>{if(Ce(e))return ne(e.source,t);{const n=e.source,o=e.flags.replace(/y|$/,"y"),r=new RegExp(n,o);return Ze(e)&&R(t)&&!Be(t)?Ne(r,t):Te(r,t)}},"$e"),Ne=i((e,t)=>n=>{const o=n.index,r=n.input;e.lastIndex=o;const u=e.exec(r);if(u){const c=e.lastIndex;if(!n.options.silent){const h=t(...u,r,`${o}`);w(h)||n.output.push(h)}return n.index=c,!0}else return!1},"Ee"),Te=i((e,t)=>n=>{const o=n.index,r=n.input;if(e.lastIndex=o,e.test(r)){const u=e.lastIndex;if(!w(t)&&!n.options.silent){const c=R(t)?t(r.slice(o,u),r,`${o}`):t;w(c)||n.output.push(c)}return n.index=u,!0}else return!1},"Ce"),ne=i((e,t)=>n=>{const o=n.index,r=n.input;if(r.startsWith(e,o)){if(!w(t)&&!n.options.silent){const u=R(t)?t(e,r,`${o}`):t;w(u)||n.output.push(u)}return n.index+=e.length,!0}else return!1},"F"),T=i((e,t,n,o)=>{const r=j(e),u=t>1;return D(G(oe(c=>{let h=0;for(;h<n;){const m=c.index;if(!r(c)||(h+=1,c.index===m))break}return h>=t},u),o))},"k"),re=i((e,t)=>T(e,0,1,t),"L"),C=i((e,t)=>T(e,0,1/0,t),"$"),Ge=i((e,t)=>T(e,1,1/0,t),"Re"),O=i((e,t)=>{const n=e.map(j);return D(G(oe(o=>{for(let r=0,u=n.length;r<u;r++)if(!n[r](o))return!1;return!0}),t))},"x"),y=i((e,t)=>{const n=e.map(j);return D(G(o=>{for(let r=0,u=n.length;r<u;r++)if(n[r](o))return!0;return!1},t))},"p"),oe=i((e,t=!0,n=!1)=>{const o=j(e);return t?r=>{const u=r.index,c=r.output.length,h=o(r);return!h&&!n&&(r.indexBacktrackMax=Math.max(r.indexBacktrackMax,r.index)),(!h||n)&&(r.index=u,r.output.length!==c&&(r.output.length=c)),h}:o},"q"),G=i((e,t)=>{const n=j(e);return t?o=>{if(o.options.silent)return n(o);const r=o.output.length;if(n(o)){const u=o.output.splice(r,1/0),c=t(u);return w(c)||o.output.push(c),!0}else return!1}:n},"B"),D=(()=>{let e=0;return t=>{const n=j(t),o=e+=1;return r=>{var u;if(r.options.memoization===!1)return n(r);const c=r.index,h=(u=r.cache)[o]||(u[o]={indexMax:-1,queue:[]}),m=h.queue;if(c<=h.indexMax){const S=h.store||(h.store=new Map);if(m.length){for(let k=0,Jt=m.length;k<Jt;k+=2){const Kt=m[k*2],Qt=m[k*2+1];S.set(Kt,Qt)}m.length=0}const v=S.get(c);if(v===!1)return!1;if(Se(v))return r.index=v,!0;if(v)return r.index=v.index,v.output?.length&&r.output.push(...v.output),!0}const B=r.output.length,Ht=n(r);if(h.indexMax=Math.max(h.indexMax,c),Ht){const S=r.index,v=r.output.length;if(v>B){const k=r.output.slice(B,v);m.push(c,{index:S,output:k})}else m.push(c,S);return!0}else return m.push(c,!1),!1}}})(),se=i(e=>{let t;return n=>(t||(t=j(e())),t(n))},"G"),j=Le(e=>{if(R(e))return Pe(e)?se(e):e;if(ee(e)||We(e))return p(e);if(Y(e))return O(e);if(qe(e))return y(Object.values(e));throw new Error("Invalid rule")}),_=i(e=>e,"d"),De=i(e=>typeof e=="string","ke"),Ve=i(e=>{const t=new WeakMap,n=new WeakMap;return(o,r)=>{const u=r?.partial?n:t,c=u.get(o);if(c!==void 0)return c;const h=e(o,r);return u.set(o,h),h}},"Be"),He=i(e=>{const t={},n={};return(o,r)=>{const u=r?.partial?n:t;return u[o]??(u[o]=e(o,r))}},"Pe"),Je=p(/\\./,_),Ke=p(/./,_),Qe=p(/\*\*\*+/,"*"),Xe=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),Ye=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),et=C(y([Je,Qe,Xe,Ye,Ke])),tt=et,nt=i(e=>te(e,tt,{memoization:!1}).join(""),"Ie"),rt=nt,ae="abcdefghijklmnopqrstuvwxyz",ot=i(e=>{let t="";for(;e>0;){const n=(e-1)%26;t=ae[n]+t,e=Math.floor((e-1)/26)}return t},"Le"),le=i(e=>{let t=0;for(let n=0,o=e.length;n<o;n++)t=t*26+ae.indexOf(e[n])+1;return t},"V"),V=i((e,t)=>{if(t<e)return V(t,e);const n=[];for(;e<=t;)n.push(e++);return n},"b"),st=i((e,t,n)=>V(e,t).map(o=>String(o).padStart(n,"0")),"qe"),ue=i((e,t)=>V(le(e),le(t)).map(ot),"W"),d=i(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),P=i(e=>({children:e}),"y"),E=(()=>{const e=i((t,n,o)=>{if(o.has(t))return;o.add(t);const{children:r}=t;if(!r.length)r.push(n);else for(let u=0,c=r.length;u<c;u++)e(r[u],n,o)},"e");return t=>{if(!t.length)return P([]);for(let n=t.length-1;n>=1;n--){const o=new Set,r=t[n-1],u=t[n];e(r,u,o)}return t[0]}})(),M=i(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),at=p(/\\./,d),lt=p(/[$.*+?^(){}[\]\|]/,e=>d(`\\${e}`)),ut=p(/[\\\/]/,M),it=p(/[^$.*+?^(){}[\]\|\\\/]+/,d),ct=p(/^(?:!!)*!(.*)$/,(e,t)=>d(`(?!^${xe.compile(t).source}$).*?`)),ft=p(/^(!!)+/),pt=y([ct,ft]),gt=p(/\/(\*\*\/)+/,()=>P([E([M(),d(".+?"),M()]),M()])),ht=p(/^(\*\*\/)+/,()=>P([d("^"),E([d(".*?"),M()])])),dt=p(/\/(\*\*)$/,()=>P([E([M(),d(".*?")]),d("$")])),xt=p(/\*\*/,()=>d(".*?")),ie=y([gt,ht,dt,xt]),mt=p(/\*\/(?!\*\*\/|\*$)/,()=>E([d("[^\\\\/]*?"),M()])),$t=p(/\*/,()=>d("[^\\\\/]*")),ce=y([mt,$t]),fe=p("?",()=>d("[^\\\\/]")),bt=p("[",_),yt=p("]",_),vt=p(/[!^]/,"^\\\\/"),wt=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,_),jt=p(/\\./,_),Mt=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),At=p(/[\\\/]/,"\\\\/"),_t=p(/[^$.*+?^(){}[\]\|\\\/]+/,_),zt=y([jt,Mt,At,wt,_t]),pe=O([bt,re(vt),C(zt),yt],e=>d(e.join(""))),Ot=p("{","(?:"),Et=p("}",")"),kt=p(/(\d+)\.\.(\d+)/,(e,t,n)=>st(+t,+n,Math.min(t.length,n.length)).join("|")),It=p(/([a-z]+)\.\.([a-z]+)/,(e,t,n)=>ue(t,n).join("|")),Rt=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,n)=>ue(t.toLowerCase(),n.toLowerCase()).join("|").toUpperCase()),Pt=y([kt,It,Rt]),ge=O([Ot,Pt,Et],e=>d(e.join(""))),Bt=p("{"),St=p("}"),qt=p(","),Wt=p(/\\./,d),Zt=p(/[$.*+?^(){[\]\|]/,e=>d(`\\${e}`)),Ct=p(/[\\\/]/,M),Lt=p(/[^$.*+?^(){}[\]\|\\\/,]+/,d),Ut=se(()=>de),Ft=p("",()=>d("(?:)")),Nt=Ge(y([ie,ce,fe,pe,ge,Ut,Wt,Zt,Ct,Lt]),E),he=y([Nt,Ft]),de=O([Bt,re(O([he,C(O([qt,he]))])),St],P),Tt=C(y([pt,ie,ce,fe,pe,ge,de,at,lt,ut,it]),E),Gt=Tt,Dt=i(e=>te(e,Gt,{memoization:!1})[0],"kr"),Vt=Dt,H=i((e,t,n)=>H.compile(e,n).test(t),"N");H.compile=(()=>{const e=He((n,o)=>ke(Vt(rt(n)),o)),t=Ve((n,o)=>Re(n.map(r=>e(r,o))));return(n,o)=>De(n)?e(n,o):t(n,o)})();var xe=H;return b(I)})();return s.default||s},"_lazyMatch"),J;const ln=i((s,a)=>(J||(J=$e(),$e=null),J(s,a)),"default");var un=Object.defineProperty,cn=K((s,a)=>un(s,"name",{value:a,configurable:!0}),"t$1");const fn=/^[A-Z]:\//i,z=cn((s="")=>s&&s.replaceAll("\\","/").replace(fn,a=>a.toUpperCase()),"normalizeWindowsPath");var pn=Object.defineProperty,$=K((s,a)=>pn(s,"name",{value:a,configurable:!0}),"r");const gn=/^[/\\]{2}/,hn=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,ye=/^[A-Z]:$/i,be=/^\/([A-Z]:)?$/i,dn=/.(\.[^./]+)$/,xn=/^[/\\]|^[a-z]:[/\\]/i,mn=$(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),ve=$((s,a)=>{let l="",f=0,g=-1,x=0,A;for(let b=0;b<=s.length;++b){if(b<s.length)A=s[b];else{if(A==="/")break;A="/"}if(A==="/"){if(!(g===b-1||x===1))if(x===2){if(l.length<2||f!==2||!l.endsWith(".")||l.at(-2)!=="."){if(l.length>2){const I=l.lastIndexOf("/");I===-1?(l="",f=0):(l=l.slice(0,I),f=l.length-1-l.lastIndexOf("/")),g=b,x=0;continue}else if(l.length>0){l="",f=0,g=b,x=0;continue}}a&&(l+=l.length>0?"/..":"..",f=2)}else l.length>0?l+=`/${s.slice(g+1,b)}`:l=s.slice(g+1,b),f=b-g-1;g=b,x=0}else A==="."&&x!==-1?++x:x=-1}return l},"normalizeString"),Z=$(s=>hn.test(s),"isAbsolute"),we=$(function(s){if(s.length===0)return".";s=z(s);const a=gn.exec(s),l=Z(s),f=s.at(-1)==="/";return s=ve(s,!l),s.length===0?l?"/":f?"./":".":(f&&(s+="/"),ye.test(s)&&(s+="/"),a?l?`//${s}`:`//./${s}`:l&&!Z(s)?`/${s}`:s)},"normalize");$((...s)=>{let a="";for(const l of s)if(l)if(a.length>0){const f=a[a.length-1]==="/",g=l[0]==="/";f&&g?a+=l.slice(1):a+=f||g?l:`/${l}`}else a+=l;return we(a)},"join");const U=$(function(...s){s=s.map(f=>z(f));let a="",l=!1;for(let f=s.length-1;f>=-1&&!l;f--){const g=f>=0?s[f]:mn();!g||g.length===0||(a=`${g}/${a}`,l=Z(g))}return a=ve(a,!l),l&&!Z(a)?`/${a}`:a.length>0?a:"."},"resolve"),W=$(function(s){return z(s)},"toNamespacedPath"),$n=$(function(s){return dn.exec(z(s))?.[1]??""},"extname");$(function(s,a){const l=U(s).replace(be,"$1").split("/"),f=U(a).replace(be,"$1").split("/");if(f[0][1]===":"&&l[0][1]===":"&&l[0]!==f[0])return f.join("/");const g=[...l];for(const x of g){if(f[0]!==x)break;l.shift(),f.shift()}return[...l.map(()=>".."),...f].join("/")},"relative");const je=$(s=>{const a=z(s).replace(/\/$/,"").split("/").slice(0,-1);return a.length===1&&ye.test(a[0])&&(a[0]+="/"),a.join("/")||(Z(s)?"/":".")},"dirname");$(function(s){const a=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return z(s.root?U(...a):a.join("/"))},"format");const bn=$((s,a)=>{const l=z(s).split("/").pop();return a&&l.endsWith(a)?l.slice(0,-a.length):l},"basename");$(function(s){const a=xn.exec(s)?.[0]?.replaceAll("\\","/")??"",l=bn(s),f=$n(l);return{base:l,dir:je(s),ext:f,name:l.slice(0,l.length-f.length),root:a}},"parse");$((s,a)=>ln(a,we(s)),"matchesGlob");var yn=Object.defineProperty,F=L((s,a)=>yn(s,"name",{value:a,configurable:!0}),"s");const vn=/^data:application\/json[^,]+base64,/,wn=/\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+)[ \t]*$|\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*\*\/[ \t]*$/,Me=F(s=>vn.test(s),"isInlineMap"),jn=F((s,a)=>{const l=s.split(/\r?\n/);let f=null;for(let x=l.length-1;x>=0&&!f;x--)f=wn.exec(l[x]);if(!f)return;const g=f[1]??f[2];if(g)return Me(g)?g:U(a,g)},"resolveSourceMapUrl"),Mn=F(s=>{const a=s.slice(s.indexOf(",")+1);return Buffer.from(a,"base64").toString()},"decodeInlineMap"),On=F(s=>{let a;try{a=me(s,{encoding:"utf8"})}catch(g){throw g.message=`Error reading sourcemap for file "${W(s)}":
${W(g.message)}`,g}const l=jn(a,je(s));if(!l)return;let f;if(Me(l))f=Mn(l);else try{f=me(l,{encoding:"utf8"})}catch(g){throw g.message=`Error reading sourcemap for file "${W(s)}":
${W(g.message)}`,g}try{return new nn(f,l)}catch(g){throw g.message=`Error parsing sourcemap for file "${W(s)}":
${g.message}`,g}},"loadSourceMap");export{On as default};