ttsc 0.6.0 → 0.7.0

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.
Files changed (261) hide show
  1. package/cmd/ttsc/api_compile.go +134 -0
  2. package/cmd/ttsc/build.go +1 -7
  3. package/cmd/ttsc/main.go +2 -2
  4. package/cmd/ttsc/transform.go +0 -6
  5. package/driver/program.go +11 -1
  6. package/lib/TtscCompiler.d.ts +76 -0
  7. package/lib/TtscCompiler.js +245 -0
  8. package/lib/TtscCompiler.js.map +1 -0
  9. package/lib/compiler/internal/buildNativeCompiler.d.ts +6 -0
  10. package/lib/compiler/internal/buildNativeCompiler.js +72 -0
  11. package/lib/compiler/internal/buildNativeCompiler.js.map +1 -0
  12. package/lib/compiler/internal/compileProjectInMemory.d.ts +7 -0
  13. package/lib/compiler/internal/compileProjectInMemory.js +176 -0
  14. package/lib/compiler/internal/compileProjectInMemory.js.map +1 -0
  15. package/lib/compiler/internal/project/readProjectConfig.d.ts +4 -0
  16. package/lib/{project.js → compiler/internal/project/readProjectConfig.js} +12 -82
  17. package/lib/compiler/internal/project/readProjectConfig.js.map +1 -0
  18. package/lib/compiler/internal/project/resolveProjectConfig.d.ts +3 -0
  19. package/lib/compiler/internal/project/resolveProjectConfig.js +94 -0
  20. package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -0
  21. package/lib/compiler/internal/resolveBinary.d.ts +4 -0
  22. package/lib/compiler/internal/resolveBinary.js +65 -0
  23. package/lib/compiler/internal/resolveBinary.js.map +1 -0
  24. package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +7 -0
  25. package/lib/compiler/internal/resolveEmittedJavaScript.js +118 -0
  26. package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -0
  27. package/lib/compiler/internal/resolveTsgo.d.ts +20 -0
  28. package/lib/{tsgo.js → compiler/internal/resolveTsgo.js} +5 -10
  29. package/lib/compiler/internal/resolveTsgo.js.map +1 -0
  30. package/lib/compiler/internal/runBuild.d.ts +10 -0
  31. package/lib/compiler/internal/runBuild.js +480 -0
  32. package/lib/compiler/internal/runBuild.js.map +1 -0
  33. package/lib/compiler/internal/runTransform.d.ts +3 -0
  34. package/lib/compiler/internal/runTransform.js +100 -0
  35. package/lib/compiler/internal/runTransform.js.map +1 -0
  36. package/lib/index.d.ts +6 -15
  37. package/lib/index.js +6 -15
  38. package/lib/index.js.map +1 -1
  39. package/lib/launcher/internal/getCompilerVersionText.d.ts +3 -0
  40. package/lib/launcher/internal/getCompilerVersionText.js +71 -0
  41. package/lib/launcher/internal/getCompilerVersionText.js.map +1 -0
  42. package/lib/launcher/internal/prepareExecution.d.ts +10 -0
  43. package/lib/launcher/internal/prepareExecution.js +120 -0
  44. package/lib/launcher/internal/prepareExecution.js.map +1 -0
  45. package/lib/launcher/internal/runTtsc.d.ts +1 -0
  46. package/lib/{cli.js → launcher/internal/runTtsc.js} +48 -47
  47. package/lib/launcher/internal/runTtsc.js.map +1 -0
  48. package/lib/launcher/internal/runTtsx.d.ts +1 -0
  49. package/lib/{runner/cli.js → launcher/internal/runTtsx.js} +13 -35
  50. package/lib/launcher/internal/runTtsx.js.map +1 -0
  51. package/lib/launcher/ttsc.js +2 -2
  52. package/lib/launcher/ttsc.js.map +1 -1
  53. package/lib/launcher/ttsx.js +2 -2
  54. package/lib/launcher/ttsx.js.map +1 -1
  55. package/lib/plugin/internal/buildSourcePlugin.d.ts +12 -0
  56. package/lib/{source-build.js → plugin/internal/buildSourcePlugin.js} +77 -84
  57. package/lib/plugin/internal/buildSourcePlugin.js.map +1 -0
  58. package/lib/plugin/internal/loadProjectPlugins.d.ts +14 -0
  59. package/lib/{plugin.js → plugin/internal/loadProjectPlugins.js} +38 -76
  60. package/lib/plugin/internal/loadProjectPlugins.js.map +1 -0
  61. package/lib/structures/ITtscCompilerContext.d.ts +78 -0
  62. package/lib/structures/ITtscCompilerContext.js +3 -0
  63. package/lib/structures/ITtscCompilerContext.js.map +1 -0
  64. package/lib/structures/ITtscCompilerDiagnostic.d.ts +83 -0
  65. package/lib/structures/ITtscCompilerDiagnostic.js +3 -0
  66. package/lib/structures/ITtscCompilerDiagnostic.js.map +1 -0
  67. package/lib/structures/ITtscCompilerResult.d.ts +83 -0
  68. package/lib/structures/{ITtscCacheKeyInput.js → ITtscCompilerResult.js} +1 -1
  69. package/lib/structures/ITtscCompilerResult.js.map +1 -0
  70. package/lib/structures/ITtscPlugin.d.ts +52 -7
  71. package/lib/structures/ITtscPluginFactoryContext.d.ts +47 -0
  72. package/lib/structures/ITtscProjectPluginConfig.d.ts +41 -0
  73. package/lib/structures/TtscPluginStage.d.ts +15 -0
  74. package/lib/structures/{ITtscBuildResult.js → TtscPluginStage.js} +1 -1
  75. package/lib/structures/TtscPluginStage.js.map +1 -0
  76. package/lib/structures/index.d.ts +7 -0
  77. package/lib/structures/index.js +24 -0
  78. package/lib/structures/index.js.map +1 -0
  79. package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +13 -0
  80. package/lib/structures/internal/ITtscLoadedNativePlugin.js.map +1 -0
  81. package/lib/structures/internal/ITtscParsedProjectConfig.d.ts +15 -0
  82. package/lib/structures/internal/ITtscParsedProjectConfig.js.map +1 -0
  83. package/lib/structures/internal/ITtscProjectLocatorOptions.d.ts +9 -0
  84. package/lib/structures/internal/ITtscProjectLocatorOptions.js.map +1 -0
  85. package/lib/structures/internal/TtscBuildOptions.d.ts +18 -0
  86. package/lib/structures/{ITtscBuildOptions.js → internal/TtscBuildOptions.js} +1 -1
  87. package/lib/structures/internal/TtscBuildOptions.js.map +1 -0
  88. package/lib/structures/internal/TtscBuildResult.d.ts +14 -0
  89. package/lib/structures/{ITtscCheckOptions.js → internal/TtscBuildResult.js} +1 -1
  90. package/lib/structures/internal/TtscBuildResult.js.map +1 -0
  91. package/lib/structures/internal/TtscCommonOptions.d.ts +27 -0
  92. package/lib/structures/{ITtscNativeSource.js → internal/TtscCommonOptions.js} +1 -1
  93. package/lib/structures/internal/TtscCommonOptions.js.map +1 -0
  94. package/lib/structures/internal/TtscTransformOptions.d.ts +14 -0
  95. package/lib/structures/internal/TtscTransformOptions.js +3 -0
  96. package/lib/structures/internal/TtscTransformOptions.js.map +1 -0
  97. package/package.json +9 -9
  98. package/src/TtscCompiler.ts +241 -0
  99. package/src/compiler/internal/buildNativeCompiler.ts +43 -0
  100. package/src/compiler/internal/compileProjectInMemory.ts +189 -0
  101. package/src/{project.ts → compiler/internal/project/readProjectConfig.ts} +36 -111
  102. package/src/compiler/internal/project/resolveProjectConfig.ts +67 -0
  103. package/src/compiler/internal/resolveBinary.ts +41 -0
  104. package/src/compiler/internal/resolveEmittedJavaScript.ts +102 -0
  105. package/src/{tsgo.ts → compiler/internal/resolveTsgo.ts} +20 -23
  106. package/src/compiler/internal/runBuild.ts +644 -0
  107. package/src/compiler/internal/runTransform.ts +69 -0
  108. package/src/index.ts +6 -15
  109. package/src/launcher/internal/getCompilerVersionText.ts +44 -0
  110. package/src/launcher/internal/prepareExecution.ts +115 -0
  111. package/src/{cli.ts → launcher/internal/runTtsc.ts} +61 -70
  112. package/src/{runner/cli.ts → launcher/internal/runTtsx.ts} +21 -49
  113. package/src/launcher/ttsc.ts +2 -2
  114. package/src/launcher/ttsx.ts +2 -2
  115. package/src/{source-build.ts → plugin/internal/buildSourcePlugin.ts} +121 -115
  116. package/src/plugin/internal/loadProjectPlugins.ts +214 -0
  117. package/src/structures/ITtscCompilerContext.ts +84 -0
  118. package/src/structures/ITtscCompilerDiagnostic.ts +91 -0
  119. package/src/structures/ITtscCompilerResult.ts +94 -0
  120. package/src/structures/ITtscPlugin.ts +54 -7
  121. package/src/structures/ITtscPluginFactoryContext.ts +51 -0
  122. package/src/structures/ITtscProjectPluginConfig.ts +43 -0
  123. package/src/structures/TtscPluginStage.ts +15 -0
  124. package/src/structures/index.ts +7 -0
  125. package/src/structures/internal/ITtscLoadedNativePlugin.ts +14 -0
  126. package/src/structures/internal/ITtscParsedProjectConfig.ts +16 -0
  127. package/src/structures/internal/ITtscProjectLocatorOptions.ts +9 -0
  128. package/src/structures/internal/TtscBuildOptions.ts +19 -0
  129. package/src/structures/internal/TtscBuildResult.ts +15 -0
  130. package/src/structures/internal/TtscCommonOptions.ts +28 -0
  131. package/src/structures/internal/TtscTransformOptions.ts +15 -0
  132. package/test/compiler.test.ts +234 -0
  133. package/test/platform.test.ts +1 -45
  134. package/test/project.test.ts +3 -1
  135. package/test/source-build.test.ts +33 -220
  136. package/test/tsgo.test.ts +1 -8
  137. package/lib/api.d.ts +0 -40
  138. package/lib/api.js +0 -680
  139. package/lib/api.js.map +0 -1
  140. package/lib/cli.d.ts +0 -1
  141. package/lib/cli.js.map +0 -1
  142. package/lib/native.d.ts +0 -8
  143. package/lib/native.js +0 -42
  144. package/lib/native.js.map +0 -1
  145. package/lib/platform.d.ts +0 -52
  146. package/lib/platform.js +0 -175
  147. package/lib/platform.js.map +0 -1
  148. package/lib/plugin.d.ts +0 -13
  149. package/lib/plugin.js.map +0 -1
  150. package/lib/project.d.ts +0 -14
  151. package/lib/project.js.map +0 -1
  152. package/lib/runner/cli.d.ts +0 -1
  153. package/lib/runner/cli.js.map +0 -1
  154. package/lib/runner/register.d.ts +0 -6
  155. package/lib/runner/register.js +0 -358
  156. package/lib/runner/register.js.map +0 -1
  157. package/lib/source-build.d.ts +0 -19
  158. package/lib/source-build.js.map +0 -1
  159. package/lib/structures/ITtscBuildOptions.d.ts +0 -14
  160. package/lib/structures/ITtscBuildOptions.js.map +0 -1
  161. package/lib/structures/ITtscBuildResult.d.ts +0 -6
  162. package/lib/structures/ITtscBuildResult.js.map +0 -1
  163. package/lib/structures/ITtscBuildSourcePluginOptions.d.ts +0 -8
  164. package/lib/structures/ITtscBuildSourcePluginOptions.js +0 -3
  165. package/lib/structures/ITtscBuildSourcePluginOptions.js.map +0 -1
  166. package/lib/structures/ITtscCacheKeyInput.d.ts +0 -7
  167. package/lib/structures/ITtscCacheKeyInput.js.map +0 -1
  168. package/lib/structures/ITtscCheckOptions.d.ts +0 -2
  169. package/lib/structures/ITtscCheckOptions.js.map +0 -1
  170. package/lib/structures/ITtscCommonOptions.d.ts +0 -22
  171. package/lib/structures/ITtscCommonOptions.js +0 -3
  172. package/lib/structures/ITtscCommonOptions.js.map +0 -1
  173. package/lib/structures/ITtscLoadPluginsOptions.d.ts +0 -8
  174. package/lib/structures/ITtscLoadPluginsOptions.js +0 -3
  175. package/lib/structures/ITtscLoadPluginsOptions.js.map +0 -1
  176. package/lib/structures/ITtscLoadedNativePlugin.d.ts +0 -7
  177. package/lib/structures/ITtscLoadedNativePlugin.js.map +0 -1
  178. package/lib/structures/ITtscLoadedPlugins.d.ts +0 -11
  179. package/lib/structures/ITtscLoadedPlugins.js +0 -3
  180. package/lib/structures/ITtscLoadedPlugins.js.map +0 -1
  181. package/lib/structures/ITtscNativeBackend.d.ts +0 -10
  182. package/lib/structures/ITtscNativeBackend.js +0 -3
  183. package/lib/structures/ITtscNativeBackend.js.map +0 -1
  184. package/lib/structures/ITtscNativePluginContractVersion.d.ts +0 -1
  185. package/lib/structures/ITtscNativePluginContractVersion.js +0 -3
  186. package/lib/structures/ITtscNativePluginContractVersion.js.map +0 -1
  187. package/lib/structures/ITtscNativePluginShape.d.ts +0 -8
  188. package/lib/structures/ITtscNativePluginShape.js +0 -3
  189. package/lib/structures/ITtscNativePluginShape.js.map +0 -1
  190. package/lib/structures/ITtscNativeRewriteMode.d.ts +0 -1
  191. package/lib/structures/ITtscNativeRewriteMode.js +0 -3
  192. package/lib/structures/ITtscNativeRewriteMode.js.map +0 -1
  193. package/lib/structures/ITtscNativeSource.d.ts +0 -4
  194. package/lib/structures/ITtscNativeSource.js.map +0 -1
  195. package/lib/structures/ITtscParsedProjectConfig.d.ts +0 -9
  196. package/lib/structures/ITtscParsedProjectConfig.js.map +0 -1
  197. package/lib/structures/ITtscPluginFactory.d.ts +0 -4
  198. package/lib/structures/ITtscPluginFactory.js +0 -3
  199. package/lib/structures/ITtscPluginFactory.js.map +0 -1
  200. package/lib/structures/ITtscPluginModule.d.ts +0 -3
  201. package/lib/structures/ITtscPluginModule.js +0 -3
  202. package/lib/structures/ITtscPluginModule.js.map +0 -1
  203. package/lib/structures/ITtscPreparedExecution.d.ts +0 -5
  204. package/lib/structures/ITtscPreparedExecution.js +0 -3
  205. package/lib/structures/ITtscPreparedExecution.js.map +0 -1
  206. package/lib/structures/ITtscProjectLocatorOptions.d.ts +0 -5
  207. package/lib/structures/ITtscProjectLocatorOptions.js.map +0 -1
  208. package/lib/structures/ITtscRegisterOptions.d.ts +0 -6
  209. package/lib/structures/ITtscRegisterOptions.js +0 -3
  210. package/lib/structures/ITtscRegisterOptions.js.map +0 -1
  211. package/lib/structures/ITtscResolveGoBinaryOptions.d.ts +0 -7
  212. package/lib/structures/ITtscResolveGoBinaryOptions.js +0 -3
  213. package/lib/structures/ITtscResolveGoBinaryOptions.js.map +0 -1
  214. package/lib/structures/ITtscResolveOptions.d.ts +0 -20
  215. package/lib/structures/ITtscResolveOptions.js +0 -3
  216. package/lib/structures/ITtscResolveOptions.js.map +0 -1
  217. package/lib/structures/ITtscResolvedTsgo.d.ts +0 -8
  218. package/lib/structures/ITtscResolvedTsgo.js +0 -3
  219. package/lib/structures/ITtscResolvedTsgo.js.map +0 -1
  220. package/lib/structures/ITtscTransformOptions.d.ts +0 -12
  221. package/lib/structures/ITtscTransformOptions.js +0 -3
  222. package/lib/structures/ITtscTransformOptions.js.map +0 -1
  223. package/lib/structures/ITtscTsgoResolveOptions.d.ts +0 -14
  224. package/lib/structures/ITtscTsgoResolveOptions.js +0 -3
  225. package/lib/structures/ITtscTsgoResolveOptions.js.map +0 -1
  226. package/lib/tsgo.d.ts +0 -6
  227. package/lib/tsgo.js.map +0 -1
  228. package/src/api.ts +0 -872
  229. package/src/native.ts +0 -64
  230. package/src/platform.ts +0 -151
  231. package/src/plugin.ts +0 -253
  232. package/src/runner/register.ts +0 -406
  233. package/src/structures/ITtscBuildOptions.ts +0 -19
  234. package/src/structures/ITtscBuildResult.ts +0 -6
  235. package/src/structures/ITtscBuildSourcePluginOptions.ts +0 -9
  236. package/src/structures/ITtscCacheKeyInput.ts +0 -7
  237. package/src/structures/ITtscCheckOptions.ts +0 -3
  238. package/src/structures/ITtscCommonOptions.ts +0 -23
  239. package/src/structures/ITtscLoadPluginsOptions.ts +0 -9
  240. package/src/structures/ITtscLoadedNativePlugin.ts +0 -8
  241. package/src/structures/ITtscLoadedPlugins.ts +0 -12
  242. package/src/structures/ITtscNativeBackend.ts +0 -11
  243. package/src/structures/ITtscNativePluginContractVersion.ts +0 -1
  244. package/src/structures/ITtscNativePluginShape.ts +0 -9
  245. package/src/structures/ITtscNativeRewriteMode.ts +0 -1
  246. package/src/structures/ITtscNativeSource.ts +0 -4
  247. package/src/structures/ITtscParsedProjectConfig.ts +0 -10
  248. package/src/structures/ITtscPluginFactory.ts +0 -7
  249. package/src/structures/ITtscPluginModule.ts +0 -4
  250. package/src/structures/ITtscPreparedExecution.ts +0 -5
  251. package/src/structures/ITtscProjectLocatorOptions.ts +0 -5
  252. package/src/structures/ITtscRegisterOptions.ts +0 -7
  253. package/src/structures/ITtscResolveGoBinaryOptions.ts +0 -7
  254. package/src/structures/ITtscResolveOptions.ts +0 -20
  255. package/src/structures/ITtscResolvedTsgo.ts +0 -8
  256. package/src/structures/ITtscTransformOptions.ts +0 -13
  257. package/src/structures/ITtscTsgoResolveOptions.ts +0 -14
  258. package/test/native.test.ts +0 -103
  259. /package/lib/structures/{ITtscLoadedNativePlugin.js → internal/ITtscLoadedNativePlugin.js} +0 -0
  260. /package/lib/structures/{ITtscParsedProjectConfig.js → internal/ITtscParsedProjectConfig.js} +0 -0
  261. /package/lib/structures/{ITtscProjectLocatorOptions.js → internal/ITtscProjectLocatorOptions.js} +0 -0
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ITtscCompilerContext"), exports);
18
+ __exportStar(require("./ITtscCompilerDiagnostic"), exports);
19
+ __exportStar(require("./ITtscCompilerResult"), exports);
20
+ __exportStar(require("./ITtscPlugin"), exports);
21
+ __exportStar(require("./ITtscPluginFactoryContext"), exports);
22
+ __exportStar(require("./ITtscProjectPluginConfig"), exports);
23
+ __exportStar(require("./TtscPluginStage"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/structures/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,4DAA0C;AAC1C,wDAAsC;AACtC,gDAA8B;AAC9B,8DAA4C;AAC5C,6DAA2C;AAC3C,oDAAkC"}
@@ -0,0 +1,13 @@
1
+ import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
2
+ import type { TtscPluginStage } from "../TtscPluginStage";
3
+ /** Native sidecar selected and built from one plugin descriptor. */
4
+ export interface ITtscLoadedNativePlugin {
5
+ /** Executable produced by the lazy Go source build cache. */
6
+ binary: string;
7
+ /** Original tsconfig plugin entry passed unchanged to the sidecar. */
8
+ config: ITtscProjectPluginConfig;
9
+ /** Stable plugin name used in diagnostics and native manifests. */
10
+ name: string;
11
+ /** Pipeline stage where the sidecar participates. */
12
+ stage: TtscPluginStage;
13
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITtscLoadedNativePlugin.js","sourceRoot":"","sources":["../../../src/structures/internal/ITtscLoadedNativePlugin.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
2
+ /** Resolved project config subset used inside the ttsc host. */
3
+ export interface ITtscParsedProjectConfig {
4
+ /** Compiler options after extends inheritance has been applied. */
5
+ compilerOptions: {
6
+ /** Absolute output directory when configured. */
7
+ outDir?: string;
8
+ /** Project plugin entries after inheritance resolution. */
9
+ plugins: ITtscProjectPluginConfig[];
10
+ } & Record<string, unknown>;
11
+ /** Absolute path to the resolved tsconfig/jsconfig. */
12
+ path: string;
13
+ /** Directory containing the resolved tsconfig/jsconfig. */
14
+ root: string;
15
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITtscParsedProjectConfig.js","sourceRoot":"","sources":["../../../src/structures/internal/ITtscParsedProjectConfig.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ /** Inputs for locating the tsconfig/jsconfig that owns an invocation. */
2
+ export interface ITtscProjectLocatorOptions {
3
+ /** Working directory for relative paths and upward config discovery. */
4
+ cwd?: string;
5
+ /** Source file used as the starting point for nearest-config discovery. */
6
+ file?: string;
7
+ /** Explicit tsconfig/jsconfig path. */
8
+ tsconfig?: string;
9
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITtscProjectLocatorOptions.js","sourceRoot":"","sources":["../../../src/structures/internal/ITtscProjectLocatorOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import type { TtscCommonOptions } from "./TtscCommonOptions";
2
+ /** Internal options for a TypeScript-Go project build. */
3
+ export interface TtscBuildOptions extends TtscCommonOptions {
4
+ /** Project config file to compile. Relative paths are resolved from `cwd`. */
5
+ tsconfig?: string;
6
+ /**
7
+ * Emit override for the current call.
8
+ *
9
+ * - `true`: force file writes even when the project has `noEmit`.
10
+ * - `false`: force diagnostics/check-only behavior.
11
+ * - `undefined`: follow the resolved tsconfig exactly.
12
+ */
13
+ emit?: boolean;
14
+ /** Per-call TypeScript-Go `outDir` override. */
15
+ outDir?: string;
16
+ /** Suppress summary banners from ttsc/native sidecars. Defaults to `true`. */
17
+ quiet?: boolean;
18
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ITtscBuildOptions.js.map
3
+ //# sourceMappingURL=TtscBuildOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtscBuildOptions.js","sourceRoot":"","sources":["../../../src/structures/internal/TtscBuildOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { ITtscCompilerDiagnostic } from "../ITtscCompilerDiagnostic";
2
+ /** Internal result captured from TypeScript-Go or native plugin sidecars. */
3
+ export interface TtscBuildResult {
4
+ /** Structured diagnostics collected from compiler output. */
5
+ diagnostics: ITtscCompilerDiagnostic[];
6
+ /** Files written by the build when emitted-file listing was requested. */
7
+ emittedFiles?: string[];
8
+ /** Process-style exit status. `0` means success. */
9
+ status: number;
10
+ /** Captured stdout from TypeScript-Go or native plugin sidecars. */
11
+ stdout: string;
12
+ /** Captured stderr from TypeScript-Go or native plugin sidecars. */
13
+ stderr: string;
14
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ITtscCheckOptions.js.map
3
+ //# sourceMappingURL=TtscBuildResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtscBuildResult.js","sourceRoot":"","sources":["../../../src/structures/internal/TtscBuildResult.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
2
+ /** Internal options shared by the CLI build, transform, and runtime paths. */
3
+ export interface TtscCommonOptions {
4
+ /**
5
+ * Explicit TypeScript-Go executable.
6
+ *
7
+ * When supplied, ttsc skips package-based tsgo resolution and shells out to
8
+ * this binary directly.
9
+ */
10
+ binary?: string;
11
+ /** Working directory for config discovery and relative file paths. */
12
+ cwd?: string;
13
+ /** Environment variables merged over `process.env` for child processes. */
14
+ env?: NodeJS.ProcessEnv;
15
+ /** Explicit root directory for compiled source-plugin cache artifacts. */
16
+ cacheDir?: string;
17
+ /** Normalize compiler output so diagnostics can be parsed structurally. */
18
+ structuredDiagnostics?: boolean;
19
+ /**
20
+ * Override project plugin loading for this invocation.
21
+ *
22
+ * - `false`: ignore `compilerOptions.plugins` completely.
23
+ * - array: use these plugin entries instead of the project config entries.
24
+ * - `undefined`: use the project config entries as written.
25
+ */
26
+ plugins?: readonly ITtscProjectPluginConfig[] | false;
27
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ITtscNativeSource.js.map
3
+ //# sourceMappingURL=TtscCommonOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtscCommonOptions.js","sourceRoot":"","sources":["../../../src/structures/internal/TtscCommonOptions.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { TtscCommonOptions } from "./TtscCommonOptions";
2
+ /** Internal options for transforming one source file through the CLI path. */
3
+ export interface TtscTransformOptions extends TtscCommonOptions {
4
+ /** Source file to transform. Absolute paths and `cwd`-relative paths work. */
5
+ file: string;
6
+ /** Project config owning `file`; discovered from `file` when omitted. */
7
+ tsconfig?: string;
8
+ /** Optional output file path. Omit to return emitted text from stdout. */
9
+ out?: string;
10
+ /** Suppress summary banners from ttsc/native sidecars. Defaults to `true`. */
11
+ quiet?: boolean;
12
+ /** Normalize compiler output so diagnostics can be parsed structurally. */
13
+ structuredDiagnostics?: boolean;
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=TtscTransformOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtscTransformOptions.js","sourceRoot":"","sources":["../../../src/structures/internal/TtscTransformOptions.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ttsc",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "General-purpose TypeScript-Go compiler, plugin host, and runtime.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -27,17 +27,17 @@
27
27
  "homepage": "https://github.com/samchon/ttsc",
28
28
  "devDependencies": {
29
29
  "@types/node": "^25.3.0",
30
- "@typescript/native-preview": "7.0.0-dev.20260429.1",
30
+ "@typescript/native-preview": "7.0.0-dev.20260430.1",
31
31
  "rimraf": "^6.1.2"
32
32
  },
33
33
  "optionalDependencies": {
34
- "@ttsc/linux-x64": "0.6.0",
35
- "@ttsc/darwin-x64": "0.6.0",
36
- "@ttsc/darwin-arm64": "0.6.0",
37
- "@ttsc/win32-x64": "0.6.0",
38
- "@ttsc/linux-arm64": "0.6.0",
39
- "@ttsc/win32-arm64": "0.6.0",
40
- "@ttsc/linux-arm": "0.6.0"
34
+ "@ttsc/linux-x64": "0.7.0",
35
+ "@ttsc/linux-arm": "0.7.0",
36
+ "@ttsc/darwin-arm64": "0.7.0",
37
+ "@ttsc/linux-arm64": "0.7.0",
38
+ "@ttsc/darwin-x64": "0.7.0",
39
+ "@ttsc/win32-x64": "0.7.0",
40
+ "@ttsc/win32-arm64": "0.7.0"
41
41
  },
42
42
  "sideEffects": false,
43
43
  "files": [
@@ -0,0 +1,241 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+
4
+ import { compileProjectInMemory } from "./compiler/internal/compileProjectInMemory";
5
+ import { resolveProjectConfig } from "./compiler/internal/project/resolveProjectConfig";
6
+ import { resolveBinary } from "./compiler/internal/resolveBinary";
7
+ import { loadProjectPlugins } from "./plugin/internal/loadProjectPlugins";
8
+ import type { ITtscCompilerContext } from "./structures/ITtscCompilerContext";
9
+ import type { ITtscCompilerDiagnostic } from "./structures/ITtscCompilerDiagnostic";
10
+ import type { ITtscCompilerResult } from "./structures/ITtscCompilerResult";
11
+ import type { TtscBuildResult } from "./structures/internal/TtscBuildResult";
12
+
13
+ /**
14
+ * Programmatic compiler host for the `ttsc` TypeScript-Go pipeline.
15
+ *
16
+ * `TtscCompiler` is the root JavaScript API exported by the `ttsc` package.
17
+ * It represents one resolved project context: a working directory, an optional
18
+ * project config path, an optional native toolchain override, an environment,
19
+ * a cache root, and a plugin list. Those values are captured by the
20
+ * constructor and are intentionally not replaceable per method call.
21
+ *
22
+ * The class exposes only the operations that make sense for an embedded
23
+ * compiler host:
24
+ *
25
+ * - {@link TtscCompiler.prepare}: build configured Go source plugins into the
26
+ * cache before a later compile.
27
+ * - {@link TtscCompiler.clean}: remove the cache owned by this compiler
28
+ * context.
29
+ * - {@link TtscCompiler.compile}: compile the configured project and return a
30
+ * structured result instead of terminal text.
31
+ */
32
+ export class TtscCompiler {
33
+ private readonly context: ITtscCompilerContext;
34
+
35
+ public constructor(context: ITtscCompilerContext = {}) {
36
+ this.context = {
37
+ ...context,
38
+ env: context.env ? { ...context.env } : undefined,
39
+ plugins: Array.isArray(context.plugins)
40
+ ? [...context.plugins]
41
+ : context.plugins,
42
+ };
43
+ }
44
+
45
+ /**
46
+ * Build every configured source plugin into the instance cache.
47
+ *
48
+ * This method loads the project plugin descriptors, resolves their
49
+ * {@link ITtscPlugin.source} paths, and compiles those Go command packages
50
+ * into the ttsc cache. It is useful when a host application wants to pay the
51
+ * lazy build cost before the first compile call.
52
+ *
53
+ * `prepare()` is not a project check. It does not create a TypeScript-Go
54
+ * Program, does not run diagnostics, and does not emit output files.
55
+ *
56
+ * @returns Compiled native plugin binary paths.
57
+ */
58
+ public prepare(): string[] {
59
+ const execution = this.resolveProjectExecution();
60
+ const loaded = loadProjectPlugins({
61
+ binary: resolveBinary(this.compilerContext()) ?? "",
62
+ cacheDir: this.resolvePluginCacheDir(),
63
+ cwd: execution.cwd,
64
+ entries: this.context.plugins,
65
+ tsconfig: execution.tsconfig,
66
+ });
67
+ return loaded.nativePlugins.map((plugin) => plugin.binary);
68
+ }
69
+
70
+ /**
71
+ * Remove compiled cache artifacts for this compiler instance.
72
+ *
73
+ * When the constructor received `cacheDir`, this method removes exactly that
74
+ * directory. Otherwise it removes the default ttsc cache locations for the
75
+ * resolved project root, plus the `TTSC_CACHE_DIR/plugins` cache when that
76
+ * environment variable is active.
77
+ *
78
+ * The cache target comes from the constructor context. Create another
79
+ * `TtscCompiler` instance to clean another project or another cache root.
80
+ *
81
+ * @returns Cache directories that were removed.
82
+ */
83
+ public clean(): string[] {
84
+ const cacheDir = this.resolveCacheDir();
85
+ if (cacheDir !== undefined) {
86
+ return removeExistingDirectories([cacheDir]);
87
+ }
88
+
89
+ const envCacheDir =
90
+ this.context.env?.TTSC_CACHE_DIR ?? process.env.TTSC_CACHE_DIR;
91
+ const projectRoot = this.resolveCleanProjectRoot();
92
+ return removeExistingDirectories([
93
+ ...(envCacheDir ? [path.resolve(envCacheDir, "plugins")] : []),
94
+ path.join(projectRoot, "node_modules", ".ttsc"),
95
+ path.join(projectRoot, ".ttsc"),
96
+ ]);
97
+ }
98
+
99
+ /**
100
+ * Compile the configured project.
101
+ *
102
+ * The public API does not write emitted files into the caller's project tree.
103
+ * For projects without plugins, ttsc uses its native TypeScript-Go host's
104
+ * `WriteFile` callback to capture output in memory. For projects with
105
+ * native plugins, ttsc runs the plugin pipeline against a temporary output
106
+ * directory, reads the generated text artifacts, and removes the temporary
107
+ * directory before returning.
108
+ *
109
+ * The result uses an `embed-typescript`-style discriminated union:
110
+ * `success` for clean compiles, `failure` for normal compiler diagnostics,
111
+ * and `exception` for host setup or process failures.
112
+ *
113
+ * @returns Structured compilation result containing diagnostics or output.
114
+ */
115
+ public compile(): ITtscCompilerResult {
116
+ return runProject(() => compileProjectInMemory(this.compilerContext()));
117
+ }
118
+
119
+ private compilerContext(): ITtscCompilerContext {
120
+ return {
121
+ ...this.context,
122
+ cacheDir: this.resolveCacheDir(),
123
+ };
124
+ }
125
+
126
+ private resolveProjectExecution(): {
127
+ cwd: string;
128
+ projectRoot: string;
129
+ tsconfig: string;
130
+ } {
131
+ const cwd = this.resolveCwd();
132
+ const tsconfig = resolveProjectConfig({
133
+ cwd,
134
+ tsconfig: this.context.tsconfig,
135
+ });
136
+ return {
137
+ cwd,
138
+ projectRoot: path.dirname(tsconfig),
139
+ tsconfig,
140
+ };
141
+ }
142
+
143
+ private resolveCleanProjectRoot(): string {
144
+ try {
145
+ return this.resolveProjectExecution().projectRoot;
146
+ } catch (error) {
147
+ if (this.context.tsconfig) {
148
+ throw error;
149
+ }
150
+ return this.resolveCwd();
151
+ }
152
+ }
153
+
154
+ private resolveCwd(): string {
155
+ return path.resolve(this.context.cwd ?? process.cwd());
156
+ }
157
+
158
+ private resolveCacheDir(): string | undefined {
159
+ if (!this.context.cacheDir) {
160
+ return undefined;
161
+ }
162
+ return path.isAbsolute(this.context.cacheDir)
163
+ ? this.context.cacheDir
164
+ : path.resolve(this.resolveCwd(), this.context.cacheDir);
165
+ }
166
+
167
+ private resolvePluginCacheDir(): string | undefined {
168
+ return this.resolveCacheDir() ?? this.context.env?.TTSC_CACHE_DIR;
169
+ }
170
+ }
171
+
172
+ function removeExistingDirectories(directories: readonly string[]): string[] {
173
+ const removed: string[] = [];
174
+ for (const directory of [...new Set(directories)]) {
175
+ if (!fs.existsSync(directory)) {
176
+ continue;
177
+ }
178
+ fs.rmSync(directory, { recursive: true, force: true });
179
+ removed.push(directory);
180
+ }
181
+ return removed;
182
+ }
183
+
184
+ interface ProjectResult {
185
+ output: Record<string, string>;
186
+ result: TtscBuildResult;
187
+ }
188
+
189
+ function runProject(task: () => ProjectResult): ITtscCompilerResult {
190
+ try {
191
+ return toCompilerResult(task());
192
+ } catch (error) {
193
+ return {
194
+ error: normalizeError(error),
195
+ type: "exception",
196
+ };
197
+ }
198
+ }
199
+
200
+ function toCompilerResult(project: ProjectResult): ITtscCompilerResult {
201
+ const { output, result } = project;
202
+ if (result.status === 0 && result.diagnostics.length === 0) {
203
+ return {
204
+ output,
205
+ type: "success",
206
+ };
207
+ }
208
+ return {
209
+ diagnostics:
210
+ result.diagnostics.length === 0
211
+ ? [createProcessDiagnostic(result)]
212
+ : result.diagnostics,
213
+ output,
214
+ type: "failure",
215
+ };
216
+ }
217
+
218
+ function createProcessDiagnostic(
219
+ result: TtscBuildResult,
220
+ ): ITtscCompilerDiagnostic {
221
+ const messageText =
222
+ (result.stderr || result.stdout).trim() ||
223
+ `ttsc exited with status ${result.status}`;
224
+ return {
225
+ category: "error",
226
+ code: "TTSC_PROCESS",
227
+ file: null,
228
+ messageText,
229
+ };
230
+ }
231
+
232
+ function normalizeError(error: unknown): unknown {
233
+ if (!(error instanceof Error)) {
234
+ return error;
235
+ }
236
+ return {
237
+ message: error.message,
238
+ name: error.name,
239
+ stack: error.stack,
240
+ };
241
+ }
@@ -0,0 +1,43 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+
4
+ import { buildSourcePlugin } from "../../plugin/internal/buildSourcePlugin";
5
+
6
+ /** Build the native ttsc compiler host used by in-memory API compilation. */
7
+ export function buildNativeCompiler(options: {
8
+ cacheBaseDir: string;
9
+ cacheDir?: string;
10
+ packageRoot: string;
11
+ }): string {
12
+ return buildSourcePlugin({
13
+ baseDir: options.cacheBaseDir,
14
+ cacheDir: options.cacheDir,
15
+ label: "compiler host",
16
+ overlayDirs: [],
17
+ pluginName: "ttsc",
18
+ quiet: true,
19
+ source: path.join(options.packageRoot, "cmd", "ttsc"),
20
+ ttscVersion: readOwnPackageVersion(options.packageRoot),
21
+ tsgoVersion: readGoModuleVersion(options.packageRoot),
22
+ });
23
+ }
24
+
25
+ function readOwnPackageVersion(packageRoot: string): string {
26
+ try {
27
+ const pkg = JSON.parse(
28
+ fs.readFileSync(path.join(packageRoot, "package.json"), "utf8"),
29
+ ) as { version?: unknown };
30
+ return typeof pkg.version === "string" ? pkg.version : "0.0.0";
31
+ } catch {
32
+ return "0.0.0";
33
+ }
34
+ }
35
+
36
+ function readGoModuleVersion(packageRoot: string): string {
37
+ try {
38
+ const goMod = fs.readFileSync(path.join(packageRoot, "go.mod"), "utf8");
39
+ return goMod;
40
+ } catch {
41
+ return "unknown";
42
+ }
43
+ }