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.2 to 2.5.3

2

package.json
{
"name": "esmock",
"type": "module",
"version": "2.5.2",
"version": "2.5.3",
"license": "ISC",

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

type MockMap = { [specifier: string]: any }
type Resolver = (id: string, parent: string) => string | null

@@ -6,3 +7,4 @@ type Options = {

purge?: boolean | undefined,
isModuleNotFoundError?: boolean | undefined
isModuleNotFoundError?: boolean | undefined,
resolver?: Resolver | undefined
}

@@ -94,3 +96,4 @@

type MockMap,
type Options
type Options,
type Resolver
}

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

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