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.
- package/cmd/ttsc/api_compile.go +134 -0
- package/cmd/ttsc/build.go +1 -7
- package/cmd/ttsc/main.go +2 -2
- package/cmd/ttsc/transform.go +0 -6
- package/driver/program.go +11 -1
- package/lib/TtscCompiler.d.ts +76 -0
- package/lib/TtscCompiler.js +245 -0
- package/lib/TtscCompiler.js.map +1 -0
- package/lib/compiler/internal/buildNativeCompiler.d.ts +6 -0
- package/lib/compiler/internal/buildNativeCompiler.js +72 -0
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -0
- package/lib/compiler/internal/compileProjectInMemory.d.ts +7 -0
- package/lib/compiler/internal/compileProjectInMemory.js +176 -0
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -0
- package/lib/compiler/internal/project/readProjectConfig.d.ts +4 -0
- package/lib/{project.js → compiler/internal/project/readProjectConfig.js} +12 -82
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -0
- package/lib/compiler/internal/project/resolveProjectConfig.d.ts +3 -0
- package/lib/compiler/internal/project/resolveProjectConfig.js +94 -0
- package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -0
- package/lib/compiler/internal/resolveBinary.d.ts +4 -0
- package/lib/compiler/internal/resolveBinary.js +65 -0
- package/lib/compiler/internal/resolveBinary.js.map +1 -0
- package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +7 -0
- package/lib/compiler/internal/resolveEmittedJavaScript.js +118 -0
- package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -0
- package/lib/compiler/internal/resolveTsgo.d.ts +20 -0
- package/lib/{tsgo.js → compiler/internal/resolveTsgo.js} +5 -10
- package/lib/compiler/internal/resolveTsgo.js.map +1 -0
- package/lib/compiler/internal/runBuild.d.ts +10 -0
- package/lib/compiler/internal/runBuild.js +480 -0
- package/lib/compiler/internal/runBuild.js.map +1 -0
- package/lib/compiler/internal/runTransform.d.ts +3 -0
- package/lib/compiler/internal/runTransform.js +100 -0
- package/lib/compiler/internal/runTransform.js.map +1 -0
- package/lib/index.d.ts +6 -15
- package/lib/index.js +6 -15
- package/lib/index.js.map +1 -1
- package/lib/launcher/internal/getCompilerVersionText.d.ts +3 -0
- package/lib/launcher/internal/getCompilerVersionText.js +71 -0
- package/lib/launcher/internal/getCompilerVersionText.js.map +1 -0
- package/lib/launcher/internal/prepareExecution.d.ts +10 -0
- package/lib/launcher/internal/prepareExecution.js +120 -0
- package/lib/launcher/internal/prepareExecution.js.map +1 -0
- package/lib/launcher/internal/runTtsc.d.ts +1 -0
- package/lib/{cli.js → launcher/internal/runTtsc.js} +48 -47
- package/lib/launcher/internal/runTtsc.js.map +1 -0
- package/lib/launcher/internal/runTtsx.d.ts +1 -0
- package/lib/{runner/cli.js → launcher/internal/runTtsx.js} +13 -35
- package/lib/launcher/internal/runTtsx.js.map +1 -0
- package/lib/launcher/ttsc.js +2 -2
- package/lib/launcher/ttsc.js.map +1 -1
- package/lib/launcher/ttsx.js +2 -2
- package/lib/launcher/ttsx.js.map +1 -1
- package/lib/plugin/internal/buildSourcePlugin.d.ts +12 -0
- package/lib/{source-build.js → plugin/internal/buildSourcePlugin.js} +77 -84
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -0
- package/lib/plugin/internal/loadProjectPlugins.d.ts +14 -0
- package/lib/{plugin.js → plugin/internal/loadProjectPlugins.js} +38 -76
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -0
- package/lib/structures/ITtscCompilerContext.d.ts +78 -0
- package/lib/structures/ITtscCompilerContext.js +3 -0
- package/lib/structures/ITtscCompilerContext.js.map +1 -0
- package/lib/structures/ITtscCompilerDiagnostic.d.ts +83 -0
- package/lib/structures/ITtscCompilerDiagnostic.js +3 -0
- package/lib/structures/ITtscCompilerDiagnostic.js.map +1 -0
- package/lib/structures/ITtscCompilerResult.d.ts +83 -0
- package/lib/structures/{ITtscCacheKeyInput.js → ITtscCompilerResult.js} +1 -1
- package/lib/structures/ITtscCompilerResult.js.map +1 -0
- package/lib/structures/ITtscPlugin.d.ts +52 -7
- package/lib/structures/ITtscPluginFactoryContext.d.ts +47 -0
- package/lib/structures/ITtscProjectPluginConfig.d.ts +41 -0
- package/lib/structures/TtscPluginStage.d.ts +15 -0
- package/lib/structures/{ITtscBuildResult.js → TtscPluginStage.js} +1 -1
- package/lib/structures/TtscPluginStage.js.map +1 -0
- package/lib/structures/index.d.ts +7 -0
- package/lib/structures/index.js +24 -0
- package/lib/structures/index.js.map +1 -0
- package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +13 -0
- package/lib/structures/internal/ITtscLoadedNativePlugin.js.map +1 -0
- package/lib/structures/internal/ITtscParsedProjectConfig.d.ts +15 -0
- package/lib/structures/internal/ITtscParsedProjectConfig.js.map +1 -0
- package/lib/structures/internal/ITtscProjectLocatorOptions.d.ts +9 -0
- package/lib/structures/internal/ITtscProjectLocatorOptions.js.map +1 -0
- package/lib/structures/internal/TtscBuildOptions.d.ts +18 -0
- package/lib/structures/{ITtscBuildOptions.js → internal/TtscBuildOptions.js} +1 -1
- package/lib/structures/internal/TtscBuildOptions.js.map +1 -0
- package/lib/structures/internal/TtscBuildResult.d.ts +14 -0
- package/lib/structures/{ITtscCheckOptions.js → internal/TtscBuildResult.js} +1 -1
- package/lib/structures/internal/TtscBuildResult.js.map +1 -0
- package/lib/structures/internal/TtscCommonOptions.d.ts +27 -0
- package/lib/structures/{ITtscNativeSource.js → internal/TtscCommonOptions.js} +1 -1
- package/lib/structures/internal/TtscCommonOptions.js.map +1 -0
- package/lib/structures/internal/TtscTransformOptions.d.ts +14 -0
- package/lib/structures/internal/TtscTransformOptions.js +3 -0
- package/lib/structures/internal/TtscTransformOptions.js.map +1 -0
- package/package.json +9 -9
- package/src/TtscCompiler.ts +241 -0
- package/src/compiler/internal/buildNativeCompiler.ts +43 -0
- package/src/compiler/internal/compileProjectInMemory.ts +189 -0
- package/src/{project.ts → compiler/internal/project/readProjectConfig.ts} +36 -111
- package/src/compiler/internal/project/resolveProjectConfig.ts +67 -0
- package/src/compiler/internal/resolveBinary.ts +41 -0
- package/src/compiler/internal/resolveEmittedJavaScript.ts +102 -0
- package/src/{tsgo.ts → compiler/internal/resolveTsgo.ts} +20 -23
- package/src/compiler/internal/runBuild.ts +644 -0
- package/src/compiler/internal/runTransform.ts +69 -0
- package/src/index.ts +6 -15
- package/src/launcher/internal/getCompilerVersionText.ts +44 -0
- package/src/launcher/internal/prepareExecution.ts +115 -0
- package/src/{cli.ts → launcher/internal/runTtsc.ts} +61 -70
- package/src/{runner/cli.ts → launcher/internal/runTtsx.ts} +21 -49
- package/src/launcher/ttsc.ts +2 -2
- package/src/launcher/ttsx.ts +2 -2
- package/src/{source-build.ts → plugin/internal/buildSourcePlugin.ts} +121 -115
- package/src/plugin/internal/loadProjectPlugins.ts +214 -0
- package/src/structures/ITtscCompilerContext.ts +84 -0
- package/src/structures/ITtscCompilerDiagnostic.ts +91 -0
- package/src/structures/ITtscCompilerResult.ts +94 -0
- package/src/structures/ITtscPlugin.ts +54 -7
- package/src/structures/ITtscPluginFactoryContext.ts +51 -0
- package/src/structures/ITtscProjectPluginConfig.ts +43 -0
- package/src/structures/TtscPluginStage.ts +15 -0
- package/src/structures/index.ts +7 -0
- package/src/structures/internal/ITtscLoadedNativePlugin.ts +14 -0
- package/src/structures/internal/ITtscParsedProjectConfig.ts +16 -0
- package/src/structures/internal/ITtscProjectLocatorOptions.ts +9 -0
- package/src/structures/internal/TtscBuildOptions.ts +19 -0
- package/src/structures/internal/TtscBuildResult.ts +15 -0
- package/src/structures/internal/TtscCommonOptions.ts +28 -0
- package/src/structures/internal/TtscTransformOptions.ts +15 -0
- package/test/compiler.test.ts +234 -0
- package/test/platform.test.ts +1 -45
- package/test/project.test.ts +3 -1
- package/test/source-build.test.ts +33 -220
- package/test/tsgo.test.ts +1 -8
- package/lib/api.d.ts +0 -40
- package/lib/api.js +0 -680
- package/lib/api.js.map +0 -1
- package/lib/cli.d.ts +0 -1
- package/lib/cli.js.map +0 -1
- package/lib/native.d.ts +0 -8
- package/lib/native.js +0 -42
- package/lib/native.js.map +0 -1
- package/lib/platform.d.ts +0 -52
- package/lib/platform.js +0 -175
- package/lib/platform.js.map +0 -1
- package/lib/plugin.d.ts +0 -13
- package/lib/plugin.js.map +0 -1
- package/lib/project.d.ts +0 -14
- package/lib/project.js.map +0 -1
- package/lib/runner/cli.d.ts +0 -1
- package/lib/runner/cli.js.map +0 -1
- package/lib/runner/register.d.ts +0 -6
- package/lib/runner/register.js +0 -358
- package/lib/runner/register.js.map +0 -1
- package/lib/source-build.d.ts +0 -19
- package/lib/source-build.js.map +0 -1
- package/lib/structures/ITtscBuildOptions.d.ts +0 -14
- package/lib/structures/ITtscBuildOptions.js.map +0 -1
- package/lib/structures/ITtscBuildResult.d.ts +0 -6
- package/lib/structures/ITtscBuildResult.js.map +0 -1
- package/lib/structures/ITtscBuildSourcePluginOptions.d.ts +0 -8
- package/lib/structures/ITtscBuildSourcePluginOptions.js +0 -3
- package/lib/structures/ITtscBuildSourcePluginOptions.js.map +0 -1
- package/lib/structures/ITtscCacheKeyInput.d.ts +0 -7
- package/lib/structures/ITtscCacheKeyInput.js.map +0 -1
- package/lib/structures/ITtscCheckOptions.d.ts +0 -2
- package/lib/structures/ITtscCheckOptions.js.map +0 -1
- package/lib/structures/ITtscCommonOptions.d.ts +0 -22
- package/lib/structures/ITtscCommonOptions.js +0 -3
- package/lib/structures/ITtscCommonOptions.js.map +0 -1
- package/lib/structures/ITtscLoadPluginsOptions.d.ts +0 -8
- package/lib/structures/ITtscLoadPluginsOptions.js +0 -3
- package/lib/structures/ITtscLoadPluginsOptions.js.map +0 -1
- package/lib/structures/ITtscLoadedNativePlugin.d.ts +0 -7
- package/lib/structures/ITtscLoadedNativePlugin.js.map +0 -1
- package/lib/structures/ITtscLoadedPlugins.d.ts +0 -11
- package/lib/structures/ITtscLoadedPlugins.js +0 -3
- package/lib/structures/ITtscLoadedPlugins.js.map +0 -1
- package/lib/structures/ITtscNativeBackend.d.ts +0 -10
- package/lib/structures/ITtscNativeBackend.js +0 -3
- package/lib/structures/ITtscNativeBackend.js.map +0 -1
- package/lib/structures/ITtscNativePluginContractVersion.d.ts +0 -1
- package/lib/structures/ITtscNativePluginContractVersion.js +0 -3
- package/lib/structures/ITtscNativePluginContractVersion.js.map +0 -1
- package/lib/structures/ITtscNativePluginShape.d.ts +0 -8
- package/lib/structures/ITtscNativePluginShape.js +0 -3
- package/lib/structures/ITtscNativePluginShape.js.map +0 -1
- package/lib/structures/ITtscNativeRewriteMode.d.ts +0 -1
- package/lib/structures/ITtscNativeRewriteMode.js +0 -3
- package/lib/structures/ITtscNativeRewriteMode.js.map +0 -1
- package/lib/structures/ITtscNativeSource.d.ts +0 -4
- package/lib/structures/ITtscNativeSource.js.map +0 -1
- package/lib/structures/ITtscParsedProjectConfig.d.ts +0 -9
- package/lib/structures/ITtscParsedProjectConfig.js.map +0 -1
- package/lib/structures/ITtscPluginFactory.d.ts +0 -4
- package/lib/structures/ITtscPluginFactory.js +0 -3
- package/lib/structures/ITtscPluginFactory.js.map +0 -1
- package/lib/structures/ITtscPluginModule.d.ts +0 -3
- package/lib/structures/ITtscPluginModule.js +0 -3
- package/lib/structures/ITtscPluginModule.js.map +0 -1
- package/lib/structures/ITtscPreparedExecution.d.ts +0 -5
- package/lib/structures/ITtscPreparedExecution.js +0 -3
- package/lib/structures/ITtscPreparedExecution.js.map +0 -1
- package/lib/structures/ITtscProjectLocatorOptions.d.ts +0 -5
- package/lib/structures/ITtscProjectLocatorOptions.js.map +0 -1
- package/lib/structures/ITtscRegisterOptions.d.ts +0 -6
- package/lib/structures/ITtscRegisterOptions.js +0 -3
- package/lib/structures/ITtscRegisterOptions.js.map +0 -1
- package/lib/structures/ITtscResolveGoBinaryOptions.d.ts +0 -7
- package/lib/structures/ITtscResolveGoBinaryOptions.js +0 -3
- package/lib/structures/ITtscResolveGoBinaryOptions.js.map +0 -1
- package/lib/structures/ITtscResolveOptions.d.ts +0 -20
- package/lib/structures/ITtscResolveOptions.js +0 -3
- package/lib/structures/ITtscResolveOptions.js.map +0 -1
- package/lib/structures/ITtscResolvedTsgo.d.ts +0 -8
- package/lib/structures/ITtscResolvedTsgo.js +0 -3
- package/lib/structures/ITtscResolvedTsgo.js.map +0 -1
- package/lib/structures/ITtscTransformOptions.d.ts +0 -12
- package/lib/structures/ITtscTransformOptions.js +0 -3
- package/lib/structures/ITtscTransformOptions.js.map +0 -1
- package/lib/structures/ITtscTsgoResolveOptions.d.ts +0 -14
- package/lib/structures/ITtscTsgoResolveOptions.js +0 -3
- package/lib/structures/ITtscTsgoResolveOptions.js.map +0 -1
- package/lib/tsgo.d.ts +0 -6
- package/lib/tsgo.js.map +0 -1
- package/src/api.ts +0 -872
- package/src/native.ts +0 -64
- package/src/platform.ts +0 -151
- package/src/plugin.ts +0 -253
- package/src/runner/register.ts +0 -406
- package/src/structures/ITtscBuildOptions.ts +0 -19
- package/src/structures/ITtscBuildResult.ts +0 -6
- package/src/structures/ITtscBuildSourcePluginOptions.ts +0 -9
- package/src/structures/ITtscCacheKeyInput.ts +0 -7
- package/src/structures/ITtscCheckOptions.ts +0 -3
- package/src/structures/ITtscCommonOptions.ts +0 -23
- package/src/structures/ITtscLoadPluginsOptions.ts +0 -9
- package/src/structures/ITtscLoadedNativePlugin.ts +0 -8
- package/src/structures/ITtscLoadedPlugins.ts +0 -12
- package/src/structures/ITtscNativeBackend.ts +0 -11
- package/src/structures/ITtscNativePluginContractVersion.ts +0 -1
- package/src/structures/ITtscNativePluginShape.ts +0 -9
- package/src/structures/ITtscNativeRewriteMode.ts +0 -1
- package/src/structures/ITtscNativeSource.ts +0 -4
- package/src/structures/ITtscParsedProjectConfig.ts +0 -10
- package/src/structures/ITtscPluginFactory.ts +0 -7
- package/src/structures/ITtscPluginModule.ts +0 -4
- package/src/structures/ITtscPreparedExecution.ts +0 -5
- package/src/structures/ITtscProjectLocatorOptions.ts +0 -5
- package/src/structures/ITtscRegisterOptions.ts +0 -7
- package/src/structures/ITtscResolveGoBinaryOptions.ts +0 -7
- package/src/structures/ITtscResolveOptions.ts +0 -20
- package/src/structures/ITtscResolvedTsgo.ts +0 -8
- package/src/structures/ITtscTransformOptions.ts +0 -13
- package/src/structures/ITtscTsgoResolveOptions.ts +0 -14
- package/test/native.test.ts +0 -103
- /package/lib/structures/{ITtscLoadedNativePlugin.js → internal/ITtscLoadedNativePlugin.js} +0 -0
- /package/lib/structures/{ITtscParsedProjectConfig.js → internal/ITtscParsedProjectConfig.js} +0 -0
- /package/lib/structures/{ITtscProjectLocatorOptions.js → internal/ITtscProjectLocatorOptions.js} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.runTransform = runTransform;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const os = __importStar(require("node:os"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const resolveProjectConfig_1 = require("./project/resolveProjectConfig");
|
|
41
|
+
const resolveEmittedJavaScript_1 = require("./resolveEmittedJavaScript");
|
|
42
|
+
const runBuild_1 = require("./runBuild");
|
|
43
|
+
/** Transform one source file by emitting its project into a temporary directory. */
|
|
44
|
+
function runTransform(options) {
|
|
45
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
46
|
+
const sourceFile = realpathIfExists(path.isAbsolute(options.file) ? options.file : path.resolve(cwd, options.file));
|
|
47
|
+
const tsconfig = (0, resolveProjectConfig_1.resolveProjectConfig)({
|
|
48
|
+
cwd,
|
|
49
|
+
file: sourceFile,
|
|
50
|
+
tsconfig: options.tsconfig,
|
|
51
|
+
});
|
|
52
|
+
const projectRoot = path.dirname(tsconfig);
|
|
53
|
+
const outDir = fs.mkdtempSync(path.join(os.tmpdir(), "ttsc-transform-"));
|
|
54
|
+
try {
|
|
55
|
+
const result = (0, runBuild_1.runBuild)({
|
|
56
|
+
...options,
|
|
57
|
+
cwd,
|
|
58
|
+
emit: true,
|
|
59
|
+
forceListEmittedFiles: true,
|
|
60
|
+
outDir,
|
|
61
|
+
tsconfig,
|
|
62
|
+
});
|
|
63
|
+
if (result.status !== 0) {
|
|
64
|
+
throw new Error("ttsc transform exited " +
|
|
65
|
+
result.status +
|
|
66
|
+
"\n" +
|
|
67
|
+
(result.stderr || result.stdout));
|
|
68
|
+
}
|
|
69
|
+
const emitted = (0, resolveEmittedJavaScript_1.resolveEmittedJavaScript)({
|
|
70
|
+
emittedFiles: result.emittedFiles,
|
|
71
|
+
outDir,
|
|
72
|
+
projectRoot,
|
|
73
|
+
sourceFile,
|
|
74
|
+
});
|
|
75
|
+
if (emitted === null) {
|
|
76
|
+
throw new Error(`ttsc transform: no output produced for ${sourceFile}`);
|
|
77
|
+
}
|
|
78
|
+
const transformed = fs.readFileSync(emitted, "utf8");
|
|
79
|
+
if (options.out) {
|
|
80
|
+
const target = path.isAbsolute(options.out)
|
|
81
|
+
? options.out
|
|
82
|
+
: path.resolve(cwd, options.out);
|
|
83
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
84
|
+
fs.writeFileSync(target, transformed, "utf8");
|
|
85
|
+
}
|
|
86
|
+
return transformed;
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
fs.rmSync(outDir, { recursive: true, force: true });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function realpathIfExists(file) {
|
|
93
|
+
try {
|
|
94
|
+
return fs.realpathSync(file);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return file;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=runTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTransform.js","sourceRoot":"","sources":["../../../src/compiler/internal/runTransform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,oCAAgB;AAC9B,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;AAGlC,yEAAsE;AACtE,yEAAsE;AACtE,yCAAsC;AAEtC,oFAAoF;AACpF,sBAA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ACrB,MAAM,IAAI,KAAK,CAAC,0CAA0C,UAAU,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACrD,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC;gBACzC,CAAC,CAAC,OAAO,CAAC,GAAG;gBACb,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;YACnC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACxD,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;YAAS,CAAC;QACT,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ttsc — public TypeScript entry.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* helper resolution for commands such as `ttsc demo`.
|
|
9
|
-
* - programmatic API (`transform`, `build`, `check`, `version`) — a thin
|
|
10
|
-
* TS wrapper around the consumer `tsgo` binary and native plugin
|
|
11
|
-
* descriptors. Adapters never have to shell out themselves; they call
|
|
12
|
-
* these helpers and get back a string or a result record.
|
|
4
|
+
* The package root intentionally exposes only the programmatic compiler class
|
|
5
|
+
* and the plugin-author contracts. CLI launcher functions, binary resolution,
|
|
6
|
+
* project parsing helpers, and native build helpers stay internal so the
|
|
7
|
+
* public package surface remains small and stable.
|
|
13
8
|
*/
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
16
|
-
export * from "./project";
|
|
17
|
-
export * from "./plugin";
|
|
18
|
-
export * from "./tsgo";
|
|
19
|
-
export * from "./runner/register";
|
|
9
|
+
export * from "./TtscCompiler";
|
|
10
|
+
export * from "./structures/index";
|
package/lib/index.js
CHANGED
|
@@ -2,15 +2,10 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* ttsc — public TypeScript entry.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* helper resolution for commands such as `ttsc demo`.
|
|
10
|
-
* - programmatic API (`transform`, `build`, `check`, `version`) — a thin
|
|
11
|
-
* TS wrapper around the consumer `tsgo` binary and native plugin
|
|
12
|
-
* descriptors. Adapters never have to shell out themselves; they call
|
|
13
|
-
* these helpers and get back a string or a result record.
|
|
5
|
+
* The package root intentionally exposes only the programmatic compiler class
|
|
6
|
+
* and the plugin-author contracts. CLI launcher functions, binary resolution,
|
|
7
|
+
* project parsing helpers, and native build helpers stay internal so the
|
|
8
|
+
* public package surface remains small and stable.
|
|
14
9
|
*/
|
|
15
10
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
11
|
if (k2 === undefined) k2 = k;
|
|
@@ -27,10 +22,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
27
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
23
|
};
|
|
29
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
__exportStar(require("./
|
|
31
|
-
__exportStar(require("./
|
|
32
|
-
__exportStar(require("./project"), exports);
|
|
33
|
-
__exportStar(require("./plugin"), exports);
|
|
34
|
-
__exportStar(require("./tsgo"), exports);
|
|
35
|
-
__exportStar(require("./runner/register"), exports);
|
|
25
|
+
__exportStar(require("./TtscCompiler"), exports);
|
|
26
|
+
__exportStar(require("./structures/index"), exports);
|
|
36
27
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;;;;;AAEH,iDAA+B;AAC/B,qDAAmC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getCompilerVersionText = getCompilerVersionText;
|
|
37
|
+
const node_child_process_1 = require("node:child_process");
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const resolveTsgo_1 = require("../../compiler/internal/resolveTsgo");
|
|
41
|
+
/** Format the CLI version banner from the wrapper package and resolved tsgo. */
|
|
42
|
+
function getCompilerVersionText(options = {}) {
|
|
43
|
+
const tsgo = (0, resolveTsgo_1.resolveTsgo)(options);
|
|
44
|
+
const res = (0, node_child_process_1.spawnSync)(tsgo.binary, ["--version"], {
|
|
45
|
+
encoding: "utf8",
|
|
46
|
+
maxBuffer: 1024 * 1024 * 16,
|
|
47
|
+
windowsHide: true,
|
|
48
|
+
});
|
|
49
|
+
if (res.error || res.status !== 0) {
|
|
50
|
+
throw new Error("ttsc.version: failed: " +
|
|
51
|
+
(outputText(res.stderr) || res.error?.message));
|
|
52
|
+
}
|
|
53
|
+
return `ttsc ${readOwnPackageVersion()} (${outputText(res.stdout).trim()})`;
|
|
54
|
+
}
|
|
55
|
+
function outputText(value) {
|
|
56
|
+
if (value == null) {
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
return typeof value === "string" ? value : value.toString("utf8");
|
|
60
|
+
}
|
|
61
|
+
function readOwnPackageVersion() {
|
|
62
|
+
try {
|
|
63
|
+
const file = path.resolve(__dirname, "..", "..", "..", "package.json");
|
|
64
|
+
const pkg = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
65
|
+
return pkg.version ?? "0.0.0";
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return "0.0.0";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=getCompilerVersionText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCompilerVersionText.js","sourceRoot":"","sources":["../../../src/launcher/internal/getCompilerVersionText.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA+C;AAC/C,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;AAElC,qEAAkE;AAGlE,gFAAgF;AAChF,gCACE,OAAO,GAAsB,EAAE;IAE/B,MAAM,IAAI,GAAG,IAAA,yBAAW,EAAC,OAAO,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,IAAA,8BAAS,EAAC,IAAI,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE;QAChD,QAAQ,EAAE,MAAM;QAChB,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,EAAE;QAC3B,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,wBAAwB;YACtB,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CACjD,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,qBAAqB,EAAE,KAAK,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC;AAC9E,CAAC;AAED,SAAS,UAAU,CAAC,KAAyC;IAC3D,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,qBAAqB;IAC5B,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACvE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAEnD,CAAC;QACF,OAAO,GAAG,CAAC,OAAO,IAAI,OAAO,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TtscCommonOptions } from "../../structures/internal/TtscCommonOptions";
|
|
2
|
+
/** Build the owning project and locate the emitted JavaScript entry for `ttsx`. */
|
|
3
|
+
export declare function prepareExecution(entryFile: string, options?: TtscCommonOptions & {
|
|
4
|
+
cacheDir?: string;
|
|
5
|
+
project?: string;
|
|
6
|
+
}): {
|
|
7
|
+
emitDir: string;
|
|
8
|
+
entryFile: string;
|
|
9
|
+
moduleKind: "cjs" | "esm";
|
|
10
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.prepareExecution = prepareExecution;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
const resolveEmittedJavaScript_1 = require("../../compiler/internal/resolveEmittedJavaScript");
|
|
40
|
+
const runBuild_1 = require("../../compiler/internal/runBuild");
|
|
41
|
+
const resolveProjectConfig_1 = require("../../compiler/internal/project/resolveProjectConfig");
|
|
42
|
+
const PROCESS_CACHE_KEY = String(process.pid);
|
|
43
|
+
/** Build the owning project and locate the emitted JavaScript entry for `ttsx`. */
|
|
44
|
+
function prepareExecution(entryFile, options = {}) {
|
|
45
|
+
const context = createProjectContext(path.resolve(options.cwd ?? process.cwd()), entryFile, options);
|
|
46
|
+
buildProject(context, options);
|
|
47
|
+
const emittedEntry = (0, resolveEmittedJavaScript_1.resolveEmittedJavaScript)({
|
|
48
|
+
emittedFiles: context.emittedFiles ?? undefined,
|
|
49
|
+
outDir: context.emitDir,
|
|
50
|
+
projectRoot: context.root,
|
|
51
|
+
sourceFile: entryFile,
|
|
52
|
+
});
|
|
53
|
+
if (emittedEntry === null) {
|
|
54
|
+
throw new Error(`ttsx: emitted entry not found for ${entryFile}`);
|
|
55
|
+
}
|
|
56
|
+
const output = fs.readFileSync(emittedEntry, "utf8");
|
|
57
|
+
return {
|
|
58
|
+
emitDir: context.emitDir,
|
|
59
|
+
entryFile: emittedEntry,
|
|
60
|
+
moduleKind: looksLikeESM(output) ? "esm" : "cjs",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function createProjectContext(cwd, filename, options) {
|
|
64
|
+
const tsconfig = options.project
|
|
65
|
+
? (0, resolveProjectConfig_1.resolveProjectConfig)({ cwd, tsconfig: path.resolve(cwd, options.project) })
|
|
66
|
+
: (0, resolveProjectConfig_1.resolveProjectConfig)({ cwd, file: filename });
|
|
67
|
+
const root = path.dirname(tsconfig);
|
|
68
|
+
const cacheDir = options.cacheDir ?? path.join(root, "node_modules", ".cache", "ttsc", "ttsx");
|
|
69
|
+
return {
|
|
70
|
+
tsconfig,
|
|
71
|
+
root,
|
|
72
|
+
cacheDir,
|
|
73
|
+
emitDir: path.join(cacheDir, "project", PROCESS_CACHE_KEY),
|
|
74
|
+
built: false,
|
|
75
|
+
emittedFiles: undefined,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function buildProject(context, options) {
|
|
79
|
+
if (context.built)
|
|
80
|
+
return;
|
|
81
|
+
fs.mkdirSync(context.cacheDir, { recursive: true });
|
|
82
|
+
fs.rmSync(context.emitDir, { recursive: true, force: true });
|
|
83
|
+
const result = (0, runBuild_1.runBuild)({
|
|
84
|
+
binary: options.binary,
|
|
85
|
+
cwd: context.root,
|
|
86
|
+
emit: true,
|
|
87
|
+
env: options.env,
|
|
88
|
+
forceListEmittedFiles: true,
|
|
89
|
+
outDir: context.emitDir,
|
|
90
|
+
plugins: options.plugins,
|
|
91
|
+
quiet: true,
|
|
92
|
+
tsconfig: context.tsconfig,
|
|
93
|
+
});
|
|
94
|
+
if (result.status === 0) {
|
|
95
|
+
context.built = true;
|
|
96
|
+
context.emittedFiles =
|
|
97
|
+
result.emittedFiles && result.emittedFiles.length !== 0
|
|
98
|
+
? result.emittedFiles
|
|
99
|
+
: undefined;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
fs.rmSync(context.emitDir, { recursive: true, force: true });
|
|
103
|
+
const detail = [
|
|
104
|
+
`ttsx: project check failed for ${context.tsconfig}`,
|
|
105
|
+
result.stderr || result.stdout,
|
|
106
|
+
]
|
|
107
|
+
.filter((line) => line.trim().length !== 0)
|
|
108
|
+
.join("\n");
|
|
109
|
+
throw new Error(detail);
|
|
110
|
+
}
|
|
111
|
+
function looksLikeESM(output) {
|
|
112
|
+
if (/\bObject\.defineProperty\(exports\b/.test(output) ||
|
|
113
|
+
/\bmodule\.exports\b/.test(output) ||
|
|
114
|
+
/\brequire\(/.test(output) ||
|
|
115
|
+
/\bexports\./.test(output)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return /^\s*(import|export)\s/m.test(output);
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=prepareExecution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareExecution.js","sourceRoot":"","sources":["../../../src/launcher/internal/prepareExecution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;AAElC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AAC;QACrB,OAAO,CAAC,YAAY;YAClB,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,CAAC,MAAM,KAAK,CAAC;gBACrD,CAAC,CAAC,MAAM,CAAC,YAAY;gBACrB,CAAC,CAAC,SAAS,CAAC;QAChB,OAAO;IACT,CAAC;IAED,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG;QACb,kCAAkC,OAAO,CAAC,QAAQ,EAAE;QACpD,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM;KAC/B;SACE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;SAC1C,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,YAAY,CAAC,MAAc;IAClC,IACE,qCAAqC,CAAC,IAAI,CAAC,MAAM,CAAC;QAClD,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC;QAClC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1B,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAC1B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runTtsc(argv?: readonly string[]): number;
|
|
@@ -33,15 +33,16 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
36
|
+
exports.runTtsc = runTtsc;
|
|
37
37
|
const node_child_process_1 = require("node:child_process");
|
|
38
38
|
const fs = __importStar(require("node:fs"));
|
|
39
39
|
const path = __importStar(require("node:path"));
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
40
|
+
const resolveBinary_1 = require("../../compiler/internal/resolveBinary");
|
|
41
|
+
const runBuild_1 = require("../../compiler/internal/runBuild");
|
|
42
|
+
const runTransform_1 = require("../../compiler/internal/runTransform");
|
|
43
|
+
const resolveProjectConfig_1 = require("../../compiler/internal/project/resolveProjectConfig");
|
|
44
|
+
const getCompilerVersionText_1 = require("./getCompilerVersionText");
|
|
45
|
+
function runTtsc(argv = process.argv.slice(2)) {
|
|
45
46
|
try {
|
|
46
47
|
if (argv.length === 0) {
|
|
47
48
|
return runCompatibleBuild([], false);
|
|
@@ -56,7 +57,7 @@ function main(argv = process.argv.slice(2)) {
|
|
|
56
57
|
case "-v":
|
|
57
58
|
case "--version":
|
|
58
59
|
case "version":
|
|
59
|
-
process.stdout.write(`${(0,
|
|
60
|
+
process.stdout.write(`${(0, getCompilerVersionText_1.getCompilerVersionText)()}\n`);
|
|
60
61
|
return 0;
|
|
61
62
|
case "build":
|
|
62
63
|
return runCompatibleBuild(rest, false);
|
|
@@ -65,7 +66,7 @@ function main(argv = process.argv.slice(2)) {
|
|
|
65
66
|
case "clean":
|
|
66
67
|
return runClean(rest);
|
|
67
68
|
case "transform":
|
|
68
|
-
return
|
|
69
|
+
return runTransformCommand(rest);
|
|
69
70
|
case "demo":
|
|
70
71
|
return delegateToNative(argv);
|
|
71
72
|
case "-p":
|
|
@@ -98,16 +99,16 @@ function runCompatibleBuild(argv, checkOnly) {
|
|
|
98
99
|
if (options.files.length !== 0) {
|
|
99
100
|
return runSingleFile(options);
|
|
100
101
|
}
|
|
101
|
-
const result =
|
|
102
|
+
const result = (0, runBuild_1.runBuild)(checkOnly ? { ...options, emit: false } : options);
|
|
102
103
|
if (result.stdout)
|
|
103
104
|
process.stdout.write(result.stdout);
|
|
104
105
|
if (result.stderr)
|
|
105
106
|
process.stderr.write(result.stderr);
|
|
106
107
|
return result.status;
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
+
function runTransformCommand(argv) {
|
|
109
110
|
const options = parseTransformArgs(argv);
|
|
110
|
-
const text = (0,
|
|
111
|
+
const text = (0, runTransform_1.runTransform)(options);
|
|
111
112
|
if (!options.out) {
|
|
112
113
|
process.stdout.write(text);
|
|
113
114
|
}
|
|
@@ -117,7 +118,13 @@ function runClean(argv) {
|
|
|
117
118
|
const options = parseCleanArgs(argv);
|
|
118
119
|
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
119
120
|
const projectRoot = resolveCleanProjectRoot(cwd, options.tsconfig);
|
|
120
|
-
const targets =
|
|
121
|
+
const targets = [
|
|
122
|
+
path.join(projectRoot, "node_modules", ".ttsc"),
|
|
123
|
+
path.join(projectRoot, ".ttsc"),
|
|
124
|
+
...(process.env.TTSC_CACHE_DIR
|
|
125
|
+
? [path.resolve(process.env.TTSC_CACHE_DIR, "plugins")]
|
|
126
|
+
: []),
|
|
127
|
+
];
|
|
121
128
|
const removed = [];
|
|
122
129
|
for (const target of targets) {
|
|
123
130
|
if (!fs.existsSync(target))
|
|
@@ -136,7 +143,7 @@ function runClean(argv) {
|
|
|
136
143
|
}
|
|
137
144
|
function resolveCleanProjectRoot(cwd, tsconfig) {
|
|
138
145
|
try {
|
|
139
|
-
return path.dirname((0,
|
|
146
|
+
return path.dirname((0, resolveProjectConfig_1.resolveProjectConfig)({ cwd, tsconfig }));
|
|
140
147
|
}
|
|
141
148
|
catch (error) {
|
|
142
149
|
if (tsconfig)
|
|
@@ -152,12 +159,18 @@ function formatCleanPath(cwd, target) {
|
|
|
152
159
|
return relative;
|
|
153
160
|
}
|
|
154
161
|
function delegateToNative(argv) {
|
|
155
|
-
const bin = (0,
|
|
162
|
+
const bin = (0, resolveBinary_1.resolveBinary)();
|
|
156
163
|
if (!bin) {
|
|
157
|
-
process.stderr.write(
|
|
164
|
+
process.stderr.write([
|
|
165
|
+
`ttsc: platform-specific helper binary not found (@ttsc/${process.platform}-${process.arch}).`,
|
|
166
|
+
`Set TTSC_BINARY to an absolute helper path or reinstall with optional dependencies enabled.`,
|
|
167
|
+
].join("\n") + "\n");
|
|
158
168
|
return 1;
|
|
159
169
|
}
|
|
160
170
|
const viaNode = /\.(?:[cm]?js|ts)$/i.test(bin);
|
|
171
|
+
if (!viaNode) {
|
|
172
|
+
ensureExecutable(bin);
|
|
173
|
+
}
|
|
161
174
|
const result = (0, node_child_process_1.spawnSync)(viaNode ? process.execPath : bin, viaNode ? [bin, ...argv] : [...argv], {
|
|
162
175
|
stdio: "inherit",
|
|
163
176
|
env: process.env,
|
|
@@ -169,6 +182,21 @@ function delegateToNative(argv) {
|
|
|
169
182
|
}
|
|
170
183
|
return result.status ?? 1;
|
|
171
184
|
}
|
|
185
|
+
function ensureExecutable(binary) {
|
|
186
|
+
if (process.platform === "win32") {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const mode = fs.statSync(binary).mode & 0o777;
|
|
191
|
+
if ((mode & 0o111) !== 0) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
fs.chmodSync(binary, mode | 0o755);
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
/* keep the original spawn error path */
|
|
198
|
+
}
|
|
199
|
+
}
|
|
172
200
|
function parseCleanArgs(argv) {
|
|
173
201
|
let cwd;
|
|
174
202
|
let tsconfig;
|
|
@@ -210,7 +238,6 @@ function parseBuildArgs(argv, checkOnly) {
|
|
|
210
238
|
let outDir;
|
|
211
239
|
let preserveWatchOutput = false;
|
|
212
240
|
let quiet = true;
|
|
213
|
-
let rewriteMode;
|
|
214
241
|
let tsconfig;
|
|
215
242
|
let watch = false;
|
|
216
243
|
const rest = [...argv];
|
|
@@ -236,9 +263,6 @@ function parseBuildArgs(argv, checkOnly) {
|
|
|
236
263
|
case "--preserveWatchOutput":
|
|
237
264
|
preserveWatchOutput = true;
|
|
238
265
|
break;
|
|
239
|
-
case "--rewrite-mode":
|
|
240
|
-
rewriteMode = takeRewriteMode(takeValue(current, rest));
|
|
241
|
-
break;
|
|
242
266
|
case "--cwd":
|
|
243
267
|
cwd = takeValue(current, rest);
|
|
244
268
|
break;
|
|
@@ -263,9 +287,6 @@ function parseBuildArgs(argv, checkOnly) {
|
|
|
263
287
|
else if (current === "-w") {
|
|
264
288
|
watch = true;
|
|
265
289
|
}
|
|
266
|
-
else if (current.startsWith("--rewrite-mode=")) {
|
|
267
|
-
rewriteMode = takeRewriteMode(current.slice("--rewrite-mode=".length));
|
|
268
|
-
}
|
|
269
290
|
else if (current.startsWith("--tsconfig=")) {
|
|
270
291
|
tsconfig = current.slice("--tsconfig=".length);
|
|
271
292
|
}
|
|
@@ -299,7 +320,6 @@ function parseBuildArgs(argv, checkOnly) {
|
|
|
299
320
|
outDir,
|
|
300
321
|
preserveWatchOutput,
|
|
301
322
|
quiet,
|
|
302
|
-
rewriteMode,
|
|
303
323
|
tsconfig,
|
|
304
324
|
watch,
|
|
305
325
|
};
|
|
@@ -309,7 +329,6 @@ function parseTransformArgs(argv) {
|
|
|
309
329
|
let cwd;
|
|
310
330
|
let file;
|
|
311
331
|
let out;
|
|
312
|
-
let rewriteMode;
|
|
313
332
|
let tsconfig;
|
|
314
333
|
const rest = [...argv];
|
|
315
334
|
while (rest.length !== 0) {
|
|
@@ -327,9 +346,6 @@ function parseTransformArgs(argv) {
|
|
|
327
346
|
case "--out":
|
|
328
347
|
out = takeValue(current, rest);
|
|
329
348
|
break;
|
|
330
|
-
case "--rewrite-mode":
|
|
331
|
-
rewriteMode = takeRewriteMode(takeValue(current, rest));
|
|
332
|
-
break;
|
|
333
349
|
case "--tsconfig":
|
|
334
350
|
case "--project":
|
|
335
351
|
tsconfig = takeValue(current, rest);
|
|
@@ -347,9 +363,6 @@ function parseTransformArgs(argv) {
|
|
|
347
363
|
else if (current.startsWith("--out=")) {
|
|
348
364
|
out = current.slice("--out=".length);
|
|
349
365
|
}
|
|
350
|
-
else if (current.startsWith("--rewrite-mode=")) {
|
|
351
|
-
rewriteMode = takeRewriteMode(current.slice("--rewrite-mode=".length));
|
|
352
|
-
}
|
|
353
366
|
else if (current.startsWith("--tsconfig=")) {
|
|
354
367
|
tsconfig = current.slice("--tsconfig=".length);
|
|
355
368
|
}
|
|
@@ -370,7 +383,6 @@ function parseTransformArgs(argv) {
|
|
|
370
383
|
cwd,
|
|
371
384
|
file,
|
|
372
385
|
out,
|
|
373
|
-
rewriteMode,
|
|
374
386
|
tsconfig,
|
|
375
387
|
};
|
|
376
388
|
}
|
|
@@ -397,7 +409,6 @@ function printHelp() {
|
|
|
397
409
|
" -w, --watch Rebuild when project files change",
|
|
398
410
|
" --preserveWatchOutput Do not clear the screen between watch rebuilds",
|
|
399
411
|
" --outDir <dir> Override compilerOptions.outDir for this invocation",
|
|
400
|
-
" --rewrite-mode <mode> Plugin-selected native rewrite backend id",
|
|
401
412
|
" --quiet Keep build output quiet (default)",
|
|
402
413
|
" --verbose Print the build summary and emitted files",
|
|
403
414
|
" --out <path> Write transform output to a file instead of stdout",
|
|
@@ -422,12 +433,11 @@ function runSingleFile(options) {
|
|
|
422
433
|
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
423
434
|
const file = path.resolve(cwd, options.files[0]);
|
|
424
435
|
const out = resolveSingleFileOut(file, cwd, options.outDir);
|
|
425
|
-
const text = (0,
|
|
436
|
+
const text = (0, runTransform_1.runTransform)({
|
|
426
437
|
binary: options.binary,
|
|
427
438
|
cwd,
|
|
428
439
|
file,
|
|
429
440
|
out,
|
|
430
|
-
rewriteMode: options.rewriteMode,
|
|
431
441
|
tsconfig: options.tsconfig,
|
|
432
442
|
});
|
|
433
443
|
if (!fs.existsSync(out)) {
|
|
@@ -452,14 +462,11 @@ function runWatch(options, checkOnly) {
|
|
|
452
462
|
cwd,
|
|
453
463
|
quiet: true,
|
|
454
464
|
};
|
|
455
|
-
const root = path.dirname((0,
|
|
465
|
+
const root = path.dirname((0, resolveProjectConfig_1.resolveProjectConfig)({
|
|
456
466
|
cwd,
|
|
457
467
|
tsconfig: options.tsconfig,
|
|
458
468
|
}));
|
|
459
|
-
const watchRoot =
|
|
460
|
-
cwd,
|
|
461
|
-
tsconfig: options.tsconfig,
|
|
462
|
-
});
|
|
469
|
+
const watchRoot = root;
|
|
463
470
|
const directories = collectWatchDirectories(watchRoot);
|
|
464
471
|
const watchers = directories.map((dir) => fs.watch(dir, { persistent: true }, () => trigger()));
|
|
465
472
|
let running = false;
|
|
@@ -474,7 +481,7 @@ function runWatch(options, checkOnly) {
|
|
|
474
481
|
const status = invocation.files.length !== 0
|
|
475
482
|
? runSingleFile(invocation)
|
|
476
483
|
: (() => {
|
|
477
|
-
const result =
|
|
484
|
+
const result = (0, runBuild_1.runBuild)(checkOnly ? { ...invocation, emit: false } : invocation);
|
|
478
485
|
if (result.stdout)
|
|
479
486
|
process.stdout.write(result.stdout);
|
|
480
487
|
if (result.stderr)
|
|
@@ -542,16 +549,10 @@ function takeValue(flag, rest) {
|
|
|
542
549
|
}
|
|
543
550
|
return value;
|
|
544
551
|
}
|
|
545
|
-
function takeRewriteMode(value) {
|
|
546
|
-
if (value.length === 0) {
|
|
547
|
-
throw new Error("ttsc: rewrite mode must not be empty");
|
|
548
|
-
}
|
|
549
|
-
return value;
|
|
550
|
-
}
|
|
551
552
|
function formatError(error) {
|
|
552
553
|
if (error instanceof Error) {
|
|
553
554
|
return error.message;
|
|
554
555
|
}
|
|
555
556
|
return String(error);
|
|
556
557
|
}
|
|
557
|
-
//# sourceMappingURL=
|
|
558
|
+
//# sourceMappingURL=runTtsc.js.map
|