ttsc 0.12.3 → 0.13.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/platform/main.go +9 -0
- package/cmd/ttsc/api_compile.go +122 -101
- package/cmd/ttsc/api_compile_branches_test.go +55 -57
- package/cmd/ttsc/api_transform.go +67 -49
- package/cmd/ttsc/api_transform_branches_test.go +30 -32
- package/cmd/ttsc/build.go +141 -108
- package/cmd/ttsc/build_branches_test.go +95 -97
- package/cmd/ttsc/filter.go +70 -0
- package/cmd/ttsc/filter_strips_unknown_forwarded_flag_test.go +61 -0
- package/cmd/ttsc/flags_gen.go +30 -0
- package/cmd/ttsc/helpers_test.go +39 -28
- package/cmd/ttsc/main.go +111 -104
- package/cmd/ttsc/main_alias_branches_test.go +21 -23
- package/cmd/ttscserver/main.go +96 -90
- package/cmd/ttscserver/run_lsp_prefers_tsgo_flag_test.go +22 -22
- package/cmd/ttscserver/run_lsp_reports_server_error_test.go +22 -22
- package/cmd/ttscserver/run_lsp_uses_tsgo_environment_test.go +23 -23
- package/cmd/utility-host/main.go +30 -23
- package/driver/lsp.go +53 -7
- package/driver/plugins.go +88 -72
- package/driver/program.go +464 -340
- package/driver/rewrite.go +477 -380
- package/internal/lspserver/lsp_envelope.go +64 -64
- package/internal/lspserver/lsp_frame.go +60 -60
- package/internal/lspserver/lsp_plugin.go +57 -57
- package/internal/lspserver/lsp_proxy.go +265 -251
- package/internal/lspserver/lsp_server.go +155 -144
- package/lib/TtscCompiler.d.ts +7 -0
- package/lib/TtscCompiler.js +7 -0
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/compiler/internal/buildNativeCompiler.d.ts +11 -1
- package/lib/compiler/internal/buildNativeCompiler.js +23 -3
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
- package/lib/compiler/internal/compileProjectInMemory.d.ts +9 -0
- package/lib/compiler/internal/compileProjectInMemory.js +36 -21
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/paths.d.ts +27 -0
- package/lib/compiler/internal/paths.js +70 -0
- package/lib/compiler/internal/paths.js.map +1 -0
- package/lib/compiler/internal/project/readProjectConfig.d.ts +9 -1
- package/lib/compiler/internal/project/readProjectConfig.js +80 -1
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/project/resolveProjectConfig.d.ts +13 -1
- package/lib/compiler/internal/project/resolveProjectConfig.js +42 -1
- package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -1
- package/lib/compiler/internal/resolveBinary.d.ts +9 -1
- package/lib/compiler/internal/resolveBinary.js +17 -1
- package/lib/compiler/internal/resolveBinary.js.map +1 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +16 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.js +42 -10
- package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -1
- package/lib/compiler/internal/resolveTsgo.d.ts +21 -1
- package/lib/compiler/internal/resolveTsgo.js +23 -1
- package/lib/compiler/internal/resolveTsgo.js.map +1 -1
- package/lib/compiler/internal/runBuild.d.ts +24 -4
- package/lib/compiler/internal/runBuild.js +355 -93
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/runSingleFileEmit.d.ts +10 -1
- package/lib/compiler/internal/runSingleFileEmit.js +14 -1
- package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
- package/lib/compiler/internal/sharedHostHelpers.d.ts +5 -0
- package/lib/compiler/internal/sharedHostHelpers.js +6 -2
- package/lib/compiler/internal/sharedHostHelpers.js.map +1 -1
- package/lib/compiler/internal/spawnNative.d.ts +21 -0
- package/lib/compiler/internal/spawnNative.js +59 -0
- package/lib/compiler/internal/spawnNative.js.map +1 -0
- package/lib/compiler/internal/transformProjectInMemory.d.ts +15 -1
- package/lib/compiler/internal/transformProjectInMemory.js +57 -61
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/flags/parser.d.ts +63 -0
- package/lib/flags/parser.js +254 -0
- package/lib/flags/parser.js.map +1 -0
- package/lib/flags/schema.d.ts +147 -0
- package/lib/flags/schema.js +405 -0
- package/lib/flags/schema.js.map +1 -0
- package/lib/launcher/internal/getCompilerVersionText.js +7 -0
- package/lib/launcher/internal/getCompilerVersionText.js.map +1 -1
- package/lib/launcher/internal/prepareExecution.js +35 -0
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/resolveCacheDir.d.ts +9 -0
- package/lib/launcher/internal/resolveCacheDir.js +22 -0
- package/lib/launcher/internal/resolveCacheDir.js.map +1 -0
- package/lib/launcher/internal/resolveTtscserverBinary.js +2 -0
- package/lib/launcher/internal/resolveTtscserverBinary.js.map +1 -1
- package/lib/launcher/internal/runTtsc.d.ts +10 -0
- package/lib/launcher/internal/runTtsc.js +90 -153
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtscserver.js +10 -35
- package/lib/launcher/internal/runTtscserver.js.map +1 -1
- package/lib/launcher/internal/runTtsx.d.ts +8 -0
- package/lib/launcher/internal/runTtsx.js +137 -79
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/plugin/internal/buildSourcePlugin.d.ts +38 -0
- package/lib/plugin/internal/buildSourcePlugin.js +40 -17
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.d.ts +26 -0
- package/lib/plugin/internal/loadProjectPlugins.js +90 -41
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/structures/ITtscCompilerTransformation.d.ts +15 -2
- package/lib/structures/ITtscPlugin.d.ts +24 -0
- package/lib/structures/ITtscPluginCapabilities.d.ts +29 -0
- package/lib/structures/ITtscPluginCapabilities.js +3 -0
- package/lib/structures/ITtscPluginCapabilities.js.map +1 -0
- package/lib/structures/index.d.ts +1 -0
- package/lib/structures/index.js +1 -0
- package/lib/structures/index.js.map +1 -1
- package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +5 -0
- package/lib/structures/internal/TtscCommonOptions.d.ts +19 -0
- package/lib/structures/internal/TtscSingleFileEmitOptions.d.ts +0 -2
- package/package.json +9 -9
- package/shim/ast/shim.go +24 -0
- package/shim/checker/shim.go +35 -0
- package/shim/core/shim.go +17 -0
- package/shim/diagnosticwriter/shim.go +4 -0
- package/shim/lsp/shim.go +3 -3
- package/shim/printer/shim.go +20 -0
- package/src/TtscCompiler.ts +7 -0
- package/src/compiler/internal/buildNativeCompiler.ts +23 -3
- package/src/compiler/internal/compileProjectInMemory.ts +34 -25
- package/src/compiler/internal/paths.ts +68 -0
- package/src/compiler/internal/project/readProjectConfig.ts +86 -1
- package/src/compiler/internal/project/resolveProjectConfig.ts +44 -1
- package/src/compiler/internal/resolveBinary.ts +17 -1
- package/src/compiler/internal/resolveEmittedJavaScript.ts +43 -12
- package/src/compiler/internal/resolveTsgo.ts +29 -1
- package/src/compiler/internal/runBuild.ts +398 -112
- package/src/compiler/internal/runSingleFileEmit.ts +14 -1
- package/src/compiler/internal/sharedHostHelpers.ts +7 -7
- package/src/compiler/internal/spawnNative.ts +64 -0
- package/src/compiler/internal/transformProjectInMemory.ts +47 -67
- package/src/flags/parser.ts +367 -0
- package/src/flags/schema.ts +570 -0
- package/src/launcher/internal/getCompilerVersionText.ts +7 -0
- package/src/launcher/internal/prepareExecution.ts +35 -0
- package/src/launcher/internal/resolveCacheDir.ts +19 -0
- package/src/launcher/internal/resolveTtscserverBinary.ts +2 -0
- package/src/launcher/internal/runTtsc.ts +97 -143
- package/src/launcher/internal/runTtscserver.ts +9 -1
- package/src/launcher/internal/runTtsx.ts +149 -82
- package/src/plugin/internal/buildSourcePlugin.ts +40 -14
- package/src/plugin/internal/loadProjectPlugins.ts +116 -45
- package/src/structures/ITtscCompilerTransformation.ts +15 -2
- package/src/structures/ITtscPlugin.ts +26 -1
- package/src/structures/ITtscPluginCapabilities.ts +29 -0
- package/src/structures/index.ts +1 -0
- package/src/structures/internal/ITtscLoadedNativePlugin.ts +5 -0
- package/src/structures/internal/TtscCommonOptions.ts +19 -0
- package/src/structures/internal/TtscSingleFileEmitOptions.ts +0 -2
- package/tools/gen_shims/main.go +43 -8
- package/utility/flags_gen.go +30 -0
- package/utility/host.go +304 -245
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the consumer project's TypeScript-Go preview binary and metadata.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order:
|
|
5
|
+
*
|
|
6
|
+
* 1. `opts.binary` or `TTSC_TSGO_BINARY` env var — must be an existing absolute
|
|
7
|
+
* path; returns `{ binary, packageJson: "", packageRoot, version: "custom"
|
|
8
|
+
* }`.
|
|
9
|
+
* 2. `@typescript/native-preview` resolved from the project `cwd`.
|
|
10
|
+
* 3. `@typescript/native-preview` resolved from `opts.resolveFrom` (for test
|
|
11
|
+
* harnesses and embedders that anchor to a different directory).
|
|
12
|
+
*
|
|
13
|
+
* Throws a descriptive error when the package or platform binary is missing so
|
|
14
|
+
* callers never have to reason about undefined binary paths.
|
|
15
|
+
*/
|
|
2
16
|
export declare function resolveTsgo(opts?: {
|
|
17
|
+
/** Explicit path to a tsgo binary; bypasses package resolution. */
|
|
3
18
|
binary?: string;
|
|
19
|
+
/** Directory from which to discover `@typescript/native-preview`. */
|
|
4
20
|
cwd?: string;
|
|
5
21
|
env?: NodeJS.ProcessEnv;
|
|
22
|
+
/**
|
|
23
|
+
* Fallback resolution anchor used when the package is not found at `cwd`.
|
|
24
|
+
* Useful in test harnesses that install the package into a different tree.
|
|
25
|
+
*/
|
|
6
26
|
resolveFrom?: string;
|
|
7
27
|
}): {
|
|
8
28
|
binary: string;
|
|
@@ -7,7 +7,21 @@ exports.resolveTsgo = resolveTsgo;
|
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_module_1 = require("node:module");
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Resolve the consumer project's TypeScript-Go preview binary and metadata.
|
|
12
|
+
*
|
|
13
|
+
* Resolution order:
|
|
14
|
+
*
|
|
15
|
+
* 1. `opts.binary` or `TTSC_TSGO_BINARY` env var — must be an existing absolute
|
|
16
|
+
* path; returns `{ binary, packageJson: "", packageRoot, version: "custom"
|
|
17
|
+
* }`.
|
|
18
|
+
* 2. `@typescript/native-preview` resolved from the project `cwd`.
|
|
19
|
+
* 3. `@typescript/native-preview` resolved from `opts.resolveFrom` (for test
|
|
20
|
+
* harnesses and embedders that anchor to a different directory).
|
|
21
|
+
*
|
|
22
|
+
* Throws a descriptive error when the package or platform binary is missing so
|
|
23
|
+
* callers never have to reason about undefined binary paths.
|
|
24
|
+
*/
|
|
11
25
|
function resolveTsgo(opts = {}) {
|
|
12
26
|
const env = opts.env ?? process.env;
|
|
13
27
|
const explicit = opts.binary ?? env.TTSC_TSGO_BINARY;
|
|
@@ -23,6 +37,8 @@ function resolveTsgo(opts = {}) {
|
|
|
23
37
|
};
|
|
24
38
|
}
|
|
25
39
|
const cwd = node_path_1.default.resolve(opts.cwd ?? process.cwd());
|
|
40
|
+
// Resolve the package.json of @typescript/native-preview.
|
|
41
|
+
// Try cwd first, then the optional resolveFrom anchor.
|
|
26
42
|
let packageJson;
|
|
27
43
|
packageJson =
|
|
28
44
|
resolveNativePreviewPackageJson(node_path_1.default.join(cwd, "package.json")) ??
|
|
@@ -65,6 +81,11 @@ function resolveTsgo(opts = {}) {
|
|
|
65
81
|
version: typeof manifest.version === "string" ? manifest.version : "unknown",
|
|
66
82
|
};
|
|
67
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Attempt to resolve the `package.json` of `@typescript/native-preview`
|
|
86
|
+
* starting from `from` (a package.json path or directory). Returns `undefined`
|
|
87
|
+
* when the package is not resolvable from that location.
|
|
88
|
+
*/
|
|
68
89
|
function resolveNativePreviewPackageJson(from) {
|
|
69
90
|
try {
|
|
70
91
|
return (0, node_module_1.createRequire)(from).resolve("@typescript/native-preview/package.json");
|
|
@@ -73,6 +94,7 @@ function resolveNativePreviewPackageJson(from) {
|
|
|
73
94
|
return undefined;
|
|
74
95
|
}
|
|
75
96
|
}
|
|
97
|
+
/** Parse a JSON file and return the result as a plain object. */
|
|
76
98
|
function readPackageJson(file) {
|
|
77
99
|
return JSON.parse(node_fs_1.default.readFileSync(file, "utf8"));
|
|
78
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveTsgo.js","sourceRoot":"","sources":["../../../src/compiler/internal/resolveTsgo.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,6CAA4C;AAC5C,0DAA6B;AAE7B
|
|
1
|
+
{"version":3,"file":"resolveTsgo.js","sourceRoot":"","sources":["../../../src/compiler/internal/resolveTsgo.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,6CAA4C;AAC5C,0DAA6B;AAE7B;;;;;;;;;;;;;;GAcG;AACH,qBACE,IAAI,GAWA,EAAE;IAEN,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,gBAAgB,CAAC;IACrD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,mBAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC3D,MAAM,IAAI,KAAK,CACb,iEAAiE,QAAQ,EAAE,CAC5E,CAAC;QACJ,CAAC;QACD,OAAO;YACL,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,EAAE;YACf,WAAW,EAAE,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;YACnC,OAAO,EAAE,QAAQ;SAClB,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,IAAI,CA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AAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CACnD,CAAC;IACF,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,6CAA6C,MAAM,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO;QACL,MAAM;QACN,OAAO,EACL,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QACrE,WAAW;QACX,WAAW;QACX,mBAAmB;QACnB,OAAO,EACL,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;KACtE,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,+BAA+B,CAAC,IAAY;IACnD,IAAI,CAAC;QACH,OAAO,IAAA,2BAAa,EAAC,IAAI,CAAC,CAAC,OAAO,CAChC,yCAAyC,CAC1C,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,iEAAiE;AACjE,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAA4B,CAAC;AAC9E,CAAC"}
|
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
import type { ITtscCompilerDiagnostic } from "../../structures/ITtscCompilerDiagnostic";
|
|
2
2
|
import type { TtscBuildOptions } from "../../structures/internal/TtscBuildOptions";
|
|
3
3
|
import type { TtscBuildResult } from "../../structures/internal/TtscBuildResult";
|
|
4
|
+
type RunBuildOptions = TtscBuildOptions & {
|
|
5
|
+
skipDiagnosticsCheck?: boolean;
|
|
6
|
+
forceListEmittedFiles?: boolean;
|
|
7
|
+
};
|
|
4
8
|
/**
|
|
5
9
|
* Run `ttsc` against a tsconfig. Returns once the binary exits so the CLI can
|
|
6
10
|
* decide how to surface diagnostics. Does not throw on non-zero exit.
|
|
7
11
|
*/
|
|
8
|
-
export declare function runBuild(options?:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
export declare function runBuild(options?: RunBuildOptions): TtscBuildResult;
|
|
13
|
+
/**
|
|
14
|
+
* Merge two `TtscBuildResult` values into one.
|
|
15
|
+
*
|
|
16
|
+
* - `status`: the right status wins unless it is 0 (failure propagates).
|
|
17
|
+
* - `diagnostics`: concatenated left then right.
|
|
18
|
+
* - `emittedFiles`: right wins when present, otherwise left is kept.
|
|
19
|
+
* - `stdout`/`stderr`: concatenated left then right.
|
|
20
|
+
*/
|
|
12
21
|
export declare function appendBuildOutput(left: TtscBuildResult, right: TtscBuildResult): TtscBuildResult;
|
|
22
|
+
/**
|
|
23
|
+
* `TtscBuildResult` with `diagnostics` made optional. Used internally when
|
|
24
|
+
* diagnostics are parsed lazily from stdout/stderr by `normalizeBuildOutput`.
|
|
25
|
+
*/
|
|
13
26
|
type PartialBuildResult = Omit<TtscBuildResult, "diagnostics"> & {
|
|
14
27
|
diagnostics?: ITtscCompilerDiagnostic[];
|
|
15
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Normalise a raw spawn result into a `TtscBuildResult`.
|
|
31
|
+
*
|
|
32
|
+
* When `diagnostics` is absent they are parsed from the text output. When the
|
|
33
|
+
* process exited non-zero but stderr is empty and stdout is non-empty, stdout
|
|
34
|
+
* is moved to stderr so the error is visible to callers who only check stderr.
|
|
35
|
+
*/
|
|
16
36
|
export declare function normalizeBuildOutput(result: PartialBuildResult, cwd?: string): TtscBuildResult;
|
|
17
37
|
export {};
|