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.3 to 2.3.4

2

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

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

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

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