ttsc 0.10.2 → 0.11.0-dev.20260517
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/README.md +8 -0
- package/cmd/ttsc/api_compile.go +106 -106
- package/cmd/ttsc/api_transform.go +54 -54
- package/cmd/ttsc/main.go +103 -103
- package/cmd/ttscserver/helpers_test.go +27 -0
- package/cmd/ttscserver/main.go +154 -0
- package/cmd/ttscserver/run_lsp_reports_getwd_error_test.go +34 -0
- package/cmd/ttscserver/run_lsp_reports_server_error_test.go +42 -0
- package/driver/lsp_envelope.go +136 -0
- package/driver/lsp_frame.go +121 -0
- package/driver/lsp_plugin.go +150 -0
- package/driver/lsp_proxy.go +394 -0
- package/driver/lsp_server.go +197 -0
- package/go.mod +4 -0
- package/go.sum +4 -0
- package/internal/cwd/cwd.go +8 -8
- package/lib/TtscCompiler.d.ts +15 -16
- package/lib/TtscCompiler.js +15 -16
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/compiler/internal/compileProjectInMemory.d.ts +4 -1
- package/lib/compiler/internal/compileProjectInMemory.js +4 -1
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/runBuild.js +43 -1
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/sharedHostHelpers.d.ts +12 -12
- package/lib/compiler/internal/sharedHostHelpers.js +12 -12
- package/lib/defineTtscPlugin.d.ts +18 -0
- package/lib/defineTtscPlugin.js +7 -0
- package/lib/defineTtscPlugin.js.map +1 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/launcher/internal/prepareExecution.js +1 -1
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/resolveTtscserverBinary.d.ts +12 -0
- package/lib/launcher/internal/resolveTtscserverBinary.js +43 -0
- package/lib/launcher/internal/resolveTtscserverBinary.js.map +1 -0
- package/lib/launcher/internal/runTtsc.js +47 -8
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtscserver.d.ts +20 -0
- package/lib/launcher/internal/runTtscserver.js +125 -0
- package/lib/launcher/internal/runTtscserver.js.map +1 -0
- package/lib/launcher/internal/runTtsx.js +1 -1
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/launcher/ttscserver.d.ts +2 -0
- package/lib/launcher/ttscserver.js +9 -0
- package/lib/launcher/ttscserver.js.map +1 -0
- package/lib/plugin/internal/buildSourcePlugin.d.ts +9 -0
- package/lib/plugin/internal/buildSourcePlugin.js +197 -2
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.js +86 -8
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/structures/ITtscCompilerContext.d.ts +1 -1
- package/lib/structures/ITtscCompilerDiagnostic.d.ts +3 -3
- package/lib/structures/ITtscCompilerResult.d.ts +10 -22
- package/lib/structures/ITtscCompilerTransformation.d.ts +2 -2
- package/lib/structures/ITtscPlugin.d.ts +37 -4
- package/lib/structures/ITtscPlugin.js +0 -4
- package/lib/structures/ITtscPlugin.js.map +1 -1
- package/lib/structures/ITtscPluginContributor.d.ts +26 -0
- package/lib/structures/ITtscPluginContributor.js +3 -0
- package/lib/structures/ITtscPluginContributor.js.map +1 -0
- package/lib/structures/ITtscPluginFactoryContext.d.ts +5 -5
- package/lib/structures/ITtscProjectPluginConfig.d.ts +2 -2
- package/lib/structures/TtscPluginStage.d.ts +4 -3
- 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 +3 -0
- package/lib/structures/internal/TtscBuildOptions.d.ts +13 -0
- package/lib/structures/internal/TtscCommonOptions.d.ts +5 -2
- package/package.json +10 -9
- package/shim/lsp/extra-shim.json +4 -0
- package/shim/lsp/go.mod +16 -0
- package/shim/lsp/go.sum +26 -0
- package/shim/lsp/shim.go +42 -0
- package/shim/printer/shim.go +5 -5
- package/src/TtscCompiler.ts +15 -16
- package/src/compiler/internal/compileProjectInMemory.ts +4 -1
- package/src/compiler/internal/project/readProjectConfig.ts +0 -1
- package/src/compiler/internal/runBuild.ts +43 -1
- package/src/compiler/internal/sharedHostHelpers.ts +12 -12
- package/src/defineTtscPlugin.ts +26 -0
- package/src/index.ts +4 -3
- package/src/launcher/internal/prepareExecution.ts +1 -1
- package/src/launcher/internal/resolveTtscserverBinary.ts +51 -0
- package/src/launcher/internal/runTtsc.ts +53 -11
- package/src/launcher/internal/runTtscserver.ts +92 -0
- package/src/launcher/internal/runTtsx.ts +1 -1
- package/src/launcher/ttscserver.ts +8 -0
- package/src/plugin/internal/buildSourcePlugin.ts +231 -12
- package/src/plugin/internal/loadProjectPlugins.ts +108 -8
- package/src/structures/ITtscCompilerContext.ts +1 -1
- package/src/structures/ITtscCompilerDiagnostic.ts +3 -3
- package/src/structures/ITtscCompilerResult.ts +10 -22
- package/src/structures/ITtscCompilerTransformation.ts +2 -2
- package/src/structures/ITtscPlugin.ts +37 -11
- package/src/structures/ITtscPluginContributor.ts +27 -0
- package/src/structures/ITtscPluginFactoryContext.ts +5 -5
- package/src/structures/ITtscProjectPluginConfig.ts +2 -2
- package/src/structures/TtscPluginStage.ts +4 -3
- package/src/structures/index.ts +1 -0
- package/src/structures/internal/ITtscLoadedNativePlugin.ts +3 -0
- package/src/structures/internal/TtscBuildOptions.ts +13 -0
- package/src/structures/internal/TtscCommonOptions.ts +5 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One contributor entry inside `ITtscPlugin.contributors`.
|
|
3
|
+
*
|
|
4
|
+
* The native builder copies `source` into `<scratch>/contrib/<name>/` and adds
|
|
5
|
+
* a blank-import for `<host-module>/contrib/<name>` to the synthesized
|
|
6
|
+
* `ttsc_contributions.go` placed alongside the host's main package.
|
|
7
|
+
*/
|
|
8
|
+
export interface ITtscPluginContributor {
|
|
9
|
+
/**
|
|
10
|
+
* Sub-package name.
|
|
11
|
+
*
|
|
12
|
+
* Forms the final import path together with the host plugin's Go module path;
|
|
13
|
+
* must match `/^[a-z][a-z0-9_]*$/` — a lowercase ASCII letter followed by
|
|
14
|
+
* lowercase letters, digits, or underscores — and be unique within one plugin
|
|
15
|
+
* build.
|
|
16
|
+
*/
|
|
17
|
+
name: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Absolute path to the contributor's Go source directory.
|
|
21
|
+
*
|
|
22
|
+
* Every `.go` file under this directory is copied into the scratch build tree
|
|
23
|
+
* as a sub-package of the host plugin's module. Subdirectories are copied
|
|
24
|
+
* recursively; `go.mod` files, `node_modules`, and `.git` are pruned.
|
|
25
|
+
*/
|
|
26
|
+
source: string;
|
|
27
|
+
}
|
|
@@ -10,8 +10,8 @@ import type { ITtscProjectPluginConfig } from "./ITtscProjectPluginConfig";
|
|
|
10
10
|
* project root.
|
|
11
11
|
*
|
|
12
12
|
* The factory runs in Node.js while ttsc is loading `compilerOptions.plugins`.
|
|
13
|
-
* It should only create the descriptor. Heavy validation and TypeScript-Go
|
|
14
|
-
*
|
|
13
|
+
* It should only create the descriptor. Heavy validation and TypeScript-Go work
|
|
14
|
+
* belong in the Go sidecar selected by {@link ITtscPlugin.source}.
|
|
15
15
|
*/
|
|
16
16
|
export interface ITtscPluginFactoryContext<T = ITtscProjectPluginConfig> {
|
|
17
17
|
/**
|
|
@@ -19,8 +19,8 @@ export interface ITtscPluginFactoryContext<T = ITtscProjectPluginConfig> {
|
|
|
19
19
|
*
|
|
20
20
|
* This is the package's own native helper, not the plugin sidecar and not the
|
|
21
21
|
* JavaScript launcher. Most plugins do not need it; it is provided for
|
|
22
|
-
* advanced factories that need to derive behavior from the active ttsc
|
|
23
|
-
*
|
|
22
|
+
* advanced factories that need to derive behavior from the active ttsc native
|
|
23
|
+
* host.
|
|
24
24
|
*/
|
|
25
25
|
binary: string;
|
|
26
26
|
|
|
@@ -36,7 +36,7 @@ export interface ITtscPluginFactoryContext<T = ITtscProjectPluginConfig> {
|
|
|
36
36
|
/**
|
|
37
37
|
* Original `compilerOptions.plugins[]` entry that loaded this plugin.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
39
|
+
* Ttsc reserves `transform` and `enabled`. Every other property is
|
|
40
40
|
* plugin-owned config and is later serialized unchanged into the native
|
|
41
41
|
* sidecar manifest.
|
|
42
42
|
*/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* or plugin packages expose through `package.json`. ttsc deliberately keeps it
|
|
7
7
|
* open-ended because plugin packages own their own config fields.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Ttsc interprets only two properties:
|
|
10
10
|
*
|
|
11
11
|
* - `transform`: the JavaScript module specifier used to load the plugin
|
|
12
12
|
* descriptor or factory.
|
|
@@ -42,7 +42,7 @@ export interface ITtscProjectPluginConfig {
|
|
|
42
42
|
/**
|
|
43
43
|
* Plugin-specific config passed through unchanged to the native sidecar.
|
|
44
44
|
*
|
|
45
|
-
*
|
|
45
|
+
* Ttsc does not validate these fields. Plugin packages should document their
|
|
46
46
|
* own config contract and validate it inside their factory or Go sidecar.
|
|
47
47
|
*/
|
|
48
48
|
[key: string]: unknown;
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* - `"transform"`: participates in the TypeScript-Go transform path. Transform
|
|
5
5
|
* plugins do not receive emitted JavaScript or emitted file text.
|
|
6
|
-
* - `"check"`: runs before emit and reports diagnostics
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* - `"check"`: runs before emit and reports diagnostics. Use this for lint or
|
|
7
|
+
* validation plugins that should fail the compile before JavaScript or
|
|
8
|
+
* declaration output is generated. Check plugins may also implement a `fix`
|
|
9
|
+
* command, which `ttsc fix` invokes with emit disabled.
|
|
9
10
|
*/
|
|
10
11
|
export type TtscPluginStage = "transform" | "check";
|
package/src/structures/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./ITtscCompilerDiagnostic";
|
|
|
3
3
|
export * from "./ITtscCompilerResult";
|
|
4
4
|
export * from "./ITtscCompilerTransformation";
|
|
5
5
|
export * from "./ITtscPlugin";
|
|
6
|
+
export * from "./ITtscPluginContributor";
|
|
6
7
|
export * from "./ITtscPluginFactoryContext";
|
|
7
8
|
export * from "./ITtscProjectPluginConfig";
|
|
8
9
|
export * from "./TtscPluginStage";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ITtscPluginContributor } from "../ITtscPluginContributor";
|
|
1
2
|
import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
|
|
2
3
|
import type { TtscPluginStage } from "../TtscPluginStage";
|
|
3
4
|
|
|
@@ -7,6 +8,8 @@ export interface ITtscLoadedNativePlugin {
|
|
|
7
8
|
binary: string;
|
|
8
9
|
/** Original tsconfig plugin entry passed unchanged to the sidecar. */
|
|
9
10
|
config: ITtscProjectPluginConfig;
|
|
11
|
+
/** Contributor Go sources statically linked into the binary, if any. */
|
|
12
|
+
contributors?: readonly ITtscPluginContributor[];
|
|
10
13
|
/** Stable plugin name used in diagnostics and native manifests. */
|
|
11
14
|
name: string;
|
|
12
15
|
/** Go source directory selected by the plugin descriptor. */
|
|
@@ -12,6 +12,19 @@ export interface TtscBuildOptions extends TtscCommonOptions {
|
|
|
12
12
|
* - `undefined`: follow the resolved tsconfig exactly.
|
|
13
13
|
*/
|
|
14
14
|
emit?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Invoke fix-capable check-stage plugins before the final no-emit check.
|
|
17
|
+
* Source files may be rewritten; JavaScript/declaration emit stays disabled.
|
|
18
|
+
*/
|
|
19
|
+
fix?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Invoke format-capable check-stage plugins. Source files may be rewritten
|
|
22
|
+
* with formatter-class edits (whitespace, punctuation, ordering); diagnostics
|
|
23
|
+
* are not reported and JavaScript/declaration emit stays disabled. The
|
|
24
|
+
* launcher selects this through the `ttsc format` subcommand and rejects
|
|
25
|
+
* combination with watch mode, single-file mode, or an explicit `--emit`.
|
|
26
|
+
*/
|
|
27
|
+
format?: boolean;
|
|
15
28
|
/** Per-call TypeScript-Go `outDir` override. */
|
|
16
29
|
outDir?: string;
|
|
17
30
|
/** Suppress summary banners from ttsc/native sidecars. Defaults to `true`. */
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ITtscProjectPluginConfig } from "../ITtscProjectPluginConfig";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Internal options shared by the CLI build, single-file emit, and runtime
|
|
5
|
+
* paths.
|
|
6
|
+
*/
|
|
4
7
|
export interface TtscCommonOptions {
|
|
5
8
|
/**
|
|
6
9
|
* Explicit TypeScript-Go executable.
|
|
@@ -23,7 +26,7 @@ export interface TtscCommonOptions {
|
|
|
23
26
|
* Override project plugin loading for this invocation.
|
|
24
27
|
*
|
|
25
28
|
* - `false`: ignore `compilerOptions.plugins` completely.
|
|
26
|
-
* -
|
|
29
|
+
* - Array: use these plugin entries instead of the project config entries.
|
|
27
30
|
* - `undefined`: use the project config entries as written.
|
|
28
31
|
*/
|
|
29
32
|
plugins?: readonly ITtscProjectPluginConfig[] | false;
|