@lensmcp/cluster 1.25.48 → 1.25.49
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/create-webpack-dev.js +1 -1
- package/executors/gateway/gateway.impl.js +1 -1
- package/executors/gateway/runtime/kept-settings.d.ts +9 -0
- package/executors/gateway/runtime/kept-settings.js +1 -0
- package/executors/gateway/runtime/pod-env.js +2 -2
- package/package.json +4 -4
- package/shared-build/attach.d.ts +2 -2
- package/shared-build/attach.js +1 -1
- package/tsgo-check-plugin.d.ts +11 -3
- package/tsgo-check-plugin.js +3 -3
package/create-webpack-dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var j=Object.defineProperty;var p=(r,e)=>j(r,"name",{value:e,configurable:!0});var O=Object.defineProperty,c=p((r,e)=>O(r,"name",{value:e,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.DevBuildFinalizePlugin=exports.DevServerReloadPlugin=exports.devserverControlSock=exports.DevserverNotifier=void 0,exports.devCacheOptions=devCacheOptions,exports.devModuleFilename=devModuleFilename,exports.createDevWebpackConfig=createDevWebpackConfig;const tslib_1=require("tslib"),app_plugin_1=require("@nx/webpack/app-plugin"),node_crypto_1=require("node:crypto"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),webpack_node_externals_1=tslib_1.__importDefault(require("webpack-node-externals")),build_scope_patterns_1=require("./build-scope-patterns"),checkout_cache_1=require("./checkout-cache"),dev_devtool_1=require("./dev-devtool"),tsgo_check_plugin_1=require("./tsgo-check-plugin"),fork_ts_check_reporter_1=require("./fork-ts-check-reporter"),perf_rules_plugin_1=require("./perf/perf-rules-plugin"),devserver_notifier_1=require("./devserver-notifier"),workspace_paths_1=require("./workspace-paths");var devserver_notifier_2=require("./devserver-notifier");Object.defineProperty(exports,"DevserverNotifier",{enumerable:!0,get:c(function(){return devserver_notifier_2.DevserverNotifier},"get")}),Object.defineProperty(exports,"devserverControlSock",{enumerable:!0,get:c(function(){return devserver_notifier_2.devserverControlSock},"get")});const webpack=require("webpack");class DevServerReloadPlugin{static{p(this,"DevServerReloadPlugin")}static{c(this,"DevServerReloadPlugin")}constructor(e,i=!1,a,o=Number(process.env.LENSMCP_GATEWAY_PID??0)>0){this.notifier=new devserver_notifier_1.DevserverNotifier(e,i,a,o)}snapshot(){return this.notifier.snapshot()}apply(e){const i="DevServerReloadPlugin";let a=!1;e.hooks.watchRun?.tap(i,o=>{const s=[...o?.modifiedFiles??[],...o?.removedFiles??[]].filter(n=>typeof n=="string");if(!a){const n=o?.watchFileSystem?.watcher;n&&typeof n.on=="function"&&(a=!0,n.on("error",l=>this.notifier.degrade(`watcher error: ${l?.message??String(l)}`)))}this.notifier.watchRun(s)}),e.hooks.watchClose?.tap(i,()=>this.notifier.degrade("watch closed")),e.hooks.failed?.tap(i,o=>this.notifier.failed(`compiler failed: ${o?.message??String(o)}`)),e.hooks.done.tap(i,async o=>{if(o.hasErrors()){this.notifier.failed();return}await this.notifier.built()})}}exports.DevServerReloadPlugin=DevServerReloadPlugin;const DEV_CACHE_MEMORY_GENERATIONS=5,DEV_CACHE_MAX_AGE_MS=10080*60*1e3,LOCKFILES=["yarn.lock","package-lock.json","pnpm-lock.yaml","bun.lock"];function clusterVersion(){for(const r of[path.join(__dirname,"package.json"),path.join(__dirname,"..","package.json")])try{const e=JSON.parse(fs.readFileSync(r,"utf8"));if(e.name==="@lensmcp/cluster"&&e.version)return e.version}catch{}return"unknown"}p(clusterVersion,"clusterVersion"),c(clusterVersion,"clusterVersion");function devCacheOptions(r,e){const{appName:i,appRoot:a,workspaceRoot:o,tsConfig:s,webpackConfigPath:n}=r,l=clusterVersion(),_=JSON.stringify({lensmcp:l,devtool:e,buildLibsFromSource:r.buildLibsFromSource??!0,orgScopes:r.orgScopes??[],bundlePackages:r.bundlePackages??[],nodeExternalsConfig:r.nodeExternalsConfig??null}),f=c(g=>g.filter(d=>fs.existsSync(d)),"existing"),k=(0,workspace_paths_1.readWorkspacePaths)(s,o)?.configFiles??[path.resolve(o,s)],v={lensmcp:[__filename],lockfile:f(LOCKFILES.map(g=>path.join(o,g))),tsconfig:f([...new Set([...k,path.join(o,"tsconfig.base.json")])])};return n&&(v.overrides=[path.resolve(a,n)]),{type:"filesystem",cacheDirectory:(0,checkout_cache_1.checkoutCacheDir)(o,"lensmcp-webpack"),name:i.replace(/[^\w.-]+/g,"_"),version:`${l}-${(0,node_crypto_1.createHash)("sha256").update(_).digest("hex").slice(0,16)}`,buildDependencies:v,maxMemoryGenerations:DEV_CACHE_MEMORY_GENERATIONS,maxAge:DEV_CACHE_MAX_AGE_MS}}p(devCacheOptions,"devCacheOptions"),c(devCacheOptions,"devCacheOptions");function devModuleFilename(r){const e=r.absoluteResourcePath;return path.isAbsolute(e)?`file://${e}`:e}p(devModuleFilename,"devModuleFilename"),c(devModuleFilename,"devModuleFilename");class DevBuildFinalizePlugin{static{p(this,"DevBuildFinalizePlugin")}static{c(this,"DevBuildFinalizePlugin")}constructor(e){this.options=e}apply(e){const{cache:i}=this.options;e.options.cache={...i,buildDependencies:{...i.buildDependencies}},e.options.context&&(e.context=e.options.context);const a=e.options.resolve?.plugins??[];if(a.some(o=>o instanceof workspace_paths_1.WorkspacePathsResolverPlugin)){const o=new Set(a);e.hooks.afterPlugins.tap("DevBuildFinalizePlugin",()=>{const s=e.options.resolve;s.plugins=s.plugins.filter(n=>o.has(n)||n?.constructor?.name!=="TsconfigPathsPlugin")})}if(this.options.tsSourceMaps)for(const o of e.options.module?.rules??[])typeof o?.loader!="string"||!/[\\/]ts-loader[\\/]/.test(o.loader)||(o.options={...o.options,compilerOptions:{...o.options?.compilerOptions,sourceMap:!0,inlineSourceMap:!1}})}}exports.DevBuildFinalizePlugin=DevBuildFinalizePlugin;function createDevWebpackConfig(r){const{appRoot:e,outputDir:i,main:a,tsConfig:o,workspaceRoot:s,assets:n=[],port:l,memoryLimit:_=8192,buildLibsFromSource:f=!0,orgScopes:k=[],bundlePackages:v=[],additionalEntryPoints:g=[],nodeExternalsConfig:d,webpackConfigPath:b}=r,{allowlistPatterns:N,scopePrefixes:x,scopePatterns:M}=(0,build_scope_patterns_1.buildScopePatterns)(k),w=(0,tsgo_check_plugin_1.typecheckMode)(process.env),S=w==="tsgo"?(0,tsgo_check_plugin_1.resolveTsgoBin)(s,process.env.LENSMCP_TSGO_BIN):null;if(w==="tsgo"&&!S){const t=`${tsgo_check_plugin_1.TSGO_MISSING_CAUSE}. Fell back to fork-ts-checker, which reports to the console only \u2014 so typecheck:// has no producer for this project until it is fixed`;console.warn(`[serve] ${r.appName}: the type checker is tsgo but ${t}.`),(0,tsgo_check_plugin_1.reportTsgoUnavailable)({appName:r.appName,tsConfig:o,workspaceRoot:s,detail:t})}const C=!!S,P=(0,dev_devtool_1.resolveDevDevtool)(r.devtool);P.rejected&&console.warn(`[serve] ${r.appName}: '${P.rejected}' (devtool / ${dev_devtool_1.DEV_DEVTOOL_ENV}) is not a webpack devtool \u2014 building with '${dev_devtool_1.DEFAULT_DEV_DEVTOOL}'.`);const h=P.devtool,D=f?(0,workspace_paths_1.readWorkspacePaths)(o,s):null,E=v.map(t=>new RegExp(`^${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(/|$)`)),R=[/webpack\/hot\/poll\?100/,...N,...E,...d?.allowlist||[]],y={output:{path:i,...process.env.NODE_ENV!=="production"&&{devtoolModuleFilenameTemplate:devModuleFilename},clean:!0},externals:[(0,webpack_node_externals_1.default)({allowlist:R,additionalModuleDirs:d?.additionalModuleDirs||[],...d?.importType&&{importType:d.importType}}),({request:t},m)=>{if(t&&path.isAbsolute(t)&&t.startsWith(s)&&!t.includes("node_modules")||t&&(t.startsWith(path.join(s,"apps"))||t.startsWith(path.join(s,"libs")))||t&&x.some(u=>t.startsWith(u))||t&&M.some(u=>u.test(t))||t&&E.some(u=>u.test(t)))return m();if(t&&!(t.startsWith("./")||t.startsWith(".."))){const u=t.startsWith("@")?t.split("/").slice(0,2).join("/"):t.split("/")[0];return fs.existsSync(path.join(s,"node_modules",u))?m(null,`commonjs ${t}`):m()}return m()}],mode:"development",devtool:h,...(0,workspace_paths_1.hasPathMappings)(D)&&{resolve:{plugins:[new workspace_paths_1.WorkspacePathsResolverPlugin(D)]}},plugins:[new webpack.HotModuleReplacementPlugin,new app_plugin_1.NxAppWebpackPlugin({target:"node22",compiler:"tsc",main:a,additionalEntryPoints:g,verbose:!0,sourceMap:h,mergeExternals:!0,externalDependencies:[],memoryLimit:_,tsConfig:o,assets:n,optimization:!1,progress:!1,outputHashing:"none",generatePackageJson:!1,watchDependencies:!0,typeCheckOptions:process.env.LENSMCP_TYPECHECK==="off"||C?!1:{async:!0},buildLibsFromSource:f}),new DevBuildFinalizePlugin({cache:devCacheOptions(r,h),tsSourceMaps:(0,dev_devtool_1.bundleCarriesSourceMaps)(h)}),new DevServerReloadPlugin(l,r.httpsReload===!0,(0,devserver_notifier_1.devserverControlSock)(r.serviceName)),new perf_rules_plugin_1.PerfRulesPlugin({project:process.env.LENSMCP_PROJECT||r.appName,workspaceRoot:s,tsConfig:o}),...C?[new tsgo_check_plugin_1.TsgoCheckPlugin({appName:r.appName,tsConfig:o,workspaceRoot:s,...process.env.LENSMCP_TSGO_BIN?{binPath:process.env.LENSMCP_TSGO_BIN}:{}})]:process.env.LENSMCP_TYPECHECK==="off"?[]:[new fork_ts_check_reporter_1.ForkTsCheckReporterPlugin({appName:r.appName,tsConfig:o,workspaceRoot:s})]],snapshot:{managedPaths:[/^(.+?[\\/])?node_modules[\\/]/]},watch:!0,watchOptions:{ignored:["**/*.env.template","**/config.template.json","**/*.md","**/dist/**","**/migrations/**"]}};if(b){const t=require(path.resolve(e,b));return(t.default||t)(y)}return y}p(createDevWebpackConfig,"createDevWebpackConfig"),c(createDevWebpackConfig,"createDevWebpackConfig");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var i=(r,t)=>g(r,"name",{value:t,configurable:!0});var u=Object.defineProperty,c=i((r,t)=>u(r,"name",{value:t,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=gatewayExecutor;const kept_settings_1=require("./runtime/kept-settings"),gateway_lib_1=require("./gateway.lib"),own_log_1=require("./runtime/own-log"),project_graph_store_1=require("./runtime/project-graph-store"),server_1=require("./runtime/server");async function gatewayExecutor(r,t){const p=(0,own_log_1.takeOverGatewayLog)();p&&console.log(`[gateway] ${new Date().toISOString()} writing ${p.file} itself (pid ${process.pid}) \u2014 a line a full disk refuses is counted, and the next line that lands says how many were lost`),kept_settings_1.KEPT_AT_START.length&&console.log(`[gateway] settings kept for this checkout and this machine: ${kept_settings_1.KEPT_AT_START.map(e=>`${e}=${process.env[e]}`).join(" ")} (Settings; a variable set in the environment wins)`),process.on("uncaughtException",e=>{if((e.syscall==="read"||e.syscall==="write")&&server_1.BENIGN_SOCKET_ERRNOS.has(e.code??"")){console.warn(`[gateway] survived a stray socket ${e.syscall} error (${e.code}) \u2014 one connection dropped, the daemon lives`);return}console.error(e),process.exit(1)});let l;try{const e=(0,project_graph_store_1.createProjectGraphStore)(t.root,()=>(0,project_graph_store_1.computeProjectGraphInProcess)(t.root)),o=(await e.refresh())?.projectGraph,s=o?Object.fromEntries(Object.entries(o.dependencies).map(([n,a])=>[n,a.map(d=>d.target)])):void 0;l=await(0,gateway_lib_1.startGateway)(r,{...t,...s?{projectDependencies:s}:{},projectGraphStore:e})}catch(e){return console.error(e.message),{success:!1}}return new Promise(e=>{let o=!1;const s=c(n=>{if(o)return;o=!0;let a=!0;try{process.kill(process.ppid,0)}catch{a=!1}console.log(`[gateway] received ${n} (pid ${process.pid}, parent ${process.ppid} ${a?"alive":"gone \u2014 orphaned"}) \u2014 shutting down`),l.stop().then(()=>e({success:!0}))},"stop");process.on("SIGINT",()=>s("SIGINT")),process.on("SIGTERM",()=>s("SIGTERM"))})}i(gatewayExecutor,"gatewayExecutor"),c(gatewayExecutor,"gatewayExecutor"),module.exports=gatewayExecutor,module.exports.default=gatewayExecutor,module.exports.startGateway=gateway_lib_1.startGateway;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What this checkout and this machine keep as settings (planning/modules/03-settings-pages.md), put in the gateway's
|
|
3
|
+
* own environment before anything of the gateway reads it: several of its knobs are read once, when their module
|
|
4
|
+
* loads (`types.ts` — cold starts, a pod's age, the first-byte wait). So `gateway.impl.ts` imports this first.
|
|
5
|
+
*
|
|
6
|
+
* A variable the shell or a dotenv file set is left as it is. What is put here is marked (`LENSMCP_KEPT_SETTINGS`),
|
|
7
|
+
* so each process the gateway starts gets its own checkout's settings instead (`podBaseEnv`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const KEPT_AT_START: readonly string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.KEPT_AT_START=void 0;const settings_1=require("@lensmcp/core/settings");exports.KEPT_AT_START=(()=>{try{return(0,settings_1.applyKeptSettings)(process.env.NX_WORKSPACE_ROOT||process.cwd())}catch{return[]}})();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)){const
|
|
1
|
+
"use strict";var i=Object.defineProperty;var a=(t,e)=>i(t,"name",{value:e,configurable:!0});var c=Object.defineProperty,r=a((t,e)=>c(t,"name",{value:e,configurable:!0}),"r");Object.defineProperty(exports,"__esModule",{value:!0}),exports.FOREIGN_POD_ENV_DENYLIST=exports.WORKSPACE_DOTENV_FILES=void 0,exports.parseDotenvKeys=parseDotenvKeys,exports.workspaceDotenvKeys=workspaceDotenvKeys,exports.scrubEnv=scrubEnv,exports.podBaseEnv=podBaseEnv;const tslib_1=require("tslib"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),settings_1=require("@lensmcp/core/settings");exports.WORKSPACE_DOTENV_FILES=[".env",".env.local",".local.env"],exports.FOREIGN_POD_ENV_DENYLIST=["PG_URL","REDIS_URL","DATABASE_URL","POSTGRES_URL"];function parseDotenvKeys(t){const e=new Set;for(const s of t.split(`
|
|
2
|
+
`)){const o=s.trim();if(!o||o.startsWith("#"))continue;const n=o.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=/);n&&e.add(n[1])}return e}a(parseDotenvKeys,"parseDotenvKeys"),r(parseDotenvKeys,"parseDotenvKeys");function workspaceDotenvKeys(t){const e=new Set;for(const s of exports.WORKSPACE_DOTENV_FILES){let o;try{o=fs.readFileSync(path.join(t,s),"utf8")}catch{continue}for(const n of parseDotenvKeys(o))e.add(n)}return e}a(workspaceDotenvKeys,"workspaceDotenvKeys"),r(workspaceDotenvKeys,"workspaceDotenvKeys");function scrubEnv(t,e){const s={};for(const[o,n]of Object.entries(t))e.has(o)||exports.FOREIGN_POD_ENV_DENYLIST.includes(o)||(s[o]=n);return s}a(scrubEnv,"scrubEnv"),r(scrubEnv,"scrubEnv");function podBaseEnv(t,e,s){const o=path.resolve(s)===path.resolve(e)?t:scrubEnv(t,workspaceDotenvKeys(e));try{return(0,settings_1.withKeptSettings)(s,o,t)}catch{return o}}a(podBaseEnv,"podBaseEnv"),r(podBaseEnv,"podBaseEnv");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lensmcp/cluster",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.49",
|
|
4
4
|
"description": "Run your Nx workspace as a local production cluster: pods on unix sockets with true HMR, one https gateway with per-project domains, scale-from-zero, autoscale, idle-kill, local-CA TLS — observed by the LensMCP lens.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@lensmcp/core": "1.25.
|
|
62
|
-
"@lensmcp/node-instrumentation": "1.25.
|
|
63
|
-
"@lensmcp/nx-plugin": "1.25.
|
|
61
|
+
"@lensmcp/core": "1.25.49",
|
|
62
|
+
"@lensmcp/node-instrumentation": "1.25.49",
|
|
63
|
+
"@lensmcp/nx-plugin": "1.25.49",
|
|
64
64
|
"fastify": "^5.8.5",
|
|
65
65
|
"@fastify/reply-from": "^12.6.2",
|
|
66
66
|
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|
package/shared-build/attach.d.ts
CHANGED
|
@@ -49,8 +49,8 @@ export interface AttachedTypecheckOptions {
|
|
|
49
49
|
* is this process's:
|
|
50
50
|
*
|
|
51
51
|
* - `off`: none.
|
|
52
|
-
* - `tsgo
|
|
53
|
-
* -
|
|
52
|
+
* - `tsgo` (the default, unset included): TsgoCheckPlugin, scheduled after each of this service's builds without errors.
|
|
53
|
+
* - `tsc` (any other text): fork-ts-checker, on a compiler with no entries that exists to watch: fork-ts-checker re-checks on
|
|
54
54
|
* the watcher's changed files and adds its program's files to what it watches. Its program lists only the
|
|
55
55
|
* tsconfig's own files, so the build host's file list for this bundle (`files`) is watched too — a library
|
|
56
56
|
* save re-checks every service that compiles it, as before.
|
package/shared-build/attach.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var k=(e,t)=>y(e,"name",{value:t,configurable:!0});var _=Object.defineProperty,o=k((e,t)=>_(e,"name",{value:t,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.JOIN_TIMEOUT_MS=void 0,exports.sharedBuildOffered=sharedBuildOffered,exports.joinSharedBuild=joinSharedBuild,exports.createAttachedTypecheck=createAttachedTypecheck;const tslib_1=require("tslib"),path=tslib_1.__importStar(require("node:path")),config_files_1=require("../config-files"),fork_ts_check_reporter_1=require("../fork-ts-check-reporter"),tsgo_check_plugin_1=require("../tsgo-check-plugin"),protocol_1=require("./protocol");exports.JOIN_TIMEOUT_MS=12e4;function sharedBuildOffered(e=process.env,t=process){return e[protocol_1.SHARED_BUILD_ENV]==="1"&&typeof t.send=="function"}k(sharedBuildOffered,"sharedBuildOffered"),o(sharedBuildOffered,"sharedBuildOffered");function joinSharedBuild(e,t={}){const c=t.proc??process,r=t.timeoutMs??exports.JOIN_TIMEOUT_MS;return new Promise(n=>{const p=[];let l,f=!1;const a=o(i=>{if(!(0,protocol_1.isRunnerInbound)(i))return;const d=i.event;if(!f)return d.type==="refused"?h({kind:"refused",reason:d.reason}):d.type!=="accepted"?void 0:h({kind:"attached",session:u(d)});l?l(d):p.push(d)},"onMessage"),s=o(()=>{c.removeListener("message",a)},"close"),u=o(i=>({accepted:i,listen(d){l=d;for(const w of p.splice(0))d(w)},close:s}),"makeSession"),h=o(i=>{f||(f=!0,clearTimeout(g),i.kind==="refused"&&s(),n(i))},"finish"),g=setTimeout(()=>h({kind:"refused",reason:`the build host did not answer within ${Math.round(r/1e3)} s`}),r);g.unref?.(),c.on("message",a);const m={channel:protocol_1.SHARED_BUILD_CHANNEL,type:"join",join:e};try{c.send?.(m,void 0,void 0,i=>{i&&h({kind:"refused",reason:`could not reach the gateway (${i.message})`})})}catch(i){h({kind:"refused",reason:`could not reach the gateway (${i.message})`})}})}k(joinSharedBuild,"joinSharedBuild"),o(joinSharedBuild,"joinSharedBuild");function createAttachedTypecheck(e){const t=e.env??process.env,c=t
|
|
1
|
+
"use strict";var y=Object.defineProperty;var k=(e,t)=>y(e,"name",{value:t,configurable:!0});var _=Object.defineProperty,o=k((e,t)=>_(e,"name",{value:t,configurable:!0}),"o");Object.defineProperty(exports,"__esModule",{value:!0}),exports.JOIN_TIMEOUT_MS=void 0,exports.sharedBuildOffered=sharedBuildOffered,exports.joinSharedBuild=joinSharedBuild,exports.createAttachedTypecheck=createAttachedTypecheck;const tslib_1=require("tslib"),path=tslib_1.__importStar(require("node:path")),config_files_1=require("../config-files"),fork_ts_check_reporter_1=require("../fork-ts-check-reporter"),tsgo_check_plugin_1=require("../tsgo-check-plugin"),protocol_1=require("./protocol");exports.JOIN_TIMEOUT_MS=12e4;function sharedBuildOffered(e=process.env,t=process){return e[protocol_1.SHARED_BUILD_ENV]==="1"&&typeof t.send=="function"}k(sharedBuildOffered,"sharedBuildOffered"),o(sharedBuildOffered,"sharedBuildOffered");function joinSharedBuild(e,t={}){const c=t.proc??process,r=t.timeoutMs??exports.JOIN_TIMEOUT_MS;return new Promise(n=>{const p=[];let l,f=!1;const a=o(i=>{if(!(0,protocol_1.isRunnerInbound)(i))return;const d=i.event;if(!f)return d.type==="refused"?h({kind:"refused",reason:d.reason}):d.type!=="accepted"?void 0:h({kind:"attached",session:u(d)});l?l(d):p.push(d)},"onMessage"),s=o(()=>{c.removeListener("message",a)},"close"),u=o(i=>({accepted:i,listen(d){l=d;for(const w of p.splice(0))d(w)},close:s}),"makeSession"),h=o(i=>{f||(f=!0,clearTimeout(g),i.kind==="refused"&&s(),n(i))},"finish"),g=setTimeout(()=>h({kind:"refused",reason:`the build host did not answer within ${Math.round(r/1e3)} s`}),r);g.unref?.(),c.on("message",a);const m={channel:protocol_1.SHARED_BUILD_CHANNEL,type:"join",join:e};try{c.send?.(m,void 0,void 0,i=>{i&&h({kind:"refused",reason:`could not reach the gateway (${i.message})`})})}catch(i){h({kind:"refused",reason:`could not reach the gateway (${i.message})`})}})}k(joinSharedBuild,"joinSharedBuild"),o(joinSharedBuild,"joinSharedBuild");function createAttachedTypecheck(e){const t=e.env??process.env,c=(0,tsgo_check_plugin_1.typecheckMode)(t);if(c==="off")return{built:o(()=>{},"built"),dispose:o(()=>{},"dispose")};if(c==="tsgo"){if((0,tsgo_check_plugin_1.resolveTsgoBin)(e.workspaceRoot,t.LENSMCP_TSGO_BIN)){const n=new tsgo_check_plugin_1.TsgoCheckPlugin({appName:e.appName,tsConfig:e.tsConfig,workspaceRoot:e.workspaceRoot,...t.LENSMCP_TSGO_BIN?{binPath:t.LENSMCP_TSGO_BIN}:{}}),p=[];n.apply({hooks:{done:{tap:o((a,s)=>p.push(s),"tap")}}});let l;const f=watchTypecheckConfig(e,a=>{l&&(console.log(`[serve] ${e.appName}: ${a} changed \u2014 type-checking again`),n.schedule())});return{built:o(a=>{l=a.ok;for(const s of p)s({hasErrors:o(()=>!a.ok,"hasErrors")})},"built"),dispose:o(()=>{f.close(),n.dispose()},"dispose")}}const r=`${tsgo_check_plugin_1.TSGO_MISSING_CAUSE}. Fell back to fork-ts-checker, which reports to the console only \u2014 so typecheck:// has no producer for this project until it is fixed`;console.warn(`[serve] ${e.appName}: the type checker is tsgo but ${r}.`),(0,tsgo_check_plugin_1.reportTsgoUnavailable)({appName:e.appName,tsConfig:e.tsConfig,workspaceRoot:e.workspaceRoot,detail:r})}return forkTsCheckerOnItsOwn(e)}k(createAttachedTypecheck,"createAttachedTypecheck"),o(createAttachedTypecheck,"createAttachedTypecheck");function forkTsCheckerOnItsOwn(e){const t=(0,fork_ts_check_reporter_1.loadForkTsChecker)(e.workspaceRoot),c=t?.default??t;if(typeof c!="function")return console.warn(`[serve] ${e.appName}: fork-ts-checker-webpack-plugin is not installed \u2014 this service is not type-checked`),{built:o(()=>{},"built"),dispose:o(()=>{},"dispose")};let r=[],n,p=!1;const l=o(()=>{try{n?.close(()=>{})}catch{}n=void 0},"close"),f=watchTypecheckConfig(e,s=>{p||!n||(console.log(`[serve] ${e.appName}: ${s} changed \u2014 type-checking again with a new fork-ts-checker`),l(),a())}),a=o(()=>{n=require("webpack")({mode:"development",context:e.workspaceRoot,entry:{},infrastructureLogging:{level:"info"},plugins:[{apply(s){s.hooks.afterCompile.tapPromise("LensmcpAttachedTypecheck",()=>new Promise(u=>setTimeout(u,0))),s.hooks.afterCompile.tap("LensmcpAttachedTypecheck",u=>{for(const h of r)u.fileDependencies.add(h)})}},new c({async:!0,typescript:{configFile:e.tsConfig,memoryLimit:e.memoryLimit}}),new fork_ts_check_reporter_1.ForkTsCheckReporterPlugin({appName:e.appName,tsConfig:e.tsConfig,workspaceRoot:e.workspaceRoot})]}).watch({ignored:["**/node_modules/**",`${path.join(e.workspaceRoot,"dist")}/**`]},()=>{})},"start");return{built(s){if(p)return;const u=s.files&&s.files.join(`
|
|
2
2
|
`)!==r.join(`
|
|
3
3
|
`);s.files&&(r=[...s.files]),n?u&&n.invalidate():a()},dispose(){p=!0,f.close(),l()}}}k(forkTsCheckerOnItsOwn,"forkTsCheckerOnItsOwn"),o(forkTsCheckerOnItsOwn,"forkTsCheckerOnItsOwn");function watchTypecheckConfig(e,t){return(0,config_files_1.watchConfigFiles)({files:o(()=>(0,tsgo_check_plugin_1.tsconfigChain)(e.tsConfig),"files"),changed:o(c=>t(c.map(r=>path.relative(e.workspaceRoot,r)||r).join(", ")),"changed"),...e.configPollMs!==void 0?{intervalMs:e.configPollMs}:{}})}k(watchTypecheckConfig,"watchTypecheckConfig"),o(watchTypecheckConfig,"watchTypecheckConfig");
|
package/tsgo-check-plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* TsgoCheckPlugin — dev type checking with ZERO resident memory (`LENSMCP_TYPECHECK
|
|
2
|
+
* TsgoCheckPlugin — dev type checking with ZERO resident memory, the default (`LENSMCP_TYPECHECK` unset or `tsgo`).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* fork-ts-checker (`LENSMCP_TYPECHECK=tsc`, the default before 1.25.49) keeps an incremental tsc PROGRAM resident between saves — a
|
|
5
5
|
* 2-worker pair (~80MB+) per service, ~1GB across a 13-service cluster, alive even when nobody
|
|
6
6
|
* saves. tsgo (@typescript/native-preview, the native TS compiler) full-checks one of these
|
|
7
7
|
* services cold in ~1-3s, so instead of holding a program we re-check COLD after each successful
|
|
@@ -46,7 +46,8 @@
|
|
|
46
46
|
* `module: preserve` + `emitDecoratorMetadata` otherwise flags TS1272 on decorated signatures —
|
|
47
47
|
* an emit-safety rule that doesn't apply here (this checker never emits; webpack owns emit).
|
|
48
48
|
* Parity was verified per adopting workspace (0-error parity with tsc on all spot-checked apps);
|
|
49
|
-
* tsgo is a PREVIEW compiler,
|
|
49
|
+
* tsgo is a PREVIEW compiler; it was opt-in until the queue, the memory hold and incremental checks made it the safer
|
|
50
|
+
* default (1.25.49) — `LENSMCP_TYPECHECK=tsc` keeps fork-ts-checker for a workspace that needs it.
|
|
50
51
|
*
|
|
51
52
|
* OWNERSHIP: `@lensmcp/cluster` DEPENDS on `@typescript/native-preview` — this is our feature, so we
|
|
52
53
|
* ship the compiler that powers it rather than asking every consumer to remember a devDep. That was
|
|
@@ -94,6 +95,13 @@ export declare function tsgoBuildInfoPath(appName: string, workspaceRoot: string
|
|
|
94
95
|
/** The checker's arguments. `--pretty false` is the output contract (see the header); the build info is optional. */
|
|
95
96
|
export declare function tsgoCheckArgs(shimPath: string, buildInfo?: string): string[];
|
|
96
97
|
/** The npm package that ships the tsgo compiler — a real `dependency` of `@lensmcp/cluster`. */
|
|
98
|
+
/**
|
|
99
|
+
* The checker `LENSMCP_TYPECHECK` asks for (planning/modules/03-settings-pages.md): `tsgo` unless it says otherwise —
|
|
100
|
+
* unset and empty included — `off`, or `tsc` (fork-ts-checker) for any other text. tsgo became the default in 1.25.49:
|
|
101
|
+
* fork-ts-checker holds a whole program per service (2–3 GB each on FoodGuard), and a worktree whose `.env` lost the
|
|
102
|
+
* variable ran one per service until the machine swapped (2026-11-02). Settings › Type checking keeps it.
|
|
103
|
+
*/
|
|
104
|
+
export declare function typecheckMode(env?: NodeJS.ProcessEnv): 'tsgo' | 'off' | 'tsc';
|
|
97
105
|
export declare const TSGO_PACKAGE = "@typescript/native-preview";
|
|
98
106
|
/** Seams for {@link resolveTsgoBin}, so every branch of the precedence is testable without an install. */
|
|
99
107
|
export interface TsgoResolutionDeps {
|
package/tsgo-check-plugin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var
|
|
2
|
-
`&&(n=!1,t+=r);continue}if(s){r==="*"&&
|
|
1
|
+
"use strict";var k=Object.defineProperty;var l=(e,t)=>k(e,"name",{value:t,configurable:!0});var b=Object.defineProperty,c=l((e,t)=>b(e,"name",{value:t,configurable:!0}),"c");Object.defineProperty(exports,"__esModule",{value:!0}),exports.TsgoCheckPlugin=exports.TSGO_MISSING_CAUSE=exports.TSGO_PACKAGE=void 0,exports.checkerMaxProcs=checkerMaxProcs,exports.tsgoIncremental=tsgoIncremental,exports.tsgoBuildInfoPath=tsgoBuildInfoPath,exports.tsgoCheckArgs=tsgoCheckArgs,exports.typecheckMode=typecheckMode,exports.resolveTsgoPackageDir=resolveTsgoPackageDir,exports.resolveTsgoBin=resolveTsgoBin,exports.reportTsgoUnavailable=reportTsgoUnavailable,exports.effectivePaths=effectivePaths,exports.tsconfigChain=tsconfigChain,exports.writeShimTsconfig=writeShimTsconfig;const tslib_1=require("tslib"),node_child_process_1=require("node:child_process"),fs=tslib_1.__importStar(require("node:fs")),path=tslib_1.__importStar(require("node:path")),typecheck_bus_1=require("./typecheck-bus"),typecheck_queue_1=require("./typecheck-queue"),DEFAULT_TIMEOUT_MS=12e4,DEFAULT_MAX_PROCS=4;function checkerMaxProcs(e=process.env){const t=Number(e.LENSMCP_TYPECHECK_GOMAXPROCS);return Number.isInteger(t)&&t>=1?t:DEFAULT_MAX_PROCS}l(checkerMaxProcs,"checkerMaxProcs"),c(checkerMaxProcs,"checkerMaxProcs");function tsgoIncremental(e=process.env){const t=(e.LENSMCP_TSGO_INCREMENTAL??"").trim().toLowerCase();return!(t==="0"||t==="false"||t==="off"||t==="no")}l(tsgoIncremental,"tsgoIncremental"),c(tsgoIncremental,"tsgoIncremental");function tsgoBuildInfoPath(e,t){return path.join(t,"tmp","lensmcp-tsgo",`${e}.tsbuildinfo`)}l(tsgoBuildInfoPath,"tsgoBuildInfoPath"),c(tsgoBuildInfoPath,"tsgoBuildInfoPath");function tsgoCheckArgs(e,t){return["--noEmit","--pretty","false",...t?["--incremental","--tsBuildInfoFile",t]:[],"-p",e]}l(tsgoCheckArgs,"tsgoCheckArgs"),c(tsgoCheckArgs,"tsgoCheckArgs");const livePlugins=new Set;let exitHooked=!1;function stopWithTheProcess(e){livePlugins.add(e),!exitHooked&&(exitHooked=!0,process.once("exit",()=>{for(const t of livePlugins)t.dispose()}))}l(stopWithTheProcess,"stopWithTheProcess"),c(stopWithTheProcess,"stopWithTheProcess");function typecheckMode(e=process.env){const t=e.LENSMCP_TYPECHECK;return t===void 0||t===""||t==="tsgo"?"tsgo":t==="off"?"off":"tsc"}l(typecheckMode,"typecheckMode"),c(typecheckMode,"typecheckMode"),exports.TSGO_PACKAGE="@typescript/native-preview";function shimNames(e){return e==="win32"?["tsgo.cmd","tsgo.exe"]:["tsgo"]}l(shimNames,"shimNames"),c(shimNames,"shimNames");function isExecutableFile(e,t){try{if(!fs.statSync(e).isFile())return!1}catch{return!1}if(t==="win32")return!0;try{return fs.accessSync(e,fs.constants.X_OK),!0}catch{return!1}}l(isExecutableFile,"isExecutableFile"),c(isExecutableFile,"isExecutableFile");function resolveTsgoPackageDir(){try{return path.dirname(require.resolve(`${exports.TSGO_PACKAGE}/package.json`))}catch{}try{let e=path.dirname(require.resolve(exports.TSGO_PACKAGE));for(let t=0;t<6;t++){const o=path.join(e,"package.json");if(fs.existsSync(o))try{const{name:s}=JSON.parse(fs.readFileSync(o,"utf8"));if(s===exports.TSGO_PACKAGE)return e}catch{}const n=path.dirname(e);if(n===e)break;e=n}}catch{}return null}l(resolveTsgoPackageDir,"resolveTsgoPackageDir"),c(resolveTsgoPackageDir,"resolveTsgoPackageDir");function packageDeclaredBin(e){try{const{bin:t}=JSON.parse(fs.readFileSync(path.join(e,"package.json"),"utf8")),o=typeof t=="string"?t:t?.tsgo;return o?path.join(e,o):null}catch{return null}}l(packageDeclaredBin,"packageDeclaredBin"),c(packageDeclaredBin,"packageDeclaredBin");function ownBinCandidates(e,t){const o=path.resolve(e,"..","..",".bin"),n=shimNames(t).map(i=>path.join(o,i)),s=t==="win32"?null:packageDeclaredBin(e);return s?[s,...n]:n}l(ownBinCandidates,"ownBinCandidates"),c(ownBinCandidates,"ownBinCandidates");function resolveTsgoBin(e,t,o={}){const n=o.platform??process.platform,s=o.isExecutable??(r=>isExecutableFile(r,n));if(t)return s(t)?t:null;for(const r of shimNames(n)){const a=path.join(e,"node_modules",".bin",r);if(s(a))return a}const i=(o.ownPackageDir??resolveTsgoPackageDir)();return i?ownBinCandidates(i,n).find(s)??null:null}l(resolveTsgoBin,"resolveTsgoBin"),c(resolveTsgoBin,"resolveTsgoBin"),exports.TSGO_MISSING_CAUSE=`tsgo binary not found \u2014 @lensmcp/cluster depends on ${exports.TSGO_PACKAGE}, so an absent binary means an incomplete install (reinstall node_modules), a platform with no ${exports.TSGO_PACKAGE} build, or a LENSMCP_TSGO_BIN override pointing at a missing or non-executable file`;function reportTsgoUnavailable(e){try{(0,typecheck_bus_1.publishTypecheckRun)({workspaceRoot:e.workspaceRoot,project:e.appName,tool:"tsgo",tsConfig:e.tsConfig,output:"",durationMs:0,toolError:e.detail,...e.eventFile?{eventFile:e.eventFile}:{}})}catch{}}l(reportTsgoUnavailable,"reportTsgoUnavailable"),c(reportTsgoUnavailable,"reportTsgoUnavailable");function parseJsonc(e){let t="",o=!1,n=!1,s=!1;for(let i=0;i<e.length;i++){const r=e[i],a=e[i+1];if(n){r===`
|
|
2
|
+
`&&(n=!1,t+=r);continue}if(s){r==="*"&&a==="/"&&(s=!1,i++);continue}if(o){t+=r,r==="\\"?(t+=a??"",i++):r==='"'&&(o=!1);continue}if(r==='"'){o=!0,t+=r;continue}if(r==="/"&&a==="/"){n=!0,i++;continue}if(r==="/"&&a==="*"){s=!0,i++;continue}t+=r}try{return JSON.parse(t.replace(/,(\s*[}\]])/g,"$1"))}catch{return null}}l(parseJsonc,"parseJsonc"),c(parseJsonc,"parseJsonc");function resolveExtends(e,t){if(!e.startsWith(".")&&!path.isAbsolute(e))return null;const o=path.isAbsolute(e)?e:path.resolve(t,e);for(const n of[o,`${o}.json`,path.join(o,"tsconfig.json")])try{if(fs.statSync(n).isFile())return n}catch{}return null}l(resolveExtends,"resolveExtends"),c(resolveExtends,"resolveExtends");function effectivePaths(e,t=new Set){if(t.has(e))return null;t.add(e);let o;try{o=fs.readFileSync(e,"utf8")}catch{return null}const n=parseJsonc(o);if(!n)return null;const s=path.dirname(e),i=n.compilerOptions??{},r=Array.isArray(n.extends)?n.extends.filter(p=>typeof p=="string"):typeof n.extends=="string"?[n.extends]:[],a=c(()=>{for(const p of[...r].reverse()){const d=resolveExtends(p,s);if(!d)continue;const f=effectivePaths(d,t);if(f)return f}return null},"inherited"),u=i.paths,h=typeof i.baseUrl=="string"?path.resolve(s,i.baseUrl):void 0;if(!u){const p=a();return p?{paths:p.paths,anchorDir:h??p.anchorDir}:null}return{paths:u,anchorDir:h??a()?.anchorDir??s}}l(effectivePaths,"effectivePaths"),c(effectivePaths,"effectivePaths");function tsconfigChain(e){const t=[],o=c(n=>{if(t.includes(n))return;t.push(n);let s;try{s=parseJsonc(fs.readFileSync(n,"utf8"))}catch{return}const i=s?.extends,r=Array.isArray(i)?i.filter(a=>typeof a=="string"):typeof i=="string"?[i]:[];for(const a of r){const u=resolveExtends(a,path.dirname(n));u&&!u.split(path.sep).includes("node_modules")&&o(u)}},"visit");return o(path.resolve(e)),t}l(tsconfigChain,"tsconfigChain"),c(tsconfigChain,"tsconfigChain");function writeShimTsconfig(e,t,o){const n=path.join(o,"tmp","lensmcp-tsgo");fs.mkdirSync(n,{recursive:!0});const s=path.join(n,`${e}.tsconfig.json`),i=effectivePaths(t),r=i?Object.fromEntries(Object.entries(i.paths).map(([h,p])=>[h,(Array.isArray(p)?p:[]).map(d=>path.isAbsolute(d)?d:path.resolve(i.anchorDir,d))])):void 0,a=JSON.stringify({extends:t,compilerOptions:{module:"preserve",moduleResolution:"bundler",isolatedModules:!1,baseUrl:null,...r&&Object.keys(r).length?{paths:r}:{}}},null,2);let u;try{u=fs.readFileSync(s,"utf8")}catch{}return u!==a&&fs.writeFileSync(s,a),s}l(writeShimTsconfig,"writeShimTsconfig"),c(writeShimTsconfig,"writeShimTsconfig");class TsgoCheckPlugin{static{l(this,"TsgoCheckPlugin")}static{c(this,"TsgoCheckPlugin")}constructor(t){this.timer=null,this.phase="idle",this.dirty=!1,this.ticket=null,this.inflight=null,this.askedAt=0,this.shimPath=null,this.disabled=!1,this.disposed=!1,this.opts=t,this.spawnImpl=t.spawnImpl??node_child_process_1.spawn,this.queue=t.queue??(0,typecheck_queue_1.machineTypecheckQueue)(),this.buildInfo=t.incremental??tsgoIncremental()?tsgoBuildInfoPath(t.appName,t.workspaceRoot):void 0}apply(t){t.hooks.done.tap("TsgoCheckPlugin",o=>{o.hasErrors()||this.schedule()}),t.hooks.shutdown?.tap?.("TsgoCheckPlugin",()=>this.dispose()),t.hooks.watchClose?.tap?.("TsgoCheckPlugin",()=>this.dispose()),stopWithTheProcess(this)}schedule(){this.disabled||this.disposed||(this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.request(),this.opts.debounceMs??500),this.timer.unref?.())}request(){if(this.disabled||this.disposed)return;if(this.phase==="running"){this.dirty=!0;return}if(this.phase==="waiting")return;this.phase="waiting",this.askedAt=Date.now();const t=this.queue(this.opts.appName,()=>this.run(),{onHold:c(o=>this.held(o),"onHold")});this.isIdle()?t.release():this.ticket=t}held(t){if(!this.disposed&&(console.log(`[tsgo] ${this.opts.appName}: check held \u2014 ${t.availableMb} MB free, it waits for ${t.minFreeMb} MB (LENSMCP_TYPECHECK_MIN_FREE_MB)`),this.opts.publishEvents!==!1))try{(0,typecheck_bus_1.publishTypecheckHeld)({workspaceRoot:this.opts.workspaceRoot,project:this.opts.appName,tool:"tsgo",tsConfig:this.opts.tsConfig,availableMb:t.availableMb,minFreeMb:t.minFreeMb,...this.opts.eventFile?{eventFile:this.opts.eventFile}:{}})}catch{}}forgetBuildInfo(){if(this.buildInfo)try{fs.rmSync(this.buildInfo,{force:!0})}catch{}}isIdle(){return this.phase==="idle"}publish(t){if(this.opts.publishEvents!==!1)try{(0,typecheck_bus_1.publishTypecheckRun)({workspaceRoot:this.opts.workspaceRoot,project:this.opts.appName,tool:"tsgo",tsConfig:this.opts.tsConfig,output:t.output,durationMs:t.durationMs,...t.toolError?{toolError:t.toolError}:{},...this.opts.eventFile?{eventFile:this.opts.eventFile}:{}})}catch{}}run(){if(this.disposed)return this.leave();let t;try{t=resolveTsgoBin(this.opts.workspaceRoot,this.opts.binPath),t&&(this.shimPath=writeShimTsconfig(this.opts.appName,this.opts.tsConfig,this.opts.workspaceRoot))}catch(h){return console.warn(`[tsgo] ${this.opts.appName}: could not prepare the check \u2014 ${h.message}`),this.publish({output:"",durationMs:0,toolError:`could not prepare the check: ${h.message}`}),this.leave()}if(!t){this.disabled=!0;const h=`${exports.TSGO_MISSING_CAUSE}. Type checking is disabled for the rest of this session`;return console.warn(`[tsgo] ${this.opts.appName}: ${h}.`),this.publish({output:"",durationMs:0,toolError:h}),this.leave()}this.phase="running",this.dirty=!1;const o=Date.now(),n=o-this.askedAt,s=this.spawnImpl(t,tsgoCheckArgs(this.shimPath,this.buildInfo),{cwd:this.opts.workspaceRoot,stdio:["ignore","pipe","pipe"],env:{...process.env,GOMAXPROCS:process.env.GOMAXPROCS??String(this.opts.maxProcs??checkerMaxProcs())}});this.inflight=s;let i="",r=!1;const a=this.opts.timeoutMs??DEFAULT_TIMEOUT_MS,u=setTimeout(()=>{r=!0,s.kill("SIGKILL")},a);u.unref?.(),s.stdout?.on("data",h=>{i+=h.toString()}),s.stderr?.on("data",h=>{i+=h.toString()}),s.on("error",()=>{clearTimeout(u),this.inflight===s&&(console.warn(`[tsgo] ${this.opts.appName}: failed to spawn ${t}`),this.forgetBuildInfo(),this.publish({output:"",durationMs:Date.now()-o,toolError:`failed to spawn ${t}`}),this.finish(s))}),s.on("close",(h,p)=>{if(clearTimeout(u),this.inflight!==s)return;const d=Date.now()-o,f=(d/1e3).toFixed(1),m=n>=1e3?`${f}s, waited ${(n/1e3).toFixed(1)}s`:`${f}s`;if(this.disposed)return this.finish(s);if(r){const y=`the check was killed after ${Math.round(a/1e3)}s without finishing`;return console.warn(`[tsgo] ${this.opts.appName}: ${y} \u2014 no verdict.`),this.forgetBuildInfo(),this.publish({output:"",durationMs:d,toolError:y}),this.finish(s)}if(p)return this.forgetBuildInfo(),this.finish(s);if(h===0)return console.log(`[tsgo] ${this.opts.appName}: types clean (${m})`),this.publish({output:"",durationMs:d}),this.finish(s);i.trim()&&process.stdout.write(i.endsWith(`
|
|
3
3
|
`)?i:`${i}
|
|
4
4
|
`);const g=(i.match(/error TS\d+/g)??[]).length;console.log(`[tsgo] ${this.opts.appName}: ${g} type error${g===1?"":"s"} (${m})`),g===0&&this.forgetBuildInfo(),this.publish({output:i,durationMs:d,...g===0?{toolError:`tsgo exited ${h} with no diagnostics: ${firstLine(i)}`}:{}}),this.finish(s)})}finish(t){this.inflight===t&&(this.inflight=null),this.leave(),this.dirty&&!this.disposed&&(this.dirty=!1,this.request())}leave(){this.phase="idle",this.ticket?.release(),this.ticket=null}dispose(){this.disposed||(this.disposed=!0,livePlugins.delete(this),this.timer&&clearTimeout(this.timer),this.inflight&&(this.inflight.kill("SIGKILL"),this.forgetBuildInfo()),this.ticket?.release(),this.ticket=null)}}exports.TsgoCheckPlugin=TsgoCheckPlugin;function firstLine(e){return e.trim().split(`
|
|
5
|
-
`)[0]?.slice(0,300)??""}
|
|
5
|
+
`)[0]?.slice(0,300)??""}l(firstLine,"firstLine"),c(firstLine,"firstLine");
|