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.3.2 to 2.3.3

2

package.json
{
"name": "esmock",
"type": "module",
"version": "2.3.2",
"version": "2.3.3",
"license": "ISC",

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

@@ -28,3 +28,4 @@ ```diff

"test-ts": "node --loader=ts-node/esm --loader=esmock --test *ts",
"test-jest": "NODE_OPTIONS=--loader=esmock jest"
"test-jest": "NODE_OPTIONS=--loader=esmock jest",
"test-tsx": "⚠ https://github.com/esbuild-kit/tsx/issues/264"
},

@@ -31,0 +32,0 @@ "jest": {

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

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