ttsc 0.30.4 → 0.31.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 (2081) hide show
  1. package/cmd/graphbench/main.go +2 -3
  2. package/cmd/graphdump/main.go +42 -16
  3. package/cmd/graphdump/run_declares_the_capability_its_output_carries_test.go +32 -18
  4. package/cmd/graphdump/run_reports_an_unknown_flag_without_exiting_the_process_test.go +10 -9
  5. package/cmd/graphdump/run_reports_an_unloadable_project_without_printing_a_dump_test.go +8 -7
  6. package/cmd/platform/command_operation_families_test.go +192 -0
  7. package/cmd/platform/main.go +11 -1
  8. package/cmd/ttsc/api_compile.go +166 -46
  9. package/cmd/ttsc/api_compile_branches_test.go +97 -10
  10. package/cmd/ttsc/api_transform.go +134 -46
  11. package/cmd/ttsc/api_transform_branches_test.go +10 -7
  12. package/cmd/ttsc/build.go +177 -68
  13. package/cmd/ttsc/build_branches_test.go +35 -7
  14. package/cmd/ttsc/cli_command_operation_families_test.go +1287 -0
  15. package/cmd/ttsc/cli_contract_helpers_test.go +82 -0
  16. package/cmd/ttsc/compiler_argument_cwd_test.go +57 -0
  17. package/cmd/ttsc/filter.go +31 -14
  18. package/cmd/ttsc/filter_resolves_flag_names_case_insensitively_test.go +10 -13
  19. package/cmd/ttsc/filter_strips_unknown_forwarded_flag_test.go +10 -16
  20. package/cmd/ttsc/flags_gen.go +2 -2
  21. package/cmd/ttsc/helpers_test.go +67 -10
  22. package/cmd/ttsc/main.go +122 -21
  23. package/cmd/ttsc/main_alias_branches_test.go +35 -9
  24. package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/ambient.d.ts +1 -0
  25. package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/main.ts +2 -0
  26. package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/mytype.ts +1 -0
  27. package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/tsconfig.base.json +3 -0
  28. package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/tsconfig.json +5 -0
  29. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/index.ts +1 -0
  30. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/decorated/main.ts +10 -0
  31. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/decorated/types.ts +3 -0
  32. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/helpers.ts +1 -0
  33. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/isolated.ts +1 -0
  34. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/main.ts +7 -0
  35. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/nested/model.ts +1 -0
  36. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/tsconfig.json +14 -0
  37. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPITransformUsesCurrentDirectory/index.ts +1 -0
  38. package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPITransformUsesCurrentDirectory/tsconfig.json +7 -0
  39. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildAllowsUnusedTypeParametersOnOverloadSignatures/index.ts +4 -0
  40. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildAllowsUnusedTypeParametersOnOverloadSignatures/tsconfig.json +11 -0
  41. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSemanticDiagnostics/index.ts +2 -0
  42. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSemanticDiagnostics/tsconfig.json +9 -0
  43. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSyntacticDiagnostics/index.ts +2 -0
  44. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSyntacticDiagnostics/tsconfig.json +8 -0
  45. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksUnusedParameters/index.ts +3 -0
  46. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksUnusedParameters/tsconfig.json +10 -0
  47. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildEmitErrorRejectsManifest/index.ts +1 -0
  48. package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildEmitErrorRejectsManifest/tsconfig.json +1 -0
  49. package/cmd/ttsc/testdata/cli_operation_families/TestCLIReportsDiagnosticsWithoutEmit/index.ts +1 -0
  50. package/cmd/ttsc/testdata/cli_operation_families/TestCLIReportsDiagnosticsWithoutEmit/tsconfig.json +8 -0
  51. package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/emit.json +8 -0
  52. package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/flag-shaped.json +7 -0
  53. package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/index.ts +2 -0
  54. package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/nested/tsconfig.app.json +11 -0
  55. package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/outside.json +8 -0
  56. package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/tsconfig.json +8 -0
  57. package/cmd/ttscgraph/auxiliary_identity_state_tracks_retargets_not_source_contents_test.go +26 -15
  58. package/cmd/ttscgraph/disk_realpath_other.go +2 -0
  59. package/cmd/ttscgraph/dump.go +46 -29
  60. package/cmd/ttscgraph/prepared_projection.go +61 -0
  61. package/cmd/ttscgraph/projection_fixture_test.go +96 -0
  62. package/cmd/ttscgraph/run_dump_claims_artifacts_only_when_it_asked_test.go +30 -5
  63. package/cmd/ttscgraph/run_dump_declares_the_capability_its_output_carries_test.go +6 -1
  64. package/cmd/ttscgraph/run_dump_emits_only_checker_verified_member_relations_test.go +12 -5
  65. package/cmd/ttscgraph/run_dump_prints_the_graph_as_json_test.go +17 -12
  66. package/cmd/ttscgraph/run_help_version_and_bad_flags_exit_codes_test.go +8 -3
  67. package/cmd/ttscgraph/serve.go +116 -79
  68. package/cmd/ttscgraph/serve_adopts_a_republished_artifact_set_test.go +16 -167
  69. package/cmd/ttscgraph/serve_adopts_a_republished_set_over_the_shard_protocol_test.go +122 -0
  70. package/cmd/ttscgraph/serve_answers_a_project_that_implements_its_own_ambient_declaration_test.go +35 -7
  71. package/cmd/ttscgraph/serve_early_error_encode_failure_is_observable_test.go +5 -0
  72. package/cmd/ttscgraph/serve_error_response_still_names_its_mode_test.go +10 -5
  73. package/cmd/ttscgraph/serve_git_ignore_projection_test.go +150 -0
  74. package/cmd/ttscgraph/serve_keeps_a_startup_set_a_client_never_mentions_test.go +69 -0
  75. package/cmd/ttscgraph/serve_object_members_refresh_without_identity_collisions_test.go +82 -0
  76. package/cmd/ttscgraph/serve_phase_trace_accounts_for_load_failure_test.go +9 -3
  77. package/cmd/ttscgraph/serve_phase_trace_is_opt_in_and_payload_free_test.go +12 -6
  78. package/cmd/ttscgraph/serve_projects_an_artifact_no_source_owns_test.go +13 -16
  79. package/cmd/ttscgraph/serve_protocol_fails_the_stream_on_an_unaddressable_request_line_test.go +10 -9
  80. package/cmd/ttscgraph/serve_protocol_negotiates_incremental_shards_test.go +37 -2
  81. package/cmd/ttscgraph/serve_protocol_retries_session_creation_test.go +7 -2
  82. package/cmd/ttscgraph/serve_protocol_reuses_session_test.go +13 -3
  83. package/cmd/ttscgraph/serve_session_applies_source_edit_incrementally_test.go +12 -7
  84. package/cmd/ttscgraph/serve_session_fails_closed_on_deleted_config_test.go +12 -7
  85. package/cmd/ttscgraph/serve_session_fails_closed_on_invalid_config_test.go +8 -3
  86. package/cmd/ttscgraph/serve_session_keeps_base_url_fallback_unchanged_test.go +7 -2
  87. package/cmd/ttscgraph/serve_session_keeps_change_detection_live_after_initial_dump_error_test.go +66 -0
  88. package/cmd/ttscgraph/serve_session_keeps_esm_directory_candidate_unchanged_test.go +12 -3
  89. package/cmd/ttscgraph/serve_session_keeps_exports_blocked_file_candidates_unchanged_test.go +8 -3
  90. package/cmd/ttscgraph/serve_session_keeps_inactive_conditional_export_unchanged_test.go +12 -3
  91. package/cmd/ttscgraph/serve_session_keeps_lower_priority_module_candidate_unchanged_test.go +14 -8
  92. package/cmd/ttscgraph/serve_session_keeps_lower_priority_paths_pattern_unchanged_test.go +12 -3
  93. package/cmd/ttscgraph/serve_session_keeps_missing_literal_root_unchanged_test.go +7 -2
  94. package/cmd/ttscgraph/serve_session_keeps_nonlongest_root_dirs_candidate_unchanged_test.go +12 -3
  95. package/cmd/ttscgraph/serve_session_rebuilds_import_graph_change_test.go +17 -8
  96. package/cmd/ttscgraph/serve_session_reloads_commonjs_package_entry_for_esm_test.go +11 -2
  97. package/cmd/ttscgraph/serve_session_reloads_created_literal_root_test.go +7 -2
  98. package/cmd/ttscgraph/serve_session_reloads_extended_config_change_test.go +9 -4
  99. package/cmd/ttscgraph/serve_session_reloads_module_suffix_candidate_test.go +13 -4
  100. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_conditional_export_test.go +13 -8
  101. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_config_types_test.go +7 -2
  102. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_excluded_import_test.go +11 -3
  103. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_package_export_test.go +11 -2
  104. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_package_import_test.go +11 -2
  105. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_path_alias_test.go +11 -2
  106. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_reference_path_test.go +11 -2
  107. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_root_dirs_target_test.go +11 -2
  108. package/cmd/ttscgraph/serve_session_reloads_newly_resolved_type_reference_test.go +11 -2
  109. package/cmd/ttscgraph/serve_session_reloads_root_file_set_test.go +11 -5
  110. package/cmd/ttscgraph/serve_session_reloads_source_deleted_during_load_test.go +16 -9
  111. package/cmd/ttscgraph/serve_session_reloads_superseding_module_candidates_test.go +18 -13
  112. package/cmd/ttscgraph/serve_session_reloads_transitive_project_reference_test.go +14 -5
  113. package/cmd/ttscgraph/serve_session_reloads_when_program_plugin_linked_test.go +13 -8
  114. package/cmd/ttscgraph/serve_session_retries_a_pending_dump_before_unchanged_test.go +62 -0
  115. package/cmd/ttscgraph/serve_session_reuses_unchanged_preamble_source_test.go +21 -0
  116. package/cmd/ttscgraph/serve_session_reuses_unchanged_snapshot_test.go +12 -7
  117. package/cmd/ttscgraph/serve_session_revisits_source_edited_during_load_test.go +18 -8
  118. package/cmd/ttscgraph/serve_session_tolerates_os_invalid_resolution_candidate_test.go +13 -9
  119. package/cmd/ttscgraph/serve_session_tracks_all_module_specifier_forms_test.go +12 -3
  120. package/cmd/ttscgraph/serve_session_tracks_diamond_project_references_once_test.go +12 -8
  121. package/cmd/ttscgraph/serve_shards.go +356 -279
  122. package/cmd/ttscgraph/serve_shards_abandoned_generation_converges_on_retry_test.go +41 -16
  123. package/cmd/ttscgraph/serve_shards_delete_removed_source_test.go +14 -4
  124. package/cmd/ttscgraph/serve_shards_external_endpoints_test.go +18 -2
  125. package/cmd/ttscgraph/serve_shards_keep_source_distributed_dependencies_at_the_boundary_test.go +36 -5
  126. package/cmd/ttscgraph/serve_shards_match_full_dump_oracle_test.go +12 -3
  127. package/cmd/ttscgraph/serve_shards_merge_pending_and_new_edits_test.go +36 -3
  128. package/cmd/ttscgraph/serve_shards_prune_unreferenced_external_endpoints_test.go +18 -2
  129. package/cmd/ttscgraph/serve_shards_publish_created_source_test.go +16 -13
  130. package/cmd/ttscgraph/serve_shards_rebuild_declaration_edit_test.go +14 -4
  131. package/cmd/ttscgraph/serve_shards_refresh_cross_file_implementation_test.go +24 -5
  132. package/cmd/ttscgraph/serve_shards_refresh_dependent_diagnostics_test.go +30 -7
  133. package/cmd/ttscgraph/serve_shards_rename_moves_source_identity_test.go +14 -11
  134. package/cmd/ttscgraph/serve_shards_retry_preserves_committed_generation_test.go +17 -7
  135. package/cmd/ttscgraph/serve_shards_reuse_unaffected_sources_test.go +21 -7
  136. package/cmd/ttscgraph/serve_snapshot_proves_its_program_without_a_second_read_test.go +57 -16
  137. package/cmd/ttscgraph/serve_source_encoding_test.go +133 -0
  138. package/cmd/ttscserver/command_operation_families_test.go +207 -0
  139. package/cmd/ttscserver/main.go +121 -39
  140. package/cmd/ttscserver/resolve_launch_uses_native_flag_authority_test.go +147 -0
  141. package/cmd/ttscserver/run_lsp_forwards_execute_command_advertisement_flags_test.go +7 -0
  142. package/cmd/ttscserver/run_lsp_prefers_tsgo_flag_test.go +13 -1
  143. package/cmd/ttscserver/run_lsp_reports_getwd_error_test.go +5 -0
  144. package/cmd/ttscserver/run_lsp_reports_server_error_test.go +10 -3
  145. package/cmd/ttscserver/run_lsp_uses_native_plugin_manifest_source_test.go +13 -10
  146. package/cmd/ttscserver/run_lsp_uses_tsgo_environment_test.go +10 -3
  147. package/driver/authored_region_maps_positions_around_the_preamble_test.go +95 -0
  148. package/driver/build_information_uses_selected_output_identity_test.go +148 -0
  149. package/driver/check_observations.go +67 -0
  150. package/driver/config_discovery.go +93 -24
  151. package/driver/declaration_shape.go +9 -0
  152. package/driver/diagnostics_preamble.go +8 -7
  153. package/driver/emit_containment.go +29 -8
  154. package/driver/emit_plugin.go +106 -36
  155. package/driver/emit_plugin_output.go +26 -2
  156. package/driver/emit_provenance.go +155 -0
  157. package/driver/graph.go +54 -20
  158. package/driver/host.go +26 -3
  159. package/driver/input_observation.go +78 -16
  160. package/driver/input_observation_test.go +34 -11
  161. package/driver/lsp.go +401 -30
  162. package/driver/overlay.go +69 -2
  163. package/driver/plugins.go +256 -24
  164. package/driver/private_result.go +43 -0
  165. package/driver/program.go +439 -95
  166. package/driver/resolution_candidates.go +63 -14
  167. package/driver/resolution_candidates_test.go +28 -0
  168. package/driver/resolutioninputs/recorder.cjs +1149 -0
  169. package/driver/resolutioninputs/resolutioninputs.go +37 -0
  170. package/driver/rewrite.go +373 -420
  171. package/driver/session.go +80 -12
  172. package/driver/sourcemap_preamble.go +38 -16
  173. package/driver/transform_dependencies.go +38 -10
  174. package/driver/transform_dependencies_declares_every_file_without_a_contributor_test.go +9 -8
  175. package/driver/transform_dependencies_drops_a_self_reported_dependency_test.go +7 -6
  176. package/driver/transform_dependencies_keys_a_reported_path_like_the_envelope_test.go +9 -9
  177. package/driver/transform_dependencies_requires_every_contributor_to_declare_test.go +10 -5
  178. package/driver/transform_dependencies_stays_silent_for_an_undeclared_contributor_test.go +8 -6
  179. package/driver/transform_dependencies_withdraws_completeness_after_an_unusable_dependency_test.go +9 -5
  180. package/driver/transform_source_map.go +388 -0
  181. package/driver/windowsjunction/create_preserves_existing_directory_windows_test.go +48 -0
  182. package/driver/windowsjunction/create_treats_paths_as_data_windows_test.go +55 -0
  183. package/driver/windowsjunction/windowsjunction.go +17 -1
  184. package/go.mod +10 -10
  185. package/go.sum +10 -10
  186. package/internal/cwd/cwd.go +13 -0
  187. package/internal/e2etrace/artifact.go +147 -0
  188. package/internal/e2etrace/completion_hints.go +35 -0
  189. package/internal/e2etrace/completion_hints_test.go +76 -0
  190. package/internal/e2etrace/e2etrace.go +303 -0
  191. package/internal/e2etrace/output.go +50 -0
  192. package/internal/graph/artifacts.go +69 -12
  193. package/internal/graph/artifacts_index_what_a_plugin_published_test.go +19 -8
  194. package/internal/graph/artifacts_survive_a_partial_rebuild_test.go +11 -12
  195. package/internal/graph/assigned_implementations_of_declaration_file_symbols_leave_no_edge_source_test.go +10 -12
  196. package/internal/graph/assigned_implementations_of_node_modules_symbols_leave_no_edge_source_test.go +7 -1
  197. package/internal/graph/build.go +122 -38
  198. package/internal/graph/build_files_reuses_committed_cross_file_endpoints_test.go +9 -3
  199. package/internal/graph/build_keeps_source_distributed_dependencies_at_the_external_boundary_test.go +10 -1
  200. package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +10 -4
  201. package/internal/graph/build_releases_the_scratch_it_no_longer_reads_test.go +22 -15
  202. package/internal/graph/decorators.go +18 -0
  203. package/internal/graph/decorators_capture_name_and_literal_arguments_test.go +9 -4
  204. package/internal/graph/diagnostics.go +21 -8
  205. package/internal/graph/doc_refs_are_the_use_the_checker_already_counts_test.go +25 -13
  206. package/internal/graph/doc_refs_resolve_documentation_links_test.go +19 -15
  207. package/internal/graph/doc_tags.go +28 -19
  208. package/internal/graph/doc_tags_are_claimed_before_they_are_read_test.go +16 -6
  209. package/internal/graph/doc_tags_capture_every_unrecognized_tag_test.go +9 -2
  210. package/internal/graph/doc_tags_read_only_what_the_parser_attached_test.go +12 -8
  211. package/internal/graph/doc_tags_stop_at_the_external_boundary_test.go +11 -1
  212. package/internal/graph/doc_tags_survive_line_endings_and_repeated_blocks_test.go +16 -6
  213. package/internal/graph/dump.go +200 -51
  214. package/internal/graph/dump_checkout_paths_are_stable_test.go +9 -2
  215. package/internal/graph/dump_diagnostics_ride_the_generation_that_built_it_test.go +10 -11
  216. package/internal/graph/dump_evidence_skips_leading_trivia_test.go +8 -2
  217. package/internal/graph/dump_is_a_function_of_the_source_test.go +12 -13
  218. package/internal/graph/dump_never_serializes_a_list_as_null_test.go +9 -9
  219. package/internal/graph/dump_path_mapper_caches_alias_resolution_test.go +10 -2
  220. package/internal/graph/dump_path_mapper_rejects_unportable_roots_and_collisions_test.go +53 -0
  221. package/internal/graph/{dump_paths_are_portable_and_injective_test.go → dump_path_mapper_uses_portable_coordinates_test.go} +8 -43
  222. package/internal/graph/dump_paths.go +61 -25
  223. package/internal/graph/dump_paths_canonicalize_windows_short_root_test.go +45 -8
  224. package/internal/graph/dump_rejects_provenance_only_path_errors_test.go +5 -0
  225. package/internal/graph/dump_serializes_the_full_graph_test.go +13 -19
  226. package/internal/graph/dump_symlink_project_publishes_matching_base_test.go +8 -0
  227. package/internal/graph/dump_uses_ecma_line_terminators_test.go +12 -6
  228. package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +11 -8
  229. package/internal/graph/edge_spans_point_to_resolved_usage_test.go +13 -5
  230. package/internal/graph/edges.go +44 -47
  231. package/internal/graph/edges_cover_class_level_references_test.go +14 -11
  232. package/internal/graph/enum_initializer_calls_are_edges_test.go +13 -3
  233. package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +19 -26
  234. package/internal/graph/exports.go +3 -5
  235. package/internal/graph/file_diagnostics_match_tsgo_code_and_location_test.go +9 -4
  236. package/internal/graph/file_diagnostics_report_code_column_and_message_test.go +11 -5
  237. package/internal/graph/function_locals_do_not_collide_test.go +27 -7
  238. package/internal/graph/gitignore.go +25 -12
  239. package/internal/graph/graph.go +167 -52
  240. package/internal/graph/heritage_edges_cover_implements_and_interface_extends_test.go +11 -3
  241. package/internal/graph/heritage_edges_keep_extends_and_implements_to_same_base_test.go +6 -0
  242. package/internal/graph/heritage_edges_record_extends_versus_implements_origin_test.go +9 -3
  243. package/internal/graph/heritage_edges_traverse_barrels_and_stop_at_external_leaves_test.go +11 -4
  244. package/internal/graph/line_model.go +44 -25
  245. package/internal/graph/literals.go +6 -7
  246. package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +10 -5
  247. package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +15 -17
  248. package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +10 -9
  249. package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +11 -11
  250. package/internal/graph/literals_resolve_through_alias_indirection_test.go +11 -11
  251. package/internal/graph/member_relation_edges_follow_checker_validity_test.go +11 -2
  252. package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +11 -1
  253. package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +12 -7
  254. package/internal/graph/namespace_dotted_form_qualifies_deeply_test.go +12 -3
  255. package/internal/graph/namespace_members_become_qualified_nodes_and_edges_test.go +12 -2
  256. package/internal/graph/node_identity_is_position_invariant_test.go +8 -2
  257. package/internal/graph/node_ids_preserve_hash_bearing_components_test.go +10 -2
  258. package/internal/graph/node_modifiers_emit_union_strings_test.go +13 -12
  259. package/internal/graph/nodes_are_marked_exported_through_the_export_table_test.go +12 -14
  260. package/internal/graph/object_literal_declarations_resolve_calls_test.go +170 -0
  261. package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +14 -13
  262. package/internal/graph/object_member_signatures_preserve_literal_whitespace_test.go +11 -7
  263. package/internal/graph/object_members.go +100 -1
  264. package/internal/graph/overload_implementation_replaces_signature_test.go +13 -2
  265. package/internal/graph/property_member_edges_remain_owner_visible_test.go +9 -3
  266. package/internal/graph/provenance.go +172 -87
  267. package/internal/graph/resolve.go +46 -12
  268. package/internal/graph/resolve_prefers_implementation_declaration_test.go +10 -2
  269. package/internal/graph/resolve_unwraps_barrel_reexport_to_real_declaration_test.go +16 -20
  270. package/internal/graph/source.go +16 -6
  271. package/internal/graph/source_texts_cover_every_resident_program_source_test.go +11 -7
  272. package/internal/graph/type_ref_edges_cover_typeof_as_satisfies_test.go +21 -2
  273. package/internal/graph/type_ref_edges_resolve_named_types_across_files_test.go +8 -3
  274. package/internal/graph/value_access_edges_cover_properties_test.go +11 -3
  275. package/internal/graph/value_call_edges_attribute_function_assignments_to_members_test.go +10 -4
  276. package/internal/graph/value_call_edges_cover_jsx_components_test.go +12 -8
  277. package/internal/graph/value_call_edges_cover_methods_and_constructors_test.go +12 -9
  278. package/internal/graph/value_call_edges_cover_variable_bound_callables_test.go +9 -3
  279. package/internal/graph/value_call_edges_do_not_double_record_invoked_member_access_test.go +10 -3
  280. package/internal/graph/value_call_edges_record_construct_versus_call_origin_test.go +12 -9
  281. package/internal/graph/value_call_edges_resolve_across_files_and_dedupe_test.go +10 -3
  282. package/internal/graph/value_call_edges_skip_self_and_unresolved_test.go +16 -5
  283. package/internal/graph/wire_node_ids_share_alias_resolution_test.go +10 -4
  284. package/internal/graphsymbols/position_helpers_follow_ecma_line_terminators_test.go +16 -4
  285. package/internal/graphsymbols/provider.go +278 -113
  286. package/internal/lspserver/lsp_clean_didopen_refreshes_compiler_state_test.go +14 -12
  287. package/internal/lspserver/lsp_completion_gate_never_refuses_a_matching_line_test.go +7 -1
  288. package/internal/lspserver/lsp_completion_hints_longest_trigger_wins_test.go +30 -5
  289. package/internal/lspserver/lsp_completion_hints_nearest_trigger_wins_test.go +5 -0
  290. package/internal/lspserver/lsp_completion_merges_into_upstream_response_test.go +23 -10
  291. package/internal/lspserver/lsp_completion_nearest_hint_replaces_nearest_filter_test.go +7 -1
  292. package/internal/lspserver/lsp_completion_preserves_completion_list_extensions_test.go +13 -5
  293. package/internal/lspserver/lsp_completion_refuses_hints_inside_a_string_literal_test.go +11 -7
  294. package/internal/lspserver/lsp_completion_replaces_full_filter_in_rank_order_test.go +12 -2
  295. package/internal/lspserver/lsp_completion_request.go +5 -26
  296. package/internal/lspserver/lsp_completion_scope.go +13 -10
  297. package/internal/lspserver/lsp_completion_scope_bench_test.go +11 -5
  298. package/internal/lspserver/lsp_completion_scope_classifies_regex_statement_and_operator_boundaries_test.go +8 -1
  299. package/internal/lspserver/lsp_completion_scope_ignores_jsdoc_bytes_in_literals_test.go +11 -10
  300. package/internal/lspserver/lsp_completion_scope_refuses_regex_hints_test.go +7 -3
  301. package/internal/lspserver/lsp_completion_trigger_uses_last_rune_test.go +6 -0
  302. package/internal/lspserver/lsp_deleted_watched_file_withdraws_plugin_diagnostics_test.go +11 -10
  303. package/internal/lspserver/lsp_didsave_keeps_the_incremental_changed_uri_path_test.go +12 -9
  304. package/internal/lspserver/lsp_document_diagnostics_omits_cached_project_when_current_result_has_none_test.go +17 -5
  305. package/internal/lspserver/lsp_envelope.go +84 -11
  306. package/internal/lspserver/lsp_executable_project_input_change_requests_launcher_restart_test.go +12 -9
  307. package/internal/lspserver/lsp_external_watched_change_retains_program_test.go +8 -2
  308. package/internal/lspserver/lsp_frame.go +42 -10
  309. package/internal/lspserver/lsp_hints_absence_is_not_an_error_test.go +16 -15
  310. package/internal/lspserver/lsp_hints_refresh_coalesces_concurrent_requests_test.go +21 -12
  311. package/internal/lspserver/lsp_hints_refresh_ignores_a_superseded_generation_test.go +20 -12
  312. package/internal/lspserver/lsp_hints_refresh_keeps_each_producer_isolated_test.go +30 -9
  313. package/internal/lspserver/lsp_hints_refresh_replaces_the_session_snapshot_test.go +25 -18
  314. package/internal/lspserver/lsp_hints_refresh_scheduled_by_editor_events_test.go +12 -12
  315. package/internal/lspserver/lsp_hints_refresh_serves_completion_while_running_test.go +21 -8
  316. package/internal/lspserver/lsp_index_byte_from_bounds_its_search_start_test.go +9 -7
  317. package/internal/lspserver/lsp_initialize_constrains_position_encoding_to_utf16_test.go +57 -21
  318. package/internal/lspserver/lsp_late_completion_trigger_is_reported_once_test.go +16 -17
  319. package/internal/lspserver/lsp_native_completion_hints_decode_flat_lint_wire_test.go +8 -2
  320. package/internal/lspserver/lsp_native_completion_hints_grouped_compatibility_boundary_test.go +5 -0
  321. package/internal/lspserver/lsp_native_plugin_source.go +381 -202
  322. package/internal/lspserver/lsp_native_plugin_source_ends_the_session_on_a_selection_input_test.go +234 -0
  323. package/internal/lspserver/lsp_native_reply_policies_test.go +475 -0
  324. package/internal/lspserver/lsp_native_reply_policy.go +232 -0
  325. package/internal/lspserver/lsp_native_resident.go +171 -57
  326. package/internal/lspserver/lsp_plugin.go +372 -68
  327. package/internal/lspserver/lsp_plugin_completion_resolve_stays_local_test.go +13 -4
  328. package/internal/lspserver/lsp_plugin_selection_inputs.go +283 -0
  329. package/internal/lspserver/lsp_plugin_selection_inputs_follow_directory_case_semantics_windows_test.go +81 -0
  330. package/internal/lspserver/lsp_position_conversions_span_astral_and_combining_runes_test.go +33 -11
  331. package/internal/lspserver/lsp_project_context_transport_identity_test.go +14 -2
  332. package/internal/lspserver/lsp_project_diagnostics.go +25 -4
  333. package/internal/lspserver/lsp_project_diagnostics_capability_is_independent_test.go +13 -2
  334. package/internal/lspserver/lsp_project_diagnostics_program_input_overlap_refreshes_all_producers_test.go +14 -4
  335. package/internal/lspserver/lsp_project_diagnostics_refresh_accumulates_owner_freshness_test.go +8 -2
  336. package/internal/lspserver/lsp_project_diagnostics_refresh_keeps_each_producer_last_good_test.go +10 -5
  337. package/internal/lspserver/lsp_project_diagnostics_refreshes_only_input_owners_test.go +14 -2
  338. package/internal/lspserver/lsp_project_diagnostics_resume_preserves_generation_test.go +8 -2
  339. package/internal/lspserver/lsp_project_diagnostics_translates_relative_client_project_test.go +15 -11
  340. package/internal/lspserver/lsp_project_input_ownership_resolves_declared_spellings_test.go +17 -8
  341. package/internal/lspserver/lsp_project_input_path_key_windows.go +16 -16
  342. package/internal/lspserver/lsp_project_input_path_key_windows_test.go +34 -18
  343. package/internal/lspserver/lsp_project_input_registration.go +5 -1
  344. package/internal/lspserver/lsp_project_input_registration_rechecks_selection_baseline_test.go +10 -4
  345. package/internal/lspserver/lsp_project_input_registration_reconciles_rejected_pending_request_test.go +5 -0
  346. package/internal/lspserver/lsp_project_input_registration_shapes_patterns_test.go +9 -3
  347. package/internal/lspserver/lsp_project_input_watchers_anchor_missing_paths_test.go +8 -3
  348. package/internal/lspserver/lsp_project_inputs.go +203 -59
  349. package/internal/lspserver/lsp_project_inputs_match_missing_exact_and_glob_test.go +10 -6
  350. package/internal/lspserver/lsp_project_inputs_reject_invalid_and_foreign_snapshots_test.go +25 -2
  351. package/internal/lspserver/lsp_proxy.go +239 -80
  352. package/internal/lspserver/lsp_refresh.go +16 -1
  353. package/internal/lspserver/lsp_reload_directories_compare_immediate_topology_test.go +66 -19
  354. package/internal/lspserver/lsp_reload_directories_separate_glob_territory_test.go +26 -6
  355. package/internal/lspserver/lsp_reload_file_fingerprint_preserves_raw_symlink_target_test.go +12 -6
  356. package/internal/lspserver/lsp_reload_fingerprints_read_a_junction_as_a_link_test.go +76 -0
  357. package/internal/lspserver/lsp_resident_falls_back_when_serve_unsupported_test.go +20 -13
  358. package/internal/lspserver/lsp_resident_invalidation_broadcasts_program_input_overlap_test.go +9 -4
  359. package/internal/lspserver/lsp_resident_invalidation_targets_project_input_owners_test.go +6 -1
  360. package/internal/lspserver/lsp_resident_maps_verb_args_test.go +5 -0
  361. package/internal/lspserver/lsp_same_transport_entries_are_deduplicated_test.go +10 -1
  362. package/internal/lspserver/lsp_server.go +124 -21
  363. package/internal/lspserver/lsp_symbols.go +92 -13
  364. package/internal/lspserver/lsp_watched_file_changes_reach_compiler_caches_test.go +11 -10
  365. package/internal/sourceprocess/complete_group.go +70 -0
  366. package/internal/sourceprocess/complete_group_preserves_original_wait_and_requires_independent_absence_test.go +145 -0
  367. package/internal/sourceprocess/contain_unix.go +143 -0
  368. package/internal/sourceprocess/contain_windows.go +442 -0
  369. package/internal/sourceprocess/darwin_group_retirement_preserves_phase_evidence_test.go +287 -0
  370. package/internal/sourceprocess/observe_exit_darwin.go +57 -0
  371. package/internal/sourceprocess/observe_exit_linux.go +27 -0
  372. package/internal/sourceprocess/observe_exit_other.go +11 -0
  373. package/internal/sourceprocess/reap_linux.go +31 -0
  374. package/internal/sourceprocess/reap_other.go +10 -0
  375. package/internal/sourceprocess/request_preserves_native_command_inputs_test.go +86 -0
  376. package/internal/sourceprocess/run.go +216 -0
  377. package/internal/sourceprocess/target_windows.go +211 -0
  378. package/internal/sourceprocess/windows_job_accounting_rejects_invalid_boundary_test.go +97 -0
  379. package/internal/sourceprocess/windows_target_owns_suspended_admission_test.go +179 -0
  380. package/internal/watchhelper/run.go +32 -0
  381. package/internal/watchhelper/run_linux.go +323 -0
  382. package/internal/watchhelper/run_linux_test.go +418 -0
  383. package/internal/watchhelper/run_other.go +16 -0
  384. package/internal/watchhelper/watchhelper.go +100 -0
  385. package/lib/TtscCompiler.d.ts +118 -21
  386. package/lib/TtscCompiler.js +175 -179
  387. package/lib/TtscCompiler.js.map +1 -1
  388. package/lib/TtscService.d.ts +66 -18
  389. package/lib/TtscService.js +81 -24
  390. package/lib/TtscService.js.map +1 -1
  391. package/lib/TtscServiceRequestOptions.d.ts +21 -0
  392. package/lib/TtscServiceRequestOptions.js +3 -0
  393. package/lib/TtscServiceRequestOptions.js.map +1 -0
  394. package/lib/compiler/internal/CapturedProcessOutput.d.ts +61 -0
  395. package/lib/compiler/internal/CapturedProcessOutput.js +3 -0
  396. package/lib/compiler/internal/CapturedProcessOutput.js.map +1 -0
  397. package/lib/compiler/internal/CompilerArgumentsInspection.d.ts +53 -0
  398. package/lib/compiler/internal/CompilerArgumentsInspection.js +173 -0
  399. package/lib/compiler/internal/CompilerArgumentsInspection.js.map +1 -0
  400. package/lib/compiler/internal/EmitOwnershipIndex.d.ts +92 -0
  401. package/lib/compiler/internal/EmitOwnershipIndex.js +215 -0
  402. package/lib/compiler/internal/EmitOwnershipIndex.js.map +1 -0
  403. package/lib/compiler/internal/PrivateCompilerOutput.d.ts +67 -0
  404. package/lib/compiler/internal/PrivateCompilerOutput.js +245 -0
  405. package/lib/compiler/internal/PrivateCompilerOutput.js.map +1 -0
  406. package/lib/compiler/internal/ResidentCheckProcess.d.ts +127 -0
  407. package/lib/compiler/internal/ResidentCheckProcess.js +403 -0
  408. package/lib/compiler/internal/ResidentCheckProcess.js.map +1 -0
  409. package/lib/compiler/internal/ResidentCheckProcessOptions.d.ts +29 -0
  410. package/lib/compiler/internal/ResidentCheckProcessOptions.js +3 -0
  411. package/lib/compiler/internal/ResidentCheckProcessOptions.js.map +1 -0
  412. package/lib/compiler/internal/ResidentCheckRequest.d.ts +37 -0
  413. package/lib/compiler/internal/ResidentCheckRequest.js +3 -0
  414. package/lib/compiler/internal/ResidentCheckRequest.js.map +1 -0
  415. package/lib/compiler/internal/ResidentCheckResult.d.ts +23 -0
  416. package/lib/compiler/internal/ResidentCheckResult.js +3 -0
  417. package/lib/compiler/internal/ResidentCheckResult.js.map +1 -0
  418. package/lib/compiler/internal/ResidentCheckTelemetry.d.ts +33 -0
  419. package/lib/compiler/internal/ResidentCheckTelemetry.js +3 -0
  420. package/lib/compiler/internal/ResidentCheckTelemetry.js.map +1 -0
  421. package/lib/compiler/internal/ResidentReplyKind.d.ts +18 -0
  422. package/lib/compiler/internal/ResidentReplyKind.js +3 -0
  423. package/lib/compiler/internal/ResidentReplyKind.js.map +1 -0
  424. package/lib/compiler/internal/ResidentTransformProcess.d.ts +83 -0
  425. package/lib/compiler/internal/ResidentTransformProcess.js +261 -0
  426. package/lib/compiler/internal/ResidentTransformProcess.js.map +1 -0
  427. package/lib/compiler/internal/ResidentTransformProcessOptions.d.ts +27 -0
  428. package/lib/compiler/internal/ResidentTransformProcessOptions.js +3 -0
  429. package/lib/compiler/internal/ResidentTransformProcessOptions.js.map +1 -0
  430. package/lib/compiler/internal/ResidentTransformReply.d.ts +51 -0
  431. package/lib/compiler/internal/ResidentTransformReply.js +79 -0
  432. package/lib/compiler/internal/ResidentTransformReply.js.map +1 -0
  433. package/lib/compiler/internal/ResidentTransformRequestOptions.d.ts +16 -0
  434. package/lib/compiler/internal/ResidentTransformRequestOptions.js +3 -0
  435. package/lib/compiler/internal/ResidentTransformRequestOptions.js.map +1 -0
  436. package/lib/compiler/internal/ResidentTransformRequests.d.ts +102 -0
  437. package/lib/compiler/internal/ResidentTransformRequests.js +172 -0
  438. package/lib/compiler/internal/ResidentTransformRequests.js.map +1 -0
  439. package/lib/compiler/internal/StartedResidentTransform.d.ts +27 -0
  440. package/lib/compiler/internal/StartedResidentTransform.js +3 -0
  441. package/lib/compiler/internal/StartedResidentTransform.js.map +1 -0
  442. package/lib/compiler/internal/TransformProjectWorkerReply.d.ts +34 -0
  443. package/lib/compiler/internal/TransformProjectWorkerReply.js +3 -0
  444. package/lib/compiler/internal/TransformProjectWorkerReply.js.map +1 -0
  445. package/lib/compiler/internal/TransformProjectWorkerRequest.d.ts +39 -0
  446. package/lib/compiler/internal/TransformProjectWorkerRequest.js +3 -0
  447. package/lib/compiler/internal/TransformProjectWorkerRequest.js.map +1 -0
  448. package/lib/compiler/internal/build/BuildExecution.d.ts +359 -0
  449. package/lib/compiler/internal/build/BuildExecution.js +977 -0
  450. package/lib/compiler/internal/build/BuildExecution.js.map +1 -0
  451. package/lib/compiler/internal/build/BuildTiming.d.ts +99 -0
  452. package/lib/compiler/internal/build/BuildTiming.js +113 -0
  453. package/lib/compiler/internal/build/BuildTiming.js.map +1 -0
  454. package/lib/compiler/internal/build/CompilerDiagnostics.d.ts +82 -0
  455. package/lib/compiler/internal/build/CompilerDiagnostics.js +270 -0
  456. package/lib/compiler/internal/build/CompilerDiagnostics.js.map +1 -0
  457. package/lib/compiler/internal/build/NativePluginArguments.d.ts +114 -0
  458. package/lib/compiler/internal/build/NativePluginArguments.js +255 -0
  459. package/lib/compiler/internal/build/NativePluginArguments.js.map +1 -0
  460. package/lib/compiler/internal/build/PassthroughFlags.d.ts +137 -0
  461. package/lib/compiler/internal/build/PassthroughFlags.js +213 -0
  462. package/lib/compiler/internal/build/PassthroughFlags.js.map +1 -0
  463. package/lib/compiler/internal/build/PluginFailureDiagnostics.d.ts +48 -0
  464. package/lib/compiler/internal/build/PluginFailureDiagnostics.js +68 -0
  465. package/lib/compiler/internal/build/PluginFailureDiagnostics.js.map +1 -0
  466. package/lib/compiler/internal/build/ResidentCheckEntryPlan.d.ts +38 -0
  467. package/lib/compiler/internal/build/ResidentCheckEntryPlan.js +3 -0
  468. package/lib/compiler/internal/build/ResidentCheckEntryPlan.js.map +1 -0
  469. package/lib/compiler/internal/build/ResidentCheckWatchChange.d.ts +30 -0
  470. package/lib/compiler/internal/build/ResidentCheckWatchChange.js +3 -0
  471. package/lib/compiler/internal/build/ResidentCheckWatchChange.js.map +1 -0
  472. package/lib/compiler/internal/build/ResidentCheckWatchSession.d.ts +113 -0
  473. package/lib/compiler/internal/build/ResidentCheckWatchSession.js +378 -0
  474. package/lib/compiler/internal/build/ResidentCheckWatchSession.js.map +1 -0
  475. package/lib/compiler/internal/build/RunBuildOptions.d.ts +130 -0
  476. package/lib/compiler/internal/build/RunBuildOptions.js +3 -0
  477. package/lib/compiler/internal/build/RunBuildOptions.js.map +1 -0
  478. package/lib/compiler/internal/build/TsgoArguments.d.ts +168 -0
  479. package/lib/compiler/internal/build/TsgoArguments.js +324 -0
  480. package/lib/compiler/internal/build/TsgoArguments.js.map +1 -0
  481. package/lib/compiler/internal/build/appendBuildOutput.d.ts +41 -0
  482. package/lib/compiler/internal/build/appendBuildOutput.js +182 -0
  483. package/lib/compiler/internal/build/appendBuildOutput.js.map +1 -0
  484. package/lib/compiler/internal/build/bufferResidentCheckEntryRequests.d.ts +20 -0
  485. package/lib/compiler/internal/build/bufferResidentCheckEntryRequests.js +40 -0
  486. package/lib/compiler/internal/build/bufferResidentCheckEntryRequests.js.map +1 -0
  487. package/lib/compiler/internal/build/createProcessDiagnostic.d.ts +19 -0
  488. package/lib/compiler/internal/build/createProcessDiagnostic.js +30 -0
  489. package/lib/compiler/internal/build/createProcessDiagnostic.js.map +1 -0
  490. package/lib/compiler/internal/build/isAbsoluteLocalProjectInputPath.d.ts +22 -0
  491. package/lib/compiler/internal/build/isAbsoluteLocalProjectInputPath.js +59 -0
  492. package/lib/compiler/internal/build/isAbsoluteLocalProjectInputPath.js.map +1 -0
  493. package/lib/compiler/internal/build/mergeProjectInputSnapshots.d.ts +28 -0
  494. package/lib/compiler/internal/build/mergeProjectInputSnapshots.js +121 -0
  495. package/lib/compiler/internal/build/mergeProjectInputSnapshots.js.map +1 -0
  496. package/lib/compiler/internal/build/normalizeBuildOutput.d.ts +29 -0
  497. package/lib/compiler/internal/build/normalizeBuildOutput.js +72 -0
  498. package/lib/compiler/internal/build/normalizeBuildOutput.js.map +1 -0
  499. package/lib/compiler/internal/build/parseProjectInputSnapshot.d.ts +26 -0
  500. package/lib/compiler/internal/build/parseProjectInputSnapshot.js +68 -0
  501. package/lib/compiler/internal/build/parseProjectInputSnapshot.js.map +1 -0
  502. package/lib/compiler/internal/build/planResidentCheckEntries.d.ts +21 -0
  503. package/lib/compiler/internal/build/planResidentCheckEntries.js +45 -0
  504. package/lib/compiler/internal/build/planResidentCheckEntries.js.map +1 -0
  505. package/lib/compiler/internal/build/privateRuntimeRootDir.d.ts +20 -0
  506. package/lib/compiler/internal/build/privateRuntimeRootDir.js +35 -0
  507. package/lib/compiler/internal/build/privateRuntimeRootDir.js.map +1 -0
  508. package/lib/compiler/internal/build/residentCheckRequest.d.ts +22 -0
  509. package/lib/compiler/internal/build/residentCheckRequest.js +42 -0
  510. package/lib/compiler/internal/build/residentCheckRequest.js.map +1 -0
  511. package/lib/compiler/internal/build/runBuild.d.ts +22 -0
  512. package/lib/compiler/internal/build/runBuild.js +44 -0
  513. package/lib/compiler/internal/build/runBuild.js.map +1 -0
  514. package/lib/compiler/internal/build/runExternalEmitProvenance.d.ts +61 -0
  515. package/lib/compiler/internal/build/runExternalEmitProvenance.js +451 -0
  516. package/lib/compiler/internal/build/runExternalEmitProvenance.js.map +1 -0
  517. package/lib/compiler/internal/build/takeResidentCheckEntryRequest.d.ts +18 -0
  518. package/lib/compiler/internal/build/takeResidentCheckEntryRequest.js +28 -0
  519. package/lib/compiler/internal/build/takeResidentCheckEntryRequest.js.map +1 -0
  520. package/lib/compiler/internal/buildNativeCompiler.d.ts +16 -1
  521. package/lib/compiler/internal/buildNativeCompiler.js +14 -2
  522. package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
  523. package/lib/compiler/internal/captureProcessOutput.d.ts +23 -23
  524. package/lib/compiler/internal/captureProcessOutput.js +38 -26
  525. package/lib/compiler/internal/captureProcessOutput.js.map +1 -1
  526. package/lib/compiler/internal/compileProjectInMemory.d.ts +30 -7
  527. package/lib/compiler/internal/compileProjectInMemory.js +103 -83
  528. package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
  529. package/lib/compiler/internal/ensureExecutable.d.ts +15 -0
  530. package/lib/compiler/internal/ensureExecutable.js +40 -0
  531. package/lib/compiler/internal/ensureExecutable.js.map +1 -0
  532. package/lib/compiler/internal/findNearestGoMod.d.ts +23 -0
  533. package/lib/compiler/internal/findNearestGoMod.js +48 -0
  534. package/lib/compiler/internal/findNearestGoMod.js.map +1 -0
  535. package/lib/compiler/internal/isOutsideRelativePath.d.ts +18 -0
  536. package/lib/compiler/internal/isOutsideRelativePath.js +30 -0
  537. package/lib/compiler/internal/isOutsideRelativePath.js.map +1 -0
  538. package/lib/compiler/internal/outputText.d.ts +16 -0
  539. package/lib/compiler/internal/outputText.js +25 -0
  540. package/lib/compiler/internal/outputText.js.map +1 -0
  541. package/lib/compiler/internal/packageRootDir.d.ts +25 -0
  542. package/lib/compiler/internal/packageRootDir.js +47 -0
  543. package/lib/compiler/internal/packageRootDir.js.map +1 -0
  544. package/lib/compiler/internal/parseNativeTransformOutput.d.ts +88 -0
  545. package/lib/compiler/internal/parseNativeTransformOutput.js +552 -0
  546. package/lib/compiler/internal/parseNativeTransformOutput.js.map +1 -0
  547. package/lib/compiler/internal/project/CompilerProjectSelection.d.ts +80 -0
  548. package/lib/compiler/internal/project/CompilerProjectSelection.js +187 -0
  549. package/lib/compiler/internal/project/CompilerProjectSelection.js.map +1 -0
  550. package/lib/compiler/internal/project/ConfigJsonText.d.ts +50 -0
  551. package/lib/compiler/internal/project/ConfigJsonText.js +61 -0
  552. package/lib/compiler/internal/project/ConfigJsonText.js.map +1 -0
  553. package/lib/compiler/internal/project/compilerUsesCaseSensitiveFileNames.d.ts +48 -0
  554. package/lib/compiler/internal/project/compilerUsesCaseSensitiveFileNames.js +119 -0
  555. package/lib/compiler/internal/project/compilerUsesCaseSensitiveFileNames.js.map +1 -0
  556. package/lib/compiler/internal/project/createNativeProjectContextArgs.d.ts +11 -8
  557. package/lib/compiler/internal/project/createNativeProjectContextArgs.js +15 -17
  558. package/lib/compiler/internal/project/createNativeProjectContextArgs.js.map +1 -1
  559. package/lib/compiler/internal/project/createNativeProjectContextJson.d.ts +19 -0
  560. package/lib/compiler/internal/project/createNativeProjectContextJson.js +27 -0
  561. package/lib/compiler/internal/project/createNativeProjectContextJson.js.map +1 -0
  562. package/lib/compiler/internal/project/parseJsonc.d.ts +42 -0
  563. package/lib/compiler/internal/project/parseJsonc.js +317 -0
  564. package/lib/compiler/internal/project/parseJsonc.js.map +1 -0
  565. package/lib/compiler/internal/project/readJsonFile.d.ts +21 -0
  566. package/lib/compiler/internal/project/readJsonFile.js +38 -0
  567. package/lib/compiler/internal/project/readJsonFile.js.map +1 -0
  568. package/lib/compiler/internal/project/readJsoncFile.d.ts +20 -0
  569. package/lib/compiler/internal/project/readJsoncFile.js +47 -0
  570. package/lib/compiler/internal/project/readJsoncFile.js.map +1 -0
  571. package/lib/compiler/internal/project/readProjectConfig.d.ts +29 -2
  572. package/lib/compiler/internal/project/readProjectConfig.js +105 -168
  573. package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
  574. package/lib/compiler/internal/project/resolveOwningProjectConfig.d.ts +65 -0
  575. package/lib/compiler/internal/project/resolveOwningProjectConfig.js +248 -0
  576. package/lib/compiler/internal/project/resolveOwningProjectConfig.js.map +1 -0
  577. package/lib/compiler/internal/project/resolveProjectConfig.d.ts +17 -14
  578. package/lib/compiler/internal/project/resolveProjectConfig.js +19 -122
  579. package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -1
  580. package/lib/compiler/internal/project/resolveProjectIdentity.d.ts +32 -0
  581. package/lib/compiler/internal/project/resolveProjectIdentity.js +144 -0
  582. package/lib/compiler/internal/project/resolveProjectIdentity.js.map +1 -0
  583. package/lib/compiler/internal/project/resolveTsconfigExtends.d.ts +38 -0
  584. package/lib/compiler/internal/project/resolveTsconfigExtends.js +163 -0
  585. package/lib/compiler/internal/project/resolveTsconfigExtends.js.map +1 -0
  586. package/lib/compiler/internal/project/selectReferencedProject.d.ts +26 -0
  587. package/lib/compiler/internal/project/selectReferencedProject.js +48 -0
  588. package/lib/compiler/internal/project/selectReferencedProject.js.map +1 -0
  589. package/lib/compiler/internal/project/tsconfigExtendsFileCandidates.d.ts +34 -0
  590. package/lib/compiler/internal/project/tsconfigExtendsFileCandidates.js +55 -0
  591. package/lib/compiler/internal/project/tsconfigExtendsFileCandidates.js.map +1 -0
  592. package/lib/compiler/internal/readEffectiveCompilerOptions.d.ts +54 -0
  593. package/lib/compiler/internal/readEffectiveCompilerOptions.js +116 -0
  594. package/lib/compiler/internal/readEffectiveCompilerOptions.js.map +1 -0
  595. package/lib/compiler/internal/resolveBinary.d.ts +17 -1
  596. package/lib/compiler/internal/resolveBinary.js +24 -9
  597. package/lib/compiler/internal/resolveBinary.js.map +1 -1
  598. package/lib/compiler/internal/resolveTsgo.d.ts +22 -7
  599. package/lib/compiler/internal/resolveTsgo.js +25 -9
  600. package/lib/compiler/internal/resolveTsgo.js.map +1 -1
  601. package/lib/compiler/internal/runNativeCheckWithObservations.d.ts +41 -0
  602. package/lib/compiler/internal/runNativeCheckWithObservations.js +185 -0
  603. package/lib/compiler/internal/runNativeCheckWithObservations.js.map +1 -0
  604. package/lib/compiler/internal/runSingleFileEmit.d.ts +26 -5
  605. package/lib/compiler/internal/runSingleFileEmit.js +82 -27
  606. package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
  607. package/lib/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.d.ts +2 -0
  608. package/lib/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.js +6 -0
  609. package/lib/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.js.map +1 -0
  610. package/lib/compiler/internal/sharedHost/SidecarEnvironment.d.ts +90 -0
  611. package/lib/compiler/internal/sharedHost/SidecarEnvironment.js +153 -0
  612. package/lib/compiler/internal/sharedHost/SidecarEnvironment.js.map +1 -0
  613. package/lib/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.d.ts +7 -0
  614. package/lib/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.js +11 -0
  615. package/lib/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.js.map +1 -0
  616. package/lib/compiler/internal/sharedHost/TSGO_ARGS_ENV.d.ts +7 -0
  617. package/lib/compiler/internal/sharedHost/TSGO_ARGS_ENV.js +11 -0
  618. package/lib/compiler/internal/sharedHost/TSGO_ARGS_ENV.js.map +1 -0
  619. package/lib/compiler/internal/sharedHost/assertSharedHostCompatibility.d.ts +24 -0
  620. package/lib/compiler/internal/sharedHost/assertSharedHostCompatibility.js +46 -0
  621. package/lib/compiler/internal/sharedHost/assertSharedHostCompatibility.js.map +1 -0
  622. package/lib/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.d.ts +15 -0
  623. package/lib/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.js +23 -0
  624. package/lib/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.js.map +1 -0
  625. package/lib/compiler/internal/sharedHost/clearInheritedTsgoArgs.d.ts +23 -0
  626. package/lib/compiler/internal/sharedHost/clearInheritedTsgoArgs.js +33 -0
  627. package/lib/compiler/internal/sharedHost/clearInheritedTsgoArgs.js.map +1 -0
  628. package/lib/compiler/internal/sharedHost/inheritedSidecarEnv.d.ts +27 -0
  629. package/lib/compiler/internal/sharedHost/inheritedSidecarEnv.js +41 -0
  630. package/lib/compiler/internal/sharedHost/inheritedSidecarEnv.js.map +1 -0
  631. package/lib/compiler/internal/sharedHost/isLinkedTransform.d.ts +16 -0
  632. package/lib/compiler/internal/sharedHost/isLinkedTransform.js +21 -0
  633. package/lib/compiler/internal/sharedHost/isLinkedTransform.js.map +1 -0
  634. package/lib/compiler/internal/sharedHost/linkedTransformPlugins.d.ts +19 -0
  635. package/lib/compiler/internal/sharedHost/linkedTransformPlugins.js +25 -0
  636. package/lib/compiler/internal/sharedHost/linkedTransformPlugins.js.map +1 -0
  637. package/lib/compiler/internal/sharedHost/publishLinkedTransformPlugins.d.ts +25 -0
  638. package/lib/compiler/internal/sharedHost/publishLinkedTransformPlugins.js +35 -0
  639. package/lib/compiler/internal/sharedHost/publishLinkedTransformPlugins.js.map +1 -0
  640. package/lib/compiler/internal/sharedHost/resolvePluginConfigDir.d.ts +26 -0
  641. package/lib/compiler/internal/sharedHost/resolvePluginConfigDir.js +36 -0
  642. package/lib/compiler/internal/sharedHost/resolvePluginConfigDir.js.map +1 -0
  643. package/lib/compiler/internal/sharedHost/selectSharedHostPlugin.d.ts +22 -0
  644. package/lib/compiler/internal/sharedHost/selectSharedHostPlugin.js +32 -0
  645. package/lib/compiler/internal/sharedHost/selectSharedHostPlugin.js.map +1 -0
  646. package/lib/compiler/internal/spawnNative.d.ts +15 -16
  647. package/lib/compiler/internal/spawnNative.js +17 -45
  648. package/lib/compiler/internal/spawnNative.js.map +1 -1
  649. package/lib/compiler/internal/startResidentTransform.d.ts +26 -17
  650. package/lib/compiler/internal/startResidentTransform.js +51 -36
  651. package/lib/compiler/internal/startResidentTransform.js.map +1 -1
  652. package/lib/compiler/internal/transformProjectInMemory.d.ts +42 -5
  653. package/lib/compiler/internal/transformProjectInMemory.js +189 -469
  654. package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
  655. package/lib/compiler/internal/transformProjectInWorker.d.ts +49 -0
  656. package/lib/compiler/internal/transformProjectInWorker.js +168 -0
  657. package/lib/compiler/internal/transformProjectInWorker.js.map +1 -0
  658. package/lib/compiler/internal/transformProjectWorker.js +37 -0
  659. package/lib/compiler/internal/transformProjectWorker.js.map +1 -0
  660. package/lib/flags/AnySubcommand.d.ts +18 -0
  661. package/lib/flags/AnySubcommand.js +3 -0
  662. package/lib/flags/AnySubcommand.js.map +1 -0
  663. package/lib/flags/COMPILER_ENUM_WHITESPACE.d.ts +2 -0
  664. package/lib/flags/COMPILER_ENUM_WHITESPACE.js +38 -0
  665. package/lib/flags/COMPILER_ENUM_WHITESPACE.js.map +1 -0
  666. package/lib/flags/COMPILER_OPTIONS.d.ts +6 -0
  667. package/lib/flags/COMPILER_OPTIONS.js +509 -0
  668. package/lib/flags/COMPILER_OPTIONS.js.map +1 -0
  669. package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.d.ts +2 -0
  670. package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js +13 -0
  671. package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js.map +1 -0
  672. package/lib/flags/COMPILER_OPTION_KINDS.d.ts +2 -0
  673. package/lib/flags/COMPILER_OPTION_KINDS.js +14 -0
  674. package/lib/flags/COMPILER_OPTION_KINDS.js.map +1 -0
  675. package/lib/flags/CompilerOptionSpec.d.ts +27 -0
  676. package/lib/flags/CompilerOptionSpec.js +3 -0
  677. package/lib/flags/CompilerOptionSpec.js.map +1 -0
  678. package/lib/flags/FLAG_BY_TOKEN.d.ts +8 -0
  679. package/lib/flags/FLAG_BY_TOKEN.js +34 -0
  680. package/lib/flags/FLAG_BY_TOKEN.js.map +1 -0
  681. package/lib/flags/FLAG_SCHEMA.d.ts +35 -0
  682. package/lib/flags/{schema.js → FLAG_SCHEMA.js} +47 -153
  683. package/lib/flags/FLAG_SCHEMA.js.map +1 -0
  684. package/lib/flags/FlagKind.d.ts +22 -0
  685. package/lib/flags/FlagKind.js +3 -0
  686. package/lib/flags/FlagKind.js.map +1 -0
  687. package/lib/flags/FlagLayer.d.ts +19 -0
  688. package/lib/flags/FlagLayer.js +3 -0
  689. package/lib/flags/FlagLayer.js.map +1 -0
  690. package/lib/flags/FlagSpec.d.ts +104 -0
  691. package/lib/flags/FlagSpec.js +3 -0
  692. package/lib/flags/FlagSpec.js.map +1 -0
  693. package/lib/flags/ParseOptions.d.ts +92 -0
  694. package/lib/flags/ParseOptions.js +3 -0
  695. package/lib/flags/ParseOptions.js.map +1 -0
  696. package/lib/flags/ParseResult.d.ts +37 -0
  697. package/lib/flags/ParseResult.js +3 -0
  698. package/lib/flags/ParseResult.js.map +1 -0
  699. package/lib/flags/TtscSubcommand.d.ts +14 -0
  700. package/lib/flags/TtscSubcommand.js +3 -0
  701. package/lib/flags/TtscSubcommand.js.map +1 -0
  702. package/lib/flags/TtsxSubcommand.d.ts +13 -0
  703. package/lib/flags/TtsxSubcommand.js +3 -0
  704. package/lib/flags/TtsxSubcommand.js.map +1 -0
  705. package/lib/flags/ValueValidator.d.ts +14 -0
  706. package/lib/flags/ValueValidator.js +3 -0
  707. package/lib/flags/ValueValidator.js.map +1 -0
  708. package/lib/flags/buildGoAllowList.d.ts +18 -0
  709. package/lib/flags/buildGoAllowList.js +45 -0
  710. package/lib/flags/buildGoAllowList.js.map +1 -0
  711. package/lib/flags/flagsForSubcommand.d.ts +18 -0
  712. package/lib/flags/flagsForSubcommand.js +23 -0
  713. package/lib/flags/flagsForSubcommand.js.map +1 -0
  714. package/lib/flags/getBoolean.d.ts +19 -0
  715. package/lib/flags/getBoolean.js +27 -0
  716. package/lib/flags/getBoolean.js.map +1 -0
  717. package/lib/flags/getNumber.d.ts +16 -0
  718. package/lib/flags/getNumber.js +24 -0
  719. package/lib/flags/getNumber.js.map +1 -0
  720. package/lib/flags/getString.d.ts +16 -0
  721. package/lib/flags/getString.js +24 -0
  722. package/lib/flags/getString.js.map +1 -0
  723. package/lib/flags/getStringList.d.ts +19 -0
  724. package/lib/flags/getStringList.js +24 -0
  725. package/lib/flags/getStringList.js.map +1 -0
  726. package/lib/flags/normalizeCompilerEnumValue.d.ts +20 -0
  727. package/lib/flags/normalizeCompilerEnumValue.js +40 -0
  728. package/lib/flags/normalizeCompilerEnumValue.js.map +1 -0
  729. package/lib/flags/normalizeFlagToken.d.ts +28 -0
  730. package/lib/flags/normalizeFlagToken.js +38 -0
  731. package/lib/flags/normalizeFlagToken.js.map +1 -0
  732. package/lib/flags/parseFlags.d.ts +18 -0
  733. package/lib/flags/parseFlags.js +288 -0
  734. package/lib/flags/parseFlags.js.map +1 -0
  735. package/lib/flags/readCompilerOptionOccurrence.d.ts +34 -0
  736. package/lib/flags/readCompilerOptionOccurrence.js +81 -0
  737. package/lib/flags/readCompilerOptionOccurrence.js.map +1 -0
  738. package/lib/flags/readCompilerOptionValues.d.ts +33 -0
  739. package/lib/flags/readCompilerOptionValues.js +58 -0
  740. package/lib/flags/readCompilerOptionValues.js.map +1 -0
  741. package/lib/flags/resolveFlagSpec.d.ts +21 -0
  742. package/lib/flags/resolveFlagSpec.js +32 -0
  743. package/lib/flags/resolveFlagSpec.js.map +1 -0
  744. package/lib/index.d.ts +8 -3
  745. package/lib/index.js +10 -3
  746. package/lib/index.js.map +1 -1
  747. package/lib/internal/CanonicalTempDirectoryOperations.d.ts +73 -0
  748. package/lib/internal/CanonicalTempDirectoryOperations.js +3 -0
  749. package/lib/internal/CanonicalTempDirectoryOperations.js.map +1 -0
  750. package/lib/internal/CompilerContextSnapshot.d.ts +66 -0
  751. package/lib/internal/CompilerContextSnapshot.js +121 -0
  752. package/lib/internal/CompilerContextSnapshot.js.map +1 -0
  753. package/lib/internal/CompilerResultAdapter.d.ts +129 -0
  754. package/lib/internal/CompilerResultAdapter.js +247 -0
  755. package/lib/internal/CompilerResultAdapter.js.map +1 -0
  756. package/lib/internal/E2ETrace.d.ts +219 -0
  757. package/lib/internal/E2ETrace.js +541 -0
  758. package/lib/internal/E2ETrace.js.map +1 -0
  759. package/lib/internal/IJavaScriptRuntimeCapabilities.d.ts +48 -0
  760. package/lib/internal/IJavaScriptRuntimeCapabilities.js +3 -0
  761. package/lib/internal/IJavaScriptRuntimeCapabilities.js.map +1 -0
  762. package/lib/internal/OwnedNativeProcess.d.ts +66 -0
  763. package/lib/internal/OwnedNativeProcess.js +317 -0
  764. package/lib/internal/OwnedNativeProcess.js.map +1 -0
  765. package/lib/internal/OwnedSynchronousProcess.d.ts +158 -0
  766. package/lib/internal/OwnedSynchronousProcess.js +171 -0
  767. package/lib/internal/OwnedSynchronousProcess.js.map +1 -0
  768. package/lib/internal/RetireLockDirectoryOperations.d.ts +77 -0
  769. package/lib/internal/RetireLockDirectoryOperations.js +3 -0
  770. package/lib/internal/RetireLockDirectoryOperations.js.map +1 -0
  771. package/lib/internal/SafeCacheCleanupTarget.d.ts +39 -0
  772. package/lib/internal/SafeCacheCleanupTarget.js +3 -0
  773. package/lib/internal/SafeCacheCleanupTarget.js.map +1 -0
  774. package/lib/internal/SourceNativeRetirement.d.ts +384 -0
  775. package/lib/internal/SourceNativeRetirement.js +892 -0
  776. package/lib/internal/SourceNativeRetirement.js.map +1 -0
  777. package/lib/internal/SpawnSyncOutputFiles.d.ts +28 -0
  778. package/lib/internal/SpawnSyncOutputFiles.js +3 -0
  779. package/lib/internal/SpawnSyncOutputFiles.js.map +1 -0
  780. package/lib/internal/cacheEntryExists.d.ts +13 -0
  781. package/lib/internal/cacheEntryExists.js +32 -0
  782. package/lib/internal/cacheEntryExists.js.map +1 -0
  783. package/lib/internal/createCanonicalTempDirectory.d.ts +23 -13
  784. package/lib/internal/createCanonicalTempDirectory.js +31 -12
  785. package/lib/internal/createCanonicalTempDirectory.js.map +1 -1
  786. package/lib/internal/isContendedCandidateRename.d.ts +27 -0
  787. package/lib/internal/isContendedCandidateRename.js +37 -0
  788. package/lib/internal/isContendedCandidateRename.js.map +1 -0
  789. package/lib/internal/isSpawnSyncFdExhaustion.d.ts +16 -0
  790. package/lib/internal/isSpawnSyncFdExhaustion.js +23 -0
  791. package/lib/internal/isSpawnSyncFdExhaustion.js.map +1 -0
  792. package/lib/internal/javascriptRuntimeCapabilities.d.ts +20 -0
  793. package/lib/internal/javascriptRuntimeCapabilities.js +142 -0
  794. package/lib/internal/javascriptRuntimeCapabilities.js.map +1 -0
  795. package/lib/internal/nativeBinary.d.ts +11 -0
  796. package/lib/internal/nativeBinary.js +16 -0
  797. package/lib/internal/nativeBinary.js.map +1 -0
  798. package/lib/internal/parseWindowsDirectoryCaseSensitivity.d.ts +24 -0
  799. package/lib/internal/parseWindowsDirectoryCaseSensitivity.js +47 -0
  800. package/lib/internal/parseWindowsDirectoryCaseSensitivity.js.map +1 -0
  801. package/lib/internal/pathIdentity/FilesystemPathIdentity.d.ts +43 -0
  802. package/lib/internal/pathIdentity/FilesystemPathIdentity.js +3 -0
  803. package/lib/internal/pathIdentity/FilesystemPathIdentity.js.map +1 -0
  804. package/lib/internal/pathIdentity/FilesystemPathIdentityContext.d.ts +176 -0
  805. package/lib/internal/pathIdentity/FilesystemPathIdentityContext.js +3 -0
  806. package/lib/internal/pathIdentity/FilesystemPathIdentityContext.js.map +1 -0
  807. package/lib/internal/pathIdentity/FilesystemPathIdentityOperations.d.ts +100 -0
  808. package/lib/internal/pathIdentity/FilesystemPathIdentityOperations.js +3 -0
  809. package/lib/internal/pathIdentity/FilesystemPathIdentityOperations.js.map +1 -0
  810. package/lib/internal/pathIdentity/ProjectInputPathIdentity.d.ts +20 -0
  811. package/lib/internal/pathIdentity/ProjectInputPathIdentity.js +3 -0
  812. package/lib/internal/pathIdentity/ProjectInputPathIdentity.js.map +1 -0
  813. package/lib/internal/pathIdentity/ProjectInputPathIdentityContext.d.ts +20 -0
  814. package/lib/internal/pathIdentity/ProjectInputPathIdentityContext.js +3 -0
  815. package/lib/internal/pathIdentity/ProjectInputPathIdentityContext.js.map +1 -0
  816. package/lib/internal/pathIdentity/ProjectInputPathIdentityOperations.d.ts +20 -0
  817. package/lib/internal/pathIdentity/ProjectInputPathIdentityOperations.js +3 -0
  818. package/lib/internal/pathIdentity/ProjectInputPathIdentityOperations.js.map +1 -0
  819. package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.d.ts +25 -0
  820. package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js +336 -0
  821. package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js.map +1 -0
  822. package/lib/internal/pathIdentity/createProjectInputPathIdentityContext.d.ts +28 -0
  823. package/lib/internal/pathIdentity/createProjectInputPathIdentityContext.js +33 -0
  824. package/lib/internal/pathIdentity/createProjectInputPathIdentityContext.js.map +1 -0
  825. package/lib/internal/pathIdentity/isFilesystemPathIdentityWithin.d.ts +20 -0
  826. package/lib/internal/pathIdentity/isFilesystemPathIdentityWithin.js +33 -0
  827. package/lib/internal/pathIdentity/isFilesystemPathIdentityWithin.js.map +1 -0
  828. package/lib/internal/pathIdentity/isProjectInputPathIdentityWithin.d.ts +15 -0
  829. package/lib/internal/pathIdentity/isProjectInputPathIdentityWithin.js +22 -0
  830. package/lib/internal/pathIdentity/isProjectInputPathIdentityWithin.js.map +1 -0
  831. package/lib/internal/pathIdentity/resolveFilesystemPath.d.ts +22 -0
  832. package/lib/internal/pathIdentity/resolveFilesystemPath.js +44 -0
  833. package/lib/internal/pathIdentity/resolveFilesystemPath.js.map +1 -0
  834. package/lib/internal/pathIdentity/resolvePhysicalPath.d.ts +21 -0
  835. package/lib/internal/pathIdentity/resolvePhysicalPath.js +35 -0
  836. package/lib/internal/pathIdentity/resolvePhysicalPath.js.map +1 -0
  837. package/lib/internal/pathIdentity/resolveProjectInputPath.d.ts +14 -0
  838. package/lib/internal/pathIdentity/resolveProjectInputPath.js +21 -0
  839. package/lib/internal/pathIdentity/resolveProjectInputPath.js.map +1 -0
  840. package/lib/internal/pluginSource.d.ts +26 -0
  841. package/lib/internal/pluginSource.js +43 -0
  842. package/lib/internal/pluginSource.js.map +1 -0
  843. package/lib/internal/projectInputPathIdentity.d.ts +27 -31
  844. package/lib/internal/projectInputPathIdentity.js +37 -275
  845. package/lib/internal/projectInputPathIdentity.js.map +1 -1
  846. package/lib/internal/resolveNodeBinary.d.ts +9 -7
  847. package/lib/internal/resolveNodeBinary.js +14 -144
  848. package/lib/internal/resolveNodeBinary.js.map +1 -1
  849. package/lib/internal/resolveSafeCacheCleanupTargets.d.ts +27 -8
  850. package/lib/internal/resolveSafeCacheCleanupTargets.js +44 -11
  851. package/lib/internal/resolveSafeCacheCleanupTargets.js.map +1 -1
  852. package/lib/internal/restoreCompilerError.d.ts +21 -0
  853. package/lib/internal/restoreCompilerError.js +164 -0
  854. package/lib/internal/restoreCompilerError.js.map +1 -0
  855. package/lib/internal/retireLockDirectory.d.ts +45 -0
  856. package/lib/internal/retireLockDirectory.js +152 -0
  857. package/lib/internal/retireLockDirectory.js.map +1 -0
  858. package/lib/internal/runHoldingLock.d.ts +30 -0
  859. package/lib/internal/runHoldingLock.js +53 -0
  860. package/lib/internal/runHoldingLock.js.map +1 -0
  861. package/lib/internal/runtimeExecutableIdentity.d.ts +20 -0
  862. package/lib/internal/runtimeExecutableIdentity.js +171 -0
  863. package/lib/internal/runtimeExecutableIdentity.js.map +1 -0
  864. package/lib/internal/serializeCompilerError.d.ts +28 -0
  865. package/lib/internal/serializeCompilerError.js +138 -0
  866. package/lib/internal/serializeCompilerError.js.map +1 -0
  867. package/lib/internal/spawnSyncResilient.d.ts +21 -10
  868. package/lib/internal/spawnSyncResilient.js +31 -147
  869. package/lib/internal/spawnSyncResilient.js.map +1 -1
  870. package/lib/internal/spawnSyncWithLowDescriptors.d.ts +30 -0
  871. package/lib/internal/spawnSyncWithLowDescriptors.js +194 -0
  872. package/lib/internal/spawnSyncWithLowDescriptors.js.map +1 -0
  873. package/lib/internal/tsconfig.d.ts +16 -0
  874. package/lib/internal/tsconfig.js +33 -0
  875. package/lib/internal/tsconfig.js.map +1 -0
  876. package/lib/launcher/internal/PendingResidentCheckWatchChanges.d.ts +56 -0
  877. package/lib/launcher/internal/PendingResidentCheckWatchChanges.js +97 -0
  878. package/lib/launcher/internal/PendingResidentCheckWatchChanges.js.map +1 -0
  879. package/lib/launcher/internal/TtscBuildMode.d.ts +14 -0
  880. package/lib/launcher/internal/TtscBuildMode.js +3 -0
  881. package/lib/launcher/internal/TtscBuildMode.js.map +1 -0
  882. package/lib/launcher/internal/TtsxEntryOptions.d.ts +50 -0
  883. package/lib/launcher/internal/TtsxEntryOptions.js +94 -0
  884. package/lib/launcher/internal/TtsxEntryOptions.js.map +1 -0
  885. package/lib/launcher/internal/assertNoSolutionBuild.d.ts +17 -10
  886. package/lib/launcher/internal/assertNoSolutionBuild.js +16 -9
  887. package/lib/launcher/internal/assertNoSolutionBuild.js.map +1 -1
  888. package/lib/launcher/internal/assertTtsxNoWatch.d.ts +25 -0
  889. package/lib/launcher/internal/assertTtsxNoWatch.js +46 -0
  890. package/lib/launcher/internal/assertTtsxNoWatch.js.map +1 -0
  891. package/lib/launcher/internal/buildSingleRootProject.d.ts +108 -0
  892. package/lib/launcher/internal/buildSingleRootProject.js +229 -0
  893. package/lib/launcher/internal/buildSingleRootProject.js.map +1 -0
  894. package/lib/launcher/internal/getCompilerVersionText.d.ts +14 -1
  895. package/lib/launcher/internal/getCompilerVersionText.js +21 -6
  896. package/lib/launcher/internal/getCompilerVersionText.js.map +1 -1
  897. package/lib/launcher/internal/inlineServedSourceMap.d.ts +35 -0
  898. package/lib/launcher/internal/inlineServedSourceMap.js +255 -0
  899. package/lib/launcher/internal/inlineServedSourceMap.js.map +1 -0
  900. package/lib/launcher/internal/linkVirtualEntry.d.ts +31 -0
  901. package/lib/launcher/internal/linkVirtualEntry.js +87 -0
  902. package/lib/launcher/internal/linkVirtualEntry.js.map +1 -0
  903. package/lib/launcher/internal/parseCommonJsExports.d.ts +17 -0
  904. package/lib/launcher/internal/{commonJsExportMetadata.js → parseCommonJsExports.js} +13 -3
  905. package/lib/launcher/internal/parseCommonJsExports.js.map +1 -0
  906. package/lib/launcher/internal/parseTtscBuildArgs.d.ts +34 -0
  907. package/lib/launcher/internal/parseTtscBuildArgs.js +97 -0
  908. package/lib/launcher/internal/parseTtscBuildArgs.js.map +1 -0
  909. package/lib/launcher/internal/parseTtsxCLI.d.ts +35 -0
  910. package/lib/launcher/internal/parseTtsxCLI.js +187 -0
  911. package/lib/launcher/internal/parseTtsxCLI.js.map +1 -0
  912. package/lib/launcher/internal/prepareExecution.d.ts +49 -5
  913. package/lib/launcher/internal/prepareExecution.js +360 -324
  914. package/lib/launcher/internal/prepareExecution.js.map +1 -1
  915. package/lib/launcher/internal/prepareTtscBuildMode.d.ts +23 -0
  916. package/lib/launcher/internal/prepareTtscBuildMode.js +58 -0
  917. package/lib/launcher/internal/prepareTtscBuildMode.js.map +1 -0
  918. package/lib/launcher/internal/resolveCacheDir.d.ts +12 -3
  919. package/lib/launcher/internal/resolveCacheDir.js +12 -3
  920. package/lib/launcher/internal/resolveCacheDir.js.map +1 -1
  921. package/lib/launcher/internal/resolveSingleFileOutput.d.ts +35 -0
  922. package/lib/launcher/internal/resolveSingleFileOutput.js +115 -0
  923. package/lib/launcher/internal/resolveSingleFileOutput.js.map +1 -0
  924. package/lib/launcher/internal/resolveTtscserverBinary.d.ts +15 -3
  925. package/lib/launcher/internal/resolveTtscserverBinary.js +19 -5
  926. package/lib/launcher/internal/resolveTtscserverBinary.js.map +1 -1
  927. package/lib/launcher/internal/runTtsc.d.ts +23 -23
  928. package/lib/launcher/internal/runTtsc.js +336 -286
  929. package/lib/launcher/internal/runTtsc.js.map +1 -1
  930. package/lib/launcher/internal/runTtsx.d.ts +32 -4
  931. package/lib/launcher/internal/runTtsx.js +286 -138
  932. package/lib/launcher/internal/runTtsx.js.map +1 -1
  933. package/lib/launcher/internal/runtime/CommonJsRuntimeSource.d.ts +92 -0
  934. package/lib/launcher/internal/runtime/CommonJsRuntimeSource.js +354 -0
  935. package/lib/launcher/internal/runtime/CommonJsRuntimeSource.js.map +1 -0
  936. package/lib/launcher/internal/runtime/DependencyBuildAdmission.d.ts +72 -0
  937. package/lib/launcher/internal/runtime/DependencyBuildAdmission.js +120 -0
  938. package/lib/launcher/internal/runtime/DependencyBuildAdmission.js.map +1 -0
  939. package/lib/launcher/internal/runtime/DependencyBuildGeneration.d.ts +185 -0
  940. package/lib/launcher/internal/runtime/DependencyBuildGeneration.js +153 -0
  941. package/lib/launcher/internal/runtime/DependencyBuildGeneration.js.map +1 -0
  942. package/lib/launcher/internal/runtime/DependencyBuildLockFence.d.ts +22 -0
  943. package/lib/launcher/internal/runtime/DependencyBuildLockFence.js +3 -0
  944. package/lib/launcher/internal/runtime/DependencyBuildLockFence.js.map +1 -0
  945. package/lib/launcher/internal/runtime/DependencyBuildLockLease.d.ts +22 -0
  946. package/lib/launcher/internal/runtime/DependencyBuildLockLease.js +3 -0
  947. package/lib/launcher/internal/runtime/DependencyBuildLockLease.js.map +1 -0
  948. package/lib/launcher/internal/runtime/DependencyBuildLockObservation.d.ts +41 -0
  949. package/lib/launcher/internal/runtime/DependencyBuildLockObservation.js +3 -0
  950. package/lib/launcher/internal/runtime/DependencyBuildLockObservation.js.map +1 -0
  951. package/lib/launcher/internal/runtime/DependencyBuildLockProtocol.d.ts +83 -0
  952. package/lib/launcher/internal/runtime/DependencyBuildLockProtocol.js +126 -0
  953. package/lib/launcher/internal/runtime/DependencyBuildLockProtocol.js.map +1 -0
  954. package/lib/launcher/internal/runtime/OwnedProjectSource.d.ts +112 -0
  955. package/lib/launcher/internal/runtime/OwnedProjectSource.js +59 -0
  956. package/lib/launcher/internal/runtime/OwnedProjectSource.js.map +1 -0
  957. package/lib/launcher/internal/runtime/OwningModuleOptions.d.ts +21 -0
  958. package/lib/launcher/internal/runtime/OwningModuleOptions.js +3 -0
  959. package/lib/launcher/internal/runtime/OwningModuleOptions.js.map +1 -0
  960. package/lib/launcher/internal/runtime/PluginDescriptorInputObservation.d.ts +89 -0
  961. package/lib/launcher/internal/runtime/PluginDescriptorInputObservation.js +115 -0
  962. package/lib/launcher/internal/runtime/PluginDescriptorInputObservation.js.map +1 -0
  963. package/lib/launcher/internal/runtime/ProcessOwnedDirectory.d.ts +168 -0
  964. package/lib/launcher/internal/runtime/ProcessOwnedDirectory.js +251 -0
  965. package/lib/launcher/internal/runtime/ProcessOwnedDirectory.js.map +1 -0
  966. package/lib/launcher/internal/runtime/ResolveResult.d.ts +24 -0
  967. package/lib/launcher/internal/runtime/ResolveResult.js +3 -0
  968. package/lib/launcher/internal/runtime/ResolveResult.js.map +1 -0
  969. package/lib/launcher/internal/runtime/RuntimeEmitProvenance.d.ts +38 -0
  970. package/lib/launcher/internal/runtime/RuntimeEmitProvenance.js +60 -0
  971. package/lib/launcher/internal/runtime/RuntimeEmitProvenance.js.map +1 -0
  972. package/lib/launcher/internal/runtime/RuntimeEntryPreparer.d.ts +22 -0
  973. package/lib/launcher/internal/runtime/RuntimeEntryPreparer.js +3 -0
  974. package/lib/launcher/internal/runtime/RuntimeEntryPreparer.js.map +1 -0
  975. package/lib/launcher/internal/runtime/RuntimeFilesystem.d.ts +52 -0
  976. package/lib/launcher/internal/runtime/RuntimeFilesystem.js +73 -0
  977. package/lib/launcher/internal/runtime/RuntimeFilesystem.js.map +1 -0
  978. package/lib/launcher/internal/runtime/RuntimeHookOptions.d.ts +22 -0
  979. package/lib/launcher/internal/runtime/RuntimeHookOptions.js +3 -0
  980. package/lib/launcher/internal/runtime/RuntimeHookOptions.js.map +1 -0
  981. package/lib/launcher/internal/runtime/RuntimeIsolatedEmit.d.ts +53 -0
  982. package/lib/launcher/internal/runtime/RuntimeIsolatedEmit.js +88 -0
  983. package/lib/launcher/internal/runtime/RuntimeIsolatedEmit.js.map +1 -0
  984. package/lib/launcher/internal/runtime/RuntimeLoaderCapabilities.d.ts +78 -0
  985. package/lib/launcher/internal/runtime/RuntimeLoaderCapabilities.js +256 -0
  986. package/lib/launcher/internal/runtime/RuntimeLoaderCapabilities.js.map +1 -0
  987. package/lib/launcher/internal/runtime/RuntimeManifest.d.ts +65 -0
  988. package/lib/launcher/internal/runtime/RuntimeManifest.js +3 -0
  989. package/lib/launcher/internal/runtime/RuntimeManifest.js.map +1 -0
  990. package/lib/launcher/internal/runtime/RuntimeManifestRegistry.d.ts +95 -0
  991. package/lib/launcher/internal/runtime/RuntimeManifestRegistry.js +268 -0
  992. package/lib/launcher/internal/runtime/RuntimeManifestRegistry.js.map +1 -0
  993. package/lib/launcher/internal/runtime/RuntimeModuleFormat.d.ts +60 -0
  994. package/lib/launcher/internal/runtime/RuntimeModuleFormat.js +249 -0
  995. package/lib/launcher/internal/runtime/RuntimeModuleFormat.js.map +1 -0
  996. package/lib/launcher/internal/runtime/RuntimeProjectOwnership.d.ts +50 -0
  997. package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js +134 -0
  998. package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js.map +1 -0
  999. package/lib/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.d.ts +11 -0
  1000. package/lib/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.js +15 -0
  1001. package/lib/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.js.map +1 -0
  1002. package/lib/launcher/internal/runtime/acquireDependencyBuildLock.d.ts +22 -0
  1003. package/lib/launcher/internal/runtime/acquireDependencyBuildLock.js +74 -0
  1004. package/lib/launcher/internal/runtime/acquireDependencyBuildLock.js.map +1 -0
  1005. package/lib/launcher/internal/runtime/checkNodeRuntimeSupport.d.ts +30 -0
  1006. package/lib/launcher/internal/runtime/checkNodeRuntimeSupport.js +83 -0
  1007. package/lib/launcher/internal/runtime/checkNodeRuntimeSupport.js.map +1 -0
  1008. package/lib/launcher/internal/runtime/claimRuntimeProjectDirectory.d.ts +30 -0
  1009. package/lib/launcher/internal/runtime/claimRuntimeProjectDirectory.js +52 -0
  1010. package/lib/launcher/internal/runtime/claimRuntimeProjectDirectory.js.map +1 -0
  1011. package/lib/launcher/internal/runtime/commonJsExportNames.d.ts +21 -0
  1012. package/lib/launcher/internal/runtime/commonJsExportNames.js +68 -0
  1013. package/lib/launcher/internal/runtime/commonJsExportNames.js.map +1 -0
  1014. package/lib/launcher/internal/runtime/commonJsImportFacade.d.ts +32 -0
  1015. package/lib/launcher/internal/runtime/commonJsImportFacade.js +56 -0
  1016. package/lib/launcher/internal/runtime/commonJsImportFacade.js.map +1 -0
  1017. package/lib/launcher/internal/runtime/dependencyCacheKey.d.ts +36 -0
  1018. package/lib/launcher/internal/runtime/dependencyCacheKey.js +57 -0
  1019. package/lib/launcher/internal/runtime/dependencyCacheKey.js.map +1 -0
  1020. package/lib/launcher/internal/runtime/dependencyCacheRoot.d.ts +32 -0
  1021. package/lib/launcher/internal/runtime/dependencyCacheRoot.js +98 -0
  1022. package/lib/launcher/internal/runtime/dependencyCacheRoot.js.map +1 -0
  1023. package/lib/launcher/internal/runtime/inspectDependencyBuildLock.d.ts +23 -0
  1024. package/lib/launcher/internal/runtime/inspectDependencyBuildLock.js +126 -0
  1025. package/lib/launcher/internal/runtime/inspectDependencyBuildLock.js.map +1 -0
  1026. package/lib/launcher/internal/runtime/installRuntimeHooks.d.ts +58 -0
  1027. package/lib/launcher/internal/runtime/installRuntimeHooks.js +1988 -0
  1028. package/lib/launcher/internal/runtime/installRuntimeHooks.js.map +1 -0
  1029. package/lib/launcher/internal/runtime/interopProbe.d.ts +8 -0
  1030. package/lib/launcher/internal/runtime/interopProbe.js +3 -0
  1031. package/lib/launcher/internal/runtime/interopProbe.js.map +1 -0
  1032. package/lib/launcher/internal/runtime/isLocalProcessGone.d.ts +33 -0
  1033. package/lib/launcher/internal/runtime/isLocalProcessGone.js +60 -0
  1034. package/lib/launcher/internal/runtime/isLocalProcessGone.js.map +1 -0
  1035. package/lib/launcher/internal/runtime/observeMappedDescriptorResolution.d.ts +28 -0
  1036. package/lib/launcher/internal/runtime/observeMappedDescriptorResolution.js +50 -0
  1037. package/lib/launcher/internal/runtime/observeMappedDescriptorResolution.js.map +1 -0
  1038. package/lib/launcher/internal/runtime/projectModuleOptions.d.ts +16 -0
  1039. package/lib/launcher/internal/runtime/projectModuleOptions.js +28 -0
  1040. package/lib/launcher/internal/runtime/projectModuleOptions.js.map +1 -0
  1041. package/lib/launcher/internal/runtime/readDependencyCache.d.ts +28 -0
  1042. package/lib/launcher/internal/runtime/readDependencyCache.js +83 -0
  1043. package/lib/launcher/internal/runtime/readDependencyCache.js.map +1 -0
  1044. package/lib/launcher/internal/runtime/realPath.d.ts +22 -0
  1045. package/lib/launcher/internal/runtime/realPath.js +37 -0
  1046. package/lib/launcher/internal/runtime/realPath.js.map +1 -0
  1047. package/lib/launcher/internal/runtime/reclaimDependencyBuildLock.d.ts +17 -0
  1048. package/lib/launcher/internal/runtime/reclaimDependencyBuildLock.js +23 -0
  1049. package/lib/launcher/internal/runtime/reclaimDependencyBuildLock.js.map +1 -0
  1050. package/lib/launcher/internal/runtime/releaseDependencyBuildLock.d.ts +17 -0
  1051. package/lib/launcher/internal/runtime/releaseDependencyBuildLock.js +23 -0
  1052. package/lib/launcher/internal/runtime/releaseDependencyBuildLock.js.map +1 -0
  1053. package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.d.ts +34 -0
  1054. package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js +88 -0
  1055. package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js.map +1 -0
  1056. package/lib/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.d.ts +20 -0
  1057. package/lib/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.js +30 -0
  1058. package/lib/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.js.map +1 -0
  1059. package/lib/launcher/internal/runtime/runtimeRunKey.d.ts +24 -0
  1060. package/lib/launcher/internal/runtime/runtimeRunKey.js +36 -0
  1061. package/lib/launcher/internal/runtime/runtimeRunKey.js.map +1 -0
  1062. package/lib/launcher/internal/runtime/selectRuntimePluginPolicy.d.ts +21 -0
  1063. package/lib/launcher/internal/runtime/selectRuntimePluginPolicy.js +29 -0
  1064. package/lib/launcher/internal/runtime/selectRuntimePluginPolicy.js.map +1 -0
  1065. package/lib/launcher/internal/runtime/withRuntimeDirectoryLock.d.ts +35 -0
  1066. package/lib/launcher/internal/runtime/withRuntimeDirectoryLock.js +76 -0
  1067. package/lib/launcher/internal/runtime/withRuntimeDirectoryLock.js.map +1 -0
  1068. package/lib/launcher/internal/runtimeCompilerArgs.d.ts +35 -6
  1069. package/lib/launcher/internal/runtimeCompilerArgs.js +87 -58
  1070. package/lib/launcher/internal/runtimeCompilerArgs.js.map +1 -1
  1071. package/lib/launcher/internal/runtimeEmitProfile.d.ts +39 -0
  1072. package/lib/launcher/internal/runtimeEmitProfile.js +56 -0
  1073. package/lib/launcher/internal/runtimeEmitProfile.js.map +1 -0
  1074. package/lib/launcher/internal/runtimeHookPreload.js +4 -4
  1075. package/lib/launcher/internal/runtimeHookPreload.js.map +1 -1
  1076. package/lib/launcher/internal/runtimeOwnerPreload.d.ts +1 -0
  1077. package/lib/launcher/internal/runtimeOwnerPreload.js +43 -0
  1078. package/lib/launcher/internal/runtimeOwnerPreload.js.map +1 -0
  1079. package/lib/launcher/internal/singleRootProjectConfig.d.ts +34 -0
  1080. package/lib/launcher/internal/singleRootProjectConfig.js +39 -0
  1081. package/lib/launcher/internal/singleRootProjectConfig.js.map +1 -0
  1082. package/lib/launcher/internal/ttscserver/ILSPPluginSelectionInputs.d.ts +61 -0
  1083. package/lib/launcher/internal/ttscserver/ILSPPluginSelectionInputs.js +3 -0
  1084. package/lib/launcher/internal/ttscserver/ILSPPluginSelectionInputs.js.map +1 -0
  1085. package/lib/launcher/internal/ttscserver/LSPProjectInputDigest.d.ts +95 -0
  1086. package/lib/launcher/internal/ttscserver/LSPProjectInputDigest.js +270 -0
  1087. package/lib/launcher/internal/ttscserver/LSPProjectInputDigest.js.map +1 -0
  1088. package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.d.ts +46 -0
  1089. package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.js +91 -0
  1090. package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.js.map +1 -0
  1091. package/lib/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.d.ts +21 -0
  1092. package/lib/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.js +39 -0
  1093. package/lib/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.js.map +1 -0
  1094. package/lib/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.d.ts +18 -0
  1095. package/lib/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.js +27 -0
  1096. package/lib/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.js.map +1 -0
  1097. package/lib/launcher/internal/ttscserver/materializeLSPPluginManifest.d.ts +26 -0
  1098. package/lib/launcher/internal/ttscserver/materializeLSPPluginManifest.js +62 -0
  1099. package/lib/launcher/internal/ttscserver/materializeLSPPluginManifest.js.map +1 -0
  1100. package/lib/launcher/internal/ttscserver/needsStdio.d.ts +17 -0
  1101. package/lib/launcher/internal/ttscserver/needsStdio.js +36 -0
  1102. package/lib/launcher/internal/ttscserver/needsStdio.js.map +1 -0
  1103. package/lib/launcher/internal/ttscserver/runTtscserver.d.ts +25 -0
  1104. package/lib/launcher/internal/ttscserver/runTtscserver.js +439 -0
  1105. package/lib/launcher/internal/ttscserver/runTtscserver.js.map +1 -0
  1106. package/lib/launcher/internal/watch/CompilerDirectoryWatchEventPlan.d.ts +29 -0
  1107. package/lib/launcher/internal/watch/CompilerDirectoryWatchEventPlan.js +3 -0
  1108. package/lib/launcher/internal/watch/CompilerDirectoryWatchEventPlan.js.map +1 -0
  1109. package/lib/launcher/internal/watch/DirectoryWatcher.d.ts +44 -0
  1110. package/lib/launcher/internal/watch/DirectoryWatcher.js +3 -0
  1111. package/lib/launcher/internal/watch/DirectoryWatcher.js.map +1 -0
  1112. package/lib/launcher/internal/watch/FseventsStreams.d.ts +87 -0
  1113. package/lib/launcher/internal/watch/FseventsStreams.js +266 -0
  1114. package/lib/launcher/internal/watch/FseventsStreams.js.map +1 -0
  1115. package/lib/launcher/internal/watch/ProjectInputWatchRules.d.ts +92 -0
  1116. package/lib/launcher/internal/watch/ProjectInputWatchRules.js +163 -0
  1117. package/lib/launcher/internal/watch/ProjectInputWatchRules.js.map +1 -0
  1118. package/lib/launcher/internal/watch/WatchInputChange.d.ts +29 -0
  1119. package/lib/launcher/internal/watch/WatchInputChange.js +3 -0
  1120. package/lib/launcher/internal/watch/WatchInputChange.js.map +1 -0
  1121. package/lib/launcher/internal/watch/WatchPaths.d.ts +101 -0
  1122. package/lib/launcher/internal/watch/WatchPaths.js +150 -0
  1123. package/lib/launcher/internal/watch/WatchPaths.js.map +1 -0
  1124. package/lib/launcher/internal/watch/WatchTopology.d.ts +384 -0
  1125. package/lib/launcher/internal/{watchTopology.js → watch/WatchTopology.js} +726 -799
  1126. package/lib/launcher/internal/watch/WatchTopology.js.map +1 -0
  1127. package/lib/launcher/internal/watch/literalGlobRoot.d.ts +22 -0
  1128. package/lib/launcher/internal/watch/literalGlobRoot.js +45 -0
  1129. package/lib/launcher/internal/watch/literalGlobRoot.js.map +1 -0
  1130. package/lib/launcher/internal/watch/planCompilerDirectoryWatchEvent.d.ts +40 -0
  1131. package/lib/launcher/internal/watch/planCompilerDirectoryWatchEvent.js +69 -0
  1132. package/lib/launcher/internal/watch/planCompilerDirectoryWatchEvent.js.map +1 -0
  1133. package/lib/launcher/internal/watch/projectInputActiveWatchDirectories.d.ts +19 -0
  1134. package/lib/launcher/internal/watch/projectInputActiveWatchDirectories.js +52 -0
  1135. package/lib/launcher/internal/watch/projectInputActiveWatchDirectories.js.map +1 -0
  1136. package/lib/launcher/internal/watch/projectInputAvailableWatchDirectory.d.ts +21 -0
  1137. package/lib/launcher/internal/watch/projectInputAvailableWatchDirectory.js +55 -0
  1138. package/lib/launcher/internal/watch/projectInputAvailableWatchDirectory.js.map +1 -0
  1139. package/lib/launcher/internal/watch/projectInputEventShouldNotify.d.ts +21 -0
  1140. package/lib/launcher/internal/watch/projectInputEventShouldNotify.js +23 -0
  1141. package/lib/launcher/internal/watch/projectInputEventShouldNotify.js.map +1 -0
  1142. package/lib/launcher/internal/watch/projectInputMembershipInvalidatesProgram.d.ts +27 -0
  1143. package/lib/launcher/internal/watch/projectInputMembershipInvalidatesProgram.js +54 -0
  1144. package/lib/launcher/internal/watch/projectInputMembershipInvalidatesProgram.js.map +1 -0
  1145. package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.d.ts +26 -0
  1146. package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js +100 -0
  1147. package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js.map +1 -0
  1148. package/lib/launcher/internal/watch/projectInputReplacementStrandsWatchers.d.ts +37 -0
  1149. package/lib/launcher/internal/watch/projectInputReplacementStrandsWatchers.js +54 -0
  1150. package/lib/launcher/internal/watch/projectInputReplacementStrandsWatchers.js.map +1 -0
  1151. package/lib/launcher/internal/watch/projectInputTopologyMayAffect.d.ts +23 -0
  1152. package/lib/launcher/internal/watch/projectInputTopologyMayAffect.js +67 -0
  1153. package/lib/launcher/internal/watch/projectInputTopologyMayAffect.js.map +1 -0
  1154. package/lib/launcher/internal/watch/projectInputWatchDirectories.d.ts +22 -0
  1155. package/lib/launcher/internal/watch/projectInputWatchDirectories.js +30 -0
  1156. package/lib/launcher/internal/watch/projectInputWatchDirectories.js.map +1 -0
  1157. package/lib/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.d.ts +22 -0
  1158. package/lib/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.js +45 -0
  1159. package/lib/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.js.map +1 -0
  1160. package/lib/launcher/internal/watch/syncWatchers.d.ts +25 -0
  1161. package/lib/launcher/internal/watch/syncWatchers.js +61 -0
  1162. package/lib/launcher/internal/watch/syncWatchers.js.map +1 -0
  1163. package/lib/launcher/internal/watch/watchDirectory.d.ts +28 -0
  1164. package/lib/launcher/internal/watch/watchDirectory.js +46 -0
  1165. package/lib/launcher/internal/watch/watchDirectory.js.map +1 -0
  1166. package/lib/launcher/internal/watch/watchDirectoryThroughFsWatch.d.ts +28 -0
  1167. package/lib/launcher/internal/watch/watchDirectoryThroughFsWatch.js +38 -0
  1168. package/lib/launcher/internal/watch/watchDirectoryThroughFsWatch.js.map +1 -0
  1169. package/lib/launcher/ttscserver.js +1 -1
  1170. package/lib/launcher/ttscserver.js.map +1 -1
  1171. package/lib/launcher/ttsx.js +2 -3
  1172. package/lib/launcher/ttsx.js.map +1 -1
  1173. package/lib/plugin/CapabilityPluginResolver.d.ts +140 -0
  1174. package/lib/plugin/CapabilityPluginResolver.js +400 -0
  1175. package/lib/plugin/CapabilityPluginResolver.js.map +1 -0
  1176. package/lib/plugin/ITtscCapabilityPlugin.d.ts +87 -0
  1177. package/lib/plugin/ITtscCapabilityPlugin.js +3 -0
  1178. package/lib/plugin/ITtscCapabilityPlugin.js.map +1 -0
  1179. package/lib/plugin/internal/CapabilityPluginResult.d.ts +66 -0
  1180. package/lib/plugin/internal/CapabilityPluginResult.js +86 -0
  1181. package/lib/plugin/internal/CapabilityPluginResult.js.map +1 -0
  1182. package/lib/plugin/internal/CapabilityResolutionFormat.d.ts +114 -0
  1183. package/lib/plugin/internal/CapabilityResolutionFormat.js +229 -0
  1184. package/lib/plugin/internal/CapabilityResolutionFormat.js.map +1 -0
  1185. package/lib/plugin/internal/ITtscCapabilityPluginSource.d.ts +35 -0
  1186. package/lib/plugin/internal/ITtscCapabilityPluginSource.js +3 -0
  1187. package/lib/plugin/internal/ITtscCapabilityPluginSource.js.map +1 -0
  1188. package/lib/plugin/internal/ITtscCapabilityResolutionEntry.d.ts +49 -0
  1189. package/lib/plugin/internal/ITtscCapabilityResolutionEntry.js +3 -0
  1190. package/lib/plugin/internal/ITtscCapabilityResolutionEntry.js.map +1 -0
  1191. package/lib/plugin/internal/ITtscCapabilityResolutionPlugin.d.ts +21 -0
  1192. package/lib/plugin/internal/ITtscCapabilityResolutionPlugin.js +3 -0
  1193. package/lib/plugin/internal/ITtscCapabilityResolutionPlugin.js.map +1 -0
  1194. package/lib/plugin/internal/capabilityPluginWorker.d.ts +1 -0
  1195. package/lib/plugin/internal/capabilityPluginWorker.js +178 -0
  1196. package/lib/plugin/internal/capabilityPluginWorker.js.map +1 -0
  1197. package/lib/plugin/internal/decodeCapabilityCommandReply.d.ts +23 -0
  1198. package/lib/plugin/internal/decodeCapabilityCommandReply.js +25 -0
  1199. package/lib/plugin/internal/decodeCapabilityCommandReply.js.map +1 -0
  1200. package/lib/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.d.ts +15 -0
  1201. package/lib/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.js +182 -0
  1202. package/lib/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.js.map +1 -0
  1203. package/lib/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.d.ts +11 -0
  1204. package/lib/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.js +62 -0
  1205. package/lib/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.js.map +1 -0
  1206. package/lib/plugin/internal/load/PluginDescriptorAdmission.d.ts +46 -0
  1207. package/lib/plugin/internal/load/PluginDescriptorAdmission.js +72 -0
  1208. package/lib/plugin/internal/load/PluginDescriptorAdmission.js.map +1 -0
  1209. package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.d.ts +154 -0
  1210. package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js +317 -0
  1211. package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js.map +1 -0
  1212. package/lib/plugin/internal/load/PluginPackageResolution.d.ts +208 -0
  1213. package/lib/plugin/internal/load/PluginPackageResolution.js +593 -0
  1214. package/lib/plugin/internal/load/PluginPackageResolution.js.map +1 -0
  1215. package/lib/plugin/internal/load/ProjectPluginEntries.d.ts +60 -0
  1216. package/lib/plugin/internal/load/ProjectPluginEntries.js +164 -0
  1217. package/lib/plugin/internal/load/ProjectPluginEntries.js.map +1 -0
  1218. package/lib/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.d.ts +13 -0
  1219. package/lib/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.js +21 -0
  1220. package/lib/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.js.map +1 -0
  1221. package/lib/plugin/internal/load/collectProjectHostInputs.d.ts +16 -0
  1222. package/lib/plugin/internal/load/collectProjectHostInputs.js +66 -0
  1223. package/lib/plugin/internal/load/collectProjectHostInputs.js.map +1 -0
  1224. package/lib/plugin/internal/load/composePluginSources.d.ts +20 -0
  1225. package/lib/plugin/internal/load/composePluginSources.js +95 -0
  1226. package/lib/plugin/internal/load/composePluginSources.js.map +1 -0
  1227. package/lib/plugin/internal/load/declaresHostInputReads.d.ts +24 -0
  1228. package/lib/plugin/internal/load/declaresHostInputReads.js +48 -0
  1229. package/lib/plugin/internal/load/declaresHostInputReads.js.map +1 -0
  1230. package/lib/plugin/internal/load/hasProjectPluginEntries.d.ts +21 -0
  1231. package/lib/plugin/internal/load/hasProjectPluginEntries.js +29 -0
  1232. package/lib/plugin/internal/load/hasProjectPluginEntries.js.map +1 -0
  1233. package/lib/plugin/internal/load/hashHostInputPaths.d.ts +17 -0
  1234. package/lib/plugin/internal/load/hashHostInputPaths.js +46 -0
  1235. package/lib/plugin/internal/load/hashHostInputPaths.js.map +1 -0
  1236. package/lib/plugin/internal/load/isRelativePluginSpecifier.d.ts +22 -0
  1237. package/lib/plugin/internal/load/isRelativePluginSpecifier.js +33 -0
  1238. package/lib/plugin/internal/load/isRelativePluginSpecifier.js.map +1 -0
  1239. package/lib/plugin/internal/load/loadProjectPlugins.d.ts +113 -0
  1240. package/lib/plugin/internal/load/loadProjectPlugins.js +1615 -0
  1241. package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -0
  1242. package/lib/plugin/internal/load/moduleResolutionBaseSelects.d.ts +42 -0
  1243. package/lib/plugin/internal/load/moduleResolutionBaseSelects.js +51 -0
  1244. package/lib/plugin/internal/load/moduleResolutionBaseSelects.js.map +1 -0
  1245. package/lib/plugin/internal/load/observeImportSearchRoots.d.ts +29 -0
  1246. package/lib/plugin/internal/load/observeImportSearchRoots.js +38 -0
  1247. package/lib/plugin/internal/load/observeImportSearchRoots.js.map +1 -0
  1248. package/lib/plugin/internal/load/pluginLabel.d.ts +15 -0
  1249. package/lib/plugin/internal/load/pluginLabel.js +25 -0
  1250. package/lib/plugin/internal/load/pluginLabel.js.map +1 -0
  1251. package/lib/plugin/internal/load/realpathHostInput.d.ts +14 -0
  1252. package/lib/plugin/internal/load/realpathHostInput.js +29 -0
  1253. package/lib/plugin/internal/load/realpathHostInput.js.map +1 -0
  1254. package/lib/plugin/internal/load/realpathHostInputPaths.d.ts +17 -0
  1255. package/lib/plugin/internal/load/realpathHostInputPaths.js +28 -0
  1256. package/lib/plugin/internal/load/realpathHostInputPaths.js.map +1 -0
  1257. package/lib/plugin/internal/load/rejectJsTransformFunctions.d.ts +13 -0
  1258. package/lib/plugin/internal/load/rejectJsTransformFunctions.js +22 -0
  1259. package/lib/plugin/internal/load/rejectJsTransformFunctions.js.map +1 -0
  1260. package/lib/plugin/internal/load/requirePluginSource.d.ts +14 -0
  1261. package/lib/plugin/internal/load/requirePluginSource.js +38 -0
  1262. package/lib/plugin/internal/load/requirePluginSource.js.map +1 -0
  1263. package/lib/plugin/internal/load/resolveNativeSource.d.ts +29 -0
  1264. package/lib/plugin/internal/load/resolveNativeSource.js +37 -0
  1265. package/lib/plugin/internal/load/resolveNativeSource.js.map +1 -0
  1266. package/lib/plugin/internal/load/validatePluginContributors.d.ts +22 -0
  1267. package/lib/plugin/internal/load/validatePluginContributors.js +86 -0
  1268. package/lib/plugin/internal/load/validatePluginContributors.js.map +1 -0
  1269. package/lib/plugin/internal/load/validatePluginSource.d.ts +14 -0
  1270. package/lib/plugin/internal/load/validatePluginSource.js +21 -0
  1271. package/lib/plugin/internal/load/validatePluginSource.js.map +1 -0
  1272. package/lib/plugin/internal/load/visitImportMappedCandidates.d.ts +36 -0
  1273. package/lib/plugin/internal/load/visitImportMappedCandidates.js +45 -0
  1274. package/lib/plugin/internal/load/visitImportMappedCandidates.js.map +1 -0
  1275. package/lib/plugin/internal/pluginDescriptorFailureReason.d.ts +23 -0
  1276. package/lib/plugin/internal/pluginDescriptorFailureReason.js +43 -0
  1277. package/lib/plugin/internal/pluginDescriptorFailureReason.js.map +1 -0
  1278. package/lib/plugin/internal/pluginDescriptorProcessFailure.d.ts +28 -0
  1279. package/lib/plugin/internal/pluginDescriptorProcessFailure.js +37 -0
  1280. package/lib/plugin/internal/pluginDescriptorProcessFailure.js.map +1 -0
  1281. package/lib/plugin/internal/readCapabilityResolution.d.ts +42 -0
  1282. package/lib/plugin/internal/readCapabilityResolution.js +158 -0
  1283. package/lib/plugin/internal/readCapabilityResolution.js.map +1 -0
  1284. package/lib/plugin/internal/receiveCapabilityFailure.d.ts +21 -0
  1285. package/lib/plugin/internal/receiveCapabilityFailure.js +28 -0
  1286. package/lib/plugin/internal/receiveCapabilityFailure.js.map +1 -0
  1287. package/lib/plugin/internal/source/CachePrunePolicy.d.ts +42 -0
  1288. package/lib/plugin/internal/source/CachePrunePolicy.js +47 -0
  1289. package/lib/plugin/internal/source/CachePrunePolicy.js.map +1 -0
  1290. package/lib/plugin/internal/source/GoBuildCacheCoordination.d.ts +159 -0
  1291. package/lib/plugin/internal/source/GoBuildCacheCoordination.js +475 -0
  1292. package/lib/plugin/internal/source/GoBuildCacheCoordination.js.map +1 -0
  1293. package/lib/plugin/internal/source/GoSourceInputs.d.ts +124 -0
  1294. package/lib/plugin/internal/source/GoSourceInputs.js +180 -0
  1295. package/lib/plugin/internal/source/GoSourceInputs.js.map +1 -0
  1296. package/lib/plugin/internal/source/GoToolResolution.d.ts +125 -0
  1297. package/lib/plugin/internal/source/GoToolResolution.js +278 -0
  1298. package/lib/plugin/internal/source/GoToolResolution.js.map +1 -0
  1299. package/lib/plugin/internal/source/IGoBuildCachePruneOptions.d.ts +30 -0
  1300. package/lib/plugin/internal/source/IGoBuildCachePruneOptions.js +3 -0
  1301. package/lib/plugin/internal/source/IGoBuildCachePruneOptions.js.map +1 -0
  1302. package/lib/plugin/internal/source/IPluginCachePruneOptions.d.ts +33 -0
  1303. package/lib/plugin/internal/source/IPluginCachePruneOptions.js +3 -0
  1304. package/lib/plugin/internal/source/IPluginCachePruneOptions.js.map +1 -0
  1305. package/lib/plugin/internal/source/IPluginModuleReplaceDirectory.d.ts +27 -0
  1306. package/lib/plugin/internal/source/IPluginModuleReplaceDirectory.js +3 -0
  1307. package/lib/plugin/internal/source/IPluginModuleReplaceDirectory.js.map +1 -0
  1308. package/lib/plugin/internal/source/ITtscBuildContributor.d.ts +18 -0
  1309. package/lib/plugin/internal/source/ITtscBuildContributor.js +3 -0
  1310. package/lib/plugin/internal/source/ITtscBuildContributor.js.map +1 -0
  1311. package/lib/plugin/internal/source/ITtscSourceBuildCachePaths.d.ts +25 -0
  1312. package/lib/plugin/internal/source/ITtscSourceBuildCachePaths.js +3 -0
  1313. package/lib/plugin/internal/source/ITtscSourceBuildCachePaths.js.map +1 -0
  1314. package/lib/plugin/internal/source/NativeSourcePackages.d.ts +155 -0
  1315. package/lib/plugin/internal/source/NativeSourcePackages.js +317 -0
  1316. package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -0
  1317. package/lib/plugin/internal/source/PluginBinaryUse.d.ts +66 -0
  1318. package/lib/plugin/internal/source/PluginBinaryUse.js +163 -0
  1319. package/lib/plugin/internal/source/PluginBinaryUse.js.map +1 -0
  1320. package/lib/plugin/internal/source/PluginBinaryWaitResult.d.ts +34 -0
  1321. package/lib/plugin/internal/source/PluginBinaryWaitResult.js +3 -0
  1322. package/lib/plugin/internal/source/PluginBinaryWaitResult.js.map +1 -0
  1323. package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.d.ts +90 -0
  1324. package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js +207 -0
  1325. package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js.map +1 -0
  1326. package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.d.ts +128 -0
  1327. package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.js +209 -0
  1328. package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.js.map +1 -0
  1329. package/lib/plugin/internal/source/PluginBuildLockFence.d.ts +25 -0
  1330. package/lib/plugin/internal/source/PluginBuildLockFence.js +3 -0
  1331. package/lib/plugin/internal/source/PluginBuildLockFence.js.map +1 -0
  1332. package/lib/plugin/internal/source/PluginBuildLockLease.d.ts +29 -0
  1333. package/lib/plugin/internal/source/PluginBuildLockLease.js +3 -0
  1334. package/lib/plugin/internal/source/PluginBuildLockLease.js.map +1 -0
  1335. package/lib/plugin/internal/source/PluginBuildLockObservation.d.ts +42 -0
  1336. package/lib/plugin/internal/source/PluginBuildLockObservation.js +3 -0
  1337. package/lib/plugin/internal/source/PluginBuildLockObservation.js.map +1 -0
  1338. package/lib/plugin/internal/source/PluginBuildLockOwner.d.ts +126 -0
  1339. package/lib/plugin/internal/source/PluginBuildLockOwner.js +165 -0
  1340. package/lib/plugin/internal/source/PluginBuildLockOwner.js.map +1 -0
  1341. package/lib/plugin/internal/source/PluginBuildLockProtocol.d.ts +234 -0
  1342. package/lib/plugin/internal/source/PluginBuildLockProtocol.js +287 -0
  1343. package/lib/plugin/internal/source/PluginBuildLockProtocol.js.map +1 -0
  1344. package/lib/plugin/internal/source/SourceBuildCacheLayout.d.ts +183 -0
  1345. package/lib/plugin/internal/source/SourceBuildCacheLayout.js +291 -0
  1346. package/lib/plugin/internal/source/SourceBuildCacheLayout.js.map +1 -0
  1347. package/lib/plugin/internal/source/SourceBuildFilesystemOperations.d.ts +32 -0
  1348. package/lib/plugin/internal/source/SourceBuildFilesystemOperations.js +3 -0
  1349. package/lib/plugin/internal/source/SourceBuildFilesystemOperations.js.map +1 -0
  1350. package/lib/plugin/internal/source/SourcePluginAdmission.d.ts +80 -0
  1351. package/lib/plugin/internal/source/SourcePluginAdmission.js +114 -0
  1352. package/lib/plugin/internal/source/SourcePluginAdmission.js.map +1 -0
  1353. package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +122 -0
  1354. package/lib/plugin/internal/source/SourcePluginWorkspace.js +307 -0
  1355. package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -0
  1356. package/lib/plugin/internal/source/acquirePluginBuildLock.d.ts +35 -0
  1357. package/lib/plugin/internal/source/acquirePluginBuildLock.js +176 -0
  1358. package/lib/plugin/internal/source/acquirePluginBuildLock.js.map +1 -0
  1359. package/lib/plugin/internal/source/autoQuoteGoModToken.d.ts +24 -0
  1360. package/lib/plugin/internal/source/autoQuoteGoModToken.js +110 -0
  1361. package/lib/plugin/internal/source/autoQuoteGoModToken.js.map +1 -0
  1362. package/lib/plugin/internal/source/buildSourcePlugin.d.ts +86 -0
  1363. package/lib/plugin/internal/source/buildSourcePlugin.js +857 -0
  1364. package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -0
  1365. package/lib/plugin/internal/source/collectPluginSourceDirectories.d.ts +30 -0
  1366. package/lib/plugin/internal/source/collectPluginSourceDirectories.js +77 -0
  1367. package/lib/plugin/internal/source/collectPluginSourceDirectories.js.map +1 -0
  1368. package/lib/plugin/internal/source/collectPluginSourceFiles.d.ts +40 -0
  1369. package/lib/plugin/internal/source/collectPluginSourceFiles.js +95 -0
  1370. package/lib/plugin/internal/source/collectPluginSourceFiles.js.map +1 -0
  1371. package/lib/plugin/internal/source/computeCacheKey.d.ts +73 -0
  1372. package/lib/plugin/internal/source/computeCacheKey.js +113 -0
  1373. package/lib/plugin/internal/source/computeCacheKey.js.map +1 -0
  1374. package/lib/plugin/internal/source/copiesPluginSourceEntry.d.ts +33 -0
  1375. package/lib/plugin/internal/source/copiesPluginSourceEntry.js +57 -0
  1376. package/lib/plugin/internal/source/copiesPluginSourceEntry.js.map +1 -0
  1377. package/lib/plugin/internal/source/createExternalSourceSnapshotLayout.d.ts +22 -0
  1378. package/lib/plugin/internal/source/createExternalSourceSnapshotLayout.js +60 -0
  1379. package/lib/plugin/internal/source/createExternalSourceSnapshotLayout.js.map +1 -0
  1380. package/lib/plugin/internal/source/ensureExecutableGoToolchain.d.ts +25 -0
  1381. package/lib/plugin/internal/source/ensureExecutableGoToolchain.js +96 -0
  1382. package/lib/plugin/internal/source/ensureExecutableGoToolchain.js.map +1 -0
  1383. package/lib/plugin/internal/source/formatDuration.d.ts +18 -0
  1384. package/lib/plugin/internal/source/formatDuration.js +36 -0
  1385. package/lib/plugin/internal/source/formatDuration.js.map +1 -0
  1386. package/lib/plugin/internal/source/formatGoWorkPath.d.ts +35 -0
  1387. package/lib/plugin/internal/source/formatGoWorkPath.js +42 -0
  1388. package/lib/plugin/internal/source/formatGoWorkPath.js.map +1 -0
  1389. package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +47 -0
  1390. package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +663 -0
  1391. package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -0
  1392. package/lib/plugin/internal/source/inspectPluginBuildLock.d.ts +29 -0
  1393. package/lib/plugin/internal/source/inspectPluginBuildLock.js +285 -0
  1394. package/lib/plugin/internal/source/inspectPluginBuildLock.js.map +1 -0
  1395. package/lib/plugin/internal/source/isPathWithin.d.ts +16 -0
  1396. package/lib/plugin/internal/source/isPathWithin.js +28 -0
  1397. package/lib/plugin/internal/source/isPathWithin.js.map +1 -0
  1398. package/lib/plugin/internal/source/legacyGlobalCacheTargets.d.ts +24 -0
  1399. package/lib/plugin/internal/source/legacyGlobalCacheTargets.js +60 -0
  1400. package/lib/plugin/internal/source/legacyGlobalCacheTargets.js.map +1 -0
  1401. package/lib/plugin/internal/source/pluginBuildEnvironment.d.ts +31 -0
  1402. package/lib/plugin/internal/source/pluginBuildEnvironment.js +47 -0
  1403. package/lib/plugin/internal/source/pluginBuildEnvironment.js.map +1 -0
  1404. package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.d.ts +1 -0
  1405. package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.js +24 -0
  1406. package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.js.map +1 -0
  1407. package/lib/plugin/internal/source/pluginBuildVersions.d.ts +31 -0
  1408. package/lib/plugin/internal/source/pluginBuildVersions.js +65 -0
  1409. package/lib/plugin/internal/source/pluginBuildVersions.js.map +1 -0
  1410. package/lib/plugin/internal/source/pluginModuleReplaceDirectories.d.ts +40 -0
  1411. package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js +81 -0
  1412. package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js.map +1 -0
  1413. package/lib/plugin/internal/source/pluginSourceCovers.d.ts +32 -0
  1414. package/lib/plugin/internal/source/pluginSourceCovers.js +54 -0
  1415. package/lib/plugin/internal/source/pluginSourceCovers.js.map +1 -0
  1416. package/lib/plugin/internal/source/pluginSourceDigest.d.ts +40 -0
  1417. package/lib/plugin/internal/source/pluginSourceDigest.js +60 -0
  1418. package/lib/plugin/internal/source/pluginSourceDigest.js.map +1 -0
  1419. package/lib/plugin/internal/source/pluginSourceFilesSignature.d.ts +38 -0
  1420. package/lib/plugin/internal/source/pluginSourceFilesSignature.js +53 -0
  1421. package/lib/plugin/internal/source/pluginSourceFilesSignature.js.map +1 -0
  1422. package/lib/plugin/internal/source/pluginSourceState.d.ts +47 -0
  1423. package/lib/plugin/internal/source/pluginSourceState.js +63 -0
  1424. package/lib/plugin/internal/source/pluginSourceState.js.map +1 -0
  1425. package/lib/plugin/internal/source/pluginSourceStateHolds.d.ts +34 -0
  1426. package/lib/plugin/internal/source/pluginSourceStateHolds.js +45 -0
  1427. package/lib/plugin/internal/source/pluginSourceStateHolds.js.map +1 -0
  1428. package/lib/plugin/internal/source/processPluginBuildEnvironment.d.ts +33 -0
  1429. package/lib/plugin/internal/source/processPluginBuildEnvironment.js +40 -0
  1430. package/lib/plugin/internal/source/processPluginBuildEnvironment.js.map +1 -0
  1431. package/lib/plugin/internal/source/pruneCacheFileRoot.d.ts +34 -0
  1432. package/lib/plugin/internal/source/pruneCacheFileRoot.js +120 -0
  1433. package/lib/plugin/internal/source/pruneCacheFileRoot.js.map +1 -0
  1434. package/lib/plugin/internal/source/pruneGoBuildCacheRoot.d.ts +28 -0
  1435. package/lib/plugin/internal/source/pruneGoBuildCacheRoot.js +185 -0
  1436. package/lib/plugin/internal/source/pruneGoBuildCacheRoot.js.map +1 -0
  1437. package/lib/plugin/internal/source/prunePluginCacheRoot.d.ts +46 -0
  1438. package/lib/plugin/internal/source/prunePluginCacheRoot.js +446 -0
  1439. package/lib/plugin/internal/source/prunePluginCacheRoot.js.map +1 -0
  1440. package/lib/plugin/internal/source/prunesPluginSourceDirectory.d.ts +21 -0
  1441. package/lib/plugin/internal/source/prunesPluginSourceDirectory.js +28 -0
  1442. package/lib/plugin/internal/source/prunesPluginSourceDirectory.js.map +1 -0
  1443. package/lib/plugin/internal/source/reclaimPluginBuildLock.d.ts +23 -0
  1444. package/lib/plugin/internal/source/reclaimPluginBuildLock.js +48 -0
  1445. package/lib/plugin/internal/source/reclaimPluginBuildLock.js.map +1 -0
  1446. package/lib/plugin/internal/source/recordCacheFileUse.d.ts +22 -0
  1447. package/lib/plugin/internal/source/recordCacheFileUse.js +43 -0
  1448. package/lib/plugin/internal/source/recordCacheFileUse.js.map +1 -0
  1449. package/lib/plugin/internal/source/releasePluginBuildLock.d.ts +33 -0
  1450. package/lib/plugin/internal/source/releasePluginBuildLock.js +100 -0
  1451. package/lib/plugin/internal/source/releasePluginBuildLock.js.map +1 -0
  1452. package/lib/plugin/internal/source/resolveCleanTargets.d.ts +26 -0
  1453. package/lib/plugin/internal/source/resolveCleanTargets.js +73 -0
  1454. package/lib/plugin/internal/source/resolveCleanTargets.js.map +1 -0
  1455. package/lib/plugin/internal/source/resolveGoCompiler.d.ts +29 -0
  1456. package/lib/plugin/internal/source/resolveGoCompiler.js +62 -0
  1457. package/lib/plugin/internal/source/resolveGoCompiler.js.map +1 -0
  1458. package/lib/plugin/internal/source/resolvePluginCacheRoot.d.ts +21 -0
  1459. package/lib/plugin/internal/source/resolvePluginCacheRoot.js +31 -0
  1460. package/lib/plugin/internal/source/resolvePluginCacheRoot.js.map +1 -0
  1461. package/lib/plugin/internal/source/resolvePluginGoModule.d.ts +34 -0
  1462. package/lib/plugin/internal/source/resolvePluginGoModule.js +65 -0
  1463. package/lib/plugin/internal/source/resolvePluginGoModule.js.map +1 -0
  1464. package/lib/plugin/internal/source/resolveSourceBuildCachePaths.d.ts +21 -0
  1465. package/lib/plugin/internal/source/resolveSourceBuildCachePaths.js +236 -0
  1466. package/lib/plugin/internal/source/resolveSourceBuildCachePaths.js.map +1 -0
  1467. package/lib/plugin/internal/source/selectPluginModuleReplaceDirectories.d.ts +29 -0
  1468. package/lib/plugin/internal/source/selectPluginModuleReplaceDirectories.js +68 -0
  1469. package/lib/plugin/internal/source/selectPluginModuleReplaceDirectories.js.map +1 -0
  1470. package/lib/plugin/internal/source/spawnGoTool.d.ts +22 -0
  1471. package/lib/plugin/internal/source/spawnGoTool.js +164 -0
  1472. package/lib/plugin/internal/source/spawnGoTool.js.map +1 -0
  1473. package/lib/plugin/internal/source/touchPluginCacheEntryInUse.d.ts +27 -0
  1474. package/lib/plugin/internal/source/touchPluginCacheEntryInUse.js +48 -0
  1475. package/lib/plugin/internal/source/touchPluginCacheEntryInUse.js.map +1 -0
  1476. package/lib/plugin/internal/source/waitForPluginBinary.d.ts +36 -0
  1477. package/lib/plugin/internal/source/waitForPluginBinary.js +94 -0
  1478. package/lib/plugin/internal/source/waitForPluginBinary.js.map +1 -0
  1479. package/lib/plugin/internal/source/windowsGoCommandArgs.d.ts +17 -0
  1480. package/lib/plugin/internal/source/windowsGoCommandArgs.js +23 -0
  1481. package/lib/plugin/internal/source/windowsGoCommandArgs.js.map +1 -0
  1482. package/lib/plugin/internal/source/withGoBuildCacheLease.d.ts +37 -0
  1483. package/lib/plugin/internal/source/withGoBuildCacheLease.js +87 -0
  1484. package/lib/plugin/internal/source/withGoBuildCacheLease.js.map +1 -0
  1485. package/lib/plugin/internal/writeCapabilityResolution.d.ts +80 -0
  1486. package/lib/plugin/internal/writeCapabilityResolution.js +196 -0
  1487. package/lib/plugin/internal/writeCapabilityResolution.js.map +1 -0
  1488. package/lib/plugin/resolveCapabilityPlugins.d.ts +53 -32
  1489. package/lib/plugin/resolveCapabilityPlugins.js +209 -38
  1490. package/lib/plugin/resolveCapabilityPlugins.js.map +1 -1
  1491. package/lib/register.js +20 -5
  1492. package/lib/register.js.map +1 -1
  1493. package/lib/structures/ITtscCompilerContext.d.ts +29 -11
  1494. package/lib/structures/ITtscCompilerDiagnostic.d.ts +24 -7
  1495. package/lib/structures/ITtscCompilerResult.d.ts +75 -25
  1496. package/lib/structures/ITtscCompilerTransformation.d.ts +287 -64
  1497. package/lib/structures/ITtscPlugin.d.ts +24 -8
  1498. package/lib/structures/ITtscPluginCapabilities.d.ts +55 -5
  1499. package/lib/structures/ITtscPluginContributor.d.ts +19 -8
  1500. package/lib/structures/ITtscPluginFactoryContext.d.ts +12 -3
  1501. package/lib/structures/ITtscProjectPluginConfig.d.ts +35 -10
  1502. package/lib/structures/TtscPluginStage.d.ts +9 -0
  1503. package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +19 -5
  1504. package/lib/structures/internal/ITtscParsedProjectConfig.d.ts +29 -3
  1505. package/lib/structures/internal/ITtscProjectIdentity.d.ts +21 -6
  1506. package/lib/structures/internal/ITtscProjectInputSnapshot.d.ts +23 -8
  1507. package/lib/structures/internal/ITtscProjectLocatorOptions.d.ts +18 -4
  1508. package/lib/structures/internal/TtscBuildOptions.d.ts +33 -14
  1509. package/lib/structures/internal/TtscBuildResult.d.ts +63 -4
  1510. package/lib/structures/internal/TtscCommonOptions.d.ts +47 -14
  1511. package/lib/structures/internal/TtscSingleFileEmitOptions.d.ts +46 -5
  1512. package/package.json +26 -12
  1513. package/shim/ast/enums_gen.go +4 -2
  1514. package/shim/ast/go.mod +5 -5
  1515. package/shim/ast/go.sum +10 -10
  1516. package/shim/ast/lint.go +1088 -20
  1517. package/shim/ast/parent.go +38 -22
  1518. package/shim/ast/safe_text.go +48 -26
  1519. package/shim/ast/shim.go +1307 -20
  1520. package/shim/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
  1521. package/shim/ast/test/node_text_joins_multi_hop_qualified_name_test.go +24 -9
  1522. package/shim/ast/test/node_text_joins_one_hop_qualified_name_test.go +9 -5
  1523. package/shim/ast/test/node_text_returns_empty_for_nil_test.go +13 -5
  1524. package/shim/ast/test/node_text_returns_identifier_text_test.go +12 -5
  1525. package/shim/ast/test/node_text_skips_empty_qualified_left_test.go +35 -5
  1526. package/shim/astnav/go.mod +5 -5
  1527. package/shim/astnav/go.sum +12 -10
  1528. package/shim/astnav/shim.go +9 -0
  1529. package/shim/bundled/go.mod +7 -1
  1530. package/shim/bundled/go.sum +12 -0
  1531. package/shim/checker/enums_gen.go +4 -2
  1532. package/shim/checker/extra-shim.json +6 -0
  1533. package/shim/checker/go.mod +5 -5
  1534. package/shim/checker/go.sum +10 -10
  1535. package/shim/checker/node_builder_fields_gen.go +19 -0
  1536. package/shim/checker/shim.go +827 -114
  1537. package/shim/compiler/emit_sourcemap.go +68 -29
  1538. package/shim/compiler/emitassemble.go +36 -2
  1539. package/shim/compiler/emithook.go +13 -3
  1540. package/shim/compiler/go.mod +5 -5
  1541. package/shim/compiler/go.sum +10 -10
  1542. package/shim/compiler/incremental.go +56 -20
  1543. package/shim/compiler/resolution.go +92 -9
  1544. package/shim/core/enums_gen.go +2 -2
  1545. package/shim/core/go.mod +6 -1
  1546. package/shim/core/go.sum +10 -0
  1547. package/shim/core/modulekind.go +9 -0
  1548. package/shim/core/shim.go +157 -6
  1549. package/shim/diagnosticwriter/go.mod +10 -1
  1550. package/shim/diagnosticwriter/go.sum +20 -0
  1551. package/shim/diagnosticwriter/lint.go +188 -10
  1552. package/shim/diagnosticwriter/shim.go +14 -0
  1553. package/shim/lsp/go.mod +5 -5
  1554. package/shim/lsp/go.sum +10 -10
  1555. package/shim/lsp/shim.go +78 -2
  1556. package/shim/parser/go.mod +10 -1
  1557. package/shim/parser/go.sum +22 -0
  1558. package/shim/printer/emithost.go +46 -1
  1559. package/shim/printer/go.mod +5 -5
  1560. package/shim/printer/go.sum +10 -10
  1561. package/shim/printer/shim.go +114 -7
  1562. package/shim/printer/sourcemap.go +55 -0
  1563. package/shim/scanner/go.mod +10 -1
  1564. package/shim/scanner/go.sum +20 -0
  1565. package/shim/scanner/regexp.go +19 -4
  1566. package/shim/scanner/shim.go +3 -0
  1567. package/shim/stringutil/extra-shim.json +1 -0
  1568. package/shim/stringutil/go.mod +5 -0
  1569. package/shim/stringutil/go.sum +2 -0
  1570. package/shim/stringutil/shim.go +119 -0
  1571. package/shim/transformers/go.mod +5 -5
  1572. package/shim/transformers/go.sum +12 -10
  1573. package/shim/transformers/shim.go +12 -3
  1574. package/shim/tsoptions/command_line_raw.go +44 -0
  1575. package/shim/tsoptions/go.mod +10 -1
  1576. package/shim/tsoptions/go.sum +22 -0
  1577. package/shim/tsoptions/shim.go +1 -1
  1578. package/shim/tspath/go.mod +1 -1
  1579. package/shim/tspath/go.sum +6 -0
  1580. package/shim/vfs/cachedvfs/go.mod +3 -1
  1581. package/shim/vfs/cachedvfs/go.sum +12 -0
  1582. package/shim/vfs/decode.go +26 -0
  1583. package/shim/vfs/decode_test.go +42 -0
  1584. package/shim/vfs/go.mod +7 -1
  1585. package/shim/vfs/go.sum +12 -0
  1586. package/shim/vfs/osvfs/go.mod +7 -1
  1587. package/shim/vfs/osvfs/go.sum +12 -0
  1588. package/src/TtscCompiler.ts +223 -234
  1589. package/src/TtscService.ts +87 -31
  1590. package/src/TtscServiceRequestOptions.ts +21 -0
  1591. package/src/compiler/internal/CapturedProcessOutput.ts +69 -0
  1592. package/src/compiler/internal/CompilerArgumentsInspection.ts +184 -0
  1593. package/src/compiler/internal/EmitOwnershipIndex.ts +254 -0
  1594. package/src/compiler/internal/PrivateCompilerOutput.ts +330 -0
  1595. package/src/compiler/internal/ResidentCheckProcess.ts +445 -0
  1596. package/src/compiler/internal/ResidentCheckProcessOptions.ts +32 -0
  1597. package/src/compiler/internal/ResidentCheckRequest.ts +39 -0
  1598. package/src/compiler/internal/ResidentCheckResult.ts +24 -0
  1599. package/src/compiler/internal/ResidentCheckTelemetry.ts +36 -0
  1600. package/src/compiler/internal/ResidentReplyKind.ts +18 -0
  1601. package/src/compiler/internal/ResidentTransformProcess.ts +299 -0
  1602. package/src/compiler/internal/ResidentTransformProcessOptions.ts +30 -0
  1603. package/src/compiler/internal/ResidentTransformReply.ts +79 -0
  1604. package/src/compiler/internal/ResidentTransformRequestOptions.ts +16 -0
  1605. package/src/compiler/internal/ResidentTransformRequests.ts +198 -0
  1606. package/src/compiler/internal/StartedResidentTransform.ts +29 -0
  1607. package/src/compiler/internal/TransformProjectWorkerReply.ts +37 -0
  1608. package/src/compiler/internal/TransformProjectWorkerRequest.ts +42 -0
  1609. package/src/compiler/internal/build/BuildExecution.ts +1261 -0
  1610. package/src/compiler/internal/build/BuildTiming.ts +145 -0
  1611. package/src/compiler/internal/build/CompilerDiagnostics.ts +307 -0
  1612. package/src/compiler/internal/build/NativePluginArguments.ts +302 -0
  1613. package/src/compiler/internal/build/PassthroughFlags.ts +229 -0
  1614. package/src/compiler/internal/build/PluginFailureDiagnostics.ts +70 -0
  1615. package/src/compiler/internal/build/ResidentCheckEntryPlan.ts +42 -0
  1616. package/src/compiler/internal/build/ResidentCheckWatchChange.ts +33 -0
  1617. package/src/compiler/internal/build/ResidentCheckWatchSession.ts +501 -0
  1618. package/src/compiler/internal/build/RunBuildOptions.ts +145 -0
  1619. package/src/compiler/internal/build/TsgoArguments.ts +349 -0
  1620. package/src/compiler/internal/build/appendBuildOutput.ts +218 -0
  1621. package/src/compiler/internal/build/bufferResidentCheckEntryRequests.ts +52 -0
  1622. package/src/compiler/internal/build/createProcessDiagnostic.ts +32 -0
  1623. package/src/compiler/internal/build/isAbsoluteLocalProjectInputPath.ts +55 -0
  1624. package/src/compiler/internal/build/mergeProjectInputSnapshots.ts +147 -0
  1625. package/src/compiler/internal/build/normalizeBuildOutput.ts +89 -0
  1626. package/src/compiler/internal/build/parseProjectInputSnapshot.ts +91 -0
  1627. package/src/compiler/internal/build/planResidentCheckEntries.ts +55 -0
  1628. package/src/compiler/internal/build/privateRuntimeRootDir.ts +33 -0
  1629. package/src/compiler/internal/build/residentCheckRequest.ts +41 -0
  1630. package/src/compiler/internal/build/runBuild.ts +61 -0
  1631. package/src/compiler/internal/build/runExternalEmitProvenance.ts +566 -0
  1632. package/src/compiler/internal/build/takeResidentCheckEntryRequest.ts +31 -0
  1633. package/src/compiler/internal/buildNativeCompiler.ts +19 -2
  1634. package/src/compiler/internal/captureProcessOutput.ts +37 -39
  1635. package/src/compiler/internal/compileProjectInMemory.ts +139 -92
  1636. package/src/compiler/internal/ensureExecutable.ts +32 -0
  1637. package/src/compiler/internal/findNearestGoMod.ts +43 -0
  1638. package/src/compiler/internal/isOutsideRelativePath.ts +26 -0
  1639. package/src/compiler/internal/outputText.ts +21 -0
  1640. package/src/compiler/internal/packageRootDir.ts +43 -0
  1641. package/src/compiler/internal/parseNativeTransformOutput.ts +722 -0
  1642. package/src/compiler/internal/project/CompilerProjectSelection.ts +204 -0
  1643. package/src/compiler/internal/project/ConfigJsonText.ts +55 -0
  1644. package/src/compiler/internal/project/compilerUsesCaseSensitiveFileNames.ts +124 -0
  1645. package/src/compiler/internal/project/createNativeProjectContextArgs.ts +14 -19
  1646. package/src/compiler/internal/project/createNativeProjectContextJson.ts +28 -0
  1647. package/src/compiler/internal/project/parseJsonc.ts +318 -0
  1648. package/src/compiler/internal/project/readJsonFile.ts +34 -0
  1649. package/src/compiler/internal/project/readJsoncFile.ts +46 -0
  1650. package/src/compiler/internal/project/readProjectConfig.ts +137 -200
  1651. package/src/compiler/internal/project/resolveOwningProjectConfig.ts +278 -0
  1652. package/src/compiler/internal/project/resolveProjectConfig.ts +18 -127
  1653. package/src/compiler/internal/project/resolveProjectIdentity.ts +153 -0
  1654. package/src/compiler/internal/project/resolveTsconfigExtends.ts +175 -0
  1655. package/src/compiler/internal/project/selectReferencedProject.ts +54 -0
  1656. package/src/compiler/internal/project/tsconfigExtendsFileCandidates.ts +54 -0
  1657. package/src/compiler/internal/readEffectiveCompilerOptions.ts +126 -0
  1658. package/src/compiler/internal/resolveBinary.ts +25 -9
  1659. package/src/compiler/internal/resolveTsgo.ts +31 -11
  1660. package/src/compiler/internal/runNativeCheckWithObservations.ts +211 -0
  1661. package/src/compiler/internal/runSingleFileEmit.ts +92 -27
  1662. package/src/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.ts +2 -0
  1663. package/src/compiler/internal/sharedHost/SidecarEnvironment.ts +151 -0
  1664. package/src/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.ts +7 -0
  1665. package/src/compiler/internal/sharedHost/TSGO_ARGS_ENV.ts +7 -0
  1666. package/src/compiler/internal/sharedHost/assertSharedHostCompatibility.ts +48 -0
  1667. package/src/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.ts +27 -0
  1668. package/src/compiler/internal/sharedHost/clearInheritedTsgoArgs.ts +41 -0
  1669. package/src/compiler/internal/sharedHost/inheritedSidecarEnv.ts +45 -0
  1670. package/src/compiler/internal/sharedHost/isLinkedTransform.ts +19 -0
  1671. package/src/compiler/internal/sharedHost/linkedTransformPlugins.ts +25 -0
  1672. package/src/compiler/internal/sharedHost/publishLinkedTransformPlugins.ts +42 -0
  1673. package/src/compiler/internal/sharedHost/resolvePluginConfigDir.ts +33 -0
  1674. package/src/compiler/internal/sharedHost/selectSharedHostPlugin.ts +35 -0
  1675. package/src/compiler/internal/spawnNative.ts +16 -39
  1676. package/src/compiler/internal/startResidentTransform.ts +66 -53
  1677. package/src/compiler/internal/transformProjectInMemory.ts +347 -635
  1678. package/src/compiler/internal/transformProjectInWorker.ts +170 -0
  1679. package/src/compiler/internal/transformProjectWorker.ts +43 -0
  1680. package/src/flags/AnySubcommand.ts +19 -0
  1681. package/src/flags/COMPILER_ENUM_WHITESPACE.ts +35 -0
  1682. package/src/flags/COMPILER_OPTIONS.ts +512 -0
  1683. package/src/flags/COMPILER_OPTION_ASCII_FOLDS.ts +13 -0
  1684. package/src/flags/COMPILER_OPTION_KINDS.ts +14 -0
  1685. package/src/flags/CompilerOptionSpec.ts +30 -0
  1686. package/src/flags/FLAG_BY_TOKEN.ts +40 -0
  1687. package/src/flags/{schema.ts → FLAG_SCHEMA.ts} +43 -318
  1688. package/src/flags/FlagKind.ts +22 -0
  1689. package/src/flags/FlagLayer.ts +24 -0
  1690. package/src/flags/FlagSpec.ts +118 -0
  1691. package/src/flags/ParseOptions.ts +103 -0
  1692. package/src/flags/ParseResult.ts +44 -0
  1693. package/src/flags/TtscSubcommand.ts +22 -0
  1694. package/src/flags/TtsxSubcommand.ts +13 -0
  1695. package/src/flags/ValueValidator.ts +14 -0
  1696. package/src/flags/buildGoAllowList.ts +43 -0
  1697. package/src/flags/flagsForSubcommand.ts +22 -0
  1698. package/src/flags/getBoolean.ts +27 -0
  1699. package/src/flags/getNumber.ts +24 -0
  1700. package/src/flags/getString.ts +24 -0
  1701. package/src/flags/getStringList.ts +24 -0
  1702. package/src/flags/normalizeCompilerEnumValue.ts +41 -0
  1703. package/src/flags/normalizeFlagToken.ts +38 -0
  1704. package/src/flags/parseFlags.ts +371 -0
  1705. package/src/flags/readCompilerOptionOccurrence.ts +107 -0
  1706. package/src/flags/readCompilerOptionValues.ts +68 -0
  1707. package/src/flags/resolveFlagSpec.ts +29 -0
  1708. package/src/index.ts +9 -3
  1709. package/src/internal/CanonicalTempDirectoryOperations.ts +73 -0
  1710. package/src/internal/CompilerContextSnapshot.ts +139 -0
  1711. package/src/internal/CompilerResultAdapter.ts +320 -0
  1712. package/src/internal/E2ETrace.ts +674 -0
  1713. package/src/internal/IJavaScriptRuntimeCapabilities.ts +50 -0
  1714. package/src/internal/OwnedNativeProcess.ts +417 -0
  1715. package/src/internal/OwnedSynchronousProcess.ts +220 -0
  1716. package/src/internal/RetireLockDirectoryOperations.ts +81 -0
  1717. package/src/internal/SafeCacheCleanupTarget.ts +41 -0
  1718. package/src/internal/SourceNativeRetirement.ts +1109 -0
  1719. package/src/internal/SpawnSyncOutputFiles.ts +29 -0
  1720. package/src/internal/cacheEntryExists.ts +24 -0
  1721. package/src/internal/createCanonicalTempDirectory.ts +35 -18
  1722. package/src/internal/isContendedCandidateRename.ts +35 -0
  1723. package/src/internal/isSpawnSyncFdExhaustion.ts +19 -0
  1724. package/src/internal/javascriptRuntimeCapabilities.ts +166 -0
  1725. package/src/internal/nativeBinary.ts +11 -0
  1726. package/src/internal/parseWindowsDirectoryCaseSensitivity.ts +50 -0
  1727. package/src/internal/pathIdentity/FilesystemPathIdentity.ts +44 -0
  1728. package/src/internal/pathIdentity/FilesystemPathIdentityContext.ts +182 -0
  1729. package/src/internal/pathIdentity/FilesystemPathIdentityOperations.ts +106 -0
  1730. package/src/internal/pathIdentity/ProjectInputPathIdentity.ts +21 -0
  1731. package/src/internal/pathIdentity/ProjectInputPathIdentityContext.ts +21 -0
  1732. package/src/internal/pathIdentity/ProjectInputPathIdentityOperations.ts +22 -0
  1733. package/src/internal/pathIdentity/createFilesystemPathIdentityContext.ts +437 -0
  1734. package/src/internal/pathIdentity/createProjectInputPathIdentityContext.ts +34 -0
  1735. package/src/internal/pathIdentity/isFilesystemPathIdentityWithin.ts +32 -0
  1736. package/src/internal/pathIdentity/isProjectInputPathIdentityWithin.ts +22 -0
  1737. package/src/internal/pathIdentity/resolveFilesystemPath.ts +43 -0
  1738. package/src/internal/pathIdentity/resolvePhysicalPath.ts +31 -0
  1739. package/src/internal/pathIdentity/resolveProjectInputPath.ts +18 -0
  1740. package/src/internal/pluginSource.ts +26 -0
  1741. package/src/internal/projectInputPathIdentity.ts +26 -387
  1742. package/src/internal/resolveNodeBinary.ts +13 -165
  1743. package/src/internal/resolveSafeCacheCleanupTargets.ts +51 -19
  1744. package/src/internal/restoreCompilerError.ts +175 -0
  1745. package/src/internal/retireLockDirectory.ts +166 -0
  1746. package/src/internal/runHoldingLock.ts +55 -0
  1747. package/src/internal/runtimeExecutableIdentity.ts +212 -0
  1748. package/src/internal/serializeCompilerError.ts +145 -0
  1749. package/src/internal/spawnSyncResilient.ts +36 -182
  1750. package/src/internal/spawnSyncWithLowDescriptors.ts +227 -0
  1751. package/src/internal/tsconfig.ts +16 -0
  1752. package/src/launcher/internal/PendingResidentCheckWatchChanges.ts +94 -0
  1753. package/src/launcher/internal/TtscBuildMode.ts +14 -0
  1754. package/src/launcher/internal/TtsxEntryOptions.ts +92 -0
  1755. package/src/launcher/internal/assertNoSolutionBuild.ts +17 -10
  1756. package/src/launcher/internal/assertTtsxNoWatch.ts +49 -0
  1757. package/src/launcher/internal/buildSingleRootProject.ts +303 -0
  1758. package/src/launcher/internal/getCompilerVersionText.ts +20 -5
  1759. package/src/launcher/internal/inlineServedSourceMap.ts +294 -0
  1760. package/src/launcher/internal/linkVirtualEntry.ts +88 -0
  1761. package/src/launcher/internal/{commonJsExportMetadata.ts → parseCommonJsExports.ts} +12 -2
  1762. package/src/launcher/internal/parseTtscBuildArgs.ts +103 -0
  1763. package/src/launcher/internal/parseTtsxCLI.ts +183 -0
  1764. package/src/launcher/internal/prepareExecution.ts +474 -362
  1765. package/src/launcher/internal/prepareTtscBuildMode.ts +64 -0
  1766. package/src/launcher/internal/resolveCacheDir.ts +12 -3
  1767. package/src/launcher/internal/resolveSingleFileOutput.ts +145 -0
  1768. package/src/launcher/internal/resolveTtscserverBinary.ts +20 -5
  1769. package/src/launcher/internal/runTtsc.ts +394 -326
  1770. package/src/launcher/internal/runTtsx.ts +349 -151
  1771. package/src/launcher/internal/runtime/CommonJsRuntimeSource.ts +365 -0
  1772. package/src/launcher/internal/runtime/DependencyBuildAdmission.ts +159 -0
  1773. package/src/launcher/internal/runtime/DependencyBuildGeneration.ts +236 -0
  1774. package/src/launcher/internal/runtime/DependencyBuildLockFence.ts +22 -0
  1775. package/src/launcher/internal/runtime/DependencyBuildLockLease.ts +22 -0
  1776. package/src/launcher/internal/runtime/DependencyBuildLockObservation.ts +49 -0
  1777. package/src/launcher/internal/runtime/DependencyBuildLockProtocol.ts +137 -0
  1778. package/src/launcher/internal/runtime/OwnedProjectSource.ts +140 -0
  1779. package/src/launcher/internal/runtime/OwningModuleOptions.ts +22 -0
  1780. package/src/launcher/internal/runtime/PluginDescriptorInputObservation.ts +112 -0
  1781. package/src/launcher/internal/runtime/ProcessOwnedDirectory.ts +325 -0
  1782. package/src/launcher/internal/runtime/ResolveResult.ts +26 -0
  1783. package/src/launcher/internal/runtime/RuntimeEmitProvenance.ts +58 -0
  1784. package/src/launcher/internal/runtime/RuntimeEntryPreparer.ts +23 -0
  1785. package/src/launcher/internal/runtime/RuntimeFilesystem.ts +64 -0
  1786. package/src/launcher/internal/runtime/RuntimeHookOptions.ts +23 -0
  1787. package/src/launcher/internal/runtime/RuntimeIsolatedEmit.ts +88 -0
  1788. package/src/launcher/internal/runtime/RuntimeLoaderCapabilities.ts +256 -0
  1789. package/src/launcher/internal/runtime/RuntimeManifest.ts +77 -0
  1790. package/src/launcher/internal/runtime/RuntimeManifestRegistry.ts +309 -0
  1791. package/src/launcher/internal/runtime/RuntimeModuleFormat.ts +275 -0
  1792. package/src/launcher/internal/runtime/RuntimeProjectOwnership.ts +139 -0
  1793. package/src/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.ts +11 -0
  1794. package/src/launcher/internal/runtime/acquireDependencyBuildLock.ts +97 -0
  1795. package/src/launcher/internal/runtime/checkNodeRuntimeSupport.ts +94 -0
  1796. package/src/launcher/internal/runtime/claimRuntimeProjectDirectory.ts +54 -0
  1797. package/src/launcher/internal/runtime/commonJsExportNames.ts +57 -0
  1798. package/src/launcher/internal/runtime/commonJsImportFacade.ts +62 -0
  1799. package/src/launcher/internal/runtime/dependencyCacheKey.ts +82 -0
  1800. package/src/launcher/internal/runtime/dependencyCacheRoot.ts +112 -0
  1801. package/src/launcher/internal/runtime/inspectDependencyBuildLock.ts +162 -0
  1802. package/src/launcher/internal/runtime/installRuntimeHooks.ts +2442 -0
  1803. package/src/launcher/internal/runtime/interopProbe.ts +8 -0
  1804. package/src/launcher/internal/runtime/isLocalProcessGone.ts +67 -0
  1805. package/src/launcher/internal/runtime/observeMappedDescriptorResolution.ts +74 -0
  1806. package/src/launcher/internal/runtime/projectModuleOptions.ts +28 -0
  1807. package/src/launcher/internal/runtime/readDependencyCache.ts +89 -0
  1808. package/src/launcher/internal/runtime/realPath.ts +30 -0
  1809. package/src/launcher/internal/runtime/reclaimDependencyBuildLock.ts +27 -0
  1810. package/src/launcher/internal/runtime/releaseDependencyBuildLock.ts +27 -0
  1811. package/src/launcher/internal/runtime/resolveRuntimeCleanTargets.ts +93 -0
  1812. package/src/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.ts +32 -0
  1813. package/src/launcher/internal/runtime/runtimeRunKey.ts +31 -0
  1814. package/src/launcher/internal/runtime/selectRuntimePluginPolicy.ts +28 -0
  1815. package/src/launcher/internal/runtime/withRuntimeDirectoryLock.ts +92 -0
  1816. package/src/launcher/internal/runtimeCompilerArgs.ts +91 -62
  1817. package/src/launcher/internal/runtimeEmitProfile.ts +70 -0
  1818. package/src/launcher/internal/runtimeHookPreload.ts +3 -3
  1819. package/src/launcher/internal/runtimeOwnerPreload.ts +43 -0
  1820. package/src/launcher/internal/singleRootProjectConfig.ts +38 -0
  1821. package/src/launcher/internal/ttscserver/ILSPPluginSelectionInputs.ts +65 -0
  1822. package/src/launcher/internal/ttscserver/LSPProjectInputDigest.ts +331 -0
  1823. package/src/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.ts +107 -0
  1824. package/src/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.ts +41 -0
  1825. package/src/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.ts +36 -0
  1826. package/src/launcher/internal/ttscserver/materializeLSPPluginManifest.ts +60 -0
  1827. package/src/launcher/internal/ttscserver/needsStdio.ts +32 -0
  1828. package/src/launcher/internal/ttscserver/runTtscserver.ts +592 -0
  1829. package/src/launcher/internal/watch/CompilerDirectoryWatchEventPlan.ts +31 -0
  1830. package/src/launcher/internal/watch/DirectoryWatcher.ts +45 -0
  1831. package/src/launcher/internal/watch/FseventsStreams.ts +303 -0
  1832. package/src/launcher/internal/watch/ProjectInputWatchRules.ts +179 -0
  1833. package/src/launcher/internal/watch/WatchInputChange.ts +31 -0
  1834. package/src/launcher/internal/watch/WatchPaths.ts +156 -0
  1835. package/src/launcher/internal/{watchTopology.ts → watch/WatchTopology.ts} +867 -962
  1836. package/src/launcher/internal/watch/literalGlobRoot.ts +40 -0
  1837. package/src/launcher/internal/watch/planCompilerDirectoryWatchEvent.ts +83 -0
  1838. package/src/launcher/internal/watch/projectInputActiveWatchDirectories.ts +47 -0
  1839. package/src/launcher/internal/watch/projectInputAvailableWatchDirectory.ts +56 -0
  1840. package/src/launcher/internal/watch/projectInputEventShouldNotify.ts +23 -0
  1841. package/src/launcher/internal/watch/projectInputMembershipInvalidatesProgram.ts +63 -0
  1842. package/src/launcher/internal/watch/projectInputReloadEventShouldNotify.ts +127 -0
  1843. package/src/launcher/internal/watch/projectInputReplacementStrandsWatchers.ts +57 -0
  1844. package/src/launcher/internal/watch/projectInputTopologyMayAffect.ts +73 -0
  1845. package/src/launcher/internal/watch/projectInputWatchDirectories.ts +33 -0
  1846. package/src/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.ts +49 -0
  1847. package/src/launcher/internal/watch/syncWatchers.ts +64 -0
  1848. package/src/launcher/internal/watch/watchDirectory.ts +53 -0
  1849. package/src/launcher/internal/watch/watchDirectoryThroughFsWatch.ts +47 -0
  1850. package/src/launcher/ttscserver.ts +1 -1
  1851. package/src/launcher/ttsx.ts +2 -3
  1852. package/src/plugin/CapabilityPluginResolver.ts +549 -0
  1853. package/src/plugin/ITtscCapabilityPlugin.ts +93 -0
  1854. package/src/plugin/internal/CapabilityPluginResult.ts +99 -0
  1855. package/src/plugin/internal/CapabilityResolutionFormat.ts +248 -0
  1856. package/src/plugin/internal/ITtscCapabilityPluginSource.ts +37 -0
  1857. package/src/plugin/internal/ITtscCapabilityResolutionEntry.ts +57 -0
  1858. package/src/plugin/internal/ITtscCapabilityResolutionPlugin.ts +22 -0
  1859. package/src/plugin/internal/capabilityPluginWorker.ts +216 -0
  1860. package/src/plugin/internal/decodeCapabilityCommandReply.ts +27 -0
  1861. package/src/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.ts +182 -0
  1862. package/src/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.ts +59 -0
  1863. package/src/plugin/internal/load/PluginDescriptorAdmission.ts +75 -0
  1864. package/src/plugin/internal/load/PluginDescriptorEvaluationCache.ts +432 -0
  1865. package/src/plugin/internal/load/PluginPackageResolution.ts +711 -0
  1866. package/src/plugin/internal/load/ProjectPluginEntries.ts +232 -0
  1867. package/src/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.ts +34 -0
  1868. package/src/plugin/internal/load/collectProjectHostInputs.ts +88 -0
  1869. package/src/plugin/internal/load/composePluginSources.ts +121 -0
  1870. package/src/plugin/internal/load/declaresHostInputReads.ts +52 -0
  1871. package/src/plugin/internal/load/hasProjectPluginEntries.ts +33 -0
  1872. package/src/plugin/internal/load/hashHostInputPaths.ts +44 -0
  1873. package/src/plugin/internal/load/isRelativePluginSpecifier.ts +31 -0
  1874. package/src/plugin/internal/load/loadProjectPlugins.ts +2242 -0
  1875. package/src/plugin/internal/load/moduleResolutionBaseSelects.ts +59 -0
  1876. package/src/plugin/internal/load/observeImportSearchRoots.ts +42 -0
  1877. package/src/plugin/internal/load/pluginLabel.ts +28 -0
  1878. package/src/plugin/internal/load/realpathHostInput.ts +22 -0
  1879. package/src/plugin/internal/load/realpathHostInputPaths.ts +27 -0
  1880. package/src/plugin/internal/load/rejectJsTransformFunctions.ts +23 -0
  1881. package/src/plugin/internal/load/requirePluginSource.ts +34 -0
  1882. package/src/plugin/internal/load/resolveNativeSource.ts +42 -0
  1883. package/src/plugin/internal/load/validatePluginContributors.ts +102 -0
  1884. package/src/plugin/internal/load/validatePluginSource.ts +19 -0
  1885. package/src/plugin/internal/load/visitImportMappedCandidates.ts +63 -0
  1886. package/src/plugin/internal/pluginDescriptorFailureReason.ts +35 -0
  1887. package/src/plugin/internal/pluginDescriptorProcessFailure.ts +48 -0
  1888. package/src/plugin/internal/readCapabilityResolution.ts +193 -0
  1889. package/src/plugin/internal/receiveCapabilityFailure.ts +27 -0
  1890. package/src/plugin/internal/source/CachePrunePolicy.ts +47 -0
  1891. package/src/plugin/internal/source/GoBuildCacheCoordination.ts +588 -0
  1892. package/src/plugin/internal/source/GoSourceInputs.ts +182 -0
  1893. package/src/plugin/internal/source/GoToolResolution.ts +312 -0
  1894. package/src/plugin/internal/source/IGoBuildCachePruneOptions.ts +34 -0
  1895. package/src/plugin/internal/source/IPluginCachePruneOptions.ts +38 -0
  1896. package/src/plugin/internal/source/IPluginModuleReplaceDirectory.ts +30 -0
  1897. package/src/plugin/internal/source/ITtscBuildContributor.ts +19 -0
  1898. package/src/plugin/internal/source/ITtscSourceBuildCachePaths.ts +28 -0
  1899. package/src/plugin/internal/source/NativeSourcePackages.ts +368 -0
  1900. package/src/plugin/internal/source/PluginBinaryUse.ts +159 -0
  1901. package/src/plugin/internal/source/PluginBinaryWaitResult.ts +34 -0
  1902. package/src/plugin/internal/source/PluginBuildEnvironmentReadings.ts +231 -0
  1903. package/src/plugin/internal/source/PluginBuildEnvironmentWitness.ts +233 -0
  1904. package/src/plugin/internal/source/PluginBuildLockFence.ts +26 -0
  1905. package/src/plugin/internal/source/PluginBuildLockLease.ts +31 -0
  1906. package/src/plugin/internal/source/PluginBuildLockObservation.ts +48 -0
  1907. package/src/plugin/internal/source/PluginBuildLockOwner.ts +225 -0
  1908. package/src/plugin/internal/source/PluginBuildLockProtocol.ts +342 -0
  1909. package/src/plugin/internal/source/SourceBuildCacheLayout.ts +303 -0
  1910. package/src/plugin/internal/source/SourceBuildFilesystemOperations.ts +32 -0
  1911. package/src/plugin/internal/source/SourcePluginAdmission.ts +127 -0
  1912. package/src/plugin/internal/source/SourcePluginWorkspace.ts +446 -0
  1913. package/src/plugin/internal/source/acquirePluginBuildLock.ts +222 -0
  1914. package/src/plugin/internal/source/autoQuoteGoModToken.ts +113 -0
  1915. package/src/plugin/internal/source/buildSourcePlugin.ts +1197 -0
  1916. package/src/plugin/internal/source/collectPluginSourceDirectories.ts +70 -0
  1917. package/src/plugin/internal/source/collectPluginSourceFiles.ts +90 -0
  1918. package/src/plugin/internal/source/computeCacheKey.ts +190 -0
  1919. package/src/plugin/internal/source/copiesPluginSourceEntry.ts +52 -0
  1920. package/src/plugin/internal/source/createExternalSourceSnapshotLayout.ts +66 -0
  1921. package/src/plugin/internal/source/ensureExecutableGoToolchain.ts +87 -0
  1922. package/src/plugin/internal/source/formatDuration.ts +32 -0
  1923. package/src/plugin/internal/source/formatGoWorkPath.ts +42 -0
  1924. package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +803 -0
  1925. package/src/plugin/internal/source/inspectPluginBuildLock.ts +330 -0
  1926. package/src/plugin/internal/source/isPathWithin.ts +24 -0
  1927. package/src/plugin/internal/source/legacyGlobalCacheTargets.ts +71 -0
  1928. package/src/plugin/internal/source/pluginBuildEnvironment.ts +59 -0
  1929. package/src/plugin/internal/source/pluginBuildEnvironmentWorker.ts +30 -0
  1930. package/src/plugin/internal/source/pluginBuildVersions.ts +75 -0
  1931. package/src/plugin/internal/source/pluginModuleReplaceDirectories.ts +96 -0
  1932. package/src/plugin/internal/source/pluginSourceCovers.ts +54 -0
  1933. package/src/plugin/internal/source/pluginSourceDigest.ts +55 -0
  1934. package/src/plugin/internal/source/pluginSourceFilesSignature.ts +54 -0
  1935. package/src/plugin/internal/source/pluginSourceState.ts +69 -0
  1936. package/src/plugin/internal/source/pluginSourceStateHolds.ts +45 -0
  1937. package/src/plugin/internal/source/processPluginBuildEnvironment.ts +40 -0
  1938. package/src/plugin/internal/source/pruneCacheFileRoot.ts +134 -0
  1939. package/src/plugin/internal/source/pruneGoBuildCacheRoot.ts +228 -0
  1940. package/src/plugin/internal/source/prunePluginCacheRoot.ts +507 -0
  1941. package/src/plugin/internal/source/prunesPluginSourceDirectory.ts +25 -0
  1942. package/src/plugin/internal/source/reclaimPluginBuildLock.ts +63 -0
  1943. package/src/plugin/internal/source/recordCacheFileUse.ts +35 -0
  1944. package/src/plugin/internal/source/releasePluginBuildLock.ts +125 -0
  1945. package/src/plugin/internal/source/resolveCleanTargets.ts +84 -0
  1946. package/src/plugin/internal/source/resolveGoCompiler.ts +92 -0
  1947. package/src/plugin/internal/source/resolvePluginCacheRoot.ts +32 -0
  1948. package/src/plugin/internal/source/resolvePluginGoModule.ts +69 -0
  1949. package/src/plugin/internal/source/resolveSourceBuildCachePaths.ts +276 -0
  1950. package/src/plugin/internal/source/selectPluginModuleReplaceDirectories.ts +80 -0
  1951. package/src/plugin/internal/source/spawnGoTool.ts +204 -0
  1952. package/src/plugin/internal/source/touchPluginCacheEntryInUse.ts +44 -0
  1953. package/src/plugin/internal/source/waitForPluginBinary.ts +123 -0
  1954. package/src/plugin/internal/source/windowsGoCommandArgs.ts +19 -0
  1955. package/src/plugin/internal/source/withGoBuildCacheLease.ts +101 -0
  1956. package/src/plugin/internal/writeCapabilityResolution.ts +266 -0
  1957. package/src/plugin/resolveCapabilityPlugins.ts +242 -77
  1958. package/src/register.ts +20 -7
  1959. package/src/structures/ITtscCompilerContext.ts +29 -11
  1960. package/src/structures/ITtscCompilerDiagnostic.ts +24 -7
  1961. package/src/structures/ITtscCompilerResult.ts +75 -25
  1962. package/src/structures/ITtscCompilerTransformation.ts +304 -64
  1963. package/src/structures/ITtscPlugin.ts +24 -8
  1964. package/src/structures/ITtscPluginCapabilities.ts +58 -5
  1965. package/src/structures/ITtscPluginContributor.ts +19 -8
  1966. package/src/structures/ITtscPluginFactoryContext.ts +12 -3
  1967. package/src/structures/ITtscProjectPluginConfig.ts +35 -10
  1968. package/src/structures/TtscPluginStage.ts +9 -0
  1969. package/src/structures/internal/ITtscLoadedNativePlugin.ts +27 -5
  1970. package/src/structures/internal/ITtscParsedProjectConfig.ts +37 -3
  1971. package/src/structures/internal/ITtscProjectIdentity.ts +27 -6
  1972. package/src/structures/internal/ITtscProjectInputSnapshot.ts +31 -8
  1973. package/src/structures/internal/ITtscProjectLocatorOptions.ts +21 -4
  1974. package/src/structures/internal/TtscBuildOptions.ts +38 -14
  1975. package/src/structures/internal/TtscBuildResult.ts +74 -4
  1976. package/src/structures/internal/TtscCommonOptions.ts +59 -14
  1977. package/src/structures/internal/TtscSingleFileEmitOptions.ts +55 -5
  1978. package/tools/gen_shims/main.go +124 -11
  1979. package/tools/gen_shims/package_load_admission_rejects_incomplete_results_test.go +61 -0
  1980. package/tools/gen_shims/private_field_support_preserves_upstream_layout_test.go +104 -0
  1981. package/tools/shim_audit/enum_generation_preserves_existing_family_members_test.go +182 -0
  1982. package/tools/shim_audit/enum_generation_refuses_removed_public_members_test.go +93 -0
  1983. package/tools/shim_audit/main.go +166 -31
  1984. package/tools/shim_audit/main_test.go +35 -0
  1985. package/tools/shim_audit/producer_exemptions_require_rationale_test.go +5 -0
  1986. package/tools/shim_audit/producer_surface_includes_exposed_methods_test.go +5 -0
  1987. package/tools/shim_audit/producer_surface_rejects_unproducible_reference_test.go +5 -0
  1988. package/tools/shim_audit/shim_dir_coverage_rejects_unregistered_shims_test.go +71 -0
  1989. package/utility/command.go +48 -0
  1990. package/utility/flags_gen.go +2 -2
  1991. package/utility/host.go +282 -66
  1992. package/utility/preamble_output.go +245 -0
  1993. package/utility/preamble_output_test.go +90 -0
  1994. package/utility/serve.go +61 -18
  1995. package/cmd/ttscgraph/serve_graph_snapshot_version_matches_typescript_client_test.go +0 -32
  1996. package/cmd/ttscgraph/serve_protocol_version_matches_the_typescript_client_test.go +0 -48
  1997. package/cmd/ttscgraph/serve_session_retries_failed_dump_test.go +0 -103
  1998. package/internal/graph/dump_schema_version_matches_the_typescript_client_test.go +0 -48
  1999. package/internal/graph/edge_kinds_names_every_declared_kind_test.go +0 -49
  2000. package/internal/graph/graph_kind_contracts_match_their_producers_test.go +0 -121
  2001. package/internal/lspserver/lsp_launcher_reload_directory_fingerprint_parity_windows_test.go +0 -94
  2002. package/internal/lspserver/lsp_project_diagnostics_resident_unsupported_falls_back_test.go +0 -123
  2003. package/lib/compiler/internal/paths.d.ts +0 -27
  2004. package/lib/compiler/internal/paths.js +0 -70
  2005. package/lib/compiler/internal/paths.js.map +0 -1
  2006. package/lib/compiler/internal/project/readConfigJson.d.ts +0 -30
  2007. package/lib/compiler/internal/project/readConfigJson.js +0 -208
  2008. package/lib/compiler/internal/project/readConfigJson.js.map +0 -1
  2009. package/lib/compiler/internal/residentCheckProcess.d.ts +0 -44
  2010. package/lib/compiler/internal/residentCheckProcess.js +0 -213
  2011. package/lib/compiler/internal/residentCheckProcess.js.map +0 -1
  2012. package/lib/compiler/internal/residentTransformProcess.d.ts +0 -65
  2013. package/lib/compiler/internal/residentTransformProcess.js +0 -330
  2014. package/lib/compiler/internal/residentTransformProcess.js.map +0 -1
  2015. package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +0 -25
  2016. package/lib/compiler/internal/resolveEmittedJavaScript.js +0 -165
  2017. package/lib/compiler/internal/resolveEmittedJavaScript.js.map +0 -1
  2018. package/lib/compiler/internal/runBuild.d.ts +0 -152
  2019. package/lib/compiler/internal/runBuild.js +0 -1694
  2020. package/lib/compiler/internal/runBuild.js.map +0 -1
  2021. package/lib/compiler/internal/sharedHostHelpers.d.ts +0 -79
  2022. package/lib/compiler/internal/sharedHostHelpers.js +0 -134
  2023. package/lib/compiler/internal/sharedHostHelpers.js.map +0 -1
  2024. package/lib/flags/parser.d.ts +0 -97
  2025. package/lib/flags/parser.js +0 -293
  2026. package/lib/flags/parser.js.map +0 -1
  2027. package/lib/flags/schema.d.ts +0 -191
  2028. package/lib/flags/schema.js.map +0 -1
  2029. package/lib/internal/windowsDirectoryCaseSensitivity.d.ts +0 -10
  2030. package/lib/internal/windowsDirectoryCaseSensitivity.js +0 -34
  2031. package/lib/internal/windowsDirectoryCaseSensitivity.js.map +0 -1
  2032. package/lib/launcher/internal/commonJsExportMetadata.d.ts +0 -7
  2033. package/lib/launcher/internal/commonJsExportMetadata.js.map +0 -1
  2034. package/lib/launcher/internal/registerRuntimeHooks.js +0 -59
  2035. package/lib/launcher/internal/registerRuntimeHooks.js.map +0 -1
  2036. package/lib/launcher/internal/runTtscserver.d.ts +0 -35
  2037. package/lib/launcher/internal/runTtscserver.js +0 -661
  2038. package/lib/launcher/internal/runTtscserver.js.map +0 -1
  2039. package/lib/launcher/internal/runtimeHooks.d.ts +0 -198
  2040. package/lib/launcher/internal/runtimeHooks.js +0 -2579
  2041. package/lib/launcher/internal/runtimeHooks.js.map +0 -1
  2042. package/lib/launcher/internal/servedSourceMap.d.ts +0 -25
  2043. package/lib/launcher/internal/servedSourceMap.js +0 -164
  2044. package/lib/launcher/internal/servedSourceMap.js.map +0 -1
  2045. package/lib/launcher/internal/singleFileOutput.d.ts +0 -16
  2046. package/lib/launcher/internal/singleFileOutput.js +0 -103
  2047. package/lib/launcher/internal/singleFileOutput.js.map +0 -1
  2048. package/lib/launcher/internal/watchTopology.d.ts +0 -329
  2049. package/lib/launcher/internal/watchTopology.js.map +0 -1
  2050. package/lib/plugin/internal/buildSourcePlugin.d.ts +0 -298
  2051. package/lib/plugin/internal/buildSourcePlugin.js +0 -3087
  2052. package/lib/plugin/internal/buildSourcePlugin.js.map +0 -1
  2053. package/lib/plugin/internal/capabilityResolutionCache.d.ts +0 -76
  2054. package/lib/plugin/internal/capabilityResolutionCache.js +0 -224
  2055. package/lib/plugin/internal/capabilityResolutionCache.js.map +0 -1
  2056. package/lib/plugin/internal/descriptorProcessFailure.d.ts +0 -36
  2057. package/lib/plugin/internal/descriptorProcessFailure.js +0 -62
  2058. package/lib/plugin/internal/descriptorProcessFailure.js.map +0 -1
  2059. package/lib/plugin/internal/loadProjectPlugins.d.ts +0 -75
  2060. package/lib/plugin/internal/loadProjectPlugins.js +0 -2405
  2061. package/lib/plugin/internal/loadProjectPlugins.js.map +0 -1
  2062. package/src/compiler/internal/paths.ts +0 -68
  2063. package/src/compiler/internal/project/readConfigJson.ts +0 -209
  2064. package/src/compiler/internal/residentCheckProcess.ts +0 -259
  2065. package/src/compiler/internal/residentTransformProcess.ts +0 -406
  2066. package/src/compiler/internal/resolveEmittedJavaScript.ts +0 -197
  2067. package/src/compiler/internal/runBuild.ts +0 -2345
  2068. package/src/compiler/internal/sharedHostHelpers.ts +0 -154
  2069. package/src/flags/parser.ts +0 -459
  2070. package/src/internal/windowsDirectoryCaseSensitivity.ts +0 -33
  2071. package/src/launcher/internal/registerRuntimeHooks.ts +0 -68
  2072. package/src/launcher/internal/runTtscserver.ts +0 -842
  2073. package/src/launcher/internal/runtimeHooks.ts +0 -3197
  2074. package/src/launcher/internal/servedSourceMap.ts +0 -183
  2075. package/src/launcher/internal/singleFileOutput.ts +0 -133
  2076. package/src/plugin/internal/buildSourcePlugin.ts +0 -3993
  2077. package/src/plugin/internal/capabilityResolutionCache.ts +0 -305
  2078. package/src/plugin/internal/descriptorProcessFailure.ts +0 -69
  2079. package/src/plugin/internal/loadProjectPlugins.ts +0 -3073
  2080. package/tools/shim_audit/shim_dir_coverage_test.go +0 -25
  2081. /package/lib/{launcher/internal/registerRuntimeHooks.d.ts → compiler/internal/transformProjectWorker.d.ts} +0 -0
@@ -1,3073 +0,0 @@
1
- import childProcess from "node:child_process";
2
- import crypto from "node:crypto";
3
- import fs from "node:fs";
4
- import { createRequire } from "node:module";
5
- import path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
-
8
- import { findNearestGoMod } from "../../compiler/internal/paths";
9
- import { readJsonFile } from "../../compiler/internal/project/readConfigJson";
10
- import { readProjectConfig } from "../../compiler/internal/project/readProjectConfig";
11
- import { createCanonicalTempDirectory } from "../../internal/createCanonicalTempDirectory";
12
- import {
13
- javascriptRuntimeCapabilities,
14
- resolveNodeBinary,
15
- } from "../../internal/resolveNodeBinary";
16
- import { spawnSyncResilient } from "../../internal/spawnSyncResilient";
17
- import type { ITtscPlugin } from "../../structures/ITtscPlugin";
18
- import type { ITtscPluginContributor } from "../../structures/ITtscPluginContributor";
19
- import type { ITtscPluginFactoryContext } from "../../structures/ITtscPluginFactoryContext";
20
- import type { ITtscProjectPluginConfig } from "../../structures/ITtscProjectPluginConfig";
21
- import type { TtscPluginStage } from "../../structures/TtscPluginStage";
22
- import type { ITtscLoadedNativePlugin } from "../../structures/internal/ITtscLoadedNativePlugin";
23
- import type { ITtscParsedProjectConfig } from "../../structures/internal/ITtscParsedProjectConfig";
24
- import { buildSourcePlugin } from "./buildSourcePlugin";
25
- import {
26
- pluginDescriptorFailureReason,
27
- pluginDescriptorProcessFailure,
28
- } from "./descriptorProcessFailure";
29
-
30
- const GO_MOD_SEARCH_MAX_DEPTH = 3;
31
-
32
- type ProjectPluginEntry = {
33
- baseDir: string;
34
- config: ITtscProjectPluginConfig;
35
- };
36
-
37
- type PackageManifest = {
38
- dependencies?: Record<string, unknown>;
39
- devDependencies?: Record<string, unknown>;
40
- exports?: unknown;
41
- main?: unknown;
42
- module?: unknown;
43
- name?: unknown;
44
- ttsc?: unknown;
45
- };
46
-
47
- type ProjectHostInputSnapshot = {
48
- hostInputHashes: Record<string, string | null>;
49
- hostInputRealpaths: Record<string, string | null>;
50
- hostInputs: string[];
51
- project: ITtscParsedProjectConfig;
52
- };
53
-
54
- /**
55
- * Resolve, load, and build all native plugin sidecars for a TypeScript project.
56
- *
57
- * Reads the project config, discovers plugin entries (from tsconfig and package
58
- * auto-discovery), validates and composes their descriptors, then invokes
59
- * `buildSourcePlugin` to compile each Go source package into a cached binary.
60
- * Returns the ordered native plugins, parsed project config, and exact
61
- * JavaScript-host files that universally influence the loaded selection.
62
- *
63
- * @param options.binary - Absolute path to the ttsc native helper binary.
64
- * @param options.cacheDir - Override the plugin binary cache directory.
65
- * @param options.cwd - Working directory for resolving relative paths.
66
- * @param options.entries - Explicit plugin entries; `false` disables all
67
- * plugins (skips both tsconfig entries and package auto-discovery).
68
- * @param options.env - Effective environment for source-plugin builds and
69
- * isolated descriptor evaluators, including the `ttsx` fallback (`{
70
- * ...process.env, ...context.env }`). Defaults to `process.env` for CLI
71
- * callers, so ambient behavior is unchanged.
72
- * @param options.file - Path to the tsconfig/jsconfig file.
73
- * @param options.pluginConfigDir - Caller-declared anchor for plugin
74
- * config-file discovery (see `ITtscPluginFactoryContext.pluginConfigDir`).
75
- * @param options.projectRoot - Override the project root directory.
76
- * @param options.tsconfig - Alias for `file`.
77
- */
78
- export function loadProjectPlugins(options: {
79
- binary: string;
80
- cacheDir?: string;
81
- cwd?: string;
82
- entries?: readonly ITtscProjectPluginConfig[] | false;
83
- env?: NodeJS.ProcessEnv;
84
- file?: string;
85
- onWatchInputs?: (inputs: readonly string[]) => void;
86
- pluginConfigDir?: string;
87
- projectRoot?: string;
88
- tsconfig?: string;
89
- }): {
90
- deferredHostInputs: string[];
91
- hostInputHashes: Record<string, string | null>;
92
- hostInputRealpaths: Record<string, string | null>;
93
- hostInputs: string[];
94
- nativePlugins: ITtscLoadedNativePlugin[];
95
- project: ITtscParsedProjectConfig;
96
- } {
97
- // Snapshot the caller environment before `withPluginLoaderEnv` injects
98
- // host-owned Node/ttsx locators into process.env. Under a Bun parent the
99
- // direct descriptor evaluator must remain Bun unless the caller explicitly
100
- // selected another runtime.
101
- const effectiveEnv = { ...(options.env ?? process.env) };
102
- const projectSnapshot = readProjectHostInputSnapshot({
103
- cwd: options.cwd,
104
- file: options.file,
105
- includePluginDiscovery: options.entries === undefined,
106
- projectRoot: options.projectRoot,
107
- tsconfig: options.tsconfig,
108
- });
109
- const { project } = projectSnapshot;
110
- const projectHostInputs = projectSnapshot.hostInputs;
111
- const projectHostInputHashes = projectSnapshot.hostInputHashes;
112
- const projectHostInputRealpaths = projectSnapshot.hostInputRealpaths;
113
- const entries: ProjectPluginEntry[] =
114
- options.entries === false
115
- ? []
116
- : resolvePluginEntries(project, options.entries).filter(
117
- (entry) => entry.config.enabled !== false,
118
- );
119
- if (entries.length === 0) {
120
- options.onWatchInputs?.([]);
121
- return {
122
- ...collectHostInputSnapshot(
123
- project,
124
- {},
125
- [],
126
- projectHostInputs,
127
- revalidateHostInputHashes(projectHostInputHashes, projectHostInputs),
128
- revalidateHostInputRealpaths(
129
- projectHostInputRealpaths,
130
- projectHostInputs,
131
- ),
132
- ),
133
- nativePlugins: [],
134
- project,
135
- };
136
- }
137
-
138
- const cwd = path.resolve(options.cwd ?? process.cwd());
139
- const context = {
140
- binary: options.binary,
141
- cwd,
142
- ...(options.pluginConfigDir === undefined || options.pluginConfigDir === ""
143
- ? {}
144
- : { pluginConfigDir: path.resolve(cwd, options.pluginConfigDir) }),
145
- projectRoot: project.root,
146
- tsconfig: project.path,
147
- };
148
- const loadedEntries = withPluginLoaderEnv(() =>
149
- entries.map((entry) => {
150
- const specifier = entry.config.transform;
151
- if (typeof specifier !== "string" || specifier.length === 0) {
152
- throw new Error(
153
- `ttsc: plugin entry is missing a string "transform" field`,
154
- );
155
- }
156
- const entryCandidates = collectModuleResolutionCandidates(
157
- specifier,
158
- path.join(entry.baseDir, "package.json"),
159
- undefined,
160
- );
161
- // Capture every candidate before resolution chooses the descriptor entry.
162
- // A post-resolution snapshot could bless a higher-priority file created
163
- // after the resolver had already selected the old entry.
164
- const entryCandidateHashes = hashHostInputPaths(entryCandidates);
165
- const entryCandidateRealpaths = realpathHostInputPaths(entryCandidates);
166
- const request = resolvePluginRequest(specifier, entry.baseDir);
167
- const loaded = loadPluginEntry(
168
- entry.config,
169
- { ...context, plugin: entry.config },
170
- request,
171
- effectiveEnv,
172
- );
173
- const loadedHostInputHashes = mergeObservedHostInputHashes(
174
- loaded.hostInputHashes,
175
- hashHostInputPaths(Object.keys(loaded.hostInputHashes)),
176
- );
177
- const loadedHostInputRealpaths = mergeObservedHostInputRealpaths(
178
- loaded.hostInputRealpaths,
179
- realpathHostInputPaths(Object.keys(loaded.hostInputRealpaths)),
180
- );
181
- const hostInputHashes = mergeObservedHostInputHashes(
182
- entryCandidateHashes,
183
- loadedHostInputHashes,
184
- );
185
- const hostInputRealpaths = mergeObservedHostInputRealpaths(
186
- entryCandidateRealpaths,
187
- loadedHostInputRealpaths,
188
- );
189
- for (const input of loaded.hostInputs) {
190
- const absolute = path.resolve(input);
191
- if (
192
- !Object.prototype.hasOwnProperty.call(loadedHostInputHashes, absolute)
193
- ) {
194
- delete hostInputHashes[absolute];
195
- }
196
- }
197
- return {
198
- ...loaded,
199
- hostInputHashes,
200
- hostInputRealpaths,
201
- hostInputs: [...loaded.hostInputs, ...entryCandidates],
202
- request,
203
- };
204
- }),
205
- );
206
- const plugins = composePluginSources(
207
- entries,
208
- loadedEntries.map((entry) => entry.plugin),
209
- );
210
-
211
- const ttscVersion = readTtscVersion();
212
- const tsgoVersion = readTsgoVersion(context.projectRoot);
213
- const records = plugins.map((plugin, index) => {
214
- const stage = resolvePluginStage(plugin);
215
- validatePluginSource(plugin);
216
- const contributors = validatePluginContributors(plugin);
217
- const source = resolvePluginSource(plugin.source, context.projectRoot);
218
- const kind = resolveNativeSourceKind(
219
- source,
220
- plugin,
221
- entries[index]!.config,
222
- index,
223
- );
224
- if (kind === "linked" && stage !== "transform") {
225
- throw new Error(
226
- `ttsc: plugin "${pluginLabel(plugin, entries[index]!.config, index)}" source is a linked Go package, but only transform-stage plugins can be linked into a compiler host`,
227
- );
228
- }
229
- const linkedContributorName =
230
- kind === "linked"
231
- ? `linked_${String(index).padStart(6, "0")}`
232
- : undefined;
233
- const hostInputs = validatePluginHostInputs(plugin, index);
234
- const pluginHostInputHashes = validatePluginHostInputHashes(
235
- plugin,
236
- index,
237
- hostInputs,
238
- );
239
- const pluginHostInputRealpaths = validatePluginHostInputRealpaths(
240
- plugin,
241
- index,
242
- hostInputs,
243
- );
244
- return {
245
- capabilities: plugin.capabilities,
246
- contributors,
247
- config: entries[index]!.config,
248
- kind,
249
- label: pluginLabel(plugin, entries[index]!.config, index),
250
- linkedContributorName,
251
- name: plugin.name,
252
- reportsTypeScriptDiagnostics:
253
- plugin.reportsTypeScriptDiagnostics === true,
254
- request: loadedEntries[index]!.request,
255
- hostInputHashes: mergePluginHostInputHashes(
256
- loadedEntries[index]!.hostInputHashes,
257
- pluginHostInputHashes,
258
- loadedEntries[index]!.hostInputs,
259
- hostInputs,
260
- ),
261
- hostInputRealpaths: mergePluginHostInputHashes(
262
- loadedEntries[index]!.hostInputRealpaths,
263
- pluginHostInputRealpaths,
264
- loadedEntries[index]!.hostInputs,
265
- hostInputs,
266
- ),
267
- hostInputs: [...loadedEntries[index]!.hostInputs, ...hostInputs],
268
- source,
269
- stage,
270
- };
271
- });
272
- options.onWatchInputs?.(
273
- records.flatMap((record) => [
274
- record.source,
275
- ...(record.contributors?.map((contributor) => contributor.source) ?? []),
276
- ]),
277
- );
278
- const linkedContributors = records
279
- .filter((record) => record.stage === "transform")
280
- .flatMap((record) =>
281
- record.kind === "linked"
282
- ? [{ name: record.linkedContributorName!, source: record.source }]
283
- : [],
284
- );
285
- const transformHosts = records.filter(
286
- (record) => record.stage === "transform" && record.kind === "executable",
287
- );
288
- const hostContributors =
289
- linkedContributors.length === 0 ? undefined : linkedContributors;
290
- const builtTransformHosts = new Map<object, string>();
291
- for (const record of transformHosts) {
292
- builtTransformHosts.set(
293
- record,
294
- buildSourcePlugin({
295
- baseDir: context.projectRoot,
296
- cacheDir: options.cacheDir,
297
- contributors: mergeContributors(record.contributors, hostContributors),
298
- env: effectiveEnv,
299
- pluginName: record.label,
300
- source: record.source,
301
- ttscVersion,
302
- tsgoVersion,
303
- }),
304
- );
305
- }
306
- const fallbackDriverHost =
307
- transformHosts.length === 0 && linkedContributors.length !== 0
308
- ? buildSourcePlugin({
309
- baseDir: context.projectRoot,
310
- cacheDir: options.cacheDir,
311
- contributors: linkedContributors,
312
- env: effectiveEnv,
313
- label: "linked plugin host",
314
- pluginName: "linked-plugin-host",
315
- source: path.join(ttscPackageRoot(), "cmd", "utility-host"),
316
- ttscVersion,
317
- tsgoVersion,
318
- })
319
- : undefined;
320
- const selectedTransformHost =
321
- transformHosts.length === 0
322
- ? fallbackDriverHost
323
- : builtTransformHosts.get(transformHosts[0]!);
324
- const nativePlugins: ITtscLoadedNativePlugin[] = records.map((record) => {
325
- const binary =
326
- record.stage === "transform" && record.kind === "linked"
327
- ? selectedTransformHost
328
- : record.stage === "transform"
329
- ? builtTransformHosts.get(record)
330
- : buildSourcePlugin({
331
- baseDir: context.projectRoot,
332
- cacheDir: options.cacheDir,
333
- contributors: record.contributors,
334
- env: effectiveEnv,
335
- pluginName: record.label,
336
- source: record.source,
337
- ttscVersion,
338
- tsgoVersion,
339
- });
340
- if (binary === undefined) {
341
- throw new Error(
342
- `ttsc: plugin "${record.label}" is a linked Go package, but no compiler host is available`,
343
- );
344
- }
345
- return {
346
- binary,
347
- capabilities: record.capabilities,
348
- config: record.config,
349
- contributors: record.contributors,
350
- kind: record.kind,
351
- name: record.name,
352
- reportsTypeScriptDiagnostics: record.reportsTypeScriptDiagnostics,
353
- source: record.source,
354
- stage: record.stage,
355
- };
356
- });
357
- return {
358
- ...collectHostInputSnapshot(
359
- project,
360
- context,
361
- records,
362
- projectHostInputs,
363
- revalidateHostInputHashes(projectHostInputHashes, projectHostInputs),
364
- revalidateHostInputRealpaths(
365
- projectHostInputRealpaths,
366
- projectHostInputs,
367
- ),
368
- ),
369
- nativePlugins: orderNativePlugins(nativePlugins),
370
- project,
371
- };
372
- }
373
-
374
- /**
375
- * Collect exact JavaScript-host files that universally influence the loaded
376
- * transform. Program files belong to the native reference graph; this list is
377
- * deliberately limited to config ancestry, descriptor entries, the project
378
- * manifest controlling auto-discovery, and explicit plugin config files.
379
- */
380
- function collectHostInputSnapshot(
381
- project: ITtscParsedProjectConfig,
382
- context: { pluginConfigDir?: string },
383
- records: readonly {
384
- config: ITtscProjectPluginConfig;
385
- hostInputHashes: Readonly<Record<string, string | null>>;
386
- hostInputRealpaths: Readonly<Record<string, string | null>>;
387
- hostInputs: readonly string[];
388
- request: string;
389
- }[],
390
- baselineInputs: readonly string[],
391
- baselineHashes: Readonly<Record<string, string | null>>,
392
- baselineRealpaths: Readonly<Record<string, string | null>>,
393
- ): {
394
- deferredHostInputs: string[];
395
- hostInputHashes: Record<string, string | null>;
396
- hostInputRealpaths: Record<string, string | null>;
397
- hostInputs: string[];
398
- } {
399
- const inputs = new Set<string>(
400
- baselineInputs.map((file) => path.resolve(file)),
401
- );
402
- // A path consumed by any JavaScript-host stage keeps that stage's proof
403
- // obligation, even when another plugin merely forwards the same spelling as
404
- // its conventional native `configFile`. Otherwise one non-consuming record
405
- // could let the native result replace a missing/raced JavaScript proof for a
406
- // different record that really read the file.
407
- const consumed = new Set<string>(
408
- baselineInputs.map((file) => path.resolve(file)),
409
- );
410
- for (const record of records) {
411
- for (const hostInput of record.hostInputs) {
412
- consumed.add(path.resolve(hostInput));
413
- }
414
- }
415
- const deferred = new Set<string>();
416
- const configBase = context.pluginConfigDir ?? path.dirname(project.path);
417
- for (const record of records) {
418
- inputs.add(path.resolve(record.request));
419
- for (const hostInput of record.hostInputs) {
420
- inputs.add(path.resolve(hostInput));
421
- }
422
- const descriptorManifest = findNearestPackageJson(record.request);
423
- if (descriptorManifest !== undefined) {
424
- inputs.add(path.resolve(descriptorManifest));
425
- }
426
- const configFile = record.config.configFile;
427
- if (typeof configFile === "string" && configFile.trim() !== "") {
428
- const absolute = path.isAbsolute(configFile)
429
- ? path.resolve(configFile)
430
- : path.resolve(configBase, configFile);
431
- inputs.add(absolute);
432
- // `configFile` is a convention forwarded to the native plugin, not a
433
- // file the JavaScript loader reads. Its compile-time proof must therefore
434
- // come back from that plugin. A descriptor that separately reports the
435
- // same path did consume it here and remains subject to its own proof.
436
- if (!consumed.has(absolute)) {
437
- deferred.add(absolute);
438
- }
439
- }
440
- }
441
- const hostInputs = [...inputs].sort();
442
- const evaluationHashes = mergeObservedHostInputHashes(
443
- baselineHashes,
444
- ...records.map((record) => record.hostInputHashes),
445
- );
446
- const evaluationRealpaths = mergeObservedHostInputRealpaths(
447
- baselineRealpaths,
448
- ...records.map((record) => record.hostInputRealpaths),
449
- );
450
- for (const record of records) {
451
- for (const input of record.hostInputs) {
452
- const absolute = path.resolve(input);
453
- if (
454
- !Object.prototype.hasOwnProperty.call(record.hostInputHashes, absolute)
455
- ) {
456
- delete evaluationHashes[absolute];
457
- }
458
- if (
459
- !Object.prototype.hasOwnProperty.call(
460
- record.hostInputRealpaths,
461
- absolute,
462
- )
463
- ) {
464
- delete evaluationRealpaths[absolute];
465
- }
466
- }
467
- }
468
- const hostInputHashes = Object.fromEntries(
469
- hostInputs.flatMap((file) =>
470
- Object.prototype.hasOwnProperty.call(evaluationHashes, file)
471
- ? ([[file, evaluationHashes[file]!]] as const)
472
- : [],
473
- ),
474
- );
475
- const hostInputRealpaths = Object.fromEntries(
476
- hostInputs.flatMap((file) =>
477
- Object.prototype.hasOwnProperty.call(evaluationRealpaths, file)
478
- ? ([[file, evaluationRealpaths[file]!]] as const)
479
- : [],
480
- ),
481
- );
482
- return {
483
- deferredHostInputs: [...deferred].sort(),
484
- hostInputHashes,
485
- hostInputRealpaths,
486
- hostInputs,
487
- };
488
- }
489
-
490
- /**
491
- * Read one project configuration while its complete discovery surface remains
492
- * unchanged. The preliminary read discovers the input set; the accepted read is
493
- * bracketed by equal fingerprints for that same set. A repeatedly changing
494
- * project is still returned so compilation can make progress, but without any
495
- * cache proof for the ambiguous snapshot.
496
- */
497
- function readProjectHostInputSnapshot(options: {
498
- cwd?: string;
499
- file?: string;
500
- includePluginDiscovery: boolean;
501
- projectRoot?: string;
502
- tsconfig?: string;
503
- }): ProjectHostInputSnapshot {
504
- const { includePluginDiscovery, ...projectOptions } = options;
505
- let project = readProjectConfig(projectOptions);
506
- let hostInputs = collectProjectHostInputs(project, includePluginDiscovery);
507
- const observedInputs = new Set(hostInputs);
508
- for (let attempt = 0; attempt < 3; attempt++) {
509
- const before = hashHostInputPaths(hostInputs);
510
- const beforeRealpaths = realpathHostInputPaths(hostInputs);
511
- const beforeSignatures = hostInputMetadataSignatures(hostInputs);
512
- const candidateProject = readProjectConfig(projectOptions);
513
- const candidateInputs = collectProjectHostInputs(
514
- candidateProject,
515
- includePluginDiscovery,
516
- );
517
- for (const input of candidateInputs) observedInputs.add(input);
518
- const after = hashHostInputPaths(candidateInputs);
519
- const afterRealpaths = realpathHostInputPaths(candidateInputs);
520
- const afterSignatures = hostInputMetadataSignatures(candidateInputs);
521
- if (
522
- equalHostInputLists(hostInputs, candidateInputs) &&
523
- equalHostInputHashes(before, after) &&
524
- equalHostInputHashes(beforeRealpaths, afterRealpaths) &&
525
- beforeSignatures !== undefined &&
526
- afterSignatures !== undefined &&
527
- equalHostInputHashes(beforeSignatures, afterSignatures)
528
- ) {
529
- return {
530
- hostInputHashes: after,
531
- hostInputRealpaths: afterRealpaths,
532
- hostInputs: candidateInputs,
533
- project: candidateProject,
534
- };
535
- }
536
- project = candidateProject;
537
- hostInputs = candidateInputs;
538
- }
539
- return {
540
- hostInputHashes: {},
541
- hostInputRealpaths: {},
542
- hostInputs: [...observedInputs].sort(),
543
- project,
544
- };
545
- }
546
-
547
- function equalHostInputLists(
548
- first: readonly string[],
549
- second: readonly string[],
550
- ): boolean {
551
- return (
552
- first.length === second.length &&
553
- first.every(
554
- (file, index) => path.resolve(file) === path.resolve(second[index]!),
555
- )
556
- );
557
- }
558
-
559
- function equalHostInputHashes(
560
- first: Readonly<Record<string, string | null>>,
561
- second: Readonly<Record<string, string | null>>,
562
- ): boolean {
563
- const files = Object.keys(first);
564
- return (
565
- files.length === Object.keys(second).length &&
566
- files.every(
567
- (file) =>
568
- Object.prototype.hasOwnProperty.call(second, file) &&
569
- first[file] === second[file],
570
- )
571
- );
572
- }
573
-
574
- /** Retain proof only for inputs whose initial and final observations agree. */
575
- function revalidateHostInputHashes(
576
- initial: Readonly<Record<string, string | null>>,
577
- inputs: readonly string[],
578
- ): Record<string, string | null> {
579
- const current = hashHostInputPaths(inputs);
580
- const output: Record<string, string | null> = {};
581
- for (const input of inputs) {
582
- const absolute = path.resolve(input);
583
- if (
584
- Object.prototype.hasOwnProperty.call(initial, absolute) &&
585
- initial[absolute] === current[absolute]
586
- ) {
587
- output[absolute] = current[absolute]!;
588
- }
589
- }
590
- return output;
591
- }
592
-
593
- /** Keep physical-identity proof only while the same path resolves identically. */
594
- function revalidateHostInputRealpaths(
595
- initial: Readonly<Record<string, string | null>>,
596
- inputs: readonly string[],
597
- ): Record<string, string | null> {
598
- const current = realpathHostInputPaths(inputs);
599
- return Object.fromEntries(
600
- inputs.flatMap((input) => {
601
- const absolute = path.resolve(input);
602
- return Object.prototype.hasOwnProperty.call(initial, absolute) &&
603
- initial[absolute] === current[absolute]
604
- ? ([[absolute, current[absolute]!]] as const)
605
- : [];
606
- }),
607
- );
608
- }
609
-
610
- function hashHostInput(file: string): string | null {
611
- try {
612
- if (fs.statSync(file).isDirectory()) {
613
- return crypto
614
- .createHash("sha256")
615
- .update("ttsc:host-input:directory\0")
616
- .digest("hex");
617
- }
618
- return crypto
619
- .createHash("sha256")
620
- .update(fs.readFileSync(file))
621
- .digest("hex");
622
- } catch {
623
- return null;
624
- }
625
- }
626
-
627
- export function hashHostInputPaths(
628
- files: readonly string[],
629
- ): Record<string, string | null> {
630
- return Object.fromEntries(
631
- files.map((file) => [path.resolve(file), hashHostInput(file)]),
632
- );
633
- }
634
-
635
- /** Physical path selected by a host input, or null while it is unresolved. */
636
- export function realpathHostInput(file: string): string | null {
637
- try {
638
- return fs.realpathSync.native(file);
639
- } catch {
640
- return null;
641
- }
642
- }
643
-
644
- export function realpathHostInputPaths(
645
- files: readonly string[],
646
- ): Record<string, string | null> {
647
- return Object.fromEntries(
648
- files.map((file) => [path.resolve(file), realpathHostInput(file)]),
649
- );
650
- }
651
-
652
- /**
653
- * Metadata identity that survives content-preserving reads but exposes A-B-A
654
- * replacement. Missing paths are tied to the nearest existing ancestor whose
655
- * directory metadata changes when the missing branch appears or disappears.
656
- */
657
- function hostInputMetadataSignature(file: string): string | undefined {
658
- const requested = path.resolve(file);
659
- let current = requested;
660
- for (;;) {
661
- try {
662
- const link = fs.lstatSync(current, { bigint: true });
663
- let target = link;
664
- if (link.isSymbolicLink()) {
665
- try {
666
- target = fs.statSync(current, { bigint: true });
667
- } catch {
668
- // A broken link's own metadata cannot expose its target appearing
669
- // and disappearing during evaluation. Decline cache proof instead.
670
- return undefined;
671
- }
672
- }
673
- return [
674
- path.relative(current, requested),
675
- link.dev,
676
- link.ino,
677
- link.mode,
678
- link.size,
679
- link.mtimeNs,
680
- link.ctimeNs,
681
- target.dev,
682
- target.ino,
683
- target.mode,
684
- target.size,
685
- target.mtimeNs,
686
- target.ctimeNs,
687
- ].join(":");
688
- } catch (error) {
689
- if (!isMissingPathError(error)) return undefined;
690
- const parent = path.dirname(current);
691
- if (parent === current) return undefined;
692
- current = parent;
693
- }
694
- }
695
- }
696
-
697
- function hostInputMetadataSignatures(
698
- files: readonly string[],
699
- ): Record<string, string> | undefined {
700
- const output: Record<string, string> = {};
701
- for (const file of files) {
702
- const signature = hostInputMetadataSignature(file);
703
- if (signature === undefined) return undefined;
704
- output[path.resolve(file)] = signature;
705
- }
706
- return output;
707
- }
708
-
709
- function isMissingPathError(error: unknown): boolean {
710
- const code = (error as NodeJS.ErrnoException | undefined)?.code;
711
- return code === "ENOENT" || code === "ENOTDIR";
712
- }
713
-
714
- /** Return config ancestry and the manifest controlling package discovery. */
715
- export function collectProjectHostInputs(
716
- project: ITtscParsedProjectConfig,
717
- includePluginDiscovery: boolean = true,
718
- ): string[] {
719
- const inputs = new Set<string>(
720
- project.configPaths.map((file) => path.resolve(file)),
721
- );
722
- if (!includePluginDiscovery) return [...inputs].sort();
723
- const manifestCandidates = collectNearestPackageJsonCandidates(project.root);
724
- for (const candidate of manifestCandidates) inputs.add(candidate);
725
- const manifest = manifestCandidates.find(existingFile);
726
- if (manifest !== undefined) {
727
- const projectManifest = readPackageManifest(manifest);
728
- if (projectManifest !== undefined) {
729
- const projectRoot = path.dirname(manifest);
730
- for (const dependency of directDependencyNames(projectManifest)) {
731
- const dependencyManifest = resolveDependencyPackageJson(
732
- dependency,
733
- projectRoot,
734
- );
735
- for (const candidate of collectDependencyManifestCandidates(
736
- dependency,
737
- manifest,
738
- dependencyManifest,
739
- )) {
740
- inputs.add(candidate);
741
- }
742
- if (dependencyManifest !== undefined) {
743
- inputs.add(path.resolve(dependencyManifest));
744
- }
745
- }
746
- }
747
- }
748
- return [...inputs].sort();
749
- }
750
-
751
- // The direct evaluator preloads ttsx's supported Node hook, whose
752
- // extensionless rescue order includes TypeScript and ESM/CJS spellings in
753
- // addition to Node's ordinary CommonJS probes.
754
- const MODULE_PROBE_EXTENSIONS = [
755
- ".ts",
756
- ".tsx",
757
- ".mts",
758
- ".cts",
759
- ".js",
760
- ".mjs",
761
- ".cjs",
762
- ".json",
763
- ".node",
764
- ] as const;
765
-
766
- /** Record every file whose later appearance can change one module resolution. */
767
- function collectModuleResolutionCandidates(
768
- specifier: string,
769
- parentFile: string,
770
- resolvedFile: string | undefined,
771
- ): string[] {
772
- const inputs = new Set<string>();
773
- const recordedBases = new Set<string>();
774
- const candidates = (base: string): string[] => [
775
- base,
776
- ...MODULE_PROBE_EXTENSIONS.map((extension) => base + extension),
777
- path.join(base, "package.json"),
778
- ...MODULE_PROBE_EXTENSIONS.map((extension) =>
779
- path.join(base, `index${extension}`),
780
- ),
781
- ];
782
- const recordManifestTargets = (
783
- value: unknown,
784
- directory: string,
785
- allowBare: boolean = false,
786
- ): void => {
787
- if (typeof value === "string") {
788
- if (
789
- value !== "" &&
790
- (allowBare || value.startsWith("./") || value.startsWith("../"))
791
- ) {
792
- recordBase(path.resolve(directory, value));
793
- }
794
- return;
795
- }
796
- if (Array.isArray(value)) {
797
- for (const item of value) {
798
- recordManifestTargets(item, directory, allowBare);
799
- }
800
- return;
801
- }
802
- if (isRecord(value)) {
803
- for (const item of Object.values(value)) {
804
- recordManifestTargets(item, directory, allowBare);
805
- }
806
- }
807
- };
808
- const recordBase = (base: string): void => {
809
- const resolvedBase = path.resolve(base);
810
- if (recordedBases.has(resolvedBase)) return;
811
- recordedBases.add(resolvedBase);
812
- for (const candidate of candidates(resolvedBase)) {
813
- inputs.add(path.resolve(candidate));
814
- }
815
- try {
816
- const manifest = readJsonFile(path.join(resolvedBase, "package.json"));
817
- if (isRecord(manifest)) {
818
- recordManifestTargets(manifest.exports, resolvedBase);
819
- recordManifestTargets(manifest.module, resolvedBase, true);
820
- recordManifestTargets(manifest.main, resolvedBase, true);
821
- }
822
- } catch {
823
- // A malformed selected manifest is reported by normal resolution/load.
824
- }
825
- };
826
- const selectedBy = (base: string): boolean => {
827
- if (resolvedFile === undefined) return false;
828
- let selected: string;
829
- try {
830
- selected = fs.realpathSync.native(resolvedFile);
831
- } catch {
832
- selected = path.resolve(resolvedFile);
833
- }
834
- for (const candidate of candidates(base)) {
835
- try {
836
- const canonical = fs.realpathSync.native(candidate);
837
- const relative = path.relative(canonical, selected);
838
- if (
839
- relative === "" ||
840
- (fs.statSync(canonical).isDirectory() &&
841
- relative !== ".." &&
842
- !relative.startsWith(`..${path.sep}`) &&
843
- !path.isAbsolute(relative))
844
- ) {
845
- return true;
846
- }
847
- } catch {
848
- // Missing candidates are the inputs this function intentionally keeps.
849
- }
850
- }
851
- return false;
852
- };
853
- const localBases = (): string[] => {
854
- if (specifier.startsWith("file:")) return [fileURLToPath(specifier)];
855
- const directory = path.dirname(parentFile);
856
- const raw = path.resolve(directory, specifier);
857
- const suffixStart = specifier.search(/[?#]/);
858
- if (suffixStart === -1) return [raw];
859
- const pathname = specifier.slice(0, suffixStart);
860
- return pathname === ""
861
- ? [raw]
862
- : [...new Set([raw, path.resolve(directory, pathname)])];
863
- };
864
-
865
- if (
866
- specifier.startsWith(".") ||
867
- path.isAbsolute(specifier) ||
868
- specifier.startsWith("file:")
869
- ) {
870
- try {
871
- for (const base of localBases()) {
872
- // An existing exact file wins before extension and directory probes.
873
- // Its own recorded identity is therefore sufficient; siblings cannot
874
- // supersede it while it exists.
875
- if (
876
- selectedByExactFile(base, resolvedFile) ||
877
- (resolvedFile === undefined && existingFile(base))
878
- ) {
879
- inputs.add(path.resolve(base));
880
- } else {
881
- recordBase(base);
882
- }
883
- }
884
- } catch {
885
- // Invalid URL spellings are diagnosed by the real resolver.
886
- }
887
- return [...inputs];
888
- }
889
- const parts = specifier.split("/");
890
- const packageParts = parts[0]?.startsWith("@")
891
- ? parts.slice(0, 2)
892
- : parts.slice(0, 1);
893
- if (packageParts.some((part) => part === undefined || part === "")) {
894
- return [...inputs];
895
- }
896
- const packageName = packageParts.join("/");
897
- const subpath = parts.slice(packageParts.length);
898
- const searchPaths = createRequire(parentFile).resolve.paths(specifier) ?? [];
899
- for (const searchPath of searchPaths) {
900
- const packageDirectory = path.join(searchPath, packageName);
901
- recordBase(packageDirectory);
902
- if (subpath.length !== 0) {
903
- recordBase(path.join(packageDirectory, ...subpath));
904
- }
905
- if (selectedBy(packageDirectory)) break;
906
- }
907
- return [...inputs];
908
- }
909
-
910
- function existingFile(file: string): boolean {
911
- try {
912
- return fs.statSync(file).isFile();
913
- } catch {
914
- return false;
915
- }
916
- }
917
-
918
- function selectedByExactFile(
919
- candidate: string,
920
- selected: string | undefined,
921
- ): boolean {
922
- if (selected === undefined) return false;
923
- try {
924
- return (
925
- fs.realpathSync.native(candidate) === fs.realpathSync.native(selected)
926
- );
927
- } catch {
928
- return path.resolve(candidate) === path.resolve(selected);
929
- }
930
- }
931
-
932
- /** Record package manifests whose later appearance can redirect discovery. */
933
- function collectDependencyManifestCandidates(
934
- packageName: string,
935
- parentFile: string,
936
- selectedManifest: string | undefined,
937
- ): string[] {
938
- const out: string[] = [];
939
- let selectedDirectory: string | undefined;
940
- if (selectedManifest !== undefined) {
941
- try {
942
- selectedDirectory = fs.realpathSync.native(
943
- path.dirname(selectedManifest),
944
- );
945
- } catch {
946
- selectedDirectory = path.resolve(path.dirname(selectedManifest));
947
- }
948
- }
949
- for (const searchPath of createRequire(parentFile).resolve.paths(
950
- packageName,
951
- ) ?? []) {
952
- const packageDirectory = path.join(searchPath, ...packageName.split("/"));
953
- out.push(path.join(packageDirectory, "package.json"));
954
- if (selectedDirectory === undefined) continue;
955
- try {
956
- if (fs.realpathSync.native(packageDirectory) === selectedDirectory) break;
957
- } catch {
958
- // Keep searching until the selected package directory is reached.
959
- }
960
- }
961
- return out;
962
- }
963
-
964
- function composePluginSources(
965
- entries: readonly ProjectPluginEntry[],
966
- plugins: readonly ITtscPlugin[],
967
- ): ITtscPlugin[] {
968
- const aggregates = plugins
969
- .map((plugin, index) => ({ index, plugin }))
970
- .filter(({ plugin }) => Array.isArray(plugin.composes));
971
- if (aggregates.length === 0) {
972
- return [...plugins];
973
- }
974
- for (const { plugin } of aggregates) {
975
- for (const target of plugin.composes!) {
976
- if (typeof target !== "string" || target.trim() === "") {
977
- throw new Error(
978
- `ttsc: plugin "${plugin.name}" has an invalid "composes" target; ` +
979
- `targets must be non-empty plugin names or transform specifiers`,
980
- );
981
- }
982
- }
983
- }
984
- // Composition is intentionally one hop only: A.composes=[B] sends B to A's
985
- // binary, but if B.composes=[C] then C uses B's original source and does NOT
986
- // cascade to A. Detect cycles (A.composes=[B] && B.composes=[A]) and throw,
987
- // otherwise the silent reswap below would mis-route both plugins.
988
- for (const { index: i, plugin: a } of aggregates) {
989
- for (const { index: j, plugin: b } of aggregates) {
990
- if (i === j) continue;
991
- const aTransform = entries[i]?.config.transform;
992
- const bTransform = entries[j]?.config.transform;
993
- const aComposesB = a.composes!.some((alias) =>
994
- matchesPluginAlias(alias, b, bTransform),
995
- );
996
- const bComposesA = b.composes!.some((alias) =>
997
- matchesPluginAlias(alias, a, aTransform),
998
- );
999
- if (aComposesB && bComposesA) {
1000
- throw new Error(
1001
- `ttsc: plugin composes cycle detected between "${a.name}" and "${b.name}"; ` +
1002
- `each plugin lists the other in its "composes" array — composition is one hop only, not transitive`,
1003
- );
1004
- }
1005
- }
1006
- }
1007
- return plugins.map((plugin, index) => {
1008
- const transform = entries[index]?.config.transform;
1009
- const matchingAggregates = aggregates.filter(
1010
- ({ index: aggregateIndex, plugin: aggregatePlugin }) =>
1011
- aggregateIndex !== index &&
1012
- aggregatePlugin.composes!.some((alias) =>
1013
- matchesPluginAlias(alias, plugin, transform),
1014
- ),
1015
- );
1016
- if (matchingAggregates.length > 1) {
1017
- throw new Error(
1018
- `ttsc: plugin "${plugin.name}" is composed by multiple aggregate plugins; ` +
1019
- `each plugin entry can be redirected to only one aggregate native host`,
1020
- );
1021
- }
1022
- const aggregate = matchingAggregates[0];
1023
- if (aggregate === undefined) {
1024
- return plugin;
1025
- }
1026
- // A composed plugin's source is rerouted to the aggregate's binary,
1027
- // so its own `contributors` would link into a different host than
1028
- // it was authored against. The "one binary" guarantee in the
1029
- // protocol doc holds only when the composed plugin defers entirely
1030
- // to the aggregate; reject early instead of silently producing two
1031
- // diverging binaries.
1032
- if (plugin.contributors && plugin.contributors.length > 0) {
1033
- throw new Error(
1034
- `ttsc: plugin "${plugin.name}" is composed by "${aggregate.plugin.name}" but declares its own "contributors"; ` +
1035
- `move the contributors onto the aggregate plugin or drop the composes redirect`,
1036
- );
1037
- }
1038
- return {
1039
- ...plugin,
1040
- source: aggregate.plugin.source,
1041
- contributors: aggregate.plugin.contributors,
1042
- // The composed plugin's runtime BINARY is the aggregate's binary,
1043
- // so the CLI surface (which flags the sidecar parses) is the
1044
- // aggregate's. Inherit `capabilities` from the aggregate so a
1045
- // capability the aggregate declares — e.g. threadingArgs — does
1046
- // not get silently dropped just because the composed entry's own
1047
- // descriptor omitted it. If the aggregate did not set capabilities
1048
- // we keep the composed plugin's own as a fallback.
1049
- capabilities: aggregate.plugin.capabilities ?? plugin.capabilities,
1050
- };
1051
- });
1052
- }
1053
-
1054
- function matchesPluginAlias(
1055
- alias: string,
1056
- plugin: ITtscPlugin,
1057
- transform: ITtscProjectPluginConfig["transform"],
1058
- ): boolean {
1059
- return (
1060
- alias === plugin.name ||
1061
- (typeof transform === "string" && alias === transform)
1062
- );
1063
- }
1064
-
1065
- /**
1066
- * Return `true` when the project has at least one enabled plugin entry.
1067
- *
1068
- * Used by callers that need to skip plugin-specific work when no plugins are
1069
- * configured, without paying the full cost of `loadProjectPlugins`.
1070
- *
1071
- * @param entries - Explicit entries; `false` always returns `false`.
1072
- */
1073
- export function hasProjectPluginEntries(
1074
- project: ITtscParsedProjectConfig,
1075
- entries?: readonly ITtscProjectPluginConfig[] | false,
1076
- ): boolean {
1077
- if (entries === false) {
1078
- return false;
1079
- }
1080
- return resolvePluginEntries(project, entries).some(
1081
- (entry) => entry.config.enabled !== false,
1082
- );
1083
- }
1084
-
1085
- function resolvePluginEntries(
1086
- project: ITtscParsedProjectConfig,
1087
- entries?: readonly ITtscProjectPluginConfig[],
1088
- ): ProjectPluginEntry[] {
1089
- if (entries !== undefined) {
1090
- return entries.map((config) => ({
1091
- baseDir: project.root,
1092
- config,
1093
- }));
1094
- }
1095
- const configured = project.compilerOptions.plugins.map((config, index) => {
1096
- // A bare/package plugin specifier (e.g. "typia/lib/transform") must resolve
1097
- // from the project's own node_modules, not from the tsconfig that declared
1098
- // it: an `extends`ed base config (a shared `tests/config/tsconfig.json`)
1099
- // declares the plugin, but the package is installed under the consuming
1100
- // project. Only a relative specifier ("./plugin") is meaningful relative to
1101
- // the declaring config's directory. Mirrors discoverPackagePluginEntries.
1102
- const declaringDir = project.pluginBaseDirs[index];
1103
- const baseDir =
1104
- typeof config.transform === "string" &&
1105
- isRelativePluginSpecifier(config.transform) &&
1106
- declaringDir !== undefined
1107
- ? declaringDir
1108
- : project.root;
1109
- return { baseDir, config };
1110
- });
1111
- return [...configured, ...discoverPackagePluginEntries(project, configured)];
1112
- }
1113
-
1114
- function discoverPackagePluginEntries(
1115
- project: ITtscParsedProjectConfig,
1116
- configured: readonly ProjectPluginEntry[],
1117
- ): ProjectPluginEntry[] {
1118
- const projectPackageJson = findNearestPackageJson(project.root);
1119
- if (projectPackageJson === undefined) {
1120
- return [];
1121
- }
1122
- const projectPackageRoot = path.dirname(projectPackageJson);
1123
- const projectManifest = readPackageManifest(projectPackageJson);
1124
- if (projectManifest === undefined) {
1125
- return [];
1126
- }
1127
-
1128
- const configuredTransforms = createConfiguredTransformSet(configured);
1129
- const out: ProjectPluginEntry[] = [];
1130
- for (const name of directDependencyNames(projectManifest)) {
1131
- const packageJson = resolveDependencyPackageJson(name, projectPackageRoot);
1132
- if (packageJson === undefined) {
1133
- continue;
1134
- }
1135
- const manifest = readPackageManifest(packageJson);
1136
- const config = readPackagePluginConfig(name, manifest);
1137
- if (config === undefined || config.enabled === false) {
1138
- continue;
1139
- }
1140
- const packageRoot = path.dirname(packageJson);
1141
- const transform = config.transform;
1142
- if (typeof transform !== "string") {
1143
- continue;
1144
- }
1145
- const baseDir = isRelativePluginSpecifier(transform)
1146
- ? packageRoot
1147
- : projectPackageRoot;
1148
- const resolved = resolvePluginRequest(transform, baseDir);
1149
- if (hasConfiguredTransform(configuredTransforms, transform, resolved)) {
1150
- continue;
1151
- }
1152
- out.push({
1153
- baseDir,
1154
- config,
1155
- });
1156
- addConfiguredTransform(configuredTransforms, transform, resolved);
1157
- }
1158
- return out;
1159
- }
1160
-
1161
- type ConfiguredTransformSet = {
1162
- raw: Set<string>;
1163
- resolved: Set<string>;
1164
- };
1165
-
1166
- function createConfiguredTransformSet(
1167
- entries: readonly ProjectPluginEntry[],
1168
- ): ConfiguredTransformSet {
1169
- const raw = new Set<string>();
1170
- const resolved = new Set<string>();
1171
- for (const entry of entries) {
1172
- const transform = entry.config.transform;
1173
- if (typeof transform !== "string" || transform.length === 0) {
1174
- continue;
1175
- }
1176
- if (!isRelativePluginSpecifier(transform)) {
1177
- raw.add(transform);
1178
- }
1179
- try {
1180
- resolved.add(resolvePluginRequest(transform, entry.baseDir));
1181
- } catch {
1182
- // Keep the normal plugin loading error path for invalid explicit entries.
1183
- }
1184
- }
1185
- return { raw, resolved };
1186
- }
1187
-
1188
- function hasConfiguredTransform(
1189
- configuredTransforms: ConfiguredTransformSet,
1190
- transform: string,
1191
- resolved: string,
1192
- ): boolean {
1193
- return (
1194
- configuredTransforms.resolved.has(resolved) ||
1195
- (!isRelativePluginSpecifier(transform) &&
1196
- configuredTransforms.raw.has(transform))
1197
- );
1198
- }
1199
-
1200
- function addConfiguredTransform(
1201
- configuredTransforms: ConfiguredTransformSet,
1202
- transform: string,
1203
- resolved: string,
1204
- ): void {
1205
- if (!isRelativePluginSpecifier(transform)) {
1206
- configuredTransforms.raw.add(transform);
1207
- }
1208
- configuredTransforms.resolved.add(resolved);
1209
- }
1210
-
1211
- function directDependencyNames(manifest: PackageManifest): string[] {
1212
- const seen = new Set<string>();
1213
- const out: string[] = [];
1214
- for (const dependencies of [
1215
- manifest.dependencies,
1216
- manifest.devDependencies,
1217
- ]) {
1218
- if (!isRecord(dependencies)) {
1219
- continue;
1220
- }
1221
- for (const name of Object.keys(dependencies)) {
1222
- if (seen.has(name)) {
1223
- continue;
1224
- }
1225
- seen.add(name);
1226
- out.push(name);
1227
- }
1228
- }
1229
- return out;
1230
- }
1231
-
1232
- function resolveDependencyPackageJson(
1233
- name: string,
1234
- projectRoot: string,
1235
- ): string | undefined {
1236
- const direct = path.join(projectRoot, "node_modules", ...name.split("/"));
1237
- const directManifest = path.join(direct, "package.json");
1238
- if (existingFile(directManifest)) {
1239
- return resolveRealPath(directManifest);
1240
- }
1241
- const projectPackage = path.join(projectRoot, "package.json");
1242
- const projectRequire = createRequire(projectPackage);
1243
- try {
1244
- return resolveRealPath(projectRequire.resolve(`${name}/package.json`));
1245
- } catch {
1246
- try {
1247
- return findNearestPackageJson(projectRequire.resolve(name));
1248
- } catch {
1249
- return undefined;
1250
- }
1251
- }
1252
- }
1253
-
1254
- function findNearestPackageJson(location: string): string | undefined {
1255
- const selected =
1256
- collectNearestPackageJsonCandidates(location).find(existingFile);
1257
- return selected === undefined ? undefined : resolveRealPath(selected);
1258
- }
1259
-
1260
- /** Every package-scope candidate through the first regular manifest file. */
1261
- function collectNearestPackageJsonCandidates(location: string): string[] {
1262
- let current = fs.statSync(location).isDirectory()
1263
- ? location
1264
- : path.dirname(location);
1265
- const candidates: string[] = [];
1266
- while (true) {
1267
- const manifest = path.resolve(current, "package.json");
1268
- candidates.push(manifest);
1269
- if (existingFile(manifest)) return candidates;
1270
- const parent = path.dirname(current);
1271
- if (parent === current) return candidates;
1272
- current = parent;
1273
- }
1274
- }
1275
-
1276
- /**
1277
- * Read a package manifest, or `undefined` when the file is absent or is not a
1278
- * JSON object. A malformed manifest throws naming the file: these are usually
1279
- * files the user did not author, which makes an unattributed `JSON.parse`
1280
- * message worse here than anywhere else.
1281
- */
1282
- function readPackageManifest(file: string): PackageManifest | undefined {
1283
- if (!existingFile(file)) {
1284
- return undefined;
1285
- }
1286
- const parsed = readJsonFile(file);
1287
- return isRecord(parsed) ? (parsed as PackageManifest) : undefined;
1288
- }
1289
-
1290
- function readPackagePluginConfig(
1291
- packageName: string,
1292
- manifest: PackageManifest | undefined,
1293
- ): ITtscProjectPluginConfig | undefined {
1294
- const ttsc = manifest?.ttsc;
1295
- if (!isRecord(ttsc) || !("plugin" in ttsc)) {
1296
- return undefined;
1297
- }
1298
- const plugin = ttsc.plugin;
1299
- if (!isRecord(plugin) || Array.isArray(plugin)) {
1300
- throw new Error(
1301
- `ttsc: package ${JSON.stringify(packageName)} declares invalid "ttsc.plugin"; expected an object`,
1302
- );
1303
- }
1304
- if (typeof plugin.transform !== "string" || plugin.transform.length === 0) {
1305
- throw new Error(
1306
- `ttsc: package ${JSON.stringify(packageName)} declares invalid "ttsc.plugin.transform"; expected a non-empty string`,
1307
- );
1308
- }
1309
- return { ...plugin } as ITtscProjectPluginConfig;
1310
- }
1311
-
1312
- function isRecord(value: unknown): value is Record<string, unknown> {
1313
- return typeof value === "object" && value !== null;
1314
- }
1315
-
1316
- function orderNativePlugins(
1317
- plugins: readonly ITtscLoadedNativePlugin[],
1318
- ): ITtscLoadedNativePlugin[] {
1319
- return [
1320
- ...plugins.filter((plugin) => plugin.stage === "check"),
1321
- ...plugins.filter((plugin) => plugin.stage === "transform"),
1322
- ];
1323
- }
1324
-
1325
- function loadPluginEntry(
1326
- entry: ITtscProjectPluginConfig,
1327
- base: Omit<ITtscPluginFactoryContext, "dirname" | "filename">,
1328
- request: string,
1329
- effectiveEnv: NodeJS.ProcessEnv,
1330
- ): {
1331
- hostInputHashes: Record<string, string | null>;
1332
- hostInputRealpaths: Record<string, string | null>;
1333
- hostInputs: string[];
1334
- plugin: ITtscPlugin;
1335
- } {
1336
- const specifier = entry.transform;
1337
- if (typeof specifier !== "string" || specifier.length === 0) {
1338
- throw new Error(`ttsc: plugin entry is missing a string "transform" field`);
1339
- }
1340
-
1341
- // `dirname`/`filename` are per-entry: each plugin entry resolves to its own
1342
- // descriptor module, so they are derived here from the resolved `request`
1343
- // rather than carried on the shared base context. They give factories a
1344
- // load-mode-independent stand-in for `__dirname`/`__filename`, which are
1345
- // undefined when a descriptor loads through ttsx or as ESM.
1346
- const context: ITtscPluginFactoryContext = {
1347
- ...base,
1348
- dirname: path.dirname(request),
1349
- filename: request,
1350
- };
1351
- const loaded = loadPluginDescriptor(request, context, effectiveEnv);
1352
- if (isTtscPlugin(loaded.descriptor)) {
1353
- rejectJsTransformFunctions(specifier, loaded.descriptor);
1354
- return {
1355
- hostInputHashes: loaded.hostInputHashes,
1356
- hostInputRealpaths: loaded.hostInputRealpaths,
1357
- hostInputs: loaded.inputs,
1358
- plugin: loaded.descriptor,
1359
- };
1360
- }
1361
- throw new Error(
1362
- `ttsc: plugin "${specifier}" does not export a valid ttsc plugin`,
1363
- );
1364
- }
1365
-
1366
- /**
1367
- * Require a plugin descriptor entry, falling back to `ttsx` when Node cannot
1368
- * load a `.ts` source entry directly.
1369
- *
1370
- * A descriptor entry that is `.ts` source — especially a package root that
1371
- * re-exports a runtime alongside the descriptor — fails Node's loader on its
1372
- * first extensionless import or un-stripped type, and its imports can fan out
1373
- * into a whole transitive graph of source packages. Rather than reimplement
1374
- * that graph build, run the entry through `ttsx`, which already builds each
1375
- * `.ts` dependency on demand. The run is forced plugins-off across the whole
1376
- * graph (`--no-plugins` for the entry, `TTSC_PLUGIN_DESCRIPTOR_LOAD` for every
1377
- * dependency), so the descriptor's own — possibly self-hosting — transform
1378
- * never runs and cannot deadlock. A package that loads directly (a compiled
1379
- * descriptor, or Bun's native `.ts`) never reaches the fallback.
1380
- */
1381
- function loadPluginDescriptor(
1382
- request: string,
1383
- context: ITtscPluginFactoryContext,
1384
- effectiveEnv: NodeJS.ProcessEnv,
1385
- ): IsolatedPluginDescriptor {
1386
- try {
1387
- return loadCommonJsDescriptor(request, context, effectiveEnv);
1388
- } catch (error) {
1389
- if (
1390
- !TS_SOURCE_PATTERN.test(request) ||
1391
- !(error instanceof CommonJsDescriptorLoadError) ||
1392
- !error.retryWithTtsx
1393
- ) {
1394
- throw error;
1395
- }
1396
- const loaded = loadDescriptorViaTtsx(request, context, effectiveEnv);
1397
- if (loaded === undefined) {
1398
- throw error;
1399
- }
1400
- return loaded;
1401
- }
1402
- }
1403
-
1404
- interface IsolatedPluginDescriptor {
1405
- descriptor: unknown;
1406
- hostInputHashes: Record<string, string | null>;
1407
- hostInputRealpaths: Record<string, string | null>;
1408
- inputs: string[];
1409
- }
1410
-
1411
- class CommonJsDescriptorLoadError extends Error {
1412
- public constructor(
1413
- message: string,
1414
- public readonly retryWithTtsx: boolean,
1415
- ) {
1416
- super(message);
1417
- this.name = "CommonJsDescriptorLoadError";
1418
- }
1419
- }
1420
-
1421
- /**
1422
- * Evaluate one CommonJS descriptor in a fresh runtime module-cache generation.
1423
- *
1424
- * Reloading an external descriptor dependency inside this process has no safe
1425
- * cache operation: retaining it serves stale exports, while deleting it splits
1426
- * any application singleton that required the same module first. Isolation
1427
- * gives every descriptor load current bytes without mutating the host's cache.
1428
- * The child invokes the factory before walking its graph, so lazy `require()`
1429
- * calls are included, and a failed first load cannot strand poisoned children.
1430
- */
1431
- function loadCommonJsDescriptor(
1432
- request: string,
1433
- context: ITtscPluginFactoryContext,
1434
- effectiveEnv: NodeJS.ProcessEnv,
1435
- ): IsolatedPluginDescriptor {
1436
- const runtime = pluginDescriptorRuntimeBinary(effectiveEnv);
1437
- const runtimeCapabilities = javascriptRuntimeCapabilities(
1438
- runtime,
1439
- effectiveEnv,
1440
- context.projectRoot,
1441
- );
1442
- const node =
1443
- !runtimeCapabilities.bun &&
1444
- runtimeCapabilities.registerHooks &&
1445
- runtimeCapabilities.executable !== undefined
1446
- ? runtimeCapabilities.executable
1447
- : resolveNodeBinary(effectiveEnv, context.projectRoot);
1448
- const dir = createEvaluationTempDir();
1449
- const out = path.join(dir, "descriptor.json");
1450
- const inputsOut = path.join(dir, "descriptor-inputs.ndjson");
1451
- const diagnostics = path.join(dir, "descriptor.stderr");
1452
- const bunConfig = path.join(dir, "bunfig.toml");
1453
- const runtimeHookPreload = path.join(
1454
- __dirname,
1455
- "..",
1456
- "..",
1457
- "launcher",
1458
- "internal",
1459
- "runtimeHookPreload.js",
1460
- );
1461
- try {
1462
- if (runtimeCapabilities.bun) {
1463
- // A descriptor receives exactly the environment supplied by its ttsc
1464
- // invocation. Bun otherwise auto-loads project `.env*`, local/global
1465
- // bunfig preloads and loaders, and may install a missing package from the
1466
- // network. Those implicit authorities are neither part of Node's loader
1467
- // contract nor reproducible host inputs, so isolate this evaluator from
1468
- // them while retaining Bun's native TypeScript/module semantics.
1469
- fs.writeFileSync(bunConfig, "", "utf8");
1470
- }
1471
- const diagnosticsFd = fs.openSync(diagnostics, "w");
1472
- let result: ReturnType<typeof childProcess.spawnSync>;
1473
- try {
1474
- result = spawnSyncResilient(
1475
- runtime,
1476
- [
1477
- ...(runtimeCapabilities.bun
1478
- ? [
1479
- "--no-env-file",
1480
- "--no-install",
1481
- `--config=${bunConfig}`,
1482
- `--tsconfig-override=${context.tsconfig}`,
1483
- ]
1484
- : []),
1485
- ...(runtimeCapabilities.registerHooks
1486
- ? ["--require", runtimeHookPreload]
1487
- : []),
1488
- "-e",
1489
- COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE,
1490
- ],
1491
- {
1492
- cwd: context.projectRoot,
1493
- env: {
1494
- ...effectiveEnv,
1495
- // The direct evaluator may be Bun, but ttsx and native config
1496
- // loaders require a real Node runtime with synchronous hooks.
1497
- ...(node === undefined ? {} : { TTSC_NODE_BINARY: node }),
1498
- TTSC_TTSX_BINARY:
1499
- effectiveEnv.TTSC_TTSX_BINARY ?? process.env.TTSC_TTSX_BINARY,
1500
- TTSC_PLUGIN_CONTEXT: JSON.stringify(context),
1501
- TTSC_PLUGIN_DESCRIPTOR_LOAD: "1",
1502
- TTSC_PLUGIN_DESCRIPTOR_OUT: out,
1503
- TTSC_PLUGIN_DESCRIPTOR_INPUTS_ACTIVE: "1",
1504
- TTSC_PLUGIN_DESCRIPTOR_INPUTS_OUT: inputsOut,
1505
- TTSC_PLUGIN_ENTRY: request,
1506
- },
1507
- // Hold direct-evaluator diagnostics until its retry decision is
1508
- // known. A successful ttsx fallback must not inherit the expected
1509
- // loader stack from the discarded first attempt.
1510
- stdio: ["ignore", diagnosticsFd, diagnosticsFd],
1511
- windowsHide: true,
1512
- },
1513
- { stderr: diagnostics, stdout: diagnostics },
1514
- );
1515
- } finally {
1516
- fs.closeSync(diagnosticsFd);
1517
- }
1518
- const failure = commonJsDescriptorProcessFailure(result, request);
1519
- if (failure !== undefined) {
1520
- const reason = pluginDescriptorFailureReason(out);
1521
- const retryWithTtsx = commonJsDescriptorRetryWithTtsx(out);
1522
- if (!retryWithTtsx) replayEvaluationDiagnostics(diagnostics);
1523
- throw new CommonJsDescriptorLoadError(
1524
- reason === "" ? failure.message : `${failure.message}\n${reason}`,
1525
- retryWithTtsx,
1526
- );
1527
- }
1528
- replayEvaluationDiagnostics(diagnostics);
1529
- if (!fs.existsSync(out)) {
1530
- throw new Error(
1531
- `ttsc: plugin descriptor "${request}" evaluation in an isolated process produced no descriptor output.`,
1532
- );
1533
- }
1534
- let parsed: unknown;
1535
- try {
1536
- parsed = JSON.parse(fs.readFileSync(out, "utf8"));
1537
- } catch (error) {
1538
- throw new Error(
1539
- `ttsc: plugin descriptor "${request}" produced invalid isolated output: ${errorMessage(error)}`,
1540
- );
1541
- }
1542
- if (!isRecord(parsed) || !Array.isArray(parsed.inputs)) {
1543
- throw new Error(
1544
- `ttsc: plugin descriptor "${request}" produced an invalid isolated result`,
1545
- );
1546
- }
1547
- const parsedHashes = isRecord(parsed.inputHashes)
1548
- ? Object.fromEntries(
1549
- Object.entries(parsed.inputHashes).flatMap(([file, hash]) =>
1550
- typeof hash === "string" || hash === null
1551
- ? [[path.resolve(file), hash]]
1552
- : [],
1553
- ),
1554
- )
1555
- : {};
1556
- const parsedRealpaths = isRecord(parsed.inputRealpaths)
1557
- ? Object.fromEntries(
1558
- Object.entries(parsed.inputRealpaths).flatMap(([file, realpath]) =>
1559
- (typeof realpath === "string" && path.isAbsolute(realpath)) ||
1560
- realpath === null
1561
- ? [
1562
- [
1563
- path.resolve(file),
1564
- realpath === null ? null : path.resolve(realpath),
1565
- ],
1566
- ]
1567
- : [],
1568
- ),
1569
- )
1570
- : {};
1571
- const stableParsedRealpaths = mergeObservedHostInputRealpaths(
1572
- parsedRealpaths,
1573
- realpathHostInputPaths(Object.keys(parsedRealpaths)),
1574
- );
1575
- for (const input of parsed.inputs) {
1576
- const absolute = path.resolve(String(input));
1577
- if (
1578
- !Object.prototype.hasOwnProperty.call(stableParsedRealpaths, absolute)
1579
- ) {
1580
- delete parsedHashes[absolute];
1581
- }
1582
- }
1583
- const runtimeInputs = readTtsxDescriptorInputs(inputsOut, request);
1584
- return {
1585
- descriptor: parsed.descriptor,
1586
- hostInputHashes: omitUnstableHostInputHashes(
1587
- mergeObservedHostInputHashes(
1588
- parsedHashes,
1589
- runtimeInputs.hostInputHashes,
1590
- ),
1591
- runtimeInputs.unstableInputs,
1592
- ),
1593
- hostInputRealpaths: mergeObservedHostInputRealpaths(
1594
- stableParsedRealpaths,
1595
- runtimeInputs.hostInputRealpaths,
1596
- ),
1597
- inputs: [
1598
- ...new Set([
1599
- ...parsed.inputs.map((input) => String(input)),
1600
- ...runtimeInputs.inputs,
1601
- ]),
1602
- ].sort(),
1603
- };
1604
- } finally {
1605
- removeEvaluationTempDir(dir);
1606
- }
1607
- }
1608
-
1609
- /** Validate plugin-declared universal host inputs. */
1610
- function validatePluginHostInputs(
1611
- plugin: ITtscPlugin,
1612
- index: number,
1613
- ): string[] {
1614
- const label = plugin.name ?? `#${index + 1}`;
1615
- if (plugin.hostInputs === undefined) return [];
1616
- if (!Array.isArray(plugin.hostInputs)) {
1617
- throw new Error(
1618
- `ttsc: plugin ${JSON.stringify(label)} has invalid "hostInputs"; expected an array of absolute paths`,
1619
- );
1620
- }
1621
- return plugin.hostInputs.map((file) => {
1622
- if (typeof file !== "string" || !path.isAbsolute(file)) {
1623
- throw new Error(
1624
- `ttsc: plugin ${JSON.stringify(label)} has invalid "hostInputs" entry ${JSON.stringify(file)}; expected an absolute path`,
1625
- );
1626
- }
1627
- return path.resolve(file);
1628
- });
1629
- }
1630
-
1631
- /** Validate descriptor-supplied evaluation fingerprints for host inputs. */
1632
- function validatePluginHostInputHashes(
1633
- plugin: ITtscPlugin,
1634
- index: number,
1635
- hostInputs: readonly string[],
1636
- ): Record<string, string | null> {
1637
- const label = plugin.name ?? `#${index + 1}`;
1638
- if (plugin.hostInputHashes === undefined) return {};
1639
- if (
1640
- !isRecord(plugin.hostInputHashes) ||
1641
- Array.isArray(plugin.hostInputHashes)
1642
- ) {
1643
- throw new Error(
1644
- `ttsc: plugin ${JSON.stringify(label)} has invalid "hostInputHashes"; expected an object keyed by absolute hostInputs paths`,
1645
- );
1646
- }
1647
- const allowed = new Set(hostInputs.map((file) => path.resolve(file)));
1648
- const output: Record<string, string | null> = {};
1649
- for (const [file, hash] of Object.entries(plugin.hostInputHashes)) {
1650
- if (!path.isAbsolute(file)) {
1651
- throw new Error(
1652
- `ttsc: plugin ${JSON.stringify(label)} has invalid "hostInputHashes" key ${JSON.stringify(file)}; expected an absolute path`,
1653
- );
1654
- }
1655
- const absolute = path.resolve(file);
1656
- if (!allowed.has(absolute)) {
1657
- throw new Error(
1658
- `ttsc: plugin ${JSON.stringify(label)} fingerprints ${JSON.stringify(file)} without listing it in "hostInputs"`,
1659
- );
1660
- }
1661
- if (
1662
- hash !== null &&
1663
- (typeof hash !== "string" || !/^[0-9a-f]{64}$/.test(hash))
1664
- ) {
1665
- throw new Error(
1666
- `ttsc: plugin ${JSON.stringify(label)} has invalid fingerprint for ${JSON.stringify(file)}; expected a lowercase SHA-256 digest or null`,
1667
- );
1668
- }
1669
- output[absolute] = hash;
1670
- }
1671
- return output;
1672
- }
1673
-
1674
- /** Validate descriptor-supplied physical identities for host inputs. */
1675
- function validatePluginHostInputRealpaths(
1676
- plugin: ITtscPlugin,
1677
- index: number,
1678
- hostInputs: readonly string[],
1679
- ): Record<string, string | null> {
1680
- const label = plugin.name ?? `#${index + 1}`;
1681
- if (plugin.hostInputRealpaths === undefined) return {};
1682
- if (
1683
- !isRecord(plugin.hostInputRealpaths) ||
1684
- Array.isArray(plugin.hostInputRealpaths)
1685
- ) {
1686
- throw new Error(
1687
- `ttsc: plugin ${JSON.stringify(label)} has invalid "hostInputRealpaths"; expected an object keyed by absolute hostInputs paths`,
1688
- );
1689
- }
1690
- const allowed = new Set(hostInputs.map((file) => path.resolve(file)));
1691
- const output: Record<string, string | null> = {};
1692
- for (const [file, realpath] of Object.entries(plugin.hostInputRealpaths)) {
1693
- if (!path.isAbsolute(file)) {
1694
- throw new Error(
1695
- `ttsc: plugin ${JSON.stringify(label)} has invalid "hostInputRealpaths" key ${JSON.stringify(file)}; expected an absolute path`,
1696
- );
1697
- }
1698
- const absolute = path.resolve(file);
1699
- if (!allowed.has(absolute)) {
1700
- throw new Error(
1701
- `ttsc: plugin ${JSON.stringify(label)} identifies ${JSON.stringify(file)} without listing it in "hostInputs"`,
1702
- );
1703
- }
1704
- if (
1705
- realpath !== null &&
1706
- (typeof realpath !== "string" || !path.isAbsolute(realpath))
1707
- ) {
1708
- throw new Error(
1709
- `ttsc: plugin ${JSON.stringify(label)} has invalid physical identity for ${JSON.stringify(file)}; expected an absolute realpath or null`,
1710
- );
1711
- }
1712
- output[absolute] =
1713
- realpath === null ? null : path.resolve(realpath as string);
1714
- }
1715
- return output;
1716
- }
1717
-
1718
- /** Merge snapshots and omit every path observed in contradictory states. */
1719
- function mergeObservedHostInputHashes(
1720
- ...sources: Readonly<Record<string, string | null>>[]
1721
- ): Record<string, string | null> {
1722
- const conflicts = new Set<string>();
1723
- const output: Record<string, string | null> = {};
1724
- for (const source of sources) {
1725
- for (const [file, hash] of Object.entries(source)) {
1726
- const absolute = path.resolve(file);
1727
- if (conflicts.has(absolute)) continue;
1728
- if (
1729
- Object.prototype.hasOwnProperty.call(output, absolute) &&
1730
- output[absolute] !== hash
1731
- ) {
1732
- delete output[absolute];
1733
- conflicts.add(absolute);
1734
- continue;
1735
- }
1736
- output[absolute] = hash;
1737
- }
1738
- }
1739
- return output;
1740
- }
1741
-
1742
- const mergeObservedHostInputRealpaths = mergeObservedHostInputHashes;
1743
-
1744
- /** Prevent a later plugin claim from reviving an unstable loader input. */
1745
- function mergePluginHostInputHashes(
1746
- first: Readonly<Record<string, string | null>>,
1747
- second: Readonly<Record<string, string | null>>,
1748
- loaderInputs: readonly string[],
1749
- pluginInputs: readonly string[],
1750
- ): Record<string, string | null> {
1751
- const output = { ...first };
1752
- const guarded = new Set(loaderInputs.map((file) => path.resolve(file)));
1753
- for (const input of pluginInputs) {
1754
- const absolute = path.resolve(input);
1755
- if (!Object.prototype.hasOwnProperty.call(second, absolute)) {
1756
- delete output[absolute];
1757
- }
1758
- }
1759
- for (const [file, hash] of Object.entries(second)) {
1760
- const absolute = path.resolve(file);
1761
- if (
1762
- guarded.has(absolute) &&
1763
- !Object.prototype.hasOwnProperty.call(first, absolute)
1764
- ) {
1765
- continue;
1766
- }
1767
- if (
1768
- Object.prototype.hasOwnProperty.call(output, absolute) &&
1769
- output[absolute] !== hash
1770
- ) {
1771
- delete output[absolute];
1772
- continue;
1773
- }
1774
- output[absolute] = hash;
1775
- }
1776
- return output;
1777
- }
1778
-
1779
- function omitUnstableHostInputHashes(
1780
- hashes: Record<string, string | null>,
1781
- unstableInputs: readonly string[],
1782
- ): Record<string, string | null> {
1783
- for (const input of unstableInputs) delete hashes[path.resolve(input)];
1784
- return hashes;
1785
- }
1786
-
1787
- /** CommonJS evaluator emitted into a clean Node process for every load. */
1788
- export const COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE = [
1789
- `const crypto = require("node:crypto");`,
1790
- `const fs = require("node:fs");`,
1791
- `const Module = require("node:module");`,
1792
- `const path = require("node:path");`,
1793
- `const { fileURLToPath } = require("node:url");`,
1794
- `const out = process.env.TTSC_PLUGIN_DESCRIPTOR_OUT;`,
1795
- `let retryWithTtsx = false;`,
1796
- `const moduleLoadFailures = new WeakMap();`,
1797
- `const moduleResolutionFailures = new WeakMap();`,
1798
- `function existingFile(file) { try { return fs.statSync(file).isFile(); } catch { return false; } }`,
1799
- `function shouldRetryWithTtsx(error) {`,
1800
- ` const loadFailure = error && (typeof error === "object" || typeof error === "function") ? moduleLoadFailures.get(error) : undefined;`,
1801
- ` if (loadFailure?.retryWithTtsx === true) return true;`,
1802
- ` const failure = error && (typeof error === "object" || typeof error === "function") ? moduleResolutionFailures.get(error) : undefined;`,
1803
- ` return failure?.retryWithTtsx === true;`,
1804
- `}`,
1805
- `try {`,
1806
- ` const request = process.env.TTSC_PLUGIN_ENTRY;`,
1807
- ` const context = JSON.parse(process.env.TTSC_PLUGIN_CONTEXT);`,
1808
- ` const inputs = new Set();`,
1809
- ` const inputHashes = new Map();`,
1810
- ` const inputRealpaths = new Map();`,
1811
- ` const inputSignatures = new Map();`,
1812
- ` const unstableInputHashes = new Set();`,
1813
- ` function missingPathError(error) { return error && (error.code === "ENOENT" || error.code === "ENOTDIR"); }`,
1814
- ` function inputMetadataSignature(file) {`,
1815
- ` const requested = path.resolve(file);`,
1816
- ` let current = requested;`,
1817
- ` for (;;) {`,
1818
- ` try {`,
1819
- ` const link = fs.lstatSync(current, { bigint: true });`,
1820
- ` let target = link;`,
1821
- ` if (link.isSymbolicLink()) {`,
1822
- ` try { target = fs.statSync(current, { bigint: true }); }`,
1823
- ` catch { return undefined; }`,
1824
- ` }`,
1825
- ` return [path.relative(current, requested), link.dev, link.ino, link.mode, link.size, link.mtimeNs, link.ctimeNs, target.dev, target.ino, target.mode, target.size, target.mtimeNs, target.ctimeNs].join(":");`,
1826
- ` } catch (error) {`,
1827
- ` if (!missingPathError(error)) return undefined;`,
1828
- ` const parent = path.dirname(current);`,
1829
- ` if (parent === current) return undefined;`,
1830
- ` current = parent;`,
1831
- ` }`,
1832
- ` }`,
1833
- ` }`,
1834
- ` function recordOneInput(file) {`,
1835
- ` file = path.resolve(file);`,
1836
- ` inputs.add(file);`,
1837
- ` if (unstableInputHashes.has(file)) return;`,
1838
- ` const beforeSignature = inputMetadataSignature(file);`,
1839
- ` let observedRealpath;`,
1840
- ` try { observedRealpath = fs.realpathSync.native(file); } catch { observedRealpath = null; }`,
1841
- ` let observed;`,
1842
- ` try { observed = fs.statSync(file).isDirectory() ? crypto.createHash("sha256").update("ttsc:host-input:directory\\0").digest("hex") : crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex"); } catch { observed = null; }`,
1843
- ` const afterSignature = inputMetadataSignature(file);`,
1844
- ` if (beforeSignature === undefined || afterSignature === undefined || beforeSignature !== afterSignature || (inputSignatures.has(file) && inputSignatures.get(file) !== afterSignature) || (inputRealpaths.has(file) && inputRealpaths.get(file) !== observedRealpath) || (inputHashes.has(file) && inputHashes.get(file) !== observed)) { inputHashes.delete(file); inputRealpaths.delete(file); inputSignatures.delete(file); unstableInputHashes.add(file); return; }`,
1845
- ` inputSignatures.set(file, afterSignature);`,
1846
- ` inputRealpaths.set(file, observedRealpath);`,
1847
- ` inputHashes.set(file, observed);`,
1848
- ` }`,
1849
- ` function recordInput(file) {`,
1850
- ` file = path.resolve(file);`,
1851
- ` recordOneInput(file);`,
1852
- ` const parsed = path.parse(file);`,
1853
- ` let current = parsed.root;`,
1854
- ` const relative = path.relative(parsed.root, file);`,
1855
- ` for (const segment of relative.split(path.sep).slice(0, -1)) {`,
1856
- ` if (segment === "") continue;`,
1857
- ` current = path.join(current, segment);`,
1858
- ` try {`,
1859
- ` if (fs.lstatSync(current).isSymbolicLink()) recordOneInput(current);`,
1860
- ` } catch {`,
1861
- ` break;`,
1862
- ` }`,
1863
- ` }`,
1864
- ` }`,
1865
- ` function asFile(resolved) {`,
1866
- ` if (typeof resolved !== "string") return undefined;`,
1867
- ` if (!resolved.startsWith("file:")) return path.isAbsolute(resolved) ? path.resolve(resolved) : undefined;`,
1868
- ` try { return path.resolve(fileURLToPath(resolved)); } catch { return undefined; }`,
1869
- ` }`,
1870
- ` function recordFile(resolved) {`,
1871
- ` const file = asFile(resolved);`,
1872
- ` if (file === undefined) return;`,
1873
- ` recordInput(file);`,
1874
- ` for (let directory = path.dirname(file);;) {`,
1875
- ` const manifest = path.join(directory, "package.json");`,
1876
- ` recordInput(manifest);`,
1877
- ` if (existingFile(manifest)) break;`,
1878
- ` const parent = path.dirname(directory);`,
1879
- ` if (parent === directory) break;`,
1880
- ` directory = parent;`,
1881
- ` }`,
1882
- ` }`,
1883
- ` function recordPackageManifests(file) {`,
1884
- ` for (let directory = path.dirname(path.resolve(file));;) {`,
1885
- ` const manifest = path.join(directory, "package.json");`,
1886
- ` recordInput(manifest);`,
1887
- ` if (existingFile(manifest)) return;`,
1888
- ` const parent = path.dirname(directory);`,
1889
- ` if (parent === directory) return;`,
1890
- ` directory = parent;`,
1891
- ` }`,
1892
- ` }`,
1893
- ` recordFile(request);`,
1894
- ` const moduleProbeExtensions = typeof globalThis.Bun === "object" ? [".tsx", ".jsx", ".ts", ".mjs", ".js", ".cjs", ".json"] : [".ts", ".tsx", ".mts", ".cts", ".js", ".mjs", ".cjs", ".json", ".node"];`,
1895
- ` const jsToTsProbeExtensions = new Map([[".js", [".ts", ".tsx"]], [".jsx", [".tsx"]], [".mjs", [".mts"]], [".cjs", [".cts"]]]);`,
1896
- ` function sourceSubstitutionCandidates(base) {`,
1897
- ` const extension = path.extname(base).toLowerCase();`,
1898
- ` const substitutions = jsToTsProbeExtensions.get(extension);`,
1899
- ` if (substitutions === undefined) return [];`,
1900
- ` const stem = base.slice(0, base.length - extension.length);`,
1901
- ` return substitutions.map((candidate) => stem + candidate);`,
1902
- ` }`,
1903
- ` function moduleCandidates(base) {`,
1904
- ` return [base, ...sourceSubstitutionCandidates(base), ...moduleProbeExtensions.map((extension) => base + extension), path.join(base, "package.json"), ...moduleProbeExtensions.map((extension) => path.join(base, "index" + extension))];`,
1905
- ` }`,
1906
- ` const recordedModuleBases = new Set();`,
1907
- ` function recordManifestTargets(value, directory, allowBare = false) {`,
1908
- ` if (typeof value === "string") {`,
1909
- ` if (value !== "" && (allowBare || value.startsWith("./") || value.startsWith("../"))) recordModuleCandidates(path.resolve(directory, value));`,
1910
- ` return;`,
1911
- ` }`,
1912
- ` if (Array.isArray(value)) { for (const item of value) recordManifestTargets(item, directory, allowBare); return; }`,
1913
- ` if (value && typeof value === "object") for (const item of Object.values(value)) recordManifestTargets(item, directory, allowBare);`,
1914
- ` }`,
1915
- ` function recordModuleCandidates(base) {`,
1916
- ` const resolvedBase = path.resolve(base);`,
1917
- ` if (recordedModuleBases.has(resolvedBase)) return;`,
1918
- ` recordedModuleBases.add(resolvedBase);`,
1919
- ` for (const candidate of moduleCandidates(resolvedBase)) recordInput(candidate);`,
1920
- ` try {`,
1921
- ` const manifest = JSON.parse(fs.readFileSync(path.join(resolvedBase, "package.json"), "utf8").replace(/^\uFEFF/, ""));`,
1922
- ` recordManifestTargets(manifest.exports, resolvedBase);`,
1923
- ` recordManifestTargets(manifest.module, resolvedBase, true);`,
1924
- ` recordManifestTargets(manifest.main, resolvedBase, true);`,
1925
- ` } catch {}`,
1926
- ` }`,
1927
- ` function candidateSelected(base, selected) {`,
1928
- ` if (selected === undefined) return false;`,
1929
- ` for (const candidate of moduleCandidates(base)) {`,
1930
- ` try {`,
1931
- ` const canonical = fs.realpathSync.native(candidate);`,
1932
- ` const relative = path.relative(canonical, selected);`,
1933
- ` if (relative === "" || (fs.statSync(canonical).isDirectory() && relative !== ".." && !relative.startsWith(".." + path.sep) && !path.isAbsolute(relative))) return true;`,
1934
- ` } catch {}`,
1935
- ` }`,
1936
- ` return false;`,
1937
- ` }`,
1938
- ` function localBases(specifier, parentFile) {`,
1939
- ` if (specifier.startsWith("file:")) return [fileURLToPath(specifier)];`,
1940
- ` const directory = path.dirname(parentFile);`,
1941
- ` const raw = path.resolve(directory, specifier);`,
1942
- ` const suffixStart = specifier.search(/[?#]/);`,
1943
- ` if (suffixStart === -1) return [raw];`,
1944
- ` const pathname = specifier.slice(0, suffixStart);`,
1945
- ` return pathname === "" ? [raw] : [...new Set([raw, path.resolve(directory, pathname)])];`,
1946
- ` }`,
1947
- ` function recordResolutionCandidates(specifier, parent, resolved) {`,
1948
- ` const parentFile = asFile(parent);`,
1949
- ` if (typeof specifier !== "string" || parentFile === undefined) return;`,
1950
- ` let selected;`,
1951
- ` try { const file = asFile(resolved); selected = file === undefined ? undefined : fs.realpathSync.native(file); } catch {}`,
1952
- ` if (specifier.startsWith(".") || path.isAbsolute(specifier) || specifier.startsWith("file:")) {`,
1953
- ` try {`,
1954
- ` for (const base of localBases(specifier, parentFile)) {`,
1955
- ` recordPackageManifests(base);`,
1956
- ` let exact = false;`,
1957
- ` try { exact = selected === undefined ? fs.statSync(base).isFile() : fs.realpathSync.native(base) === selected; } catch {}`,
1958
- ` if (exact) recordInput(base);`,
1959
- ` if (!exact) recordModuleCandidates(base);`,
1960
- ` }`,
1961
- ` } catch {}`,
1962
- ` return;`,
1963
- ` }`,
1964
- ` if (Module.isBuiltin(specifier) || specifier.startsWith("#")) return;`,
1965
- ` const parts = specifier.split("/");`,
1966
- ` const packageParts = parts[0].startsWith("@") ? parts.slice(0, 2) : parts.slice(0, 1);`,
1967
- ` if (packageParts.some((part) => part === undefined || part === "")) return;`,
1968
- ` const packageName = packageParts.join("/");`,
1969
- ` const subpath = parts.slice(packageParts.length);`,
1970
- ` const searchPaths = Module.createRequire(parentFile).resolve.paths(specifier) ?? [];`,
1971
- ` for (const searchPath of searchPaths) {`,
1972
- ` const packageDirectory = path.join(searchPath, packageName);`,
1973
- ` recordModuleCandidates(packageDirectory);`,
1974
- ` if (subpath.length !== 0) recordModuleCandidates(path.join(packageDirectory, ...subpath));`,
1975
- ` if (candidateSelected(packageDirectory, selected)) break;`,
1976
- ` }`,
1977
- ` }`,
1978
- ` function scanBunModuleGraph(entry) {`,
1979
- ` if (typeof globalThis.Bun !== "object" || typeof globalThis.Bun.Transpiler !== "function") return;`,
1980
- ` const scanned = new Set();`,
1981
- ` function scan(file) {`,
1982
- ` file = asFile(file);`,
1983
- ` if (file === undefined) return;`,
1984
- ` let canonical;`,
1985
- ` try { canonical = fs.realpathSync.native(file); } catch { return; }`,
1986
- ` if (scanned.has(canonical)) return;`,
1987
- ` scanned.add(canonical);`,
1988
- ` const extension = path.extname(canonical).toLowerCase();`,
1989
- ` if (![".js", ".jsx", ".mjs", ".cjs", ".ts", ".tsx", ".mts", ".cts"].includes(extension)) return;`,
1990
- ` const loader = extension === ".tsx" ? "tsx" : extension === ".jsx" ? "jsx" : [".ts", ".mts", ".cts"].includes(extension) ? "ts" : "js";`,
1991
- ` let imports;`,
1992
- ` try {`,
1993
- ` const source = fs.readFileSync(canonical, "utf8");`,
1994
- ` imports = new globalThis.Bun.Transpiler({ loader }).scan(source).imports;`,
1995
- ` } catch { return; }`,
1996
- ` for (const imported of imports) {`,
1997
- ` const specifier = imported && imported.path;`,
1998
- ` if (typeof specifier !== "string" || specifier.startsWith("node:") || Module.isBuiltin(specifier)) continue;`,
1999
- ` recordResolutionCandidates(specifier, canonical, undefined);`,
2000
- ` try {`,
2001
- ` const resolved = globalThis.Bun.resolveSync(specifier, path.dirname(canonical));`,
2002
- ` recordResolutionCandidates(specifier, canonical, resolved);`,
2003
- ` recordFile(resolved);`,
2004
- ` scan(resolved);`,
2005
- ` } catch {`,
2006
- ` // The real descriptor load below owns user-facing resolution errors.`,
2007
- ` }`,
2008
- ` }`,
2009
- ` }`,
2010
- ` scan(entry);`,
2011
- ` }`,
2012
- ` if (typeof Module.registerHooks === "function") {`,
2013
- ` Module.registerHooks({`,
2014
- ` load(url, loadContext, nextLoad) {`,
2015
- ` try { return nextLoad(url, loadContext); }`,
2016
- ` catch (error) {`,
2017
- ` if (error && (typeof error === "object" || typeof error === "function")) moduleLoadFailures.set(error, { retryWithTtsx: error.code === "ERR_UNKNOWN_FILE_EXTENSION" });`,
2018
- ` throw error;`,
2019
- ` }`,
2020
- ` },`,
2021
- ` resolve(specifier, resolveContext, nextResolve) {`,
2022
- ` recordResolutionCandidates(specifier, resolveContext.parentURL, undefined);`,
2023
- ` let resolved;`,
2024
- ` try {`,
2025
- ` resolved = nextResolve(specifier, resolveContext);`,
2026
- ` } catch (error) {`,
2027
- ` if (error && (typeof error === "object" || typeof error === "function")) {`,
2028
- ` const parent = asFile(resolveContext.parentURL);`,
2029
- ` const anchor = typeof parent === "string" ? parent : request;`,
2030
- ` const candidate = specifier.startsWith(".") && path.extname(specifier) === "" ? path.resolve(path.dirname(anchor), specifier) : undefined;`,
2031
- ` const retryWithTtsx = candidate !== undefined && [".ts", ".cts", ".mts", ".tsx"].some((extension) => existingFile(candidate + extension) || existingFile(path.join(candidate, "index" + extension)));`,
2032
- ` moduleResolutionFailures.set(error, { retryWithTtsx });`,
2033
- ` }`,
2034
- ` throw error;`,
2035
- ` }`,
2036
- ` const url = typeof resolved === "string" ? resolved : resolved && resolved.url;`,
2037
- ` recordResolutionCandidates(specifier, resolveContext.parentURL, url);`,
2038
- ` recordFile(url);`,
2039
- ` return resolved;`,
2040
- ` },`,
2041
- ` });`,
2042
- ` }`,
2043
- ` if (typeof globalThis.Bun === "object" && typeof globalThis.Bun.plugin === "function") {`,
2044
- ` let insideBunResolve = false;`,
2045
- ` globalThis.Bun.plugin({`,
2046
- ` name: "ttsc-plugin-descriptor-inputs",`,
2047
- ` setup(build) {`,
2048
- ` build.onResolve({ filter: /.*/ }, (args) => {`,
2049
- ` if (insideBunResolve || args.path.startsWith("node:")) return;`,
2050
- ` try {`,
2051
- ` insideBunResolve = true;`,
2052
- ` const importer = args.importer && args.importer.startsWith("file:") ? fileURLToPath(args.importer) : args.importer;`,
2053
- ` const from = importer ? path.dirname(importer) : process.cwd();`,
2054
- ` recordResolutionCandidates(args.path, importer, undefined);`,
2055
- ` const resolved = globalThis.Bun.resolveSync(args.path, from);`,
2056
- ` recordResolutionCandidates(args.path, importer, resolved);`,
2057
- ` recordFile(resolved);`,
2058
- ` } catch {`,
2059
- ` // The real resolver below owns user-facing resolution errors.`,
2060
- ` } finally {`,
2061
- ` insideBunResolve = false;`,
2062
- ` }`,
2063
- ` });`,
2064
- ` },`,
2065
- ` });`,
2066
- ` }`,
2067
- ` scanBunModuleGraph(request);`,
2068
- ` let mod;`,
2069
- ` try {`,
2070
- ` mod = require(request);`,
2071
- ` } catch (error) {`,
2072
- ` retryWithTtsx = shouldRetryWithTtsx(error);`,
2073
- ` throw error;`,
2074
- ` }`,
2075
- ` const candidate = mod.createTtscPlugin ?? mod.default ?? mod.plugin ?? mod;`,
2076
- ` const descriptor = typeof candidate === "function" ? candidate(context) : candidate;`,
2077
- ` if (descriptor && typeof descriptor === "object" && ("transformSource" in descriptor || "transformOutput" in descriptor)) {`,
2078
- ` throw new Error("ttsc: plugin descriptor declares unsupported JS transform functions; declare a native backend instead");`,
2079
- ` }`,
2080
- // Serialize the descriptor while the module-resolution hooks are still
2081
- // collecting. Getters are allowed by JavaScript's object model and can
2082
- // lazily require a config; snapshotting inputs first would silently omit
2083
- // that influence.
2084
- ` const serializedDescriptor = JSON.stringify(descriptor);`,
2085
- ` for (const input of [...inputs]) recordInput(input);`,
2086
- ` const payload = { inputHashes: Object.fromEntries(inputHashes), inputRealpaths: Object.fromEntries(inputRealpaths), inputs: [...inputs].sort() };`,
2087
- ` if (serializedDescriptor !== undefined) payload.descriptor = JSON.parse(serializedDescriptor);`,
2088
- ` fs.writeFileSync(out, JSON.stringify(payload));`,
2089
- `} catch (error) {`,
2090
- ` const message = error instanceof Error ? error.message : String(error);`,
2091
- ` const stack = error instanceof Error && error.stack ? error.stack : String(error);`,
2092
- ` try {`,
2093
- ` fs.writeFileSync(out, JSON.stringify({ __ttscLoaderError: message, __ttscRetryWithTtsx: retryWithTtsx }));`,
2094
- ` } catch {}`,
2095
- ` try { process.stderr.write(stack + "\\n"); } catch {}`,
2096
- ` process.exit(1);`,
2097
- `}`,
2098
- ``,
2099
- ].join("\n");
2100
-
2101
- /** Read the isolated loader's explicit retry classification. */
2102
- function commonJsDescriptorRetryWithTtsx(file: string): boolean {
2103
- try {
2104
- const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
2105
- return isRecord(parsed) && parsed.__ttscRetryWithTtsx === true;
2106
- } catch {
2107
- return false;
2108
- }
2109
- }
2110
-
2111
- function commonJsDescriptorProcessFailure(
2112
- result: {
2113
- error?: Error;
2114
- signal: NodeJS.Signals | null;
2115
- status: number | null;
2116
- },
2117
- request: string,
2118
- ): Error | undefined {
2119
- if (result.error !== undefined) {
2120
- return new Error(
2121
- `ttsc: failed to launch an isolated process for plugin descriptor "${request}": ${result.error.message}`,
2122
- );
2123
- }
2124
- if (result.signal !== null) {
2125
- return new Error(
2126
- `ttsc: plugin descriptor "${request}" isolated evaluation was killed by signal ${result.signal}.`,
2127
- );
2128
- }
2129
- if (result.status !== 0) {
2130
- return new Error(
2131
- `ttsc: plugin descriptor "${request}" isolated evaluation failed with exit code ${String(result.status)}`,
2132
- );
2133
- }
2134
- return undefined;
2135
- }
2136
-
2137
- const TS_SOURCE_PATTERN = /\.(?:[cm]?ts|tsx)$/i;
2138
-
2139
- /**
2140
- * The descriptor shim's emitted source.
2141
- *
2142
- * Exported so a regression can inspect the same bytes ttsx executes. This
2143
- * template consumes its own escapes, so reading this file's text instead would
2144
- * check characters no consumer ever sees — and a dropped backslash turns an
2145
- * escape into the character it was escaping: a raw line terminator inside a
2146
- * string literal, which stops the shim parsing and takes every descriptor load
2147
- * with it. Its `@ttsc/lint` twin has carried that guard since the same defect
2148
- * shipped there.
2149
- */
2150
- export const PLUGIN_DESCRIPTOR_SHIM_SOURCE = [
2151
- `// @ts-nocheck`,
2152
- `import { writeFileSync } from "node:fs";`,
2153
- `import { pathToFileURL } from "node:url";`,
2154
- // The import is inside the try, not above it. A descriptor that cannot be
2155
- // found, or whose module body throws, fails exactly where a descriptor
2156
- // whose factory throws does, and a caller deserves the same reason for
2157
- // both — "Cannot find module ./missing" is as actionable as anything the
2158
- // factory could have said.
2159
- `try {`,
2160
- // Runtime hooks are installed before this shim loads. Arm their internal
2161
- // side channel only for the descriptor import itself, after this shim's own
2162
- // imports have resolved, so ttsc implementation files never become project
2163
- // cache inputs.
2164
- ` process.env.TTSC_PLUGIN_DESCRIPTOR_INPUTS_ACTIVE = "1";`,
2165
- ` const mod = await import(pathToFileURL(process.env.TTSC_PLUGIN_ENTRY).href);`,
2166
- ` const context = JSON.parse(process.env.TTSC_PLUGIN_CONTEXT);`,
2167
- ` const candidate = mod.createTtscPlugin ?? mod.default ?? mod.plugin ?? mod;`,
2168
- ` const descriptor =`,
2169
- ` typeof candidate === "function" ? candidate(context) : candidate;`,
2170
- ` writeFileSync(process.env.TTSC_PLUGIN_DESCRIPTOR_OUT, JSON.stringify(descriptor));`,
2171
- `} catch (error) {`,
2172
- // The stack streams to the user's stderr on its own. This puts the reason
2173
- // a caller can act on into the channel the parent already reads, so the
2174
- // failure is not reduced to a bare exit status.
2175
- // The escape is doubled on purpose: this template consumes one level, so
2176
- // `\\n` here is what puts the two-character escape into the emitted shim.
2177
- // A single `\n` would put a raw line terminator inside a string literal,
2178
- // and the shim would stop parsing — taking every descriptor load with it.
2179
- ` process.stderr.write((error instanceof Error && error.stack ? error.stack : String(error)) + "\\n");`,
2180
- ` try {`,
2181
- ` writeFileSync(process.env.TTSC_PLUGIN_DESCRIPTOR_OUT, JSON.stringify({ __ttscLoaderError: error instanceof Error ? error.message : String(error) }));`,
2182
- ` } catch {}`,
2183
- ` process.exit(1);`,
2184
- `}`,
2185
- ``,
2186
- ].join("\n");
2187
-
2188
- /**
2189
- * Evaluate a `.ts` plugin descriptor entry in a child `ttsx` process and return
2190
- * the descriptor it produces. A generated shim imports the entry, invokes its
2191
- * factory with `context`, and writes the descriptor as JSON; `ttsx` runs the
2192
- * shim with plugins disabled across the whole graph. Returns `undefined` when
2193
- * `ttsx` is unavailable, so the caller can rethrow the original load error.
2194
- */
2195
- function loadDescriptorViaTtsx(
2196
- request: string,
2197
- context: ITtscPluginFactoryContext,
2198
- effectiveEnv: NodeJS.ProcessEnv,
2199
- ): IsolatedPluginDescriptor | undefined {
2200
- // Binary discovery prefers the instance environment, then the ambient
2201
- // process.env (where `withPluginLoaderEnv` injects ttsc's own node/ttsx paths
2202
- // just before this runs), then the running interpreter.
2203
- const node = resolveNodeBinary(effectiveEnv, context.projectRoot);
2204
- const ttsx = effectiveEnv.TTSC_TTSX_BINARY ?? process.env.TTSC_TTSX_BINARY;
2205
- if (node === undefined || ttsx === undefined || ttsx.length === 0) {
2206
- return undefined;
2207
- }
2208
- const dir = createEvaluationTempDir();
2209
- const out = path.join(dir, "descriptor.json");
2210
- const inputsOut = path.join(dir, "descriptor-inputs.ndjson");
2211
- const shim = path.join(dir, "load-descriptor.mts");
2212
- // ttsx type-checks and builds the shim's own project, so it needs a tsconfig
2213
- // to anchor on; a minimal one is enough (the shim is `@ts-nocheck`).
2214
- try {
2215
- fs.writeFileSync(
2216
- path.join(dir, "tsconfig.json"),
2217
- JSON.stringify({
2218
- compilerOptions: {
2219
- module: "nodenext",
2220
- moduleResolution: "nodenext",
2221
- skipLibCheck: true,
2222
- target: "es2022",
2223
- },
2224
- }),
2225
- );
2226
- fs.writeFileSync(shim, PLUGIN_DESCRIPTOR_SHIM_SOURCE);
2227
- const result = childProcess.spawnSync(node, [ttsx, "--no-plugins", shim], {
2228
- cwd: context.projectRoot,
2229
- encoding: "utf8",
2230
- env: {
2231
- ...effectiveEnv,
2232
- // Carry ttsc's own node/ttsx locators explicitly so the child (which
2233
- // may recurse into further descriptor loads) finds them even when the
2234
- // instance-env snapshot predates `withPluginLoaderEnv`.
2235
- TTSC_NODE_BINARY: node,
2236
- TTSC_TTSX_BINARY: ttsx,
2237
- TTSC_PLUGIN_CONTEXT: JSON.stringify({
2238
- binary: context.binary,
2239
- cwd: context.cwd,
2240
- dirname: context.dirname,
2241
- filename: context.filename,
2242
- plugin: context.plugin,
2243
- pluginConfigDir: context.pluginConfigDir,
2244
- projectRoot: context.projectRoot,
2245
- tsconfig: context.tsconfig,
2246
- }),
2247
- TTSC_PLUGIN_DESCRIPTOR_LOAD: "1",
2248
- TTSC_PLUGIN_DESCRIPTOR_OUT: out,
2249
- TTSC_PLUGIN_DESCRIPTOR_INPUTS_OUT: inputsOut,
2250
- TTSC_PLUGIN_ENTRY: request,
2251
- },
2252
- // Both child streams are human output, and they go straight to this
2253
- // process's stderr as they are written. The descriptor itself travels
2254
- // through a file, so nothing here needs collecting — and collecting it
2255
- // only to replay it afterwards is what forced an invented output ceiling.
2256
- stdio: ["ignore", 2, 2],
2257
- windowsHide: true,
2258
- });
2259
- const processFailure = pluginDescriptorProcessFailure(result, request);
2260
- if (processFailure) {
2261
- // The descriptor's stack already reached the user's stderr as it ran.
2262
- // What it could not put there is a reason a caller can act on, so that
2263
- // arrives through the result file instead.
2264
- const reason = pluginDescriptorFailureReason(out);
2265
- throw reason === ""
2266
- ? processFailure
2267
- : new Error(`${processFailure.message}
2268
- ${reason}`);
2269
- }
2270
- if (!fs.existsSync(out)) {
2271
- throw new Error(
2272
- `ttsc: plugin descriptor "${request}" evaluation through ttsx produced no descriptor output.`,
2273
- );
2274
- }
2275
- const text = fs.readFileSync(out, "utf8");
2276
- try {
2277
- const inputSnapshot = readTtsxDescriptorInputs(inputsOut, request);
2278
- return {
2279
- descriptor: JSON.parse(text),
2280
- hostInputHashes: omitUnstableHostInputHashes(
2281
- inputSnapshot.hostInputHashes,
2282
- inputSnapshot.unstableInputs,
2283
- ),
2284
- hostInputRealpaths: inputSnapshot.hostInputRealpaths,
2285
- inputs: inputSnapshot.inputs,
2286
- };
2287
- } catch (error) {
2288
- throw new Error(
2289
- `ttsc: plugin descriptor "${request}" produced invalid JSON: ${errorMessage(error)}`,
2290
- );
2291
- }
2292
- } finally {
2293
- removeEvaluationTempDir(dir);
2294
- }
2295
- }
2296
-
2297
- interface TtsxDescriptorResolutionRecord {
2298
- hash?: string | null;
2299
- parent?: string;
2300
- realpath?: string | null;
2301
- resolved?: string;
2302
- signature?: string;
2303
- specifier?: string;
2304
- unstable?: boolean;
2305
- }
2306
-
2307
- /**
2308
- * Expand the ttsx runtime's selected module edges into the same exact and
2309
- * missing resolution inputs used by the direct isolated evaluator.
2310
- */
2311
- function readTtsxDescriptorInputs(
2312
- file: string,
2313
- request: string,
2314
- ): {
2315
- hostInputHashes: Record<string, string | null>;
2316
- hostInputRealpaths: Record<string, string | null>;
2317
- inputs: string[];
2318
- unstableInputs: string[];
2319
- } {
2320
- const inputs = new Set<string>([path.resolve(request)]);
2321
- const hashes = new Map<string, string | null>();
2322
- const realpaths = new Map<string, string | null>();
2323
- const signatures = new Map<string, string>();
2324
- const unstableInputs = new Set<string>();
2325
- let text: string;
2326
- try {
2327
- text = fs.readFileSync(file, "utf8");
2328
- } catch {
2329
- return {
2330
- hostInputHashes: {},
2331
- hostInputRealpaths: {},
2332
- inputs: [...inputs],
2333
- unstableInputs: [],
2334
- };
2335
- }
2336
- for (const line of text.split(/\r?\n/)) {
2337
- if (line.trim() === "") continue;
2338
- let record: TtsxDescriptorResolutionRecord;
2339
- try {
2340
- record = JSON.parse(line) as TtsxDescriptorResolutionRecord;
2341
- } catch {
2342
- continue;
2343
- }
2344
- if (typeof record.resolved === "string") {
2345
- const resolved = path.resolve(record.resolved);
2346
- inputs.add(resolved);
2347
- if (record.unstable === true) {
2348
- hashes.delete(resolved);
2349
- realpaths.delete(resolved);
2350
- signatures.delete(resolved);
2351
- unstableInputs.add(resolved);
2352
- continue;
2353
- }
2354
- if (
2355
- typeof record.signature !== "string" ||
2356
- (signatures.has(resolved) &&
2357
- signatures.get(resolved) !== record.signature)
2358
- ) {
2359
- hashes.delete(resolved);
2360
- realpaths.delete(resolved);
2361
- signatures.delete(resolved);
2362
- unstableInputs.add(resolved);
2363
- continue;
2364
- }
2365
- signatures.set(resolved, record.signature);
2366
- if (
2367
- (typeof record.realpath === "string" &&
2368
- path.isAbsolute(record.realpath)) ||
2369
- record.realpath === null
2370
- ) {
2371
- const observed =
2372
- record.realpath === null ? null : path.resolve(record.realpath);
2373
- if (realpaths.has(resolved) && realpaths.get(resolved) !== observed) {
2374
- hashes.delete(resolved);
2375
- realpaths.delete(resolved);
2376
- signatures.delete(resolved);
2377
- unstableInputs.add(resolved);
2378
- continue;
2379
- }
2380
- realpaths.set(resolved, observed);
2381
- }
2382
- if (typeof record.hash === "string" || record.hash === null) {
2383
- if (unstableInputs.has(resolved)) {
2384
- // Keep a previously observed contradiction unstable.
2385
- } else if (
2386
- hashes.has(resolved) &&
2387
- hashes.get(resolved) !== record.hash
2388
- ) {
2389
- hashes.delete(resolved);
2390
- realpaths.delete(resolved);
2391
- signatures.delete(resolved);
2392
- unstableInputs.add(resolved);
2393
- } else {
2394
- hashes.set(resolved, record.hash);
2395
- }
2396
- }
2397
- }
2398
- if (
2399
- typeof record.specifier === "string" &&
2400
- typeof record.parent === "string"
2401
- ) {
2402
- for (const candidate of collectModuleResolutionCandidates(
2403
- record.specifier,
2404
- record.parent,
2405
- record.resolved,
2406
- )) {
2407
- inputs.add(path.resolve(candidate));
2408
- }
2409
- }
2410
- }
2411
- for (const [resolved, observed] of realpaths) {
2412
- if (
2413
- realpathHostInput(resolved) === observed &&
2414
- signatures.get(resolved) === hostInputMetadataSignature(resolved)
2415
- ) {
2416
- continue;
2417
- }
2418
- hashes.delete(resolved);
2419
- realpaths.delete(resolved);
2420
- signatures.delete(resolved);
2421
- unstableInputs.add(resolved);
2422
- }
2423
- return {
2424
- hostInputHashes: Object.fromEntries(hashes),
2425
- hostInputRealpaths: Object.fromEntries(realpaths),
2426
- inputs: [...inputs].sort(),
2427
- unstableInputs: [...unstableInputs],
2428
- };
2429
- }
2430
-
2431
- function errorMessage(error: unknown): string {
2432
- return error instanceof Error ? error.message : String(error);
2433
- }
2434
-
2435
- function withPluginLoaderEnv<T>(run: () => T): T {
2436
- const previousNode = process.env.TTSC_NODE_BINARY;
2437
- const previousTtsx = process.env.TTSC_TTSX_BINARY;
2438
- const node = resolveNodeBinary({}, process.cwd());
2439
- if (process.env.TTSC_NODE_BINARY === undefined && node !== undefined) {
2440
- process.env.TTSC_NODE_BINARY = node;
2441
- }
2442
- process.env.TTSC_TTSX_BINARY ??= path.join(
2443
- __dirname,
2444
- "..",
2445
- "..",
2446
- "launcher",
2447
- "ttsx.js",
2448
- );
2449
- try {
2450
- return run();
2451
- } finally {
2452
- restoreEnv("TTSC_NODE_BINARY", previousNode);
2453
- restoreEnv("TTSC_TTSX_BINARY", previousTtsx);
2454
- }
2455
- }
2456
-
2457
- /**
2458
- * Select the executable for isolated descriptor evaluation.
2459
- *
2460
- * Under Bun, `process.execPath` names Bun itself. Bun implements enough of the
2461
- * Node module surface to evaluate descriptors natively, but not Node's
2462
- * synchronous `module.registerHooks` preload. The caller therefore recognizes
2463
- * this default and omits the Node-only preload while retaining the fresh
2464
- * process boundary. An explicitly configured Node executable remains
2465
- * authoritative and receives the preload as usual.
2466
- */
2467
- function pluginDescriptorRuntimeBinary(env: NodeJS.ProcessEnv): string {
2468
- if (
2469
- env.TTSC_NODE_BINARY === undefined &&
2470
- typeof (process.versions as Record<string, string | undefined>).bun ===
2471
- "string"
2472
- ) {
2473
- return process.execPath;
2474
- }
2475
- return (
2476
- env.TTSC_NODE_BINARY ?? process.env.TTSC_NODE_BINARY ?? process.execPath
2477
- );
2478
- }
2479
-
2480
- /** Replay a child's human output without imposing a fixed output ceiling. */
2481
- function replayEvaluationDiagnostics(file: string): void {
2482
- let fd: number | undefined;
2483
- try {
2484
- fd = fs.openSync(file, "r");
2485
- const buffer = Buffer.allocUnsafe(64 * 1024);
2486
- for (;;) {
2487
- const length = fs.readSync(fd, buffer, 0, buffer.length, null);
2488
- if (length === 0) break;
2489
- fs.writeSync(2, buffer, 0, length);
2490
- }
2491
- } catch {
2492
- // Diagnostic replay must never replace the descriptor result.
2493
- } finally {
2494
- if (fd !== undefined) fs.closeSync(fd);
2495
- }
2496
- }
2497
-
2498
- function restoreEnv(
2499
- key: "TTSC_NODE_BINARY" | "TTSC_TTSX_BINARY",
2500
- value: string | undefined,
2501
- ): void {
2502
- if (value === undefined) {
2503
- delete process.env[key];
2504
- } else {
2505
- process.env[key] = value;
2506
- }
2507
- }
2508
-
2509
- function isTtscPlugin(value: unknown): value is ITtscPlugin {
2510
- return typeof value === "object" && value !== null && !Array.isArray(value);
2511
- }
2512
-
2513
- function rejectJsTransformFunctions(
2514
- specifier: string,
2515
- candidate: object,
2516
- ): void {
2517
- if ("transformSource" in candidate || "transformOutput" in candidate) {
2518
- throw new Error(
2519
- `ttsc: plugin "${specifier}" declares unsupported JS transform functions; ` +
2520
- "declare a native backend instead",
2521
- );
2522
- }
2523
- }
2524
-
2525
- function resolvePluginStage(plugin: ITtscPlugin): TtscPluginStage {
2526
- if (plugin.stage === undefined) {
2527
- return "transform";
2528
- }
2529
- if (!isPluginStage(plugin.stage)) {
2530
- if (plugin.stage === "output") {
2531
- throw new Error(
2532
- `ttsc: plugin "${plugin.name}" requested removed stage "output"; ` +
2533
- "upgrade the plugin to a transform-stage descriptor compatible with this ttsc version",
2534
- );
2535
- }
2536
- throw new Error(
2537
- `ttsc: plugin "${plugin.name}" requested unsupported stage ${JSON.stringify(plugin.stage)}`,
2538
- );
2539
- }
2540
- return plugin.stage;
2541
- }
2542
-
2543
- function validatePluginSource(plugin: ITtscPlugin): void {
2544
- if (typeof plugin.source !== "string" || plugin.source.length === 0) {
2545
- throw new Error(`ttsc: plugin must declare source`);
2546
- }
2547
- }
2548
-
2549
- function pluginLabel(
2550
- plugin: ITtscPlugin,
2551
- config: ITtscProjectPluginConfig,
2552
- index: number,
2553
- ): string {
2554
- if (typeof plugin.name === "string" && plugin.name.length !== 0) {
2555
- return plugin.name;
2556
- }
2557
- if (typeof config.transform === "string" && config.transform.length !== 0) {
2558
- return config.transform;
2559
- }
2560
- return `#${index}`;
2561
- }
2562
-
2563
- function resolvePluginSource(source: string, projectRoot: string): string {
2564
- return resolveRealPath(
2565
- path.isAbsolute(source) ? source : path.resolve(projectRoot, source),
2566
- );
2567
- }
2568
-
2569
- function resolveNativeSourceKind(
2570
- source: string,
2571
- plugin: ITtscPlugin,
2572
- config: ITtscProjectPluginConfig,
2573
- index: number,
2574
- ): "executable" | "linked" {
2575
- const packageDir = resolveGoPackageDir(
2576
- source,
2577
- pluginLabel(plugin, config, index),
2578
- );
2579
- if (findNearestGoMod(packageDir, GO_MOD_SEARCH_MAX_DEPTH) === null) {
2580
- throw new Error(
2581
- `ttsc: plugin "${pluginLabel(plugin, config, index)}" source must be inside a Go module with go.mod within ${GO_MOD_SEARCH_MAX_DEPTH} parent directories: ${source}`,
2582
- );
2583
- }
2584
- const packageName = readGoPackageName(packageDir);
2585
- if (packageName === null) {
2586
- throw new Error(
2587
- `ttsc: plugin "${pluginLabel(plugin, config, index)}" source must contain at least one non-test ".go" file with a package declaration: ${packageDir}`,
2588
- );
2589
- }
2590
- return packageName === "main" ? "executable" : "linked";
2591
- }
2592
-
2593
- function resolveGoPackageDir(source: string, label: string): string {
2594
- if (!fs.existsSync(source)) {
2595
- // A descriptor factory runs without CommonJS globals when ttsc loads it
2596
- // through ttsx or as ESM — `__dirname`/`__filename`/`require` are undefined,
2597
- // so a `source` derived from them mis-resolves (often against cwd) and lands
2598
- // here. Name that failure mode explicitly instead of leaving a bare
2599
- // not-found path: the breakage is otherwise silent. (See #248.)
2600
- throw new Error(
2601
- `ttsc: plugin "${label}" source does not exist: ${source}\n` +
2602
- ` Plugin descriptors run without CommonJS globals: __dirname, __filename, ` +
2603
- `and require are undefined when ttsc loads a descriptor through ttsx or as ESM. ` +
2604
- `If this path was derived from one of them, use context.dirname / ` +
2605
- `context.filename (the descriptor's own directory and file, populated in ` +
2606
- `every load mode), or resolve it from context.projectRoot, e.g. ` +
2607
- `createRequire(path.join(context.projectRoot, "package.json"))` +
2608
- `.resolve("<your-package>/package.json").`,
2609
- );
2610
- }
2611
- const stat = fs.statSync(source);
2612
- if (stat.isFile() && path.basename(source) === "go.mod") {
2613
- return path.dirname(source);
2614
- }
2615
- if (stat.isDirectory()) {
2616
- return source;
2617
- }
2618
- throw new Error(
2619
- `ttsc: plugin "${label}" source must be a Go package directory or go.mod file: ${source}`,
2620
- );
2621
- }
2622
-
2623
- function readGoPackageName(dir: string): string | null {
2624
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
2625
- if (
2626
- !entry.isFile() ||
2627
- !entry.name.endsWith(".go") ||
2628
- entry.name.endsWith("_test.go")
2629
- ) {
2630
- continue;
2631
- }
2632
- const file = path.join(dir, entry.name);
2633
- for (const line of fs.readFileSync(file, "utf8").split(/\r?\n/)) {
2634
- const match = /^\s*package\s+([A-Za-z_][A-Za-z0-9_]*)\b/.exec(line);
2635
- if (match) {
2636
- return match[1]!;
2637
- }
2638
- }
2639
- }
2640
- return null;
2641
- }
2642
-
2643
- const CONTRIBUTOR_NAME_PATTERN = /^[a-z][a-z0-9_]*$/;
2644
-
2645
- function validatePluginContributors(
2646
- plugin: ITtscPlugin,
2647
- ): readonly { name: string; source: string }[] | undefined {
2648
- const contributors = plugin.contributors;
2649
- if (contributors === undefined) return undefined;
2650
- if (!Array.isArray(contributors)) {
2651
- throw new Error(
2652
- `ttsc: plugin "${plugin.name}" "contributors" must be an array of { name, source } entries`,
2653
- );
2654
- }
2655
- if (contributors.length === 0) return undefined;
2656
- const seen = new Set<string>();
2657
- const out: { name: string; source: string }[] = [];
2658
- for (const [index, entry] of contributors.entries()) {
2659
- if (typeof entry !== "object" || entry === null) {
2660
- throw new Error(
2661
- `ttsc: plugin "${plugin.name}" contributors[${index}] must be an object`,
2662
- );
2663
- }
2664
- const { name, source } = entry as { name?: unknown; source?: unknown };
2665
- if (typeof name !== "string" || !CONTRIBUTOR_NAME_PATTERN.test(name)) {
2666
- throw new Error(
2667
- `ttsc: plugin "${plugin.name}" contributors[${index}].name must match /^[a-z][a-z0-9_]*$/; ` +
2668
- `got ${JSON.stringify(name)}`,
2669
- );
2670
- }
2671
- if (seen.has(name)) {
2672
- throw new Error(
2673
- `ttsc: plugin "${plugin.name}" contributors[${index}] duplicate name ${JSON.stringify(name)}`,
2674
- );
2675
- }
2676
- seen.add(name);
2677
- if (typeof source !== "string" || source.length === 0) {
2678
- throw new Error(
2679
- `ttsc: plugin "${plugin.name}" contributors[${index}].source must be a non-empty string`,
2680
- );
2681
- }
2682
- if (!path.isAbsolute(source)) {
2683
- throw new Error(
2684
- `ttsc: plugin "${plugin.name}" contributors[${index}].source must be an absolute path; ` +
2685
- `got ${JSON.stringify(source)}`,
2686
- );
2687
- }
2688
- if (!fs.existsSync(source) || !fs.statSync(source).isDirectory()) {
2689
- throw new Error(
2690
- `ttsc: plugin "${plugin.name}" contributors[${index}].source must be an existing directory: ${source}`,
2691
- );
2692
- }
2693
- // Pre-flight check that the directory actually carries a buildable
2694
- // contributor package. Without this, an accidentally-empty directory
2695
- // (or a directory containing only `_test.go` files, which `go build`
2696
- // silently skips) reaches the synthesized blank-import step and Go's
2697
- // compile error surfaces with a scratch-tempdir path that doesn't
2698
- // name the contributor entry. Catching it here lets us name the
2699
- // entry the user actually authored.
2700
- if (!hasBuildableGoSource(source)) {
2701
- throw new Error(
2702
- `ttsc: plugin "${plugin.name}" contributors[${index}].source must contain at least one non-test ".go" file: ${source}`,
2703
- );
2704
- }
2705
- out.push({ name, source: resolveRealPath(source) });
2706
- }
2707
- return out;
2708
- }
2709
-
2710
- function mergeContributors(
2711
- first: readonly ITtscPluginContributor[] | undefined,
2712
- second: readonly ITtscPluginContributor[] | undefined,
2713
- ): readonly ITtscPluginContributor[] | undefined {
2714
- const out = [...(first ?? []), ...(second ?? [])];
2715
- return out.length === 0 ? undefined : out;
2716
- }
2717
-
2718
- function isPluginStage(value: string): value is TtscPluginStage {
2719
- return value === "transform" || value === "check";
2720
- }
2721
-
2722
- function hasBuildableGoSource(dir: string): boolean {
2723
- // `go build` consumes `.go` files but silently ignores `_test.go`. A
2724
- // contributor whose source dir holds only test files would compile to
2725
- // an empty package and surface as an opaque scratch-tempdir error;
2726
- // require at least one production `.go` file so the validator can
2727
- // name the contributor entry instead.
2728
- let entries: string[];
2729
- try {
2730
- entries = fs.readdirSync(dir);
2731
- } catch {
2732
- return false;
2733
- }
2734
- return entries.some(
2735
- (name) => name.endsWith(".go") && !name.endsWith("_test.go"),
2736
- );
2737
- }
2738
-
2739
- function resolvePluginRequest(specifier: string, projectRoot: string): string {
2740
- if (path.isAbsolute(specifier)) {
2741
- return resolveRealPath(specifier);
2742
- }
2743
- if (isRelativePluginSpecifier(specifier)) {
2744
- return resolveRealPath(path.resolve(projectRoot, specifier));
2745
- }
2746
- // A package whose main `.` entry is a runtime barrel cannot double as a
2747
- // plugin descriptor entry: loading it during plugin bootstrap drags the
2748
- // runtime in (and, for a self-hosting transform like typia, deadlocks —
2749
- // loading the transform would have to build the runtime the transform
2750
- // emits). Such a package opts in with a `ttsc` export condition that points
2751
- // at a runtime-free descriptor; honour it here, scoped to plugin resolution.
2752
- const conditioned = resolvePluginExportCondition(specifier, projectRoot);
2753
- if (conditioned !== null) {
2754
- return conditioned;
2755
- }
2756
- return resolveRealPath(require.resolve(specifier, { paths: [projectRoot] }));
2757
- }
2758
-
2759
- /**
2760
- * Condition names ttsc activates when resolving a plugin entry's package
2761
- * `exports`.
2762
- */
2763
- const PLUGIN_EXPORT_CONDITIONS: readonly string[] = [
2764
- "ttsc",
2765
- "node",
2766
- "require",
2767
- "default",
2768
- ];
2769
-
2770
- /**
2771
- * Resolve a bare plugin specifier under the dedicated `ttsc` export condition.
2772
- *
2773
- * A package whose `.` entry is a runtime barrel (e.g. `typia`, whose index
2774
- * re-exports the whole validator runtime) cannot serve as the plugin descriptor
2775
- * entry: loading it during plugin bootstrap pulls the runtime in and, for a
2776
- * self-hosting transform, forms a cycle. Such a package opts in by adding a
2777
- * `ttsc` condition to its `exports` that points at a runtime-free descriptor:
2778
- *
2779
- * "exports": { ".": { "ttsc": "./lib/transform.js", "default": "./lib/index.js"
2780
- * } }
2781
- *
2782
- * The condition is honoured ONLY here, scoped to plugin-entry resolution. A
2783
- * process-wide `--conditions=ttsc` would also redirect the package's normal
2784
- * `import`s to the descriptor and break its runtime, so it must not be used.
2785
- *
2786
- * Returns an absolute path when the package opts in, or `null` to fall back to
2787
- * the normal `require.resolve` — no `exports`, no `ttsc` branch for the
2788
- * requested subpath, or an unresolved/missing target — so a package that does
2789
- * not opt in resolves exactly as it did before.
2790
- */
2791
- function resolvePluginExportCondition(
2792
- specifier: string,
2793
- baseDir: string,
2794
- ): string | null {
2795
- const split = splitPackageSpecifier(specifier);
2796
- if (split === null) {
2797
- return null;
2798
- }
2799
- const packageJson = resolveDependencyPackageJson(split.packageName, baseDir);
2800
- if (packageJson === undefined) {
2801
- return null;
2802
- }
2803
- const exportsField = readPackageManifest(packageJson)?.exports;
2804
- if (exportsField === undefined) {
2805
- return null;
2806
- }
2807
- const target = selectExportTarget(exportsField, split.subpath);
2808
- // Only take over when the package actually opts in with a `ttsc` condition
2809
- // for this subpath; otherwise defer so behaviour is unchanged for every
2810
- // package that does not.
2811
- if (target === undefined || !containsCondition(target, "ttsc")) {
2812
- return null;
2813
- }
2814
- const resolved = resolveConditionalTarget(target, PLUGIN_EXPORT_CONDITIONS);
2815
- if (resolved === null || !resolved.startsWith("./")) {
2816
- return null;
2817
- }
2818
- const file = path.resolve(path.dirname(packageJson), resolved);
2819
- return existingFile(file) ? resolveRealPath(file) : null;
2820
- }
2821
-
2822
- /**
2823
- * Split a bare specifier into its package name and the `.`-prefixed subpath it
2824
- * addresses (`"typia"` → `.`, `"typia/lib/transform"` → `./lib/transform`,
2825
- * `"@scope/pkg/sub"` → `./sub`). Returns `null` for a relative/empty specifier
2826
- * or a malformed scoped name.
2827
- */
2828
- function splitPackageSpecifier(
2829
- specifier: string,
2830
- ): { packageName: string; subpath: string } | null {
2831
- if (specifier.length === 0 || specifier.startsWith(".")) {
2832
- return null;
2833
- }
2834
- const segments = specifier.split("/");
2835
- const nameSegments = specifier.startsWith("@") ? 2 : 1;
2836
- if (segments.length < nameSegments) {
2837
- return null;
2838
- }
2839
- const rest = segments.slice(nameSegments).join("/");
2840
- return {
2841
- packageName: segments.slice(0, nameSegments).join("/"),
2842
- subpath: rest.length === 0 ? "." : `./${rest}`,
2843
- };
2844
- }
2845
-
2846
- /**
2847
- * The `exports` entry addressing `subpath`, applying Node's rule that an
2848
- * `exports` value with no `.`-prefixed keys is sugar for the `.` target.
2849
- * Returns `undefined` when no entry addresses the subpath.
2850
- */
2851
- function selectExportTarget(exportsField: unknown, subpath: string): unknown {
2852
- if (typeof exportsField === "string" || Array.isArray(exportsField)) {
2853
- return subpath === "." ? exportsField : undefined;
2854
- }
2855
- if (typeof exportsField !== "object" || exportsField === null) {
2856
- return undefined;
2857
- }
2858
- const record = exportsField as Record<string, unknown>;
2859
- const isSubpathMap = Object.keys(record).some(
2860
- (key) => key === "." || key.startsWith("./"),
2861
- );
2862
- if (!isSubpathMap) {
2863
- // Conditions object: the whole value is the `.` target.
2864
- return subpath === "." ? exportsField : undefined;
2865
- }
2866
- if (
2867
- Object.prototype.hasOwnProperty.call(record, subpath) &&
2868
- !subpath.includes("*") &&
2869
- !subpath.endsWith("/")
2870
- ) {
2871
- return record[subpath];
2872
- }
2873
- const patterns = Object.keys(record)
2874
- .filter((key) => exportPatternReplacement(key, subpath) !== undefined)
2875
- .sort(compareExportPatternKeys);
2876
- if (patterns.length === 0) {
2877
- return undefined;
2878
- }
2879
- const pattern = patterns[0]!;
2880
- return substituteExportTarget(
2881
- record[pattern],
2882
- exportPatternReplacement(pattern, subpath)!,
2883
- );
2884
- }
2885
-
2886
- /** Capture the middle of one valid single-star exports key. */
2887
- function exportPatternReplacement(
2888
- pattern: string,
2889
- subpath: string,
2890
- ): string | undefined {
2891
- const star = pattern.indexOf("*");
2892
- if (
2893
- !pattern.startsWith("./") ||
2894
- star === -1 ||
2895
- pattern.indexOf("*", star + 1) !== -1
2896
- ) {
2897
- return undefined;
2898
- }
2899
- const prefix = pattern.slice(0, star);
2900
- const suffix = pattern.slice(star + 1);
2901
- if (
2902
- subpath.length < pattern.length ||
2903
- !subpath.startsWith(prefix) ||
2904
- !subpath.endsWith(suffix)
2905
- ) {
2906
- return undefined;
2907
- }
2908
- return subpath.slice(prefix.length, subpath.length - suffix.length);
2909
- }
2910
-
2911
- /** Node exports patterns rank longer prefixes, then longer full keys, first. */
2912
- function compareExportPatternKeys(left: string, right: string): number {
2913
- const leftPrefix = left.indexOf("*");
2914
- const rightPrefix = right.indexOf("*");
2915
- if (leftPrefix !== rightPrefix) {
2916
- return rightPrefix - leftPrefix;
2917
- }
2918
- return right.length - left.length;
2919
- }
2920
-
2921
- /** Substitute the selected pattern capture into every string target branch. */
2922
- function substituteExportTarget(target: unknown, replacement: string): unknown {
2923
- if (typeof target === "string") {
2924
- return target.split("*").join(replacement);
2925
- }
2926
- if (Array.isArray(target)) {
2927
- return target.map((entry) => substituteExportTarget(entry, replacement));
2928
- }
2929
- if (typeof target !== "object" || target === null) {
2930
- return target;
2931
- }
2932
- return Object.fromEntries(
2933
- Object.entries(target).map(([condition, value]) => [
2934
- condition,
2935
- substituteExportTarget(value, replacement),
2936
- ]),
2937
- );
2938
- }
2939
-
2940
- /** True when condition key `condition` appears anywhere in a (nested) target. */
2941
- function containsCondition(target: unknown, condition: string): boolean {
2942
- if (Array.isArray(target)) {
2943
- return target.some((entry) => containsCondition(entry, condition));
2944
- }
2945
- if (typeof target !== "object" || target === null) {
2946
- return false;
2947
- }
2948
- return Object.entries(target).some(
2949
- ([key, value]) => key === condition || containsCondition(value, condition),
2950
- );
2951
- }
2952
-
2953
- /**
2954
- * Resolve a (possibly conditional) export target to a relative file string,
2955
- * honouring `conditions` — a string is the target, an array is a fallback list,
2956
- * an object picks the first key in the active condition set (package key order
2957
- * wins, as Node does), and an explicit `null` blocks the target.
2958
- */
2959
- function resolveConditionalTarget(
2960
- target: unknown,
2961
- conditions: readonly string[],
2962
- ): string | null {
2963
- if (typeof target === "string") {
2964
- return target;
2965
- }
2966
- if (target === null || target === undefined) {
2967
- return null;
2968
- }
2969
- if (Array.isArray(target)) {
2970
- for (const entry of target) {
2971
- const resolved = resolveConditionalTarget(entry, conditions);
2972
- if (resolved !== null) {
2973
- return resolved;
2974
- }
2975
- }
2976
- return null;
2977
- }
2978
- if (typeof target !== "object") {
2979
- return null;
2980
- }
2981
- const active = new Set(conditions);
2982
- for (const [key, value] of Object.entries(
2983
- target as Record<string, unknown>,
2984
- )) {
2985
- if (active.has(key)) {
2986
- const resolved = resolveConditionalTarget(value, conditions);
2987
- if (resolved !== null) {
2988
- return resolved;
2989
- }
2990
- }
2991
- }
2992
- return null;
2993
- }
2994
-
2995
- function resolveRealPath(location: string): string {
2996
- try {
2997
- return fs.realpathSync(location);
2998
- } catch {
2999
- return location;
3000
- }
3001
- }
3002
-
3003
- function isRelativePluginSpecifier(specifier: string): boolean {
3004
- return (
3005
- specifier === "." ||
3006
- specifier === ".." ||
3007
- specifier.startsWith("./") ||
3008
- specifier.startsWith("../") ||
3009
- specifier.startsWith(".\\") ||
3010
- specifier.startsWith("..\\")
3011
- );
3012
- }
3013
-
3014
- let cachedTtscVersion: string | null = null;
3015
-
3016
- function readTtscVersion(): string {
3017
- if (cachedTtscVersion !== null) {
3018
- return cachedTtscVersion;
3019
- }
3020
- try {
3021
- const file = path.join(ttscPackageRoot(), "package.json");
3022
- const pkg = JSON.parse(fs.readFileSync(file, "utf8")) as {
3023
- version?: string;
3024
- };
3025
- cachedTtscVersion = pkg.version ?? "0.0.0";
3026
- } catch {
3027
- cachedTtscVersion = "0.0.0";
3028
- }
3029
- return cachedTtscVersion;
3030
- }
3031
-
3032
- function ttscPackageRoot(): string {
3033
- return path.resolve(__dirname, "..", "..", "..");
3034
- }
3035
-
3036
- function readTsgoVersion(projectRoot: string): string {
3037
- try {
3038
- const projectRequire = createRequire(
3039
- path.join(projectRoot, "package.json"),
3040
- );
3041
- const pkgPath = projectRequire.resolve("typescript/package.json");
3042
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")) as {
3043
- version?: string;
3044
- };
3045
- return pkg.version ?? "unknown";
3046
- } catch {
3047
- return "unknown";
3048
- }
3049
- }
3050
-
3051
- /**
3052
- * Create an evaluator directory whose cleanup path cannot follow a retargeted
3053
- * parent alias.
3054
- */
3055
- function createEvaluationTempDir(): string {
3056
- return createCanonicalTempDirectory("ttsc-plugin-descriptor-");
3057
- }
3058
-
3059
- /**
3060
- * Remove an evaluation temp directory without letting cleanup replace a result.
3061
- *
3062
- * This runs from a `finally`, so a throw here would surface instead of the
3063
- * evaluation's own outcome — and on Windows a grandchild that inherited a
3064
- * handle, or a scanner holding the file, can make removal fail. Leaving bytes
3065
- * in the system temp directory is by far the lesser outcome.
3066
- */
3067
- function removeEvaluationTempDir(directory: string): void {
3068
- try {
3069
- fs.rmSync(directory, { force: true, recursive: true });
3070
- } catch {
3071
- // Best effort.
3072
- }
3073
- }