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
@@ -3,19 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.definePlugin = definePlugin;
7
6
  exports.loadProjectPlugins = loadProjectPlugins;
8
7
  const node_module_1 = require("node:module");
9
8
  const node_fs_1 = __importDefault(require("node:fs"));
10
9
  const node_path_1 = __importDefault(require("node:path"));
11
- const native_1 = require("./native");
12
- const project_1 = require("./project");
13
- const source_build_1 = require("./source-build");
14
- function definePlugin(plugin) {
15
- return plugin;
16
- }
10
+ const readProjectConfig_1 = require("../../compiler/internal/project/readProjectConfig");
11
+ const buildSourcePlugin_1 = require("./buildSourcePlugin");
17
12
  function loadProjectPlugins(options) {
18
- const project = (0, project_1.readProjectConfig)({
13
+ const project = (0, readProjectConfig_1.readProjectConfig)({
19
14
  cwd: options.cwd,
20
15
  file: options.file,
21
16
  tsconfig: options.tsconfig,
@@ -25,11 +20,7 @@ function loadProjectPlugins(options) {
25
20
  : [...(options.entries ?? project.compilerOptions.plugins)].filter((entry) => entry.enabled !== false);
26
21
  if (entries.length === 0) {
27
22
  return {
28
- compatibilityFallback: false,
29
- nativeBinary: null,
30
- nativeBinaries: [],
31
23
  nativePlugins: [],
32
- plugins: [],
33
24
  project,
34
25
  };
35
26
  }
@@ -44,39 +35,24 @@ function loadProjectPlugins(options) {
44
35
  const ttscVersion = readTtscVersion();
45
36
  const tsgoVersion = readTsgoVersion(context.projectRoot);
46
37
  plugins.forEach((plugin, index) => {
47
- let backend = (0, native_1.resolveNativeBackend)(plugin);
48
- if (!backend) {
49
- return;
50
- }
51
- if (backend.source && !backend.binary) {
52
- const built = (0, source_build_1.buildSourcePlugin)({
53
- baseDir: context.projectRoot,
54
- pluginName: plugin.name,
55
- source: backend.source,
56
- ttscVersion,
57
- tsgoVersion,
58
- });
59
- backend = { ...backend, binary: built };
60
- }
61
- nativePlugins.push({ backend, config: entries[index], name: plugin.name });
38
+ validatePluginSource(plugin);
39
+ const binary = (0, buildSourcePlugin_1.buildSourcePlugin)({
40
+ baseDir: context.projectRoot,
41
+ cacheDir: options.cacheDir,
42
+ pluginName: plugin.name,
43
+ source: plugin.source,
44
+ ttscVersion,
45
+ tsgoVersion,
46
+ });
47
+ nativePlugins.push({
48
+ binary,
49
+ config: entries[index],
50
+ name: plugin.name,
51
+ stage: resolvePluginStage(plugin),
52
+ });
62
53
  });
63
- if (nativePlugins.length !== plugins.length) {
64
- const missing = plugins
65
- .filter((plugin) => !(0, native_1.resolveNativeBackend)(plugin))
66
- .map((plugin) => plugin.name)
67
- .join(", ");
68
- throw new Error(`ttsc: every plugin must declare a native backend; missing native for ${missing}`);
69
- }
70
54
  return {
71
- compatibilityFallback: false,
72
- nativeBinary: nativePlugins[0]?.backend.binary ?? null,
73
- nativeBinaries: [
74
- ...new Set(nativePlugins
75
- .map((plugin) => plugin.backend.binary)
76
- .filter((binary) => typeof binary === "string")),
77
- ],
78
55
  nativePlugins,
79
- plugins,
80
56
  project,
81
57
  };
82
58
  }
@@ -116,6 +92,23 @@ function rejectJsTransformHooks(specifier, candidate) {
116
92
  "declare a native backend instead");
117
93
  }
118
94
  }
95
+ function resolvePluginStage(plugin) {
96
+ if (plugin.stage === undefined) {
97
+ return "transform";
98
+ }
99
+ if (!isPluginStage(plugin.stage)) {
100
+ throw new Error(`ttsc: plugin "${plugin.name}" requested unsupported stage ${JSON.stringify(plugin.stage)}`);
101
+ }
102
+ return plugin.stage;
103
+ }
104
+ function validatePluginSource(plugin) {
105
+ if (typeof plugin.source !== "string" || plugin.source.length === 0) {
106
+ throw new Error(`ttsc: plugin "${plugin.name}" must declare source`);
107
+ }
108
+ }
109
+ function isPluginStage(value) {
110
+ return value === "transform" || value === "check" || value === "output";
111
+ }
119
112
  function resolvePluginRequest(specifier, projectRoot) {
120
113
  if (node_path_1.default.isAbsolute(specifier)) {
121
114
  return specifier;
@@ -123,16 +116,7 @@ function resolvePluginRequest(specifier, projectRoot) {
123
116
  if (isRelativePluginSpecifier(specifier)) {
124
117
  return node_path_1.default.resolve(projectRoot, specifier);
125
118
  }
126
- try {
127
- return require.resolve(specifier, { paths: [projectRoot] });
128
- }
129
- catch (error) {
130
- const sourceFallback = resolveSourceCheckoutPlugin(specifier, projectRoot);
131
- if (sourceFallback) {
132
- return sourceFallback;
133
- }
134
- throw error;
135
- }
119
+ return require.resolve(specifier, { paths: [projectRoot] });
136
120
  }
137
121
  function isRelativePluginSpecifier(specifier) {
138
122
  return (specifier === "." ||
@@ -142,35 +126,13 @@ function isRelativePluginSpecifier(specifier) {
142
126
  specifier.startsWith(".\\") ||
143
127
  specifier.startsWith("..\\"));
144
128
  }
145
- function resolveSourceCheckoutPlugin(specifier, projectRoot) {
146
- const normalized = specifier.replace(/\\/g, "/");
147
- const match = normalized.match(/^(.*)\/lib\/transform$/);
148
- if (!match) {
149
- return null;
150
- }
151
- try {
152
- const packageJson = require.resolve(`${match[1]}/package.json`, {
153
- paths: [projectRoot],
154
- });
155
- const packageRoot = node_path_1.default.dirname(packageJson);
156
- const candidates = [
157
- node_path_1.default.join(packageRoot, "lib", "transform.js"),
158
- node_path_1.default.join(packageRoot, "src", "transform.ts"),
159
- node_path_1.default.join(packageRoot, "bin", "ttsc-plugin.cjs"),
160
- ];
161
- return candidates.find((candidate) => node_fs_1.default.existsSync(candidate)) ?? null;
162
- }
163
- catch {
164
- return null;
165
- }
166
- }
167
129
  let cachedTtscVersion = null;
168
130
  function readTtscVersion() {
169
131
  if (cachedTtscVersion !== null) {
170
132
  return cachedTtscVersion;
171
133
  }
172
134
  try {
173
- const file = node_path_1.default.resolve(__dirname, "..", "package.json");
135
+ const file = node_path_1.default.resolve(__dirname, "..", "..", "..", "package.json");
174
136
  const pkg = JSON.parse(node_fs_1.default.readFileSync(file, "utf8"));
175
137
  cachedTtscVersion = pkg.version ?? "0.0.0";
176
138
  }
@@ -190,4 +152,4 @@ function readTsgoVersion(projectRoot) {
190
152
  return "unknown";
191
153
  }
192
154
  }
193
- //# sourceMappingURL=plugin.js.map
155
+ //# sourceMappingURL=loadProjectPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadProjectPlugins.js","sourceRoot":"","sources":["../../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IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAEnD,CAAC;QACF,iBAAiB,GAAG,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB,GAAG,OAAO,CAAC;IAC9B,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,eAAe,CAAC,WAAmB;IAC1C,IAAI,CAAC;QACH,MAAM,cAAc,GAAG,IAAA,2BAAa,EAClC,mBAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CACvC,CAAC;QACF,MAAM,OAAO,GAAG,cAAc,CAAC,OAAO,CACpC,yCAAyC,CAC1C,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAEtD,CAAC;QACF,OAAO,GAAG,CAAC,OAAO,IAAI,SAAS,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,78 @@
1
+ import type { ITtscProjectPluginConfig } from "./ITtscProjectPluginConfig";
2
+ /**
3
+ * Constructor context for {@link TtscCompiler}.
4
+ *
5
+ * Represents the project environment owned by a programmatic ttsc compiler
6
+ * instance. The context is fixed when the class is constructed: compile,
7
+ * prepare, and clean operations all use the same working directory, project
8
+ * config, native toolchain, environment, cache root, and plugin list.
9
+ *
10
+ * Keeping this context immutable prevents one `TtscCompiler` object from
11
+ * silently compiling different projects across calls. Create another compiler
12
+ * instance when any of these fields must change.
13
+ *
14
+ * @author Jeongho Nam - https://github.com/samchon
15
+ */
16
+ export interface ITtscCompilerContext {
17
+ /**
18
+ * The working directory for this compiler instance.
19
+ *
20
+ * Used to discover `tsconfig.json`, resolve relative `tsconfig` paths,
21
+ * resolve project source files, resolve plugin packages, and resolve relative
22
+ * cache paths.
23
+ *
24
+ * @default process.cwd()
25
+ */
26
+ cwd?: string;
27
+ /**
28
+ * The project configuration file for this compiler instance.
29
+ *
30
+ * Relative paths are resolved from {@link ITtscCompilerContext.cwd}. When this
31
+ * field is omitted, ttsc discovers the nearest owning `tsconfig.json` or
32
+ * `jsconfig.json` from the working directory.
33
+ */
34
+ tsconfig?: string;
35
+ /**
36
+ * Explicit TypeScript-Go executable for controlled embedding.
37
+ *
38
+ * Normal consumers should leave this unset. ttsc resolves the installed or
39
+ * bundled toolchain needed for each compile path. This field is intended for
40
+ * tests, pinned toolchains, and embedding environments that need plugin or
41
+ * CLI-compatible paths to use a specific TypeScript-Go binary.
42
+ *
43
+ * The no-plugin in-memory API path is hosted by ttsc's native compiler host
44
+ * so it can return structured diagnostics and output. Plugin-backed paths
45
+ * pass this binary through to the TypeScript-Go execution layer.
46
+ */
47
+ binary?: string;
48
+ /**
49
+ * Additional environment variables for child compiler processes.
50
+ *
51
+ * Values are merged over `process.env` before ttsc starts TypeScript-Go,
52
+ * native plugin binaries, or the native compiler host used by
53
+ * {@link TtscCompiler.compile}.
54
+ */
55
+ env?: NodeJS.ProcessEnv;
56
+ /**
57
+ * Root directory for compiled ttsc artifacts.
58
+ *
59
+ * Relative paths are resolved from {@link ITtscCompilerContext.cwd}. When
60
+ * omitted, ttsc uses its normal cache location: `TTSC_CACHE_DIR` when
61
+ * present, otherwise `node_modules/.ttsc` or `.ttsc` under the project root.
62
+ *
63
+ * The same cache stores source-plugin binaries and the lazily built native
64
+ * compiler host used for in-memory API compilation.
65
+ */
66
+ cacheDir?: string;
67
+ /**
68
+ * Plugin entries for this compiler instance.
69
+ *
70
+ * - `undefined`: read `compilerOptions.plugins` from the project config.
71
+ * - `false`: ignore project plugins for this compiler instance.
72
+ * - array: use these plugin entries instead of the project config entries.
73
+ *
74
+ * Plugin entries are resolved once per operation from this instance context.
75
+ * Per-call plugin overrides are intentionally not part of the public API.
76
+ */
77
+ plugins?: readonly ITtscProjectPluginConfig[] | false;
78
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ITtscCompilerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITtscCompilerContext.js","sourceRoot":"","sources":["../../src/structures/ITtscCompilerContext.ts"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
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
+ * The severity category of the diagnostic.
23
+ *
24
+ * Values follow TypeScript's diagnostic categories: error, warning,
25
+ * suggestion, and message.
26
+ */
27
+ category: ITtscCompilerDiagnostic.Category;
28
+ /**
29
+ * The error code or identifier associated with this diagnostic.
30
+ *
31
+ * TypeScript diagnostics normally use numeric codes such as `2322`. Native
32
+ * plugins may use stable string identifiers for plugin-defined diagnostics.
33
+ */
34
+ code: number | string;
35
+ /**
36
+ * The starting position of the issue in the source file, if available.
37
+ *
38
+ * TypeScript-Go reports this as a zero-based character offset. It is omitted
39
+ * for global diagnostics or messages that do not expose a source offset.
40
+ */
41
+ start?: number;
42
+ /**
43
+ * The length of the problematic section in the source file, if available.
44
+ *
45
+ * Omitted when TypeScript-Go or a native plugin reports only a point
46
+ * location, or when the diagnostic is not tied to a source file.
47
+ */
48
+ length?: number;
49
+ /**
50
+ * 1-based line number where the diagnostic starts, if available.
51
+ *
52
+ * This follows TypeScript's display convention rather than TypeScript-Go's
53
+ * zero-based internal line index.
54
+ */
55
+ line?: number;
56
+ /**
57
+ * 1-based character (column) position where the diagnostic starts, if
58
+ * available.
59
+ *
60
+ * This follows TypeScript's display convention rather than TypeScript-Go's
61
+ * zero-based internal column index.
62
+ */
63
+ character?: number;
64
+ /**
65
+ * The human-readable diagnostic message describing the issue.
66
+ *
67
+ * Message chains are flattened into text so callers do not need to depend on
68
+ * TypeScript-Go's internal diagnostic representation.
69
+ */
70
+ messageText: string;
71
+ }
72
+ export declare namespace ITtscCompilerDiagnostic {
73
+ /**
74
+ * Possible severity categories for diagnostics.
75
+ *
76
+ * - `"warning"`: issues that might cause problems but do not necessarily
77
+ * prevent compilation.
78
+ * - `"error"`: issues that prevent successful compilation.
79
+ * - `"suggestion"`: recommendations for code improvement.
80
+ * - `"message"`: informational notes without warning or error severity.
81
+ */
82
+ type Category = "warning" | "error" | "suggestion" | "message";
83
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ITtscCompilerDiagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITtscCompilerDiagnostic.js","sourceRoot":"","sources":["../../src/structures/ITtscCompilerDiagnostic.ts"],"names":[],"mappings":""}
@@ -0,0 +1,83 @@
1
+ import type { ITtscCompilerDiagnostic } from "./ITtscCompilerDiagnostic";
2
+ /**
3
+ * Result of a ttsc TypeScript-Go compilation operation.
4
+ *
5
+ * Represents the possible outcomes of {@link TtscCompiler.compile}, which can
6
+ * be either a successful compilation, a compilation that completed with
7
+ * diagnostics, or an unexpected host error during the compilation process.
8
+ *
9
+ * This type follows the legacy `embed-typescript` result model, but stores all
10
+ * emitted text artifacts in {@link ITtscCompilerResult.ISuccess.output} and
11
+ * {@link ITtscCompilerResult.IFailure.output}. TypeScript-Go may emit
12
+ * JavaScript, declaration files, source maps, and declaration maps from one
13
+ * compile operation, so the public result is not limited to JavaScript.
14
+ *
15
+ * @author Jeongho Nam - https://github.com/samchon
16
+ */
17
+ export type ITtscCompilerResult = ITtscCompilerResult.ISuccess | ITtscCompilerResult.IFailure | ITtscCompilerResult.IException;
18
+ export declare namespace ITtscCompilerResult {
19
+ /**
20
+ * Represents a successful ttsc compilation result.
21
+ *
22
+ * This interface is returned when TypeScript-Go completes without
23
+ * diagnostics, containing every text output captured from the native
24
+ * compiler host's `WriteFile` callback.
25
+ */
26
+ interface ISuccess {
27
+ /**
28
+ * Indicates that the compilation was successful.
29
+ */
30
+ type: "success";
31
+ /**
32
+ * The generated compiler output.
33
+ *
34
+ * A record mapping project-relative output file paths to their generated
35
+ * text content. This includes JavaScript, declaration files, source maps,
36
+ * declaration maps, and any other text artifact emitted through
37
+ * TypeScript-Go's `WriteFile` callback.
38
+ */
39
+ output: Record<string, string>;
40
+ }
41
+ /**
42
+ * Represents a ttsc compilation that completed but had diagnostics.
43
+ *
44
+ * This interface is returned when the compiler reports errors, warnings, or
45
+ * other diagnostics during normal compilation. It contains both structured
46
+ * diagnostic information and any output that was still generated despite the
47
+ * diagnostics.
48
+ */
49
+ interface IFailure {
50
+ /**
51
+ * Indicates that compilation completed with diagnostics.
52
+ */
53
+ type: "failure";
54
+ /**
55
+ * Array of diagnostic messages describing the compilation issues.
56
+ */
57
+ diagnostics: ITtscCompilerDiagnostic[];
58
+ /**
59
+ * Any compiler output that was generated despite the diagnostics.
60
+ *
61
+ * This may be partial or empty depending on the severity of the issues and
62
+ * how far TypeScript-Go progressed before returning diagnostics.
63
+ */
64
+ output: Record<string, string>;
65
+ }
66
+ /**
67
+ * Represents an unexpected error during the compilation process.
68
+ *
69
+ * This interface is returned when ttsc cannot prepare, build, or spawn the
70
+ * native compiler host. Normal TypeScript diagnostics are represented by
71
+ * {@link IFailure}; this variant is reserved for host-level exceptions.
72
+ */
73
+ interface IException {
74
+ /**
75
+ * Indicates that an unexpected host error occurred.
76
+ */
77
+ type: "exception";
78
+ /**
79
+ * The error that was thrown while preparing or running the compiler host.
80
+ */
81
+ error: unknown;
82
+ }
83
+ }
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ITtscCacheKeyInput.js.map
3
+ //# sourceMappingURL=ITtscCompilerResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITtscCompilerResult.js","sourceRoot":"","sources":["../../src/structures/ITtscCompilerResult.ts"],"names":[],"mappings":""}
@@ -1,10 +1,55 @@
1
- import type { ITtscNativeBackend } from "./ITtscNativeBackend";
2
- import type { ITtscNativeRewriteMode } from "./ITtscNativeRewriteMode";
1
+ import type { TtscPluginStage } from "./TtscPluginStage";
2
+ /**
3
+ * Runtime descriptor returned by a ttsc plugin module.
4
+ *
5
+ * A JavaScript plugin entry in `compilerOptions.plugins[]` is only the loading
6
+ * point. After ttsc resolves that JavaScript module, the module must return an
7
+ * `ITtscPlugin` descriptor either directly, as `default`, as `plugin`, or from
8
+ * `createTtscPlugin(context)`.
9
+ *
10
+ * The descriptor tells ttsc which Go command package implements the native
11
+ * sidecar and where that sidecar participates in the TypeScript-Go pipeline.
12
+ * ttsc then builds the Go source lazily with the bundled Go toolchain and
13
+ * passes the original project plugin config to the sidecar through
14
+ * `--plugins-json`.
15
+ */
3
16
  export interface ITtscPlugin {
17
+ /**
18
+ * Stable plugin name used in diagnostics, build messages, and native plugin
19
+ * manifests.
20
+ *
21
+ * Keep this stable across releases. Native sidecars and downstream tooling
22
+ * can use the name to select their own config from the ordered
23
+ * `--plugins-json` payload.
24
+ */
4
25
  name: string;
5
- native?: ITtscNativeBackend;
6
- /** @deprecated Use `native.mode` instead. */
7
- nativeMode?: ITtscNativeRewriteMode;
8
- /** @deprecated Use `native.binary` instead. */
9
- nativeBinary?: string;
26
+ /**
27
+ * Go command package directory, or a `go.mod` file, that ttsc lazily builds.
28
+ *
29
+ * ttsc accepts source only. It does not accept a prebuilt binary path: the
30
+ * package-local Go compiler builds this source into the ttsc plugin cache on
31
+ * demand.
32
+ *
33
+ * Directory sources search upward at most 3 parent directories for `go.mod`;
34
+ * direct `go.mod` sources build the module root as `.`.
35
+ *
36
+ * Common layouts:
37
+ *
38
+ * - `source: "src"` when the plugin package keeps its Go command in `src`.
39
+ * - `source: "plugin"` when the repository has a dedicated Go plugin folder.
40
+ * - `source: "lib"` only when the published package intentionally ships Go
41
+ * source under `lib` instead of compiled JavaScript.
42
+ * - `source: "go.mod"` when the module root itself is the command package.
43
+ */
44
+ source: string;
45
+ /**
46
+ * Pipeline stage implemented by the sidecar.
47
+ *
48
+ * Omit this field for normal compiler-transform plugins. Explicit stages are
49
+ * intended for tools that only validate (`"check"`) or rewrite already
50
+ * emitted files (`"output"`).
51
+ *
52
+ * @default "transform"
53
+ */
54
+ stage?: TtscPluginStage;
10
55
  }
@@ -1,8 +1,55 @@
1
1
  import type { ITtscProjectPluginConfig } from "./ITtscProjectPluginConfig";
2
+ /**
3
+ * Project context passed to `createTtscPlugin()` factories.
4
+ *
5
+ * Plugin packages may export a static {@link ITtscPlugin} descriptor when the
6
+ * descriptor never depends on the consuming project. Export a
7
+ * `createTtscPlugin(context)` factory instead when the descriptor needs to
8
+ * inspect the original plugin config, the resolved tsconfig path, or the
9
+ * project root.
10
+ *
11
+ * The factory runs in Node.js while ttsc is loading `compilerOptions.plugins`.
12
+ * It should only create the descriptor. Heavy validation and TypeScript-Go
13
+ * work belong in the Go sidecar selected by {@link ITtscPlugin.source}.
14
+ */
2
15
  export interface ITtscPluginFactoryContext<T = ITtscProjectPluginConfig> {
16
+ /**
17
+ * Absolute ttsc native helper binary selected for this invocation.
18
+ *
19
+ * This is the package's own native helper, not the plugin sidecar and not the
20
+ * JavaScript launcher. Most plugins do not need it; it is provided for
21
+ * advanced factories that need to derive behavior from the active ttsc
22
+ * native host.
23
+ */
3
24
  binary: string;
25
+ /**
26
+ * Current working directory requested by the caller.
27
+ *
28
+ * This is the cwd used for project discovery and relative command-line
29
+ * inputs. It can differ from {@link ITtscPluginFactoryContext.projectRoot}
30
+ * when the caller points at a tsconfig in another directory.
31
+ */
4
32
  cwd: string;
33
+ /**
34
+ * Original `compilerOptions.plugins[]` entry that loaded this plugin.
35
+ *
36
+ * ttsc reserves `transform` and `enabled`. Every other property is
37
+ * plugin-owned config and is later serialized unchanged into the native
38
+ * sidecar manifest.
39
+ */
5
40
  plugin: T;
41
+ /**
42
+ * Directory containing the resolved tsconfig/jsconfig.
43
+ *
44
+ * Relative plugin module specifiers and plugin source paths are resolved from
45
+ * this directory, matching TypeScript plugin config behavior.
46
+ */
6
47
  projectRoot: string;
48
+ /**
49
+ * Absolute path to the resolved tsconfig/jsconfig.
50
+ *
51
+ * Factories can use this to select descriptor variants for monorepos or
52
+ * multiple project configs without reparsing command-line arguments.
53
+ */
7
54
  tsconfig: string;
8
55
  }
@@ -1,5 +1,46 @@
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
+ * Plugin module specifier, relative path, or absolute path to load.
29
+ *
30
+ * Relative paths are resolved from the resolved project root, which is the
31
+ * directory containing the active tsconfig/jsconfig. Package specifiers are
32
+ * resolved with Node's package resolution from that same project root.
33
+ *
34
+ * The loaded JavaScript module must export an {@link ITtscPlugin} descriptor
35
+ * or a `createTtscPlugin(context)` factory. The Go implementation itself is
36
+ * declared by the descriptor's {@link ITtscPlugin.source} field.
37
+ */
3
38
  transform?: string;
39
+ /**
40
+ * Plugin-specific config passed through unchanged to the native sidecar.
41
+ *
42
+ * ttsc does not validate these fields. Plugin packages should document their
43
+ * own config contract and validate it inside their factory or Go sidecar.
44
+ */
4
45
  [key: string]: unknown;
5
46
  }
@@ -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";
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=ITtscBuildResult.js.map
3
+ //# sourceMappingURL=TtscPluginStage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TtscPluginStage.js","sourceRoot":"","sources":["../../src/structures/TtscPluginStage.ts"],"names":[],"mappings":""}
@@ -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";