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