Comparing version 2.4.1 to 2.5.0
{ | ||
"name": "esmock", | ||
"type": "module", | ||
"version": "2.4.1", | ||
"version": "2.5.0", | ||
"license": "ISC", | ||
@@ -6,0 +6,0 @@ "readmeFilename": "README.md", |
@@ -14,25 +14,4 @@ ```diff | ||
_**Note: For versions of node prior to v20.6.0,** "--loader" command line arguments must be used with `esmock` as demonstrated [in the wiki.][4] Current versions of node do not require "--loader"._ | ||
`esmock` is used with node's --loader | ||
``` json | ||
{ | ||
"name": "give-esmock-a-star", | ||
"type": "module", | ||
"scripts": { | ||
"test": "node --loader=esmock --test", | ||
"test-mocha": "mocha --loader=esmock", | ||
"test-tap": "NODE_OPTIONS=--loader=esmock tap", | ||
"test-ava": "NODE_OPTIONS=--loader=esmock ava", | ||
"test-uvu": "NODE_OPTIONS=--loader=esmock uvu spec", | ||
"test-tsm": "node --loader=tsm --loader=esmock --test *ts", | ||
"test-ts": "node --loader=ts-node/esm --loader=esmock --test *ts", | ||
"test-jest": "NODE_OPTIONS=--loader=esmock jest", | ||
"test-tsx": "β https://github.com/esbuild-kit/tsx/issues/264" | ||
}, | ||
"jest": { | ||
"runner": "jest-light-runner" | ||
} | ||
} | ||
``` | ||
`esmock` has the below signature | ||
@@ -39,0 +18,0 @@ ``` javascript |
@@ -1,3 +0,3 @@ | ||
import xe from"node:fs/promises";import Ce from"process";var Re=(e,t)=>new Error(`invalid moduleId: "${e}" (used by ${t})`),Se=(e,t)=>new Error(`un-mocked moduleId: "${e}" (used by ${t})`),Ee=()=>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})`),f={errModuleIdNotFound:Re,errModuleIdNotMocked:Se,errMissingLoader:Ee,errModuleIdNoDefs:Oe};var[z,Ne]=Ce.versions.node.split(".").map(e=>+e),H=z<16||z===16&&Ne<12,g=import.meta.url,Pe=/\?esmkgdefs=.*/,J=/.*\?esmkgdefs=/,E=/#-#esmkdefs/,_=/^file:\/\/\/import\?/,Te=/file:\/\/\/import\?([^#]*)/,ve=/\bimport,|,import\b|\bimport\b/g,S=/esmkTreeId=\d*/,Fe=/esmkModuleId=([^&]*)/,B=/\?esmk=\d*/,$=/.*exportNames=(.*)/,Ae=/.*#-#/,De=/isesm=true/,Ge=/isfound=false/,Ke=/^(commonjs|module)$/,Ue=/strict=3/,V=/^(#![^\n]*\n)/,W=(e,t)=>new RegExp(`.*(${e}(\\?${t}(?:(?!#-#).)*)).*`),Ct=({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,$.test(s)&&s.replace($,"$1").split(",")]},ze=e=>{let t=e.split(E)[1]||"",s=Z(t),o=e.replace(J,""),r=Z(o);return[s[0]||r[0],[...new Set([s[1]||[],r[1]||[]].flat())]]},Q=e=>B.test(e)&&global.esmockTreeIdGet(e.match(B)[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),Nt=async(e,t,s)=>{let{parentURL:o}=t,r=Q(o)||o;if(!S.test(r))return q(s,e,t);let[c]=String(r).match(S),[n,l]=r.split(E),a=n&&n.replace(J,"");if(r.includes(`esmkModuleId=${e}&isfound=false`)){let I=W(`file:///${e}`,c),M=(a.match(I)||l.match(I)||[])[2];if(M)return{shortCircuit:!0,url:g+M}}if(_.test(e))return{shortCircuit:!0,url:e.replace(_,g+"?")};let m=await q(s,e,t),d=W(m.url,c),p=d.test(l)&&l.replace(d,"$1")||d.test(a)&&a.replace(d,"$1");if(p?m.url=De.test(p)?p:g+"#-#"+p:a&&a!=="0"&&(m.url.startsWith("node:")||(m.url+="?esmkgdefs="+a)),Ue.test(r)&&!p)throw f.errModuleIdNotMocked(m.url,r.split("?")[0]);return m},X=g+"?esmock-loader=true",Y=(e=>async()=>e=e||(await import(X)).default===!0)(),_e=async(e,t,s)=>{if(e===X)return{format:"module",shortCircuit:!0,responseURL:e,source:"export default true"};let o=Q(e)||e;if(o&&(o.match(S)||[])[0]){let[n,l]=ze(o);if(l&&l.length){let a=await s(e,t);if(!Ke.test(a.format))return s(e,t);let m=a.source===null||a.source===void 0,d=String(m?await xe.readFile(new URL(e)):a.source),p=(d.match(V)||[])[0]||"",I=p?d.replace(V,""):d,M=a.format==="commonjs"?`const {${l}} = global.esmockCacheGet("${n}");`:`import {${l}} from '${n}';`;return{format:a.format,shortCircuit:!0,responseURL:encodeURI(e),source:p+M+I}}}if(E.test(e))return s(e,t);e=e.replace(Pe,""),e.startsWith(g)&&(e=e.replace(Ae,""),Ge.test(e)&&(e=e.replace(g,`file:///${e.match(Fe)[1]}`)));let c=$.test(e)&&e.replace($,"$1").replace(ve,"").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=H&&_e;import mt from"fs";import ne from"fs";import ce from"url";import i from"path";import ie from"module";var N=ie.createRequire(import.meta.url),L=ne.realpathSync.native,ae=new RegExp("^(?:node:)?("+ie.builtinModules.join("|").replace("/","/")+")$"),Be=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,P=/^.\.?(?=\/|\\)/,ee=/\\/g,Ve=/index.[tj]sx?$/,We=/[\\/]resolvewithplus[\\/]/,Ze=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,O=/^#/,le=/(\*)/g,me=/([./])/g,qe=/^node:/,He=/^file:/,ue=[".js",".mjs",".ts",".tsx",".json",".node"],te="node_modules",R="package.json",se="node",oe="default",T="import",w=".",de=e=>e&&typeof e=="object",x={},Je=e=>qe.test(e)?e:`node:${e}`,Qe=e=>e&&ce.pathToFileURL(e).href,Xe=e=>ae.test(e),Ye=e=>He.test(e)?ce.fileURLToPath(e):e,Le=e=>i.resolve(i.extname(e)?i.dirname(e):e)+i.sep,C=e=>ee.test(e)?e.replace(ee,i.posix.sep):e,k=(e,t)=>{try{t=ne.statSync(e)}catch{t=!1}return t&&(t.isFile()||t.isFIFO())},pe=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(),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,R)));return t&&i.join(t,R)},tt=e=>(String(e).match(Ze)||[]).slice(1),re=(e,t)=>new RegExp(e.replace(me,"\\$1").replace(le,".*")).test(t),st=(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=st(e,t,s)):o=t),o),ge=(e,t,s,o=e[0])=>e.length?(O.test(s)?O.test(o):P.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&&de(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===T&&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:de(o)&&([c]=Object.keys(o).filter(l=>Ve.test(l)),n=c in o&&o[c])),r&&(n=u(r,T)),n},b=e=>{var t=null;return k(e)?t=e:ue.some(s=>k(e+s)&&(t=e+s)),t},he=(e,t)=>{let s=null,o,r=i.join(e,R),c=k(r)&&N(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}`))&&k(n)&&(s=n)),s},be=(e,t,s)=>{let o=P.test(e)?i.join(t,e):e;return b(o,s)||he(o,s)},ot=(e,t,s)=>{let o=s&&s.imports,r=u(o,t);return r&&(P.test(r)?i.join(e,r):je(r,e,{isposixpath:!0}))},rt=(e,t,s,o)=>{let r=u(o&&o.exports,s?"./"+s:T);return r&&i.join(e,t,r)},nt=(e,t,s,o)=>{let r=i.join(e,t,R),c=k(r),n=c&&N(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,N(o),s)},it=(e,t,s)=>{let[o,r]=tt(e);if(O.test(o))return ct(e,t,s);let c=pe(t).sort((n,l)=>n.length>l.length);return function n(l,a,m=a-1){return a--?nt(i.join(l[m-a]),o,r,s)||be(i.join(l[m-a],e),null,s)||n(c,a,m):null}(c,c.length)},at=(e,t,s)=>{var o=null;return t=typeof t=="string"?Le(Ye(decodeURI(t))):process.cwd(),ae.test(e)?o=Je(e):(o=Be.test(e)?be(C(e),t,s):it(e,t),o=o&&(s.isposixpath?L(o):Qe(C(L(o))))),o},je=(e,t,s)=>{let o=x[e+t];return o||(o=at(e,t,s||{}),x[e+t]=o)},j=Object.assign(je,{pathToPosix:C,getasnode_module_paths:pe,getesmkeyvalmatch:fe,getasfilesync:b,getasdirsync:he,gettargetindex:ke,iscoremodule:Xe,esmparse:u,cache:x});var ye=/(^\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 v={isESM:{},mockDefs:{}},Ie=(e,t)=>(typeof global.postMessageEsmk=="function"&&global.postMessageEsmk({key:e,keylong:t}),global.mockKeys[String(e)]=t),F=e=>global.mockKeys[String(e)],A=(e,t)=>global.esmockCache.mockDefs[e]=t,lt=e=>global.esmockCache.mockDefs[e],Me=e=>v.isESM[e],$e=(e,t)=>v.isESM[e]=t;Object.assign(global,{esmockCache:v,esmockCacheGet:lt,esmockTreeIdGet:F,mockKeys:{}});var D=e=>typeof e=="object"&&e,G=e=>D(e)&&"default"in e,ut=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,dt=((e=0)=>()=>++e)(),pt=Object.getPrototypeOf({}),ft=e=>Object.getPrototypeOf(e)===pt,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)=>D(e)&&D(t)?gt(e,t):t,ht=(e,t,s)=>s===null?Object.assign({},e||{},t):(t=Object.assign({},e||{},{default:kt(G(e)&&e.default,G(t)?t.default:t)},t),!j.iscoremodule(s)&&Object.isExtensible(t.default)&&(t.default.default=t.default),t),bt=(e,t)=>(t=Me(e),typeof t=="boolean"||(t=!j.iscoremodule(e)&&ut.test(e)&&ye.test(mt.readFileSync(e,"utf-8")),$e(e,t)),t),jt=(e,t)=>{let s=G(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})},yt=e=>{let t=c=>c==="null"||A(c,null),s=F(e.split("esmk=")[1]),[o,r]=s.split("#-#esmkdefs=");String(r).split("#-#").forEach(t),String(o.split("esmkgdefs=")[1]).split("#-#").forEach(t)},It=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},K=async(e,t,s,o,r,c,n)=>{if(o=o||Object.keys(s),n=o[0],c=c||[],!n)return c;let l=j(n,e);if(!l&&r.isModuleNotFoundError!==!1&&n!=="import")throw f.errModuleIdNotFound(n,e);return c.push(await It(t,s[n],n,l,r)),K(e,t,s,o.slice(1),r,c)},Mt=async(e,t,s,o,r)=>{let c=j(e,t);if(!c)throw f.errModuleIdNotFound(e,t);let n=o?Object.keys(o):[],l=s?Object.keys(s):[];if(r.strict===3&&!n.length&&!l.length)throw f.errModuleIdNoDefs(e,t);let a=typeof r.id=="number"?r.id:dt(),m=`${c}?key=${a}&strict=${r.strict}?`+["esmkgdefs="+(n.length&&(await K(t,a,o,n,r)).join("#-#")||0),"esmkdefs=",l.length&&(await K(t,a,s,l,r)).join("#-#")||0].join("#-#");return Ie(String(a),m),c+`?esmk=${a}`},y=Object.assign(Mt,{purge:yt,sanitize:jt});var $t=/^.*(\(|at )(.*):[\d]*:[\d]*.*$/,we=(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 h=e=>async(...t)=>{let[s,o,r,c,n]=we(t,e);if(!await Y())throw f.errMissingLoader();let l=await y(s,o,r,c,n),a=await import(l);return n.purge!==!1&&y.purge(l),y.sanitize(a,l)},U=e=>e&&/object|function/.test(typeof e)&&"esmkTreeId"in e&&y.purge(e.esmkTreeId),wt=Object.assign(h({strict:1}),{purge:U,p:h({strict:1,purge:!1})}),Rt=Object.assign(h({strict:3}),{purge:U,p:h({strict:3,purge:!1})}),Yt=Object.assign(h(),{purge:U,p:h({purge:!1}),strict:wt,strictest:Rt});export{Yt as default,Pt as getSource,Ct as globalPreload,_e as load,Nt as resolve,wt as strict,Rt as strictest}; | ||
var Te=Object.defineProperty;var Ke=(e,t)=>{for(var s in t)Te(e,s,{get:t[s],enumerable:!0})};import Ne from"node:module";var C={};Ke(C,{default:()=>E,getSource:()=>ot,globalPreload:()=>Ye,initialize:()=>et,load:()=>oe,resolve:()=>st});import Ue from"node:fs/promises";import X from"node:module";import Be from"process";var Ae=(e,t)=>new Error(`invalid moduleId: "${e}" (used by ${t})`),De=(e,t)=>new Error(`un-mocked moduleId: "${e}" (used by ${t})`),Ge=()=>new Error("For versions of node prior to v20.6.0, the loader chain process must include esmock. start the process using --loader=esmock."),ze=(e,t)=>new Error(`no mocks provided for module: "${e}" (used by ${t})`),f={errModuleIdNotFound:Ae,errModuleIdNotMocked:De,errMissingLoader:Ge,errModuleIdNoDefs:ze};var[V,_e]=Be.versions.node.split(".").map(e=>+e),Y=V<16||V===16&&_e<12,g=import.meta.url,Le=/\?esmkgdefs=.*/,ee=/.*\?esmkgdefs=/,x=/#-#esmkdefs/,W=/^file:\/\/\/import\?/,Ve=/file:\/\/\/import\?([^#]*)/,We=/\bimport,|,import\b|\bimport\b/g,S=/esmkTreeId=\d*/,Ze=/esmkModuleId=([^&]*)/,Z=/\?esmk=\d*/,$=/.*exportNames=(.*)/,qe=/.*#-#/,He=/isesm=true/,Je=/isfound=false/,Qe=/^(commonjs|module)$/,Xe=/strict=3/,q=/^(#![^\n]*\n)/,H=(e,t)=>new RegExp(`.*(${e}(\\?${t}(?:(?!#-#).)*)).*`),O=global.mockKeys=global.mockKeys||{},Ye=!X.register&&(({port:e})=>(e.addEventListener("message",t=>O[t.data.key]=t.data.keylong),e.unref(),"global.postMessageEsmk = d => port.postMessage(d)")),et=X.register&&(e=>{e&&e.port&&e.port.on("message",t=>{O[t.key]=t.keylong})}),J=e=>{let[t,s]=e.match(Ve)||[];return[t,$.test(s)&&s.replace($,"$1").split(",")]},tt=e=>{let t=e.split(x)[1]||"",s=J(t),o=e.replace(ee,""),r=J(o);return[s[0]||r[0],[...new Set([s[1]||[],r[1]||[]].flat())]]},te=e=>Z.test(e)&&O[e.match(Z)[0].split("=")[1]],Q=async(e,t,s)=>s.parentURL&&(s.conditions.slice(-1)[0]==="node-addons"||s.importAssertions||Y)?e(t,s):e(t),st=async(e,t,s)=>{let{parentURL:o}=t,r=te(o)||o;if(!S.test(r))return Q(s,e,t);let[c]=String(r).match(S),[n,l]=r.split(x),a=n&&n.replace(ee,"");if(r.includes(`esmkModuleId=${e}&isfound=false`)){let I=H(`file:///${e}`,c),M=(a.match(I)||l.match(I)||[])[2];if(M)return{shortCircuit:!0,url:g+M}}if(W.test(e))return{shortCircuit:!0,url:e.replace(W,g+"?")};let m=await Q(s,e,t),p=H(m.url,c),d=p.test(l)&&l.replace(p,"$1")||p.test(a)&&a.replace(p,"$1");if(d?m.url=He.test(d)?d:g+"#-#"+d:a&&a!=="0"&&(m.url.startsWith("node:")||(m.url+="?esmkgdefs="+a)),Xe.test(r)&&!d)throw f.errModuleIdNotMocked(m.url,r.split("?")[0]);return m},se=g+"?esmock-loader=true",E=(e=>async()=>e=e||(await import(se)).default===!0)(),oe=async(e,t,s)=>{if(e===se)return{format:"module",shortCircuit:!0,responseURL:e,source:"export default true"};let o=te(e)||e;if(o&&(o.match(S)||[])[0]){let[n,l]=tt(o);if(l&&l.length){let a=await s(e,t);if(!Qe.test(a.format))return a;let m=a.source===null||a.source===void 0,p=String(m?await Ue.readFile(new URL(e)):a.source),d=(p.match(q)||[])[0]||"",I=d?p.replace(q,""):p,M=a.format==="commonjs"?`const {${l}} = global.esmockCacheGet("${n}");`:`import {${l}} from '${n}';`;return{format:a.format,shortCircuit:!0,responseURL:encodeURI(e),source:d+M+I}}}if(x.test(e))return s(e,t);e=e.replace(Le,""),e.startsWith(g)&&(e=e.replace(qe,""),Je.test(e)&&(e=e.replace(g,`file:///${e.match(Ze)[1]}`)));let c=$.test(e)&&e.replace($,"$1").replace(We,"").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)},ot=Y&&oe;import Rt from"fs";import me from"fs";import ue from"url";import i from"path";import pe from"module";var N=pe.createRequire(import.meta.url),re=me.realpathSync.native,de=new RegExp("^(?:node:)?("+pe.builtinModules.join("|").replace("/","/")+")$"),rt=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,T=/^.\.?(?=\/|\\)/,ne=/\\/g,nt=/index.[tj]sx?$/,ct=/[\\/]resolvewithplus[\\/]/,it=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,P=/^#/,fe=/(\*)/g,ge=/([./])/g,at=/^node:/,lt=/^file:/,ke=[".js",".mjs",".ts",".tsx",".json",".node"],ce="node_modules",R="package.json",ie="node",ae="default",K="import",w=".",he=e=>e&&typeof e=="object",v={},mt=e=>at.test(e)?e:`node:${e}`,ut=e=>e&&ue.pathToFileURL(e).href,pt=e=>de.test(e),dt=e=>lt.test(e)?ue.fileURLToPath(e):e,ft=e=>i.resolve(i.extname(e)?i.dirname(e):e)+i.sep,F=e=>ne.test(e)?e.replace(ne,i.posix.sep):e,k=(e,t)=>{try{t=me.statSync(e)}catch{t=!1}return t&&(t.isFile()||t.isFIFO())},be=e=>e.split(i.sep).reduce((t,s,o)=>(s===ce&&!ct.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,ce)))),t),[[],[]])[1].reverse(),gt=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,R)));return t&&i.join(t,R)},kt=e=>(String(e).match(it)||[]).slice(1),le=(e,t)=>new RegExp(e.replace(ge,"\\$1").replace(fe,".*")).test(t),ht=(e,t,s)=>{let o=new RegExp(e.replace(ge,"\\$1").replace(fe,"(.*)")),r=(s.match(o)||[])[1];return r&&t.replace("*",r)},je=(e,t,s,o=!1)=>(le(e,s)&&(t.includes("*")?le(t,s)?o=s:e.includes("*")&&e!==t&&(o=ht(e,t,s)):o=t),o),ye=(e,t,s,o=e[0])=>e.length?(P.test(s)?P.test(o):T.test(o))&&typeof t[o]=="string"&&je(o,t[o],s)||ye(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&&he(e)&&(typeof e[t]=="string"&&(s=e[t]),!s&&e[ie]&&(s=u(e[ie],t)),!s&&e[ae]&&(s=u(e[ae],t)),!s&&e[t]&&(s=u(e[t],t)),!s&&e[w]&&(s=typeof e[w]=="string"?t===K&&u(e[w],t):u(e[w],t)),s||(s=ye(Object.keys(e),e,t))),s)},Ie=(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:he(o)&&([c]=Object.keys(o).filter(l=>nt.test(l)),n=c in o&&o[c])),r&&(n=u(r,K)),n},b=e=>{var t=null;return k(e)?t=e:ke.some(s=>k(e+s)&&(t=e+s)),t},Me=(e,t)=>{let s=null,o,r=i.join(e,R),c=k(r)&&N(r);return(o=Ie(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"))):ke.some(n=>(n=i.join(e,`index${n}`))&&k(n)&&(s=n)),s},$e=(e,t,s)=>{let o=T.test(e)?i.join(t,e):e;return b(o,s)||Me(o,s)},bt=(e,t,s)=>{let o=s&&s.imports,r=u(o,t);return r&&(T.test(r)?i.join(e,r):we(r,e,{isposixpath:!0}))},jt=(e,t,s,o)=>{let r=u(o&&o.exports,s?"./"+s:K);return r&&i.join(e,t,r)},yt=(e,t,s,o)=>{let r=i.join(e,t,R),c=k(r),n=c&&N(r);return c&&jt(e,t,s,n,o)},It=(e,t,s)=>{let o=gt(t),r=i.dirname(o);return o&&bt(r,e,N(o),s)},Mt=(e,t,s)=>{let[o,r]=kt(e);if(P.test(o))return It(e,t,s);let c=be(t).sort((n,l)=>n.length>l.length);return function n(l,a,m=a-1){return a--?yt(i.join(l[m-a]),o,r,s)||$e(i.join(l[m-a],e),null,s)||n(c,a,m):null}(c,c.length)},$t=(e,t,s)=>{var o=null;return t=typeof t=="string"?ft(dt(decodeURI(t))):process.cwd(),de.test(e)?o=mt(e):(o=rt.test(e)?$e(F(e),t,s):Mt(e,t),o=o&&(s.isposixpath?re(o):ut(F(re(o))))),o},we=(e,t,s)=>{let o=v[e+t];return o||(o=$t(e,t,s||{}),v[e+t]=o)},j=Object.assign(we,{pathToPosix:F,getasnode_module_paths:be,getesmkeyvalmatch:je,getasfilesync:b,getasdirsync:Me,gettargetindex:Ie,iscoremodule:pt,esmparse:u,cache:v});var Re=/(^\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 Se from"node:module";import xe from"node:worker_threads";var A=xe.MessageChannel&&new xe.MessageChannel,Oe=(e=>()=>(typeof e=="boolean"||(e=!!Se.register)&&Se.register("./esmockLoader.js",{parentURL:import.meta.url,data:{port:A.port2},transferList:[A.port2]}),e))(),Ee=Object.assign(e=>{Oe()?A.port1.postMessage(e):typeof global.postMessageEsmk=="function"&&global.postMessageEsmk(e)},{register:Oe});var D={isESM:{},mockDefs:{}},Ce=(e,t)=>(Ee({key:e,keylong:t}),global.mockKeys[String(e)]=t),G=e=>global.mockKeys[String(e)],z=(e,t)=>global.esmockCache.mockDefs[e]=t,wt=e=>global.esmockCache.mockDefs[e],Pe=e=>D.isESM[e],ve=(e,t)=>D.isESM[e]=t;Object.assign(global,{esmockCache:D,esmockCacheGet:wt,esmockTreeIdGet:G,mockKeys:global.mockKeys||{}});var U=e=>typeof e=="object"&&e,B=e=>U(e)&&"default"in e,St=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,xt=((e=0)=>()=>++e)(),Ot=Object.getPrototypeOf({}),Et=e=>Object.getPrototypeOf(e)===Ot,Ct=(e,t)=>Et(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),Pt=(e,t)=>U(e)&&U(t)?Ct(e,t):t,vt=(e,t,s)=>s===null?Object.assign({},e||{},t):(t=Object.assign({},e||{},{default:Pt(B(e)&&e.default,B(t)?t.default:t)},t),!j.iscoremodule(s)&&Object.isExtensible(t.default)&&(t.default.default=t.default),t),Ft=(e,t)=>(t=Pe(e),typeof t=="boolean"||(t=!j.iscoremodule(e)&&St.test(e)&&Re.test(Rt.readFileSync(e,"utf-8")),ve(e,t)),t),Nt=(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})},Tt=e=>{let t=c=>c==="null"||z(c,null),s=G(e.split("esmk=")[1]),[o,r]=s.split("#-#esmkdefs=");String(r).split("#-#").forEach(t),String(o.split("esmkgdefs=")[1]).split("#-#").forEach(t)},Kt=async(e,t,s,o,r)=>{t=vt(r.strict||!o||await import(o),t,o);let c=(o||"file:///"+s)+"?"+["esmkTreeId="+e,"esmkModuleId="+s,"isfound="+!!o,"isesm="+Ft(o),"exportNames="+Object.keys(t).sort().join()].join("&");return z(c,t),c},_=async(e,t,s,o,r,c,n)=>{if(o=o||Object.keys(s),n=o[0],c=c||[],!n)return c;let l=j(n,e);if(!l&&r.isModuleNotFoundError!==!1&&n!=="import")throw f.errModuleIdNotFound(n,e);return c.push(await Kt(t,s[n],n,l,r)),_(e,t,s,o.slice(1),r,c)},At=async(e,t,s,o,r)=>{let c=j(e,t);if(!c)throw f.errModuleIdNotFound(e,t);let n=o?Object.keys(o):[],l=s?Object.keys(s):[];if(r.strict===3&&!n.length&&!l.length)throw f.errModuleIdNoDefs(e,t);let a=typeof r.id=="number"?r.id:xt(),m=`${c}?key=${a}&strict=${r.strict}?`+["esmkgdefs="+(n.length&&(await _(t,a,o,n,r)).join("#-#")||0),"esmkdefs=",l.length&&(await _(t,a,s,l,r)).join("#-#")||0].join("#-#");return Ce(String(a),m),c+`?esmk=${a}`},y=Object.assign(At,{purge:Tt,sanitize:Nt});var Dt=/^.*(\(|at )(.*):[\d]*:[\d]*.*$/,Fe=(e,t)=>(e=typeof e[1]=="string"?e:[e[0],new Error().stack.split(` | ||
`)[3].replace(Dt,"$2"),...e.slice(1)],e[4]={...e[4],...t},e);var h=e=>async(...t)=>{let[s,o,r,c,n]=Fe(t,e);if(!Ne.register&&!await E())throw f.errMissingLoader();let l=await y(s,o,r,c,n),a=await import(l);return n.purge!==!1&&y.purge(l),y.sanitize(a,l)},L=e=>e&&/object|function/.test(typeof e)&&"esmkTreeId"in e&&y.purge(e.esmkTreeId),Gt=Object.assign(h({strict:1}),{purge:L,p:h({strict:1,purge:!1})}),zt=Object.assign(h({strict:3}),{purge:L,p:h({strict:3,purge:!1})}),hs=Object.assign(h(),{purge:L,p:h({purge:!1}),strict:Gt,strictest:zt});var Ut=Ne.register?{}:C,{load:bs,resolve:js,getSource:ys,initialize:Is,globalPreload:Ms}=Ut;export{hs as default,ys as getSource,Ms as globalPreload,Is as initialize,bs as load,js as resolve,Gt as strict,zt as strictest}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23120
6
142
104