ttsc 0.20.1 → 0.22.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/ttscserver/main.go +79 -3
- package/cmd/ttscserver/run_lsp_uses_native_plugin_manifest_source_test.go +96 -16
- package/driver/lsp.go +4 -0
- package/internal/lspserver/lsp_document_diagnostics_omits_cached_project_when_current_result_has_none_test.go +48 -0
- package/internal/lspserver/lsp_executable_project_input_change_requests_launcher_restart_test.go +98 -0
- package/internal/lspserver/lsp_external_watched_change_retains_program_test.go +53 -0
- package/internal/lspserver/lsp_hints_refresh_scheduled_by_editor_events_test.go +9 -0
- package/internal/lspserver/lsp_native_plugin_source.go +171 -55
- package/internal/lspserver/lsp_native_resident.go +110 -9
- package/internal/lspserver/lsp_plugin.go +6 -0
- package/internal/lspserver/lsp_project_context_transport_identity_test.go +43 -0
- package/internal/lspserver/lsp_project_diagnostics.go +235 -0
- package/internal/lspserver/lsp_project_diagnostics_capability_is_independent_test.go +67 -0
- package/internal/lspserver/lsp_project_diagnostics_program_input_overlap_refreshes_all_producers_test.go +78 -0
- package/internal/lspserver/lsp_project_diagnostics_refresh_accumulates_owner_freshness_test.go +65 -0
- package/internal/lspserver/lsp_project_diagnostics_refresh_keeps_each_producer_last_good_test.go +90 -0
- package/internal/lspserver/lsp_project_diagnostics_refreshes_only_input_owners_test.go +62 -0
- package/internal/lspserver/lsp_project_diagnostics_resident_unsupported_falls_back_test.go +123 -0
- package/internal/lspserver/lsp_project_diagnostics_resume_preserves_generation_test.go +52 -0
- package/internal/lspserver/lsp_project_diagnostics_translates_relative_client_project_test.go +90 -0
- package/internal/lspserver/lsp_project_input_ownership_resolves_declared_spellings_test.go +95 -0
- package/internal/lspserver/lsp_project_input_registration.go +504 -0
- package/internal/lspserver/lsp_project_input_registration_rechecks_selection_baseline_test.go +71 -0
- package/internal/lspserver/lsp_project_input_registration_reconciles_rejected_pending_request_test.go +268 -0
- package/internal/lspserver/lsp_project_input_registration_shapes_patterns_test.go +94 -0
- package/internal/lspserver/lsp_project_input_watchers_anchor_missing_paths_test.go +48 -0
- package/internal/lspserver/lsp_project_inputs.go +944 -0
- package/internal/lspserver/lsp_project_inputs_match_missing_exact_and_glob_test.go +129 -0
- package/internal/lspserver/lsp_project_inputs_reject_invalid_and_foreign_snapshots_test.go +110 -0
- package/internal/lspserver/lsp_proxy.go +591 -28
- package/internal/lspserver/lsp_reload_directories_compare_immediate_topology_test.go +188 -0
- package/internal/lspserver/lsp_reload_file_fingerprint_preserves_raw_symlink_target_test.go +47 -0
- package/internal/lspserver/lsp_resident_falls_back_when_serve_unsupported_test.go +1 -1
- package/internal/lspserver/lsp_resident_invalidation_broadcasts_program_input_overlap_test.go +60 -0
- package/internal/lspserver/lsp_resident_invalidation_targets_project_input_owners_test.go +51 -0
- package/internal/lspserver/lsp_same_transport_entries_are_deduplicated_test.go +66 -0
- package/lib/compiler/internal/project/readProjectConfig.d.ts +5 -3
- package/lib/compiler/internal/project/readProjectConfig.js +46 -14
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/residentCheckProcess.d.ts +46 -0
- package/lib/compiler/internal/residentCheckProcess.js +227 -0
- package/lib/compiler/internal/residentCheckProcess.js.map +1 -0
- package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +2 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.js +35 -18
- package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -1
- package/lib/compiler/internal/runBuild.d.ts +64 -1
- package/lib/compiler/internal/runBuild.js +484 -7
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/runSingleFileEmit.js +1 -0
- package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
- package/lib/flags/parser.js +13 -17
- package/lib/flags/parser.js.map +1 -1
- package/lib/flags/schema.d.ts +10 -3
- package/lib/flags/schema.js +99 -0
- package/lib/flags/schema.js.map +1 -1
- package/lib/internal/projectInputPathIdentity.d.ts +23 -0
- package/lib/internal/projectInputPathIdentity.js +222 -0
- package/lib/internal/projectInputPathIdentity.js.map +1 -0
- package/lib/launcher/internal/runTtsc.d.ts +17 -0
- package/lib/launcher/internal/runTtsc.js +121 -88
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtscserver.d.ts +13 -1
- package/lib/launcher/internal/runTtscserver.js +415 -45
- package/lib/launcher/internal/runTtscserver.js.map +1 -1
- package/lib/launcher/internal/singleFileOutput.d.ts +16 -0
- package/lib/launcher/internal/singleFileOutput.js +103 -0
- package/lib/launcher/internal/singleFileOutput.js.map +1 -0
- package/lib/launcher/internal/watchTopology.d.ts +214 -2
- package/lib/launcher/internal/watchTopology.js +1560 -41
- package/lib/launcher/internal/watchTopology.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.d.ts +1 -0
- package/lib/plugin/internal/loadProjectPlugins.js +5 -0
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/structures/ITtscPluginCapabilities.d.ts +31 -0
- package/lib/structures/internal/ITtscProjectInputSnapshot.d.ts +29 -0
- package/lib/structures/internal/ITtscProjectInputSnapshot.js +3 -0
- package/lib/structures/internal/ITtscProjectInputSnapshot.js.map +1 -0
- package/lib/structures/internal/TtscSingleFileEmitOptions.d.ts +5 -0
- package/package.json +8 -8
- package/src/compiler/internal/project/readProjectConfig.ts +62 -8
- package/src/compiler/internal/residentCheckProcess.ts +279 -0
- package/src/compiler/internal/resolveEmittedJavaScript.ts +43 -21
- package/src/compiler/internal/runBuild.ts +728 -12
- package/src/compiler/internal/runSingleFileEmit.ts +1 -0
- package/src/flags/parser.ts +17 -17
- package/src/flags/schema.ts +111 -3
- package/src/internal/projectInputPathIdentity.ts +273 -0
- package/src/launcher/internal/runTtsc.ts +141 -117
- package/src/launcher/internal/runTtscserver.ts +561 -54
- package/src/launcher/internal/singleFileOutput.ts +133 -0
- package/src/launcher/internal/watchTopology.ts +2008 -59
- package/src/plugin/internal/loadProjectPlugins.ts +8 -0
- package/src/structures/ITtscPluginCapabilities.ts +34 -0
- package/src/structures/internal/ITtscProjectInputSnapshot.ts +29 -0
- package/src/structures/internal/TtscSingleFileEmitOptions.ts +5 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { readProjectConfig } from "../../compiler/internal/project/readProjectConfig";
|
|
4
|
+
import { resolveFlagSpec } from "../../flags/schema";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the only file that positional `ttsc <source>` can materialize in the
|
|
8
|
+
* user's tree.
|
|
9
|
+
*
|
|
10
|
+
* The compiler itself emits into a private temporary directory. The launcher
|
|
11
|
+
* then copies one transformed JavaScript file to this path, so project-mode
|
|
12
|
+
* declaration, map, build-info, outFile, and broad outDir products are not
|
|
13
|
+
* positional outputs.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveSingleFileOutput(options: {
|
|
16
|
+
cliOutDir?: string;
|
|
17
|
+
cwd: string;
|
|
18
|
+
file: string;
|
|
19
|
+
passthrough?: readonly string[];
|
|
20
|
+
tsconfig?: string;
|
|
21
|
+
}): string {
|
|
22
|
+
const project = readProjectSettings(options);
|
|
23
|
+
const extension = singleFileJavaScriptExtension(
|
|
24
|
+
options.file,
|
|
25
|
+
passthroughStringOption(options.passthrough, "--jsx") ?? project?.jsx,
|
|
26
|
+
);
|
|
27
|
+
const jsBasename =
|
|
28
|
+
path.basename(options.file).replace(/\.(?:[cm]?tsx?|jsx)$/i, "") +
|
|
29
|
+
extension;
|
|
30
|
+
|
|
31
|
+
if (options.cliOutDir) {
|
|
32
|
+
const relative = path.relative(options.cwd, options.file);
|
|
33
|
+
const jsRelative =
|
|
34
|
+
relative.slice(0, relative.length - path.extname(relative).length) +
|
|
35
|
+
extension;
|
|
36
|
+
return path.resolve(options.cwd, options.cliOutDir, jsRelative);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (project?.outDir !== undefined) {
|
|
40
|
+
const fromRoot = path.relative(project.rootDir, options.file);
|
|
41
|
+
if (fromRoot !== "" && !isOutsideSingleFileLayout(fromRoot)) {
|
|
42
|
+
const jsRelative =
|
|
43
|
+
fromRoot.slice(0, fromRoot.length - path.extname(fromRoot).length) +
|
|
44
|
+
extension;
|
|
45
|
+
return path.resolve(project.outDir, jsRelative);
|
|
46
|
+
}
|
|
47
|
+
return path.resolve(project.outDir, jsBasename);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return options.file.replace(/\.(?:[cm]?tsx?|jsx)$/i, extension);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readProjectSettings(options: {
|
|
54
|
+
cwd: string;
|
|
55
|
+
file: string;
|
|
56
|
+
tsconfig?: string;
|
|
57
|
+
}): { jsx?: string; outDir?: string; rootDir: string } | null {
|
|
58
|
+
try {
|
|
59
|
+
const project = readProjectConfig({
|
|
60
|
+
cwd: options.cwd,
|
|
61
|
+
file: options.file,
|
|
62
|
+
tsconfig: options.tsconfig,
|
|
63
|
+
});
|
|
64
|
+
const outDir = project.compilerOptions.outDir;
|
|
65
|
+
const rawRoot = project.compilerOptions.rootDir;
|
|
66
|
+
const rootDir =
|
|
67
|
+
typeof rawRoot === "string" && rawRoot.length !== 0
|
|
68
|
+
? path.isAbsolute(rawRoot)
|
|
69
|
+
? rawRoot
|
|
70
|
+
: path.resolve(project.root, rawRoot)
|
|
71
|
+
: project.root;
|
|
72
|
+
const rawJsx = project.compilerOptions.jsx;
|
|
73
|
+
return {
|
|
74
|
+
jsx:
|
|
75
|
+
typeof rawJsx === "string" && rawJsx.length !== 0
|
|
76
|
+
? rawJsx.toLowerCase()
|
|
77
|
+
: undefined,
|
|
78
|
+
outDir:
|
|
79
|
+
typeof outDir === "string" && outDir.length !== 0 ? outDir : undefined,
|
|
80
|
+
rootDir,
|
|
81
|
+
};
|
|
82
|
+
} catch {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function isOutsideSingleFileLayout(relative: string): boolean {
|
|
88
|
+
return (
|
|
89
|
+
relative === ".." ||
|
|
90
|
+
relative.startsWith(`..${path.sep}`) ||
|
|
91
|
+
path.isAbsolute(relative)
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function singleFileJavaScriptExtension(
|
|
96
|
+
file: string,
|
|
97
|
+
jsx: string | undefined,
|
|
98
|
+
): string {
|
|
99
|
+
switch (path.extname(file).toLowerCase()) {
|
|
100
|
+
case ".mts":
|
|
101
|
+
return ".mjs";
|
|
102
|
+
case ".cts":
|
|
103
|
+
return ".cjs";
|
|
104
|
+
case ".tsx":
|
|
105
|
+
case ".jsx":
|
|
106
|
+
return jsx === "preserve" ? ".jsx" : ".js";
|
|
107
|
+
default:
|
|
108
|
+
return ".js";
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function passthroughStringOption(
|
|
113
|
+
tokens: readonly string[] | undefined,
|
|
114
|
+
name: string,
|
|
115
|
+
): string | undefined {
|
|
116
|
+
let value: string | undefined;
|
|
117
|
+
for (let index = 0; index < (tokens?.length ?? 0); index++) {
|
|
118
|
+
const token = tokens?.[index];
|
|
119
|
+
if (
|
|
120
|
+
token === undefined ||
|
|
121
|
+
token.includes("=") ||
|
|
122
|
+
resolveFlagSpec(token)?.name !== resolveFlagSpec(name)?.name
|
|
123
|
+
) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
const next = tokens?.[index + 1];
|
|
127
|
+
if (next !== undefined) {
|
|
128
|
+
value = next.toLowerCase();
|
|
129
|
+
index++;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return value;
|
|
133
|
+
}
|