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,91 @@
1
+ /**
2
+ * Diagnostic information from the ttsc TypeScript-Go compiler.
3
+ *
4
+ * Represents standardized diagnostic information produced during a
5
+ * TypeScript-Go compilation. This interface provides a simplified and
6
+ * consistent representation of TypeScript's diagnostic structure without
7
+ * requiring callers to depend on TypeScript-Go's internal Go types or parse
8
+ * terminal output.
9
+ *
10
+ * @author Jeongho Nam - https://github.com/samchon
11
+ */
12
+ export interface ITtscCompilerDiagnostic {
13
+ /**
14
+ * The filename where the diagnostic originated, or null if not
15
+ * file-specific.
16
+ *
17
+ * Global diagnostics such as invalid compiler options or host-level failures
18
+ * are reported with `null` because they are not tied to a single source file.
19
+ */
20
+ file: string | null;
21
+
22
+ /**
23
+ * The severity category of the diagnostic.
24
+ *
25
+ * Values follow TypeScript's diagnostic categories: error, warning,
26
+ * suggestion, and message.
27
+ */
28
+ category: ITtscCompilerDiagnostic.Category;
29
+
30
+ /**
31
+ * The error code or identifier associated with this diagnostic.
32
+ *
33
+ * TypeScript diagnostics normally use numeric codes such as `2322`. Native
34
+ * plugins may use stable string identifiers for plugin-defined diagnostics.
35
+ */
36
+ code: number | string;
37
+
38
+ /**
39
+ * The starting position of the issue in the source file, if available.
40
+ *
41
+ * TypeScript-Go reports this as a zero-based character offset. It is omitted
42
+ * for global diagnostics or messages that do not expose a source offset.
43
+ */
44
+ start?: number;
45
+
46
+ /**
47
+ * The length of the problematic section in the source file, if available.
48
+ *
49
+ * Omitted when TypeScript-Go or a native plugin reports only a point
50
+ * location, or when the diagnostic is not tied to a source file.
51
+ */
52
+ length?: number;
53
+
54
+ /**
55
+ * 1-based line number where the diagnostic starts, if available.
56
+ *
57
+ * This follows TypeScript's display convention rather than TypeScript-Go's
58
+ * zero-based internal line index.
59
+ */
60
+ line?: number;
61
+
62
+ /**
63
+ * 1-based character (column) position where the diagnostic starts, if
64
+ * available.
65
+ *
66
+ * This follows TypeScript's display convention rather than TypeScript-Go's
67
+ * zero-based internal column index.
68
+ */
69
+ character?: number;
70
+
71
+ /**
72
+ * The human-readable diagnostic message describing the issue.
73
+ *
74
+ * Message chains are flattened into text so callers do not need to depend on
75
+ * TypeScript-Go's internal diagnostic representation.
76
+ */
77
+ messageText: string;
78
+ }
79
+
80
+ export namespace ITtscCompilerDiagnostic {
81
+ /**
82
+ * Possible severity categories for diagnostics.
83
+ *
84
+ * - `"warning"`: issues that might cause problems but do not necessarily
85
+ * prevent compilation.
86
+ * - `"error"`: issues that prevent successful compilation.
87
+ * - `"suggestion"`: recommendations for code improvement.
88
+ * - `"message"`: informational notes without warning or error severity.
89
+ */
90
+ export type Category = "warning" | "error" | "suggestion" | "message";
91
+ }
@@ -0,0 +1,94 @@
1
+ import type { ITtscCompilerDiagnostic } from "./ITtscCompilerDiagnostic";
2
+
3
+ /**
4
+ * Result of a ttsc TypeScript-Go compilation operation.
5
+ *
6
+ * Represents the possible outcomes of {@link TtscCompiler.compile}, which can
7
+ * be either a successful compilation, a compilation that completed with
8
+ * diagnostics, or an unexpected host error during the compilation process.
9
+ *
10
+ * This type follows the legacy `embed-typescript` result model, but stores all
11
+ * emitted text artifacts in {@link ITtscCompilerResult.ISuccess.output} and
12
+ * {@link ITtscCompilerResult.IFailure.output}. TypeScript-Go may emit
13
+ * JavaScript, declaration files, source maps, and declaration maps from one
14
+ * compile operation, so the public result is not limited to JavaScript.
15
+ *
16
+ * @author Jeongho Nam - https://github.com/samchon
17
+ */
18
+ export type ITtscCompilerResult =
19
+ | ITtscCompilerResult.ISuccess
20
+ | ITtscCompilerResult.IFailure
21
+ | ITtscCompilerResult.IException;
22
+
23
+ export namespace ITtscCompilerResult {
24
+ /**
25
+ * Represents a successful ttsc compilation result.
26
+ *
27
+ * This interface is returned when TypeScript-Go completes without
28
+ * diagnostics, containing every text output captured from the native
29
+ * compiler host's `WriteFile` callback.
30
+ */
31
+ export interface ISuccess {
32
+ /**
33
+ * Indicates that the compilation was successful.
34
+ */
35
+ type: "success";
36
+
37
+ /**
38
+ * The generated compiler output.
39
+ *
40
+ * A record mapping project-relative output file paths to their generated
41
+ * text content. This includes JavaScript, declaration files, source maps,
42
+ * declaration maps, and any other text artifact emitted through
43
+ * TypeScript-Go's `WriteFile` callback.
44
+ */
45
+ output: Record<string, string>;
46
+ }
47
+
48
+ /**
49
+ * Represents a ttsc compilation that completed but had diagnostics.
50
+ *
51
+ * This interface is returned when the compiler reports errors, warnings, or
52
+ * other diagnostics during normal compilation. It contains both structured
53
+ * diagnostic information and any output that was still generated despite the
54
+ * diagnostics.
55
+ */
56
+ export interface IFailure {
57
+ /**
58
+ * Indicates that compilation completed with diagnostics.
59
+ */
60
+ type: "failure";
61
+
62
+ /**
63
+ * Array of diagnostic messages describing the compilation issues.
64
+ */
65
+ diagnostics: ITtscCompilerDiagnostic[];
66
+
67
+ /**
68
+ * Any compiler output that was generated despite the diagnostics.
69
+ *
70
+ * This may be partial or empty depending on the severity of the issues and
71
+ * how far TypeScript-Go progressed before returning diagnostics.
72
+ */
73
+ output: Record<string, string>;
74
+ }
75
+
76
+ /**
77
+ * Represents an unexpected error during the compilation process.
78
+ *
79
+ * This interface is returned when ttsc cannot prepare, build, or spawn the
80
+ * native compiler host. Normal TypeScript diagnostics are represented by
81
+ * {@link IFailure}; this variant is reserved for host-level exceptions.
82
+ */
83
+ export interface IException {
84
+ /**
85
+ * Indicates that an unexpected host error occurred.
86
+ */
87
+ type: "exception";
88
+
89
+ /**
90
+ * The error that was thrown while preparing or running the compiler host.
91
+ */
92
+ error: unknown;
93
+ }
94
+ }
@@ -1,11 +1,58 @@
1
- import type { ITtscNativeBackend } from "./ITtscNativeBackend";
2
- import type { ITtscNativeRewriteMode } from "./ITtscNativeRewriteMode";
1
+ import type { TtscPluginStage } from "./TtscPluginStage";
3
2
 
3
+ /**
4
+ * Runtime descriptor returned by a ttsc plugin module.
5
+ *
6
+ * A JavaScript plugin entry in `compilerOptions.plugins[]` is only the loading
7
+ * point. After ttsc resolves that JavaScript module, the module must return an
8
+ * `ITtscPlugin` descriptor either directly, as `default`, as `plugin`, or from
9
+ * `createTtscPlugin(context)`.
10
+ *
11
+ * The descriptor tells ttsc which Go command package implements the native
12
+ * sidecar and where that sidecar participates in the TypeScript-Go pipeline.
13
+ * ttsc then builds the Go source lazily with the bundled Go toolchain and
14
+ * passes the original project plugin config to the sidecar through
15
+ * `--plugins-json`.
16
+ */
4
17
  export interface ITtscPlugin {
18
+ /**
19
+ * Stable plugin name used in diagnostics, build messages, and native plugin
20
+ * manifests.
21
+ *
22
+ * Keep this stable across releases. Native sidecars and downstream tooling
23
+ * can use the name to select their own config from the ordered
24
+ * `--plugins-json` payload.
25
+ */
5
26
  name: string;
6
- native?: ITtscNativeBackend;
7
- /** @deprecated Use `native.mode` instead. */
8
- nativeMode?: ITtscNativeRewriteMode;
9
- /** @deprecated Use `native.binary` instead. */
10
- nativeBinary?: string;
27
+
28
+ /**
29
+ * Go command package directory, or a `go.mod` file, that ttsc lazily builds.
30
+ *
31
+ * ttsc accepts source only. It does not accept a prebuilt binary path: the
32
+ * package-local Go compiler builds this source into the ttsc plugin cache on
33
+ * demand.
34
+ *
35
+ * Directory sources search upward at most 3 parent directories for `go.mod`;
36
+ * direct `go.mod` sources build the module root as `.`.
37
+ *
38
+ * Common layouts:
39
+ *
40
+ * - `source: "src"` when the plugin package keeps its Go command in `src`.
41
+ * - `source: "plugin"` when the repository has a dedicated Go plugin folder.
42
+ * - `source: "lib"` only when the published package intentionally ships Go
43
+ * source under `lib` instead of compiled JavaScript.
44
+ * - `source: "go.mod"` when the module root itself is the command package.
45
+ */
46
+ source: string;
47
+
48
+ /**
49
+ * Pipeline stage implemented by the sidecar.
50
+ *
51
+ * Omit this field for normal compiler-transform plugins. Explicit stages are
52
+ * intended for tools that only validate (`"check"`) or rewrite already
53
+ * emitted files (`"output"`).
54
+ *
55
+ * @default "transform"
56
+ */
57
+ stage?: TtscPluginStage;
11
58
  }
@@ -1,9 +1,60 @@
1
1
  import type { ITtscProjectPluginConfig } from "./ITtscProjectPluginConfig";
2
2
 
3
+ /**
4
+ * Project context passed to `createTtscPlugin()` factories.
5
+ *
6
+ * Plugin packages may export a static {@link ITtscPlugin} descriptor when the
7
+ * descriptor never depends on the consuming project. Export a
8
+ * `createTtscPlugin(context)` factory instead when the descriptor needs to
9
+ * inspect the original plugin config, the resolved tsconfig path, or the
10
+ * project root.
11
+ *
12
+ * The factory runs in Node.js while ttsc is loading `compilerOptions.plugins`.
13
+ * It should only create the descriptor. Heavy validation and TypeScript-Go
14
+ * work belong in the Go sidecar selected by {@link ITtscPlugin.source}.
15
+ */
3
16
  export interface ITtscPluginFactoryContext<T = ITtscProjectPluginConfig> {
17
+ /**
18
+ * Absolute ttsc native helper binary selected for this invocation.
19
+ *
20
+ * This is the package's own native helper, not the plugin sidecar and not the
21
+ * JavaScript launcher. Most plugins do not need it; it is provided for
22
+ * advanced factories that need to derive behavior from the active ttsc
23
+ * native host.
24
+ */
4
25
  binary: string;
26
+
27
+ /**
28
+ * Current working directory requested by the caller.
29
+ *
30
+ * This is the cwd used for project discovery and relative command-line
31
+ * inputs. It can differ from {@link ITtscPluginFactoryContext.projectRoot}
32
+ * when the caller points at a tsconfig in another directory.
33
+ */
5
34
  cwd: string;
35
+
36
+ /**
37
+ * Original `compilerOptions.plugins[]` entry that loaded this plugin.
38
+ *
39
+ * ttsc reserves `transform` and `enabled`. Every other property is
40
+ * plugin-owned config and is later serialized unchanged into the native
41
+ * sidecar manifest.
42
+ */
6
43
  plugin: T;
44
+
45
+ /**
46
+ * Directory containing the resolved tsconfig/jsconfig.
47
+ *
48
+ * Relative plugin module specifiers and plugin source paths are resolved from
49
+ * this directory, matching TypeScript plugin config behavior.
50
+ */
7
51
  projectRoot: string;
52
+
53
+ /**
54
+ * Absolute path to the resolved tsconfig/jsconfig.
55
+ *
56
+ * Factories can use this to select descriptor variants for monorepos or
57
+ * multiple project configs without reparsing command-line arguments.
58
+ */
8
59
  tsconfig: string;
9
60
  }
@@ -1,5 +1,48 @@
1
+ /**
2
+ * Raw `compilerOptions.plugins[]` entry read from tsconfig/jsconfig.
3
+ *
4
+ * This is the project-facing config shape that users write in
5
+ * `tsconfig.json`. ttsc deliberately keeps it open-ended because plugin
6
+ * packages own their own config fields.
7
+ *
8
+ * ttsc interprets only two properties:
9
+ *
10
+ * - `transform`: the JavaScript module specifier used to load the plugin
11
+ * descriptor or factory.
12
+ * - `enabled`: an opt-out switch that keeps the config entry in the file while
13
+ * preventing ttsc from loading it.
14
+ *
15
+ * Every other property is preserved as plugin config. After ttsc loads and
16
+ * builds the plugin, the original entry is serialized into the native sidecar
17
+ * manifest so Go code can read exactly the same plugin-specific options.
18
+ */
1
19
  export interface ITtscProjectPluginConfig {
20
+ /**
21
+ * Set to `false` to keep the entry while disabling it for ttsc.
22
+ *
23
+ * This is useful for sharing one tsconfig across environments while turning
24
+ * selected plugins on or off without deleting their config.
25
+ */
2
26
  enabled?: boolean;
27
+
28
+ /**
29
+ * Plugin module specifier, relative path, or absolute path to load.
30
+ *
31
+ * Relative paths are resolved from the resolved project root, which is the
32
+ * directory containing the active tsconfig/jsconfig. Package specifiers are
33
+ * resolved with Node's package resolution from that same project root.
34
+ *
35
+ * The loaded JavaScript module must export an {@link ITtscPlugin} descriptor
36
+ * or a `createTtscPlugin(context)` factory. The Go implementation itself is
37
+ * declared by the descriptor's {@link ITtscPlugin.source} field.
38
+ */
3
39
  transform?: string;
40
+
41
+ /**
42
+ * Plugin-specific config passed through unchanged to the native sidecar.
43
+ *
44
+ * ttsc does not validate these fields. Plugin packages should document their
45
+ * own config contract and validate it inside their factory or Go sidecar.
46
+ */
4
47
  [key: string]: unknown;
5
48
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Pipeline stage where a plugin's lazily built Go sidecar participates.
3
+ *
4
+ * - `"transform"`: owns the TypeScript-Go emit pass. This is the default and
5
+ * is the right stage for compiler-transform plugins such as typia-style
6
+ * source rewrites. A transform sidecar receives the ordered plugin manifest
7
+ * and is responsible for producing the project's emitted output.
8
+ * - `"check"`: runs before emit and reports diagnostics only. Use this for
9
+ * lint or validation plugins that should fail the compile before JavaScript
10
+ * or declaration output is generated.
11
+ * - `"output"`: runs after emit for each emitted output file. Use this for
12
+ * post-processing plugins such as banner insertion, import-path rewriting,
13
+ * or output stripping that operate on `.js`, `.d.ts`, or map files.
14
+ */
15
+ export type TtscPluginStage = "transform" | "check" | "output";
@@ -0,0 +1,7 @@
1
+ export * from "./ITtscCompilerContext";
2
+ export * from "./ITtscCompilerDiagnostic";
3
+ export * from "./ITtscCompilerResult";
4
+ export * from "./ITtscPlugin";
5
+ export * from "./ITtscPluginFactoryContext";
6
+ export * from "./ITtscProjectPluginConfig";
7
+ export * from "./TtscPluginStage";
@@ -0,0 +1,14 @@
1
+ import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
2
+ import type { TtscPluginStage } from "../TtscPluginStage";
3
+
4
+ /** Native sidecar selected and built from one plugin descriptor. */
5
+ export interface ITtscLoadedNativePlugin {
6
+ /** Executable produced by the lazy Go source build cache. */
7
+ binary: string;
8
+ /** Original tsconfig plugin entry passed unchanged to the sidecar. */
9
+ config: ITtscProjectPluginConfig;
10
+ /** Stable plugin name used in diagnostics and native manifests. */
11
+ name: string;
12
+ /** Pipeline stage where the sidecar participates. */
13
+ stage: TtscPluginStage;
14
+ }
@@ -0,0 +1,16 @@
1
+ import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
2
+
3
+ /** Resolved project config subset used inside the ttsc host. */
4
+ export interface ITtscParsedProjectConfig {
5
+ /** Compiler options after extends inheritance has been applied. */
6
+ compilerOptions: {
7
+ /** Absolute output directory when configured. */
8
+ outDir?: string;
9
+ /** Project plugin entries after inheritance resolution. */
10
+ plugins: ITtscProjectPluginConfig[];
11
+ } & Record<string, unknown>;
12
+ /** Absolute path to the resolved tsconfig/jsconfig. */
13
+ path: string;
14
+ /** Directory containing the resolved tsconfig/jsconfig. */
15
+ root: string;
16
+ }
@@ -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,19 @@
1
+ import type { TtscCommonOptions } from "./TtscCommonOptions";
2
+
3
+ /** Internal options for a TypeScript-Go project build. */
4
+ export interface TtscBuildOptions extends TtscCommonOptions {
5
+ /** Project config file to compile. Relative paths are resolved from `cwd`. */
6
+ tsconfig?: string;
7
+ /**
8
+ * Emit override for the current call.
9
+ *
10
+ * - `true`: force file writes even when the project has `noEmit`.
11
+ * - `false`: force diagnostics/check-only behavior.
12
+ * - `undefined`: follow the resolved tsconfig exactly.
13
+ */
14
+ emit?: boolean;
15
+ /** Per-call TypeScript-Go `outDir` override. */
16
+ outDir?: string;
17
+ /** Suppress summary banners from ttsc/native sidecars. Defaults to `true`. */
18
+ quiet?: boolean;
19
+ }
@@ -0,0 +1,15 @@
1
+ import type { ITtscCompilerDiagnostic } from "../ITtscCompilerDiagnostic";
2
+
3
+ /** Internal result captured from TypeScript-Go or native plugin sidecars. */
4
+ export interface TtscBuildResult {
5
+ /** Structured diagnostics collected from compiler output. */
6
+ diagnostics: ITtscCompilerDiagnostic[];
7
+ /** Files written by the build when emitted-file listing was requested. */
8
+ emittedFiles?: string[];
9
+ /** Process-style exit status. `0` means success. */
10
+ status: number;
11
+ /** Captured stdout from TypeScript-Go or native plugin sidecars. */
12
+ stdout: string;
13
+ /** Captured stderr from TypeScript-Go or native plugin sidecars. */
14
+ stderr: string;
15
+ }
@@ -0,0 +1,28 @@
1
+ import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
2
+
3
+ /** Internal options shared by the CLI build, transform, and runtime paths. */
4
+ export interface TtscCommonOptions {
5
+ /**
6
+ * Explicit TypeScript-Go executable.
7
+ *
8
+ * When supplied, ttsc skips package-based tsgo resolution and shells out to
9
+ * this binary directly.
10
+ */
11
+ binary?: string;
12
+ /** Working directory for config discovery and relative file paths. */
13
+ cwd?: string;
14
+ /** Environment variables merged over `process.env` for child processes. */
15
+ env?: NodeJS.ProcessEnv;
16
+ /** Explicit root directory for compiled source-plugin cache artifacts. */
17
+ cacheDir?: string;
18
+ /** Normalize compiler output so diagnostics can be parsed structurally. */
19
+ structuredDiagnostics?: boolean;
20
+ /**
21
+ * Override project plugin loading for this invocation.
22
+ *
23
+ * - `false`: ignore `compilerOptions.plugins` completely.
24
+ * - array: use these plugin entries instead of the project config entries.
25
+ * - `undefined`: use the project config entries as written.
26
+ */
27
+ plugins?: readonly ITtscProjectPluginConfig[] | false;
28
+ }
@@ -0,0 +1,15 @@
1
+ import type { TtscCommonOptions } from "./TtscCommonOptions";
2
+
3
+ /** Internal options for transforming one source file through the CLI path. */
4
+ export interface TtscTransformOptions extends TtscCommonOptions {
5
+ /** Source file to transform. Absolute paths and `cwd`-relative paths work. */
6
+ file: string;
7
+ /** Project config owning `file`; discovered from `file` when omitted. */
8
+ tsconfig?: string;
9
+ /** Optional output file path. Omit to return emitted text from stdout. */
10
+ out?: string;
11
+ /** Suppress summary banners from ttsc/native sidecars. Defaults to `true`. */
12
+ quiet?: boolean;
13
+ /** Normalize compiler output so diagnostics can be parsed structurally. */
14
+ structuredDiagnostics?: boolean;
15
+ }