Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esmock

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esmock - npm Package Compare versions

Comparing version 2.5.4 to 2.5.5

2

package.json
{
"name": "esmock",
"type": "module",
"version": "2.5.4",
"version": "2.5.5",
"license": "ISC",

@@ -6,0 +6,0 @@ "readmeFilename": "README.md",

@@ -1,3 +0,3 @@

var ze=Object.defineProperty;var Ue=(e,t)=>{for(var s in t)ze(e,s,{get:t[s],enumerable:!0})};import Ge from"node:module";var v={};Ue(v,{default:()=>C,getSource:()=>at,globalPreload:()=>rt,initialize:()=>nt,load:()=>re,resolve:()=>it});import Ve from"node:fs/promises";import Y from"node:module";import We from"process";var Be=(e,t)=>new Error(`invalid moduleId: "${e}" (used by ${t})`),_e=(e,t)=>new Error(`un-mocked moduleId: "${e}" (used by ${t})`),qe=()=>new Error("For versions of node prior to v20.6.0, the loader chain process must include esmock. start the process using --loader=esmock."),Le=(e,t)=>new Error(`no mocks provided for module: "${e}" (used by ${t})`),f={errModuleIdNotFound:Be,errModuleIdNotMocked:_e,errMissingLoader:qe,errModuleIdNoDefs:Le};var[V,Ze]=We.versions.node.split(".").map(e=>+e),ee=V<16||V===16&&Ze<12,k=import.meta.url,He=/\?esmkgdefs=.*/,te=/.*\?esmkgdefs=/,O=/#-#esmkdefs/,W=/^file:\/\/\/import\?/,Je=/file:\/\/\/import\?([^#]*)/,Qe=/\bimport,|,import\b|\bimport\b/g,S=/esmkTreeId=\d*/,Xe=/esmkModuleId=([^&]*)/,Z=/\?esmk=\d*/,I=/.*exportNames=(.*)/,Ye=/.*#-#/,et=/isesm=true/,tt=/isfound=false/,st=/^(commonjs|module)$/,ot=/strict=3/,H=/^(#![^\n]*\n)/,J=(e,t)=>new RegExp(`.*(${e}(\\?${t}(?:(?!#-#).)*)).*`),E=global.mockKeys=global.mockKeys||{},rt=!Y.register&&(({port:e})=>(e.addEventListener("message",t=>E[t.data.key]=t.data.keylong),e.unref(),"global.postMessageEsmk = d => port.postMessage(d)")),nt=Y.register&&(e=>{e&&e.port&&e.port.on("message",t=>{E[t.key]=t.keylong})}),Q=e=>{let[t,s]=e.match(Je)||[];return[t,I.test(s)&&s.replace(I,"$1").split(",")]},ct=e=>{let t=e.split(O)[1]||"",s=Q(t),o=e.replace(te,""),r=Q(o);return[s[0]||r[0],[...new Set([s[1]||[],r[1]||[]].flat())]]},se=e=>Z.test(e)&&E[e.match(Z)[0].split("=")[1]],X=async(e,t,s)=>s.parentURL&&(s.conditions.slice(-1)[0]==="node-addons"||s.importAssertions||ee)?e(t,s):e(t),it=async(e,t,s)=>{let{parentURL:o}=t,r=se(o)||o;if(!S.test(r))return X(s,e,t);let[n]=String(r).match(S),[c,l]=r.split(O),a=c&&c.replace(te,"");if(r.includes(`esmkModuleId=${e}&isfound=false`)){let b=J(`file:///${e}`,n),j=(a.match(b)||l.match(b)||[])[2];if(j)return{shortCircuit:!0,url:k+j}}if(W.test(e))return{shortCircuit:!0,url:e.replace(W,k+"?")};let p=await X(s,e,t),u=J(p.url,n),d=u.test(l)&&l.replace(u,"$1")||u.test(a)&&a.replace(u,"$1");if(d?p.url=et.test(d)?d:k+"#-#"+d:a&&a!=="0"&&(p.url.startsWith("node:")||(p.url+="?esmkgdefs="+a)),ot.test(r)&&!d)throw f.errModuleIdNotMocked(p.url,r.split("?")[0]);return p},oe=k+"?esmock-loader=true",C=(e=>async()=>e=e||(await import(oe)).default===!0)(),re=async(e,t,s)=>{if(e===oe)return{format:"module",shortCircuit:!0,responseURL:e,source:"export default true"};let o=se(e)||e;if(o&&(o.match(S)||[])[0]){let[c,l]=ct(o);if(l&&l.length){let a=await s(e,t);if(!st.test(a.format))return a;let p=a.source===null||a.source===void 0,u=String(p?await Ve.readFile(new URL(e)):a.source),d=(u.match(H)||[])[0]||"",b=d?u.replace(H,""):u,j=a.format==="commonjs"?`const {${l}} = global.esmockCacheGet("${c}");`:`import {${l}} from '${c}';`;return{format:a.format,shortCircuit:!0,responseURL:encodeURI(e),source:d+j+b}}}if(O.test(e))return s(e,t);e=e.replace(He,""),e.startsWith(k)&&(e=e.replace(Ye,""),tt.test(e)&&(e=e.replace(k,`file:///${e.match(Xe)[1]}`)));let n=I.test(e)&&e.replace(I,"$1").replace(Qe,"").split(",");return n&&n[0]?{format:"module",shortCircuit:!0,responseURL:encodeURI(e),source:n.map(c=>c==="default"?`export default global.esmockCacheGet("${e}").default`:`export const ${c} = global.esmockCacheGet("${e}").${c}`).join(`
`)}:s(e,t)},at=ee&&re;import Bt from"fs";import me from"fs";import pe from"url";import i from"path";import ue from"module";var T=ue.createRequire(import.meta.url),ne=me.realpathSync.native,de=new RegExp("^(?:node:)?("+ue.builtinModules.join("|").replace("/","/")+")$"),lt=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,A=/^.\.?(?=\/|\\)/,ce=/\\/g,mt=/index.[tj]sx?$/,pt=/[\\/]resolvewithplus[\\/]/,ie=/\.js$/,ut=/\.ts$/,dt=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,P=/^#/,fe=/(\*)/g,ge=/([./])/g,ft=/^node:/,gt=/^file:/,ke=[".js",".mjs",".ts",".tsx",".json",".node"],kt=ke.map(e=>`index${e}`),ae="node_modules",$="package.json",he="node",w="default",ht="browser",K="import",ye=":spectype",yt="module",bt="import",be="commonjs",jt="require",M=".",It=e=>e&&typeof e=="object",F={},je=e=>({[yt]:bt,[be]:jt})[e]||null,Mt=e=>ft.test(e)?e:`node:${e}`,wt=e=>e&&pe.pathToFileURL(e).href,$t=e=>de.test(e),Rt=e=>gt.test(e)?pe.fileURLToPath(e):e,xt=e=>i.resolve(i.extname(e)?i.dirname(e):e)+i.sep,N=e=>ce.test(e)?e.replace(ce,i.posix.sep):e,g=(e,t)=>{try{t=me.statSync(e)}catch{t=!1}return t&&(t.isFile()||t.isFIFO())},St=(e,t)=>{let s=t.find(o=>g(e+o))||null;return s&&e+s},Ot=(e,t)=>{let s=t.find(o=>g(i.join(e,o)))||null;return s&&i.join(e,s)},Ie=(e,t=e.split(i.sep))=>{let s=(o,r=[[],[]])=>{if(!o.length)return r[1];if(o[0]===ae&&!pt.test(e))return s(o.slice(1),r);let n=r[0].length?i.join(r[0].slice(-1)[0],o[0]):o[0]||i.sep;return r[0].push(n),r[1].push(i.resolve(i.join(n,ae))),s(o.slice(1),r)};return s(t)},Et=e=>{let t=e.split(i.sep).slice(1).reduce((s,o,r)=>(s.push(i.resolve(i.join(r?s[r-1]:i.sep,o))),s),[]).reverse().find(s=>g(i.join(s,$)));return t&&i.join(t,$)},Ct=e=>(String(e).match(dt)||[]).slice(1),le=(e,t)=>new RegExp(e.replace(ge,"\\$1").replace(fe,".*")).test(t),vt=(e,t,s)=>{let o=new RegExp(e.replace(ge,"\\$1").replace(fe,"(.*)")),r=(s.match(o)||[])[1];return r&&t.replace("*",r)},Me=(e,t,s,o=!1)=>(le(e,s)&&(t.includes("*")?le(t,s)?o=s:e.includes("*")&&e!==t&&(o=vt(e,t,s)):o=t),o),we=(e,t,s,o=e[0])=>e.length?(P.test(s)?P.test(o):A.test(o))&&typeof t[o]=="string"&&Me(o,t[o],s)||we(e.slice(1),t,s):null,m=(e,t,s={})=>{let o=!1;return typeof e=="string"?e:(!o&&Array.isArray(e)&&(o=e.reduce((r,n)=>r||m(n,t,s),null)),!o&&It(e)&&(typeof e[t]=="string"&&(o=e[t]),o||(o=(s.priority||[he,w]).reduce((r,n)=>r||(n=n===ye?je(s.packagejsontype):n,m(e[n],t,s)),!1)),!o&&e[w]&&(o=m(e[w],t)),!o&&e[t]&&(o=m(e[t],t,s)),!o&&e[M]&&(o=typeof e[M]=="string"?t===K&&m(e[M],t,s):m(e[M],t,s)),o||(o=we(Object.keys(e),e,t))),o)},R=(e,t={})=>{var s=null,o=t.istypescript&&ie.test(e)&&e.replace(ie,".ts");return g(o)?s=o:g(e)?s=e:s=St(e,ke),s},Pt=e=>e.type||be,Ft=(e,t={},s="")=>{let o=s?i.join(s,e):e;return R(o,t)||!mt.test(e)&&R(i.join(o,"index"))},Nt=(e,t={},s="",o=!1)=>{let r=t.packagejsontype;return t.isspectype!==!1&&(o=e[r]||e[je(r)]),!o&&e.main&&(o=Ft(e.main,t,s)),o||null},$e=(e,t={},s="",o)=>{let r=Pt(e),n=Object.assign({packagejsontype:r},t);return t.isbrowser&&e.browser&&(o=m(e.browser,K,n)),!o&&e.exports&&(o=m(e.exports,r,n)),o||(o=Nt(e,n,s)),o},Re=(e,t)=>{let s=i.join(e,$),o=g(s)&&T(s);return(o?$e(o,t,e):!1)||Ot(e,kt)},xe=(e,t,s)=>{let o=A.test(e)?i.join(t,e):e;return R(o,s)||Re(o,s)},Tt=(e,t,s,o)=>{let r=s&&s.imports,n=m(r,t,o);return n&&(A.test(n)?i.join(e,n):Oe(n,e,{isposixpath:!0}))},At=(e,t,s,o,r)=>{let n=m(o&&o.exports,s?"./"+s:K,r);return n&&i.join(e,t,n)},Kt=(e,t,s,o)=>{let r=i.join(e,t,$),n=g(r),c=n&&T(r);return n&&At(e,t,s,c,o)},Dt=(e,t,s)=>{let o=Et(t),r=i.dirname(o);return o&&Tt(r,e,T(o),s)},Gt=(e,t,s)=>{let[o,r]=Ct(e);if(P.test(o))return Dt(e,t,s);let n=Ie(t);return function c(l,a){return a--?Kt(i.join(l[a]),o,r,s)||xe(i.join(l[a],e),null,s)||c(n,a):null}(n,n.length)},zt=(e,t,s)=>{var o=null;return t=typeof t=="string"?xt(Rt(decodeURI(t))):process.cwd(),de.test(e)?o=Mt(e):(o=lt.test(e)?xe(N(e),t,s):Gt(e,t,s),o=o&&(s.isposixpath?ne(o):wt(N(ne(o))))),o},Se=(e,t,s)=>{let o=(r,n)=>typeof r=="boolean"?r:n;return s=s||{},s.istypescript=o(s.istypescript,ut.test(t)),s.isbrowser=o(s.isbrowser,!1),s.isspectype=o(s.isspectype,!0),Array.isArray(s.priority)||(s.priority=s.isbrowser?[ht]:[],s.priority.push(ye),s.priority.push(he),s.priority.push(w)),s},Oe=(e,t,s)=>{let o=F[e+t];return o||(s=Se(e,t,s),o=zt(e,t,s),F[e+t]=o)},x=Object.assign(Oe,{pathToPosix:N,getasnode_module_paths:Ie,getesmkeyvalmatch:Me,getasfilesync:R,getasdirsync:Re,gettargetindex:$e,iscoremodule:$t,createopts:Se,esmparse:m,cache:F});var Ee=/(^\s*|[});\n]\s*)(import\s+(['"]|(\*\s+as\s+)?[^"'()\n;]+\s+from\s+['"]|\{)|export\s+\*\s+from\s+["']|export\s+(\{|default|function|class|var|const|let|async\s+function))/;import Ce from"node:module";import ve from"node:worker_threads";var D=ve.MessageChannel&&new ve.MessageChannel,Pe=(e=>()=>(typeof e=="boolean"||(e=!!Ce.register)&&Ce.register("./esmockLoader.js",{parentURL:import.meta.url,data:{port:D.port2},transferList:[D.port2]}),e))(),Fe=Object.assign(e=>{Pe()?D.port1.postMessage(e):typeof global.postMessageEsmk=="function"&&global.postMessageEsmk(e)},{register:Pe});var G={isESM:{},mockDefs:{}},Ne=(e,t)=>(Fe({key:e,keylong:t}),global.mockKeys[String(e)]=t),z=e=>global.mockKeys[String(e)],U=(e,t)=>global.esmockCache.mockDefs[e]=t,Ut=e=>global.esmockCache.mockDefs[e],Te=e=>G.isESM[e],Ae=(e,t)=>G.isESM[e]=t;Object.assign(global,{esmockCache:G,esmockCacheGet:Ut,esmockTreeIdGet:z,mockKeys:global.mockKeys||{}});var B=e=>typeof e=="object"&&e,_=e=>B(e)&&"default"in e,_t=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,qt=((e=0)=>()=>++e)(),Lt=Object.getPrototypeOf({}),Vt=e=>Object.getPrototypeOf(e)===Lt,Ke=x.iscoremodule,Wt=(e,t)=>Vt(e)?Object.assign({},e,t):Object.assign(Object.keys(e).reduce((s,o)=>(Object.defineProperty(s,o,{value:e[o],writable:!0}),s),Object.create(e)),t),Zt=(e,t)=>B(e)&&B(t)?Wt(e,t):t,Ht=(e,t,s)=>s===null?Object.assign({},e||{},t):(t=Object.assign({},e||{},{default:Zt(_(e)&&e.default,_(t)?t.default:t)},t),!Ke(s)&&Object.isExtensible(t.default)&&(t.default.default=t.default),t),Jt=(e,t)=>(t=Te(e),typeof t=="boolean"||(t=!Ke(e)&&_t.test(e)&&Ee.test(Bt.readFileSync(e,"utf-8")),Ae(e,t)),t),Qt=(e,t)=>{let s=_(e)&&e.default;return/boolean|string|number/.test(typeof s)?e:Object.isExtensible(s)?Object.assign(s,e,{esmkTreeId:t}):Object.assign({},s,e,{esmkTreeId:t})},Xt=e=>{let t=n=>n==="null"||U(n,null),s=z(e.split("esmk=")[1]),[o,r]=s.split("#-#esmkdefs=");String(r).split("#-#").forEach(t),String(o.split("esmkgdefs=")[1]).split("#-#").forEach(t)},Yt=async(e,t,s,o,r)=>{t=Ht(r.strict||!o||await import(o),t,o);let n=(o||"file:///"+s)+"?"+["esmkTreeId="+e,"esmkModuleId="+s,"isfound="+!!o,"isesm="+Jt(o),"exportNames="+Object.keys(t).sort().join()].join("&");return U(n,t),n},q=async(e,t,s,o,r,n,c)=>{if(o=o||Object.keys(s),c=o[0],n=n||[],!c)return n;let l=r.resolver(c,e);if(!l&&r.isModuleNotFoundError!==!1&&c!=="import")throw f.errModuleIdNotFound(c,e);return n.push(await Yt(t,s[c],c,l,r)),q(e,t,s,o.slice(1),r,n)},es=async(e,t,s,o,r)=>{let n=r.resolver(e,t);if(!n)throw f.errModuleIdNotFound(e,t);let c=o?Object.keys(o):[],l=s?Object.keys(s):[];if(r.strict===3&&!c.length&&!l.length)throw f.errModuleIdNoDefs(e,t);let a=typeof r.id=="number"?r.id:qt(),p=`${n}?key=${a}&strict=${r.strict}?`+["esmkgdefs="+(c.length&&(await q(t,a,o,c,r)).join("#-#")||0),"esmkdefs=",l.length&&(await q(t,a,s,l,r)).join("#-#")||0].join("#-#");return Ne(String(a),p),n+`?esmk=${a}`},y=Object.assign(es,{purge:Xt,sanitize:Qt});var ts=/^.*(\(|at )(.*):[\d]*:[\d]*.*$/,De=(e,t)=>(e=typeof e[1]=="string"?e:[e[0],new Error().stack.split(`
`)[3].replace(ts,"$2"),...e.slice(1)],e[4]={resolver:x,...e[4],...t},e);var h=e=>async(...t)=>{let[s,o,r,n,c]=De(t,e);if(!Ge.register&&!await C())throw f.errMissingLoader();let l=await y(s,o,r,n,c),a=await import(l);return c.purge!==!1&&y.purge(l),y.sanitize(a,l)},L=e=>e&&/object|function/.test(typeof e)&&"esmkTreeId"in e&&y.purge(e.esmkTreeId),ss=Object.assign(h({strict:1}),{purge:L,p:h({strict:1,purge:!1})}),os=Object.assign(h({strict:3}),{purge:L,p:h({strict:3,purge:!1})}),Ts=Object.assign(h(),{purge:L,p:h({purge:!1}),strict:ss,strictest:os});var rs=Ge.register?{}:v,{load:As,resolve:Ks,getSource:Ds,initialize:Gs,globalPreload:zs}=rs;export{Ts as default,Ds as getSource,zs as globalPreload,Gs as initialize,As as load,Ks as resolve,ss as strict,os as strictest};
var Be=Object.defineProperty;var qe=(e,t)=>{for(var s in t)Be(e,s,{get:t[s],enumerable:!0})};import ze from"node:module";var v={};qe(v,{default:()=>C,getSource:()=>pt,globalPreload:()=>ct,initialize:()=>it,load:()=>re,resolve:()=>lt});import Ze from"node:fs/promises";import Y from"node:module";import He from"process";var Le=(e,t)=>new Error(`invalid moduleId: "${e}" (used by ${t})`),We=(e,t)=>new Error(`un-mocked moduleId: "${e}" (used by ${t})`),_e=()=>new Error("For versions of node prior to v20.6.0, the loader chain process must include esmock. start the process using --loader=esmock."),Ve=(e,t)=>new Error(`no mocks provided for module: "${e}" (used by ${t})`),f={errModuleIdNotFound:Le,errModuleIdNotMocked:We,errMissingLoader:_e,errModuleIdNoDefs:Ve};var[_,Je]=He.versions.node.split(".").map(e=>+e),ee=_<16||_===16&&Je<12,k=import.meta.url,Qe=/\?esmkgdefs=.*/,te=/.*\?esmkgdefs=/,O=/#-#esmkdefs/,V=/^file:\/\/\/import\?/,Xe=/file:\/\/\/import\?([^#]*)/,Ye=/\bimport,|,import\b|\bimport\b/g,S=/esmkTreeId=\d*/,et=/esmkModuleId=([^&]*)/,Z=/\?esmk=\d*/,I=/.*exportNames=(.*)/,tt=/.*#-#/,st=/isesm=true/,ot=/isfound=false/,rt=/^(commonjs|module)$/,nt=/strict=3/,H=/^(#![^\n]*\n)/,J=(e,t)=>new RegExp(`.*(${e}(\\?${t}(?:(?!#-#).)*)).*`),E=global.mockKeys=global.mockKeys||{},ct=!Y.register&&(({port:e})=>(e.addEventListener("message",t=>E[t.data.key]=t.data.keylong),e.unref(),"global.postMessageEsmk = d => port.postMessage(d)")),it=Y.register&&(e=>{e&&e.port&&e.port.on("message",t=>{E[t.key]=t.keylong})}),Q=e=>{let[t,s]=e.match(Xe)||[];return[t,I.test(s)&&s.replace(I,"$1").split(",")]},at=e=>{let t=e.split(O)[1]||"",s=Q(t),o=e.replace(te,""),r=Q(o);return[s[0]||r[0],[...new Set([s[1]||[],r[1]||[]].flat())]]},se=e=>Z.test(e)&&E[e.match(Z)[0].split("=")[1]],X=async(e,t,s)=>s.parentURL&&(s.conditions.slice(-1)[0]==="node-addons"||s.importAssertions||ee)?e(t,s):e(t),lt=async(e,t,s)=>{let{parentURL:o}=t,r=se(o)||o;if(!S.test(r))return X(s,e,t);let[n]=String(r).match(S),[c,l]=r.split(O),a=c&&c.replace(te,"");if(r.includes(`esmkModuleId=${e}&isfound=false`)){let b=J(`file:///${e}`,n),j=(a.match(b)||l.match(b)||[])[2];if(j)return{shortCircuit:!0,url:k+j}}if(V.test(e))return{shortCircuit:!0,url:e.replace(V,k+"?")};let m=await X(s,e,t),u=J(m.url,n),d=u.test(l)&&l.replace(u,"$1")||u.test(a)&&a.replace(u,"$1");if(d?m.url=st.test(d)?d:k+"#-#"+d:a&&a!=="0"&&(m.url.startsWith("node:")||(m.url+="?esmkgdefs="+a)),nt.test(r)&&!d)throw f.errModuleIdNotMocked(m.url,r.split("?")[0]);return m},oe=k+"?esmock-loader=true",C=(e=>async()=>e=e||(await import(oe)).default===!0)(),re=async(e,t,s)=>{if(e===oe)return{format:"module",shortCircuit:!0,responseURL:e,source:"export default true"};let o=se(e)||e;if(o&&(o.match(S)||[])[0]){let[c,l]=at(o);if(l&&l.length){let a=await s(e,t);if(!rt.test(a.format))return a;let m=a.source===null||a.source===void 0,u=String(m?await Ze.readFile(new URL(e)):a.source),d=(u.match(H)||[])[0]||"",b=d?u.replace(H,""):u,j=a.format==="commonjs"?`const {${l}} = global.esmockCacheGet("${c}");`:`import {${l}} from '${c}';`;return{format:a.format,shortCircuit:!0,responseURL:encodeURI(e),source:d+j+b}}}if(O.test(e))return s(e,t);e=e.replace(Qe,""),e.startsWith(k)&&(e=e.replace(tt,""),ot.test(e)&&(e=e.replace(k,`file:///${e.match(et)[1]}`)));let n=I.test(e)&&e.replace(I,"$1").replace(Ye,"").split(",");return n&&n[0]?{format:"module",shortCircuit:!0,responseURL:encodeURI(e),source:n.map(c=>c==="default"?`export default global.esmockCacheGet("${e}").default`:`export const ${c} = global.esmockCacheGet("${e}").${c}`).join(`
`)}:s(e,t)},pt=ee&&re;import Lt from"fs";import pe from"fs";import me from"url";import i from"path";import ue from"module";var T=ue.createRequire(import.meta.url),ne=pe.realpathSync.native,de=new RegExp("^(?:node:)?("+ue.builtinModules.join("|").replace("/","/")+")$"),mt=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,A=/^.\.?(?=\/|\\)/,ce=/\\/g,ut=/index.[tj]sx?$/,dt=/[\\/]resolvewithplus[\\/]/,ie=/\.js$/,ft=/\.ts$/,gt=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,P=/^#/,fe=/(\*)/g,ge=/([./])/g,kt=/^node:/,ht=/^file:/,ke=[".js",".mjs",".ts",".tsx",".json",".node"],yt=ke.map(e=>`index${e}`),ae="node_modules",$="package.json",he="node",w="default",bt="browser",K="import",ye=":spectype",jt="module",It="import",be="commonjs",Mt="require",M=".",wt=e=>e&&typeof e=="object",F={},je=e=>({[jt]:It,[be]:Mt})[e]||null,$t=e=>kt.test(e)?e:`node:${e}`,Rt=e=>e&&me.pathToFileURL(e).href,xt=e=>de.test(e),St=e=>ht.test(e)?me.fileURLToPath(e):e,Ot=e=>i.resolve(i.extname(e)?i.dirname(e):e)+i.sep,N=e=>ce.test(e)?e.replace(ce,i.posix.sep):e,g=(e,t)=>{try{t=pe.statSync(e)}catch{t=!1}return t&&(t.isFile()||t.isFIFO())},Et=(e,t)=>{let s=t.find(o=>g(e+o))||null;return s&&e+s},Ct=(e,t)=>{let s=t.find(o=>g(i.join(e,o)))||null;return s&&i.join(e,s)},Ie=(e,t=e.split(i.sep))=>{let s=(o,r=[[],[]])=>{if(!o.length)return r[1];if(o[0]===ae&&!dt.test(e))return s(o.slice(1),r);let n=r[0].length?i.join(r[0].slice(-1)[0],o[0]):o[0]||i.sep;return r[0].push(n),r[1].push(i.resolve(i.join(n,ae))),s(o.slice(1),r)};return s(t)},vt=e=>{let t=e.split(i.sep).slice(1).reduce((s,o,r)=>(s.push(i.resolve(i.join(r?s[r-1]:i.sep,o))),s),[]).reverse().find(s=>g(i.join(s,$)));return t&&i.join(t,$)},Pt=e=>(String(e).match(gt)||[]).slice(1),le=(e,t)=>new RegExp(e.replace(ge,"\\$1").replace(fe,".*")).test(t),Ft=(e,t,s)=>{let o=new RegExp(e.replace(ge,"\\$1").replace(fe,"(.*)")),r=(s.match(o)||[])[1];return r&&t.replace("*",r)},Me=(e,t,s,o=!1)=>(le(e,s)&&(t.includes("*")?le(t,s)?o=s:e.includes("*")&&e!==t&&(o=Ft(e,t,s)):o=t),o),we=(e,t,s,o=e[0])=>e.length?(P.test(s)?P.test(o):A.test(o))&&typeof t[o]=="string"&&Me(o,t[o],s)||we(e.slice(1),t,s):null,p=(e,t,s={})=>{let o=!1;return typeof e=="string"?e:(!o&&Array.isArray(e)&&(o=e.reduce((r,n)=>r||p(n,t,s),null)),!o&&wt(e)&&(typeof e[t]=="string"&&(o=e[t]),o||(o=(s.priority||[he,w]).reduce((r,n)=>r||(n=n===ye?je(s.packagejsontype):n,p(e[n],t,s)),!1)),!o&&e[w]&&(o=p(e[w],t)),!o&&e[t]&&(o=p(e[t],t,s)),!o&&e[M]&&(o=typeof e[M]=="string"?t===K&&p(e[M],t,s):p(e[M],t,s)),o||(o=we(Object.keys(e),e,t))),o)},R=(e,t={})=>{var s=null,o=t.istypescript&&ie.test(e)&&e.replace(ie,".ts");return g(o)?s=o:g(e)?s=e:s=Et(e,ke),s},Nt=e=>e.type||be,Tt=(e,t={},s="")=>{let o=s?i.join(s,e):e;return R(o,t)||!ut.test(e)&&R(i.join(o,"index"))},At=(e,t={},s="",o=!1)=>{let r=t.packagejsontype;return t.isspectype!==!1&&(o=e[r]||e[je(r)]),!o&&e.main&&(o=Tt(e.main,t,s)),o||null},$e=(e,t={},s="",o)=>{let r=Nt(e),n=Object.assign({packagejsontype:r},t);return t.isbrowser&&e.browser&&(o=p(e.browser,K,n)),!o&&e.exports&&(o=p(e.exports,r,n)),o||(o=At(e,n,s)),o},Re=(e,t)=>{let s=i.join(e,$),o=g(s)&&T(s);return(o?$e(o,t,e):!1)||Ct(e,yt)},xe=(e,t,s)=>{let o=A.test(e)?i.join(t,e):e;return R(o,s)||Re(o,s)},Kt=(e,t,s,o)=>{let r=s&&s.imports,n=p(r,t,o);return n&&(A.test(n)?i.join(e,n):Oe(n,e,{isposixpath:!0}))},Dt=(e,t,s,o,r)=>{let n=p(o&&o.exports,s?"./"+s:K,r);return n&&i.join(e,t,n)},Gt=(e,t,s,o)=>{let r=i.join(e,t,$),n=g(r),c=n&&T(r);return n&&Dt(e,t,s,c,o)},Ut=(e,t,s)=>{let o=vt(t),r=i.dirname(o);return o&&Kt(r,e,T(o),s)},zt=(e,t,s)=>{let[o,r]=Pt(e);if(P.test(o))return Ut(e,t,s);let n=Ie(t);return function c(l,a){return a--?Gt(i.join(l[a]),o,r,s)||xe(i.join(l[a],e),null,s)||c(n,a):null}(n,n.length)},Bt=(e,t,s)=>{var o=null;return t=typeof t=="string"?Ot(St(decodeURI(t))):process.cwd(),de.test(e)?o=$t(e):(o=mt.test(e)?xe(N(e),t,s):zt(e,t,s),o=o&&(s.isposixpath?ne(o):Rt(N(ne(o))))),o},Se=(e,t,s)=>{let o=(r,n)=>typeof r=="boolean"?r:n;return s=s||{},s.istypescript=o(s.istypescript,ft.test(t)),s.isbrowser=o(s.isbrowser,!1),s.isspectype=o(s.isspectype,!0),Array.isArray(s.priority)||(s.priority=s.isbrowser?[bt]:[],s.priority.push(ye),s.priority.push(he),s.priority.push(w)),s},Oe=(e,t,s)=>{let o=F[e+t];return o||(s=Se(e,t,s),o=Bt(e,t,s),F[e+t]=o)},x=Object.assign(Oe,{pathToPosix:N,getasnode_module_paths:Ie,getesmkeyvalmatch:Me,getasfilesync:R,getasdirsync:Re,gettargetindex:$e,iscoremodule:xt,createopts:Se,esmparse:p,cache:F});var Ee=/(^\s*|[});\n]\s*)(import\s+(['"]|(\*\s+as\s+)?[^"'()\n;]+\s+from\s+['"]|\{)|export\s+\*\s+from\s+["']|export\s+(\{|default|function|class|var|const|let|async\s+function))/;import Ce from"node:module";import ve from"node:worker_threads";var D=ve.MessageChannel&&new ve.MessageChannel,Pe=(e=>()=>(typeof e=="boolean"||(e=!!Ce.register)&&Ce.register("./esmockLoader.js",{parentURL:import.meta.url,data:{port:D.port2},transferList:[D.port2]}),e))(),Fe=Object.assign(e=>{Pe()?D.port1.postMessage(e):typeof global.postMessageEsmk=="function"&&global.postMessageEsmk(e)},{register:Pe});var G={isESM:{},mockDefs:{}},Ne=(e,t)=>(Fe({key:e,keylong:t}),global.mockKeys[String(e)]=t),U=e=>global.mockKeys[String(e)],z=(e,t)=>global.esmockCache.mockDefs[e]=t,qt=e=>global.esmockCache.mockDefs[e],Te=e=>G.isESM[e],Ae=(e,t)=>G.isESM[e]=t;Object.assign(global,{esmockCache:G,esmockCacheGet:qt,esmockTreeIdGet:U,mockKeys:global.mockKeys||{}});var B=e=>typeof e=="object"&&e,q=e=>B(e)&&"default"in e,Wt=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,_t=((e=0)=>()=>++e)(),Vt=Object.getPrototypeOf({}),Zt=e=>Object.getPrototypeOf(e)===Vt,Ke=x.iscoremodule,Ht=(e,t)=>Zt(e)?Object.assign({},e,t):Object.assign(Object.keys(e).reduce((s,o)=>(Object.defineProperty(s,o,{value:e[o],writable:!0}),s),Object.create(e)),t),Jt=(e,t)=>B(e)&&B(t)?Ht(e,t):t,Qt=(e,t,s)=>s===null?Object.assign({},e||{},t):(t=Object.assign({},e||{},{default:Jt(q(e)&&e.default,q(t)?t.default:t)},t),!Ke(s)&&Object.isExtensible(t.default)&&(t.default.default=t.default),t),Xt=(e,t)=>(t=Te(e),typeof t=="boolean"||(t=!Ke(e)&&Wt.test(e)&&Ee.test(Lt.readFileSync(e,"utf-8")),Ae(e,t)),t),Yt=(e,t)=>{let s=q(e)&&e.default;return/boolean|string|number/.test(typeof s)?e:Object.isExtensible(s)?Object.assign(s,e,{esmkTreeId:t}):Object.assign({},s,e,{esmkTreeId:t})},es=e=>{let t=n=>n==="null"||z(n,null),s=U(e.split("esmk=")[1]),[o,r]=s.split("#-#esmkdefs=");String(r).split("#-#").forEach(t),String(o.split("esmkgdefs=")[1]).split("#-#").forEach(t)},ts=async(e,t,s,o,r)=>{t=Qt(r.strict||!o||await import(o),t,o);let n=(o||"file:///"+s)+"?"+["esmkTreeId="+e,"esmkModuleId="+s,"isfound="+!!o,"isesm="+Xt(o),"exportNames="+Object.keys(t).sort().join()].join("&");return z(n,t),n},L=async(e,t,s,o,r,n,c)=>{if(o=o||Object.keys(s),c=o[0],n=n||[],!c)return n;let l=r.resolver(c,e);if(!l&&r.isModuleNotFoundError!==!1&&c!=="import")throw f.errModuleIdNotFound(c,e);return n.push(await ts(t,s[c],c,l,r)),L(e,t,s,o.slice(1),r,n)},ss=async(e,t,s,o,r)=>{let n=r.resolver(e,t);if(!n)throw f.errModuleIdNotFound(e,t);let c=o?Object.keys(o):[],l=s?Object.keys(s):[];if(r.strict===3&&!c.length&&!l.length)throw f.errModuleIdNoDefs(e,t);let a=typeof r.id=="number"?r.id:_t(),m=`${n}?key=${a}&strict=${r.strict}?`+["esmkgdefs="+(c.length&&(await L(t,a,o,c,r)).join("#-#")||0),"esmkdefs=",l.length&&(await L(t,a,s,l,r)).join("#-#")||0].join("#-#");return Ne(String(a),m),n+`?esmk=${a}`},y=Object.assign(ss,{purge:es,sanitize:Yt});import{isBuiltin as os}from"node:module";import{pathToFileURL as rs}from"node:url";var De=process.versions.pnp&&(await import("pnpapi")).default,Ge=De&&((e,t)=>{if(os(e))return e.startsWith("node:")?e:`node:${e}`;if(e==="import")return null;let s=De.resolveRequest(e,t);return s!==null?rs(s).href:null});var ns=/^.*(\(|at )(.*):[\d]*:[\d]*.*$/,cs=Ge||x,Ue=(e,t)=>(e=typeof e[1]=="string"?e:[e[0],new Error().stack.split(`
`)[3].replace(ns,"$2"),...e.slice(1)],e[4]={resolver:cs,...e[4],...t},e);var h=e=>async(...t)=>{let[s,o,r,n,c]=Ue(t,e);if(!ze.register&&!await C())throw f.errMissingLoader();let l=await y(s,o,r,n,c),a=await import(l);return c.purge!==!1&&y.purge(l),y.sanitize(a,l)},W=e=>e&&/object|function/.test(typeof e)&&"esmkTreeId"in e&&y.purge(e.esmkTreeId),is=Object.assign(h({strict:1}),{purge:W,p:h({strict:1,purge:!1})}),as=Object.assign(h({strict:3}),{purge:W,p:h({strict:3,purge:!1})}),Ls=Object.assign(h(),{purge:W,p:h({purge:!1}),strict:is,strictest:as});var ls=ze.register?{}:v,{load:Ws,resolve:_s,getSource:Vs,initialize:Zs,globalPreload:Hs}=ls;export{Ls as default,Vs as getSource,Hs as globalPreload,Zs as initialize,Ws as load,_s as resolve,is as strict,as as strictest};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc