3 lines
20 KiB
JavaScript
3 lines
20 KiB
JavaScript
var Xt=Object.defineProperty;var c=(t,r)=>Xt(t,"name",{value:r,configurable:!0});import kt from"node:crypto";import j from"node:module";import{MessageChannel as zt}from"node:worker_threads";import{i as L,b as Vt,e as Y,m as Kt}from"./node-features-JeyyvQz6.mjs";import{l as ut,t as ft,g as Yt,a as Zt,d as A,b as u,e as Z,f as U,h as B,j as tt,k as te,m as P,n as ee,o as q,p as pt,q as ht,w as gt,s as Q,u as yt,v as F,x as re}from"./register-C9AniqUt.mjs";import{pathToFileURL as S,fileURLToPath as R}from"node:url";import{readFileSync as se,existsSync as ne}from"node:fs";import{readFile as oe}from"node:fs/promises";import{p as ae,i as Pt,t as St,a as H,b as vt,c as ie,r as et}from"./index-DQtFPMc2.mjs";import{p as Ut}from"./client-D_mPDF5S.mjs";import v from"node:path";const ce=c(()=>({active:!0,parsedTsconfig:void 0}),"createDefaultData"),wt=c(t=>{const r={active:!0,namespace:t?.namespace,onImport:t?.onImport,parsedTsconfig:void 0,port:t?.port,tsconfig:t?.tsconfig};return t?.tsconfig!==!1&&(r.parsedTsconfig=ut(t?.tsconfig??process.env.TSX_TSCONFIG_PATH)),r},"createData"),me=c(t=>async r=>{if(!r)throw new Error(`tsx must be loaded with --import instead of --loader
|
|
The --loader flag was deprecated in Node v20.6.0 and v18.19.0`);Object.assign(t,wt(r)),r.port&&r.port.on("message",e=>{e==="deactivate"&&(t.active=!1,r.port.postMessage({type:"deactivated"}))})},"createInitialize"),de=c(t=>()=>(t.parsedTsconfig=ut(process.env.TSX_TSCONFIG_PATH),"process.setSourceMapsEnabled(true);"),"createGlobalPreload"),le=c(t=>{const{pathname:r}=new URL(t),e=v.extname(r);if(e===".mts"||e===".mjs")return"module";if(e===".cts"||e===".cjs")return"commonjs";if(e===".js"||ft.includes(e))return Yt(t)},"getFormatFromFileUrl"),ue=c(t=>{const{pathname:r}=new URL(t),e=v.extname(r);if(e===".mts"||e===".mjs")return"module";if(e===".cts"||e===".cjs")return"commonjs";if(e===".js"||ft.includes(e))return Zt(t)},"getFormatFromFileUrlSync"),Rt="tsx-namespace",I=`${Rt}=`,W="tsx-commonjs-export-preparse",fe=`${W}=1`,O="tsx-commonjs-virtual-query",$=new Map,pe=/^data:/i,T=c(t=>pe.test(t),"isDataUrl"),rt=c((t,r)=>t.slice(1).split("&").filter(e=>e&&r.every(s=>!e.startsWith(s))).join("&"),"getQueryWithoutParameters"),x=c((t,r)=>{const e=rt(t,r);return e?`?${e}`:""},"getSearchWithoutParameters"),he=c(t=>t.replaceAll(/\/\*[\s\S]*?\*\/|\/\/[^\n\r]*/g,""),"stripComments"),ge=c(t=>{const r=he(t);if(/^\s*export\s*\*/.test(r))return"named";if(/^\s*import\s*\*\s*as\s+[\w$]+/.test(r))return"namespace";const e=r.match(/\{([^}]*)\}/)?.[1];if(e)return e.split(",").some(s=>{const n=s.trim().split(/\s+as\s+/)[0];return!!(n&&n!=="default")})?"named":void 0},"getCommonJsImportBinding"),ye=c((t,r,e)=>{const s=$.get(t);if(!s)return!1;try{const[n]=ae(s);return n.some(o=>{if(o.d!==-1||o.n!==r)return!1;const a=ge(s.slice(o.ss,o.s));return a==="named"||e&&a==="namespace"})}catch{return!1}},"parentImportsCommonJsExports"),w=c(t=>{const r=t.indexOf("?"),e=t.indexOf("#");if(T(t)){if(e===-1)return;const s=t.slice(e+1),n=s.lastIndexOf("&"),o=s.slice(n+1);return o.startsWith(I)?o.slice(I.length):void 0}if(!(r===-1||e!==-1&&e<r))return new URLSearchParams(t.slice(r,e===-1?void 0:e)).get(Rt)??void 0},"getNamespace"),It=L(Vt)?"importAttributes":"importAssertions",Tt=c(t=>t==="commonjs"||t==="commonjs-typescript","isCommonJsFormat"),Et=c(t=>t==="module-typescript"||t==="typescript","isModuleTypeScriptFormat"),Pe=L(Y),Se=[`${O}=`],G=[`${W}=`,`${O}=`],E=c((t,r)=>r.parsedTsconfig&&te(r.parsedTsconfig,t)?r.parsedTsconfig.config:void 0,"getTsconfigRaw"),ve=c(t=>{if(!t.searchParams.has(O))return;const{pathname:r}=t,e=r.toLowerCase().lastIndexOf("%3f");if(e===-1)return;const s=new URL(t);return s.pathname=r.slice(0,e),s.search="",R(s)},"getFilePathFromVirtualQuery"),st=c(t=>{const r=t.startsWith(P)?new URL(t):void 0,e=r?R(r):t,s=r&&ve(r),n=s||e,o=r&&s?S(n).toString()+x(r.search,Se):t;return{fileUrl:r,filePath:n,loadUrl:o}},"getFileLoadContext"),jt=c((t,r)=>{if(!r?.search)return t;const e=x(r.search,G);return e?S(t).toString()+e:t},"getTransformPath"),Lt=c((t,r,e)=>{const s=[...r?rt(r.search,[I,...G]).split("&").filter(Boolean):[],...e?[`namespace=${encodeURIComponent(e)}`]:[]].join("&");return s?`${t}?${s}`:t},"getFilePathWithQuery"),Ue=new TextDecoder,Ft=c(t=>typeof t=="string"?t:Ue.decode(t),"decodeSource"),we=c((t,r)=>{const e=new URL(r),s=r.startsWith(P)?st(r).filePath:void 0;if(T(r)){if(t.namespace){const o=`${I}${t.namespace}`;e.hash===`#${o}`?e.hash="":e.hash.endsWith(`&${o}`)&&(e.hash=e.hash.slice(0,-o.length-1))}}else e.searchParams.delete("tsx-namespace"),e.searchParams.delete(W),e.searchParams.delete(O);s&&(e.pathname=new URL(S(s)).pathname);const n=e.toString();return t.port&&t.port.postMessage({type:"load",url:n}),t.onImport?.(n),n},"notifyLoad"),Wt=c((t,r)=>{if(!t.active)return!1;const e=w(r);if(t.namespace!==e)return!1;const s=we(t,r);return Ut.send&&Ut.send({type:"dependency",path:s}),!0},"prepareLoad"),Ot=c((t,r)=>{if(!ee.test(t))return r;const e=r[It];return e?.type?r:{...r,[It]:{...e,type:"json"}}},"prepareJsonAttributes"),nt=c(({conditions:t})=>t?.includes("require")===!0&&!t.includes("import"),"isCommonJsRequireContext$1"),Re=c(t=>{const r=c(async(e,s,n)=>{if(!Wt(t,e))return n(e,s);const o=w(e),{fileUrl:a,filePath:i,loadUrl:l}=st(e),f=Ot(l,s),m=await n(l,f);u(3,"loaded by next loader",{url:e,loadUrl:l,loaded:m});const d=a?.searchParams.has(W)===!0,p=m.format,h=a?new URL(S(i)):void 0;if(h&&a&&(h.search=x(a.search,G)),Tt(p)&&a&&m.responseURL?.startsWith("file:")&&!i.endsWith(".cjs")){const g=await oe(S(i),"utf8"),M=Pt(g);if(p==="commonjs-typescript"||!i.endsWith(".js")||M){if(!Pe){if(d&&M&&Z.test(i)){const _=await St(g,i,{define:{"import.meta.url":JSON.stringify(h.toString())},tsconfigRaw:E(i,t)});return $.set(e,_.code),{format:"module",source:U(_)}}return m}if(!o&&!d&&!i.endsWith(".cts"))return m;const dt=!!(o||d||x(a.search,G)),lt=H(g,jt(i,a),{cjsBanner:dt?`require = require("node:module").createRequire(${JSON.stringify(S(i).toString())});`:void 0,tsconfigRaw:E(i,t)});if(m.format="commonjs",m.source=U(lt),dt){const _=Lt(i,a,o);m.responseURL=`data:text/javascript,${encodeURIComponent(lt.code)}?filePath=${encodeURIComponent(_)}`}return u(3,"returning CJS export annotation",m),m}}if(!m.source)return m;const y=Ft(m.source),N=p==="json"&&!nt(s);if(p==="commonjs-typescript"){const g=H(y,i,{tsconfigRaw:E(i,t)});return{...m,format:"commonjs",source:U(g)}}if(N||Et(p)||B.test(e)){const g=await St(y,i,{tsconfigRaw:E(i,t)});return $.set(e,g.code),{format:"module",source:U(g)}}if(m.format==="module"){const g=vt(i,y);g?(m.source=U(g),$.set(e,g.code)):$.set(e,y)}return m},"load");return A?async(e,s,n)=>{u(2,"load",{url:e,context:s});const o=await r(e,s,n);return u(1,"loaded",{url:e,result:o}),o}:r},"createLoad"),Ie=c(t=>{const r=c((e,s,n)=>{if(nt(s)&&tt()||!Wt(t,e))return n(e,s);const o=w(e),{fileUrl:a,filePath:i,loadUrl:l}=st(e),f=Ot(l,s),m=n(l,f);u(3,"loaded by next loader",{url:e,loadUrl:l,loaded:m});const d=m.format;if(Tt(d)&&L(Y)&&m.responseURL?.startsWith("file:")&&!i.endsWith(".cjs")){const y=se(S(i),"utf8");if(d==="commonjs-typescript"||!i.endsWith(".js")||Pt(y)){const N=H(y,jt(i,a),{tsconfigRaw:E(i,t)}),g=!o&&tt(),M=Lt(i,a,o);return m.format="commonjs",m.shouldBeReloadedByCJSLoader=g,m.source=U(N),g||(m.responseURL=`data:text/javascript,${encodeURIComponent(N.code)}?filePath=${encodeURIComponent(M)}`),u(3,"returning CJS export annotation",m),m}}if(!m.source)return m;const p=Ft(m.source),h=d==="json"&&!nt(s);if(d==="commonjs-typescript"){const y=H(p,i,{tsconfigRaw:E(i,t)});return{...m,format:"commonjs",shouldBeReloadedByCJSLoader:!1,source:U(y)}}if(h||Et(d)||B.test(e)){const y=ie(p,i,{tsconfigRaw:E(i,t)});return{format:"module",source:U(y)}}if(m.format==="module"){const y=vt(i,p);y&&(m.source=U(y))}return m},"load");return A?(e,s,n)=>{u(2,"loadSync",{url:e,context:s});const o=r(e,s,n);return u(1,"loadedSync",{url:e,result:o}),o}:r},"createLoadSync"),Te=c(t=>{if(q(t)||t.startsWith("#")||t.includes(":"))return!1;const r=t.split("/"),e=r[0]?.startsWith("@")?2:1;return r.length>e&&r.slice(0,e).every(Boolean)},"isBarePackageSubpath"),Ee=c(t=>{const r=t.lastIndexOf(pt);if(r===-1)return;const s=t.slice(r+pt.length).split(v.sep),n=s[0]?.startsWith("@")?2:1;if(!(s.length<=n||!s[n-1]))return v.join(t.slice(0,r),"node_modules",...s.slice(0,n))},"getPackageDirectory"),$t=c((t,r)=>{if(!Te(t)||!r.startsWith(P))return;const e=R(r),s=Ee(e);if(!s)return;const o=et(v.join(s,"package.json"))?.exports;if(o!=null)return{kind:"root-exports"};const a=et(v.join(e,"package.json"));return typeof a?.main!="string"||!a.main?{kind:"legacy-directory"}:{kind:"legacy-directory",mainUrl:S(v.resolve(e,a.main)).toString()}},"getPackageSubpathDirectoryInfo"),je=L(Y),bt=/^(?:[a-z][\d+.a-z-]*:\/\/|data:|file:|node:)/i,Ct=c(t=>!q(t)&&!bt.test(t),"isTsconfigPathAliasSpecifier"),D=c(t=>{if(t.url)return t.url;const r=t.message.match(/^Cannot find module '([^']+)'/);if(r){const[,s]=r;return s}const e=t.message.match(/^Cannot find package '([^']+)'/);if(e){const[,s]=e;if(!v.isAbsolute(s))return;const n=S(s);if(n.pathname.endsWith("/")&&(n.pathname+="package.json"),n.pathname.endsWith("/package.json")){const o=et(n);if(o?.main)return new URL(o.main,n).toString()}else return n.toString()}},"getMissingPathFromNotFound"),b=c(t=>t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND","isModuleNotFound"),X=c(t=>t instanceof Error&&(b(t.code)||t.code==="ERR_UNSUPPORTED_DIR_IMPORT"),"isDirectoryEntryMiss"),k=c(t=>t.conditions.includes("require")&&!t.conditions.includes("import"),"isCommonJsRequireContext"),ot=c(t=>{const r=t.indexOf("?"),e=t.indexOf("#");return r===-1?e:e===-1?r:Math.min(r,e)},"getUrlMetadataIndex"),Jt=c((t,r)=>r||!q(t)&&!bt.test(t)?t.indexOf("?"):ot(t),"getSpecifierMetadataIndex"),Nt=c(t=>{if(t?.startsWith(P))return R(new URL(t))},"getParentFilePath"),Le=c(t=>{if(!t)return!1;const r=Nt(t);if(r)return B.test(r);const e=ot(t);return B.test(e===-1?t:t.slice(0,e))},"isTypeScriptParent"),C=c(t=>{const r=Nt(t);return r!==void 0&&ht(r)},"isParentDependency"),Mt=c(t=>v.extname(new URL(t).pathname)===".js"&&ht(R(t)),"isImplicitJavaScriptDependency"),_t=c((t,r)=>Le(t)||r&&!C(t),"resolvesTsExtensions"),Fe=c((t,r)=>{const e=ot(t),s=e===-1?t:t.slice(0,e);try{if(s.startsWith(P))return R(s);if(v.isAbsolute(s))return s;if(F(s)&&r?.startsWith(P))return R(new URL(s,r))}catch{}},"getProbeFilePath"),At=c((t,r)=>{const e=Fe(t,r);return e!==void 0&&!ne(e)},"candidateDoesntExist"),z=c(async(t,r,e,s)=>{const n=yt(t);if(u(3,"resolveExtensions",{url:t,context:r,throwError:s,tryPaths:n}),!n)return;let o;for(const a of n)if(!At(a,r.parentURL))try{return await e(a,r)}catch(i){const{code:l}=i;if(!b(l)&&l!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw i;o=i}if(s){if(o===void 0)return e(n[0],r);throw o}},"resolveExtensions"),J=c((t,r,e,s)=>{const n=yt(t);if(u(3,"resolveExtensionsSync",{url:t,context:r,throwError:s,tryPaths:n}),!n)return;let o;for(const a of n)if(!At(a,r.parentURL))try{return e(a,r)}catch(i){const{code:l}=i;if(!b(l)&&l!=="ERR_PACKAGE_PATH_NOT_EXPORTED")throw i;o=i}if(s){if(o===void 0)return e(n[0],r);throw o}},"resolveExtensionsSync"),We=c(async(t,r,e,s)=>{const n=s.parsedTsconfig?.config.compilerOptions?.allowJs??!1,o=_t(r.parentURL,n);if(u(3,"resolveBase",{specifier:t,context:r,specifierStartsWithFileUrl:t.startsWith(P),isRelativePath:F(t),resolveTsExtensions:o,allowJs:n}),(t.startsWith(P)||F(t))&&o){const a=await z(t,r,e,void 0);if(u(3,"resolveBase resolved",{specifier:t,context:r,resolved:a}),a)return a}try{return await e(t,r)}catch(a){if(u(3,"resolveBase error",{specifier:t,context:r,error:a}),a instanceof Error){const i=a;if(b(i.code)){const l=D(i);if(l){const f=await z(l,r,e,void 0);if(f)return f}}}throw a}},"resolveBase"),at=c((t,r,e,s)=>{const n=s.parsedTsconfig?.config.compilerOptions?.allowJs??!1,o=_t(r.parentURL,n);if(u(3,"resolveBaseSync",{specifier:t,context:r,specifierStartsWithFileUrl:t.startsWith(P),isRelativePath:F(t),resolveTsExtensions:o,allowJs:n}),(t.startsWith(P)||F(t))&&o){const a=J(t,r,e,void 0);if(u(3,"resolveBaseSync resolved",{specifier:t,context:r,resolved:a}),a)return a}try{return e(t,r)}catch(a){if(u(3,"resolveBaseSync error",{specifier:t,context:r,error:a}),a instanceof Error){const i=a;if(b(i.code)){const l=D(i);if(l){const f=J(l,r,e,void 0);if(f)return f}}}throw a}},"resolveBaseSync"),it=c(async(t,r,e,s)=>{if(u(3,"resolveDirectory",{specifier:t,context:r,isDirectory:Q.test(t)}),(t==="."||t===".."||t.endsWith("/.."))&&(t+="/"),Q.test(t)){const n=new URL(t,r.parentURL);return n.pathname=v.join(n.pathname,"index"),await z(n.toString(),r,e,!0)}try{return await We(t,r,e,s)}catch(n){if(n instanceof Error){u(3,"resolveDirectory error",{specifier:t,context:r,error:n});const o=n;if(o.code==="ERR_UNSUPPORTED_DIR_IMPORT"){const a=D(o);if(a){if(t.startsWith("#"))throw n;const i=$t(t,a);if(i?.kind==="root-exports")throw n;if(i?.mainUrl){try{return await e(i.mainUrl,r)}catch(m){if(!X(m))throw m}try{return await it(i.mainUrl,r,e,s)}catch(m){if(!X(m))throw m}}const l=`${a}/index`,f=await z(l,r,e);if(f)return f}}}throw n}},"resolveDirectory"),ct=c((t,r,e,s)=>{if(u(3,"resolveDirectorySync",{specifier:t,context:r,isDirectory:Q.test(t)}),(t==="."||t===".."||t.endsWith("/.."))&&(t+="/"),Q.test(t)){const n=k(r);if(n&&!q(t))return at(t,r,e,s);const o=new URL(t,r.parentURL);return o.pathname=v.join(o.pathname,"index"),n?J(R(o),r,e,!1)??at(t,r,e,s):J(o.toString(),r,e,!0)}try{return at(t,r,e,s)}catch(n){if(n instanceof Error){u(3,"resolveDirectorySync error",{specifier:t,context:r,error:n});const o=n;if(o.code==="ERR_UNSUPPORTED_DIR_IMPORT"){const a=D(o);if(a){if(t.startsWith("#"))throw n;const i=$t(t,a);if(i?.kind==="root-exports")throw n;if(i?.mainUrl){try{return e(i.mainUrl,r)}catch(m){if(!X(m))throw m}try{return ct(i.mainUrl,r,e,s)}catch(m){if(!X(m))throw m}}const l=`${a}/index`,f=J(l,r,e);if(f)return f}}}throw n}},"resolveDirectorySync"),Oe=c(async(t,r,e,s)=>{const n=Ct(t);if(u(3,"resolveTsPaths",{specifier:t,context:r,tsconfigPathAliasSpecifier:n,tsconfig:s.parsedTsconfig,fromNodeModules:C(r.parentURL)}),n&&s.parsedTsconfig&&!C(r.parentURL)){const o=gt(s.parsedTsconfig,t);u(3,"resolveTsPaths",{possiblePaths:o});for(const a of o)try{return await it(S(a).toString(),r,e,s)}catch{}}return it(t,r,e,s)},"resolveTsPaths"),$e=c((t,r,e,s)=>{const n=Ct(t);if(u(3,"resolveTsPathsSync",{specifier:t,context:r,tsconfigPathAliasSpecifier:n,tsconfig:s.parsedTsconfig,fromNodeModules:C(r.parentURL)}),n&&s.parsedTsconfig&&!C(r.parentURL)){const o=gt(s.parsedTsconfig,t);u(3,"resolveTsPathsSync",{possiblePaths:o});for(const a of o)try{return ct(S(a).toString(),r,e,s)}catch{}}return ct(t,r,e,s)},"resolveTsPathsSync"),V="tsx://",mt=c((t,r)=>{const e=t.indexOf("#"),s=e===-1?t:t.slice(0,e),n=e===-1?"":t.slice(e);return`${s}${s.includes("?")?"&":"?"}${r}${n}`},"addQuery"),K=c((t,r)=>T(t)?`${t}${t.includes("#")?"&":"#"}${I}${r}`:mt(t,`${I}${r}`),"addNamespace"),Bt=c((t,r)=>{const e=r.indexOf("#"),s=r[0]==="?"?r.slice(1,e===-1?void 0:e):"",n=e===-1?"":r.slice(e),o=t.indexOf("#"),a=o===-1?t:t.slice(0,o),i=o===-1?"":t.slice(o),l=s?mt(a,s):a;return new URL(`${l}${n||i}`).toString()},"mergeUrlMetadata"),qt=c((t,r,e)=>{if(r!=="commonjs"||!t.startsWith(P)||!Z.test(t))return t;const s=new URL(t),n=[rt(s.search,[I]),...e?[`namespace=${encodeURIComponent(e)}`]:[]].filter(Boolean).join("&");return n?(s.pathname+=`%3F${n}`,s.searchParams.set(O,"1"),s.toString()):t},"preserveCommonJsQueryIdentity"),be=c(t=>{const r=c(async(e,s,n)=>{if(!t.active||e.startsWith("node:"))return n(e,s);const o=s.parentURL&&w(s.parentURL);let a=T(e)?o:w(e)??o;if(t.namespace){let h;if(e.startsWith(V)){try{h=JSON.parse(e.slice(V.length))}catch{}h?.namespace&&(a=h.namespace)}if(t.namespace!==a)return n(e,s);h&&(e=h.specifier,s.parentURL=h.parentURL)}if(T(e)){const h=await n(e,s);return t.namespace?{...h,url:K(h.url,t.namespace)}:h}const i=Jt(e,k(s)),l=i===-1?e:e.slice(0,i),f=i===-1?"":e.slice(i),m=await Oe(l,s,n,t);if(u(2,"nextResolve",{resolved:m}),m.format==="builtin")return m;const d={...m};d.url.startsWith(P)&&(d.format==="module-typescript"?d.format="module":d.format==="commonjs-typescript"?d.format="commonjs":!d.format&&!Mt(d.url)&&(d.format=await le(d.url),u(2,"getFormatFromFileUrl",{resolved:d,format:d.format}))),f&&(d.url=Bt(d.url,f));const p=s.parentURL&&d.format==="commonjs"&&Z.test(d.url)&&(new URL(s.parentURL).searchParams.has(W)||ye(s.parentURL,e,je));return a&&w(d.url)===void 0&&(d.url=K(d.url,a)),p&&(d.url=mt(d.url,fe)),(a||p)&&(d.url=qt(d.url,d.format,a)),d},"resolve");return A?async(e,s,n)=>{u(2,"resolve",{specifier:e,context:s});const o=await r(e,s,n);return u(1,"resolved",{specifier:e,context:s,result:o}),o}:r},"createResolve"),Ce=c(t=>{const r=c((e,s,n)=>{if(!t.active||e.startsWith("node:")||k(s)&&tt())return n(e,s);const o=s.parentURL&&w(s.parentURL);let a=T(e)?o:w(e)??o;if(t.namespace){let p;if(e.startsWith(V)){try{p=JSON.parse(e.slice(V.length))}catch{}p?.namespace&&(a=p.namespace)}if(t.namespace!==a)return n(e,s);p&&(e=p.specifier,s.parentURL=p.parentURL)}if(T(e)){const p=n(e,s);return t.namespace?{...p,url:K(p.url,t.namespace)}:p}const i=Jt(e,k(s)),l=i===-1?e:e.slice(0,i),f=i===-1?"":e.slice(i),m=$e(l,s,n,t);if(u(2,"nextResolve",{resolved:m}),m.format==="builtin")return m;const d={...m};return d.url.startsWith(P)&&(d.format==="module-typescript"?d.format="module":d.format==="commonjs-typescript"?d.format="commonjs":!d.format&&!Mt(d.url)&&(d.format=ue(d.url),u(2,"getFormatFromFileUrlSync",{resolved:d,format:d.format}))),f&&(d.url=Bt(d.url,f)),a&&w(d.url)===void 0&&(d.url=K(d.url,a)),d.url=qt(d.url,d.format,a),d},"resolve");return A?(e,s,n)=>{u(2,"resolveSync",{specifier:e,context:s});const o=r(e,s,n);return u(1,"resolvedSync",{specifier:e,context:s,result:o}),o}:r},"createResolveSync"),Qt=c(t=>(r,e)=>{if(!e)throw new Error("The current file path (import.meta.url) must be provided in the second argument of tsImport()");const s=e.startsWith(P)?e:S(e).toString();return import(`tsx://${JSON.stringify({specifier:r,parentURL:s,namespace:t})}`)},"createScopedImport");let Ht=!1;const Je=c(t=>{const r=[];for(let e=0;e<t.length;e+=1){const s=t[e];if(s==="--import"){const n=t[e+1];n&&r.push(n),e+=1}else s.startsWith("--import=")&&r.push(s.slice(9))}return r},"collectImportSpecifiers"),Ne=c(()=>[...(process.env.NODE_OPTIONS??"").matchAll(/(?:^|\s)--import(?:=|\s+)(\S+)/g)].map(([,t])=>t),"collectNodeOptionsImportSpecifiers"),xt=[new URL("loader.mjs",import.meta.url).toString(),new URL("esm/index.mjs",import.meta.url).toString()],Me=new Set(["tsx","tsx/esm",...xt,...xt.map(t=>decodeURI(new URL(t).pathname))]),_e=c(t=>Me.has(t),"isTsxImport"),Gt=c(t=>/\.(?:[cm]?ts|tsx)(?:[?#].*)?$/.test(t),"isTypeScriptImport"),Ae=c(()=>{const t=Je(process.execArgv),r=t.findIndex(_e);return r>0&&t.slice(0,r).some(Gt)},"hasCliTypeScriptPreload"),Be=Ne().some(Gt)||Ae(),Dt=typeof j.registerHooks=="function"&&L(Kt)&&!Be,qe=c(t=>{if(!j.register&&!Dt)throw new Error(`This version of Node.js (${process.version}) does not support module.register(). Please upgrade to Node v18.19 or v20.6 and above.`);if(!Ht){const{_resolveFilename:i}=j;j._resolveFilename=(l,...f)=>i(re(l),...f),Ht=!0}const{sourceMapsEnabled:r}=process;if(process.setSourceMapsEnabled(!0),Dt){const i=wt({namespace:t?.namespace,onImport:t?.onImport,tsconfig:t?.tsconfig}),l=j.registerHooks({load:Ie(i),resolve:Ce(i)}),f=c(async()=>{i.active=!1,l.deregister(),r===!1&&process.setSourceMapsEnabled(!1)},"unregister2");return t?.namespace&&(f.import=Qt(t.namespace),f.unregister=f),f}const{port1:e,port2:s}=new zt;j.register(`./esm/index.mjs?${kt.randomUUID()}`,{parentURL:import.meta.url,data:{port:s,namespace:t?.namespace,tsconfig:t?.tsconfig},transferList:[s]});const n=t?.onImport,o=n&&(i=>{i.type==="load"&&n(i.url)});o&&(e.on("message",o),e.unref());const a=c(()=>(r===!1&&process.setSourceMapsEnabled(!1),o&&e.off("message",o),e.postMessage("deactivate"),new Promise(i=>{const l=c(f=>{f.type==="deactivated"&&(i(),e.off("message",l))},"onDeactivated");e.on("message",l)})),"unregister");return t?.namespace&&(a.import=Qt(t.namespace),a.unregister=a),a},"register");export{de as a,Re as b,me as c,be as d,ce as e,qe as r};
|