ttsc 0.33.1 → 0.34.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.
Files changed (397) hide show
  1. package/README.md +2 -0
  2. package/cmd/ttsc/api_compile.go +3 -2
  3. package/cmd/ttsc/api_transform.go +1 -1
  4. package/cmd/ttsc/build.go +5 -4
  5. package/cmd/ttsc-cache/account.go +16 -0
  6. package/cmd/ttsc-cache/account_test.go +91 -0
  7. package/cmd/ttsc-cache/main.go +1 -1
  8. package/cmd/ttsc-cache/protocol_test.go +2 -2
  9. package/cmd/ttsc-cache/publisher_seal_test.go +1 -1
  10. package/cmd/ttsc-cache/stock_go_failure_test.go +1 -1
  11. package/cmd/ttsc-cache/stock_go_test.go +2 -2
  12. package/cmd/ttsc-cache/store.go +5 -0
  13. package/cmd/ttsc-cache/tuple.go +6 -2
  14. package/cmd/ttsc-cache/tuple_test.go +1 -1
  15. package/cmd/ttscgraph/main.go +6 -1
  16. package/cmd/ttscgraph/run_help_version_and_bad_flags_exit_codes_test.go +6 -1
  17. package/cmd/ttscgraph/serve.go +22 -20
  18. package/cmd/ttscgraph/serve_shards.go +26 -15
  19. package/cmd/ttscgraph/serve_shards_abandoned_generation_converges_on_retry_test.go +2 -2
  20. package/cmd/ttscgraph/serve_shards_delete_removed_source_test.go +3 -3
  21. package/cmd/ttscgraph/serve_shards_prune_unreferenced_external_endpoints_test.go +1 -1
  22. package/cmd/ttscgraph/serve_shards_publish_created_source_test.go +3 -3
  23. package/cmd/ttscgraph/serve_shards_refresh_cross_file_implementation_test.go +2 -2
  24. package/cmd/ttscgraph/serve_shards_refresh_dependent_diagnostics_test.go +3 -3
  25. package/cmd/ttscgraph/serve_shards_rename_moves_source_identity_test.go +5 -5
  26. package/cmd/ttscgraph/serve_shards_reuse_unaffected_sources_test.go +8 -8
  27. package/cmd/ttscgraph/serve_source_encoding_test.go +2 -2
  28. package/driver/build_information_uses_selected_output_identity_test.go +5 -4
  29. package/driver/check_observations.go +1 -1
  30. package/driver/config_discovery.go +5 -1
  31. package/driver/declaration_shape.go +15 -21
  32. package/driver/diagnostics_preamble.go +2 -2
  33. package/driver/emit_containment.go +11 -14
  34. package/driver/emit_plugin.go +51 -43
  35. package/driver/emit_plugin_output.go +6 -5
  36. package/driver/emit_provenance.go +12 -15
  37. package/driver/graph.go +8 -8
  38. package/driver/host.go +15 -5
  39. package/driver/input_observation.go +22 -21
  40. package/driver/input_observation_test.go +11 -10
  41. package/driver/overlay.go +11 -11
  42. package/driver/program.go +102 -51
  43. package/driver/resolution_candidates.go +50 -32
  44. package/driver/resolution_candidates_test.go +18 -5
  45. package/driver/rewrite.go +11 -13
  46. package/driver/session.go +13 -7
  47. package/driver/target_ts70.go +85 -0
  48. package/driver/target_ts71.go +97 -0
  49. package/driver/transform_dependencies.go +1 -1
  50. package/driver/transform_source_map.go +21 -20
  51. package/go.mod +3 -3
  52. package/go.sum +4 -4
  53. package/internal/graph/alternative_member_declarations_resolve_uses_test.go +9 -9
  54. package/internal/graph/assigned_implementations_of_declaration_file_symbols_leave_no_edge_source_test.go +2 -2
  55. package/internal/graph/assigned_implementations_of_node_modules_symbols_leave_no_edge_source_test.go +2 -2
  56. package/internal/graph/build.go +17 -17
  57. package/internal/graph/build_files_reuses_committed_cross_file_endpoints_test.go +4 -4
  58. package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +1 -1
  59. package/internal/graph/declaration_members.go +1 -1
  60. package/internal/graph/decorators_capture_name_and_literal_arguments_test.go +3 -3
  61. package/internal/graph/doc_tags.go +2 -2
  62. package/internal/graph/dump_paths.go +6 -5
  63. package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +1 -1
  64. package/internal/graph/edges.go +49 -38
  65. package/internal/graph/edges_cover_class_level_references_test.go +5 -5
  66. package/internal/graph/enum_initializer_calls_are_edges_test.go +2 -2
  67. package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +6 -6
  68. package/internal/graph/exports.go +6 -6
  69. package/internal/graph/file_diagnostics_match_tsgo_code_and_location_test.go +2 -2
  70. package/internal/graph/file_diagnostics_report_code_column_and_message_test.go +1 -1
  71. package/internal/graph/function_locals_do_not_collide_test.go +3 -3
  72. package/internal/graph/heritage_edges_cover_implements_and_interface_extends_test.go +5 -5
  73. package/internal/graph/heritage_edges_keep_extends_and_implements_to_same_base_test.go +2 -2
  74. package/internal/graph/heritage_edges_record_extends_versus_implements_origin_test.go +3 -3
  75. package/internal/graph/heritage_edges_traverse_barrels_and_stop_at_external_leaves_test.go +3 -3
  76. package/internal/graph/literals.go +3 -3
  77. package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +2 -2
  78. package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +4 -4
  79. package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +2 -2
  80. package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +1 -1
  81. package/internal/graph/literals_resolve_through_alias_indirection_test.go +3 -3
  82. package/internal/graph/member_relation_edges_follow_checker_validity_test.go +7 -7
  83. package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +19 -19
  84. package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +11 -11
  85. package/internal/graph/namespace_dotted_form_qualifies_deeply_test.go +2 -2
  86. package/internal/graph/namespace_members_become_qualified_nodes_and_edges_test.go +7 -7
  87. package/internal/graph/namespace_private_declarations_keep_lexical_identity_test.go +5 -5
  88. package/internal/graph/nodes_are_marked_exported_through_the_export_table_test.go +2 -2
  89. package/internal/graph/object_literal_declarations_resolve_calls_test.go +9 -9
  90. package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +1 -1
  91. package/internal/graph/overload_implementation_replaces_signature_test.go +2 -2
  92. package/internal/graph/property_member_edges_remain_owner_visible_test.go +6 -6
  93. package/internal/graph/resolve.go +7 -7
  94. package/internal/graph/resolve_unwraps_barrel_reexport_to_real_declaration_test.go +6 -6
  95. package/internal/graph/source.go +1 -1
  96. package/internal/graph/type_ref_edges_cover_typeof_as_satisfies_test.go +7 -7
  97. package/internal/graph/type_ref_edges_resolve_named_types_across_files_test.go +2 -2
  98. package/internal/graph/value_access_edges_cover_properties_test.go +5 -5
  99. package/internal/graph/value_call_edges_attribute_function_assignments_to_members_test.go +3 -3
  100. package/internal/graph/value_call_edges_cover_jsx_components_test.go +2 -2
  101. package/internal/graph/value_call_edges_cover_methods_and_constructors_test.go +3 -3
  102. package/internal/graph/value_call_edges_cover_variable_bound_callables_test.go +2 -2
  103. package/internal/graph/value_call_edges_do_not_double_record_invoked_member_access_test.go +4 -4
  104. package/internal/graph/value_call_edges_record_construct_versus_call_origin_test.go +3 -3
  105. package/internal/graph/value_call_edges_resolve_across_files_and_dedupe_test.go +2 -2
  106. package/internal/graph/value_call_edges_skip_self_and_unresolved_test.go +4 -4
  107. package/internal/graph/value_reads_cover_expression_positions_test.go +6 -6
  108. package/lib/compiler/internal/buildNativeCompiler.d.ts +5 -2
  109. package/lib/compiler/internal/buildNativeCompiler.js +12 -4
  110. package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
  111. package/lib/flags/COMPILER_ENUM_WHITESPACE.js +1 -1
  112. package/lib/flags/COMPILER_ENUM_WHITESPACE.js.map +1 -1
  113. package/lib/flags/COMPILER_OPTIONS.js +1079 -149
  114. package/lib/flags/COMPILER_OPTIONS.js.map +1 -1
  115. package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js +1 -1
  116. package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js.map +1 -1
  117. package/lib/flags/COMPILER_OPTION_KINDS.js +1 -1
  118. package/lib/flags/COMPILER_OPTION_KINDS.js.map +1 -1
  119. package/lib/flags/CompilerOptionSpec.d.ts +9 -2
  120. package/lib/internal/pluginSource.d.ts +1 -0
  121. package/lib/internal/pluginSource.js +1 -0
  122. package/lib/internal/pluginSource.js.map +1 -1
  123. package/lib/launcher/internal/TypeScriptSyncApi.d.ts +140 -0
  124. package/lib/launcher/internal/TypeScriptSyncApi.js +99 -0
  125. package/lib/launcher/internal/TypeScriptSyncApi.js.map +1 -0
  126. package/lib/launcher/internal/buildSingleRootInMemory.d.ts +80 -0
  127. package/lib/launcher/internal/buildSingleRootInMemory.js +253 -0
  128. package/lib/launcher/internal/buildSingleRootInMemory.js.map +1 -0
  129. package/lib/launcher/internal/buildSingleRootProject.d.ts +22 -18
  130. package/lib/launcher/internal/buildSingleRootProject.js +27 -18
  131. package/lib/launcher/internal/buildSingleRootProject.js.map +1 -1
  132. package/lib/launcher/internal/compilerArgsAsConfigOptions.d.ts +39 -0
  133. package/lib/launcher/internal/compilerArgsAsConfigOptions.js +115 -0
  134. package/lib/launcher/internal/compilerArgsAsConfigOptions.js.map +1 -0
  135. package/lib/plugin/CapabilityPluginResolver.js +3 -0
  136. package/lib/plugin/CapabilityPluginResolver.js.map +1 -1
  137. package/lib/plugin/internal/load/loadProjectPlugins.js +6 -2
  138. package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
  139. package/lib/plugin/internal/source/CompilerTarget.d.ts +127 -0
  140. package/lib/plugin/internal/source/CompilerTarget.js +231 -0
  141. package/lib/plugin/internal/source/CompilerTarget.js.map +1 -0
  142. package/lib/plugin/internal/source/NativeSourcePackages.js +6 -5
  143. package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -1
  144. package/lib/plugin/internal/source/SourcePluginAdmission.d.ts +18 -1
  145. package/lib/plugin/internal/source/SourcePluginAdmission.js +24 -2
  146. package/lib/plugin/internal/source/SourcePluginAdmission.js.map +1 -1
  147. package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +6 -3
  148. package/lib/plugin/internal/source/SourcePluginWorkspace.js +31 -13
  149. package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -1
  150. package/lib/plugin/internal/source/buildSourcePlugin.js +3 -1
  151. package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -1
  152. package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +1 -1
  153. package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +9 -1
  154. package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -1
  155. package/package.json +14 -9
  156. package/shim/ast/enums_gen.go +1 -0
  157. package/shim/ast/go.mod +2 -2
  158. package/shim/ast/go.sum +4 -4
  159. package/shim/ast/neutral.go +141 -0
  160. package/shim/astnav/go.mod +2 -2
  161. package/shim/astnav/go.sum +4 -4
  162. package/shim/bundled/go.mod +2 -2
  163. package/shim/bundled/go.sum +4 -4
  164. package/shim/checker/go.mod +2 -2
  165. package/shim/checker/go.sum +4 -4
  166. package/shim/compiler/go.mod +2 -2
  167. package/shim/compiler/go.sum +4 -4
  168. package/shim/compiler/neutral.go +213 -0
  169. package/shim/core/go.mod +2 -2
  170. package/shim/core/go.sum +4 -4
  171. package/shim/diagnosticwriter/go.mod +2 -2
  172. package/shim/diagnosticwriter/go.sum +4 -4
  173. package/shim/lsp/go.mod +2 -2
  174. package/shim/lsp/go.sum +4 -4
  175. package/shim/parser/go.mod +2 -2
  176. package/shim/parser/go.sum +4 -4
  177. package/shim/printer/go.mod +2 -2
  178. package/shim/printer/go.sum +4 -4
  179. package/shim/scanner/go.mod +2 -2
  180. package/shim/scanner/go.sum +4 -4
  181. package/shim/stringutil/go.mod +1 -1
  182. package/shim/stringutil/go.sum +2 -2
  183. package/shim/stringutil/shim.go +15 -0
  184. package/shim/transformers/go.mod +2 -2
  185. package/shim/transformers/go.sum +4 -4
  186. package/shim/tsoptions/go.mod +2 -2
  187. package/shim/tsoptions/go.sum +4 -4
  188. package/shim/tsoptions/neutral.go +56 -0
  189. package/shim/tspath/go.mod +1 -1
  190. package/shim/tspath/go.sum +2 -2
  191. package/shim/tspath/neutral.go +150 -0
  192. package/shim/tspath/typed_paths.go +266 -0
  193. package/shim/vfs/cachedvfs/go.mod +2 -2
  194. package/shim/vfs/cachedvfs/go.sum +4 -4
  195. package/shim/vfs/go.mod +2 -2
  196. package/shim/vfs/go.sum +4 -4
  197. package/shim/vfs/neutral.go +20 -0
  198. package/shim/vfs/osvfs/go.mod +2 -2
  199. package/shim/vfs/osvfs/go.sum +4 -4
  200. package/src/compiler/internal/buildNativeCompiler.ts +13 -4
  201. package/src/flags/COMPILER_ENUM_WHITESPACE.ts +1 -1
  202. package/src/flags/COMPILER_OPTIONS.ts +1080 -150
  203. package/src/flags/COMPILER_OPTION_ASCII_FOLDS.ts +1 -1
  204. package/src/flags/COMPILER_OPTION_KINDS.ts +1 -1
  205. package/src/flags/CompilerOptionSpec.ts +11 -2
  206. package/src/internal/pluginSource.ts +1 -0
  207. package/src/launcher/internal/TypeScriptSyncApi.ts +186 -0
  208. package/src/launcher/internal/buildSingleRootInMemory.ts +319 -0
  209. package/src/launcher/internal/buildSingleRootProject.ts +26 -18
  210. package/src/launcher/internal/compilerArgsAsConfigOptions.ts +112 -0
  211. package/src/plugin/CapabilityPluginResolver.ts +4 -1
  212. package/src/plugin/internal/load/loadProjectPlugins.ts +12 -2
  213. package/src/plugin/internal/source/CompilerTarget.ts +249 -0
  214. package/src/plugin/internal/source/NativeSourcePackages.ts +10 -4
  215. package/src/plugin/internal/source/SourcePluginAdmission.ts +28 -2
  216. package/src/plugin/internal/source/SourcePluginWorkspace.ts +45 -19
  217. package/src/plugin/internal/source/buildSourcePlugin.ts +3 -1
  218. package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +9 -1
  219. package/targets/7.1/bridge/ast/enums_gen.go +174 -0
  220. package/targets/7.1/bridge/ast/extra-shim.json +4 -0
  221. package/targets/7.1/bridge/ast/go.mod +14 -0
  222. package/targets/7.1/bridge/ast/go.sum +20 -0
  223. package/targets/7.1/bridge/ast/lint.go +1412 -0
  224. package/targets/7.1/bridge/ast/neutral.go +141 -0
  225. package/targets/7.1/bridge/ast/parent.go +60 -0
  226. package/targets/7.1/bridge/ast/safe_text.go +108 -0
  227. package/targets/7.1/bridge/ast/shim.go +1656 -0
  228. package/targets/7.1/bridge/ast/surface.go +686 -0
  229. package/targets/7.1/bridge/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
  230. package/targets/7.1/bridge/ast/test/node_text_joins_multi_hop_qualified_name_test.go +47 -0
  231. package/targets/7.1/bridge/ast/test/node_text_joins_one_hop_qualified_name_test.go +35 -0
  232. package/targets/7.1/bridge/ast/test/node_text_returns_empty_for_nil_test.go +31 -0
  233. package/targets/7.1/bridge/ast/test/node_text_returns_identifier_text_test.go +34 -0
  234. package/targets/7.1/bridge/ast/test/node_text_skips_empty_qualified_left_test.go +60 -0
  235. package/targets/7.1/bridge/astnav/go.mod +14 -0
  236. package/targets/7.1/bridge/astnav/go.sum +22 -0
  237. package/targets/7.1/bridge/astnav/shim.go +24 -0
  238. package/targets/7.1/bridge/bundled/extra-shim.json +1 -0
  239. package/targets/7.1/bridge/bundled/go.mod +10 -0
  240. package/targets/7.1/bridge/bundled/go.sum +10 -0
  241. package/targets/7.1/bridge/bundled/shim.go +24 -0
  242. package/targets/7.1/bridge/checker/enums_gen.go +150 -0
  243. package/targets/7.1/bridge/checker/extra-shim.json +37 -0
  244. package/targets/7.1/bridge/checker/go.mod +15 -0
  245. package/targets/7.1/bridge/checker/go.sum +24 -0
  246. package/targets/7.1/bridge/checker/node_builder_fields_gen.go +19 -0
  247. package/targets/7.1/bridge/checker/shim.go +1390 -0
  248. package/targets/7.1/bridge/compiler/contentmapper_process.go +70 -0
  249. package/targets/7.1/bridge/compiler/emit_sourcemap.go +296 -0
  250. package/targets/7.1/bridge/compiler/emitassemble.go +81 -0
  251. package/targets/7.1/bridge/compiler/emithook.go +44 -0
  252. package/targets/7.1/bridge/compiler/extra-shim.json +4 -0
  253. package/targets/7.1/bridge/compiler/go.mod +15 -0
  254. package/targets/7.1/bridge/compiler/go.sum +24 -0
  255. package/targets/7.1/bridge/compiler/incremental.go +185 -0
  256. package/targets/7.1/bridge/compiler/neutral.go +256 -0
  257. package/targets/7.1/bridge/compiler/resolution.go +571 -0
  258. package/targets/7.1/bridge/compiler/shim.go +70 -0
  259. package/targets/7.1/bridge/core/enums_gen.go +15 -0
  260. package/targets/7.1/bridge/core/extra-shim.json +4 -0
  261. package/targets/7.1/bridge/core/go.mod +7 -0
  262. package/targets/7.1/bridge/core/go.sum +8 -0
  263. package/targets/7.1/bridge/core/modulekind.go +19 -0
  264. package/targets/7.1/bridge/core/shim.go +272 -0
  265. package/targets/7.1/bridge/diagnosticwriter/go.mod +14 -0
  266. package/targets/7.1/bridge/diagnosticwriter/go.sum +20 -0
  267. package/targets/7.1/bridge/diagnosticwriter/lint.go +411 -0
  268. package/targets/7.1/bridge/diagnosticwriter/shim.go +56 -0
  269. package/targets/7.1/bridge/lsp/extra-shim.json +4 -0
  270. package/targets/7.1/bridge/lsp/go.mod +16 -0
  271. package/targets/7.1/bridge/lsp/go.sum +26 -0
  272. package/targets/7.1/bridge/lsp/shim.go +112 -0
  273. package/targets/7.1/bridge/parser/extra-shim.json +4 -0
  274. package/targets/7.1/bridge/parser/go.mod +14 -0
  275. package/targets/7.1/bridge/parser/go.sum +24 -0
  276. package/targets/7.1/bridge/parser/shim.go +61 -0
  277. package/targets/7.1/bridge/printer/emithost.go +69 -0
  278. package/targets/7.1/bridge/printer/go.mod +15 -0
  279. package/targets/7.1/bridge/printer/go.sum +24 -0
  280. package/targets/7.1/bridge/printer/shim.go +168 -0
  281. package/targets/7.1/bridge/printer/sourcemap.go +49 -0
  282. package/targets/7.1/bridge/scanner/extra-shim.json +4 -0
  283. package/targets/7.1/bridge/scanner/go.mod +14 -0
  284. package/targets/7.1/bridge/scanner/go.sum +20 -0
  285. package/targets/7.1/bridge/scanner/regexp.go +42 -0
  286. package/targets/7.1/bridge/scanner/shim.go +137 -0
  287. package/targets/7.1/bridge/stringutil/extra-shim.json +1 -0
  288. package/targets/7.1/bridge/stringutil/go.mod +5 -0
  289. package/targets/7.1/bridge/stringutil/go.sum +2 -0
  290. package/targets/7.1/bridge/stringutil/shim.go +131 -0
  291. package/targets/7.1/bridge/transformers/go.mod +15 -0
  292. package/targets/7.1/bridge/transformers/go.sum +24 -0
  293. package/targets/7.1/bridge/transformers/shim.go +24 -0
  294. package/targets/7.1/bridge/tsoptions/command_line_raw.go +44 -0
  295. package/targets/7.1/bridge/tsoptions/extra-shim.json +4 -0
  296. package/targets/7.1/bridge/tsoptions/go.mod +15 -0
  297. package/targets/7.1/bridge/tsoptions/go.sum +24 -0
  298. package/targets/7.1/bridge/tsoptions/neutral.go +47 -0
  299. package/targets/7.1/bridge/tsoptions/shim.go +193 -0
  300. package/targets/7.1/bridge/tspath/extra-shim.json +4 -0
  301. package/targets/7.1/bridge/tspath/go.mod +5 -0
  302. package/targets/7.1/bridge/tspath/go.sum +6 -0
  303. package/targets/7.1/bridge/tspath/neutral.go +142 -0
  304. package/targets/7.1/bridge/tspath/shim.go +382 -0
  305. package/targets/7.1/bridge/vfs/cachedvfs/extra-shim.json +4 -0
  306. package/targets/7.1/bridge/vfs/cachedvfs/go.mod +5 -0
  307. package/targets/7.1/bridge/vfs/cachedvfs/go.sum +10 -0
  308. package/targets/7.1/bridge/vfs/cachedvfs/shim.go +12 -0
  309. package/targets/7.1/bridge/vfs/decode.go +26 -0
  310. package/targets/7.1/bridge/vfs/decode_test.go +42 -0
  311. package/targets/7.1/bridge/vfs/extra-shim.json +4 -0
  312. package/targets/7.1/bridge/vfs/go.mod +10 -0
  313. package/targets/7.1/bridge/vfs/go.sum +10 -0
  314. package/targets/7.1/bridge/vfs/neutral.go +23 -0
  315. package/targets/7.1/bridge/vfs/osvfs/extra-shim.json +4 -0
  316. package/targets/7.1/bridge/vfs/osvfs/go.mod +10 -0
  317. package/targets/7.1/bridge/vfs/osvfs/go.sum +10 -0
  318. package/targets/7.1/bridge/vfs/osvfs/shim.go +14 -0
  319. package/targets/7.1/bridge/vfs/shim.go +27 -0
  320. package/targets/7.1/facade/ast/facade_gen.go +2691 -0
  321. package/targets/7.1/facade/ast/go.mod +20 -0
  322. package/targets/7.1/facade/ast/go.sum +20 -0
  323. package/targets/7.1/facade/astnav/facade_gen.go +15 -0
  324. package/targets/7.1/facade/astnav/go.mod +22 -0
  325. package/targets/7.1/facade/astnav/go.sum +22 -0
  326. package/targets/7.1/facade/bundled/facade_gen.go +32 -0
  327. package/targets/7.1/facade/bundled/go.mod +21 -0
  328. package/targets/7.1/facade/bundled/go.sum +10 -0
  329. package/targets/7.1/facade/checker/facade_gen.go +563 -0
  330. package/targets/7.1/facade/checker/go.mod +26 -0
  331. package/targets/7.1/facade/checker/go.sum +24 -0
  332. package/targets/7.1/facade/compiler/facade_gen.go +198 -0
  333. package/targets/7.1/facade/compiler/go.mod +41 -0
  334. package/targets/7.1/facade/compiler/go.sum +24 -0
  335. package/targets/7.1/facade/core/facade_gen.go +130 -0
  336. package/targets/7.1/facade/core/go.mod +12 -0
  337. package/targets/7.1/facade/core/go.sum +8 -0
  338. package/targets/7.1/facade/diagnosticwriter/facade_gen.go +36 -0
  339. package/targets/7.1/facade/diagnosticwriter/go.mod +22 -0
  340. package/targets/7.1/facade/diagnosticwriter/go.sum +20 -0
  341. package/targets/7.1/facade/lsp/facade_gen.go +31 -0
  342. package/targets/7.1/facade/lsp/go.mod +19 -0
  343. package/targets/7.1/facade/lsp/go.sum +26 -0
  344. package/targets/7.1/facade/parser/facade_gen.go +102 -0
  345. package/targets/7.1/facade/parser/go.mod +25 -0
  346. package/targets/7.1/facade/parser/go.sum +24 -0
  347. package/targets/7.1/facade/printer/facade_gen.go +74 -0
  348. package/targets/7.1/facade/printer/go.mod +26 -0
  349. package/targets/7.1/facade/printer/go.sum +24 -0
  350. package/targets/7.1/facade/scanner/facade_gen.go +191 -0
  351. package/targets/7.1/facade/scanner/go.mod +25 -0
  352. package/targets/7.1/facade/scanner/go.sum +20 -0
  353. package/targets/7.1/facade/stringutil/facade_gen.go +176 -0
  354. package/targets/7.1/facade/stringutil/go.mod +9 -0
  355. package/targets/7.1/facade/stringutil/go.sum +2 -0
  356. package/targets/7.1/facade/transformers/facade_gen.go +12 -0
  357. package/targets/7.1/facade/transformers/go.mod +18 -0
  358. package/targets/7.1/facade/transformers/go.sum +24 -0
  359. package/targets/7.1/facade/tsoptions/facade_gen.go +274 -0
  360. package/targets/7.1/facade/tsoptions/go.mod +32 -0
  361. package/targets/7.1/facade/tsoptions/go.sum +24 -0
  362. package/targets/7.1/facade/tspath/facade_gen.go +550 -0
  363. package/targets/7.1/facade/tspath/go.mod +9 -0
  364. package/targets/7.1/facade/tspath/go.sum +6 -0
  365. package/targets/7.1/facade/vfs/cachedvfs/facade_gen.go +17 -0
  366. package/targets/7.1/facade/vfs/cachedvfs/go.mod +18 -0
  367. package/targets/7.1/facade/vfs/cachedvfs/go.sum +10 -0
  368. package/targets/7.1/facade/vfs/facade_gen.go +47 -0
  369. package/targets/7.1/facade/vfs/go.mod +18 -0
  370. package/targets/7.1/facade/vfs/go.sum +10 -0
  371. package/targets/7.1/facade/vfs/osvfs/facade_gen.go +20 -0
  372. package/targets/7.1/facade/vfs/osvfs/go.mod +21 -0
  373. package/targets/7.1/facade/vfs/osvfs/go.sum +10 -0
  374. package/tools/gen_facade/committed_facades_match_their_bridges_test.go +57 -0
  375. package/tools/gen_facade/facade_manifest_points_into_the_bridge_root_test.go +75 -0
  376. package/tools/gen_facade/facade_spells_internal_types_through_bridge_aliases_test.go +75 -0
  377. package/tools/gen_facade/facade_types_are_their_bridge_types_test.go +99 -0
  378. package/tools/gen_facade/go.mod +10 -0
  379. package/tools/gen_facade/go.sum +8 -0
  380. package/tools/gen_facade/main.go +734 -0
  381. package/tools/gen_shims/go.mod +4 -4
  382. package/tools/gen_shims/go.sum +6 -6
  383. package/tools/gen_shims/main.go +124 -66
  384. package/tools/gen_shims/mirror_structs_terminate_on_unexported_cycles_test.go +101 -0
  385. package/tools/shim_audit/baseline-7.1.json +720 -0
  386. package/tools/shim_audit/baseline.json +5 -4
  387. package/tools/shim_audit/go.mod +4 -4
  388. package/tools/shim_audit/go.sum +6 -6
  389. package/tools/shim_audit/linkname_signatures.go +178 -0
  390. package/tools/shim_audit/linkname_signatures_match_their_targets_test.go +64 -0
  391. package/tools/shim_audit/linkname_targets_follow_the_audited_compiler_test.go +38 -0
  392. package/tools/shim_audit/main.go +29 -4
  393. package/tools/shim_audit/neutral_api.go +160 -0
  394. package/tools/shim_audit/neutral_api_must_match_across_targets_test.go +74 -0
  395. package/utility/host.go +5 -4
  396. package/utility/preamble_output.go +15 -15
  397. package/utility/serve.go +1 -1
@@ -0,0 +1,185 @@
1
+ // gen_shims:hand-maintained
2
+ //
3
+ // Parts of tsgo's own incremental engine (`tsc --incremental` semantics),
4
+ // exposed from internal/execute/incremental for the two things a ttsc host
5
+ // needs from it:
6
+ //
7
+ // - the reference graph, so transform envelopes can carry the same
8
+ // language-semantic input bound the compiler itself uses for invalidation:
9
+ // per-file direct resolved references and the files that contribute to the
10
+ // global scope;
11
+ // - the build-information emit, so a host that constructs its Program
12
+ // in-process still writes the `.tsbuildinfo` an `incremental` or
13
+ // `composite` project asked for.
14
+ package compiler
15
+
16
+ import (
17
+ "context"
18
+ "time"
19
+ _ "unsafe"
20
+
21
+ innerast "github.com/microsoft/TypeScript/tsc/internal/ast"
22
+ "github.com/microsoft/TypeScript/tsc/internal/collections"
23
+ innercompiler "github.com/microsoft/TypeScript/tsc/internal/compiler"
24
+ innertsoptions "github.com/microsoft/TypeScript/tsc/internal/tsoptions"
25
+ "github.com/microsoft/TypeScript/tsc/internal/tspath"
26
+
27
+ // Imported for EmitFreshWithBuildInfo below, and for the linknamed symbols
28
+ // further down: compiling the package into every shim consumer is what makes
29
+ // those references resolve.
30
+ "github.com/microsoft/TypeScript/tsc/internal/execute/incremental"
31
+ )
32
+
33
+ // EmitFreshWithBuildInfo emits through a new upstream incremental wrapper
34
+ // around the supplied checked Program, with no previous wrapper/snapshot.
35
+ // Its build-information format and candidate location come from upstream
36
+ // snapshot serialization and outputpaths.GetBuildInfoFileName.
37
+ //
38
+ // This is the emit half of `tsc.go::performIncrementalCompilation`, which the
39
+ // tsgo CLI takes whenever `CompilerOptions.IsIncremental()`. A host that builds
40
+ // its Program in-process (ttsc's driver, and therefore every plugin sidecar
41
+ // emitting through it) never reaches that CLI path, so without this the build
42
+ // information is silently dropped even though the options parsed cleanly.
43
+ //
44
+ // "Fresh" in EmitFreshWithBuildInfo means no previous snapshot is supplied.
45
+ // When upstream incremental-state tracking is enabled, initial construction
46
+ // tracks loaded files and makes their applicable output pending rather than
47
+ // reusing prior emit signatures or diagnostics. TargetSourceFile still selects
48
+ // single-file emission; noEmit/noEmitOnError, cancellation, blocked output and
49
+ // write failure retain their upstream behavior. A whole-program eligible emit
50
+ // attempts pending build info, but a record is not guaranteed on every call.
51
+ // The supplied Program and context must be valid for this emit round. A plugin's
52
+ // output is not a pure function of the source text a build info records — it
53
+ // also depends on the plugin binary, its config file, and its contributors —
54
+ // so reusing a previous snapshot to skip a file would serve stale transformed
55
+ // output. Using a record to skip plugin effects requires a reuse identity that
56
+ // covers every relevant input and effect, not source text alone.
57
+ //
58
+ // @evidence contracts/common.md#principled-implementation A nil previous wrapper prevents reuse of old snapshot emit signatures/diagnostics and initializes applicable pending output under upstream emit controls; source-only prior state cannot establish plugin-effect equivalence.
59
+ // @evidence contracts/common.md#clear-and-simple-design One upstream incremental-program construction owns full emit and build-info output, avoiding a separate record serializer or a partially reused emit path.
60
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Fresh emission is grounded in absent plugin identity in the snapshot key, not a blanket retry masking stale output; no fake build-info or consumer-specific cache key is introduced.
61
+ // @evidence contracts/common.md#meaningful-documentation Native paragraphs explain the in-process build-info connection, fresh pending state, emit/cancellation/write limits and plugin-effect invalidation rather than unconditional output or incremental reuse.
62
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation This wrapper chooses snapshot reuse, while Program.Host and the upstream incremental emitter own native output-path and filesystem decisions.
63
+ // @evidence contracts/performance.md#efficient-algorithms The fresh wrapper reuses the checked Program but builds snapshot file hashes, references and semantic metadata; eligible output then incurs emission and additional build-info table traversal/JSON serialization. File, reference, source/output-byte and diagnostic populations drive this work. Delegating the actual engine avoids a separate record implementation, not those traversals; prior snapshot skipping is unsafe without plugin-equivalent inputs/effects.
64
+ // @evidence contracts/performance.md#reuse-equivalent-work The supplied checked Program is reused, while no previous incremental wrapper is admitted. Skipping effectful emission requires identity and invalidation covering all plugin/runtime/configuration/contributor dependencies and effects; quiet source text alone cannot authorize it.
65
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The invocation acquires an incremental snapshot with file/reference/pending/diagnostic state plus temporary emission and build-info serialization storage. It retains the supplied Program while upstream work runs; returned results and WriteFile callback data may retain output or semantic references afterward. This adapter keeps no historical snapshot registry or independent running-task owner, and caller/host/upstream own result, callback and Program lifetimes on success, error or cancellation.
66
+ func EmitFreshWithBuildInfo(ctx context.Context, program *Program, options EmitOptions) *EmitResult {
67
+ incrementalProgram := incremental.NewProgram(
68
+ program,
69
+ nil,
70
+ incremental.CreateHost(program.Host()),
71
+ time.Now,
72
+ false,
73
+ )
74
+ return incrementalProgram.Emit(ctx, options)
75
+ }
76
+
77
+ //go:linkname incrementalGetReferencedFiles github.com/microsoft/TypeScript/tsc/internal/execute/incremental.getReferencedFiles
78
+ func incrementalGetReferencedFiles(program *innercompiler.Program, file *innerast.SourceFile) *collections.Set[tspath.PathKey]
79
+
80
+ //go:linkname incrementalFileAffectsGlobalScope github.com/microsoft/TypeScript/tsc/internal/execute/incremental.fileAffectsGlobalScope
81
+ func incrementalFileAffectsGlobalScope(file *innerast.SourceFile) bool
82
+
83
+ // GetReferencedFilePaths adapts the upstream incremental reference set:
84
+ // import/re-export and string module-augmentation symbols' declaration files,
85
+ // path directives, resolved type directives and ambient-module declarations.
86
+ // It is not a transitive symbol-reachability closure or proof that every path
87
+ // is a loaded source. Extensionless path-directive adaptation below can also
88
+ // differ from the raw upstream build-info entry.
89
+ //
90
+ // The returned keys are tspath.PathKey values (case-canonicalized on
91
+ // case-insensitive filesystems); map them back to real file names through
92
+ // Program.GetSourceFileByPath when the original spelling matters.
93
+ // Extensionless path references are replaced with the source file Program
94
+ // actually loaded because the upstream incremental helper retains their raw
95
+ // directive path instead of the selected extension-bearing path.
96
+ // Program and file must be nonnil and belong to the same loaded program.
97
+ // Returned order follows the compiler's reference set; it is not sorted.
98
+ //
99
+ // @evidence contracts/common.md#principled-implementation Upstream's semantic reference set is combined with the same program's resolved path directives, replacing extensionless raw paths with loaded source identities and deduplicating canonical paths; project-reference redirects use the program's actual declaration-to-source mapping.
100
+ // @evidence contracts/common.md#clear-and-simple-design The exported function owns reference-set adaptation while a private helper resolves resident and virtual declaration sources through one program context.
101
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The extra project-reference lookup addresses supported unbuilt declaration outputs using compiler redirects and supported extensions, rather than guessing filenames or special-casing projects.
102
+ // @evidence contracts/common.md#meaningful-documentation Native paragraphs identify reference categories, canonical spelling, extension replacement, same-program premises and unsorted output with descriptive text separate from tags.
103
+ // @evidence contracts/portability.md#os-neutral-implementation Path identity uses the Program's own path keys and compiler path helpers, while project-reference redirects recover the loaded filename rather than inferring native case behavior from the OS.
104
+ // @evidence contracts/performance.md#efficient-algorithms Adaptation uses expected linear map/set processing in upstream reference count plus path-directive count, with path-text hashing/canonicalization and a bounded supported-extension search per unresolved directive. Before that, upstream obtains a checker and visits import/augmentation symbols, their declarations and ambient modules; semantic lookup, declaration parent walks and host/project-reference queries are additional delegated work, not bounded by the returned path count alone.
105
+ // @evidence contracts/performance.md#reuse-equivalent-work Loaded Program resolutions, sources and checker state are reused, while the reference set and adaptation maps are rebuilt per invocation. Upstream checker queries may populate semantic caches; this adapter coordinates no cross-Program cache or separate resolver producer.
106
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Upstream acquires a file checker with a deferred release callback and may retain semantic state under its Program/checker owner. Reference, replacement and deduplication sets are invocation-local; returned slice/string ownership transfers to the caller and may share existing path backing storage. The bridge keeps no historical result registry.
107
+ func GetReferencedFilePaths(program *Program, file *innerast.SourceFile) []tspath.PathKey {
108
+ set := incrementalGetReferencedFiles(program, file)
109
+ if set == nil {
110
+ return nil
111
+ }
112
+ resolvedPathReferences := make(map[tspath.PathKey]tspath.PathKey, len(file.ReferencedFiles))
113
+ sourceDirectory := file.FileName().Directory()
114
+ for _, reference := range file.ReferencedFiles {
115
+ referencedFile := tspath.ToRootedFilePath(reference.FileName, sourceDirectory)
116
+ if redirect := program.GetParseFileRedirect(referencedFile); redirect != "" {
117
+ referencedFile = redirect
118
+ }
119
+ rawPath := program.PathKeyForFileName(referencedFile)
120
+ if resolved := getSourceFileFromReference(program, file, reference); resolved != nil {
121
+ resolvedPathReferences[rawPath] = resolved.PathKey()
122
+ }
123
+ }
124
+ out := make([]tspath.PathKey, 0, set.Len())
125
+ seen := collections.Set[tspath.PathKey]{}
126
+ for path := range set.Keys() {
127
+ if resolved := resolvedPathReferences[path]; resolved != "" {
128
+ path = resolved
129
+ }
130
+ if seen.Has(path) {
131
+ continue
132
+ }
133
+ seen.Add(path)
134
+ out = append(out, path)
135
+ }
136
+ return out
137
+ }
138
+
139
+ // getSourceFileFromReference extends TypeScript-Go's resident-file lookup with
140
+ // the virtual declaration outputs its project-reference filesystem accepts.
141
+ // The upstream helper cannot see an unbuilt output in Program.filesByPath, but
142
+ // the project-reference mapper retains the output-to-source redirect that made
143
+ // the reference valid while the Program was loaded.
144
+ func getSourceFileFromReference(program *Program, file *innerast.SourceFile, reference *innerast.FileReference) *innerast.SourceFile {
145
+ if resolved := program.GetSourceFileFromReference(file, reference); resolved != nil {
146
+ return resolved
147
+ }
148
+ referencedFile := tspath.ToRootedFilePath(reference.FileName, file.FileName().Directory())
149
+ if referencedFile.HasExtension() {
150
+ return nil
151
+ }
152
+ supportedExtensions := innertsoptions.GetSupportedExtensions(program.Options(), nil)
153
+ supportedExtensions = innertsoptions.GetSupportedExtensionsWithJsonIfResolveJsonModule(program.Options(), supportedExtensions)
154
+ for _, extension := range supportedExtensions[0] {
155
+ outputPath := program.PathKeyForFileName(referencedFile.AppendSuffix(extension))
156
+ redirect := program.GetProjectReferenceFromOutputDts(outputPath)
157
+ if redirect == nil {
158
+ continue
159
+ }
160
+ if source := program.GetSourceFile(redirect.Source); source != nil {
161
+ return source
162
+ }
163
+ }
164
+ return nil
165
+ }
166
+
167
+ // FileAffectsGlobalScope reports the upstream incremental engine's global
168
+ // impact classification, first ensuring the source file is bound. A global
169
+ // augmentation is true; otherwise external/CommonJS modules and JSON are false.
170
+ // A remaining script is true only when it has a statement other than a
171
+ // string-literal-named module declaration. Empty or ambient-external-only
172
+ // scripts are not automatically global-impact files.
173
+ // file must be a nonnil compiler source file.
174
+ //
175
+ // @evidence contracts/common.md#principled-implementation The wrapper delegates the pinned incremental engine's global-scope predicate, preserving the same distinction used for program-wide semantic invalidation.
176
+ // @evidence contracts/common.md#clear-and-simple-design One predicate exposes compiler-owned classification without an independent global-scope analysis.
177
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No path, project name or expected invalidation result is special-cased; the foreign predicate remains unchanged.
178
+ // @evidence contracts/common.md#meaningful-documentation Native prose states binding, augmentation/module/JSON/script distinctions, empty/ambient-only limits and the nonnil source-file premise without certifying every edit's runtime invalidation result.
179
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Global-scope syntax classification has no native filesystem or process boundary.
180
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Upstream binding and global-impact classification own their algorithms: an unbound file can incur AST binding, then augmentation/statement scans short-circuit according to the classification. This direct bridge chooses no independent traversal or impact analysis.
181
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Upstream IsBound/BindOnce and its binder pool own binding reuse; this bridge coordinates no separate impact-result cache or cross-generation producer/invalidation policy.
182
+ // @evidence contracts/performance.md#bound-retention-and-release-resources Binding can acquire a pooled binder and populate source-owned symbols, flow and classification state; its defer returns and resets the binder while that bound AST state survives under the file owner. The bridge returns only a boolean and keeps no independent state registry or handle, but does not equate that with absence of delegated retention.
183
+ func FileAffectsGlobalScope(file *innerast.SourceFile) bool {
184
+ return incrementalFileAffectsGlobalScope(file)
185
+ }
@@ -0,0 +1,256 @@
1
+ package compiler
2
+
3
+ import (
4
+ "context"
5
+ "errors"
6
+ "sync"
7
+
8
+ innerast "github.com/microsoft/TypeScript/tsc/internal/ast"
9
+ innercompiler "github.com/microsoft/TypeScript/tsc/internal/compiler"
10
+ "github.com/microsoft/TypeScript/tsc/internal/contentmapper"
11
+ innercore "github.com/microsoft/TypeScript/tsc/internal/core"
12
+ innerlocale "github.com/microsoft/TypeScript/tsc/internal/locale"
13
+ inneroutputpaths "github.com/microsoft/TypeScript/tsc/internal/outputpaths"
14
+ innertsoptions "github.com/microsoft/TypeScript/tsc/internal/tsoptions"
15
+ innertspath "github.com/microsoft/TypeScript/tsc/internal/tspath"
16
+ innervfs "github.com/microsoft/TypeScript/tsc/internal/vfs"
17
+ )
18
+
19
+ // Version-neutral compiler operations.
20
+ //
21
+ // The TypeScript 7.0 and 7.1 compilers construct hosts, update Programs and
22
+ // report path identity through different signatures. Code that must compile on
23
+ // both compiler targets calls these functions, which the 7.0 shim declares
24
+ // with identical signatures. Here each makes the 7.1 call.
25
+
26
+ // NewHost returns a compiler host over fs that finds the bundled library files
27
+ // at defaultLibraryPath. TypeScript 7.0 hosts carry currentDirectory as the
28
+ // Program's working directory; TypeScript 7.1 takes it from the parsed config,
29
+ // so here it is unused.
30
+ //
31
+ // @evidence contracts/common.md#principled-implementation Calls NewCompilerHost with the filesystem and library path and no config cache, trace or content-mapper project; 7.1 hosts carry no working directory.
32
+ // @evidence contracts/common.md#clear-and-simple-design One constructor call keeps the target difference inside the shim.
33
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No host behavior is reimplemented here.
34
+ // @evidence contracts/common.md#meaningful-documentation Native prose states each target's use of currentDirectory.
35
+ // @evidence contracts/portability.md#os-neutral-implementation The supplied FS owns every native operation the host later makes; construction performs none.
36
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Construction assigns fields and chooses no algorithm.
37
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Each call returns a fresh host; callers share one by holding it.
38
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The host retains fs and the library path for the caller's lifetime and owns no handle.
39
+ func NewHost(currentDirectory innertspath.RootedDirectoryPath, fs innervfs.FS, defaultLibraryPath innertspath.RootedDirectoryPath) innercompiler.CompilerHost {
40
+ return innercompiler.NewCompilerHost(fs, defaultLibraryPath, nil, nil, nil)
41
+ }
42
+
43
+ // ProjectHosts builds the compiler hosts of the Programs one parsed project
44
+ // produces and owns what those hosts share. On TypeScript 7.1 that is the
45
+ // project's content mappers: when the config declares `contentMappers` and the
46
+ // command line passed `--runExternalCode`, every host transforms content-mapped
47
+ // files through one mapper project, and Close stops the mapper processes. A nil
48
+ // ProjectHosts builds plain hosts. TypeScript 7.0 has no content mappers.
49
+ //
50
+ // @evidence contracts/common.md#principled-implementation Mirrors tsc's own setup: a content-mapper host and its ProjectSpec project exist only under runExternalCode with configured mappers, and the project is handed to every compiler host.
51
+ // @evidence contracts/common.md#clear-and-simple-design One value pairs host construction with the release of the mapper state the hosts share, so incremental hosts keep the project the first host used.
52
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The compiler's own runExternalCode gate and mapper resolution decide whether mappers run; no ttsc authorization or mapping policy is added.
53
+ // @evidence contracts/common.md#meaningful-documentation Native prose states when mappers run, the nil meaning and the 7.0 difference.
54
+ // @evidence contracts/portability.md#os-neutral-implementation Mapper processes start through spawnContentMapper's os/exec boundary in each mapper package's directory; the supplied FS owns every file read.
55
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The type stores two handles and chooses no algorithm.
56
+ // @evidence contracts/performance.md#reuse-equivalent-work Every host built from one ProjectHosts shares one mapper project, so an incremental generation reuses the processes the first generation started.
57
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The mapper project and host, and with them every spawned mapper process, live until Close; Close releases them once.
58
+ type ProjectHosts struct {
59
+ mappers contentmapper.Host
60
+ project contentmapper.Project
61
+ closeOnce sync.Once
62
+ closeErr error
63
+ }
64
+
65
+ // NewProjectHosts returns the hosts of Programs built from config. It starts
66
+ // no process: mapper processes start when a host first reads a mapped file.
67
+ //
68
+ // @evidence contracts/common.md#principled-implementation Opens the content-mapper host and project exactly as tsc's NewContentMapperHost and getContentMapperProject do, from the config's resolved mappers and effective options.
69
+ // @evidence contracts/common.md#clear-and-simple-design One gate returns either a nil value or a value holding the mapper project.
70
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Mapper resolution and its diagnostics stay with the config parser; this function adds none.
71
+ // @evidence contracts/common.md#meaningful-documentation Native prose states that construction starts no process.
72
+ // @evidence contracts/portability.md#os-neutral-implementation Construction performs no native operation; mapper processes start later through spawnContentMapper.
73
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Construction checks one option and one slice length.
74
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Each call opens its own mapper state; callers share it by holding the value.
75
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The returned value owns the mapper host and project until Close.
76
+ func NewProjectHosts(config *innertsoptions.ParsedCommandLine) *ProjectHosts {
77
+ if config == nil || !config.CompilerOptions().RunExternalCode.IsTrue() || len(config.ContentMappers()) == 0 {
78
+ return nil
79
+ }
80
+ diagnosticLocale, _ := innerlocale.Parse(config.CompilerOptions().Locale)
81
+ mappers := contentmapper.NewHost(context.Background(), contentmapper.SpawnerFunc(spawnContentMapper), diagnosticLocale)
82
+ return &ProjectHosts{
83
+ mappers: mappers,
84
+ project: mappers.Project(contentmapper.ProjectSpec{
85
+ ConfigFileName: config.ConfigName(),
86
+ Mappers: config.ContentMappers(),
87
+ CompilerOptions: config.CompilerOptions(),
88
+ }),
89
+ }
90
+ }
91
+
92
+ // Host returns a compiler host over fs, like NewHost, that transforms
93
+ // content-mapped files through this project's mappers.
94
+ //
95
+ // @evidence contracts/common.md#principled-implementation Calls NewCompilerHost with the shared mapper project, the argument tsc passes for the same project.
96
+ // @evidence contracts/common.md#clear-and-simple-design A nil receiver reduces to NewHost, so callers need no separate plain-host branch.
97
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Content-mapped file loading stays the compiler host's.
98
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the relation to NewHost.
99
+ // @evidence contracts/portability.md#os-neutral-implementation The supplied FS owns every native read the host makes.
100
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Construction assigns fields.
101
+ // @evidence contracts/performance.md#reuse-equivalent-work Every returned host shares one mapper project.
102
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The host borrows the project; Close on the ProjectHosts releases it.
103
+ func (h *ProjectHosts) Host(currentDirectory innertspath.RootedDirectoryPath, fs innervfs.FS, defaultLibraryPath innertspath.RootedDirectoryPath) innercompiler.CompilerHost {
104
+ if h == nil {
105
+ return NewHost(currentDirectory, fs, defaultLibraryPath)
106
+ }
107
+ return innercompiler.NewCompilerHost(fs, defaultLibraryPath, nil, nil, h.project)
108
+ }
109
+
110
+ // Close closes the mapper project and stops every mapper process. Later calls
111
+ // return the first result.
112
+ //
113
+ // @evidence contracts/common.md#principled-implementation Closes the project before its host, the order tsc releases them in.
114
+ // @evidence contracts/common.md#clear-and-simple-design sync.Once makes release idempotent for every owner that closes it.
115
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Both close errors are returned rather than dropped.
116
+ // @evidence contracts/common.md#meaningful-documentation Native prose states repeated-call behavior.
117
+ // @evidence contracts/portability.md#os-neutral-implementation Stopping a mapper closes its pipes and kills its process through os/exec.
118
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Release closes two handles.
119
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work Release coordinates no shared computation.
120
+ // @evidence contracts/performance.md#bound-retention-and-release-resources After Close no mapper process of this project remains; hosts built from it can no longer transform mapped files.
121
+ func (h *ProjectHosts) Close() error {
122
+ if h == nil {
123
+ return nil
124
+ }
125
+ h.closeOnce.Do(func() {
126
+ h.closeErr = errors.Join(h.project.Close(), h.mappers.Close())
127
+ })
128
+ return h.closeErr
129
+ }
130
+
131
+ // UpdateProgram returns a Program in which only the file keyed by changed was
132
+ // edited, the changed file as host parsed it, and whether the old Program's
133
+ // data was reused. A nil Program means the update could not be made.
134
+ //
135
+ // @evidence contracts/common.md#principled-implementation Calls Program.UpdateProgram with the Program's own checker pool and module resolver.
136
+ // @evidence contracts/common.md#clear-and-simple-design One method call keeps the target difference inside the shim.
137
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Reuse decisions remain the compiler's.
138
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the three results and the nil meaning.
139
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation The host owns any filesystem read; this call adds none.
140
+ // @evidence contracts/performance.md#efficient-algorithms The compiler reparses only the changed file and reuses the rest when it can.
141
+ // @evidence contracts/performance.md#reuse-equivalent-work The compiler decides reuse of the old Program's files and data.
142
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The new Program may share data with the old one; the caller owns releasing the old Program's checkers.
143
+ func UpdateProgram(program *innercompiler.Program, changed innertspath.PathKey, host innercompiler.CompilerHost) (*innercompiler.Program, *innerast.SourceFile, bool) {
144
+ return program.UpdateProgram(changed, host, nil, nil)
145
+ }
146
+
147
+ // ProgramCaseSensitivity reports the case policy the Program compares file
148
+ // names with.
149
+ //
150
+ // @evidence contracts/common.md#principled-implementation Returns Program.CaseSensitivity.
151
+ // @evidence contracts/common.md#clear-and-simple-design One method call keeps the target difference inside the shim.
152
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The policy is the Program's own, not probed again.
153
+ // @evidence contracts/common.md#meaningful-documentation Native prose names what the policy governs.
154
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation The Program answers from its stored policy without a native call.
155
+ // @evidenceExclude contracts/performance.md#efficient-algorithms A stored value is returned.
156
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The function coordinates no shared work.
157
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The function retains nothing.
158
+ func ProgramCaseSensitivity(program *innercompiler.Program) innertspath.CaseSensitivity {
159
+ return program.CaseSensitivity()
160
+ }
161
+
162
+ // ProgramPathKey returns the key the Program files fileName under, which is
163
+ // the canonical form of its absolute path.
164
+ //
165
+ // @evidence contracts/common.md#principled-implementation Returns Program.PathKeyForFileName, the key the Program indexes its files by.
166
+ // @evidence contracts/common.md#clear-and-simple-design One method call keeps the target difference inside the shim.
167
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts No path canonicalization is reimplemented here.
168
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the canonical-key meaning.
169
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Key derivation manipulates path text only.
170
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The compiler owns the canonicalization.
171
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The function coordinates no shared work.
172
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The function retains nothing beyond the returned key.
173
+ func ProgramPathKey(program *innercompiler.Program, fileName innertspath.RootedFilePath) innertspath.PathKey {
174
+ return program.PathKeyForFileName(fileName)
175
+ }
176
+
177
+ // SourceFilesToEmit returns the program files a whole-program emit writes.
178
+ //
179
+ // @evidence contracts/common.md#principled-implementation Calls 7.1's GetSourceFilesToEmit with no target files and no forced declaration or JavaScript emit, the emitter's whole-program file set.
180
+ // @evidence contracts/common.md#clear-and-simple-design One call per target keeps compiler signature differences out of every emit caller.
181
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts File selection remains the compiler's.
182
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the whole-program scope.
183
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Selection reads Program state and performs no native operation.
184
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The compiler owns the file scan.
185
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The function coordinates no shared work.
186
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned slice is caller-owned.
187
+ func SourceFilesToEmit(host innercompiler.SourceFileMayBeEmittedHost) []*innerast.SourceFile {
188
+ return GetSourceFilesToEmit(host, nil, false, false)
189
+ }
190
+
191
+ // OutputPathsFor returns the emitter's output paths for one source file
192
+ // without forcing declaration paths.
193
+ //
194
+ // @evidence contracts/common.md#principled-implementation Calls 7.1's GetOutputPathsFor with an empty ForceEmitPaths, the paths the emitter writes.
195
+ // @evidence contracts/common.md#clear-and-simple-design One call per target keeps compiler signature differences out of every emit caller.
196
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Path derivation remains the compiler's.
197
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the unforced mode.
198
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Path derivation manipulates path text only.
199
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The compiler owns the derivation.
200
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The function coordinates no shared work.
201
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned paths are caller-owned.
202
+ func OutputPathsFor(source *innerast.SourceFile, options *innercore.CompilerOptions, host inneroutputpaths.OutputPathsHost) *inneroutputpaths.OutputPaths {
203
+ return GetOutputPathsFor(source, options, host, ForceEmitPaths{})
204
+ }
205
+
206
+ // TargetedEmitOptions returns EmitOptions that emit target alone through
207
+ // writeFile, or the whole program when target is nil.
208
+ //
209
+ // @evidence contracts/common.md#principled-implementation Sets 7.1's TargetSourceFiles list to the single target, or leaves it nil for a whole-program emit.
210
+ // @evidence contracts/common.md#clear-and-simple-design One constructor per target keeps EmitOptions field differences out of every emit caller.
211
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts Emit scope remains the compiler's interpretation of the field.
212
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the nil meaning.
213
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Construction performs no native operation.
214
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Construction assigns two fields.
215
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The function coordinates no shared work.
216
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The returned value is caller-owned.
217
+ func TargetedEmitOptions(target *innerast.SourceFile, writeFile innercompiler.WriteFile) innercompiler.EmitOptions {
218
+ var targets []*innerast.SourceFile
219
+ if target != nil {
220
+ targets = []*innerast.SourceFile{target}
221
+ }
222
+ return innercompiler.EmitOptions{TargetSourceFiles: targets, WriteFile: writeFile}
223
+ }
224
+
225
+ // EmitsWholeProgram reports whether options name no target file.
226
+ //
227
+ // @evidence contracts/common.md#principled-implementation Reads 7.1's TargetSourceFiles list.
228
+ // @evidence contracts/common.md#clear-and-simple-design One predicate per target keeps EmitOptions field differences out of every emit caller.
229
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The predicate reads the field the compiler reads.
230
+ // @evidence contracts/common.md#meaningful-documentation Native prose states the predicate.
231
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation The predicate performs no native operation.
232
+ // @evidenceExclude contracts/performance.md#efficient-algorithms The predicate reads one field.
233
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The function coordinates no shared work.
234
+ // @evidenceExclude contracts/performance.md#bound-retention-and-release-resources The function retains nothing.
235
+ func EmitsWholeProgram(options innercompiler.EmitOptions) bool {
236
+ return options.TargetSourceFiles == nil
237
+ }
238
+
239
+ // NewProgramOptions returns the options of a Program over config built through
240
+ // host. useSourceOfProjectReference reads a referenced project's sources rather
241
+ // than its declaration outputs. Every other option keeps the compiler default.
242
+ //
243
+ // @evidence contracts/common.md#principled-implementation Fills 7.1's ProgramConfig and ProgramHosts groups.
244
+ // @evidence contracts/common.md#clear-and-simple-design One constructor per target keeps ProgramOptions' layout difference out of every Program caller.
245
+ // @evidence contracts/common.md#prohibited-implementation-shortcuts The returned options leave every other field at the compiler's default.
246
+ // @evidence contracts/common.md#meaningful-documentation Native prose names the three fields set and the defaults.
247
+ // @evidenceExclude contracts/portability.md#os-neutral-implementation Construction performs no native operation.
248
+ // @evidenceExclude contracts/performance.md#efficient-algorithms Construction assigns three fields.
249
+ // @evidenceExclude contracts/performance.md#reuse-equivalent-work The function coordinates no shared work.
250
+ // @evidence contracts/performance.md#bound-retention-and-release-resources The returned options reference the caller's config and host without copying them.
251
+ func NewProgramOptions(config *innertsoptions.ParsedCommandLine, host innercompiler.CompilerHost, useSourceOfProjectReference bool) innercompiler.ProgramOptions {
252
+ return innercompiler.ProgramOptions{
253
+ ProgramConfig: innercompiler.ProgramConfig{Config: config, UseSourceOfProjectReference: useSourceOfProjectReference},
254
+ ProgramHosts: innercompiler.ProgramHosts{Host: host},
255
+ }
256
+ }