ttsc 0.31.6 → 0.32.1
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/compiler_argument_cwd_test.go +38 -38
- package/cmd/ttscserver/main.go +2 -12
- package/cmd/ttscserver/resolve_launch_uses_native_flag_authority_test.go +7 -7
- package/driver/lsp.go +4 -43
- package/driver/rewrite.go +1 -1
- package/internal/e2etrace/completion_hints.go +3 -3
- package/internal/e2etrace/completion_hints_test.go +26 -12
- package/internal/graph/build.go +5 -6
- package/internal/graph/graph.go +3 -3
- package/internal/graph/line_model.go +2 -35
- package/internal/lspserver/lsp_clean_didopen_refreshes_compiler_state_test.go +13 -36
- package/internal/lspserver/lsp_hints_refresh_ignores_a_superseded_generation_test.go +9 -3
- package/internal/lspserver/lsp_plugin.go +19 -0
- package/internal/lspserver/lsp_proxy.go +9 -129
- package/internal/lspserver/lsp_server.go +0 -8
- package/internal/lspserver/lsp_watched_file_changes_reach_compiler_caches_test.go +6 -36
- package/internal/sourceprocess/windows_target_owns_suspended_admission_test.go +5 -5
- package/lib/TtscCompiler.js +1 -1
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/compiler/internal/ResidentCheckProcess.d.ts +74 -96
- package/lib/compiler/internal/ResidentCheckProcess.js +150 -335
- package/lib/compiler/internal/ResidentCheckProcess.js.map +1 -1
- package/lib/compiler/internal/ResidentCheckProcessHost.d.ts +127 -0
- package/lib/compiler/internal/ResidentCheckProcessHost.js +447 -0
- package/lib/compiler/internal/ResidentCheckProcessHost.js.map +1 -0
- package/lib/compiler/internal/ResidentCheckProcessProtocol.d.ts +64 -0
- package/lib/compiler/internal/ResidentCheckProcessProtocol.js +3 -0
- package/lib/compiler/internal/ResidentCheckProcessProtocol.js.map +1 -0
- package/lib/compiler/internal/build/BuildExecution.d.ts +103 -1
- package/lib/compiler/internal/build/BuildExecution.js +92 -12
- package/lib/compiler/internal/build/BuildExecution.js.map +1 -1
- package/lib/compiler/internal/build/ResidentCheckWatchSession.d.ts +16 -11
- package/lib/compiler/internal/build/ResidentCheckWatchSession.js +37 -21
- package/lib/compiler/internal/build/ResidentCheckWatchSession.js.map +1 -1
- package/lib/compiler/internal/build/RunBuildOptions.d.ts +6 -5
- package/lib/compiler/internal/build/TsgoArguments.js.map +1 -1
- package/lib/compiler/internal/build/WatchInputPublication.d.ts +59 -0
- package/lib/compiler/internal/build/WatchInputPublication.js +93 -0
- package/lib/compiler/internal/build/WatchInputPublication.js.map +1 -0
- package/lib/compiler/internal/build/runBuild.d.ts +29 -2
- package/lib/compiler/internal/build/runBuild.js +45 -19
- package/lib/compiler/internal/build/runBuild.js.map +1 -1
- package/lib/compiler/internal/buildNativeCompiler.d.ts +2 -0
- package/lib/compiler/internal/buildNativeCompiler.js +1 -0
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
- package/lib/compiler/internal/compileProjectInMemory.js +4 -2
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/project/CompilerProjectSelection.d.ts +9 -8
- package/lib/compiler/internal/project/CompilerProjectSelection.js +11 -9
- package/lib/compiler/internal/project/CompilerProjectSelection.js.map +1 -1
- package/lib/compiler/internal/project/resolveOwningProjectConfig.d.ts +25 -8
- package/lib/compiler/internal/project/resolveOwningProjectConfig.js +26 -14
- package/lib/compiler/internal/project/resolveOwningProjectConfig.js.map +1 -1
- package/lib/compiler/internal/readEffectiveCompilerOptions.js +1 -1
- package/lib/compiler/internal/readEffectiveCompilerOptions.js.map +1 -1
- package/lib/compiler/internal/resolveBinary.d.ts +1 -0
- package/lib/compiler/internal/resolveBinary.js.map +1 -1
- package/lib/compiler/internal/resolveTsgo.d.ts +6 -0
- package/lib/compiler/internal/resolveTsgo.js.map +1 -1
- package/lib/compiler/internal/runSingleFileEmit.d.ts +32 -4
- package/lib/compiler/internal/runSingleFileEmit.js +124 -89
- package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
- package/lib/compiler/internal/startResidentTransform.js +8 -2
- package/lib/compiler/internal/startResidentTransform.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.js +11 -3
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/transformProjectInWorker.d.ts +1 -1
- package/lib/compiler/internal/transformProjectInWorker.js +3 -2
- package/lib/compiler/internal/transformProjectInWorker.js.map +1 -1
- package/lib/flags/ParseOptions.d.ts +2 -2
- package/lib/internal/E2ETrace.js.map +1 -1
- package/lib/internal/OwnedNativeProcess.d.ts +2 -2
- package/lib/internal/OwnedNativeProcess.js +2 -2
- package/lib/internal/SourceNativeRetirement.d.ts +8 -7
- package/lib/internal/SourceNativeRetirement.js +19 -10
- package/lib/internal/SourceNativeRetirement.js.map +1 -1
- package/lib/internal/TtsxNodeOptions.d.ts +79 -0
- package/lib/internal/TtsxNodeOptions.js +121 -0
- package/lib/internal/TtsxNodeOptions.js.map +1 -0
- package/lib/internal/javascriptRuntimeCapabilities.js +4 -1
- package/lib/internal/javascriptRuntimeCapabilities.js.map +1 -1
- package/lib/internal/parseWindowsDirectoryCaseSensitivity.d.ts +5 -5
- package/lib/internal/parseWindowsDirectoryCaseSensitivity.js +5 -5
- package/lib/internal/pathIdentity/createCaseSensitivityObservations.d.ts +35 -0
- package/lib/internal/pathIdentity/createCaseSensitivityObservations.js +209 -0
- package/lib/internal/pathIdentity/createCaseSensitivityObservations.js.map +1 -0
- package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js +2 -143
- package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js.map +1 -1
- package/lib/internal/projectInputPathIdentity.d.ts +1 -0
- package/lib/internal/projectInputPathIdentity.js +1 -0
- package/lib/internal/projectInputPathIdentity.js.map +1 -1
- package/lib/internal/workerModuleUrl.d.ts +28 -0
- package/lib/internal/workerModuleUrl.js +40 -0
- package/lib/internal/workerModuleUrl.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootProject.js +2 -1
- package/lib/launcher/internal/buildSingleRootProject.js.map +1 -1
- package/lib/launcher/internal/getCompilerVersionText.js +3 -2
- package/lib/launcher/internal/getCompilerVersionText.js.map +1 -1
- package/lib/launcher/internal/parseTtsxCLI.d.ts +5 -4
- package/lib/launcher/internal/parseTtsxCLI.js +5 -4
- package/lib/launcher/internal/parseTtsxCLI.js.map +1 -1
- package/lib/launcher/internal/prepareExecution.js +2 -1
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/resolveSingleFileOutput.d.ts +8 -9
- package/lib/launcher/internal/resolveSingleFileOutput.js +8 -9
- package/lib/launcher/internal/resolveSingleFileOutput.js.map +1 -1
- package/lib/launcher/internal/runTtsc.js +91 -41
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtsx.js +5 -2
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/launcher/internal/runtime/CommonJsRuntimeSource.d.ts +10 -6
- package/lib/launcher/internal/runtime/CommonJsRuntimeSource.js +11 -9
- package/lib/launcher/internal/runtime/CommonJsRuntimeSource.js.map +1 -1
- package/lib/launcher/internal/runtime/RuntimeEntrySources.d.ts +40 -0
- package/lib/launcher/internal/runtime/RuntimeEntrySources.js +57 -0
- package/lib/launcher/internal/runtime/RuntimeEntrySources.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeProjectOwnership.d.ts +5 -4
- package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js +8 -6
- package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js.map +1 -1
- package/lib/launcher/internal/runtime/advertiseTypeScriptExtensions.d.ts +20 -0
- package/lib/launcher/internal/runtime/advertiseTypeScriptExtensions.js +27 -0
- package/lib/launcher/internal/runtime/advertiseTypeScriptExtensions.js.map +1 -0
- package/lib/launcher/internal/runtime/commonJsExportNames.d.ts +2 -1
- package/lib/launcher/internal/runtime/commonJsExportNames.js +2 -1
- package/lib/launcher/internal/runtime/commonJsExportNames.js.map +1 -1
- package/lib/launcher/internal/runtime/installRuntimeHooks.d.ts +5 -3
- package/lib/launcher/internal/runtime/installRuntimeHooks.js +42 -12
- package/lib/launcher/internal/runtime/installRuntimeHooks.js.map +1 -1
- package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js +3 -1
- package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js.map +1 -1
- package/lib/launcher/internal/watch/AsyncWatchTopology.d.ts +113 -0
- package/lib/launcher/internal/watch/AsyncWatchTopology.js +232 -0
- package/lib/launcher/internal/watch/AsyncWatchTopology.js.map +1 -0
- package/lib/launcher/internal/watch/WatchSettlement.d.ts +49 -0
- package/lib/launcher/internal/watch/WatchSettlement.js +70 -0
- package/lib/launcher/internal/watch/WatchSettlement.js.map +1 -0
- package/lib/launcher/internal/watch/WatchTopology.d.ts +103 -13
- package/lib/launcher/internal/watch/WatchTopology.js +380 -95
- package/lib/launcher/internal/watch/WatchTopology.js.map +1 -1
- package/lib/launcher/internal/watch/WatchTopologyWorkerProtocol.d.ts +121 -0
- package/lib/launcher/internal/watch/WatchTopologyWorkerProtocol.js +3 -0
- package/lib/launcher/internal/watch/WatchTopologyWorkerProtocol.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.d.ts +4 -1
- package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js +3 -2
- package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js.map +1 -1
- package/lib/launcher/internal/watch/serveWatchTopologyWorker.d.ts +19 -0
- package/lib/launcher/internal/watch/serveWatchTopologyWorker.js +62 -0
- package/lib/launcher/internal/watch/serveWatchTopologyWorker.js.map +1 -0
- package/lib/launcher/internal/watch/watchTopologyWorker.d.ts +1 -0
- package/lib/launcher/internal/watch/watchTopologyWorker.js +22 -0
- package/lib/launcher/internal/watch/watchTopologyWorker.js.map +1 -0
- package/lib/plugin/CapabilityPluginResolver.d.ts +1 -1
- package/lib/plugin/CapabilityPluginResolver.js +3 -2
- package/lib/plugin/CapabilityPluginResolver.js.map +1 -1
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.d.ts +15 -12
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js +13 -11
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js.map +1 -1
- package/lib/plugin/internal/load/PluginPackageResolution.d.ts +2 -2
- package/lib/plugin/internal/load/PluginPackageResolution.js +13 -7
- package/lib/plugin/internal/load/PluginPackageResolution.js.map +1 -1
- package/lib/plugin/internal/load/ProjectPluginEntries.d.ts +23 -7
- package/lib/plugin/internal/load/ProjectPluginEntries.js +36 -14
- package/lib/plugin/internal/load/ProjectPluginEntries.js.map +1 -1
- package/lib/plugin/internal/load/collectProjectHostInputs.d.ts +3 -1
- package/lib/plugin/internal/load/collectProjectHostInputs.js +5 -2
- package/lib/plugin/internal/load/collectProjectHostInputs.js.map +1 -1
- package/lib/plugin/internal/load/hasProjectPluginEntries.d.ts +3 -1
- package/lib/plugin/internal/load/hasProjectPluginEntries.js +4 -2
- package/lib/plugin/internal/load/hasProjectPluginEntries.js.map +1 -1
- package/lib/plugin/internal/load/loadProjectPlugins.d.ts +36 -5
- package/lib/plugin/internal/load/loadProjectPlugins.js +477 -421
- package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
- package/lib/plugin/internal/load/pluginResolutionFailure.d.ts +18 -0
- package/lib/plugin/internal/load/pluginResolutionFailure.js +32 -0
- package/lib/plugin/internal/load/pluginResolutionFailure.js.map +1 -0
- package/lib/plugin/internal/load/resolveNativeSource.js +2 -3
- package/lib/plugin/internal/load/resolveNativeSource.js.map +1 -1
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.d.ts +1 -1
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js +3 -2
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js.map +1 -1
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.d.ts +4 -1
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js +9 -2
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js.map +1 -1
- package/lib/structures/ITtscCompilerContext.d.ts +12 -12
- package/lib/structures/ITtscPlugin.d.ts +7 -5
- package/lib/structures/ITtscPluginFactoryContext.d.ts +9 -8
- package/lib/structures/internal/TtscCommonOptions.d.ts +2 -2
- package/lib/structures/internal/TtscSingleFileEmitOptions.d.ts +12 -6
- package/package.json +9 -9
- package/src/TtscCompiler.ts +1 -1
- package/src/compiler/internal/ResidentCheckProcess.ts +159 -374
- package/src/compiler/internal/ResidentCheckProcessHost.ts +502 -0
- package/src/compiler/internal/ResidentCheckProcessProtocol.ts +53 -0
- package/src/compiler/internal/build/BuildExecution.ts +123 -11
- package/src/compiler/internal/build/ResidentCheckWatchSession.ts +41 -24
- package/src/compiler/internal/build/RunBuildOptions.ts +9 -5
- package/src/compiler/internal/build/TsgoArguments.ts +4 -1
- package/src/compiler/internal/build/WatchInputPublication.ts +106 -0
- package/src/compiler/internal/build/runBuild.ts +58 -34
- package/src/compiler/internal/buildNativeCompiler.ts +4 -0
- package/src/compiler/internal/compileProjectInMemory.ts +8 -2
- package/src/compiler/internal/project/CompilerProjectSelection.ts +14 -14
- package/src/compiler/internal/project/resolveOwningProjectConfig.ts +42 -16
- package/src/compiler/internal/readEffectiveCompilerOptions.ts +1 -1
- package/src/compiler/internal/resolveBinary.ts +4 -1
- package/src/compiler/internal/resolveTsgo.ts +7 -0
- package/src/compiler/internal/runSingleFileEmit.ts +145 -101
- package/src/compiler/internal/startResidentTransform.ts +9 -2
- package/src/compiler/internal/transformProjectInMemory.ts +12 -3
- package/src/compiler/internal/transformProjectInWorker.ts +10 -2
- package/src/flags/ParseOptions.ts +2 -2
- package/src/internal/E2ETrace.ts +3 -1
- package/src/internal/OwnedNativeProcess.ts +2 -2
- package/src/internal/SourceNativeRetirement.ts +42 -19
- package/src/internal/TtsxNodeOptions.ts +124 -0
- package/src/internal/javascriptRuntimeCapabilities.ts +6 -1
- package/src/internal/parseWindowsDirectoryCaseSensitivity.ts +5 -5
- package/src/internal/pathIdentity/createCaseSensitivityObservations.ts +242 -0
- package/src/internal/pathIdentity/createFilesystemPathIdentityContext.ts +2 -169
- package/src/internal/projectInputPathIdentity.ts +1 -0
- package/src/internal/workerModuleUrl.ts +34 -0
- package/src/launcher/internal/buildSingleRootProject.ts +2 -0
- package/src/launcher/internal/getCompilerVersionText.ts +3 -2
- package/src/launcher/internal/parseTtsxCLI.ts +5 -4
- package/src/launcher/internal/prepareExecution.ts +6 -1
- package/src/launcher/internal/resolveSingleFileOutput.ts +8 -9
- package/src/launcher/internal/runTtsc.ts +127 -49
- package/src/launcher/internal/runTtsx.ts +17 -8
- package/src/launcher/internal/runtime/CommonJsRuntimeSource.ts +11 -9
- package/src/launcher/internal/runtime/RuntimeEntrySources.ts +57 -0
- package/src/launcher/internal/runtime/RuntimeProjectOwnership.ts +23 -10
- package/src/launcher/internal/runtime/advertiseTypeScriptExtensions.ts +25 -0
- package/src/launcher/internal/runtime/commonJsExportNames.ts +11 -4
- package/src/launcher/internal/runtime/installRuntimeHooks.ts +62 -16
- package/src/launcher/internal/runtime/resolveRuntimeCleanTargets.ts +17 -5
- package/src/launcher/internal/watch/AsyncWatchTopology.ts +267 -0
- package/src/launcher/internal/watch/WatchSettlement.ts +67 -0
- package/src/launcher/internal/watch/WatchTopology.ts +461 -102
- package/src/launcher/internal/watch/WatchTopologyWorkerProtocol.ts +106 -0
- package/src/launcher/internal/watch/projectInputReloadEventShouldNotify.ts +14 -9
- package/src/launcher/internal/watch/serveWatchTopologyWorker.ts +75 -0
- package/src/launcher/internal/watch/watchTopologyWorker.ts +29 -0
- package/src/plugin/CapabilityPluginResolver.ts +9 -2
- package/src/plugin/internal/load/PluginDescriptorEvaluationCache.ts +17 -12
- package/src/plugin/internal/load/PluginPackageResolution.ts +14 -9
- package/src/plugin/internal/load/ProjectPluginEntries.ts +40 -15
- package/src/plugin/internal/load/collectProjectHostInputs.ts +7 -1
- package/src/plugin/internal/load/hasProjectPluginEntries.ts +8 -3
- package/src/plugin/internal/load/loadProjectPlugins.ts +683 -593
- package/src/plugin/internal/load/pluginResolutionFailure.ts +37 -0
- package/src/plugin/internal/load/resolveNativeSource.ts +10 -4
- package/src/plugin/internal/source/PluginBuildEnvironmentReadings.ts +8 -2
- package/src/plugin/internal/source/pluginModuleReplaceDirectories.ts +10 -1
- package/src/structures/ITtscCompilerContext.ts +12 -12
- package/src/structures/ITtscPlugin.ts +7 -5
- package/src/structures/ITtscPluginFactoryContext.ts +9 -8
- package/src/structures/internal/TtscCommonOptions.ts +2 -2
- package/src/structures/internal/TtscSingleFileEmitOptions.ts +22 -11
- package/internal/graphsymbols/position_helpers_follow_ecma_line_terminators_test.go +0 -78
- package/internal/graphsymbols/provider.go +0 -650
- package/internal/lspserver/lsp_symbols.go +0 -212
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attribute a package-resolution failure to its plugin and consumer directory.
|
|
3
|
+
*
|
|
4
|
+
* Runtime resolvers can throw objects with an empty message. The request and
|
|
5
|
+
* directory remain actionable independently of that message; the original cause
|
|
6
|
+
* and any string error code remain available to callers.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/common.md#principled-implementation Resolution supplies the actual specifier and consumer directory, so diagnostic context survives an empty runtime message without inferring a cause or changing resolver policy.
|
|
9
|
+
* @evidence contracts/common.md#clear-and-simple-design One error boundary enriches diagnostics while preserving the original cause and a string code.
|
|
10
|
+
* @evidence contracts/common.md#prohibited-implementation-shortcuts Error attribution uses every failed request without package-name, runtime-name or message-pattern exceptions.
|
|
11
|
+
* @evidence contracts/common.md#meaningful-documentation The comment states why independent resolution context is necessary and which original failure fields survive.
|
|
12
|
+
*
|
|
13
|
+
* @evidenceExclude contracts/portability.md#os-neutral-implementation The function displays caller-supplied strings and performs no filesystem, path-identity or process operation.
|
|
14
|
+
* @evidence contracts/performance.md#efficient-algorithms One diagnostic allocation copies specifier, directory and optional message text; work and storage scale with those strings.
|
|
15
|
+
* @evidenceExclude contracts/performance.md#reuse-equivalent-work Errors describe the current failed request and own no reusable observation.
|
|
16
|
+
* @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned error transfers its cause to the caller and owns no native resource or cross-call population.
|
|
17
|
+
*/
|
|
18
|
+
export function pluginResolutionFailure(
|
|
19
|
+
specifier: string,
|
|
20
|
+
consumerDir: string,
|
|
21
|
+
cause: unknown,
|
|
22
|
+
): Error {
|
|
23
|
+
const record =
|
|
24
|
+
typeof cause === "object" && cause !== null
|
|
25
|
+
? (cause as { code?: unknown; message?: unknown })
|
|
26
|
+
: undefined;
|
|
27
|
+
const message = typeof cause === "string" ? cause : record?.message;
|
|
28
|
+
const detail =
|
|
29
|
+
typeof message === "string" && message.trim() !== "" ? `: ${message}` : "";
|
|
30
|
+
const error = new Error(
|
|
31
|
+
`ttsc: could not resolve plugin ${JSON.stringify(specifier)} from ${JSON.stringify(consumerDir)}${detail}`,
|
|
32
|
+
{ cause },
|
|
33
|
+
);
|
|
34
|
+
return typeof record?.code === "string"
|
|
35
|
+
? Object.assign(error, { code: record.code })
|
|
36
|
+
: error;
|
|
37
|
+
}
|
|
@@ -30,13 +30,19 @@ export function resolveNativeSource(
|
|
|
30
30
|
plugin: ITtscPlugin,
|
|
31
31
|
config: ITtscProjectPluginConfig,
|
|
32
32
|
index: number,
|
|
33
|
-
options?: {
|
|
33
|
+
options?: {
|
|
34
|
+
env?: NodeJS.ProcessEnv;
|
|
35
|
+
observation?: NativeSourcePackages.Package;
|
|
36
|
+
},
|
|
34
37
|
): { kind: "executable" | "linked"; moduleRoot: string } {
|
|
35
38
|
const label = pluginLabel(plugin, config, index);
|
|
36
39
|
requirePluginSource(source, label);
|
|
37
40
|
const { moduleRoot } = resolvePluginGoModule(source, label);
|
|
38
|
-
const observation =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
const observation =
|
|
42
|
+
options?.observation ??
|
|
43
|
+
NativeSourcePackages.propose(
|
|
44
|
+
[{ source, label, ownModule: plugin.stage === "check" }],
|
|
45
|
+
SidecarEnvironment.merge(options?.env ?? process.env),
|
|
46
|
+
)[0]!.observation;
|
|
41
47
|
return { kind: NativeSourcePackages.kind(observation, label), moduleRoot };
|
|
42
48
|
}
|
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { SHARE_ENV, Worker } from "node:worker_threads";
|
|
4
4
|
|
|
5
5
|
import { SidecarEnvironment } from "../../../compiler/internal/sharedHost/SidecarEnvironment";
|
|
6
|
+
import { workerModuleUrl } from "../../../internal/workerModuleUrl";
|
|
6
7
|
import { PluginBuildEnvironmentWitness } from "./PluginBuildEnvironmentWitness";
|
|
7
8
|
import { PluginContentIdentities } from "./PluginContentIdentities";
|
|
8
9
|
import { pluginBuildEnvironment } from "./pluginBuildEnvironment";
|
|
@@ -24,7 +25,7 @@ import { pluginBuildEnvironment } from "./pluginBuildEnvironment";
|
|
|
24
25
|
* @evidence contracts/common.md#clear-and-simple-design One owner shares observation records across synchronous reads, cache-only proof and asynchronous preparation.
|
|
25
26
|
* @evidence contracts/common.md#prohibited-implementation-shortcuts Cold preparation performs the same actual native Go/toolchain reading off-thread; failed or stale observations are never replaced by producer-expected state.
|
|
26
27
|
* @evidence contracts/common.md#meaningful-documentation Native prose distinguishes preparation, publication and cache-only authority; members document their separate execution responsibilities.
|
|
27
|
-
* @evidence contracts/portability.md#os-neutral-implementation Complete environment snapshots use the shared native-name merger; metadata witnesses preserve actual native filesystem and link identity.
|
|
28
|
+
* @evidence contracts/portability.md#os-neutral-implementation Complete environment snapshots use the shared native-name merger; metadata witnesses preserve actual native filesystem and link identity. A supported module URL requires the CommonJS source or emitted worker entry while Node retains inherited execution options and preload hooks.
|
|
28
29
|
* @evidenceExclude contracts/performance.md#efficient-algorithms Individual members own variable indexing, witness validation and native preparation.
|
|
29
30
|
* @evidenceExclude contracts/performance.md#reuse-equivalent-work The members specify the invalidation and sharing boundaries.
|
|
30
31
|
* @evidence contracts/performance.md#bound-retention-and-release-resources Readings replace existing keys but retain historical directory/environment keys without eviction. One idle worker and its retirement listeners remain process-owned/unreferenced; active work is ref'ed and per-request listeners are removed at settlement. Distinct requests can queue without a population bound/timeout; a stalled request can delay successors. Failed-worker termination is initiated without joining its promise, and this owner does not mutate the shared environment.
|
|
@@ -293,7 +294,12 @@ export namespace PluginBuildEnvironmentReadings {
|
|
|
293
294
|
function acquireWorker(): Worker {
|
|
294
295
|
if (worker !== undefined) return worker;
|
|
295
296
|
const created = new Worker(
|
|
296
|
-
|
|
297
|
+
workerModuleUrl(
|
|
298
|
+
path.join(
|
|
299
|
+
__dirname,
|
|
300
|
+
`pluginBuildEnvironmentWorker${path.extname(__filename)}`,
|
|
301
|
+
),
|
|
302
|
+
),
|
|
297
303
|
{ env: SHARE_ENV },
|
|
298
304
|
);
|
|
299
305
|
worker = created;
|
|
@@ -4,6 +4,7 @@ import path from "node:path";
|
|
|
4
4
|
import { resolvePhysicalPath } from "../../../internal/pathIdentity/resolvePhysicalPath";
|
|
5
5
|
import { GoToolResolution } from "./GoToolResolution";
|
|
6
6
|
import type { IPluginModuleReplaceDirectory } from "./IPluginModuleReplaceDirectory";
|
|
7
|
+
import type { PluginContentIdentities } from "./PluginContentIdentities";
|
|
7
8
|
import { SourcePluginWorkspace } from "./SourcePluginWorkspace";
|
|
8
9
|
import { resolveGoCompiler } from "./resolveGoCompiler";
|
|
9
10
|
import { selectPluginModuleReplaceDirectories } from "./selectPluginModuleReplaceDirectories";
|
|
@@ -30,6 +31,8 @@ import { selectPluginModuleReplaceDirectories } from "./selectPluginModuleReplac
|
|
|
30
31
|
* @param env The build's effective environment.
|
|
31
32
|
* @param goBinary The Go tool the build runs, or `undefined` to resolve it as
|
|
32
33
|
* the build does.
|
|
34
|
+
* @param identities The load's record store, carried by a reader this call
|
|
35
|
+
* registers so the load's later reads reuse recorded syntax.
|
|
33
36
|
* @returns Each replacement outside the module, sorted by module path: the
|
|
34
37
|
* replaced module path and version, the target as `go.mod` spells it, and the
|
|
35
38
|
* target's absolute path.
|
|
@@ -52,6 +55,7 @@ export function pluginModuleReplaceDirectories(
|
|
|
52
55
|
goBinary?: string,
|
|
53
56
|
reader?: SourcePluginWorkspace.GoModReader,
|
|
54
57
|
readers?: Map<string, SourcePluginWorkspace.GoModReader>,
|
|
58
|
+
identities?: PluginContentIdentities.Store,
|
|
55
59
|
): IPluginModuleReplaceDirectory[] {
|
|
56
60
|
const root = path.resolve(moduleRoot);
|
|
57
61
|
let text: string;
|
|
@@ -72,7 +76,12 @@ export function pluginModuleReplaceDirectories(
|
|
|
72
76
|
root,
|
|
73
77
|
);
|
|
74
78
|
const parsed = (
|
|
75
|
-
reader ??
|
|
79
|
+
reader ??
|
|
80
|
+
// WARNING (#1739): the first reader registered for a Go binary serves the
|
|
81
|
+
// whole load, so it must carry the load's record store, or every later
|
|
82
|
+
// reader request of the load gets a store-less one and the go.mod syntax
|
|
83
|
+
// records are never read or written.
|
|
84
|
+
SourcePluginWorkspace.createGoModReader(go, root, env, readers, identities)
|
|
76
85
|
).read(root);
|
|
77
86
|
// Parsed syntax may be shared; physical containment is current native state
|
|
78
87
|
// and must be recomputed even when these manifest bytes are unchanged.
|
|
@@ -29,8 +29,7 @@ export interface ITtscCompilerContext {
|
|
|
29
29
|
* The working directory for this compiler instance.
|
|
30
30
|
*
|
|
31
31
|
* Used to discover `tsconfig.json`, resolve relative `tsconfig` paths,
|
|
32
|
-
* resolve project source files,
|
|
33
|
-
* cache paths.
|
|
32
|
+
* resolve project source files, and resolve relative cache paths.
|
|
34
33
|
*
|
|
35
34
|
* An omitted value uses `process.cwd()` when the operation resolves its
|
|
36
35
|
* context; construction does not capture that default.
|
|
@@ -49,19 +48,20 @@ export interface ITtscCompilerContext {
|
|
|
49
48
|
tsconfig?: string;
|
|
50
49
|
|
|
51
50
|
/**
|
|
52
|
-
*
|
|
51
|
+
* Source root used for source membership, native plugin cwd and cache paths.
|
|
53
52
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* real
|
|
53
|
+
* Omission uses the resolved config directory. Set a common ancestor when the
|
|
54
|
+
* config includes sibling packages; relative paths resolve from cwd. Returned
|
|
55
|
+
* relative Go-source paths and descriptor process cwd also use this root.
|
|
56
|
+
* Plugin package resolution and factory contexts keep the selected config
|
|
57
|
+
* directory independently. Generated config wrappers supply the real consumer
|
|
58
|
+
* directory through pluginConfigDir and may retain a wider source root here.
|
|
59
59
|
*/
|
|
60
60
|
projectRoot?: string;
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
* `configFile` resolution.
|
|
63
|
+
* Consumer directory for plugin packages, factory contexts, plugin
|
|
64
|
+
* config-file discovery and relative `configFile` resolution.
|
|
65
65
|
*
|
|
66
66
|
* Leave this unset so plugins anchor at the directory of the resolved
|
|
67
67
|
* {@link ITtscCompilerContext.tsconfig} as usual. Embedders that compile
|
|
@@ -89,8 +89,8 @@ export interface ITtscCompilerContext {
|
|
|
89
89
|
binary?: string;
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Additional environment variables for
|
|
93
|
-
* processes, and for the worker thread of
|
|
92
|
+
* Additional environment variables for executable selection, compiler and
|
|
93
|
+
* plugin-descriptor child processes, and for the worker thread of
|
|
94
94
|
* {@link TtscCompiler.transformAsync}.
|
|
95
95
|
*
|
|
96
96
|
* The supplied overrides are copied at construction. Values are merged over
|
|
@@ -87,11 +87,13 @@ export interface ITtscPlugin {
|
|
|
87
87
|
* linked into the selected native host and must register through
|
|
88
88
|
* `driver.RegisterPlugin`.
|
|
89
89
|
*
|
|
90
|
-
* Relative paths are resolved from the
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
90
|
+
* Relative paths are resolved from the compiler's source root, including an
|
|
91
|
+
* explicit projectRoot override. This can differ from the factory's consumer
|
|
92
|
+
* directory for plugin package resolution. Package descriptors published in
|
|
93
|
+
* npm packages should normally return absolute paths based on their own
|
|
94
|
+
* descriptor directory. Derive them from a factory's `context.dirname` (the
|
|
95
|
+
* load-mode-independent replacement for `__dirname`, which is undefined when
|
|
96
|
+
* ttsc loads the descriptor through ttsx or as ESM).
|
|
95
97
|
*
|
|
96
98
|
* Common layouts:
|
|
97
99
|
*
|
|
@@ -76,8 +76,8 @@ export interface ITtscPluginFactoryContext<T = ITtscProjectPluginConfig> {
|
|
|
76
76
|
plugin: T;
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* Caller-declared
|
|
80
|
-
* `configFile` resolution.
|
|
79
|
+
* Caller-declared consumer directory for plugin package discovery, factory
|
|
80
|
+
* contexts and relative `configFile` resolution.
|
|
81
81
|
*
|
|
82
82
|
* Absent for ordinary invocations, where a factory anchors config discovery
|
|
83
83
|
* at the {@link ITtscPluginFactoryContext.tsconfig} directory. Present when
|
|
@@ -91,13 +91,14 @@ export interface ITtscPluginFactoryContext<T = ITtscProjectPluginConfig> {
|
|
|
91
91
|
pluginConfigDir?: string;
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
|
-
*
|
|
95
|
-
* discovery base.
|
|
94
|
+
* Consumer directory used for plugin package discovery.
|
|
96
95
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
96
|
+
* This is pluginConfigDir when supplied, otherwise the directory containing
|
|
97
|
+
* the resolved tsconfig/jsconfig. A compiler projectRoot override can widen
|
|
98
|
+
* source membership without changing this package-resolution anchor.
|
|
99
|
+
* Descriptor process cwd, native plugin cwd and returned relative source
|
|
100
|
+
* paths retain the compiler's source root; return absolute source paths when
|
|
101
|
+
* those directories differ.
|
|
101
102
|
*/
|
|
102
103
|
projectRoot: string;
|
|
103
104
|
|
|
@@ -86,8 +86,8 @@ export interface TtscCommonOptions {
|
|
|
86
86
|
}[];
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
|
-
* Retained native compiler argument base when project selection redirects
|
|
90
|
-
*
|
|
89
|
+
* Retained native compiler argument base when project selection redirects the
|
|
90
|
+
* Program to a different root. Absent retains the selected project root.
|
|
91
91
|
* Response frames and relative native options use this base; plugin/rule
|
|
92
92
|
* context and config-relative paths retain their separate project authority.
|
|
93
93
|
*/
|
|
@@ -42,10 +42,14 @@ export interface TtscSingleFileEmitOptions extends TtscCommonOptions {
|
|
|
42
42
|
* this notification is not the complete compiler or project-rule input graph.
|
|
43
43
|
* The reporting load also hands over its record store, if it opened one, so the
|
|
44
44
|
* owner proves each root's state from the plugin cache's records instead of
|
|
45
|
-
* reading the sources the load is about to prove (#1728).
|
|
45
|
+
* reading the sources the load is about to prove (#1728). Asynchronous build
|
|
46
|
+
* entries await a returned promise before reading or building those sources;
|
|
47
|
+
* synchronous entries require a synchronous handler. Separate function
|
|
48
|
+
* alternatives preserve TypeScript's void-handler assignability, including
|
|
49
|
+
* ignored non-promise return values.
|
|
46
50
|
*
|
|
47
|
-
* @evidence contracts/common.md#principled-implementation Readonly roots describe the actual native-plugin sources whose later edits need observation.
|
|
48
|
-
* @evidence contracts/common.md#clear-and-simple-design
|
|
51
|
+
* @evidence contracts/common.md#principled-implementation Readonly roots describe the actual native-plugin sources whose later edits need observation; separate void and Promise function alternatives preserve existing ignored-return callback assignability while exposing asynchronous completion.
|
|
52
|
+
* @evidence contracts/common.md#clear-and-simple-design The handoff leaves watcher construction and lifetime with the invocation owner, while its completion determines when the producer may continue.
|
|
49
53
|
* @evidence contracts/common.md#prohibited-implementation-shortcuts The supported callback neither replaces foreign watchers nor fabricates fixture-specific roots.
|
|
50
54
|
* @evidence contracts/common.md#meaningful-documentation Native prose states the source population and owner before acknowledgment tags.
|
|
51
55
|
* @evidence contracts/portability.md#os-neutral-implementation Native source paths pass through without separator rewriting, alias collapse or an encoded OS-specific watcher.
|
|
@@ -53,16 +57,23 @@ export interface TtscSingleFileEmitOptions extends TtscCommonOptions {
|
|
|
53
57
|
* @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
|
|
54
58
|
* @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
|
|
55
59
|
*/
|
|
56
|
-
export type TtscPluginSourceInputsHandler =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
export type TtscPluginSourceInputsHandler =
|
|
61
|
+
| ((
|
|
62
|
+
inputs: readonly string[],
|
|
63
|
+
identities?: PluginContentIdentities.Store,
|
|
64
|
+
) => void)
|
|
65
|
+
| ((
|
|
66
|
+
inputs: readonly string[],
|
|
67
|
+
identities?: PluginContentIdentities.Store,
|
|
68
|
+
) => Promise<void>);
|
|
60
69
|
|
|
61
70
|
/**
|
|
62
71
|
* Receive the discovered project-rule filesystem topology for the watch owner.
|
|
72
|
+
* Asynchronous build entries await a returned promise before compilation;
|
|
73
|
+
* synchronous entries require a synchronous handler.
|
|
63
74
|
*
|
|
64
75
|
* @evidence contracts/common.md#principled-implementation The snapshot retains exact, glob and reload dependencies rather than reducing them to plugin-source roots.
|
|
65
|
-
* @evidence contracts/common.md#clear-and-simple-design A separate
|
|
76
|
+
* @evidence contracts/common.md#clear-and-simple-design A separate completion-bearing notification transfers topology without assigning watcher lifetime to the emit options.
|
|
66
77
|
* @evidence contracts/common.md#prohibited-implementation-shortcuts A discovered rule snapshot crosses a supported boundary without replacing watcher internals or inventing passing inputs.
|
|
67
78
|
* @evidence contracts/common.md#meaningful-documentation Native prose identifies the project-rule payload and watch owner before the separated tags.
|
|
68
79
|
* @evidence contracts/portability.md#os-neutral-implementation The snapshot retains native paths, explicit glob grammar and declared versus physical identities without blanket case folding.
|
|
@@ -70,6 +81,6 @@ export type TtscPluginSourceInputsHandler = (
|
|
|
70
81
|
* @evidenceExclude contracts/performance.md#efficient-algorithms A type declaration chooses no processing strategy.
|
|
71
82
|
* @evidenceExclude contracts/performance.md#reuse-equivalent-work A type declaration computes nothing, so there is no work to share.
|
|
72
83
|
*/
|
|
73
|
-
export type TtscProjectInputsHandler =
|
|
74
|
-
inputs: ITtscProjectInputSnapshot
|
|
75
|
-
) => void;
|
|
84
|
+
export type TtscProjectInputsHandler =
|
|
85
|
+
| ((inputs: ITtscProjectInputSnapshot) => void)
|
|
86
|
+
| ((inputs: ITtscProjectInputSnapshot) => Promise<void>);
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
package graphsymbols
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"testing"
|
|
5
|
-
"unicode/utf8"
|
|
6
|
-
|
|
7
|
-
"github.com/samchon/ttsc/packages/ttsc/internal/graph"
|
|
8
|
-
"github.com/samchon/ttsc/packages/ttsc/internal/lspserver"
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
// TestPositionHelpersFollowECMALineTerminators verifies graph-backed LSP
|
|
12
|
-
// positions use the compiler's LF, CRLF, CR, LS, and PS line boundaries.
|
|
13
|
-
//
|
|
14
|
-
// An offset-to-position helper that counted only LF while its inverse counted
|
|
15
|
-
// CR too would map an editor cursor to a graph offset that returns on a
|
|
16
|
-
// different line. Literal starts and ends establish three authored logical
|
|
17
|
-
// lines; the test walks their UTF-8 boundaries, including an emoji, and requires
|
|
18
|
-
// a round trip. Columns are not compared to literal UTF-16 counts, so symmetric
|
|
19
|
-
// column mistakes can pass. No editor/server request is exercised.
|
|
20
|
-
//
|
|
21
|
-
// 1. Build three lines with each ECMAScript terminator.
|
|
22
|
-
// 2. Enumerate every valid cursor boundary before each terminator.
|
|
23
|
-
// 3. Convert each offset to UTF-16 LSP position and back to the same offset.
|
|
24
|
-
//
|
|
25
|
-
// @evidence contracts/testing.md#behavioral-verification Verifies graph-backed LSP positions use the compiler's LF, CRLF, CR, LS, and PS line boundaries.
|
|
26
|
-
// @evidence contracts/testing.md#independent-expectations Each case embeds one ECMAScript terminator (LF, CRLF, CR, LS or PS) in a three-line literal, so the expected line count (three) and the line of every offset follow from the language's line-terminator definition. Columns are checked only by an offset -> position -> offset round trip over every UTF-8 rune boundary (including the two-unit emoji), not against literal UTF-16 column numbers, so a column error made symmetrically by both helpers would not be detected.
|
|
27
|
-
// @evidence contracts/testing.md#distinguishing-cases Build three lines with each ECMAScript terminator; Enumerate every valid cursor boundary before each terminator; Convert each offset to UTF-16 LSP position and back to the same offset; the five terminator subtests differ only in the terminator, and a position on the line index just past the last line must not resolve (negative case). No empty-text or out-of-range-column input is exercised here.
|
|
28
|
-
// @evidence contracts/testing.md#execution-ownership Directly calls the maintained line and position helpers on authored UTF-8 strings in this process. Literal byte boundaries establish enumeration; round-trip column expectations share the two converters and are not a separate UTF-16 oracle. It creates no native fixture, loads no Program, installs no consumer, and starts no product process or editor/server connection.
|
|
29
|
-
func TestPositionHelpersFollowECMALineTerminators(t *testing.T) {
|
|
30
|
-
cases := []struct {
|
|
31
|
-
name string
|
|
32
|
-
terminator string
|
|
33
|
-
}{
|
|
34
|
-
{name: "LF", terminator: "\n"},
|
|
35
|
-
{name: "CRLF", terminator: "\r\n"},
|
|
36
|
-
{name: "CR", terminator: "\r"},
|
|
37
|
-
{name: "LS", terminator: "\u2028"},
|
|
38
|
-
{name: "PS", terminator: "\u2029"},
|
|
39
|
-
}
|
|
40
|
-
for _, tc := range cases {
|
|
41
|
-
t.Run(tc.name, func(t *testing.T) {
|
|
42
|
-
text := "alpha😀" + tc.terminator + "beta" + tc.terminator + "gamma"
|
|
43
|
-
starts := graph.ECMALineStarts(text)
|
|
44
|
-
if len(starts) != 3 {
|
|
45
|
-
t.Fatalf("line starts = %v, want three lines", starts)
|
|
46
|
-
}
|
|
47
|
-
expectedStarts := []int{0, 9 + len(tc.terminator), 13 + 2*len(tc.terminator)}
|
|
48
|
-
expectedEnds := []int{9, 13 + len(tc.terminator), len(text)}
|
|
49
|
-
for line, start := range starts {
|
|
50
|
-
end := graph.LineEnd(text, starts, line)
|
|
51
|
-
if start != expectedStarts[line] || end != expectedEnds[line] {
|
|
52
|
-
t.Fatalf("line %d boundaries = (%d, %d), want (%d, %d)", line, start, end, expectedStarts[line], expectedEnds[line])
|
|
53
|
-
}
|
|
54
|
-
for offset := start; ; {
|
|
55
|
-
position := offsetToPosition(text, offset)
|
|
56
|
-
if position.Line != line {
|
|
57
|
-
t.Fatalf("offset %d position line = %d, want %d", offset, position.Line, line)
|
|
58
|
-
}
|
|
59
|
-
restored, ok := lspPositionToOffset(text, position)
|
|
60
|
-
if !ok || restored != offset {
|
|
61
|
-
t.Fatalf("offset %d -> %+v -> (%d, %t), want itself", offset, position, restored, ok)
|
|
62
|
-
}
|
|
63
|
-
if offset == end {
|
|
64
|
-
break
|
|
65
|
-
}
|
|
66
|
-
_, size := utf8.DecodeRuneInString(text[offset:])
|
|
67
|
-
if size == 0 {
|
|
68
|
-
t.Fatal("unexpected zero-width UTF-8 rune")
|
|
69
|
-
}
|
|
70
|
-
offset += size
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
if _, ok := lspPositionToOffset(text, lspserver.LSPPosition{Line: len(starts), Character: 0}); ok {
|
|
74
|
-
t.Fatal("position on a nonexistent source line must not resolve")
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
}
|