@remotex-labs/xbuild 3.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bash.js +18 -18
- package/dist/bash.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -279,8 +279,8 @@ declare class TypescriptService {
|
|
|
279
279
|
* This path always passes a directory on, so `declarationDir` is never consulted.
|
|
280
280
|
* Name it explicitly to write somewhere other than `outDir`.
|
|
281
281
|
* The keys name the entries alone, while the files reached through them keep the layout of the source tree.
|
|
282
|
-
*
|
|
283
|
-
* and a
|
|
282
|
+
* Declarations come out of this project's program, so the checker writes the types the source leaves out,
|
|
283
|
+
* and a type it cannot write surfaces through {@link check} rather than as a failure to write.
|
|
284
284
|
*
|
|
285
285
|
* @example
|
|
286
286
|
* ```ts
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var W=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=(o,e,t)=>e in o?W(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var y=(o,e,t,r)=>{for(var i=r>1?void 0:r?ee(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&W(e,t,i),i};var k=(o,e,t)=>te(o,typeof e!="symbol"?e+"":e,t);import*as Q from"http";import*as X from"https";import{extname as U}from"path";import{readFileSync as K}from"fs";var V=`<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Dark File Browser \u2014 FTP-like</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" integrity="sha512-2SwdPD6INVrV/lHTZbO2nodKhrnDdJK9/kg2XD1r9uGqPo1cUbujc+IYdlYdEErWNu69gVcYgdxlmVmzTWnetw==" crossorigin="anonymous" referrerpolicy="no-referrer" /><style>:root{--bg:#0b0f14;--panel:#0f1720;--muted:#9aa4b2;--accent:#E5C07B;--glass:rgba(255,255,255,0.03);--card:#0c1116;--radius:12px;--gap:12px;--shadow:0 6px 18px rgba(0,0,0,0.4);--file-icon-size:40px;font-family:Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial}*{box-sizing:border-box;font-style:normal !important}html,body{height:100%;margin:0;font-size:14px;color:#dce7ef;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:radial-gradient(1200px 600px at 10% 10%,rgba(110,231,183,0.04),transparent 8%),linear-gradient(180deg,rgba(255,255,255,0.01),transparent 20%),var(--bg);padding:28px;display:flex;gap:20px;align-items:flex-start;justify-content:center}.app{width:1100px;max-width:98vw;display:flex;gap:18px;padding:18px;border-radius:16px;box-shadow:var(--shadow);border:1px solid rgba(255,255,255,0.03);background:linear-gradient(180deg,rgba(255,255,255,0.02),rgba(255,255,255,0));overflow:hidden}.sidebar{width:260px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border-radius:var(--radius);padding:14px}.brand{display:flex;gap:12px;align-items:center;margin-bottom:10px}.logo{width:46px;height:46px;border-radius:10px;background:linear-gradient(135deg,#b65b9f 0%,#804b8f 100%);display:flex;align-items:center;justify-content:center;font-weight:700}.brand h1{font-size:16px;margin:0}.muted{color:var(--muted);font-size:13px}.search{margin:12px 0}.search input{width:100%;padding:10px 12px;border-radius:10px;border:1px solid rgba(255,255,255,0.03);background:var(--glass);color:inherit}.quick-list{margin-top:12px}.quick-list a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;background:transparent;color:var(--muted);text-decoration:none;cursor:pointer;transition:color 0.15s ease}.quick-list a:hover{color:var(--accent)}.main{flex:1;display:flex;flex-direction:column}.topbar{display:flex;align-items:center;gap:12px;padding-bottom:12px}.breadcrumbs{list-style:none;display:flex;gap:8px;align-items:center;background:var(--glass);padding:8px 12px;border-radius:var(--radius);margin:0}.breadcrumbs li{display:flex;align-items:center}.breadcrumbs li:not(:last-child)::after{content:'>';margin-left:8px;color:var(--muted)}.breadcrumbs a{color:var(--muted);text-decoration:none;transition:color 0.15s ease}.breadcrumbs a:hover{color:var(--accent)}.list{margin-top:14px;display:grid;grid-template-columns:1fr;gap:10px}.list a{display:flex;text-decoration:none;color:inherit}.folder-row,.file-row{display:flex;gap:12px;align-items:center;padding:10px;border-radius:10px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border:1px solid rgba(255,255,255,0.02);transition:color 0.25s ease}.icon{width:var(--file-icon-size);height:var(--file-icon-size);border-radius:10px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.02);flex-shrink:0;transition:background 0.25s ease,color 0.25s ease}.folder-row:hover,.file-row:hover{color:var(--accent)}.folder-row:hover .icon{background:rgba(152,195,121,0.2)}.file-row:hover .icon{background:rgba(224,108,117,0.2)}.folder-row:hover .icon i{color:#98C379}.file-row:hover .icon i{color:#e09c6c}.meta{display:flex;flex-direction:column}.name{font-weight:600}.sub{color:var(--muted);font-size:13px}.empty{padding:40px;text-align:center;color:var(--muted)}@media (max-width:880px){.app{flex-direction:column;padding:12px}.sidebar,.main{width:100%}}</style></head><body><div class="app"><aside class="sidebar"><div class="brand"><div class="logo">F</div><div><h1>xBuildFTP</h1><div class="muted">Browse & serve files</div></div></div><div class="search"><input placeholder="Search files & folders..."/></div><div class="quick-list"><a href="/">\u{1F3E0} Home</a><a href="\${ up }">\u2B06\uFE0F Up</a></div></aside><main class="main"><div class="topbar"><div class="topbar"><ul class="breadcrumbs"> \${ paths } </ul></div></div> \${ fileList } </main></div></body><script> const searchInput = document.querySelector('.search input'); const listItems = document.querySelectorAll('.list > .folder-row, .list > .file-row'); const emptyMessage = document.querySelector('.empty'); searchInput.addEventListener('input', () => { const query = searchInput.value.toLowerCase(); let anyVisible = false; listItems.forEach(item => { const name = item.querySelector('.name').textContent.toLowerCase(); if (name.includes(query)) { item.style.display = 'flex'; anyVisible = true; } else { item.style.display = 'none'; } }); emptyMessage.style.display = anyVisible ? 'none' : 'block'; }); </script></html>`;import{join as C}from"@remotex-labs/xmap";import{inject as ue}from"@remotex-labs/xinject";import{Subject as he}from"@remotex-labs/xobservable";import{readdir as me,stat as ge,readFile as ve}from"fs/promises";import{cwd as ae}from"process";import{readFileSync as ce}from"fs";import{readFileSync as ie,statSync as se}from"fs";import{resolve as ne}from"@remotex-labs/xmap";import{Injectable as oe}from"@remotex-labs/xinject";var v=class{resolved=new Map;cache=new Map;clear(){this.cache.clear(),this.resolved.clear()}getSnapshot(e){return this.cache.get(this.resolve(e))}touch(e,t){let r=this.resolve(e);return this.cache.get(r)??this.sync(r,this.stat(r),t)}refresh(e,t,r){let i=this.resolve(e);return this.sync(i,t??this.stat(i),r)}refreshAll(e){let t=e??this.cache.keys();for(let r of t)this.refresh(r)}resolve(e){let t=this.resolved.get(e);return t===void 0&&this.resolved.set(e,t=ne(e)),t}sync(e,t,r="utf-8"){let i=this.cache.get(e);return t?.isFile()?i?.mtimeMs===t.mtimeMs?i:this.store(e,{mtimeMs:t.mtimeMs,version:(i?.version??0)+1,snapshot:this.snapshot(ie(e,r))}):i&&!i.snapshot?i:this.store(e,{mtimeMs:0,snapshot:void 0,version:(i?.version??0)+1})}changeRange(e,t){let r=e.length,i=t.length,s=Math.min(r,i),n=0;for(;n<s&&e.charCodeAt(n)===t.charCodeAt(n);)n++;let a=0;for(;a<s-n&&e.charCodeAt(r-1-a)===t.charCodeAt(i-1-a);)a++;return{span:{start:n,length:r-n-a},newLength:i-n-a}}snapshot(e){return{text:e,getText:(t,r)=>e.slice(t,r),getLength:()=>e.length,getChangeRange:t=>this.changeRange(t.getText(0,t.getLength()),e)}}store(e,t){return this.cache.set(e,t),t}stat(e){return se(e,{throwIfNoEntry:!1})}};v=y([oe({scope:"singleton"})],v);import{inject as le,Injectable as pe}from"@remotex-labs/xinject";import{normalize as
|
|
1
|
+
var W=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=(o,e,t)=>e in o?W(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var y=(o,e,t,r)=>{for(var i=r>1?void 0:r?ee(e,t):e,s=o.length-1,n;s>=0;s--)(n=o[s])&&(i=(r?n(e,t,i):n(i))||i);return r&&i&&W(e,t,i),i};var k=(o,e,t)=>te(o,typeof e!="symbol"?e+"":e,t);import*as Q from"http";import*as X from"https";import{extname as U}from"path";import{readFileSync as K}from"fs";var V=`<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>Dark File Browser \u2014 FTP-like</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" integrity="sha512-2SwdPD6INVrV/lHTZbO2nodKhrnDdJK9/kg2XD1r9uGqPo1cUbujc+IYdlYdEErWNu69gVcYgdxlmVmzTWnetw==" crossorigin="anonymous" referrerpolicy="no-referrer" /><style>:root{--bg:#0b0f14;--panel:#0f1720;--muted:#9aa4b2;--accent:#E5C07B;--glass:rgba(255,255,255,0.03);--card:#0c1116;--radius:12px;--gap:12px;--shadow:0 6px 18px rgba(0,0,0,0.4);--file-icon-size:40px;font-family:Inter,ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,'Helvetica Neue',Arial}*{box-sizing:border-box;font-style:normal !important}html,body{height:100%;margin:0;font-size:14px;color:#dce7ef;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background:radial-gradient(1200px 600px at 10% 10%,rgba(110,231,183,0.04),transparent 8%),linear-gradient(180deg,rgba(255,255,255,0.01),transparent 20%),var(--bg);padding:28px;display:flex;gap:20px;align-items:flex-start;justify-content:center}.app{width:1100px;max-width:98vw;display:flex;gap:18px;padding:18px;border-radius:16px;box-shadow:var(--shadow);border:1px solid rgba(255,255,255,0.03);background:linear-gradient(180deg,rgba(255,255,255,0.02),rgba(255,255,255,0));overflow:hidden}.sidebar{width:260px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border-radius:var(--radius);padding:14px}.brand{display:flex;gap:12px;align-items:center;margin-bottom:10px}.logo{width:46px;height:46px;border-radius:10px;background:linear-gradient(135deg,#b65b9f 0%,#804b8f 100%);display:flex;align-items:center;justify-content:center;font-weight:700}.brand h1{font-size:16px;margin:0}.muted{color:var(--muted);font-size:13px}.search{margin:12px 0}.search input{width:100%;padding:10px 12px;border-radius:10px;border:1px solid rgba(255,255,255,0.03);background:var(--glass);color:inherit}.quick-list{margin-top:12px}.quick-list a{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:8px;background:transparent;color:var(--muted);text-decoration:none;cursor:pointer;transition:color 0.15s ease}.quick-list a:hover{color:var(--accent)}.main{flex:1;display:flex;flex-direction:column}.topbar{display:flex;align-items:center;gap:12px;padding-bottom:12px}.breadcrumbs{list-style:none;display:flex;gap:8px;align-items:center;background:var(--glass);padding:8px 12px;border-radius:var(--radius);margin:0}.breadcrumbs li{display:flex;align-items:center}.breadcrumbs li:not(:last-child)::after{content:'>';margin-left:8px;color:var(--muted)}.breadcrumbs a{color:var(--muted);text-decoration:none;transition:color 0.15s ease}.breadcrumbs a:hover{color:var(--accent)}.list{margin-top:14px;display:grid;grid-template-columns:1fr;gap:10px}.list a{display:flex;text-decoration:none;color:inherit}.folder-row,.file-row{display:flex;gap:12px;align-items:center;padding:10px;border-radius:10px;background:linear-gradient(180deg,rgba(255,255,255,0.01),transparent);border:1px solid rgba(255,255,255,0.02);transition:color 0.25s ease}.icon{width:var(--file-icon-size);height:var(--file-icon-size);border-radius:10px;display:flex;align-items:center;justify-content:center;background:rgba(255,255,255,0.02);flex-shrink:0;transition:background 0.25s ease,color 0.25s ease}.folder-row:hover,.file-row:hover{color:var(--accent)}.folder-row:hover .icon{background:rgba(152,195,121,0.2)}.file-row:hover .icon{background:rgba(224,108,117,0.2)}.folder-row:hover .icon i{color:#98C379}.file-row:hover .icon i{color:#e09c6c}.meta{display:flex;flex-direction:column}.name{font-weight:600}.sub{color:var(--muted);font-size:13px}.empty{padding:40px;text-align:center;color:var(--muted)}@media (max-width:880px){.app{flex-direction:column;padding:12px}.sidebar,.main{width:100%}}</style></head><body><div class="app"><aside class="sidebar"><div class="brand"><div class="logo">F</div><div><h1>xBuildFTP</h1><div class="muted">Browse & serve files</div></div></div><div class="search"><input placeholder="Search files & folders..."/></div><div class="quick-list"><a href="/">\u{1F3E0} Home</a><a href="\${ up }">\u2B06\uFE0F Up</a></div></aside><main class="main"><div class="topbar"><div class="topbar"><ul class="breadcrumbs"> \${ paths } </ul></div></div> \${ fileList } </main></div></body><script> const searchInput = document.querySelector('.search input'); const listItems = document.querySelectorAll('.list > .folder-row, .list > .file-row'); const emptyMessage = document.querySelector('.empty'); searchInput.addEventListener('input', () => { const query = searchInput.value.toLowerCase(); let anyVisible = false; listItems.forEach(item => { const name = item.querySelector('.name').textContent.toLowerCase(); if (name.includes(query)) { item.style.display = 'flex'; anyVisible = true; } else { item.style.display = 'none'; } }); emptyMessage.style.display = anyVisible ? 'none' : 'block'; }); </script></html>`;import{join as C}from"@remotex-labs/xmap";import{inject as ue}from"@remotex-labs/xinject";import{Subject as he}from"@remotex-labs/xobservable";import{readdir as me,stat as ge,readFile as ve}from"fs/promises";import{cwd as ae}from"process";import{readFileSync as ce}from"fs";import{readFileSync as ie,statSync as se}from"fs";import{resolve as ne}from"@remotex-labs/xmap";import{Injectable as oe}from"@remotex-labs/xinject";var v=class{resolved=new Map;cache=new Map;clear(){this.cache.clear(),this.resolved.clear()}getSnapshot(e){return this.cache.get(this.resolve(e))}touch(e,t){let r=this.resolve(e);return this.cache.get(r)??this.sync(r,this.stat(r),t)}refresh(e,t,r){let i=this.resolve(e);return this.sync(i,t??this.stat(i),r)}refreshAll(e){let t=e??this.cache.keys();for(let r of t)this.refresh(r)}resolve(e){let t=this.resolved.get(e);return t===void 0&&this.resolved.set(e,t=ne(e)),t}sync(e,t,r="utf-8"){let i=this.cache.get(e);return t?.isFile()?i?.mtimeMs===t.mtimeMs?i:this.store(e,{mtimeMs:t.mtimeMs,version:(i?.version??0)+1,snapshot:this.snapshot(ie(e,r))}):i&&!i.snapshot?i:this.store(e,{mtimeMs:0,snapshot:void 0,version:(i?.version??0)+1})}changeRange(e,t){let r=e.length,i=t.length,s=Math.min(r,i),n=0;for(;n<s&&e.charCodeAt(n)===t.charCodeAt(n);)n++;let a=0;for(;a<s-n&&e.charCodeAt(r-1-a)===t.charCodeAt(i-1-a);)a++;return{span:{start:n,length:r-n-a},newLength:i-n-a}}snapshot(e){return{text:e,getText:(t,r)=>e.slice(t,r),getLength:()=>e.length,getChangeRange:t=>this.changeRange(t.getText(0,t.getLength()),e)}}store(e,t){return this.cache.set(e,t),t}stat(e){return se(e,{throwIfNoEntry:!1})}};v=y([oe({scope:"singleton"})],v);import{inject as le,Injectable as pe}from"@remotex-labs/xinject";import{normalize as F,SourceService as fe}from"@remotex-labs/xmap";var G=/xbuild(?!\.config)/i,de=/"mappings"\s*:\s*""/,f=class{frameworkFile;frameworkRoot;projectRoot;sourceMaps=new Map;constructor(){this.projectRoot=F(ae()),this.frameworkFile=F(import.meta.filename),this.frameworkRoot=F(import.meta.dirname),this.loadSourceMap(this.frameworkFile)}static resolve(e){return(f.files??=le(v)).resolve(e)}isFrameworkFile(e){return G.test(e.source??"")||G.test(e.sourceRoot??"")}getSourceMap(e){return this.sourceMaps.get(f.resolve(e))}addSourceMap(e,t,r=!1){let i=f.resolve(e);!r&&this.sourceMaps.has(i)||this.register(i,t)}loadSourceMap(e){if(!e)return;let t=f.resolve(e);if(this.sourceMaps.has(t))return;let r;try{r=ce(`${t}.map`,"utf-8")}catch(i){throw f.failure(t,i)}this.register(t,r)}static failure(e,t){return new Error(`Failed to load source map for: ${e}
|
|
2
2
|
${t instanceof Error?t.message:String(t)}`)}register(e,t){if(!de.test(t))try{this.sourceMaps.set(e,new fe(t,e))}catch(r){throw f.failure(e,r)}}};k(f,"files"),f=y([pe({scope:"singleton"})],f);var Y=class{constructor(e,t){this.config=e;this.rootDir=f.resolve(t),this.config.port||=0,this.config.host||="localhost"}config;server;events$=new he;rootDir;framework=ue(f);get pipe(){return this.events$.pipe.bind(this.events$)}get subscribe(){return this.events$.subscribe.bind(this.events$)}async start(){if(this.config.https)return await this.startHttpsServer();await this.startHttpServer()}async stop(){if(!this.server)return this.events$.next({type:"stop",running:!1});await new Promise((e,t)=>{this.server.close(r=>{r?t(r):e()})}),this.server=void 0,this.events$.next({type:"stop",running:!0})}async restart(){await this.stop(),await this.start()}setActualPort(){if(this.config.port===0){let e=this.server.address();e&&typeof e=="object"&&e.port&&(this.config.port=e.port)}}startHttpServer(){return new Promise(e=>{this.server=Q.createServer((t,r)=>{this.handleRequest(t,r,()=>this.defaultResponse(t,r))}),this.server.listen(this.config.port,this.config.host,()=>{this.setActualPort();let t={host:this.config.host,port:this.config.port,url:`http://${this.config.host}:${this.config.port}`};this.config.onStart?.(t),this.events$.next({...t,type:"start"}),e()})})}startHttpsServer(){return new Promise(e=>{let t={key:K(this.config.key??C(this.framework.frameworkRoot,"..","certs","server.key")),cert:K(this.config.cert??C(this.framework.frameworkRoot,"..","certs","server.crt"))};this.server=X.createServer(t,(r,i)=>{this.handleRequest(r,i,()=>this.defaultResponse(r,i))}),this.server.listen(this.config.port,this.config.host,()=>{this.setActualPort();let r={host:this.config.host,port:this.config.port,url:`https://${this.config.host}:${this.config.port}`};this.config.onStart?.(r),this.events$.next({...r,type:"start"}),e()})})}handleRequest(e,t,r){try{this.events$.next({type:"request",url:e.url??""}),this.config.onRequest?this.config.onRequest(e,t,r):r()}catch(i){this.sendError(t,i)}}getContentType(e){return{html:"text/html",css:"text/css",js:"application/javascript",cjs:"application/javascript",mjs:"application/javascript",ts:"text/plain",map:"application/json",json:"application/json",png:"image/png",jpg:"image/jpeg",gif:"image/gif",txt:"text/plain"}[e]||"application/octet-stream"}async defaultResponse(e,t){let r=e.url==="/"?"":e.url?.replace(/^\/+/,"")||"",i=C(this.rootDir,r);if(!i.startsWith(this.rootDir)){t.statusCode=403,t.end();return}try{let s=await ge(i);s.isDirectory()?await this.handleDirectory(i,r,t):s.isFile()&&await this.handleFile(i,t)}catch(s){this.events$.next({type:"error",error:s,url:e.url}),this.sendNotFound(t)}}async handleDirectory(e,t,r){let s=(await me(e)).map(l=>{let u=C(t,l),m=U(l).slice(1)||"folder";return m==="folder"?`
|
|
3
3
|
<a href="/${u}" class="folder-row">
|
|
4
4
|
<div class="icon"><i class="fa-solid fa-folder"></i></div>
|
|
@@ -9,9 +9,9 @@ ${t instanceof Error?t.message:String(t)}`)}register(e,t){if(!de.test(t))try{thi
|
|
|
9
9
|
<div class="icon"><i class="fa-solid fa-file-code"></i></div>
|
|
10
10
|
<div class="meta"><div class="name">${l}</div><div class="sub">${m}</div></div>
|
|
11
11
|
</a>
|
|
12
|
-
`}).join("");s?s=`<div class="list">${s}</div>`:s='<div class="empty">No files or folders here.</div>';let n="/",a=t.split("/").map(l=>(n+=`${l}/`,`<li><a href="${n}">${l}</a></li>`)).join(""),c=V.replace("${ fileList }",s).replace("${ paths }",'<li><a href="/">root</a></li>'+a).replace("${ up }","/"+t.split("/").slice(0,-1).join("/"));r.writeHead(200,{"Content-Type":"text/html"}),r.end(c)}async handleFile(e,t){let r=U(e).slice(1)||"txt",i=this.getContentType(r),s=await ve(e);t.writeHead(200,{"Content-Type":i}),t.end(s)}sendNotFound(e){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not Found")}sendError(e,t){this.events$.next({type:"error",error:t}),e.writeHead(500,{"Content-Type":"text/plain"}),e.end("Internal Server Error")}};import{Injectable as De}from"@remotex-labs/xinject";import{Subject as Ee}from"@remotex-labs/xobservable";import{join as
|
|
12
|
+
`}).join("");s?s=`<div class="list">${s}</div>`:s='<div class="empty">No files or folders here.</div>';let n="/",a=t.split("/").map(l=>(n+=`${l}/`,`<li><a href="${n}">${l}</a></li>`)).join(""),c=V.replace("${ fileList }",s).replace("${ paths }",'<li><a href="/">root</a></li>'+a).replace("${ up }","/"+t.split("/").slice(0,-1).join("/"));r.writeHead(200,{"Content-Type":"text/html"}),r.end(c)}async handleFile(e,t){let r=U(e).slice(1)||"txt",i=this.getContentType(r),s=await ve(e);t.writeHead(200,{"Content-Type":i}),t.end(s)}sendNotFound(e){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not Found")}sendError(e,t){this.events$.next({type:"error",error:t}),e.writeHead(500,{"Content-Type":"text/plain"}),e.end("Internal Server Error")}};import{Injectable as De}from"@remotex-labs/xinject";import{Subject as Ee}from"@remotex-labs/xobservable";import{join as Et}from"@remotex-labs/xmap";var j={64:")",43:")+",42:")*",63:")?"};function $(o){return".+^$()|\\{}[]*?".includes(o)?"\\"+o:o}function d(o,e){return o.charCodeAt(e)}function ye(o,e){return(e===0||d(o,e-1)===47)&&(e+2===o.length||d(o,e+2)===47)}function I(o){return`(?:${o})`}function B(o,e){let t=e+1,r=d(o,t);for((r===33||r===94)&&t++,d(o,t)===93&&t++;t<o.length&&d(o,t)!==93;)t+=d(o,t)===92?2:1;return t}function xe(o,e){for(let t=e,r=0;t<o.length;t++){let i=d(o,t);if(i===92)t++;else if(i===40)r++;else{if(i===41&&--r===0)return t;i===91&&(t=B(o,t))}}return-1}function be(o,e){let t=!1;for(let r=e+1,i=0;r<o.length;r++){let s=d(o,r);if(s===92)r++;else if(s===123)i++;else if(s===125){if(i===0)return t?r:-1;i--}else s===44&&i===0?t=!0:s===91&&(r=B(o,r))}return-1}function Se(o,e){let t=B(o,e);if(t>=o.length)return["\\[",e+1];let r=e+1,i="[",s=d(o,r);for((s===33||s===94)&&(i+="^/",r++),d(o,r)===93&&(i+="\\]",r++);r<t;r++)d(o,r)===92?i+="\\"+o[++r]:d(o,r)===94?i+="\\^":i+=o[r];return[i+"]",t+1]}function we(o,e){for(let t=e;t<o.length;t++){if(d(o,t)===47)return t;d(o,t)===92&&t++}return o.length}function D(o,e=!1,t=0,r={}){let{dot:i=!1}=r,s="",n=0,a=e,c=i?"":"(?!\\.)",l=c+"[^/]"+"+",u=I(l+"(?:/"+l+")*")+"?";for(;n<o.length;){let m=d(o,n),w=d(o,n+1);if(w===40&&(m===33||j[m])){let p=xe(o,n+1);if(m!==33){let b=p===-1?o.length:p,E=D(o.slice(n+2,b),a,124,r);s+="(?:"+E+j[m],n=b+1;continue}if(p!==-1){let b=D(o.slice(n+2,p),a,124,r),E=we(o,p+1),q=D(o.slice(p+1,E),!1,0,r);s+=I((a?c:"")+`(?!${I(b)+q+"(?:$|/)"})`+"[^/]*?"+q),n=E;continue}}switch(m){case 47:s+="/",n++,a=!0;break;case 92:s+=n+1<o.length?$(o[n+1]):"\\\\",n+=2;break;case 63:s+=a&&!i?"[^./]":"[^/]",n++;break;case 42:if(w===42&&t!==124&&(n>0||e)&&ye(o,n)){let p=n===0&&t===0?"(?:[A-Za-z]:)?/?":"";d(o,n+2)===47?(s+=p+I(l+"/")+"*",n+=3,a=!0):(s+=p+u,n+=2)}else s+=(a?c:"")+"[^/]*",n++;break;case 123:{let p=be(o,n);p===-1?(s+="\\{",n++):(s+=I(D(o.slice(n+1,p),a,44,r)),n=p+1);break}case 91:{let[p,b]=Se(o,n);s+=(a&&!i&&p!=="\\["?"(?!\\.)":"")+p,n=b;break}case 124:case 44:t===m?(s+="|",a=e):s+=$(o[n]),n++;break;default:s+=$(o[n]),n++}}return s}function Ie(o,e={}){return new RegExp("^"+D(o,!0,0,e)+"$",e.flags)}function A(o,e={}){let t=[],r=[];for(let i of o){let s=!1;for(;d(i,0)===33&&d(i,1)!==40;)s=!s,i=i.slice(1);(s?r:t).push(Ie(i,e))}return i=>(t.length===0||t.some(s=>s.test(i)))&&!r.some(s=>s.test(i))}import{resolve as ke,join as J,relative as Ce}from"@remotex-labs/xmap";import{watch as Ae,realpathSync as Pe,readdirSync as Re,lstatSync as Me,statSync as Fe}from"fs";var P=class extends Ee{constructor(t,r){super();this.options=r;this.base=ke(t),this.matcher=A(this.options?.filter??[],{dot:this.options?.dot??!1})}options;base;matcher;watchers=new Map;pending=new Map;subscriptions=0;timer;subscribe(t,r,i){let s=super.subscribe(t,r,i);return++this.subscriptions===1&&this.start(),this.toUnsubscribe(()=>{s(),--this.subscriptions===0&&this.stop()})}get debounce(){return this.options?.debounce??150}start(){this.watch(this.base,this.ignored.bind(this),this.options?.recursive),this.options?.followSymlinks&&this.watchSymlinks(this.base)}stop(){this.timer&&clearTimeout(this.timer);for(let t of this.watchers.values())t.close();this.timer=void 0,this.pending.clear(),this.watchers.clear()}flush(){if(this.timer=void 0,this.pending.size===0)return;let t=Object.fromEntries(this.pending);this.pending.clear();try{this.next(t)}catch{}}watcherClose(t){let r=this.watchers.get(t);r&&(r.close(),this.watchers.delete(t))}watcherEvent(t,r){let i=Ce(this.base,r),s=Me(r,{throwIfNoEntry:!1}),n=s?.isSymbolicLink()?Fe(r,{throwIfNoEntry:!1}):s;if(s?.isSymbolicLink()){if(!n)return;t==="rename"&&this.watcherClose(r),n.isFile()&&this.matcher(r)?this.watch(r):n.isDirectory()&&this.options?.recursive&&this.watch(r,this.ignored.bind(this),!0)}if(!this.matcher(i))return;this.timer?this.timer.refresh():this.timer=setTimeout(this.flush.bind(this),this.debounce);let a;n?a=n.birthtimeMs===n.mtimeMs?0:1:(this.watcherClose(r),a=2),this.pending.set(i,{type:a,stats:n})}watch(t,r,i=!1){if(this.watchers.has(t)||this.ignored(t))return;let s=Ae(Pe(t),{recursive:i,ignore:r},(n,a)=>{if(!a)return;let c=t.includes(a)?t:J(t,a);this.watcherEvent(n,c)});s.on("error",n=>{this.watcherClose(t),this.error(n)}),this.watchers.set(t,s)}ignored(t){return!!(!t||t.endsWith("~")||!this.options?.dot&&t&&t.split(/[/\\]/).some(r=>r.startsWith(".")))}watchSymlinks(t){let r=[t];for(;r.length;){let i=r.pop(),s;try{s=Re(i,{withFileTypes:!0})}catch{continue}for(let n of s){let a=J(n.parentPath??i,n.name);this.ignored(a)||(n.isSymbolicLink()?this.watch(a,this.ignored.bind(this),this.options?.recursive):this.options?.recursive&&n.isDirectory()&&r.push(a))}}}};P=y([De({scope:"singleton"})],P);import{inject as N}from"@remotex-labs/xinject";import{resolveError as Te}from"@remotex-labs/xmap";import{xterm as L}from"@remotex-labs/xansi/xterm.component";import{parseErrorStack as Z}from"@remotex-labs/xmap/parser.component";import{formatErrorCode as je}from"@remotex-labs/xmap/formatter.component";import{highlightCode as $e}from"@remotex-labs/xmap/highlighter.component";function Be(o=""){let t=N(f).getSourceMap(o);if(t)return t;let r=N(v).touch(o),i=r.snapshot?.text;if(!r||!i)return null;let s=i.split(`
|
|
13
13
|
`);return{getPositionWithCode:(n,a,c,l)=>{let u=l?.linesAfter??3,m=l?.linesBefore??3,w=Math.max(n-m,1),p=Math.min(n+u,s.length);return{line:n,name:null,code:s.slice(w-1,p).join(`
|
|
14
|
-
`),source:o,column:a,endLine:p,startLine:w,sourceRoot:null,sourceIndex:-1,generatedLine:-1,generatedColumn:-1}}}}function Ne(o){return o instanceof Error?Z(o):o.detail instanceof Error?Z(o.detail):o.location?{name:"esBuildMessage",message:o.text??"",rawStack:"",stack:[{source:`@${o.location.file}`,line:o.location.line,column:o.location.column||1,fileName:o.location.file,eval:!1,async:!1,native:!1,constructor:!1}]}:{stack:[],name:"esBuildMessage",message:o.text??"",rawStack:""}}function
|
|
14
|
+
`),source:o,column:a,endLine:p,startLine:w,sourceRoot:null,sourceIndex:-1,generatedLine:-1,generatedColumn:-1}}}}function Ne(o){return o instanceof Error?Z(o):o.detail instanceof Error?Z(o.detail):o.location?{name:"esBuildMessage",message:o.text??"",rawStack:"",stack:[{source:`@${o.location.file}`,line:o.location.line,column:o.location.column||1,fileName:o.location.file,eval:!1,async:!1,native:!1,constructor:!1}]}:{stack:[],name:"esBuildMessage",message:o.text??"",rawStack:""}}function Kt(o,e,t=!1){let r=N(f),i=Ne(o),s=Te(i,{...e,withNativeFrames:t||(e?.withFrameworkFrames??!1),getSource(n){return Be(n)}});return s.stack.filter(n=>{if(!(e?.withFrameworkFrames??!1)&&r.isFrameworkFile(n))return!1;!s.formatCode&&n.code&&(s.formatCode=je({code:$e(n.code),line:n.line??1,column:n.column??1,startLine:n.stratLine??1},{color:L.brightPink}))}),s}function Yt(o,e,t,r=[]){let i=[`
|
|
15
15
|
${e}: ${L.lightCoral(t)}`];for(let s of r??[])s.text&&i.push(`
|
|
16
16
|
`+L.gray(s.text));return o.formatCode&&i.push(`
|
|
17
17
|
|
|
@@ -20,15 +20,15 @@ ${o.formatCode}`),o.stack.length&&i.push(`
|
|
|
20
20
|
Enhanced Stack Trace:
|
|
21
21
|
${o.stack.map(s=>s.format).join(`
|
|
22
22
|
`)}
|
|
23
|
-
`),i.join("")}import h from"typescript";import{Injectable as
|
|
23
|
+
`),i.join("")}import h from"typescript";import{Injectable as Ue}from"@remotex-labs/xinject";import{normalize as Ke,relative as Ye,dirname as Qe}from"@remotex-labs/xmap";import{existsSync as Le}from"fs";import{parseSync as Oe}from"oxc-parser";import{inject as He}from"@remotex-labs/xinject";import{mkdir as ze,writeFile as qe}from"fs/promises";import{join as H,dirname as z,relative as We}from"@remotex-labs/xmap";function x(o,e,t){let r=o.end;for(;r<e.length;){let i=e.charCodeAt(r);if(i!==32&&i!==9)break;r++}e.charCodeAt(r)===13&&r++,e.charCodeAt(r)===10&&r++,t.push({start:o.start,end:r})}function O(o,e){if(e.length<1)return o;e.sort((s,n)=>s.start-n.start);let t=new Array(e.length*2+1),r=0,i=0;for(let s=0;s<e.length;s++){let n=e[s];n.start<i||(t[r++]=o.slice(i,n.start),t[r++]=n.text??"",i=n.end)}return t[r++]=o.slice(i),t.length=r,t.join("")}var _=`/**
|
|
24
24
|
* This file was automatically generated by xBuild.
|
|
25
25
|
* DO NOT EDIT MANUALLY.
|
|
26
26
|
*/
|
|
27
|
-
`;var R=class{constructor(e){this.ts=e}ts;cache=new Map;filesCache=He(v);emitted=new Map;clear(){this.cache.clear(),this.emitted.clear()}touch(e){let t=this.filesCache.resolve(e),r=this.filesCache.touch(t),i=this.cache.get(t);if(i?.version===r.version)return i;let s=this.build(t,r.
|
|
27
|
+
`;var R=class{constructor(e){this.ts=e}ts;cache=new Map;filesCache=He(v);emitted=new Map;clear(){this.cache.clear(),this.emitted.clear()}touch(e){let t=this.filesCache.resolve(e),r=this.filesCache.touch(t),i=this.cache.get(t);if(i?.version===r.version)return i;let s=this.build(t,r.version);return this.cache.set(t,s),s}async emit(e,t){let r=[],i=[],s=new Set,n=new Map;for(let[c,l]of Object.entries(e))n.set(this.filesCache.resolve(l),c);let a=[...n.keys()];for(;a.length>0;){let c=a.pop();if(s.has(c)||c.endsWith(".d.ts"))continue;s.add(c);let l=this.touch(c);for(let m of l.projectDependencies)s.has(m)||a.push(m);let u=this.outputPath(c,t,n.get(c));this.emitted.get(u)===l.version&&Le(u)||(this.emitted.set(u,l.version),r.push(u),i.push(l.declaration))}return this.write(r,i)}async emitBundle(e,t){let r=this.ts.config.options,i=this.filesCache.resolve(t??r.declarationDir??r.outDir??".");return this.write(Object.keys(e).map(s=>H(i,`${s}.d.ts`)),Object.values(e).map(s=>this.bundle(s)))}bundle(e){let t=this.filesCache.resolve(e),r=this.touch(t);return this.render(this.collectClosure(t,r),this.collectSurface(t,r))}async write(e,t){if(e.length<1)return e;let r=new Set(e.map(i=>z(i)));return await Promise.all([...r].map(i=>ze(i,{recursive:!0}))),await Promise.all(e.map((i,s)=>qe(i,t[s],"utf-8"))),e}outputPath(e,t,r){let{declarationDir:i,outDir:s,rootDir:n}=this.ts.config.options,a=t??i??s,c=a?this.filesCache.resolve(a):z(e);if(r)return H(c,`${r}.d.ts`);let l=n?this.filesCache.resolve(n):z(e);return H(c,We(l,e).replace(/\.([cm]?)tsx?$/,".d.$1ts"))}collectClosure(e,t){let r=new Set([e]),i=[],s=[...t.projectDependencies];for(;s.length>0;){let n=s.pop();if(r.has(n))continue;r.add(n);let a=this.touch(n);i.push(a);for(let c of a.projectDependencies)r.has(c)||s.push(c)}return i.push(t),i}collectSurface(e,t){let r=new Set,i=new Set,s=new Set([e]),n=[t];for(;n.length>0;){let a=n.pop();for(let c of a.projectExports.exports)r.add(this.clause(c));for(let[c,l]of Object.entries(a.packageExports)){l.star&&i.add(`export * from '${c}';`),l.named?.length&&i.add(`export { ${l.named.map(u=>this.clause(u)).join(", ")} } from '${c}';`);for(let u of l.namespaces??[])i.add(`export * as ${u} from '${c}';`)}for(let c of a.projectExports.star)s.has(c)||(s.add(c),n.push(this.touch(c)))}return{exports:r,statements:i}}mergeImports(e){let t=new Map;for(let r of e)for(let[i,s]of Object.entries(r.packageImports)){let n=t.get(i);n||t.set(i,n={side:!1,named:new Set,namespaces:new Set}),s.side&&(n.side=!0),n.default??=s.default;for(let a of s.namespaces??[])n.namespaces.add(a);for(let a of s.named??[])n.named.add(this.clause(a))}return t}renderImports(e){let t=[];for(let[r,i]of e){i.side&&t.push(`import '${r}';`);for(let n of i.namespaces)t.push(`import * as ${n} from '${r}';`);let s=[];i.default&&s.push(i.default),i.named.size>0&&s.push(`{ ${[...i.named].sort().join(", ")} }`),s.length>0&&t.push(`import ${s.join(", ")} from '${r}';`)}return t}render(e,t){let r=[_],i=this.renderImports(this.mergeImports(e));i.length>0&&r.push(...i,"");for(let s of e){let n=s.content.trim();n&&r.push(n,"")}return t.exports.size>0&&r.push(`export {
|
|
28
28
|
${[...t.exports].sort().join(`,
|
|
29
29
|
`)}
|
|
30
30
|
};`),r.push(...t.statements),t.exports.size<1&&t.statements.size<1&&r.push("export {};"),`${r.join(`
|
|
31
31
|
`)}
|
|
32
|
-
`}clause(e){return e.alias?`${e.name} as ${e.alias}`:e.name}
|
|
33
|
-
`),category:e.category};if(e.file&&e.start!==void 0){let{line:r,character:i}=e.file.getLineAndCharacterOfPosition(e.start);t.file=e.file.fileName,t.line=r+1,t.column=i+1,t.code=e.code}return t}parseConfig(){let e=h.getParsedCommandLineOfConfigFile(this.configPath,{sourceMap:!1,skipLibCheck:!0,stripInternal:!0,declarationMap:!1,emitDeclarationOnly:!0},{...h.sys,onUnRecoverableConfigFileDiagnostic:()=>{}});return e||(e={options:{strict:!0,target:h.ScriptTarget.ESNext,module:h.ModuleKind.NodeNext,sourceMap:!1,skipLibCheck:!0,stripInternal:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:h.ModuleResolutionKind.NodeNext},errors:[],fileNames:[],projectReferences:void 0}),e.options={...e.options,noEmit:!0,rootDir:e.options?.rootDir??process.cwd(),isolatedModules:!1,useCaseSensitiveFileNames:!0},e}};k(g,"cache",new Map),g=y([
|
|
32
|
+
`}clause(e){return e.alias?`${e.name} as ${e.alias}`:e.name}emitDeclaration(e){let t=this.ts.languageService;return!t.getProgram()?.getSourceFile(e)&&(this.ts.touchFiles([e]),!t.getProgram()?.getSourceFile(e))?"":t.getEmitOutput(e,!0,!0).outputFiles.find(r=>r.name.endsWith(".d.ts"))?.text??""}build(e,t){let r=this.emitDeclaration(e),i={edits:[],target:e,parsed:Oe(e,r,{sourceType:"module"}),content:r,bundleEdits:[],packageImports:Object.create(null),packageExports:Object.create(null),projectExports:{star:new Set,exports:[],namespace:Object.create(null)},projectDependencies:new Set},s=[],{body:n}=i.parsed.program;for(let a of n)this.strip(a,i)&&s.push(a.start);return this.pruneComments(i,n,s),{version:t,content:O(r,i.bundleEdits),declaration:O(r,i.edits),packageImports:i.packageImports,packageExports:i.packageExports,projectExports:i.projectExports,projectDependencies:i.projectDependencies}}strip(e,t){switch(e.type){case"ImportDeclaration":return this.stripImport(e,t),!1;case"ExportAllDeclaration":return this.stripStarExport(e,t),!1;case"ExportNamedDeclaration":return this.stripNamedExport(e,t);case"ExportDefaultDeclaration":return this.stripDefaultExport(e,t);case"TSImportEqualsDeclaration":return this.stripImportEquals(e,t);case"TSExportAssignment":case"TSNamespaceExportDeclaration":return x(e,t.content,t.bundleEdits),!1;default:return!0}}stripImport(e,t){if(x(e,t.content,t.bundleEdits),this.link(e.source,t))return;let r=t.packageImports[e.source.value]??={};if(e.specifiers.length<1){r.side=!0;return}for(let i of e.specifiers)switch(i.type){case"ImportDefaultSpecifier":r.default??=i.local.name;break;case"ImportNamespaceSpecifier":(r.namespaces??=[]).push(i.local.name);break;default:(r.named??=[]).push(this.binding(this.nameOf(i.imported),i.local.name))}}stripImportEquals(e,t){let{moduleReference:r}=e;if(r.type!=="TSExternalModuleReference")return!0;x(e,t.content,t.bundleEdits);let i=r.expression;return this.link(i,t)||((t.packageImports[i.value]??={}).namespaces??=[]).push(e.id.name),!1}stripNamedExport(e,t){let{exports:r}=t.projectExports;if(e.declaration)return this.collectDeclared(e.declaration,r),t.bundleEdits.push({start:e.start,end:e.declaration.start}),!0;x(e,t.content,t.bundleEdits);let i=e.source&&!this.link(e.source,t)?(t.packageExports[e.source.value]??={}).named??=[]:r;for(let s of e.specifiers)i.push(this.binding(this.nameOf(s.local),this.nameOf(s.exported)));return!1}stripStarExport(e,t){x(e,t.content,t.bundleEdits);let r=this.link(e.source,t),i=e.exported?this.nameOf(e.exported):null;if(r){i?t.projectExports.namespace[i]=r:t.projectExports.star.add(r);return}let s=t.packageExports[e.source.value]??={};i?(s.namespaces??=[]).push(i):s.star=!0}stripDefaultExport(e,t){let{declaration:r}=e,i=this.defaultBinding(r);return i&&t.projectExports.exports.push({name:i,alias:"default"}),i&&r.type!=="Identifier"?(t.bundleEdits.push({start:e.start,end:r.start,text:"declare "}),!0):(x(e,t.content,t.bundleEdits),!1)}pruneComments(e,t,r){let{content:i,bundleEdits:s}=e,n=0,a=0;for(let c of e.parsed.comments)if(!(c.type!=="Block"||c.value.charCodeAt(0)!==42)){for(;n<t.length&&t[n].end<=c.start;)n++;if(!(n<t.length&&t[n].start<c.start)){for(;a<r.length&&r[a]<c.end;)a++;a<r.length&&this.blank(i,c.end,r[a])||x(c,i,s)}}}link(e,t){let r=this.ts.resolve(e.value,t.target);if(!r||r.isExternalLibraryImport)return null;let{extension:i,relativeFileName:s,resolvedFileName:n}=r,a=this.filesCache.resolve(n);return t.projectDependencies.add(a),t.edits.push({end:e.end,start:e.start,text:`'${i?s.slice(0,-i.length):s}.d.ts'`}),a}collectDeclared(e,t){if(e.type==="VariableDeclaration"){for(let r of e.declarations)r.id.type==="Identifier"&&t.push({name:r.id.name});return}"id"in e&&e.id&&"name"in e.id&&t.push({name:e.id.name})}defaultBinding(e){return e.type==="Identifier"?e.name:"id"in e?e.id?.name:void 0}nameOf(e){return"name"in e?e.name:JSON.stringify(e.value)}binding(e,t){return e===t?{name:e}:{name:e,alias:t}}blank(e,t,r){for(let i=t;i<r;i++){let s=e.charCodeAt(i);if(s!==32&&s!==9&&s!==10&&s!==13)return!1}return!0}};import S from"typescript";import{relative as Ve}from"@remotex-labs/xmap";import{inject as Ge}from"@remotex-labs/xinject";var M=class{constructor(e){this.config=e;this.reload()}config;filesCache=Ge(v);trackedFiles=new Set;exclusions=new Map;matches;get tracked(){return this.trackedFiles}get ignoreSourceFile(){return e=>this.isExcluded(e.fileName)}set options(e){this.config=e,this.reload()}clearTracked(){this.trackedFiles.clear(),this.refreshFiles(this.config.fileNames)}reload(){this.matches=this.compileExclude(this.config.raw?.exclude),this.exclusions.clear(),this.clearTracked()}refresh(e){return this.filesCache.refresh(this.track(e))}refreshFiles(e=this.trackedFiles){for(let t of e)this.isExcluded(t)||this.refresh(t)}getCompilationSettings(){return this.config.options}fileExists(e){return S.sys.fileExists(e)}readFile(e,t){return this.filesCache.touch(e,t).snapshot?.text}readDirectory(e,t,r,i,s){return S.sys.readDirectory(e,t,r,i,s)}getDirectories(e){return S.sys.getDirectories(e)}directoryExists(e){return S.sys.directoryExists(e)}getCurrentDirectory(){return S.sys.getCurrentDirectory()}getScriptFileNames(){return[...this.trackedFiles]}getDefaultLibFileName(e){return S.getDefaultLibFilePath(e)}getScriptVersion(e){return this.filesCache.touch(this.track(e)).version.toString()}getScriptSnapshot(e){return this.filesCache.touch(e).snapshot}realpath(e){return this.filesCache.resolve(e)}compileExclude(e){return e&&e.length>0?A(e):()=>!1}isExcluded(e){let t=this.filesCache.resolve(e),r=this.exclusions.get(t);return r===void 0&&this.exclusions.set(t,r=this.matches(Ve(process.cwd(),t))),r}track(e){let t=this.filesCache.resolve(e);return this.trackedFiles.add(t),t}};var g=class{constructor(e="tsconfig.json"){this.configPath=e;this.parsedConfig=this.parseConfig(),this.languageHostService=new M(this.parsedConfig),this.configVersion=this.languageHostService.filesCache.touch(this.configPath).version,this.resolutionCache=this.createResolutionCache(),this.languageService=h.createLanguageService(this.languageHostService,h.createDocumentRegistry(!0)),this.declaration=new R(this)}configPath;languageService;languageHostService;diagnosticsCache=new Map;builderHost={createHash:h.sys.createHash,readFile:(e,t)=>this.languageHostService.readFile(e,t),getCurrentDirectory:()=>h.sys.getCurrentDirectory(),useCaseSensitiveFileNames:()=>h.sys.useCaseSensitiveFileNames};declaration;parsedConfig;configVersion;resolutionCache;builder;static reload(e=!1){let t=[];for(let[r,i]of g.cache)i.instance.refresh(e)&&t.push(r);return t}get config(){return this.parsedConfig}check(e){let t=this.languageService.getProgram();if(!t)return[];let r=this.languageHostService.ignoreSourceFile,i=n=>n.fileName.includes("node_modules")?!0:r(n),s;for(this.builder=h.createEmitAndSemanticDiagnosticsBuilderProgram(t,this.builderHost,this.builder);s=this.builder.getSemanticDiagnosticsOfNextAffectedFile(void 0,i);)if("fileName"in s.affected){let n=s.affected;this.diagnosticsCache.set(n.fileName,[...s.result,...this.builder.getSyntacticDiagnostics(n),...this.languageService.getSuggestionDiagnostics(n.fileName)].map(a=>this.formatDiagnostic(a)))}return this.reconcileDiagnostics(t,e??this.diagnosticsCache.keys())}async emit(e,t){return t??=this.config.options.outDir??"dist",this.declaration.emit(e,t)}async emitBundle(e,t){return t??=this.config.options.outDir??"dist",this.declaration.emitBundle(e,t)}touchFiles(e){this.languageHostService.refreshFiles(e)}resolve(e,t){let r=t?this.languageHostService.filesCache.resolve(Qe(t)):process.cwd(),s=this.resolutionCache.getOrCreateCacheForDirectory(r).get(e,void 0)?.resolvedModule;if(s)return s;let n=h.resolveModuleName(e,t??"",this.parsedConfig.options,this.languageHostService,this.resolutionCache).resolvedModule;if(n){let a=Ye(r,n.resolvedFileName);n.container=r,n.relativeFileName=a.startsWith(".")?a:`./${a}`}return n}dispose(){let e=g.cache.get(this.configPath);e&&(e.refCount--,!(e.refCount>0)&&(this.languageService.dispose(),g.cache.delete(this.configPath)))}[Symbol.dispose??Symbol.for("Symbol.dispose")](){this.dispose()}static acquire(e="tsconfig.json"){let t=Ke(e),r=g.cache.get(t);if(r)return r.refCount++,r.instance;let i=new g(t);return g.cache.set(t,{instance:i,refCount:1}),i}refresh(e=!1){let{version:t}=this.languageHostService.filesCache.touch(this.configPath);return!e&&t===this.configVersion?!1:(this.configVersion=t,this.parsedConfig=this.parseConfig(),this.languageHostService.options=this.parsedConfig,this.resolutionCache=this.createResolutionCache(),this.declaration.clear(),this.diagnosticsCache.clear(),this.builder=void 0,!0)}createResolutionCache(){return h.createModuleResolutionCache(h.sys.getCurrentDirectory(),e=>this.languageHostService.realpath(e),this.parsedConfig.options)}reconcileDiagnostics(e,t){let r=this.languageHostService.filesCache,i=[];for(let s of t){let n=r.resolve(s),a=this.diagnosticsCache.get(n);a&&(e.getSourceFile(n)?i.push(...a):this.diagnosticsCache.delete(n))}return i}formatDiagnostic(e){let t={message:h.flattenDiagnosticMessageText(e.messageText,`
|
|
33
|
+
`),category:e.category};if(e.file&&e.start!==void 0){let{line:r,character:i}=e.file.getLineAndCharacterOfPosition(e.start);t.file=e.file.fileName,t.line=r+1,t.column=i+1,t.code=e.code}return t}parseConfig(){let e=h.getParsedCommandLineOfConfigFile(this.configPath,{sourceMap:!1,skipLibCheck:!0,stripInternal:!0,declarationMap:!1,emitDeclarationOnly:!0},{...h.sys,onUnRecoverableConfigFileDiagnostic:()=>{}});return e||(e={options:{strict:!0,target:h.ScriptTarget.ESNext,module:h.ModuleKind.NodeNext,sourceMap:!1,skipLibCheck:!0,stripInternal:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:h.ModuleResolutionKind.NodeNext},errors:[],fileNames:[],projectReferences:void 0}),e.options={...e.options,noEmit:!0,rootDir:e.options?.rootDir??process.cwd(),isolatedModules:!1,useCaseSensitiveFileNames:!0},e}};k(g,"cache",new Map),g=y([Ue({factory(o){return g.acquire(o)}})],g);export{Y as ServerModule,g as Typescript,P as WatchService,Yt as formatStack,Kt as getErrorMetadata,Ne as getErrorStack,Be as getSource};
|
|
34
34
|
//# sourceMappingURL=index.js.map
|