ttsc 0.30.4 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cmd/graphbench/main.go +2 -3
- package/cmd/graphdump/main.go +42 -16
- package/cmd/graphdump/run_declares_the_capability_its_output_carries_test.go +32 -18
- package/cmd/graphdump/run_reports_an_unknown_flag_without_exiting_the_process_test.go +10 -9
- package/cmd/graphdump/run_reports_an_unloadable_project_without_printing_a_dump_test.go +8 -7
- package/cmd/platform/command_operation_families_test.go +192 -0
- package/cmd/platform/main.go +11 -1
- package/cmd/ttsc/api_compile.go +166 -46
- package/cmd/ttsc/api_compile_branches_test.go +97 -10
- package/cmd/ttsc/api_transform.go +134 -46
- package/cmd/ttsc/api_transform_branches_test.go +10 -7
- package/cmd/ttsc/build.go +177 -68
- package/cmd/ttsc/build_branches_test.go +35 -7
- package/cmd/ttsc/cli_command_operation_families_test.go +1287 -0
- package/cmd/ttsc/cli_contract_helpers_test.go +82 -0
- package/cmd/ttsc/compiler_argument_cwd_test.go +57 -0
- package/cmd/ttsc/filter.go +31 -14
- package/cmd/ttsc/filter_resolves_flag_names_case_insensitively_test.go +10 -13
- package/cmd/ttsc/filter_strips_unknown_forwarded_flag_test.go +10 -16
- package/cmd/ttsc/flags_gen.go +2 -2
- package/cmd/ttsc/helpers_test.go +67 -10
- package/cmd/ttsc/main.go +122 -21
- package/cmd/ttsc/main_alias_branches_test.go +35 -9
- package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/ambient.d.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/main.ts +2 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/mytype.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/tsconfig.base.json +3 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestAPITransformEnvelopeCarriesReferenceGraph/tsconfig.json +5 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/index.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/decorated/main.ts +10 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/decorated/types.ts +3 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/helpers.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/isolated.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/main.ts +7 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/src/nested/model.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPICompileAndTransform/tsconfig.json +14 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPITransformUsesCurrentDirectory/index.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIAPITransformUsesCurrentDirectory/tsconfig.json +7 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildAllowsUnusedTypeParametersOnOverloadSignatures/index.ts +4 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildAllowsUnusedTypeParametersOnOverloadSignatures/tsconfig.json +11 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSemanticDiagnostics/index.ts +2 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSemanticDiagnostics/tsconfig.json +9 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSyntacticDiagnostics/index.ts +2 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksSyntacticDiagnostics/tsconfig.json +8 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksUnusedParameters/index.ts +3 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildBlocksUnusedParameters/tsconfig.json +10 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildEmitErrorRejectsManifest/index.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIProjectBuildEmitErrorRejectsManifest/tsconfig.json +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIReportsDiagnosticsWithoutEmit/index.ts +1 -0
- package/cmd/ttsc/testdata/cli_operation_families/TestCLIReportsDiagnosticsWithoutEmit/tsconfig.json +8 -0
- package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/emit.json +8 -0
- package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/flag-shaped.json +7 -0
- package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/index.ts +2 -0
- package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/nested/tsconfig.app.json +11 -0
- package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/outside.json +8 -0
- package/cmd/ttsc/testdata/cli_operation_families/shared-value-one/project/tsconfig.json +8 -0
- package/cmd/ttscgraph/auxiliary_identity_state_tracks_retargets_not_source_contents_test.go +26 -15
- package/cmd/ttscgraph/disk_realpath_other.go +2 -0
- package/cmd/ttscgraph/dump.go +46 -29
- package/cmd/ttscgraph/prepared_projection.go +61 -0
- package/cmd/ttscgraph/projection_fixture_test.go +96 -0
- package/cmd/ttscgraph/run_dump_claims_artifacts_only_when_it_asked_test.go +30 -5
- package/cmd/ttscgraph/run_dump_declares_the_capability_its_output_carries_test.go +6 -1
- package/cmd/ttscgraph/run_dump_emits_only_checker_verified_member_relations_test.go +12 -5
- package/cmd/ttscgraph/run_dump_prints_the_graph_as_json_test.go +17 -12
- package/cmd/ttscgraph/run_help_version_and_bad_flags_exit_codes_test.go +8 -3
- package/cmd/ttscgraph/serve.go +116 -79
- package/cmd/ttscgraph/serve_adopts_a_republished_artifact_set_test.go +16 -167
- package/cmd/ttscgraph/serve_adopts_a_republished_set_over_the_shard_protocol_test.go +122 -0
- package/cmd/ttscgraph/serve_answers_a_project_that_implements_its_own_ambient_declaration_test.go +35 -7
- package/cmd/ttscgraph/serve_early_error_encode_failure_is_observable_test.go +5 -0
- package/cmd/ttscgraph/serve_error_response_still_names_its_mode_test.go +10 -5
- package/cmd/ttscgraph/serve_git_ignore_projection_test.go +150 -0
- package/cmd/ttscgraph/serve_keeps_a_startup_set_a_client_never_mentions_test.go +69 -0
- package/cmd/ttscgraph/serve_object_members_refresh_without_identity_collisions_test.go +82 -0
- package/cmd/ttscgraph/serve_phase_trace_accounts_for_load_failure_test.go +9 -3
- package/cmd/ttscgraph/serve_phase_trace_is_opt_in_and_payload_free_test.go +12 -6
- package/cmd/ttscgraph/serve_projects_an_artifact_no_source_owns_test.go +13 -16
- package/cmd/ttscgraph/serve_protocol_fails_the_stream_on_an_unaddressable_request_line_test.go +10 -9
- package/cmd/ttscgraph/serve_protocol_negotiates_incremental_shards_test.go +37 -2
- package/cmd/ttscgraph/serve_protocol_retries_session_creation_test.go +7 -2
- package/cmd/ttscgraph/serve_protocol_reuses_session_test.go +13 -3
- package/cmd/ttscgraph/serve_session_applies_source_edit_incrementally_test.go +12 -7
- package/cmd/ttscgraph/serve_session_fails_closed_on_deleted_config_test.go +12 -7
- package/cmd/ttscgraph/serve_session_fails_closed_on_invalid_config_test.go +8 -3
- package/cmd/ttscgraph/serve_session_keeps_base_url_fallback_unchanged_test.go +7 -2
- package/cmd/ttscgraph/serve_session_keeps_change_detection_live_after_initial_dump_error_test.go +66 -0
- package/cmd/ttscgraph/serve_session_keeps_esm_directory_candidate_unchanged_test.go +12 -3
- package/cmd/ttscgraph/serve_session_keeps_exports_blocked_file_candidates_unchanged_test.go +8 -3
- package/cmd/ttscgraph/serve_session_keeps_inactive_conditional_export_unchanged_test.go +12 -3
- package/cmd/ttscgraph/serve_session_keeps_lower_priority_module_candidate_unchanged_test.go +14 -8
- package/cmd/ttscgraph/serve_session_keeps_lower_priority_paths_pattern_unchanged_test.go +12 -3
- package/cmd/ttscgraph/serve_session_keeps_missing_literal_root_unchanged_test.go +7 -2
- package/cmd/ttscgraph/serve_session_keeps_nonlongest_root_dirs_candidate_unchanged_test.go +12 -3
- package/cmd/ttscgraph/serve_session_rebuilds_import_graph_change_test.go +17 -8
- package/cmd/ttscgraph/serve_session_reloads_commonjs_package_entry_for_esm_test.go +11 -2
- package/cmd/ttscgraph/serve_session_reloads_created_literal_root_test.go +7 -2
- package/cmd/ttscgraph/serve_session_reloads_extended_config_change_test.go +9 -4
- package/cmd/ttscgraph/serve_session_reloads_module_suffix_candidate_test.go +13 -4
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_conditional_export_test.go +13 -8
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_config_types_test.go +7 -2
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_excluded_import_test.go +11 -3
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_package_export_test.go +11 -2
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_package_import_test.go +11 -2
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_path_alias_test.go +11 -2
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_reference_path_test.go +11 -2
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_root_dirs_target_test.go +11 -2
- package/cmd/ttscgraph/serve_session_reloads_newly_resolved_type_reference_test.go +11 -2
- package/cmd/ttscgraph/serve_session_reloads_root_file_set_test.go +11 -5
- package/cmd/ttscgraph/serve_session_reloads_source_deleted_during_load_test.go +16 -9
- package/cmd/ttscgraph/serve_session_reloads_superseding_module_candidates_test.go +18 -13
- package/cmd/ttscgraph/serve_session_reloads_transitive_project_reference_test.go +14 -5
- package/cmd/ttscgraph/serve_session_reloads_when_program_plugin_linked_test.go +13 -8
- package/cmd/ttscgraph/serve_session_retries_a_pending_dump_before_unchanged_test.go +62 -0
- package/cmd/ttscgraph/serve_session_reuses_unchanged_preamble_source_test.go +21 -0
- package/cmd/ttscgraph/serve_session_reuses_unchanged_snapshot_test.go +12 -7
- package/cmd/ttscgraph/serve_session_revisits_source_edited_during_load_test.go +18 -8
- package/cmd/ttscgraph/serve_session_tolerates_os_invalid_resolution_candidate_test.go +13 -9
- package/cmd/ttscgraph/serve_session_tracks_all_module_specifier_forms_test.go +12 -3
- package/cmd/ttscgraph/serve_session_tracks_diamond_project_references_once_test.go +12 -8
- package/cmd/ttscgraph/serve_shards.go +356 -279
- package/cmd/ttscgraph/serve_shards_abandoned_generation_converges_on_retry_test.go +41 -16
- package/cmd/ttscgraph/serve_shards_delete_removed_source_test.go +14 -4
- package/cmd/ttscgraph/serve_shards_external_endpoints_test.go +18 -2
- package/cmd/ttscgraph/serve_shards_keep_source_distributed_dependencies_at_the_boundary_test.go +36 -5
- package/cmd/ttscgraph/serve_shards_match_full_dump_oracle_test.go +12 -3
- package/cmd/ttscgraph/serve_shards_merge_pending_and_new_edits_test.go +36 -3
- package/cmd/ttscgraph/serve_shards_prune_unreferenced_external_endpoints_test.go +18 -2
- package/cmd/ttscgraph/serve_shards_publish_created_source_test.go +16 -13
- package/cmd/ttscgraph/serve_shards_rebuild_declaration_edit_test.go +14 -4
- package/cmd/ttscgraph/serve_shards_refresh_cross_file_implementation_test.go +24 -5
- package/cmd/ttscgraph/serve_shards_refresh_dependent_diagnostics_test.go +30 -7
- package/cmd/ttscgraph/serve_shards_rename_moves_source_identity_test.go +14 -11
- package/cmd/ttscgraph/serve_shards_retry_preserves_committed_generation_test.go +17 -7
- package/cmd/ttscgraph/serve_shards_reuse_unaffected_sources_test.go +21 -7
- package/cmd/ttscgraph/serve_snapshot_proves_its_program_without_a_second_read_test.go +57 -16
- package/cmd/ttscgraph/serve_source_encoding_test.go +133 -0
- package/cmd/ttscserver/command_operation_families_test.go +207 -0
- package/cmd/ttscserver/main.go +121 -39
- package/cmd/ttscserver/resolve_launch_uses_native_flag_authority_test.go +147 -0
- package/cmd/ttscserver/run_lsp_forwards_execute_command_advertisement_flags_test.go +7 -0
- package/cmd/ttscserver/run_lsp_prefers_tsgo_flag_test.go +13 -1
- package/cmd/ttscserver/run_lsp_reports_getwd_error_test.go +5 -0
- package/cmd/ttscserver/run_lsp_reports_server_error_test.go +10 -3
- package/cmd/ttscserver/run_lsp_uses_native_plugin_manifest_source_test.go +13 -10
- package/cmd/ttscserver/run_lsp_uses_tsgo_environment_test.go +10 -3
- package/driver/authored_region_maps_positions_around_the_preamble_test.go +95 -0
- package/driver/build_information_uses_selected_output_identity_test.go +148 -0
- package/driver/check_observations.go +67 -0
- package/driver/config_discovery.go +93 -24
- package/driver/declaration_shape.go +9 -0
- package/driver/diagnostics_preamble.go +8 -7
- package/driver/emit_containment.go +29 -8
- package/driver/emit_plugin.go +106 -36
- package/driver/emit_plugin_output.go +26 -2
- package/driver/emit_provenance.go +155 -0
- package/driver/graph.go +54 -20
- package/driver/host.go +26 -3
- package/driver/input_observation.go +78 -16
- package/driver/input_observation_test.go +34 -11
- package/driver/lsp.go +401 -30
- package/driver/overlay.go +69 -2
- package/driver/plugins.go +256 -24
- package/driver/private_result.go +43 -0
- package/driver/program.go +439 -95
- package/driver/resolution_candidates.go +63 -14
- package/driver/resolution_candidates_test.go +28 -0
- package/driver/resolutioninputs/recorder.cjs +1149 -0
- package/driver/resolutioninputs/resolutioninputs.go +37 -0
- package/driver/rewrite.go +373 -420
- package/driver/session.go +80 -12
- package/driver/sourcemap_preamble.go +38 -16
- package/driver/transform_dependencies.go +38 -10
- package/driver/transform_dependencies_declares_every_file_without_a_contributor_test.go +9 -8
- package/driver/transform_dependencies_drops_a_self_reported_dependency_test.go +7 -6
- package/driver/transform_dependencies_keys_a_reported_path_like_the_envelope_test.go +9 -9
- package/driver/transform_dependencies_requires_every_contributor_to_declare_test.go +10 -5
- package/driver/transform_dependencies_stays_silent_for_an_undeclared_contributor_test.go +8 -6
- package/driver/transform_dependencies_withdraws_completeness_after_an_unusable_dependency_test.go +9 -5
- package/driver/transform_source_map.go +388 -0
- package/driver/windowsjunction/create_preserves_existing_directory_windows_test.go +48 -0
- package/driver/windowsjunction/create_treats_paths_as_data_windows_test.go +55 -0
- package/driver/windowsjunction/windowsjunction.go +17 -1
- package/go.mod +10 -10
- package/go.sum +10 -10
- package/internal/cwd/cwd.go +13 -0
- package/internal/e2etrace/artifact.go +147 -0
- package/internal/e2etrace/completion_hints.go +35 -0
- package/internal/e2etrace/completion_hints_test.go +76 -0
- package/internal/e2etrace/e2etrace.go +303 -0
- package/internal/e2etrace/output.go +50 -0
- package/internal/graph/artifacts.go +69 -12
- package/internal/graph/artifacts_index_what_a_plugin_published_test.go +19 -8
- package/internal/graph/artifacts_survive_a_partial_rebuild_test.go +11 -12
- package/internal/graph/assigned_implementations_of_declaration_file_symbols_leave_no_edge_source_test.go +10 -12
- package/internal/graph/assigned_implementations_of_node_modules_symbols_leave_no_edge_source_test.go +7 -1
- package/internal/graph/build.go +122 -38
- package/internal/graph/build_files_reuses_committed_cross_file_endpoints_test.go +9 -3
- package/internal/graph/build_keeps_source_distributed_dependencies_at_the_external_boundary_test.go +10 -1
- package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +10 -4
- package/internal/graph/build_releases_the_scratch_it_no_longer_reads_test.go +22 -15
- package/internal/graph/decorators.go +18 -0
- package/internal/graph/decorators_capture_name_and_literal_arguments_test.go +9 -4
- package/internal/graph/diagnostics.go +21 -8
- package/internal/graph/doc_refs_are_the_use_the_checker_already_counts_test.go +25 -13
- package/internal/graph/doc_refs_resolve_documentation_links_test.go +19 -15
- package/internal/graph/doc_tags.go +28 -19
- package/internal/graph/doc_tags_are_claimed_before_they_are_read_test.go +16 -6
- package/internal/graph/doc_tags_capture_every_unrecognized_tag_test.go +9 -2
- package/internal/graph/doc_tags_read_only_what_the_parser_attached_test.go +12 -8
- package/internal/graph/doc_tags_stop_at_the_external_boundary_test.go +11 -1
- package/internal/graph/doc_tags_survive_line_endings_and_repeated_blocks_test.go +16 -6
- package/internal/graph/dump.go +200 -51
- package/internal/graph/dump_checkout_paths_are_stable_test.go +9 -2
- package/internal/graph/dump_diagnostics_ride_the_generation_that_built_it_test.go +10 -11
- package/internal/graph/dump_evidence_skips_leading_trivia_test.go +8 -2
- package/internal/graph/dump_is_a_function_of_the_source_test.go +12 -13
- package/internal/graph/dump_never_serializes_a_list_as_null_test.go +9 -9
- package/internal/graph/dump_path_mapper_caches_alias_resolution_test.go +10 -2
- package/internal/graph/dump_path_mapper_rejects_unportable_roots_and_collisions_test.go +53 -0
- package/internal/graph/{dump_paths_are_portable_and_injective_test.go → dump_path_mapper_uses_portable_coordinates_test.go} +8 -43
- package/internal/graph/dump_paths.go +61 -25
- package/internal/graph/dump_paths_canonicalize_windows_short_root_test.go +45 -8
- package/internal/graph/dump_rejects_provenance_only_path_errors_test.go +5 -0
- package/internal/graph/dump_serializes_the_full_graph_test.go +13 -19
- package/internal/graph/dump_symlink_project_publishes_matching_base_test.go +8 -0
- package/internal/graph/dump_uses_ecma_line_terminators_test.go +12 -6
- package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +11 -8
- package/internal/graph/edge_spans_point_to_resolved_usage_test.go +13 -5
- package/internal/graph/edges.go +44 -47
- package/internal/graph/edges_cover_class_level_references_test.go +14 -11
- package/internal/graph/enum_initializer_calls_are_edges_test.go +13 -3
- package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +19 -26
- package/internal/graph/exports.go +3 -5
- package/internal/graph/file_diagnostics_match_tsgo_code_and_location_test.go +9 -4
- package/internal/graph/file_diagnostics_report_code_column_and_message_test.go +11 -5
- package/internal/graph/function_locals_do_not_collide_test.go +27 -7
- package/internal/graph/gitignore.go +25 -12
- package/internal/graph/graph.go +167 -52
- package/internal/graph/heritage_edges_cover_implements_and_interface_extends_test.go +11 -3
- package/internal/graph/heritage_edges_keep_extends_and_implements_to_same_base_test.go +6 -0
- package/internal/graph/heritage_edges_record_extends_versus_implements_origin_test.go +9 -3
- package/internal/graph/heritage_edges_traverse_barrels_and_stop_at_external_leaves_test.go +11 -4
- package/internal/graph/line_model.go +44 -25
- package/internal/graph/literals.go +6 -7
- package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +10 -5
- package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +15 -17
- package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +10 -9
- package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +11 -11
- package/internal/graph/literals_resolve_through_alias_indirection_test.go +11 -11
- package/internal/graph/member_relation_edges_follow_checker_validity_test.go +11 -2
- package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +11 -1
- package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +12 -7
- package/internal/graph/namespace_dotted_form_qualifies_deeply_test.go +12 -3
- package/internal/graph/namespace_members_become_qualified_nodes_and_edges_test.go +12 -2
- package/internal/graph/node_identity_is_position_invariant_test.go +8 -2
- package/internal/graph/node_ids_preserve_hash_bearing_components_test.go +10 -2
- package/internal/graph/node_modifiers_emit_union_strings_test.go +13 -12
- package/internal/graph/nodes_are_marked_exported_through_the_export_table_test.go +12 -14
- package/internal/graph/object_literal_declarations_resolve_calls_test.go +170 -0
- package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +14 -13
- package/internal/graph/object_member_signatures_preserve_literal_whitespace_test.go +11 -7
- package/internal/graph/object_members.go +100 -1
- package/internal/graph/overload_implementation_replaces_signature_test.go +13 -2
- package/internal/graph/property_member_edges_remain_owner_visible_test.go +9 -3
- package/internal/graph/provenance.go +172 -87
- package/internal/graph/resolve.go +46 -12
- package/internal/graph/resolve_prefers_implementation_declaration_test.go +10 -2
- package/internal/graph/resolve_unwraps_barrel_reexport_to_real_declaration_test.go +16 -20
- package/internal/graph/source.go +16 -6
- package/internal/graph/source_texts_cover_every_resident_program_source_test.go +11 -7
- package/internal/graph/type_ref_edges_cover_typeof_as_satisfies_test.go +21 -2
- package/internal/graph/type_ref_edges_resolve_named_types_across_files_test.go +8 -3
- package/internal/graph/value_access_edges_cover_properties_test.go +11 -3
- package/internal/graph/value_call_edges_attribute_function_assignments_to_members_test.go +10 -4
- package/internal/graph/value_call_edges_cover_jsx_components_test.go +12 -8
- package/internal/graph/value_call_edges_cover_methods_and_constructors_test.go +12 -9
- package/internal/graph/value_call_edges_cover_variable_bound_callables_test.go +9 -3
- package/internal/graph/value_call_edges_do_not_double_record_invoked_member_access_test.go +10 -3
- package/internal/graph/value_call_edges_record_construct_versus_call_origin_test.go +12 -9
- package/internal/graph/value_call_edges_resolve_across_files_and_dedupe_test.go +10 -3
- package/internal/graph/value_call_edges_skip_self_and_unresolved_test.go +16 -5
- package/internal/graph/wire_node_ids_share_alias_resolution_test.go +10 -4
- package/internal/graphsymbols/position_helpers_follow_ecma_line_terminators_test.go +16 -4
- package/internal/graphsymbols/provider.go +278 -113
- package/internal/lspserver/lsp_clean_didopen_refreshes_compiler_state_test.go +14 -12
- package/internal/lspserver/lsp_completion_gate_never_refuses_a_matching_line_test.go +7 -1
- package/internal/lspserver/lsp_completion_hints_longest_trigger_wins_test.go +30 -5
- package/internal/lspserver/lsp_completion_hints_nearest_trigger_wins_test.go +5 -0
- package/internal/lspserver/lsp_completion_merges_into_upstream_response_test.go +23 -10
- package/internal/lspserver/lsp_completion_nearest_hint_replaces_nearest_filter_test.go +7 -1
- package/internal/lspserver/lsp_completion_preserves_completion_list_extensions_test.go +13 -5
- package/internal/lspserver/lsp_completion_refuses_hints_inside_a_string_literal_test.go +11 -7
- package/internal/lspserver/lsp_completion_replaces_full_filter_in_rank_order_test.go +12 -2
- package/internal/lspserver/lsp_completion_request.go +5 -26
- package/internal/lspserver/lsp_completion_scope.go +13 -10
- package/internal/lspserver/lsp_completion_scope_bench_test.go +11 -5
- package/internal/lspserver/lsp_completion_scope_classifies_regex_statement_and_operator_boundaries_test.go +8 -1
- package/internal/lspserver/lsp_completion_scope_ignores_jsdoc_bytes_in_literals_test.go +11 -10
- package/internal/lspserver/lsp_completion_scope_refuses_regex_hints_test.go +7 -3
- package/internal/lspserver/lsp_completion_trigger_uses_last_rune_test.go +6 -0
- package/internal/lspserver/lsp_deleted_watched_file_withdraws_plugin_diagnostics_test.go +11 -10
- package/internal/lspserver/lsp_didsave_keeps_the_incremental_changed_uri_path_test.go +12 -9
- package/internal/lspserver/lsp_document_diagnostics_omits_cached_project_when_current_result_has_none_test.go +17 -5
- package/internal/lspserver/lsp_envelope.go +84 -11
- package/internal/lspserver/lsp_executable_project_input_change_requests_launcher_restart_test.go +12 -9
- package/internal/lspserver/lsp_external_watched_change_retains_program_test.go +8 -2
- package/internal/lspserver/lsp_frame.go +42 -10
- package/internal/lspserver/lsp_hints_absence_is_not_an_error_test.go +16 -15
- package/internal/lspserver/lsp_hints_refresh_coalesces_concurrent_requests_test.go +21 -12
- package/internal/lspserver/lsp_hints_refresh_ignores_a_superseded_generation_test.go +20 -12
- package/internal/lspserver/lsp_hints_refresh_keeps_each_producer_isolated_test.go +30 -9
- package/internal/lspserver/lsp_hints_refresh_replaces_the_session_snapshot_test.go +25 -18
- package/internal/lspserver/lsp_hints_refresh_scheduled_by_editor_events_test.go +12 -12
- package/internal/lspserver/lsp_hints_refresh_serves_completion_while_running_test.go +21 -8
- package/internal/lspserver/lsp_index_byte_from_bounds_its_search_start_test.go +9 -7
- package/internal/lspserver/lsp_initialize_constrains_position_encoding_to_utf16_test.go +57 -21
- package/internal/lspserver/lsp_late_completion_trigger_is_reported_once_test.go +16 -17
- package/internal/lspserver/lsp_native_completion_hints_decode_flat_lint_wire_test.go +8 -2
- package/internal/lspserver/lsp_native_completion_hints_grouped_compatibility_boundary_test.go +5 -0
- package/internal/lspserver/lsp_native_plugin_source.go +381 -202
- package/internal/lspserver/lsp_native_plugin_source_ends_the_session_on_a_selection_input_test.go +234 -0
- package/internal/lspserver/lsp_native_reply_policies_test.go +475 -0
- package/internal/lspserver/lsp_native_reply_policy.go +232 -0
- package/internal/lspserver/lsp_native_resident.go +171 -57
- package/internal/lspserver/lsp_plugin.go +372 -68
- package/internal/lspserver/lsp_plugin_completion_resolve_stays_local_test.go +13 -4
- package/internal/lspserver/lsp_plugin_selection_inputs.go +283 -0
- package/internal/lspserver/lsp_plugin_selection_inputs_follow_directory_case_semantics_windows_test.go +81 -0
- package/internal/lspserver/lsp_position_conversions_span_astral_and_combining_runes_test.go +33 -11
- package/internal/lspserver/lsp_project_context_transport_identity_test.go +14 -2
- package/internal/lspserver/lsp_project_diagnostics.go +25 -4
- package/internal/lspserver/lsp_project_diagnostics_capability_is_independent_test.go +13 -2
- package/internal/lspserver/lsp_project_diagnostics_program_input_overlap_refreshes_all_producers_test.go +14 -4
- package/internal/lspserver/lsp_project_diagnostics_refresh_accumulates_owner_freshness_test.go +8 -2
- package/internal/lspserver/lsp_project_diagnostics_refresh_keeps_each_producer_last_good_test.go +10 -5
- package/internal/lspserver/lsp_project_diagnostics_refreshes_only_input_owners_test.go +14 -2
- package/internal/lspserver/lsp_project_diagnostics_resume_preserves_generation_test.go +8 -2
- package/internal/lspserver/lsp_project_diagnostics_translates_relative_client_project_test.go +15 -11
- package/internal/lspserver/lsp_project_input_ownership_resolves_declared_spellings_test.go +17 -8
- package/internal/lspserver/lsp_project_input_path_key_windows.go +16 -16
- package/internal/lspserver/lsp_project_input_path_key_windows_test.go +34 -18
- package/internal/lspserver/lsp_project_input_registration.go +5 -1
- package/internal/lspserver/lsp_project_input_registration_rechecks_selection_baseline_test.go +10 -4
- package/internal/lspserver/lsp_project_input_registration_reconciles_rejected_pending_request_test.go +5 -0
- package/internal/lspserver/lsp_project_input_registration_shapes_patterns_test.go +9 -3
- package/internal/lspserver/lsp_project_input_watchers_anchor_missing_paths_test.go +8 -3
- package/internal/lspserver/lsp_project_inputs.go +203 -59
- package/internal/lspserver/lsp_project_inputs_match_missing_exact_and_glob_test.go +10 -6
- package/internal/lspserver/lsp_project_inputs_reject_invalid_and_foreign_snapshots_test.go +25 -2
- package/internal/lspserver/lsp_proxy.go +239 -80
- package/internal/lspserver/lsp_refresh.go +16 -1
- package/internal/lspserver/lsp_reload_directories_compare_immediate_topology_test.go +66 -19
- package/internal/lspserver/lsp_reload_directories_separate_glob_territory_test.go +26 -6
- package/internal/lspserver/lsp_reload_file_fingerprint_preserves_raw_symlink_target_test.go +12 -6
- package/internal/lspserver/lsp_reload_fingerprints_read_a_junction_as_a_link_test.go +76 -0
- package/internal/lspserver/lsp_resident_falls_back_when_serve_unsupported_test.go +20 -13
- package/internal/lspserver/lsp_resident_invalidation_broadcasts_program_input_overlap_test.go +9 -4
- package/internal/lspserver/lsp_resident_invalidation_targets_project_input_owners_test.go +6 -1
- package/internal/lspserver/lsp_resident_maps_verb_args_test.go +5 -0
- package/internal/lspserver/lsp_same_transport_entries_are_deduplicated_test.go +10 -1
- package/internal/lspserver/lsp_server.go +124 -21
- package/internal/lspserver/lsp_symbols.go +92 -13
- package/internal/lspserver/lsp_watched_file_changes_reach_compiler_caches_test.go +11 -10
- package/internal/sourceprocess/complete_group.go +70 -0
- package/internal/sourceprocess/complete_group_preserves_original_wait_and_requires_independent_absence_test.go +145 -0
- package/internal/sourceprocess/contain_unix.go +143 -0
- package/internal/sourceprocess/contain_windows.go +439 -0
- package/internal/sourceprocess/darwin_group_retirement_preserves_phase_evidence_test.go +287 -0
- package/internal/sourceprocess/observe_exit_darwin.go +57 -0
- package/internal/sourceprocess/observe_exit_linux.go +27 -0
- package/internal/sourceprocess/observe_exit_other.go +11 -0
- package/internal/sourceprocess/reap_linux.go +31 -0
- package/internal/sourceprocess/reap_other.go +10 -0
- package/internal/sourceprocess/request_preserves_native_command_inputs_test.go +86 -0
- package/internal/sourceprocess/run.go +216 -0
- package/internal/sourceprocess/started_windows.go +41 -0
- package/internal/sourceprocess/target_windows.go +211 -0
- package/internal/sourceprocess/windows_job_accounting_rejects_invalid_boundary_test.go +97 -0
- package/internal/sourceprocess/windows_started_publication_distinguishes_pending_from_refusal_test.go +76 -0
- package/internal/sourceprocess/windows_target_owns_suspended_admission_test.go +179 -0
- package/internal/watchhelper/run.go +42 -0
- package/internal/watchhelper/run_linux.go +323 -0
- package/internal/watchhelper/run_linux_test.go +418 -0
- package/internal/watchhelper/run_other.go +16 -0
- package/internal/watchhelper/run_windows.go +471 -0
- package/internal/watchhelper/watchhelper.go +106 -0
- package/internal/watchhelper/windows_notifications_preserve_mutations_without_access_noise_test.go +506 -0
- package/lib/TtscCompiler.d.ts +118 -21
- package/lib/TtscCompiler.js +175 -179
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/TtscService.d.ts +66 -18
- package/lib/TtscService.js +81 -24
- package/lib/TtscService.js.map +1 -1
- package/lib/TtscServiceRequestOptions.d.ts +21 -0
- package/lib/TtscServiceRequestOptions.js +3 -0
- package/lib/TtscServiceRequestOptions.js.map +1 -0
- package/lib/compiler/internal/CapturedProcessOutput.d.ts +61 -0
- package/lib/compiler/internal/CapturedProcessOutput.js +3 -0
- package/lib/compiler/internal/CapturedProcessOutput.js.map +1 -0
- package/lib/compiler/internal/CompilerArgumentsInspection.d.ts +53 -0
- package/lib/compiler/internal/CompilerArgumentsInspection.js +173 -0
- package/lib/compiler/internal/CompilerArgumentsInspection.js.map +1 -0
- package/lib/compiler/internal/EmitOwnershipIndex.d.ts +92 -0
- package/lib/compiler/internal/EmitOwnershipIndex.js +215 -0
- package/lib/compiler/internal/EmitOwnershipIndex.js.map +1 -0
- package/lib/compiler/internal/PrivateCompilerOutput.d.ts +67 -0
- package/lib/compiler/internal/PrivateCompilerOutput.js +245 -0
- package/lib/compiler/internal/PrivateCompilerOutput.js.map +1 -0
- package/lib/compiler/internal/ResidentCheckProcess.d.ts +127 -0
- package/lib/compiler/internal/ResidentCheckProcess.js +403 -0
- package/lib/compiler/internal/ResidentCheckProcess.js.map +1 -0
- package/lib/compiler/internal/ResidentCheckProcessOptions.d.ts +29 -0
- package/lib/compiler/internal/ResidentCheckProcessOptions.js +3 -0
- package/lib/compiler/internal/ResidentCheckProcessOptions.js.map +1 -0
- package/lib/compiler/internal/ResidentCheckRequest.d.ts +37 -0
- package/lib/compiler/internal/ResidentCheckRequest.js +3 -0
- package/lib/compiler/internal/ResidentCheckRequest.js.map +1 -0
- package/lib/compiler/internal/ResidentCheckResult.d.ts +23 -0
- package/lib/compiler/internal/ResidentCheckResult.js +3 -0
- package/lib/compiler/internal/ResidentCheckResult.js.map +1 -0
- package/lib/compiler/internal/ResidentCheckTelemetry.d.ts +33 -0
- package/lib/compiler/internal/ResidentCheckTelemetry.js +3 -0
- package/lib/compiler/internal/ResidentCheckTelemetry.js.map +1 -0
- package/lib/compiler/internal/ResidentReplyKind.d.ts +18 -0
- package/lib/compiler/internal/ResidentReplyKind.js +3 -0
- package/lib/compiler/internal/ResidentReplyKind.js.map +1 -0
- package/lib/compiler/internal/ResidentTransformProcess.d.ts +83 -0
- package/lib/compiler/internal/ResidentTransformProcess.js +261 -0
- package/lib/compiler/internal/ResidentTransformProcess.js.map +1 -0
- package/lib/compiler/internal/ResidentTransformProcessOptions.d.ts +27 -0
- package/lib/compiler/internal/ResidentTransformProcessOptions.js +3 -0
- package/lib/compiler/internal/ResidentTransformProcessOptions.js.map +1 -0
- package/lib/compiler/internal/ResidentTransformReply.d.ts +51 -0
- package/lib/compiler/internal/ResidentTransformReply.js +79 -0
- package/lib/compiler/internal/ResidentTransformReply.js.map +1 -0
- package/lib/compiler/internal/ResidentTransformRequestOptions.d.ts +16 -0
- package/lib/compiler/internal/ResidentTransformRequestOptions.js +3 -0
- package/lib/compiler/internal/ResidentTransformRequestOptions.js.map +1 -0
- package/lib/compiler/internal/ResidentTransformRequests.d.ts +102 -0
- package/lib/compiler/internal/ResidentTransformRequests.js +172 -0
- package/lib/compiler/internal/ResidentTransformRequests.js.map +1 -0
- package/lib/compiler/internal/StartedResidentTransform.d.ts +27 -0
- package/lib/compiler/internal/StartedResidentTransform.js +3 -0
- package/lib/compiler/internal/StartedResidentTransform.js.map +1 -0
- package/lib/compiler/internal/TransformProjectWorkerReply.d.ts +34 -0
- package/lib/compiler/internal/TransformProjectWorkerReply.js +3 -0
- package/lib/compiler/internal/TransformProjectWorkerReply.js.map +1 -0
- package/lib/compiler/internal/TransformProjectWorkerRequest.d.ts +39 -0
- package/lib/compiler/internal/TransformProjectWorkerRequest.js +3 -0
- package/lib/compiler/internal/TransformProjectWorkerRequest.js.map +1 -0
- package/lib/compiler/internal/build/BuildExecution.d.ts +359 -0
- package/lib/compiler/internal/build/BuildExecution.js +977 -0
- package/lib/compiler/internal/build/BuildExecution.js.map +1 -0
- package/lib/compiler/internal/build/BuildTiming.d.ts +99 -0
- package/lib/compiler/internal/build/BuildTiming.js +113 -0
- package/lib/compiler/internal/build/BuildTiming.js.map +1 -0
- package/lib/compiler/internal/build/CompilerDiagnostics.d.ts +82 -0
- package/lib/compiler/internal/build/CompilerDiagnostics.js +270 -0
- package/lib/compiler/internal/build/CompilerDiagnostics.js.map +1 -0
- package/lib/compiler/internal/build/NativePluginArguments.d.ts +114 -0
- package/lib/compiler/internal/build/NativePluginArguments.js +255 -0
- package/lib/compiler/internal/build/NativePluginArguments.js.map +1 -0
- package/lib/compiler/internal/build/PassthroughFlags.d.ts +137 -0
- package/lib/compiler/internal/build/PassthroughFlags.js +213 -0
- package/lib/compiler/internal/build/PassthroughFlags.js.map +1 -0
- package/lib/compiler/internal/build/PluginFailureDiagnostics.d.ts +48 -0
- package/lib/compiler/internal/build/PluginFailureDiagnostics.js +68 -0
- package/lib/compiler/internal/build/PluginFailureDiagnostics.js.map +1 -0
- package/lib/compiler/internal/build/ResidentCheckEntryPlan.d.ts +38 -0
- package/lib/compiler/internal/build/ResidentCheckEntryPlan.js +3 -0
- package/lib/compiler/internal/build/ResidentCheckEntryPlan.js.map +1 -0
- package/lib/compiler/internal/build/ResidentCheckWatchChange.d.ts +30 -0
- package/lib/compiler/internal/build/ResidentCheckWatchChange.js +3 -0
- package/lib/compiler/internal/build/ResidentCheckWatchChange.js.map +1 -0
- package/lib/compiler/internal/build/ResidentCheckWatchSession.d.ts +113 -0
- package/lib/compiler/internal/build/ResidentCheckWatchSession.js +378 -0
- package/lib/compiler/internal/build/ResidentCheckWatchSession.js.map +1 -0
- package/lib/compiler/internal/build/RunBuildOptions.d.ts +130 -0
- package/lib/compiler/internal/build/RunBuildOptions.js +3 -0
- package/lib/compiler/internal/build/RunBuildOptions.js.map +1 -0
- package/lib/compiler/internal/build/TsgoArguments.d.ts +168 -0
- package/lib/compiler/internal/build/TsgoArguments.js +324 -0
- package/lib/compiler/internal/build/TsgoArguments.js.map +1 -0
- package/lib/compiler/internal/build/appendBuildOutput.d.ts +41 -0
- package/lib/compiler/internal/build/appendBuildOutput.js +182 -0
- package/lib/compiler/internal/build/appendBuildOutput.js.map +1 -0
- package/lib/compiler/internal/build/bufferResidentCheckEntryRequests.d.ts +20 -0
- package/lib/compiler/internal/build/bufferResidentCheckEntryRequests.js +40 -0
- package/lib/compiler/internal/build/bufferResidentCheckEntryRequests.js.map +1 -0
- package/lib/compiler/internal/build/createProcessDiagnostic.d.ts +19 -0
- package/lib/compiler/internal/build/createProcessDiagnostic.js +30 -0
- package/lib/compiler/internal/build/createProcessDiagnostic.js.map +1 -0
- package/lib/compiler/internal/build/isAbsoluteLocalProjectInputPath.d.ts +22 -0
- package/lib/compiler/internal/build/isAbsoluteLocalProjectInputPath.js +59 -0
- package/lib/compiler/internal/build/isAbsoluteLocalProjectInputPath.js.map +1 -0
- package/lib/compiler/internal/build/mergeProjectInputSnapshots.d.ts +28 -0
- package/lib/compiler/internal/build/mergeProjectInputSnapshots.js +121 -0
- package/lib/compiler/internal/build/mergeProjectInputSnapshots.js.map +1 -0
- package/lib/compiler/internal/build/normalizeBuildOutput.d.ts +29 -0
- package/lib/compiler/internal/build/normalizeBuildOutput.js +72 -0
- package/lib/compiler/internal/build/normalizeBuildOutput.js.map +1 -0
- package/lib/compiler/internal/build/parseProjectInputSnapshot.d.ts +26 -0
- package/lib/compiler/internal/build/parseProjectInputSnapshot.js +68 -0
- package/lib/compiler/internal/build/parseProjectInputSnapshot.js.map +1 -0
- package/lib/compiler/internal/build/planResidentCheckEntries.d.ts +21 -0
- package/lib/compiler/internal/build/planResidentCheckEntries.js +45 -0
- package/lib/compiler/internal/build/planResidentCheckEntries.js.map +1 -0
- package/lib/compiler/internal/build/privateRuntimeRootDir.d.ts +20 -0
- package/lib/compiler/internal/build/privateRuntimeRootDir.js +35 -0
- package/lib/compiler/internal/build/privateRuntimeRootDir.js.map +1 -0
- package/lib/compiler/internal/build/residentCheckRequest.d.ts +22 -0
- package/lib/compiler/internal/build/residentCheckRequest.js +42 -0
- package/lib/compiler/internal/build/residentCheckRequest.js.map +1 -0
- package/lib/compiler/internal/build/runBuild.d.ts +22 -0
- package/lib/compiler/internal/build/runBuild.js +44 -0
- package/lib/compiler/internal/build/runBuild.js.map +1 -0
- package/lib/compiler/internal/build/runExternalEmitProvenance.d.ts +61 -0
- package/lib/compiler/internal/build/runExternalEmitProvenance.js +451 -0
- package/lib/compiler/internal/build/runExternalEmitProvenance.js.map +1 -0
- package/lib/compiler/internal/build/takeResidentCheckEntryRequest.d.ts +18 -0
- package/lib/compiler/internal/build/takeResidentCheckEntryRequest.js +28 -0
- package/lib/compiler/internal/build/takeResidentCheckEntryRequest.js.map +1 -0
- package/lib/compiler/internal/buildNativeCompiler.d.ts +16 -1
- package/lib/compiler/internal/buildNativeCompiler.js +14 -2
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
- package/lib/compiler/internal/captureProcessOutput.d.ts +23 -23
- package/lib/compiler/internal/captureProcessOutput.js +38 -26
- package/lib/compiler/internal/captureProcessOutput.js.map +1 -1
- package/lib/compiler/internal/compileProjectInMemory.d.ts +30 -7
- package/lib/compiler/internal/compileProjectInMemory.js +103 -83
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/ensureExecutable.d.ts +15 -0
- package/lib/compiler/internal/ensureExecutable.js +40 -0
- package/lib/compiler/internal/ensureExecutable.js.map +1 -0
- package/lib/compiler/internal/findNearestGoMod.d.ts +23 -0
- package/lib/compiler/internal/findNearestGoMod.js +48 -0
- package/lib/compiler/internal/findNearestGoMod.js.map +1 -0
- package/lib/compiler/internal/isOutsideRelativePath.d.ts +18 -0
- package/lib/compiler/internal/isOutsideRelativePath.js +30 -0
- package/lib/compiler/internal/isOutsideRelativePath.js.map +1 -0
- package/lib/compiler/internal/outputText.d.ts +16 -0
- package/lib/compiler/internal/outputText.js +25 -0
- package/lib/compiler/internal/outputText.js.map +1 -0
- package/lib/compiler/internal/packageRootDir.d.ts +25 -0
- package/lib/compiler/internal/packageRootDir.js +47 -0
- package/lib/compiler/internal/packageRootDir.js.map +1 -0
- package/lib/compiler/internal/parseNativeTransformOutput.d.ts +88 -0
- package/lib/compiler/internal/parseNativeTransformOutput.js +552 -0
- package/lib/compiler/internal/parseNativeTransformOutput.js.map +1 -0
- package/lib/compiler/internal/project/CompilerProjectSelection.d.ts +80 -0
- package/lib/compiler/internal/project/CompilerProjectSelection.js +187 -0
- package/lib/compiler/internal/project/CompilerProjectSelection.js.map +1 -0
- package/lib/compiler/internal/project/ConfigJsonText.d.ts +50 -0
- package/lib/compiler/internal/project/ConfigJsonText.js +61 -0
- package/lib/compiler/internal/project/ConfigJsonText.js.map +1 -0
- package/lib/compiler/internal/project/compilerUsesCaseSensitiveFileNames.d.ts +48 -0
- package/lib/compiler/internal/project/compilerUsesCaseSensitiveFileNames.js +119 -0
- package/lib/compiler/internal/project/compilerUsesCaseSensitiveFileNames.js.map +1 -0
- package/lib/compiler/internal/project/createNativeProjectContextArgs.d.ts +11 -8
- package/lib/compiler/internal/project/createNativeProjectContextArgs.js +15 -17
- package/lib/compiler/internal/project/createNativeProjectContextArgs.js.map +1 -1
- package/lib/compiler/internal/project/createNativeProjectContextJson.d.ts +19 -0
- package/lib/compiler/internal/project/createNativeProjectContextJson.js +27 -0
- package/lib/compiler/internal/project/createNativeProjectContextJson.js.map +1 -0
- package/lib/compiler/internal/project/parseJsonc.d.ts +42 -0
- package/lib/compiler/internal/project/parseJsonc.js +317 -0
- package/lib/compiler/internal/project/parseJsonc.js.map +1 -0
- package/lib/compiler/internal/project/readJsonFile.d.ts +21 -0
- package/lib/compiler/internal/project/readJsonFile.js +38 -0
- package/lib/compiler/internal/project/readJsonFile.js.map +1 -0
- package/lib/compiler/internal/project/readJsoncFile.d.ts +20 -0
- package/lib/compiler/internal/project/readJsoncFile.js +47 -0
- package/lib/compiler/internal/project/readJsoncFile.js.map +1 -0
- package/lib/compiler/internal/project/readProjectConfig.d.ts +29 -2
- package/lib/compiler/internal/project/readProjectConfig.js +105 -168
- package/lib/compiler/internal/project/readProjectConfig.js.map +1 -1
- package/lib/compiler/internal/project/resolveOwningProjectConfig.d.ts +65 -0
- package/lib/compiler/internal/project/resolveOwningProjectConfig.js +248 -0
- package/lib/compiler/internal/project/resolveOwningProjectConfig.js.map +1 -0
- package/lib/compiler/internal/project/resolveProjectConfig.d.ts +17 -14
- package/lib/compiler/internal/project/resolveProjectConfig.js +19 -122
- package/lib/compiler/internal/project/resolveProjectConfig.js.map +1 -1
- package/lib/compiler/internal/project/resolveProjectIdentity.d.ts +32 -0
- package/lib/compiler/internal/project/resolveProjectIdentity.js +144 -0
- package/lib/compiler/internal/project/resolveProjectIdentity.js.map +1 -0
- package/lib/compiler/internal/project/resolveTsconfigExtends.d.ts +38 -0
- package/lib/compiler/internal/project/resolveTsconfigExtends.js +163 -0
- package/lib/compiler/internal/project/resolveTsconfigExtends.js.map +1 -0
- package/lib/compiler/internal/project/selectReferencedProject.d.ts +26 -0
- package/lib/compiler/internal/project/selectReferencedProject.js +48 -0
- package/lib/compiler/internal/project/selectReferencedProject.js.map +1 -0
- package/lib/compiler/internal/project/tsconfigExtendsFileCandidates.d.ts +34 -0
- package/lib/compiler/internal/project/tsconfigExtendsFileCandidates.js +55 -0
- package/lib/compiler/internal/project/tsconfigExtendsFileCandidates.js.map +1 -0
- package/lib/compiler/internal/readEffectiveCompilerOptions.d.ts +54 -0
- package/lib/compiler/internal/readEffectiveCompilerOptions.js +116 -0
- package/lib/compiler/internal/readEffectiveCompilerOptions.js.map +1 -0
- package/lib/compiler/internal/resolveBinary.d.ts +17 -1
- package/lib/compiler/internal/resolveBinary.js +24 -9
- package/lib/compiler/internal/resolveBinary.js.map +1 -1
- package/lib/compiler/internal/resolveTsgo.d.ts +22 -7
- package/lib/compiler/internal/resolveTsgo.js +25 -9
- package/lib/compiler/internal/resolveTsgo.js.map +1 -1
- package/lib/compiler/internal/runNativeCheckWithObservations.d.ts +41 -0
- package/lib/compiler/internal/runNativeCheckWithObservations.js +185 -0
- package/lib/compiler/internal/runNativeCheckWithObservations.js.map +1 -0
- package/lib/compiler/internal/runSingleFileEmit.d.ts +26 -5
- package/lib/compiler/internal/runSingleFileEmit.js +82 -27
- package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
- package/lib/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.d.ts +2 -0
- package/lib/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.js +6 -0
- package/lib/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.js.map +1 -0
- package/lib/compiler/internal/sharedHost/SidecarEnvironment.d.ts +90 -0
- package/lib/compiler/internal/sharedHost/SidecarEnvironment.js +153 -0
- package/lib/compiler/internal/sharedHost/SidecarEnvironment.js.map +1 -0
- package/lib/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.d.ts +7 -0
- package/lib/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.js +11 -0
- package/lib/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.js.map +1 -0
- package/lib/compiler/internal/sharedHost/TSGO_ARGS_ENV.d.ts +7 -0
- package/lib/compiler/internal/sharedHost/TSGO_ARGS_ENV.js +11 -0
- package/lib/compiler/internal/sharedHost/TSGO_ARGS_ENV.js.map +1 -0
- package/lib/compiler/internal/sharedHost/assertSharedHostCompatibility.d.ts +24 -0
- package/lib/compiler/internal/sharedHost/assertSharedHostCompatibility.js +46 -0
- package/lib/compiler/internal/sharedHost/assertSharedHostCompatibility.js.map +1 -0
- package/lib/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.d.ts +15 -0
- package/lib/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.js +23 -0
- package/lib/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.js.map +1 -0
- package/lib/compiler/internal/sharedHost/clearInheritedTsgoArgs.d.ts +23 -0
- package/lib/compiler/internal/sharedHost/clearInheritedTsgoArgs.js +33 -0
- package/lib/compiler/internal/sharedHost/clearInheritedTsgoArgs.js.map +1 -0
- package/lib/compiler/internal/sharedHost/inheritedSidecarEnv.d.ts +27 -0
- package/lib/compiler/internal/sharedHost/inheritedSidecarEnv.js +41 -0
- package/lib/compiler/internal/sharedHost/inheritedSidecarEnv.js.map +1 -0
- package/lib/compiler/internal/sharedHost/isLinkedTransform.d.ts +16 -0
- package/lib/compiler/internal/sharedHost/isLinkedTransform.js +21 -0
- package/lib/compiler/internal/sharedHost/isLinkedTransform.js.map +1 -0
- package/lib/compiler/internal/sharedHost/linkedTransformPlugins.d.ts +19 -0
- package/lib/compiler/internal/sharedHost/linkedTransformPlugins.js +25 -0
- package/lib/compiler/internal/sharedHost/linkedTransformPlugins.js.map +1 -0
- package/lib/compiler/internal/sharedHost/publishLinkedTransformPlugins.d.ts +25 -0
- package/lib/compiler/internal/sharedHost/publishLinkedTransformPlugins.js +35 -0
- package/lib/compiler/internal/sharedHost/publishLinkedTransformPlugins.js.map +1 -0
- package/lib/compiler/internal/sharedHost/resolvePluginConfigDir.d.ts +26 -0
- package/lib/compiler/internal/sharedHost/resolvePluginConfigDir.js +36 -0
- package/lib/compiler/internal/sharedHost/resolvePluginConfigDir.js.map +1 -0
- package/lib/compiler/internal/sharedHost/selectSharedHostPlugin.d.ts +22 -0
- package/lib/compiler/internal/sharedHost/selectSharedHostPlugin.js +32 -0
- package/lib/compiler/internal/sharedHost/selectSharedHostPlugin.js.map +1 -0
- package/lib/compiler/internal/spawnNative.d.ts +15 -16
- package/lib/compiler/internal/spawnNative.js +17 -45
- package/lib/compiler/internal/spawnNative.js.map +1 -1
- package/lib/compiler/internal/startResidentTransform.d.ts +26 -17
- package/lib/compiler/internal/startResidentTransform.js +51 -36
- package/lib/compiler/internal/startResidentTransform.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.d.ts +42 -5
- package/lib/compiler/internal/transformProjectInMemory.js +189 -469
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/transformProjectInWorker.d.ts +49 -0
- package/lib/compiler/internal/transformProjectInWorker.js +168 -0
- package/lib/compiler/internal/transformProjectInWorker.js.map +1 -0
- package/lib/compiler/internal/transformProjectWorker.js +37 -0
- package/lib/compiler/internal/transformProjectWorker.js.map +1 -0
- package/lib/flags/AnySubcommand.d.ts +18 -0
- package/lib/flags/AnySubcommand.js +3 -0
- package/lib/flags/AnySubcommand.js.map +1 -0
- package/lib/flags/COMPILER_ENUM_WHITESPACE.d.ts +2 -0
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js +38 -0
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js.map +1 -0
- package/lib/flags/COMPILER_OPTIONS.d.ts +6 -0
- package/lib/flags/COMPILER_OPTIONS.js +509 -0
- package/lib/flags/COMPILER_OPTIONS.js.map +1 -0
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.d.ts +2 -0
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js +13 -0
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js.map +1 -0
- package/lib/flags/COMPILER_OPTION_KINDS.d.ts +2 -0
- package/lib/flags/COMPILER_OPTION_KINDS.js +14 -0
- package/lib/flags/COMPILER_OPTION_KINDS.js.map +1 -0
- package/lib/flags/CompilerOptionSpec.d.ts +27 -0
- package/lib/flags/CompilerOptionSpec.js +3 -0
- package/lib/flags/CompilerOptionSpec.js.map +1 -0
- package/lib/flags/FLAG_BY_TOKEN.d.ts +8 -0
- package/lib/flags/FLAG_BY_TOKEN.js +34 -0
- package/lib/flags/FLAG_BY_TOKEN.js.map +1 -0
- package/lib/flags/FLAG_SCHEMA.d.ts +35 -0
- package/lib/flags/{schema.js → FLAG_SCHEMA.js} +47 -153
- package/lib/flags/FLAG_SCHEMA.js.map +1 -0
- package/lib/flags/FlagKind.d.ts +22 -0
- package/lib/flags/FlagKind.js +3 -0
- package/lib/flags/FlagKind.js.map +1 -0
- package/lib/flags/FlagLayer.d.ts +19 -0
- package/lib/flags/FlagLayer.js +3 -0
- package/lib/flags/FlagLayer.js.map +1 -0
- package/lib/flags/FlagSpec.d.ts +104 -0
- package/lib/flags/FlagSpec.js +3 -0
- package/lib/flags/FlagSpec.js.map +1 -0
- package/lib/flags/ParseOptions.d.ts +92 -0
- package/lib/flags/ParseOptions.js +3 -0
- package/lib/flags/ParseOptions.js.map +1 -0
- package/lib/flags/ParseResult.d.ts +37 -0
- package/lib/flags/ParseResult.js +3 -0
- package/lib/flags/ParseResult.js.map +1 -0
- package/lib/flags/TtscSubcommand.d.ts +14 -0
- package/lib/flags/TtscSubcommand.js +3 -0
- package/lib/flags/TtscSubcommand.js.map +1 -0
- package/lib/flags/TtsxSubcommand.d.ts +13 -0
- package/lib/flags/TtsxSubcommand.js +3 -0
- package/lib/flags/TtsxSubcommand.js.map +1 -0
- package/lib/flags/ValueValidator.d.ts +14 -0
- package/lib/flags/ValueValidator.js +3 -0
- package/lib/flags/ValueValidator.js.map +1 -0
- package/lib/flags/buildGoAllowList.d.ts +18 -0
- package/lib/flags/buildGoAllowList.js +45 -0
- package/lib/flags/buildGoAllowList.js.map +1 -0
- package/lib/flags/flagsForSubcommand.d.ts +18 -0
- package/lib/flags/flagsForSubcommand.js +23 -0
- package/lib/flags/flagsForSubcommand.js.map +1 -0
- package/lib/flags/getBoolean.d.ts +19 -0
- package/lib/flags/getBoolean.js +27 -0
- package/lib/flags/getBoolean.js.map +1 -0
- package/lib/flags/getNumber.d.ts +16 -0
- package/lib/flags/getNumber.js +24 -0
- package/lib/flags/getNumber.js.map +1 -0
- package/lib/flags/getString.d.ts +16 -0
- package/lib/flags/getString.js +24 -0
- package/lib/flags/getString.js.map +1 -0
- package/lib/flags/getStringList.d.ts +19 -0
- package/lib/flags/getStringList.js +24 -0
- package/lib/flags/getStringList.js.map +1 -0
- package/lib/flags/normalizeCompilerEnumValue.d.ts +20 -0
- package/lib/flags/normalizeCompilerEnumValue.js +40 -0
- package/lib/flags/normalizeCompilerEnumValue.js.map +1 -0
- package/lib/flags/normalizeFlagToken.d.ts +28 -0
- package/lib/flags/normalizeFlagToken.js +38 -0
- package/lib/flags/normalizeFlagToken.js.map +1 -0
- package/lib/flags/parseFlags.d.ts +18 -0
- package/lib/flags/parseFlags.js +288 -0
- package/lib/flags/parseFlags.js.map +1 -0
- package/lib/flags/readCompilerOptionOccurrence.d.ts +34 -0
- package/lib/flags/readCompilerOptionOccurrence.js +81 -0
- package/lib/flags/readCompilerOptionOccurrence.js.map +1 -0
- package/lib/flags/readCompilerOptionValues.d.ts +33 -0
- package/lib/flags/readCompilerOptionValues.js +58 -0
- package/lib/flags/readCompilerOptionValues.js.map +1 -0
- package/lib/flags/resolveFlagSpec.d.ts +21 -0
- package/lib/flags/resolveFlagSpec.js +32 -0
- package/lib/flags/resolveFlagSpec.js.map +1 -0
- package/lib/index.d.ts +8 -3
- package/lib/index.js +10 -3
- package/lib/index.js.map +1 -1
- package/lib/internal/CanonicalTempDirectoryOperations.d.ts +73 -0
- package/lib/internal/CanonicalTempDirectoryOperations.js +3 -0
- package/lib/internal/CanonicalTempDirectoryOperations.js.map +1 -0
- package/lib/internal/CompilerContextSnapshot.d.ts +66 -0
- package/lib/internal/CompilerContextSnapshot.js +121 -0
- package/lib/internal/CompilerContextSnapshot.js.map +1 -0
- package/lib/internal/CompilerResultAdapter.d.ts +129 -0
- package/lib/internal/CompilerResultAdapter.js +247 -0
- package/lib/internal/CompilerResultAdapter.js.map +1 -0
- package/lib/internal/E2ETrace.d.ts +219 -0
- package/lib/internal/E2ETrace.js +541 -0
- package/lib/internal/E2ETrace.js.map +1 -0
- package/lib/internal/IJavaScriptRuntimeCapabilities.d.ts +48 -0
- package/lib/internal/IJavaScriptRuntimeCapabilities.js +3 -0
- package/lib/internal/IJavaScriptRuntimeCapabilities.js.map +1 -0
- package/lib/internal/OwnedNativeProcess.d.ts +66 -0
- package/lib/internal/OwnedNativeProcess.js +317 -0
- package/lib/internal/OwnedNativeProcess.js.map +1 -0
- package/lib/internal/OwnedSynchronousProcess.d.ts +158 -0
- package/lib/internal/OwnedSynchronousProcess.js +171 -0
- package/lib/internal/OwnedSynchronousProcess.js.map +1 -0
- package/lib/internal/RetireLockDirectoryOperations.d.ts +77 -0
- package/lib/internal/RetireLockDirectoryOperations.js +3 -0
- package/lib/internal/RetireLockDirectoryOperations.js.map +1 -0
- package/lib/internal/SafeCacheCleanupTarget.d.ts +39 -0
- package/lib/internal/SafeCacheCleanupTarget.js +3 -0
- package/lib/internal/SafeCacheCleanupTarget.js.map +1 -0
- package/lib/internal/SourceNativeRetirement.d.ts +384 -0
- package/lib/internal/SourceNativeRetirement.js +892 -0
- package/lib/internal/SourceNativeRetirement.js.map +1 -0
- package/lib/internal/SpawnSyncOutputFiles.d.ts +28 -0
- package/lib/internal/SpawnSyncOutputFiles.js +3 -0
- package/lib/internal/SpawnSyncOutputFiles.js.map +1 -0
- package/lib/internal/cacheEntryExists.d.ts +13 -0
- package/lib/internal/cacheEntryExists.js +32 -0
- package/lib/internal/cacheEntryExists.js.map +1 -0
- package/lib/internal/createCanonicalTempDirectory.d.ts +23 -13
- package/lib/internal/createCanonicalTempDirectory.js +31 -12
- package/lib/internal/createCanonicalTempDirectory.js.map +1 -1
- package/lib/internal/isContendedCandidateRename.d.ts +27 -0
- package/lib/internal/isContendedCandidateRename.js +37 -0
- package/lib/internal/isContendedCandidateRename.js.map +1 -0
- package/lib/internal/isSpawnSyncFdExhaustion.d.ts +16 -0
- package/lib/internal/isSpawnSyncFdExhaustion.js +23 -0
- package/lib/internal/isSpawnSyncFdExhaustion.js.map +1 -0
- package/lib/internal/javascriptRuntimeCapabilities.d.ts +20 -0
- package/lib/internal/javascriptRuntimeCapabilities.js +142 -0
- package/lib/internal/javascriptRuntimeCapabilities.js.map +1 -0
- package/lib/internal/nativeBinary.d.ts +11 -0
- package/lib/internal/nativeBinary.js +16 -0
- package/lib/internal/nativeBinary.js.map +1 -0
- package/lib/internal/parseWindowsDirectoryCaseSensitivity.d.ts +24 -0
- package/lib/internal/parseWindowsDirectoryCaseSensitivity.js +47 -0
- package/lib/internal/parseWindowsDirectoryCaseSensitivity.js.map +1 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentity.d.ts +43 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentity.js +3 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentity.js.map +1 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentityContext.d.ts +176 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentityContext.js +3 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentityContext.js.map +1 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentityOperations.d.ts +100 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentityOperations.js +3 -0
- package/lib/internal/pathIdentity/FilesystemPathIdentityOperations.js.map +1 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentity.d.ts +20 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentity.js +3 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentity.js.map +1 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentityContext.d.ts +20 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentityContext.js +3 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentityContext.js.map +1 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentityOperations.d.ts +20 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentityOperations.js +3 -0
- package/lib/internal/pathIdentity/ProjectInputPathIdentityOperations.js.map +1 -0
- package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.d.ts +25 -0
- package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js +336 -0
- package/lib/internal/pathIdentity/createFilesystemPathIdentityContext.js.map +1 -0
- package/lib/internal/pathIdentity/createProjectInputPathIdentityContext.d.ts +28 -0
- package/lib/internal/pathIdentity/createProjectInputPathIdentityContext.js +33 -0
- package/lib/internal/pathIdentity/createProjectInputPathIdentityContext.js.map +1 -0
- package/lib/internal/pathIdentity/isFilesystemPathIdentityWithin.d.ts +20 -0
- package/lib/internal/pathIdentity/isFilesystemPathIdentityWithin.js +33 -0
- package/lib/internal/pathIdentity/isFilesystemPathIdentityWithin.js.map +1 -0
- package/lib/internal/pathIdentity/isProjectInputPathIdentityWithin.d.ts +15 -0
- package/lib/internal/pathIdentity/isProjectInputPathIdentityWithin.js +22 -0
- package/lib/internal/pathIdentity/isProjectInputPathIdentityWithin.js.map +1 -0
- package/lib/internal/pathIdentity/resolveFilesystemPath.d.ts +22 -0
- package/lib/internal/pathIdentity/resolveFilesystemPath.js +44 -0
- package/lib/internal/pathIdentity/resolveFilesystemPath.js.map +1 -0
- package/lib/internal/pathIdentity/resolvePhysicalPath.d.ts +21 -0
- package/lib/internal/pathIdentity/resolvePhysicalPath.js +35 -0
- package/lib/internal/pathIdentity/resolvePhysicalPath.js.map +1 -0
- package/lib/internal/pathIdentity/resolveProjectInputPath.d.ts +14 -0
- package/lib/internal/pathIdentity/resolveProjectInputPath.js +21 -0
- package/lib/internal/pathIdentity/resolveProjectInputPath.js.map +1 -0
- package/lib/internal/pluginSource.d.ts +26 -0
- package/lib/internal/pluginSource.js +43 -0
- package/lib/internal/pluginSource.js.map +1 -0
- package/lib/internal/projectInputPathIdentity.d.ts +27 -31
- package/lib/internal/projectInputPathIdentity.js +37 -275
- package/lib/internal/projectInputPathIdentity.js.map +1 -1
- package/lib/internal/resolveNodeBinary.d.ts +9 -7
- package/lib/internal/resolveNodeBinary.js +14 -144
- package/lib/internal/resolveNodeBinary.js.map +1 -1
- package/lib/internal/resolveSafeCacheCleanupTargets.d.ts +27 -8
- package/lib/internal/resolveSafeCacheCleanupTargets.js +44 -11
- package/lib/internal/resolveSafeCacheCleanupTargets.js.map +1 -1
- package/lib/internal/restoreCompilerError.d.ts +21 -0
- package/lib/internal/restoreCompilerError.js +164 -0
- package/lib/internal/restoreCompilerError.js.map +1 -0
- package/lib/internal/retireLockDirectory.d.ts +45 -0
- package/lib/internal/retireLockDirectory.js +152 -0
- package/lib/internal/retireLockDirectory.js.map +1 -0
- package/lib/internal/runHoldingLock.d.ts +30 -0
- package/lib/internal/runHoldingLock.js +53 -0
- package/lib/internal/runHoldingLock.js.map +1 -0
- package/lib/internal/runtimeExecutableIdentity.d.ts +20 -0
- package/lib/internal/runtimeExecutableIdentity.js +171 -0
- package/lib/internal/runtimeExecutableIdentity.js.map +1 -0
- package/lib/internal/serializeCompilerError.d.ts +28 -0
- package/lib/internal/serializeCompilerError.js +138 -0
- package/lib/internal/serializeCompilerError.js.map +1 -0
- package/lib/internal/spawnSyncResilient.d.ts +21 -10
- package/lib/internal/spawnSyncResilient.js +31 -147
- package/lib/internal/spawnSyncResilient.js.map +1 -1
- package/lib/internal/spawnSyncWithLowDescriptors.d.ts +30 -0
- package/lib/internal/spawnSyncWithLowDescriptors.js +194 -0
- package/lib/internal/spawnSyncWithLowDescriptors.js.map +1 -0
- package/lib/internal/tsconfig.d.ts +16 -0
- package/lib/internal/tsconfig.js +33 -0
- package/lib/internal/tsconfig.js.map +1 -0
- package/lib/launcher/internal/PendingResidentCheckWatchChanges.d.ts +56 -0
- package/lib/launcher/internal/PendingResidentCheckWatchChanges.js +97 -0
- package/lib/launcher/internal/PendingResidentCheckWatchChanges.js.map +1 -0
- package/lib/launcher/internal/TtscBuildMode.d.ts +14 -0
- package/lib/launcher/internal/TtscBuildMode.js +3 -0
- package/lib/launcher/internal/TtscBuildMode.js.map +1 -0
- package/lib/launcher/internal/TtsxEntryOptions.d.ts +50 -0
- package/lib/launcher/internal/TtsxEntryOptions.js +94 -0
- package/lib/launcher/internal/TtsxEntryOptions.js.map +1 -0
- package/lib/launcher/internal/assertNoSolutionBuild.d.ts +17 -10
- package/lib/launcher/internal/assertNoSolutionBuild.js +16 -9
- package/lib/launcher/internal/assertNoSolutionBuild.js.map +1 -1
- package/lib/launcher/internal/assertTtsxNoWatch.d.ts +25 -0
- package/lib/launcher/internal/assertTtsxNoWatch.js +46 -0
- package/lib/launcher/internal/assertTtsxNoWatch.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootProject.d.ts +108 -0
- package/lib/launcher/internal/buildSingleRootProject.js +229 -0
- package/lib/launcher/internal/buildSingleRootProject.js.map +1 -0
- package/lib/launcher/internal/getCompilerVersionText.d.ts +14 -1
- package/lib/launcher/internal/getCompilerVersionText.js +21 -6
- package/lib/launcher/internal/getCompilerVersionText.js.map +1 -1
- package/lib/launcher/internal/inlineServedSourceMap.d.ts +35 -0
- package/lib/launcher/internal/inlineServedSourceMap.js +255 -0
- package/lib/launcher/internal/inlineServedSourceMap.js.map +1 -0
- package/lib/launcher/internal/linkVirtualEntry.d.ts +31 -0
- package/lib/launcher/internal/linkVirtualEntry.js +87 -0
- package/lib/launcher/internal/linkVirtualEntry.js.map +1 -0
- package/lib/launcher/internal/parseCommonJsExports.d.ts +17 -0
- package/lib/launcher/internal/{commonJsExportMetadata.js → parseCommonJsExports.js} +13 -3
- package/lib/launcher/internal/parseCommonJsExports.js.map +1 -0
- package/lib/launcher/internal/parseTtscBuildArgs.d.ts +34 -0
- package/lib/launcher/internal/parseTtscBuildArgs.js +97 -0
- package/lib/launcher/internal/parseTtscBuildArgs.js.map +1 -0
- package/lib/launcher/internal/parseTtsxCLI.d.ts +35 -0
- package/lib/launcher/internal/parseTtsxCLI.js +187 -0
- package/lib/launcher/internal/parseTtsxCLI.js.map +1 -0
- package/lib/launcher/internal/prepareExecution.d.ts +49 -5
- package/lib/launcher/internal/prepareExecution.js +360 -324
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/prepareTtscBuildMode.d.ts +23 -0
- package/lib/launcher/internal/prepareTtscBuildMode.js +58 -0
- package/lib/launcher/internal/prepareTtscBuildMode.js.map +1 -0
- package/lib/launcher/internal/resolveCacheDir.d.ts +12 -3
- package/lib/launcher/internal/resolveCacheDir.js +12 -3
- package/lib/launcher/internal/resolveCacheDir.js.map +1 -1
- package/lib/launcher/internal/resolveSingleFileOutput.d.ts +35 -0
- package/lib/launcher/internal/resolveSingleFileOutput.js +115 -0
- package/lib/launcher/internal/resolveSingleFileOutput.js.map +1 -0
- package/lib/launcher/internal/resolveTtscserverBinary.d.ts +15 -3
- package/lib/launcher/internal/resolveTtscserverBinary.js +19 -5
- package/lib/launcher/internal/resolveTtscserverBinary.js.map +1 -1
- package/lib/launcher/internal/runTtsc.d.ts +23 -23
- package/lib/launcher/internal/runTtsc.js +336 -286
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtsx.d.ts +32 -4
- package/lib/launcher/internal/runTtsx.js +286 -138
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/launcher/internal/runtime/CommonJsRuntimeSource.d.ts +92 -0
- package/lib/launcher/internal/runtime/CommonJsRuntimeSource.js +354 -0
- package/lib/launcher/internal/runtime/CommonJsRuntimeSource.js.map +1 -0
- package/lib/launcher/internal/runtime/DependencyBuildAdmission.d.ts +72 -0
- package/lib/launcher/internal/runtime/DependencyBuildAdmission.js +120 -0
- package/lib/launcher/internal/runtime/DependencyBuildAdmission.js.map +1 -0
- package/lib/launcher/internal/runtime/DependencyBuildGeneration.d.ts +185 -0
- package/lib/launcher/internal/runtime/DependencyBuildGeneration.js +153 -0
- package/lib/launcher/internal/runtime/DependencyBuildGeneration.js.map +1 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockFence.d.ts +22 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockFence.js +3 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockFence.js.map +1 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockLease.d.ts +22 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockLease.js +3 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockLease.js.map +1 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockObservation.d.ts +41 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockObservation.js +3 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockObservation.js.map +1 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockProtocol.d.ts +83 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockProtocol.js +126 -0
- package/lib/launcher/internal/runtime/DependencyBuildLockProtocol.js.map +1 -0
- package/lib/launcher/internal/runtime/OwnedProjectSource.d.ts +112 -0
- package/lib/launcher/internal/runtime/OwnedProjectSource.js +59 -0
- package/lib/launcher/internal/runtime/OwnedProjectSource.js.map +1 -0
- package/lib/launcher/internal/runtime/OwningModuleOptions.d.ts +21 -0
- package/lib/launcher/internal/runtime/OwningModuleOptions.js +3 -0
- package/lib/launcher/internal/runtime/OwningModuleOptions.js.map +1 -0
- package/lib/launcher/internal/runtime/PluginDescriptorInputObservation.d.ts +89 -0
- package/lib/launcher/internal/runtime/PluginDescriptorInputObservation.js +115 -0
- package/lib/launcher/internal/runtime/PluginDescriptorInputObservation.js.map +1 -0
- package/lib/launcher/internal/runtime/ProcessOwnedDirectory.d.ts +168 -0
- package/lib/launcher/internal/runtime/ProcessOwnedDirectory.js +251 -0
- package/lib/launcher/internal/runtime/ProcessOwnedDirectory.js.map +1 -0
- package/lib/launcher/internal/runtime/ResolveResult.d.ts +24 -0
- package/lib/launcher/internal/runtime/ResolveResult.js +3 -0
- package/lib/launcher/internal/runtime/ResolveResult.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeEmitProvenance.d.ts +38 -0
- package/lib/launcher/internal/runtime/RuntimeEmitProvenance.js +60 -0
- package/lib/launcher/internal/runtime/RuntimeEmitProvenance.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeEntryPreparer.d.ts +22 -0
- package/lib/launcher/internal/runtime/RuntimeEntryPreparer.js +3 -0
- package/lib/launcher/internal/runtime/RuntimeEntryPreparer.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeFilesystem.d.ts +52 -0
- package/lib/launcher/internal/runtime/RuntimeFilesystem.js +73 -0
- package/lib/launcher/internal/runtime/RuntimeFilesystem.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeHookOptions.d.ts +22 -0
- package/lib/launcher/internal/runtime/RuntimeHookOptions.js +3 -0
- package/lib/launcher/internal/runtime/RuntimeHookOptions.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeIsolatedEmit.d.ts +53 -0
- package/lib/launcher/internal/runtime/RuntimeIsolatedEmit.js +88 -0
- package/lib/launcher/internal/runtime/RuntimeIsolatedEmit.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeLoaderCapabilities.d.ts +78 -0
- package/lib/launcher/internal/runtime/RuntimeLoaderCapabilities.js +256 -0
- package/lib/launcher/internal/runtime/RuntimeLoaderCapabilities.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeManifest.d.ts +65 -0
- package/lib/launcher/internal/runtime/RuntimeManifest.js +3 -0
- package/lib/launcher/internal/runtime/RuntimeManifest.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeManifestRegistry.d.ts +95 -0
- package/lib/launcher/internal/runtime/RuntimeManifestRegistry.js +268 -0
- package/lib/launcher/internal/runtime/RuntimeManifestRegistry.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeModuleFormat.d.ts +60 -0
- package/lib/launcher/internal/runtime/RuntimeModuleFormat.js +249 -0
- package/lib/launcher/internal/runtime/RuntimeModuleFormat.js.map +1 -0
- package/lib/launcher/internal/runtime/RuntimeProjectOwnership.d.ts +50 -0
- package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js +134 -0
- package/lib/launcher/internal/runtime/RuntimeProjectOwnership.js.map +1 -0
- package/lib/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.d.ts +11 -0
- package/lib/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.js +15 -0
- package/lib/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.js.map +1 -0
- package/lib/launcher/internal/runtime/acquireDependencyBuildLock.d.ts +22 -0
- package/lib/launcher/internal/runtime/acquireDependencyBuildLock.js +74 -0
- package/lib/launcher/internal/runtime/acquireDependencyBuildLock.js.map +1 -0
- package/lib/launcher/internal/runtime/checkNodeRuntimeSupport.d.ts +30 -0
- package/lib/launcher/internal/runtime/checkNodeRuntimeSupport.js +83 -0
- package/lib/launcher/internal/runtime/checkNodeRuntimeSupport.js.map +1 -0
- package/lib/launcher/internal/runtime/claimRuntimeProjectDirectory.d.ts +30 -0
- package/lib/launcher/internal/runtime/claimRuntimeProjectDirectory.js +52 -0
- package/lib/launcher/internal/runtime/claimRuntimeProjectDirectory.js.map +1 -0
- package/lib/launcher/internal/runtime/commonJsExportNames.d.ts +21 -0
- package/lib/launcher/internal/runtime/commonJsExportNames.js +68 -0
- package/lib/launcher/internal/runtime/commonJsExportNames.js.map +1 -0
- package/lib/launcher/internal/runtime/commonJsImportFacade.d.ts +32 -0
- package/lib/launcher/internal/runtime/commonJsImportFacade.js +56 -0
- package/lib/launcher/internal/runtime/commonJsImportFacade.js.map +1 -0
- package/lib/launcher/internal/runtime/dependencyCacheKey.d.ts +36 -0
- package/lib/launcher/internal/runtime/dependencyCacheKey.js +57 -0
- package/lib/launcher/internal/runtime/dependencyCacheKey.js.map +1 -0
- package/lib/launcher/internal/runtime/dependencyCacheRoot.d.ts +32 -0
- package/lib/launcher/internal/runtime/dependencyCacheRoot.js +98 -0
- package/lib/launcher/internal/runtime/dependencyCacheRoot.js.map +1 -0
- package/lib/launcher/internal/runtime/inspectDependencyBuildLock.d.ts +23 -0
- package/lib/launcher/internal/runtime/inspectDependencyBuildLock.js +126 -0
- package/lib/launcher/internal/runtime/inspectDependencyBuildLock.js.map +1 -0
- package/lib/launcher/internal/runtime/installRuntimeHooks.d.ts +58 -0
- package/lib/launcher/internal/runtime/installRuntimeHooks.js +1988 -0
- package/lib/launcher/internal/runtime/installRuntimeHooks.js.map +1 -0
- package/lib/launcher/internal/runtime/interopProbe.d.ts +8 -0
- package/lib/launcher/internal/runtime/interopProbe.js +3 -0
- package/lib/launcher/internal/runtime/interopProbe.js.map +1 -0
- package/lib/launcher/internal/runtime/isLocalProcessGone.d.ts +33 -0
- package/lib/launcher/internal/runtime/isLocalProcessGone.js +60 -0
- package/lib/launcher/internal/runtime/isLocalProcessGone.js.map +1 -0
- package/lib/launcher/internal/runtime/observeMappedDescriptorResolution.d.ts +28 -0
- package/lib/launcher/internal/runtime/observeMappedDescriptorResolution.js +50 -0
- package/lib/launcher/internal/runtime/observeMappedDescriptorResolution.js.map +1 -0
- package/lib/launcher/internal/runtime/projectModuleOptions.d.ts +16 -0
- package/lib/launcher/internal/runtime/projectModuleOptions.js +28 -0
- package/lib/launcher/internal/runtime/projectModuleOptions.js.map +1 -0
- package/lib/launcher/internal/runtime/readDependencyCache.d.ts +28 -0
- package/lib/launcher/internal/runtime/readDependencyCache.js +83 -0
- package/lib/launcher/internal/runtime/readDependencyCache.js.map +1 -0
- package/lib/launcher/internal/runtime/realPath.d.ts +22 -0
- package/lib/launcher/internal/runtime/realPath.js +37 -0
- package/lib/launcher/internal/runtime/realPath.js.map +1 -0
- package/lib/launcher/internal/runtime/reclaimDependencyBuildLock.d.ts +17 -0
- package/lib/launcher/internal/runtime/reclaimDependencyBuildLock.js +23 -0
- package/lib/launcher/internal/runtime/reclaimDependencyBuildLock.js.map +1 -0
- package/lib/launcher/internal/runtime/releaseDependencyBuildLock.d.ts +17 -0
- package/lib/launcher/internal/runtime/releaseDependencyBuildLock.js +23 -0
- package/lib/launcher/internal/runtime/releaseDependencyBuildLock.js.map +1 -0
- package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.d.ts +34 -0
- package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js +88 -0
- package/lib/launcher/internal/runtime/resolveRuntimeCleanTargets.js.map +1 -0
- package/lib/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.d.ts +20 -0
- package/lib/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.js +30 -0
- package/lib/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.js.map +1 -0
- package/lib/launcher/internal/runtime/runtimeRunKey.d.ts +24 -0
- package/lib/launcher/internal/runtime/runtimeRunKey.js +36 -0
- package/lib/launcher/internal/runtime/runtimeRunKey.js.map +1 -0
- package/lib/launcher/internal/runtime/selectRuntimePluginPolicy.d.ts +21 -0
- package/lib/launcher/internal/runtime/selectRuntimePluginPolicy.js +29 -0
- package/lib/launcher/internal/runtime/selectRuntimePluginPolicy.js.map +1 -0
- package/lib/launcher/internal/runtime/withRuntimeDirectoryLock.d.ts +35 -0
- package/lib/launcher/internal/runtime/withRuntimeDirectoryLock.js +76 -0
- package/lib/launcher/internal/runtime/withRuntimeDirectoryLock.js.map +1 -0
- package/lib/launcher/internal/runtimeCompilerArgs.d.ts +35 -6
- package/lib/launcher/internal/runtimeCompilerArgs.js +87 -58
- package/lib/launcher/internal/runtimeCompilerArgs.js.map +1 -1
- package/lib/launcher/internal/runtimeEmitProfile.d.ts +39 -0
- package/lib/launcher/internal/runtimeEmitProfile.js +56 -0
- package/lib/launcher/internal/runtimeEmitProfile.js.map +1 -0
- package/lib/launcher/internal/runtimeHookPreload.js +4 -4
- package/lib/launcher/internal/runtimeHookPreload.js.map +1 -1
- package/lib/launcher/internal/runtimeOwnerPreload.d.ts +1 -0
- package/lib/launcher/internal/runtimeOwnerPreload.js +43 -0
- package/lib/launcher/internal/runtimeOwnerPreload.js.map +1 -0
- package/lib/launcher/internal/singleRootProjectConfig.d.ts +34 -0
- package/lib/launcher/internal/singleRootProjectConfig.js +39 -0
- package/lib/launcher/internal/singleRootProjectConfig.js.map +1 -0
- package/lib/launcher/internal/ttscserver/ILSPPluginSelectionInputs.d.ts +61 -0
- package/lib/launcher/internal/ttscserver/ILSPPluginSelectionInputs.js +3 -0
- package/lib/launcher/internal/ttscserver/ILSPPluginSelectionInputs.js.map +1 -0
- package/lib/launcher/internal/ttscserver/LSPProjectInputDigest.d.ts +95 -0
- package/lib/launcher/internal/ttscserver/LSPProjectInputDigest.js +270 -0
- package/lib/launcher/internal/ttscserver/LSPProjectInputDigest.js.map +1 -0
- package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.d.ts +46 -0
- package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.js +91 -0
- package/lib/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.js.map +1 -0
- package/lib/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.d.ts +21 -0
- package/lib/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.js +39 -0
- package/lib/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.js.map +1 -0
- package/lib/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.d.ts +18 -0
- package/lib/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.js +27 -0
- package/lib/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.js.map +1 -0
- package/lib/launcher/internal/ttscserver/materializeLSPPluginManifest.d.ts +26 -0
- package/lib/launcher/internal/ttscserver/materializeLSPPluginManifest.js +62 -0
- package/lib/launcher/internal/ttscserver/materializeLSPPluginManifest.js.map +1 -0
- package/lib/launcher/internal/ttscserver/needsStdio.d.ts +17 -0
- package/lib/launcher/internal/ttscserver/needsStdio.js +36 -0
- package/lib/launcher/internal/ttscserver/needsStdio.js.map +1 -0
- package/lib/launcher/internal/ttscserver/runTtscserver.d.ts +25 -0
- package/lib/launcher/internal/ttscserver/runTtscserver.js +439 -0
- package/lib/launcher/internal/ttscserver/runTtscserver.js.map +1 -0
- package/lib/launcher/internal/watch/CompilerDirectoryWatchEventPlan.d.ts +29 -0
- package/lib/launcher/internal/watch/CompilerDirectoryWatchEventPlan.js +3 -0
- package/lib/launcher/internal/watch/CompilerDirectoryWatchEventPlan.js.map +1 -0
- package/lib/launcher/internal/watch/DirectoryWatcher.d.ts +44 -0
- package/lib/launcher/internal/watch/DirectoryWatcher.js +3 -0
- package/lib/launcher/internal/watch/DirectoryWatcher.js.map +1 -0
- package/lib/launcher/internal/watch/FseventsStreams.d.ts +87 -0
- package/lib/launcher/internal/watch/FseventsStreams.js +266 -0
- package/lib/launcher/internal/watch/FseventsStreams.js.map +1 -0
- package/lib/launcher/internal/watch/ProjectInputWatchRules.d.ts +92 -0
- package/lib/launcher/internal/watch/ProjectInputWatchRules.js +163 -0
- package/lib/launcher/internal/watch/ProjectInputWatchRules.js.map +1 -0
- package/lib/launcher/internal/watch/WatchInputChange.d.ts +29 -0
- package/lib/launcher/internal/watch/WatchInputChange.js +3 -0
- package/lib/launcher/internal/watch/WatchInputChange.js.map +1 -0
- package/lib/launcher/internal/watch/WatchPaths.d.ts +101 -0
- package/lib/launcher/internal/watch/WatchPaths.js +150 -0
- package/lib/launcher/internal/watch/WatchPaths.js.map +1 -0
- package/lib/launcher/internal/watch/WatchTopology.d.ts +384 -0
- package/lib/launcher/internal/{watchTopology.js → watch/WatchTopology.js} +726 -799
- package/lib/launcher/internal/watch/WatchTopology.js.map +1 -0
- package/lib/launcher/internal/watch/literalGlobRoot.d.ts +22 -0
- package/lib/launcher/internal/watch/literalGlobRoot.js +45 -0
- package/lib/launcher/internal/watch/literalGlobRoot.js.map +1 -0
- package/lib/launcher/internal/watch/planCompilerDirectoryWatchEvent.d.ts +40 -0
- package/lib/launcher/internal/watch/planCompilerDirectoryWatchEvent.js +69 -0
- package/lib/launcher/internal/watch/planCompilerDirectoryWatchEvent.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputActiveWatchDirectories.d.ts +19 -0
- package/lib/launcher/internal/watch/projectInputActiveWatchDirectories.js +52 -0
- package/lib/launcher/internal/watch/projectInputActiveWatchDirectories.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputAvailableWatchDirectory.d.ts +21 -0
- package/lib/launcher/internal/watch/projectInputAvailableWatchDirectory.js +55 -0
- package/lib/launcher/internal/watch/projectInputAvailableWatchDirectory.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputEventShouldNotify.d.ts +21 -0
- package/lib/launcher/internal/watch/projectInputEventShouldNotify.js +23 -0
- package/lib/launcher/internal/watch/projectInputEventShouldNotify.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputMembershipInvalidatesProgram.d.ts +27 -0
- package/lib/launcher/internal/watch/projectInputMembershipInvalidatesProgram.js +54 -0
- package/lib/launcher/internal/watch/projectInputMembershipInvalidatesProgram.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.d.ts +26 -0
- package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js +100 -0
- package/lib/launcher/internal/watch/projectInputReloadEventShouldNotify.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputReplacementStrandsWatchers.d.ts +37 -0
- package/lib/launcher/internal/watch/projectInputReplacementStrandsWatchers.js +54 -0
- package/lib/launcher/internal/watch/projectInputReplacementStrandsWatchers.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputTopologyMayAffect.d.ts +23 -0
- package/lib/launcher/internal/watch/projectInputTopologyMayAffect.js +67 -0
- package/lib/launcher/internal/watch/projectInputTopologyMayAffect.js.map +1 -0
- package/lib/launcher/internal/watch/projectInputWatchDirectories.d.ts +22 -0
- package/lib/launcher/internal/watch/projectInputWatchDirectories.js +30 -0
- package/lib/launcher/internal/watch/projectInputWatchDirectories.js.map +1 -0
- package/lib/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.d.ts +22 -0
- package/lib/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.js +45 -0
- package/lib/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.js.map +1 -0
- package/lib/launcher/internal/watch/syncWatchers.d.ts +25 -0
- package/lib/launcher/internal/watch/syncWatchers.js +61 -0
- package/lib/launcher/internal/watch/syncWatchers.js.map +1 -0
- package/lib/launcher/internal/watch/watchDirectory.d.ts +28 -0
- package/lib/launcher/internal/watch/watchDirectory.js +46 -0
- package/lib/launcher/internal/watch/watchDirectory.js.map +1 -0
- package/lib/launcher/internal/watch/watchDirectoryThroughFsWatch.d.ts +28 -0
- package/lib/launcher/internal/watch/watchDirectoryThroughFsWatch.js +38 -0
- package/lib/launcher/internal/watch/watchDirectoryThroughFsWatch.js.map +1 -0
- package/lib/launcher/ttscserver.js +1 -1
- package/lib/launcher/ttscserver.js.map +1 -1
- package/lib/launcher/ttsx.js +2 -3
- package/lib/launcher/ttsx.js.map +1 -1
- package/lib/plugin/CapabilityPluginResolver.d.ts +140 -0
- package/lib/plugin/CapabilityPluginResolver.js +400 -0
- package/lib/plugin/CapabilityPluginResolver.js.map +1 -0
- package/lib/plugin/ITtscCapabilityPlugin.d.ts +87 -0
- package/lib/plugin/ITtscCapabilityPlugin.js +3 -0
- package/lib/plugin/ITtscCapabilityPlugin.js.map +1 -0
- package/lib/plugin/internal/CapabilityPluginResult.d.ts +66 -0
- package/lib/plugin/internal/CapabilityPluginResult.js +86 -0
- package/lib/plugin/internal/CapabilityPluginResult.js.map +1 -0
- package/lib/plugin/internal/CapabilityResolutionFormat.d.ts +114 -0
- package/lib/plugin/internal/CapabilityResolutionFormat.js +229 -0
- package/lib/plugin/internal/CapabilityResolutionFormat.js.map +1 -0
- package/lib/plugin/internal/ITtscCapabilityPluginSource.d.ts +35 -0
- package/lib/plugin/internal/ITtscCapabilityPluginSource.js +3 -0
- package/lib/plugin/internal/ITtscCapabilityPluginSource.js.map +1 -0
- package/lib/plugin/internal/ITtscCapabilityResolutionEntry.d.ts +49 -0
- package/lib/plugin/internal/ITtscCapabilityResolutionEntry.js +3 -0
- package/lib/plugin/internal/ITtscCapabilityResolutionEntry.js.map +1 -0
- package/lib/plugin/internal/ITtscCapabilityResolutionPlugin.d.ts +21 -0
- package/lib/plugin/internal/ITtscCapabilityResolutionPlugin.js +3 -0
- package/lib/plugin/internal/ITtscCapabilityResolutionPlugin.js.map +1 -0
- package/lib/plugin/internal/capabilityPluginWorker.d.ts +1 -0
- package/lib/plugin/internal/capabilityPluginWorker.js +178 -0
- package/lib/plugin/internal/capabilityPluginWorker.js.map +1 -0
- package/lib/plugin/internal/decodeCapabilityCommandReply.d.ts +23 -0
- package/lib/plugin/internal/decodeCapabilityCommandReply.js +25 -0
- package/lib/plugin/internal/decodeCapabilityCommandReply.js.map +1 -0
- package/lib/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.d.ts +15 -0
- package/lib/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.js +182 -0
- package/lib/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.js.map +1 -0
- package/lib/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.d.ts +11 -0
- package/lib/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.js +62 -0
- package/lib/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.js.map +1 -0
- package/lib/plugin/internal/load/PluginDescriptorAdmission.d.ts +46 -0
- package/lib/plugin/internal/load/PluginDescriptorAdmission.js +72 -0
- package/lib/plugin/internal/load/PluginDescriptorAdmission.js.map +1 -0
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.d.ts +154 -0
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js +317 -0
- package/lib/plugin/internal/load/PluginDescriptorEvaluationCache.js.map +1 -0
- package/lib/plugin/internal/load/PluginPackageResolution.d.ts +208 -0
- package/lib/plugin/internal/load/PluginPackageResolution.js +593 -0
- package/lib/plugin/internal/load/PluginPackageResolution.js.map +1 -0
- package/lib/plugin/internal/load/ProjectPluginEntries.d.ts +60 -0
- package/lib/plugin/internal/load/ProjectPluginEntries.js +164 -0
- package/lib/plugin/internal/load/ProjectPluginEntries.js.map +1 -0
- package/lib/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.d.ts +13 -0
- package/lib/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.js +21 -0
- package/lib/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.js.map +1 -0
- package/lib/plugin/internal/load/collectProjectHostInputs.d.ts +16 -0
- package/lib/plugin/internal/load/collectProjectHostInputs.js +66 -0
- package/lib/plugin/internal/load/collectProjectHostInputs.js.map +1 -0
- package/lib/plugin/internal/load/composePluginSources.d.ts +20 -0
- package/lib/plugin/internal/load/composePluginSources.js +95 -0
- package/lib/plugin/internal/load/composePluginSources.js.map +1 -0
- package/lib/plugin/internal/load/declaresHostInputReads.d.ts +24 -0
- package/lib/plugin/internal/load/declaresHostInputReads.js +48 -0
- package/lib/plugin/internal/load/declaresHostInputReads.js.map +1 -0
- package/lib/plugin/internal/load/hasProjectPluginEntries.d.ts +21 -0
- package/lib/plugin/internal/load/hasProjectPluginEntries.js +29 -0
- package/lib/plugin/internal/load/hasProjectPluginEntries.js.map +1 -0
- package/lib/plugin/internal/load/hashHostInputPaths.d.ts +17 -0
- package/lib/plugin/internal/load/hashHostInputPaths.js +46 -0
- package/lib/plugin/internal/load/hashHostInputPaths.js.map +1 -0
- package/lib/plugin/internal/load/isRelativePluginSpecifier.d.ts +22 -0
- package/lib/plugin/internal/load/isRelativePluginSpecifier.js +33 -0
- package/lib/plugin/internal/load/isRelativePluginSpecifier.js.map +1 -0
- package/lib/plugin/internal/load/loadProjectPlugins.d.ts +112 -0
- package/lib/plugin/internal/load/loadProjectPlugins.js +1640 -0
- package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -0
- package/lib/plugin/internal/load/moduleResolutionBaseSelects.d.ts +42 -0
- package/lib/plugin/internal/load/moduleResolutionBaseSelects.js +51 -0
- package/lib/plugin/internal/load/moduleResolutionBaseSelects.js.map +1 -0
- package/lib/plugin/internal/load/observeImportSearchRoots.d.ts +29 -0
- package/lib/plugin/internal/load/observeImportSearchRoots.js +38 -0
- package/lib/plugin/internal/load/observeImportSearchRoots.js.map +1 -0
- package/lib/plugin/internal/load/pluginLabel.d.ts +15 -0
- package/lib/plugin/internal/load/pluginLabel.js +25 -0
- package/lib/plugin/internal/load/pluginLabel.js.map +1 -0
- package/lib/plugin/internal/load/realpathHostInput.d.ts +14 -0
- package/lib/plugin/internal/load/realpathHostInput.js +29 -0
- package/lib/plugin/internal/load/realpathHostInput.js.map +1 -0
- package/lib/plugin/internal/load/realpathHostInputPaths.d.ts +17 -0
- package/lib/plugin/internal/load/realpathHostInputPaths.js +28 -0
- package/lib/plugin/internal/load/realpathHostInputPaths.js.map +1 -0
- package/lib/plugin/internal/load/rejectJsTransformFunctions.d.ts +13 -0
- package/lib/plugin/internal/load/rejectJsTransformFunctions.js +22 -0
- package/lib/plugin/internal/load/rejectJsTransformFunctions.js.map +1 -0
- package/lib/plugin/internal/load/requirePluginSource.d.ts +14 -0
- package/lib/plugin/internal/load/requirePluginSource.js +38 -0
- package/lib/plugin/internal/load/requirePluginSource.js.map +1 -0
- package/lib/plugin/internal/load/resolveNativeSource.d.ts +29 -0
- package/lib/plugin/internal/load/resolveNativeSource.js +37 -0
- package/lib/plugin/internal/load/resolveNativeSource.js.map +1 -0
- package/lib/plugin/internal/load/validatePluginContributors.d.ts +22 -0
- package/lib/plugin/internal/load/validatePluginContributors.js +86 -0
- package/lib/plugin/internal/load/validatePluginContributors.js.map +1 -0
- package/lib/plugin/internal/load/validatePluginSource.d.ts +14 -0
- package/lib/plugin/internal/load/validatePluginSource.js +21 -0
- package/lib/plugin/internal/load/validatePluginSource.js.map +1 -0
- package/lib/plugin/internal/load/visitImportMappedCandidates.d.ts +36 -0
- package/lib/plugin/internal/load/visitImportMappedCandidates.js +45 -0
- package/lib/plugin/internal/load/visitImportMappedCandidates.js.map +1 -0
- package/lib/plugin/internal/pluginDescriptorFailureReason.d.ts +23 -0
- package/lib/plugin/internal/pluginDescriptorFailureReason.js +43 -0
- package/lib/plugin/internal/pluginDescriptorFailureReason.js.map +1 -0
- package/lib/plugin/internal/pluginDescriptorProcessFailure.d.ts +28 -0
- package/lib/plugin/internal/pluginDescriptorProcessFailure.js +37 -0
- package/lib/plugin/internal/pluginDescriptorProcessFailure.js.map +1 -0
- package/lib/plugin/internal/readCapabilityResolution.d.ts +42 -0
- package/lib/plugin/internal/readCapabilityResolution.js +158 -0
- package/lib/plugin/internal/readCapabilityResolution.js.map +1 -0
- package/lib/plugin/internal/receiveCapabilityFailure.d.ts +21 -0
- package/lib/plugin/internal/receiveCapabilityFailure.js +28 -0
- package/lib/plugin/internal/receiveCapabilityFailure.js.map +1 -0
- package/lib/plugin/internal/source/CachePrunePolicy.d.ts +42 -0
- package/lib/plugin/internal/source/CachePrunePolicy.js +47 -0
- package/lib/plugin/internal/source/CachePrunePolicy.js.map +1 -0
- package/lib/plugin/internal/source/GoBuildCacheCoordination.d.ts +159 -0
- package/lib/plugin/internal/source/GoBuildCacheCoordination.js +475 -0
- package/lib/plugin/internal/source/GoBuildCacheCoordination.js.map +1 -0
- package/lib/plugin/internal/source/GoEnvironmentReading.d.ts +42 -0
- package/lib/plugin/internal/source/GoEnvironmentReading.js +110 -0
- package/lib/plugin/internal/source/GoEnvironmentReading.js.map +1 -0
- package/lib/plugin/internal/source/GoSourceInputs.d.ts +124 -0
- package/lib/plugin/internal/source/GoSourceInputs.js +180 -0
- package/lib/plugin/internal/source/GoSourceInputs.js.map +1 -0
- package/lib/plugin/internal/source/GoToolResolution.d.ts +125 -0
- package/lib/plugin/internal/source/GoToolResolution.js +278 -0
- package/lib/plugin/internal/source/GoToolResolution.js.map +1 -0
- package/lib/plugin/internal/source/IGoBuildCachePruneOptions.d.ts +30 -0
- package/lib/plugin/internal/source/IGoBuildCachePruneOptions.js +3 -0
- package/lib/plugin/internal/source/IGoBuildCachePruneOptions.js.map +1 -0
- package/lib/plugin/internal/source/IPluginCachePruneOptions.d.ts +33 -0
- package/lib/plugin/internal/source/IPluginCachePruneOptions.js +3 -0
- package/lib/plugin/internal/source/IPluginCachePruneOptions.js.map +1 -0
- package/lib/plugin/internal/source/IPluginModuleReplaceDirectory.d.ts +27 -0
- package/lib/plugin/internal/source/IPluginModuleReplaceDirectory.js +3 -0
- package/lib/plugin/internal/source/IPluginModuleReplaceDirectory.js.map +1 -0
- package/lib/plugin/internal/source/ITtscBuildContributor.d.ts +18 -0
- package/lib/plugin/internal/source/ITtscBuildContributor.js +3 -0
- package/lib/plugin/internal/source/ITtscBuildContributor.js.map +1 -0
- package/lib/plugin/internal/source/ITtscSourceBuildCachePaths.d.ts +25 -0
- package/lib/plugin/internal/source/ITtscSourceBuildCachePaths.js +3 -0
- package/lib/plugin/internal/source/ITtscSourceBuildCachePaths.js.map +1 -0
- package/lib/plugin/internal/source/NativeSourcePackages.d.ts +155 -0
- package/lib/plugin/internal/source/NativeSourcePackages.js +330 -0
- package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -0
- package/lib/plugin/internal/source/PluginBinaryUse.d.ts +66 -0
- package/lib/plugin/internal/source/PluginBinaryUse.js +163 -0
- package/lib/plugin/internal/source/PluginBinaryUse.js.map +1 -0
- package/lib/plugin/internal/source/PluginBinaryWaitResult.d.ts +34 -0
- package/lib/plugin/internal/source/PluginBinaryWaitResult.js +3 -0
- package/lib/plugin/internal/source/PluginBinaryWaitResult.js.map +1 -0
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.d.ts +111 -0
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js +243 -0
- package/lib/plugin/internal/source/PluginBuildEnvironmentReadings.js.map +1 -0
- package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.d.ts +130 -0
- package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.js +215 -0
- package/lib/plugin/internal/source/PluginBuildEnvironmentWitness.js.map +1 -0
- package/lib/plugin/internal/source/PluginBuildLockFence.d.ts +25 -0
- package/lib/plugin/internal/source/PluginBuildLockFence.js +3 -0
- package/lib/plugin/internal/source/PluginBuildLockFence.js.map +1 -0
- package/lib/plugin/internal/source/PluginBuildLockLease.d.ts +29 -0
- package/lib/plugin/internal/source/PluginBuildLockLease.js +3 -0
- package/lib/plugin/internal/source/PluginBuildLockLease.js.map +1 -0
- package/lib/plugin/internal/source/PluginBuildLockObservation.d.ts +42 -0
- package/lib/plugin/internal/source/PluginBuildLockObservation.js +3 -0
- package/lib/plugin/internal/source/PluginBuildLockObservation.js.map +1 -0
- package/lib/plugin/internal/source/PluginBuildLockOwner.d.ts +126 -0
- package/lib/plugin/internal/source/PluginBuildLockOwner.js +165 -0
- package/lib/plugin/internal/source/PluginBuildLockOwner.js.map +1 -0
- package/lib/plugin/internal/source/PluginBuildLockProtocol.d.ts +234 -0
- package/lib/plugin/internal/source/PluginBuildLockProtocol.js +287 -0
- package/lib/plugin/internal/source/PluginBuildLockProtocol.js.map +1 -0
- package/lib/plugin/internal/source/SourceBuildCacheLayout.d.ts +183 -0
- package/lib/plugin/internal/source/SourceBuildCacheLayout.js +291 -0
- package/lib/plugin/internal/source/SourceBuildCacheLayout.js.map +1 -0
- package/lib/plugin/internal/source/SourceBuildFilesystemOperations.d.ts +32 -0
- package/lib/plugin/internal/source/SourceBuildFilesystemOperations.js +3 -0
- package/lib/plugin/internal/source/SourceBuildFilesystemOperations.js.map +1 -0
- package/lib/plugin/internal/source/SourcePluginAdmission.d.ts +80 -0
- package/lib/plugin/internal/source/SourcePluginAdmission.js +114 -0
- package/lib/plugin/internal/source/SourcePluginAdmission.js.map +1 -0
- package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +153 -0
- package/lib/plugin/internal/source/SourcePluginWorkspace.js +394 -0
- package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -0
- package/lib/plugin/internal/source/acquirePluginBuildLock.d.ts +35 -0
- package/lib/plugin/internal/source/acquirePluginBuildLock.js +176 -0
- package/lib/plugin/internal/source/acquirePluginBuildLock.js.map +1 -0
- package/lib/plugin/internal/source/autoQuoteGoModToken.d.ts +24 -0
- package/lib/plugin/internal/source/autoQuoteGoModToken.js +110 -0
- package/lib/plugin/internal/source/autoQuoteGoModToken.js.map +1 -0
- package/lib/plugin/internal/source/buildSourcePlugin.d.ts +89 -0
- package/lib/plugin/internal/source/buildSourcePlugin.js +862 -0
- package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -0
- package/lib/plugin/internal/source/collectPluginSourceDirectories.d.ts +30 -0
- package/lib/plugin/internal/source/collectPluginSourceDirectories.js +77 -0
- package/lib/plugin/internal/source/collectPluginSourceDirectories.js.map +1 -0
- package/lib/plugin/internal/source/collectPluginSourceFiles.d.ts +40 -0
- package/lib/plugin/internal/source/collectPluginSourceFiles.js +95 -0
- package/lib/plugin/internal/source/collectPluginSourceFiles.js.map +1 -0
- package/lib/plugin/internal/source/computeCacheKey.d.ts +75 -0
- package/lib/plugin/internal/source/computeCacheKey.js +122 -0
- package/lib/plugin/internal/source/computeCacheKey.js.map +1 -0
- package/lib/plugin/internal/source/copiesPluginSourceEntry.d.ts +33 -0
- package/lib/plugin/internal/source/copiesPluginSourceEntry.js +57 -0
- package/lib/plugin/internal/source/copiesPluginSourceEntry.js.map +1 -0
- package/lib/plugin/internal/source/createExternalSourceSnapshotLayout.d.ts +22 -0
- package/lib/plugin/internal/source/createExternalSourceSnapshotLayout.js +60 -0
- package/lib/plugin/internal/source/createExternalSourceSnapshotLayout.js.map +1 -0
- package/lib/plugin/internal/source/ensureExecutableGoToolchain.d.ts +25 -0
- package/lib/plugin/internal/source/ensureExecutableGoToolchain.js +96 -0
- package/lib/plugin/internal/source/ensureExecutableGoToolchain.js.map +1 -0
- package/lib/plugin/internal/source/formatDuration.d.ts +18 -0
- package/lib/plugin/internal/source/formatDuration.js +36 -0
- package/lib/plugin/internal/source/formatDuration.js.map +1 -0
- package/lib/plugin/internal/source/formatGoWorkPath.d.ts +35 -0
- package/lib/plugin/internal/source/formatGoWorkPath.js +42 -0
- package/lib/plugin/internal/source/formatGoWorkPath.js.map +1 -0
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +47 -0
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +597 -0
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -0
- package/lib/plugin/internal/source/inspectPluginBuildLock.d.ts +29 -0
- package/lib/plugin/internal/source/inspectPluginBuildLock.js +285 -0
- package/lib/plugin/internal/source/inspectPluginBuildLock.js.map +1 -0
- package/lib/plugin/internal/source/isPathWithin.d.ts +16 -0
- package/lib/plugin/internal/source/isPathWithin.js +28 -0
- package/lib/plugin/internal/source/isPathWithin.js.map +1 -0
- package/lib/plugin/internal/source/legacyGlobalCacheTargets.d.ts +24 -0
- package/lib/plugin/internal/source/legacyGlobalCacheTargets.js +60 -0
- package/lib/plugin/internal/source/legacyGlobalCacheTargets.js.map +1 -0
- package/lib/plugin/internal/source/pluginBuildEnvironment.d.ts +31 -0
- package/lib/plugin/internal/source/pluginBuildEnvironment.js +47 -0
- package/lib/plugin/internal/source/pluginBuildEnvironment.js.map +1 -0
- package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.d.ts +1 -0
- package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.js +24 -0
- package/lib/plugin/internal/source/pluginBuildEnvironmentWorker.js.map +1 -0
- package/lib/plugin/internal/source/pluginBuildVersions.d.ts +31 -0
- package/lib/plugin/internal/source/pluginBuildVersions.js +65 -0
- package/lib/plugin/internal/source/pluginBuildVersions.js.map +1 -0
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.d.ts +41 -0
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js +74 -0
- package/lib/plugin/internal/source/pluginModuleReplaceDirectories.js.map +1 -0
- package/lib/plugin/internal/source/pluginSourceCovers.d.ts +32 -0
- package/lib/plugin/internal/source/pluginSourceCovers.js +54 -0
- package/lib/plugin/internal/source/pluginSourceCovers.js.map +1 -0
- package/lib/plugin/internal/source/pluginSourceDigest.d.ts +40 -0
- package/lib/plugin/internal/source/pluginSourceDigest.js +60 -0
- package/lib/plugin/internal/source/pluginSourceDigest.js.map +1 -0
- package/lib/plugin/internal/source/pluginSourceFilesSignature.d.ts +38 -0
- package/lib/plugin/internal/source/pluginSourceFilesSignature.js +53 -0
- package/lib/plugin/internal/source/pluginSourceFilesSignature.js.map +1 -0
- package/lib/plugin/internal/source/pluginSourceState.d.ts +47 -0
- package/lib/plugin/internal/source/pluginSourceState.js +63 -0
- package/lib/plugin/internal/source/pluginSourceState.js.map +1 -0
- package/lib/plugin/internal/source/pluginSourceStateHolds.d.ts +34 -0
- package/lib/plugin/internal/source/pluginSourceStateHolds.js +45 -0
- package/lib/plugin/internal/source/pluginSourceStateHolds.js.map +1 -0
- package/lib/plugin/internal/source/processPluginBuildEnvironment.d.ts +33 -0
- package/lib/plugin/internal/source/processPluginBuildEnvironment.js +40 -0
- package/lib/plugin/internal/source/processPluginBuildEnvironment.js.map +1 -0
- package/lib/plugin/internal/source/pruneCacheFileRoot.d.ts +34 -0
- package/lib/plugin/internal/source/pruneCacheFileRoot.js +120 -0
- package/lib/plugin/internal/source/pruneCacheFileRoot.js.map +1 -0
- package/lib/plugin/internal/source/pruneGoBuildCacheRoot.d.ts +28 -0
- package/lib/plugin/internal/source/pruneGoBuildCacheRoot.js +185 -0
- package/lib/plugin/internal/source/pruneGoBuildCacheRoot.js.map +1 -0
- package/lib/plugin/internal/source/prunePluginCacheRoot.d.ts +46 -0
- package/lib/plugin/internal/source/prunePluginCacheRoot.js +446 -0
- package/lib/plugin/internal/source/prunePluginCacheRoot.js.map +1 -0
- package/lib/plugin/internal/source/prunesPluginSourceDirectory.d.ts +21 -0
- package/lib/plugin/internal/source/prunesPluginSourceDirectory.js +28 -0
- package/lib/plugin/internal/source/prunesPluginSourceDirectory.js.map +1 -0
- package/lib/plugin/internal/source/reclaimPluginBuildLock.d.ts +23 -0
- package/lib/plugin/internal/source/reclaimPluginBuildLock.js +48 -0
- package/lib/plugin/internal/source/reclaimPluginBuildLock.js.map +1 -0
- package/lib/plugin/internal/source/recordCacheFileUse.d.ts +22 -0
- package/lib/plugin/internal/source/recordCacheFileUse.js +43 -0
- package/lib/plugin/internal/source/recordCacheFileUse.js.map +1 -0
- package/lib/plugin/internal/source/releasePluginBuildLock.d.ts +33 -0
- package/lib/plugin/internal/source/releasePluginBuildLock.js +100 -0
- package/lib/plugin/internal/source/releasePluginBuildLock.js.map +1 -0
- package/lib/plugin/internal/source/resolveCleanTargets.d.ts +26 -0
- package/lib/plugin/internal/source/resolveCleanTargets.js +73 -0
- package/lib/plugin/internal/source/resolveCleanTargets.js.map +1 -0
- package/lib/plugin/internal/source/resolveGoCompiler.d.ts +29 -0
- package/lib/plugin/internal/source/resolveGoCompiler.js +62 -0
- package/lib/plugin/internal/source/resolveGoCompiler.js.map +1 -0
- package/lib/plugin/internal/source/resolvePluginCacheRoot.d.ts +21 -0
- package/lib/plugin/internal/source/resolvePluginCacheRoot.js +31 -0
- package/lib/plugin/internal/source/resolvePluginCacheRoot.js.map +1 -0
- package/lib/plugin/internal/source/resolvePluginGoModule.d.ts +34 -0
- package/lib/plugin/internal/source/resolvePluginGoModule.js +65 -0
- package/lib/plugin/internal/source/resolvePluginGoModule.js.map +1 -0
- package/lib/plugin/internal/source/resolveSourceBuildCachePaths.d.ts +21 -0
- package/lib/plugin/internal/source/resolveSourceBuildCachePaths.js +236 -0
- package/lib/plugin/internal/source/resolveSourceBuildCachePaths.js.map +1 -0
- package/lib/plugin/internal/source/selectPluginModuleReplaceDirectories.d.ts +29 -0
- package/lib/plugin/internal/source/selectPluginModuleReplaceDirectories.js +68 -0
- package/lib/plugin/internal/source/selectPluginModuleReplaceDirectories.js.map +1 -0
- package/lib/plugin/internal/source/spawnGoTool.d.ts +22 -0
- package/lib/plugin/internal/source/spawnGoTool.js +164 -0
- package/lib/plugin/internal/source/spawnGoTool.js.map +1 -0
- package/lib/plugin/internal/source/touchPluginCacheEntryInUse.d.ts +27 -0
- package/lib/plugin/internal/source/touchPluginCacheEntryInUse.js +48 -0
- package/lib/plugin/internal/source/touchPluginCacheEntryInUse.js.map +1 -0
- package/lib/plugin/internal/source/waitForPluginBinary.d.ts +36 -0
- package/lib/plugin/internal/source/waitForPluginBinary.js +94 -0
- package/lib/plugin/internal/source/waitForPluginBinary.js.map +1 -0
- package/lib/plugin/internal/source/windowsGoCommandArgs.d.ts +17 -0
- package/lib/plugin/internal/source/windowsGoCommandArgs.js +23 -0
- package/lib/plugin/internal/source/windowsGoCommandArgs.js.map +1 -0
- package/lib/plugin/internal/source/withGoBuildCacheLease.d.ts +37 -0
- package/lib/plugin/internal/source/withGoBuildCacheLease.js +87 -0
- package/lib/plugin/internal/source/withGoBuildCacheLease.js.map +1 -0
- package/lib/plugin/internal/writeCapabilityResolution.d.ts +80 -0
- package/lib/plugin/internal/writeCapabilityResolution.js +196 -0
- package/lib/plugin/internal/writeCapabilityResolution.js.map +1 -0
- package/lib/plugin/resolveCapabilityPlugins.d.ts +53 -32
- package/lib/plugin/resolveCapabilityPlugins.js +209 -38
- package/lib/plugin/resolveCapabilityPlugins.js.map +1 -1
- package/lib/register.js +20 -5
- package/lib/register.js.map +1 -1
- package/lib/structures/ITtscCompilerContext.d.ts +29 -11
- package/lib/structures/ITtscCompilerDiagnostic.d.ts +24 -7
- package/lib/structures/ITtscCompilerResult.d.ts +75 -25
- package/lib/structures/ITtscCompilerTransformation.d.ts +287 -64
- package/lib/structures/ITtscPlugin.d.ts +24 -8
- package/lib/structures/ITtscPluginCapabilities.d.ts +55 -5
- package/lib/structures/ITtscPluginContributor.d.ts +19 -8
- package/lib/structures/ITtscPluginFactoryContext.d.ts +12 -3
- package/lib/structures/ITtscProjectPluginConfig.d.ts +35 -10
- package/lib/structures/TtscPluginStage.d.ts +9 -0
- package/lib/structures/internal/ITtscLoadedNativePlugin.d.ts +19 -5
- package/lib/structures/internal/ITtscParsedProjectConfig.d.ts +29 -3
- package/lib/structures/internal/ITtscProjectIdentity.d.ts +21 -6
- package/lib/structures/internal/ITtscProjectInputSnapshot.d.ts +23 -8
- package/lib/structures/internal/ITtscProjectLocatorOptions.d.ts +18 -4
- package/lib/structures/internal/TtscBuildOptions.d.ts +33 -14
- package/lib/structures/internal/TtscBuildResult.d.ts +63 -4
- package/lib/structures/internal/TtscCommonOptions.d.ts +47 -14
- package/lib/structures/internal/TtscSingleFileEmitOptions.d.ts +46 -5
- package/package.json +26 -12
- package/shim/ast/enums_gen.go +4 -2
- package/shim/ast/go.mod +5 -5
- package/shim/ast/go.sum +10 -10
- package/shim/ast/lint.go +1088 -20
- package/shim/ast/parent.go +38 -22
- package/shim/ast/safe_text.go +48 -26
- package/shim/ast/shim.go +1307 -20
- package/shim/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
- package/shim/ast/test/node_text_joins_multi_hop_qualified_name_test.go +24 -9
- package/shim/ast/test/node_text_joins_one_hop_qualified_name_test.go +9 -5
- package/shim/ast/test/node_text_returns_empty_for_nil_test.go +13 -5
- package/shim/ast/test/node_text_returns_identifier_text_test.go +12 -5
- package/shim/ast/test/node_text_skips_empty_qualified_left_test.go +35 -5
- package/shim/astnav/go.mod +5 -5
- package/shim/astnav/go.sum +12 -10
- package/shim/astnav/shim.go +9 -0
- package/shim/bundled/go.mod +7 -1
- package/shim/bundled/go.sum +12 -0
- package/shim/checker/enums_gen.go +4 -2
- package/shim/checker/extra-shim.json +6 -0
- package/shim/checker/go.mod +5 -5
- package/shim/checker/go.sum +10 -10
- package/shim/checker/node_builder_fields_gen.go +19 -0
- package/shim/checker/shim.go +827 -114
- package/shim/compiler/emit_sourcemap.go +68 -29
- package/shim/compiler/emitassemble.go +36 -2
- package/shim/compiler/emithook.go +13 -3
- package/shim/compiler/go.mod +5 -5
- package/shim/compiler/go.sum +10 -10
- package/shim/compiler/incremental.go +56 -20
- package/shim/compiler/resolution.go +92 -9
- package/shim/core/enums_gen.go +2 -2
- package/shim/core/go.mod +6 -1
- package/shim/core/go.sum +10 -0
- package/shim/core/modulekind.go +9 -0
- package/shim/core/shim.go +157 -6
- package/shim/diagnosticwriter/go.mod +10 -1
- package/shim/diagnosticwriter/go.sum +20 -0
- package/shim/diagnosticwriter/lint.go +188 -10
- package/shim/diagnosticwriter/shim.go +14 -0
- package/shim/lsp/go.mod +5 -5
- package/shim/lsp/go.sum +10 -10
- package/shim/lsp/shim.go +78 -2
- package/shim/parser/go.mod +10 -1
- package/shim/parser/go.sum +22 -0
- package/shim/printer/emithost.go +46 -1
- package/shim/printer/go.mod +5 -5
- package/shim/printer/go.sum +10 -10
- package/shim/printer/shim.go +114 -7
- package/shim/printer/sourcemap.go +55 -0
- package/shim/scanner/go.mod +10 -1
- package/shim/scanner/go.sum +20 -0
- package/shim/scanner/regexp.go +19 -4
- package/shim/scanner/shim.go +3 -0
- package/shim/stringutil/extra-shim.json +1 -0
- package/shim/stringutil/go.mod +5 -0
- package/shim/stringutil/go.sum +2 -0
- package/shim/stringutil/shim.go +119 -0
- package/shim/transformers/go.mod +5 -5
- package/shim/transformers/go.sum +12 -10
- package/shim/transformers/shim.go +12 -3
- package/shim/tsoptions/command_line_raw.go +44 -0
- package/shim/tsoptions/go.mod +10 -1
- package/shim/tsoptions/go.sum +22 -0
- package/shim/tsoptions/shim.go +1 -1
- package/shim/tspath/go.mod +1 -1
- package/shim/tspath/go.sum +6 -0
- package/shim/vfs/cachedvfs/go.mod +3 -1
- package/shim/vfs/cachedvfs/go.sum +12 -0
- package/shim/vfs/decode.go +26 -0
- package/shim/vfs/decode_test.go +42 -0
- package/shim/vfs/go.mod +7 -1
- package/shim/vfs/go.sum +12 -0
- package/shim/vfs/osvfs/go.mod +7 -1
- package/shim/vfs/osvfs/go.sum +12 -0
- package/src/TtscCompiler.ts +223 -234
- package/src/TtscService.ts +87 -31
- package/src/TtscServiceRequestOptions.ts +21 -0
- package/src/compiler/internal/CapturedProcessOutput.ts +69 -0
- package/src/compiler/internal/CompilerArgumentsInspection.ts +184 -0
- package/src/compiler/internal/EmitOwnershipIndex.ts +254 -0
- package/src/compiler/internal/PrivateCompilerOutput.ts +330 -0
- package/src/compiler/internal/ResidentCheckProcess.ts +445 -0
- package/src/compiler/internal/ResidentCheckProcessOptions.ts +32 -0
- package/src/compiler/internal/ResidentCheckRequest.ts +39 -0
- package/src/compiler/internal/ResidentCheckResult.ts +24 -0
- package/src/compiler/internal/ResidentCheckTelemetry.ts +36 -0
- package/src/compiler/internal/ResidentReplyKind.ts +18 -0
- package/src/compiler/internal/ResidentTransformProcess.ts +299 -0
- package/src/compiler/internal/ResidentTransformProcessOptions.ts +30 -0
- package/src/compiler/internal/ResidentTransformReply.ts +79 -0
- package/src/compiler/internal/ResidentTransformRequestOptions.ts +16 -0
- package/src/compiler/internal/ResidentTransformRequests.ts +198 -0
- package/src/compiler/internal/StartedResidentTransform.ts +29 -0
- package/src/compiler/internal/TransformProjectWorkerReply.ts +37 -0
- package/src/compiler/internal/TransformProjectWorkerRequest.ts +42 -0
- package/src/compiler/internal/build/BuildExecution.ts +1261 -0
- package/src/compiler/internal/build/BuildTiming.ts +145 -0
- package/src/compiler/internal/build/CompilerDiagnostics.ts +307 -0
- package/src/compiler/internal/build/NativePluginArguments.ts +302 -0
- package/src/compiler/internal/build/PassthroughFlags.ts +229 -0
- package/src/compiler/internal/build/PluginFailureDiagnostics.ts +70 -0
- package/src/compiler/internal/build/ResidentCheckEntryPlan.ts +42 -0
- package/src/compiler/internal/build/ResidentCheckWatchChange.ts +33 -0
- package/src/compiler/internal/build/ResidentCheckWatchSession.ts +501 -0
- package/src/compiler/internal/build/RunBuildOptions.ts +145 -0
- package/src/compiler/internal/build/TsgoArguments.ts +349 -0
- package/src/compiler/internal/build/appendBuildOutput.ts +218 -0
- package/src/compiler/internal/build/bufferResidentCheckEntryRequests.ts +52 -0
- package/src/compiler/internal/build/createProcessDiagnostic.ts +32 -0
- package/src/compiler/internal/build/isAbsoluteLocalProjectInputPath.ts +55 -0
- package/src/compiler/internal/build/mergeProjectInputSnapshots.ts +147 -0
- package/src/compiler/internal/build/normalizeBuildOutput.ts +89 -0
- package/src/compiler/internal/build/parseProjectInputSnapshot.ts +91 -0
- package/src/compiler/internal/build/planResidentCheckEntries.ts +55 -0
- package/src/compiler/internal/build/privateRuntimeRootDir.ts +33 -0
- package/src/compiler/internal/build/residentCheckRequest.ts +41 -0
- package/src/compiler/internal/build/runBuild.ts +61 -0
- package/src/compiler/internal/build/runExternalEmitProvenance.ts +566 -0
- package/src/compiler/internal/build/takeResidentCheckEntryRequest.ts +31 -0
- package/src/compiler/internal/buildNativeCompiler.ts +19 -2
- package/src/compiler/internal/captureProcessOutput.ts +37 -39
- package/src/compiler/internal/compileProjectInMemory.ts +139 -92
- package/src/compiler/internal/ensureExecutable.ts +32 -0
- package/src/compiler/internal/findNearestGoMod.ts +43 -0
- package/src/compiler/internal/isOutsideRelativePath.ts +26 -0
- package/src/compiler/internal/outputText.ts +21 -0
- package/src/compiler/internal/packageRootDir.ts +43 -0
- package/src/compiler/internal/parseNativeTransformOutput.ts +722 -0
- package/src/compiler/internal/project/CompilerProjectSelection.ts +204 -0
- package/src/compiler/internal/project/ConfigJsonText.ts +55 -0
- package/src/compiler/internal/project/compilerUsesCaseSensitiveFileNames.ts +124 -0
- package/src/compiler/internal/project/createNativeProjectContextArgs.ts +14 -19
- package/src/compiler/internal/project/createNativeProjectContextJson.ts +28 -0
- package/src/compiler/internal/project/parseJsonc.ts +318 -0
- package/src/compiler/internal/project/readJsonFile.ts +34 -0
- package/src/compiler/internal/project/readJsoncFile.ts +46 -0
- package/src/compiler/internal/project/readProjectConfig.ts +137 -200
- package/src/compiler/internal/project/resolveOwningProjectConfig.ts +278 -0
- package/src/compiler/internal/project/resolveProjectConfig.ts +18 -127
- package/src/compiler/internal/project/resolveProjectIdentity.ts +153 -0
- package/src/compiler/internal/project/resolveTsconfigExtends.ts +175 -0
- package/src/compiler/internal/project/selectReferencedProject.ts +54 -0
- package/src/compiler/internal/project/tsconfigExtendsFileCandidates.ts +54 -0
- package/src/compiler/internal/readEffectiveCompilerOptions.ts +126 -0
- package/src/compiler/internal/resolveBinary.ts +25 -9
- package/src/compiler/internal/resolveTsgo.ts +31 -11
- package/src/compiler/internal/runNativeCheckWithObservations.ts +211 -0
- package/src/compiler/internal/runSingleFileEmit.ts +92 -27
- package/src/compiler/internal/sharedHost/SEMANTIC_CONFIG_PATH_ENV.ts +2 -0
- package/src/compiler/internal/sharedHost/SidecarEnvironment.ts +151 -0
- package/src/compiler/internal/sharedHost/TSGO_ARGS_CWD_ENV.ts +7 -0
- package/src/compiler/internal/sharedHost/TSGO_ARGS_ENV.ts +7 -0
- package/src/compiler/internal/sharedHost/assertSharedHostCompatibility.ts +48 -0
- package/src/compiler/internal/sharedHost/clearInheritedSemanticConfigPath.ts +27 -0
- package/src/compiler/internal/sharedHost/clearInheritedTsgoArgs.ts +41 -0
- package/src/compiler/internal/sharedHost/inheritedSidecarEnv.ts +45 -0
- package/src/compiler/internal/sharedHost/isLinkedTransform.ts +19 -0
- package/src/compiler/internal/sharedHost/linkedTransformPlugins.ts +25 -0
- package/src/compiler/internal/sharedHost/publishLinkedTransformPlugins.ts +42 -0
- package/src/compiler/internal/sharedHost/resolvePluginConfigDir.ts +33 -0
- package/src/compiler/internal/sharedHost/selectSharedHostPlugin.ts +35 -0
- package/src/compiler/internal/spawnNative.ts +16 -39
- package/src/compiler/internal/startResidentTransform.ts +66 -53
- package/src/compiler/internal/transformProjectInMemory.ts +347 -635
- package/src/compiler/internal/transformProjectInWorker.ts +170 -0
- package/src/compiler/internal/transformProjectWorker.ts +43 -0
- package/src/flags/AnySubcommand.ts +19 -0
- package/src/flags/COMPILER_ENUM_WHITESPACE.ts +35 -0
- package/src/flags/COMPILER_OPTIONS.ts +512 -0
- package/src/flags/COMPILER_OPTION_ASCII_FOLDS.ts +13 -0
- package/src/flags/COMPILER_OPTION_KINDS.ts +14 -0
- package/src/flags/CompilerOptionSpec.ts +30 -0
- package/src/flags/FLAG_BY_TOKEN.ts +40 -0
- package/src/flags/{schema.ts → FLAG_SCHEMA.ts} +43 -318
- package/src/flags/FlagKind.ts +22 -0
- package/src/flags/FlagLayer.ts +24 -0
- package/src/flags/FlagSpec.ts +118 -0
- package/src/flags/ParseOptions.ts +103 -0
- package/src/flags/ParseResult.ts +44 -0
- package/src/flags/TtscSubcommand.ts +22 -0
- package/src/flags/TtsxSubcommand.ts +13 -0
- package/src/flags/ValueValidator.ts +14 -0
- package/src/flags/buildGoAllowList.ts +43 -0
- package/src/flags/flagsForSubcommand.ts +22 -0
- package/src/flags/getBoolean.ts +27 -0
- package/src/flags/getNumber.ts +24 -0
- package/src/flags/getString.ts +24 -0
- package/src/flags/getStringList.ts +24 -0
- package/src/flags/normalizeCompilerEnumValue.ts +41 -0
- package/src/flags/normalizeFlagToken.ts +38 -0
- package/src/flags/parseFlags.ts +371 -0
- package/src/flags/readCompilerOptionOccurrence.ts +107 -0
- package/src/flags/readCompilerOptionValues.ts +68 -0
- package/src/flags/resolveFlagSpec.ts +29 -0
- package/src/index.ts +9 -3
- package/src/internal/CanonicalTempDirectoryOperations.ts +73 -0
- package/src/internal/CompilerContextSnapshot.ts +139 -0
- package/src/internal/CompilerResultAdapter.ts +320 -0
- package/src/internal/E2ETrace.ts +674 -0
- package/src/internal/IJavaScriptRuntimeCapabilities.ts +50 -0
- package/src/internal/OwnedNativeProcess.ts +417 -0
- package/src/internal/OwnedSynchronousProcess.ts +220 -0
- package/src/internal/RetireLockDirectoryOperations.ts +81 -0
- package/src/internal/SafeCacheCleanupTarget.ts +41 -0
- package/src/internal/SourceNativeRetirement.ts +1109 -0
- package/src/internal/SpawnSyncOutputFiles.ts +29 -0
- package/src/internal/cacheEntryExists.ts +24 -0
- package/src/internal/createCanonicalTempDirectory.ts +35 -18
- package/src/internal/isContendedCandidateRename.ts +35 -0
- package/src/internal/isSpawnSyncFdExhaustion.ts +19 -0
- package/src/internal/javascriptRuntimeCapabilities.ts +166 -0
- package/src/internal/nativeBinary.ts +11 -0
- package/src/internal/parseWindowsDirectoryCaseSensitivity.ts +50 -0
- package/src/internal/pathIdentity/FilesystemPathIdentity.ts +44 -0
- package/src/internal/pathIdentity/FilesystemPathIdentityContext.ts +182 -0
- package/src/internal/pathIdentity/FilesystemPathIdentityOperations.ts +106 -0
- package/src/internal/pathIdentity/ProjectInputPathIdentity.ts +21 -0
- package/src/internal/pathIdentity/ProjectInputPathIdentityContext.ts +21 -0
- package/src/internal/pathIdentity/ProjectInputPathIdentityOperations.ts +22 -0
- package/src/internal/pathIdentity/createFilesystemPathIdentityContext.ts +437 -0
- package/src/internal/pathIdentity/createProjectInputPathIdentityContext.ts +34 -0
- package/src/internal/pathIdentity/isFilesystemPathIdentityWithin.ts +32 -0
- package/src/internal/pathIdentity/isProjectInputPathIdentityWithin.ts +22 -0
- package/src/internal/pathIdentity/resolveFilesystemPath.ts +43 -0
- package/src/internal/pathIdentity/resolvePhysicalPath.ts +31 -0
- package/src/internal/pathIdentity/resolveProjectInputPath.ts +18 -0
- package/src/internal/pluginSource.ts +26 -0
- package/src/internal/projectInputPathIdentity.ts +26 -387
- package/src/internal/resolveNodeBinary.ts +13 -165
- package/src/internal/resolveSafeCacheCleanupTargets.ts +51 -19
- package/src/internal/restoreCompilerError.ts +175 -0
- package/src/internal/retireLockDirectory.ts +166 -0
- package/src/internal/runHoldingLock.ts +55 -0
- package/src/internal/runtimeExecutableIdentity.ts +212 -0
- package/src/internal/serializeCompilerError.ts +145 -0
- package/src/internal/spawnSyncResilient.ts +36 -182
- package/src/internal/spawnSyncWithLowDescriptors.ts +227 -0
- package/src/internal/tsconfig.ts +16 -0
- package/src/launcher/internal/PendingResidentCheckWatchChanges.ts +94 -0
- package/src/launcher/internal/TtscBuildMode.ts +14 -0
- package/src/launcher/internal/TtsxEntryOptions.ts +92 -0
- package/src/launcher/internal/assertNoSolutionBuild.ts +17 -10
- package/src/launcher/internal/assertTtsxNoWatch.ts +49 -0
- package/src/launcher/internal/buildSingleRootProject.ts +303 -0
- package/src/launcher/internal/getCompilerVersionText.ts +20 -5
- package/src/launcher/internal/inlineServedSourceMap.ts +294 -0
- package/src/launcher/internal/linkVirtualEntry.ts +88 -0
- package/src/launcher/internal/{commonJsExportMetadata.ts → parseCommonJsExports.ts} +12 -2
- package/src/launcher/internal/parseTtscBuildArgs.ts +103 -0
- package/src/launcher/internal/parseTtsxCLI.ts +183 -0
- package/src/launcher/internal/prepareExecution.ts +474 -362
- package/src/launcher/internal/prepareTtscBuildMode.ts +64 -0
- package/src/launcher/internal/resolveCacheDir.ts +12 -3
- package/src/launcher/internal/resolveSingleFileOutput.ts +145 -0
- package/src/launcher/internal/resolveTtscserverBinary.ts +20 -5
- package/src/launcher/internal/runTtsc.ts +394 -326
- package/src/launcher/internal/runTtsx.ts +349 -151
- package/src/launcher/internal/runtime/CommonJsRuntimeSource.ts +365 -0
- package/src/launcher/internal/runtime/DependencyBuildAdmission.ts +159 -0
- package/src/launcher/internal/runtime/DependencyBuildGeneration.ts +236 -0
- package/src/launcher/internal/runtime/DependencyBuildLockFence.ts +22 -0
- package/src/launcher/internal/runtime/DependencyBuildLockLease.ts +22 -0
- package/src/launcher/internal/runtime/DependencyBuildLockObservation.ts +49 -0
- package/src/launcher/internal/runtime/DependencyBuildLockProtocol.ts +137 -0
- package/src/launcher/internal/runtime/OwnedProjectSource.ts +140 -0
- package/src/launcher/internal/runtime/OwningModuleOptions.ts +22 -0
- package/src/launcher/internal/runtime/PluginDescriptorInputObservation.ts +112 -0
- package/src/launcher/internal/runtime/ProcessOwnedDirectory.ts +325 -0
- package/src/launcher/internal/runtime/ResolveResult.ts +26 -0
- package/src/launcher/internal/runtime/RuntimeEmitProvenance.ts +58 -0
- package/src/launcher/internal/runtime/RuntimeEntryPreparer.ts +23 -0
- package/src/launcher/internal/runtime/RuntimeFilesystem.ts +64 -0
- package/src/launcher/internal/runtime/RuntimeHookOptions.ts +23 -0
- package/src/launcher/internal/runtime/RuntimeIsolatedEmit.ts +88 -0
- package/src/launcher/internal/runtime/RuntimeLoaderCapabilities.ts +256 -0
- package/src/launcher/internal/runtime/RuntimeManifest.ts +77 -0
- package/src/launcher/internal/runtime/RuntimeManifestRegistry.ts +309 -0
- package/src/launcher/internal/runtime/RuntimeModuleFormat.ts +275 -0
- package/src/launcher/internal/runtime/RuntimeProjectOwnership.ts +139 -0
- package/src/launcher/internal/runtime/TTSX_MINIMUM_NODE_VERSION.ts +11 -0
- package/src/launcher/internal/runtime/acquireDependencyBuildLock.ts +97 -0
- package/src/launcher/internal/runtime/checkNodeRuntimeSupport.ts +94 -0
- package/src/launcher/internal/runtime/claimRuntimeProjectDirectory.ts +54 -0
- package/src/launcher/internal/runtime/commonJsExportNames.ts +57 -0
- package/src/launcher/internal/runtime/commonJsImportFacade.ts +62 -0
- package/src/launcher/internal/runtime/dependencyCacheKey.ts +82 -0
- package/src/launcher/internal/runtime/dependencyCacheRoot.ts +112 -0
- package/src/launcher/internal/runtime/inspectDependencyBuildLock.ts +162 -0
- package/src/launcher/internal/runtime/installRuntimeHooks.ts +2442 -0
- package/src/launcher/internal/runtime/interopProbe.ts +8 -0
- package/src/launcher/internal/runtime/isLocalProcessGone.ts +67 -0
- package/src/launcher/internal/runtime/observeMappedDescriptorResolution.ts +74 -0
- package/src/launcher/internal/runtime/projectModuleOptions.ts +28 -0
- package/src/launcher/internal/runtime/readDependencyCache.ts +89 -0
- package/src/launcher/internal/runtime/realPath.ts +30 -0
- package/src/launcher/internal/runtime/reclaimDependencyBuildLock.ts +27 -0
- package/src/launcher/internal/runtime/releaseDependencyBuildLock.ts +27 -0
- package/src/launcher/internal/runtime/resolveRuntimeCleanTargets.ts +93 -0
- package/src/launcher/internal/runtime/restoreStrippedNodeBuiltinScheme.ts +32 -0
- package/src/launcher/internal/runtime/runtimeRunKey.ts +31 -0
- package/src/launcher/internal/runtime/selectRuntimePluginPolicy.ts +28 -0
- package/src/launcher/internal/runtime/withRuntimeDirectoryLock.ts +92 -0
- package/src/launcher/internal/runtimeCompilerArgs.ts +91 -62
- package/src/launcher/internal/runtimeEmitProfile.ts +70 -0
- package/src/launcher/internal/runtimeHookPreload.ts +3 -3
- package/src/launcher/internal/runtimeOwnerPreload.ts +43 -0
- package/src/launcher/internal/singleRootProjectConfig.ts +38 -0
- package/src/launcher/internal/ttscserver/ILSPPluginSelectionInputs.ts +65 -0
- package/src/launcher/internal/ttscserver/LSPProjectInputDigest.ts +331 -0
- package/src/launcher/internal/ttscserver/captureLSPPluginSelectionInputs.ts +107 -0
- package/src/launcher/internal/ttscserver/fingerprintInitialLSPProjectInputSnapshot.ts +41 -0
- package/src/launcher/internal/ttscserver/initialLSPProjectInputSnapshotIsCurrent.ts +36 -0
- package/src/launcher/internal/ttscserver/materializeLSPPluginManifest.ts +60 -0
- package/src/launcher/internal/ttscserver/needsStdio.ts +32 -0
- package/src/launcher/internal/ttscserver/runTtscserver.ts +592 -0
- package/src/launcher/internal/watch/CompilerDirectoryWatchEventPlan.ts +31 -0
- package/src/launcher/internal/watch/DirectoryWatcher.ts +45 -0
- package/src/launcher/internal/watch/FseventsStreams.ts +303 -0
- package/src/launcher/internal/watch/ProjectInputWatchRules.ts +179 -0
- package/src/launcher/internal/watch/WatchInputChange.ts +31 -0
- package/src/launcher/internal/watch/WatchPaths.ts +156 -0
- package/src/launcher/internal/{watchTopology.ts → watch/WatchTopology.ts} +867 -962
- package/src/launcher/internal/watch/literalGlobRoot.ts +40 -0
- package/src/launcher/internal/watch/planCompilerDirectoryWatchEvent.ts +83 -0
- package/src/launcher/internal/watch/projectInputActiveWatchDirectories.ts +47 -0
- package/src/launcher/internal/watch/projectInputAvailableWatchDirectory.ts +56 -0
- package/src/launcher/internal/watch/projectInputEventShouldNotify.ts +23 -0
- package/src/launcher/internal/watch/projectInputMembershipInvalidatesProgram.ts +63 -0
- package/src/launcher/internal/watch/projectInputReloadEventShouldNotify.ts +127 -0
- package/src/launcher/internal/watch/projectInputReplacementStrandsWatchers.ts +57 -0
- package/src/launcher/internal/watch/projectInputTopologyMayAffect.ts +73 -0
- package/src/launcher/internal/watch/projectInputWatchDirectories.ts +33 -0
- package/src/launcher/internal/watch/reloadInputsForFailedTopologyRefresh.ts +49 -0
- package/src/launcher/internal/watch/syncWatchers.ts +64 -0
- package/src/launcher/internal/watch/watchDirectory.ts +53 -0
- package/src/launcher/internal/watch/watchDirectoryThroughFsWatch.ts +47 -0
- package/src/launcher/ttscserver.ts +1 -1
- package/src/launcher/ttsx.ts +2 -3
- package/src/plugin/CapabilityPluginResolver.ts +549 -0
- package/src/plugin/ITtscCapabilityPlugin.ts +93 -0
- package/src/plugin/internal/CapabilityPluginResult.ts +99 -0
- package/src/plugin/internal/CapabilityResolutionFormat.ts +248 -0
- package/src/plugin/internal/ITtscCapabilityPluginSource.ts +37 -0
- package/src/plugin/internal/ITtscCapabilityResolutionEntry.ts +57 -0
- package/src/plugin/internal/ITtscCapabilityResolutionPlugin.ts +22 -0
- package/src/plugin/internal/capabilityPluginWorker.ts +216 -0
- package/src/plugin/internal/decodeCapabilityCommandReply.ts +27 -0
- package/src/plugin/internal/load/COMMONJS_PLUGIN_DESCRIPTOR_SHIM_SOURCE.ts +182 -0
- package/src/plugin/internal/load/PLUGIN_DESCRIPTOR_SHIM_SOURCE.ts +59 -0
- package/src/plugin/internal/load/PluginDescriptorAdmission.ts +75 -0
- package/src/plugin/internal/load/PluginDescriptorEvaluationCache.ts +432 -0
- package/src/plugin/internal/load/PluginPackageResolution.ts +711 -0
- package/src/plugin/internal/load/ProjectPluginEntries.ts +232 -0
- package/src/plugin/internal/load/RESOLUTION_INPUT_RECORDER_PATH.ts +34 -0
- package/src/plugin/internal/load/collectProjectHostInputs.ts +88 -0
- package/src/plugin/internal/load/composePluginSources.ts +121 -0
- package/src/plugin/internal/load/declaresHostInputReads.ts +52 -0
- package/src/plugin/internal/load/hasProjectPluginEntries.ts +33 -0
- package/src/plugin/internal/load/hashHostInputPaths.ts +44 -0
- package/src/plugin/internal/load/isRelativePluginSpecifier.ts +31 -0
- package/src/plugin/internal/load/loadProjectPlugins.ts +2334 -0
- package/src/plugin/internal/load/moduleResolutionBaseSelects.ts +59 -0
- package/src/plugin/internal/load/observeImportSearchRoots.ts +42 -0
- package/src/plugin/internal/load/pluginLabel.ts +28 -0
- package/src/plugin/internal/load/realpathHostInput.ts +22 -0
- package/src/plugin/internal/load/realpathHostInputPaths.ts +27 -0
- package/src/plugin/internal/load/rejectJsTransformFunctions.ts +23 -0
- package/src/plugin/internal/load/requirePluginSource.ts +34 -0
- package/src/plugin/internal/load/resolveNativeSource.ts +42 -0
- package/src/plugin/internal/load/validatePluginContributors.ts +102 -0
- package/src/plugin/internal/load/validatePluginSource.ts +19 -0
- package/src/plugin/internal/load/visitImportMappedCandidates.ts +63 -0
- package/src/plugin/internal/pluginDescriptorFailureReason.ts +35 -0
- package/src/plugin/internal/pluginDescriptorProcessFailure.ts +48 -0
- package/src/plugin/internal/readCapabilityResolution.ts +193 -0
- package/src/plugin/internal/receiveCapabilityFailure.ts +27 -0
- package/src/plugin/internal/source/CachePrunePolicy.ts +47 -0
- package/src/plugin/internal/source/GoBuildCacheCoordination.ts +588 -0
- package/src/plugin/internal/source/GoEnvironmentReading.ts +109 -0
- package/src/plugin/internal/source/GoSourceInputs.ts +182 -0
- package/src/plugin/internal/source/GoToolResolution.ts +312 -0
- package/src/plugin/internal/source/IGoBuildCachePruneOptions.ts +34 -0
- package/src/plugin/internal/source/IPluginCachePruneOptions.ts +38 -0
- package/src/plugin/internal/source/IPluginModuleReplaceDirectory.ts +30 -0
- package/src/plugin/internal/source/ITtscBuildContributor.ts +19 -0
- package/src/plugin/internal/source/ITtscSourceBuildCachePaths.ts +28 -0
- package/src/plugin/internal/source/NativeSourcePackages.ts +428 -0
- package/src/plugin/internal/source/PluginBinaryUse.ts +159 -0
- package/src/plugin/internal/source/PluginBinaryWaitResult.ts +34 -0
- package/src/plugin/internal/source/PluginBuildEnvironmentReadings.ts +273 -0
- package/src/plugin/internal/source/PluginBuildEnvironmentWitness.ts +243 -0
- package/src/plugin/internal/source/PluginBuildLockFence.ts +26 -0
- package/src/plugin/internal/source/PluginBuildLockLease.ts +31 -0
- package/src/plugin/internal/source/PluginBuildLockObservation.ts +48 -0
- package/src/plugin/internal/source/PluginBuildLockOwner.ts +225 -0
- package/src/plugin/internal/source/PluginBuildLockProtocol.ts +342 -0
- package/src/plugin/internal/source/SourceBuildCacheLayout.ts +303 -0
- package/src/plugin/internal/source/SourceBuildFilesystemOperations.ts +32 -0
- package/src/plugin/internal/source/SourcePluginAdmission.ts +127 -0
- package/src/plugin/internal/source/SourcePluginWorkspace.ts +564 -0
- package/src/plugin/internal/source/acquirePluginBuildLock.ts +222 -0
- package/src/plugin/internal/source/autoQuoteGoModToken.ts +113 -0
- package/src/plugin/internal/source/buildSourcePlugin.ts +1225 -0
- package/src/plugin/internal/source/collectPluginSourceDirectories.ts +70 -0
- package/src/plugin/internal/source/collectPluginSourceFiles.ts +90 -0
- package/src/plugin/internal/source/computeCacheKey.ts +208 -0
- package/src/plugin/internal/source/copiesPluginSourceEntry.ts +52 -0
- package/src/plugin/internal/source/createExternalSourceSnapshotLayout.ts +66 -0
- package/src/plugin/internal/source/ensureExecutableGoToolchain.ts +87 -0
- package/src/plugin/internal/source/formatDuration.ts +32 -0
- package/src/plugin/internal/source/formatGoWorkPath.ts +42 -0
- package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +735 -0
- package/src/plugin/internal/source/inspectPluginBuildLock.ts +330 -0
- package/src/plugin/internal/source/isPathWithin.ts +24 -0
- package/src/plugin/internal/source/legacyGlobalCacheTargets.ts +71 -0
- package/src/plugin/internal/source/pluginBuildEnvironment.ts +59 -0
- package/src/plugin/internal/source/pluginBuildEnvironmentWorker.ts +30 -0
- package/src/plugin/internal/source/pluginBuildVersions.ts +75 -0
- package/src/plugin/internal/source/pluginModuleReplaceDirectories.ts +84 -0
- package/src/plugin/internal/source/pluginSourceCovers.ts +54 -0
- package/src/plugin/internal/source/pluginSourceDigest.ts +55 -0
- package/src/plugin/internal/source/pluginSourceFilesSignature.ts +54 -0
- package/src/plugin/internal/source/pluginSourceState.ts +69 -0
- package/src/plugin/internal/source/pluginSourceStateHolds.ts +45 -0
- package/src/plugin/internal/source/processPluginBuildEnvironment.ts +40 -0
- package/src/plugin/internal/source/pruneCacheFileRoot.ts +134 -0
- package/src/plugin/internal/source/pruneGoBuildCacheRoot.ts +228 -0
- package/src/plugin/internal/source/prunePluginCacheRoot.ts +507 -0
- package/src/plugin/internal/source/prunesPluginSourceDirectory.ts +25 -0
- package/src/plugin/internal/source/reclaimPluginBuildLock.ts +63 -0
- package/src/plugin/internal/source/recordCacheFileUse.ts +35 -0
- package/src/plugin/internal/source/releasePluginBuildLock.ts +125 -0
- package/src/plugin/internal/source/resolveCleanTargets.ts +84 -0
- package/src/plugin/internal/source/resolveGoCompiler.ts +92 -0
- package/src/plugin/internal/source/resolvePluginCacheRoot.ts +32 -0
- package/src/plugin/internal/source/resolvePluginGoModule.ts +69 -0
- package/src/plugin/internal/source/resolveSourceBuildCachePaths.ts +276 -0
- package/src/plugin/internal/source/selectPluginModuleReplaceDirectories.ts +80 -0
- package/src/plugin/internal/source/spawnGoTool.ts +204 -0
- package/src/plugin/internal/source/touchPluginCacheEntryInUse.ts +44 -0
- package/src/plugin/internal/source/waitForPluginBinary.ts +123 -0
- package/src/plugin/internal/source/windowsGoCommandArgs.ts +19 -0
- package/src/plugin/internal/source/withGoBuildCacheLease.ts +101 -0
- package/src/plugin/internal/writeCapabilityResolution.ts +266 -0
- package/src/plugin/resolveCapabilityPlugins.ts +242 -77
- package/src/register.ts +20 -7
- package/src/structures/ITtscCompilerContext.ts +29 -11
- package/src/structures/ITtscCompilerDiagnostic.ts +24 -7
- package/src/structures/ITtscCompilerResult.ts +75 -25
- package/src/structures/ITtscCompilerTransformation.ts +304 -64
- package/src/structures/ITtscPlugin.ts +24 -8
- package/src/structures/ITtscPluginCapabilities.ts +58 -5
- package/src/structures/ITtscPluginContributor.ts +19 -8
- package/src/structures/ITtscPluginFactoryContext.ts +12 -3
- package/src/structures/ITtscProjectPluginConfig.ts +35 -10
- package/src/structures/TtscPluginStage.ts +9 -0
- package/src/structures/internal/ITtscLoadedNativePlugin.ts +27 -5
- package/src/structures/internal/ITtscParsedProjectConfig.ts +37 -3
- package/src/structures/internal/ITtscProjectIdentity.ts +27 -6
- package/src/structures/internal/ITtscProjectInputSnapshot.ts +31 -8
- package/src/structures/internal/ITtscProjectLocatorOptions.ts +21 -4
- package/src/structures/internal/TtscBuildOptions.ts +38 -14
- package/src/structures/internal/TtscBuildResult.ts +74 -4
- package/src/structures/internal/TtscCommonOptions.ts +59 -14
- package/src/structures/internal/TtscSingleFileEmitOptions.ts +55 -5
- package/tools/gen_shims/main.go +124 -11
- package/tools/gen_shims/package_load_admission_rejects_incomplete_results_test.go +61 -0
- package/tools/gen_shims/private_field_support_preserves_upstream_layout_test.go +104 -0
- package/tools/shim_audit/enum_generation_preserves_existing_family_members_test.go +182 -0
- package/tools/shim_audit/enum_generation_refuses_removed_public_members_test.go +93 -0
- package/tools/shim_audit/main.go +166 -31
- package/tools/shim_audit/main_test.go +35 -0
- package/tools/shim_audit/producer_exemptions_require_rationale_test.go +5 -0
- package/tools/shim_audit/producer_surface_includes_exposed_methods_test.go +5 -0
- package/tools/shim_audit/producer_surface_rejects_unproducible_reference_test.go +5 -0
- package/tools/shim_audit/shim_dir_coverage_rejects_unregistered_shims_test.go +71 -0
- package/utility/command.go +48 -0
- package/utility/flags_gen.go +2 -2
- package/utility/host.go +282 -66
- package/utility/preamble_output.go +245 -0
- package/utility/preamble_output_test.go +90 -0
- package/utility/serve.go +61 -18
- package/cmd/ttscgraph/serve_graph_snapshot_version_matches_typescript_client_test.go +0 -32
- package/cmd/ttscgraph/serve_protocol_version_matches_the_typescript_client_test.go +0 -48
- package/cmd/ttscgraph/serve_session_retries_failed_dump_test.go +0 -103
- package/internal/graph/dump_schema_version_matches_the_typescript_client_test.go +0 -48
- package/internal/graph/edge_kinds_names_every_declared_kind_test.go +0 -49
- package/internal/graph/graph_kind_contracts_match_their_producers_test.go +0 -121
- package/internal/lspserver/lsp_launcher_reload_directory_fingerprint_parity_windows_test.go +0 -94
- package/internal/lspserver/lsp_project_diagnostics_resident_unsupported_falls_back_test.go +0 -123
- package/lib/compiler/internal/paths.d.ts +0 -27
- package/lib/compiler/internal/paths.js +0 -70
- package/lib/compiler/internal/paths.js.map +0 -1
- package/lib/compiler/internal/project/readConfigJson.d.ts +0 -30
- package/lib/compiler/internal/project/readConfigJson.js +0 -208
- package/lib/compiler/internal/project/readConfigJson.js.map +0 -1
- package/lib/compiler/internal/residentCheckProcess.d.ts +0 -44
- package/lib/compiler/internal/residentCheckProcess.js +0 -213
- package/lib/compiler/internal/residentCheckProcess.js.map +0 -1
- package/lib/compiler/internal/residentTransformProcess.d.ts +0 -65
- package/lib/compiler/internal/residentTransformProcess.js +0 -330
- package/lib/compiler/internal/residentTransformProcess.js.map +0 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +0 -25
- package/lib/compiler/internal/resolveEmittedJavaScript.js +0 -165
- package/lib/compiler/internal/resolveEmittedJavaScript.js.map +0 -1
- package/lib/compiler/internal/runBuild.d.ts +0 -152
- package/lib/compiler/internal/runBuild.js +0 -1694
- package/lib/compiler/internal/runBuild.js.map +0 -1
- package/lib/compiler/internal/sharedHostHelpers.d.ts +0 -79
- package/lib/compiler/internal/sharedHostHelpers.js +0 -134
- package/lib/compiler/internal/sharedHostHelpers.js.map +0 -1
- package/lib/flags/parser.d.ts +0 -97
- package/lib/flags/parser.js +0 -293
- package/lib/flags/parser.js.map +0 -1
- package/lib/flags/schema.d.ts +0 -191
- package/lib/flags/schema.js.map +0 -1
- package/lib/internal/windowsDirectoryCaseSensitivity.d.ts +0 -10
- package/lib/internal/windowsDirectoryCaseSensitivity.js +0 -34
- package/lib/internal/windowsDirectoryCaseSensitivity.js.map +0 -1
- package/lib/launcher/internal/commonJsExportMetadata.d.ts +0 -7
- package/lib/launcher/internal/commonJsExportMetadata.js.map +0 -1
- package/lib/launcher/internal/registerRuntimeHooks.js +0 -59
- package/lib/launcher/internal/registerRuntimeHooks.js.map +0 -1
- package/lib/launcher/internal/runTtscserver.d.ts +0 -35
- package/lib/launcher/internal/runTtscserver.js +0 -661
- package/lib/launcher/internal/runTtscserver.js.map +0 -1
- package/lib/launcher/internal/runtimeHooks.d.ts +0 -198
- package/lib/launcher/internal/runtimeHooks.js +0 -2579
- package/lib/launcher/internal/runtimeHooks.js.map +0 -1
- package/lib/launcher/internal/servedSourceMap.d.ts +0 -25
- package/lib/launcher/internal/servedSourceMap.js +0 -164
- package/lib/launcher/internal/servedSourceMap.js.map +0 -1
- package/lib/launcher/internal/singleFileOutput.d.ts +0 -16
- package/lib/launcher/internal/singleFileOutput.js +0 -103
- package/lib/launcher/internal/singleFileOutput.js.map +0 -1
- package/lib/launcher/internal/watchTopology.d.ts +0 -329
- package/lib/launcher/internal/watchTopology.js.map +0 -1
- package/lib/plugin/internal/buildSourcePlugin.d.ts +0 -298
- package/lib/plugin/internal/buildSourcePlugin.js +0 -3087
- package/lib/plugin/internal/buildSourcePlugin.js.map +0 -1
- package/lib/plugin/internal/capabilityResolutionCache.d.ts +0 -76
- package/lib/plugin/internal/capabilityResolutionCache.js +0 -224
- package/lib/plugin/internal/capabilityResolutionCache.js.map +0 -1
- package/lib/plugin/internal/descriptorProcessFailure.d.ts +0 -36
- package/lib/plugin/internal/descriptorProcessFailure.js +0 -62
- package/lib/plugin/internal/descriptorProcessFailure.js.map +0 -1
- package/lib/plugin/internal/loadProjectPlugins.d.ts +0 -75
- package/lib/plugin/internal/loadProjectPlugins.js +0 -2405
- package/lib/plugin/internal/loadProjectPlugins.js.map +0 -1
- package/src/compiler/internal/paths.ts +0 -68
- package/src/compiler/internal/project/readConfigJson.ts +0 -209
- package/src/compiler/internal/residentCheckProcess.ts +0 -259
- package/src/compiler/internal/residentTransformProcess.ts +0 -406
- package/src/compiler/internal/resolveEmittedJavaScript.ts +0 -197
- package/src/compiler/internal/runBuild.ts +0 -2345
- package/src/compiler/internal/sharedHostHelpers.ts +0 -154
- package/src/flags/parser.ts +0 -459
- package/src/internal/windowsDirectoryCaseSensitivity.ts +0 -33
- package/src/launcher/internal/registerRuntimeHooks.ts +0 -68
- package/src/launcher/internal/runTtscserver.ts +0 -842
- package/src/launcher/internal/runtimeHooks.ts +0 -3197
- package/src/launcher/internal/servedSourceMap.ts +0 -183
- package/src/launcher/internal/singleFileOutput.ts +0 -133
- package/src/plugin/internal/buildSourcePlugin.ts +0 -3993
- package/src/plugin/internal/capabilityResolutionCache.ts +0 -305
- package/src/plugin/internal/descriptorProcessFailure.ts +0 -69
- package/src/plugin/internal/loadProjectPlugins.ts +0 -3073
- package/tools/shim_audit/shim_dir_coverage_test.go +0 -25
- /package/lib/{launcher/internal/registerRuntimeHooks.d.ts → compiler/internal/transformProjectWorker.d.ts} +0 -0
|
@@ -1,3087 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.buildSourcePlugin = buildSourcePlugin;
|
|
7
|
-
exports.acquirePluginBuildLock = acquirePluginBuildLock;
|
|
8
|
-
exports.releasePluginBuildLock = releasePluginBuildLock;
|
|
9
|
-
exports.reclaimPluginBuildLock = reclaimPluginBuildLock;
|
|
10
|
-
exports.waitForPluginBinary = waitForPluginBinary;
|
|
11
|
-
exports.inspectPluginBuildLock = inspectPluginBuildLock;
|
|
12
|
-
exports.formatDuration = formatDuration;
|
|
13
|
-
exports.formatGoWorkPath = formatGoWorkPath;
|
|
14
|
-
exports.autoQuoteGoModToken = autoQuoteGoModToken;
|
|
15
|
-
exports.spawnGoTool = spawnGoTool;
|
|
16
|
-
exports.windowsGoCommandArgs = windowsGoCommandArgs;
|
|
17
|
-
exports.ensureExecutableGoToolchain = ensureExecutableGoToolchain;
|
|
18
|
-
exports.resolvePluginCacheRoot = resolvePluginCacheRoot;
|
|
19
|
-
exports.resolveSourceBuildCachePaths = resolveSourceBuildCachePaths;
|
|
20
|
-
exports.resolveCleanTargets = resolveCleanTargets;
|
|
21
|
-
exports.legacyGlobalCacheTargets = legacyGlobalCacheTargets;
|
|
22
|
-
exports.isPathWithin = isPathWithin;
|
|
23
|
-
exports.computeCacheKey = computeCacheKey;
|
|
24
|
-
exports.prunePluginCacheRoot = prunePluginCacheRoot;
|
|
25
|
-
exports.pruneGoBuildCacheRoot = pruneGoBuildCacheRoot;
|
|
26
|
-
exports.withGoBuildCacheLease = withGoBuildCacheLease;
|
|
27
|
-
const node_child_process_1 = require("node:child_process");
|
|
28
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
29
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
30
|
-
const node_module_1 = require("node:module");
|
|
31
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
32
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
33
|
-
const node_url_1 = require("node:url");
|
|
34
|
-
const node_worker_threads_1 = require("node:worker_threads");
|
|
35
|
-
const captureProcessOutput_1 = require("../../compiler/internal/captureProcessOutput");
|
|
36
|
-
const paths_1 = require("../../compiler/internal/paths");
|
|
37
|
-
const createCanonicalTempDirectory_1 = require("../../internal/createCanonicalTempDirectory");
|
|
38
|
-
const spawnSyncResilient_1 = require("../../internal/spawnSyncResilient");
|
|
39
|
-
const GO_MOD_SEARCH_MAX_DEPTH = 3;
|
|
40
|
-
const TTSC_GO_MODULE_PATH = "github.com/samchon/ttsc/packages/ttsc";
|
|
41
|
-
const TSGO_GO_MODULE_PATH = "github.com/microsoft/typescript-go";
|
|
42
|
-
const PRUNE_DIRS = new Set(["node_modules", ".git", ".ttsc"]);
|
|
43
|
-
const GENERATED_WORKSPACE_FILES = new Set(["go.work", "go.work.sum"]);
|
|
44
|
-
// Go build environment values that can change the produced binary or decide
|
|
45
|
-
// whether `go build` succeeds. Hashed into the plugin cache key so target,
|
|
46
|
-
// build-tag, cgo, FIPS, and external-link variants never collide.
|
|
47
|
-
const GO_BUILD_ENV_KEYS = [
|
|
48
|
-
"GOOS",
|
|
49
|
-
"GOARCH",
|
|
50
|
-
"GOAMD64",
|
|
51
|
-
"GOARM",
|
|
52
|
-
"GOARM64",
|
|
53
|
-
"GO386",
|
|
54
|
-
"GOMIPS",
|
|
55
|
-
"GOMIPS64",
|
|
56
|
-
"GOPPC64",
|
|
57
|
-
"GORISCV64",
|
|
58
|
-
"GOWASM",
|
|
59
|
-
"GOFLAGS",
|
|
60
|
-
"GOEXPERIMENT",
|
|
61
|
-
"GOFIPS140",
|
|
62
|
-
"GO_EXTLINK_ENABLED",
|
|
63
|
-
"GCCGO",
|
|
64
|
-
"GCCGOTOOLDIR",
|
|
65
|
-
"CGO_ENABLED",
|
|
66
|
-
"AR",
|
|
67
|
-
"CC",
|
|
68
|
-
"CXX",
|
|
69
|
-
"FC",
|
|
70
|
-
"PKG_CONFIG",
|
|
71
|
-
"CGO_CFLAGS",
|
|
72
|
-
"CGO_CFLAGS_ALLOW",
|
|
73
|
-
"CGO_CFLAGS_DISALLOW",
|
|
74
|
-
"CGO_CPPFLAGS",
|
|
75
|
-
"CGO_CPPFLAGS_ALLOW",
|
|
76
|
-
"CGO_CPPFLAGS_DISALLOW",
|
|
77
|
-
"CGO_CXXFLAGS",
|
|
78
|
-
"CGO_CXXFLAGS_ALLOW",
|
|
79
|
-
"CGO_CXXFLAGS_DISALLOW",
|
|
80
|
-
"CGO_FFLAGS",
|
|
81
|
-
"CGO_FFLAGS_ALLOW",
|
|
82
|
-
"CGO_FFLAGS_DISALLOW",
|
|
83
|
-
"CGO_LDFLAGS",
|
|
84
|
-
"CGO_LDFLAGS_ALLOW",
|
|
85
|
-
"CGO_LDFLAGS_DISALLOW",
|
|
86
|
-
"GOTOOLCHAIN",
|
|
87
|
-
"GOROOT",
|
|
88
|
-
];
|
|
89
|
-
const GO_BUILD_COMMAND_ENV_KEYS = new Set([
|
|
90
|
-
"AR",
|
|
91
|
-
"CC",
|
|
92
|
-
"CXX",
|
|
93
|
-
"FC",
|
|
94
|
-
"GCCGO",
|
|
95
|
-
"PKG_CONFIG",
|
|
96
|
-
]);
|
|
97
|
-
const EXTERNAL_GO_BUILD_ENV_KEYS = [
|
|
98
|
-
"CPATH",
|
|
99
|
-
"C_INCLUDE_PATH",
|
|
100
|
-
"CPLUS_INCLUDE_PATH",
|
|
101
|
-
"DYLD_LIBRARY_PATH",
|
|
102
|
-
"INCLUDE",
|
|
103
|
-
"LD_LIBRARY_PATH",
|
|
104
|
-
"LIB",
|
|
105
|
-
"LIBRARY_PATH",
|
|
106
|
-
"LIBPATH",
|
|
107
|
-
"MACOSX_DEPLOYMENT_TARGET",
|
|
108
|
-
"OBJC_INCLUDE_PATH",
|
|
109
|
-
"PKG_CONFIG_ALLOW_SYSTEM_CFLAGS",
|
|
110
|
-
"PKG_CONFIG_ALLOW_SYSTEM_LIBS",
|
|
111
|
-
"PKG_CONFIG_LIBDIR",
|
|
112
|
-
"PKG_CONFIG_PATH",
|
|
113
|
-
"PKG_CONFIG_SYSROOT_DIR",
|
|
114
|
-
"PKG_CONFIG_TOP_BUILD_DIR",
|
|
115
|
-
"SDKROOT",
|
|
116
|
-
];
|
|
117
|
-
const CONTRIBUTIONS_FILE_NAME = "ttsc_contributions.go";
|
|
118
|
-
const CONTRIB_DIRNAME = "contrib";
|
|
119
|
-
// A cold source-plugin build is a multi-second-to-minutes `go build`. When a
|
|
120
|
-
// program fans out into many processes (a `pnpm -r` running several suites in
|
|
121
|
-
// parallel, a benchmark, a worker pool), each inherits the same cold cache and
|
|
122
|
-
// would otherwise launch its own full build of the SAME cache key at the same
|
|
123
|
-
// instant. The atomic lock below lets one process build while the rest poll for
|
|
124
|
-
// its published binary, so the toolchain runs once per cache key instead of N
|
|
125
|
-
// times. A waiter steals an abandoned lock (builder crashed) after this timeout
|
|
126
|
-
// so a fan-out never wedges; it matches the dependency-build lock in
|
|
127
|
-
// runtimeHooks.ts.
|
|
128
|
-
const PLUGIN_BUILD_LOCK_STEAL_MS = 600_000;
|
|
129
|
-
const PLUGIN_BUILD_LOCK_POLL_MS = 50;
|
|
130
|
-
const PLUGIN_BUILD_LOCK_LEGACY_STALE_MS = 30_000;
|
|
131
|
-
const PLUGIN_BUILD_LOCK_STATUS_MS = 30_000;
|
|
132
|
-
const PLUGIN_BUILD_LOCK_OWNER_FILE = "owner.json";
|
|
133
|
-
const PLUGIN_BUILD_LOCK_PROTOCOL_FILE = "protocol-v2";
|
|
134
|
-
const PLUGIN_BUILD_LOCK_GENERATION_FILE = "generation";
|
|
135
|
-
const PLUGIN_BUILD_LOCK_LEGACY_FENCE_DIR = "legacy-generation";
|
|
136
|
-
const PLUGIN_BUILD_LOCK_LEGACY_FENCE_RECORD = "fence.json";
|
|
137
|
-
const PLUGIN_BUILD_LOCK_CURRENT_DIR = "current";
|
|
138
|
-
const PLUGIN_BUILD_LOCK_RETIRED_DIR = "retired";
|
|
139
|
-
const PLUGIN_BUILD_LOCK_V2_SUFFIX = ".v2";
|
|
140
|
-
const PLUGIN_BUILD_LOCK_PROTOCOL = "ttsc-plugin-build-lock-v2\n";
|
|
141
|
-
// The default cache lives INSIDE the workspace, at
|
|
142
|
-
// `<workspaceRoot>/node_modules/.cache/ttsc`, so `rm -rf node_modules` (or
|
|
143
|
-
// deleting the repo) reclaims every compiled plugin binary and Go object file.
|
|
144
|
-
// This is the `find-cache-dir` convention (Babel, webpack, ESLint, Nuxt, …): a
|
|
145
|
-
// disposable build cache under `node_modules/.cache/<tool>`. ttsc keeps NO
|
|
146
|
-
// global (`~/.cache`) cache — a machine-wide cache silently grew to hundreds of
|
|
147
|
-
// GB across tsgo/plugin version bumps, so it was removed outright. See
|
|
148
|
-
// resolveSourceBuildCacheRoot for the (override → workspace-local) priority.
|
|
149
|
-
const NODE_MODULES_DIRNAME = "node_modules";
|
|
150
|
-
const LOCAL_CACHE_PARENT_DIRNAME = ".cache";
|
|
151
|
-
const TTSC_CACHE_DIRNAME = "ttsc";
|
|
152
|
-
const PLUGIN_CACHE_DIRNAME = "plugins";
|
|
153
|
-
const GO_BUILD_CACHE_DIRNAME = "go-build";
|
|
154
|
-
// Directories whose presence marks a monorepo/workspace root, so every package
|
|
155
|
-
// in the workspace shares ONE cache and a plugin builds once, not once per
|
|
156
|
-
// package. `package.json` with a `workspaces` field (yarn/npm/bun) is checked
|
|
157
|
-
// separately in isWorkspaceRootDir.
|
|
158
|
-
const WORKSPACE_ROOT_MARKER_FILES = ["pnpm-workspace.yaml"];
|
|
159
|
-
const CACHE_LAST_USED_FILE = ".last-used";
|
|
160
|
-
const CACHE_GC_MARKER_FILE = ".gc-last-run";
|
|
161
|
-
// The plugin binary cache is content-keyed, so a project that bumps tsgo/typia
|
|
162
|
-
// many times leaves one stale entry per superseded key. An opportunistic GC
|
|
163
|
-
// (once/day) evicts entries unused for 30 days and, past a 2 GB ceiling, the
|
|
164
|
-
// least-recently-used down to 80%. It is scoped to the resolved cache root only
|
|
165
|
-
// — ttsc never scans a shared or global location.
|
|
166
|
-
const PLUGIN_CACHE_GC_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
167
|
-
const PLUGIN_CACHE_ENTRY_MAX_AGE_MS = 30 * 24 * 60 * 60 * 1000;
|
|
168
|
-
const PLUGIN_CACHE_MAX_BYTES = 2 * 1024 * 1024 * 1024;
|
|
169
|
-
const PLUGIN_CACHE_TARGET_BYTES = Math.floor(PLUGIN_CACHE_MAX_BYTES * 0.8);
|
|
170
|
-
const PLUGIN_CACHE_PROTECTED_AGE_MS = 60 * 60 * 1000;
|
|
171
|
-
// Go's own object-cache trim is age-based and has no size ceiling. The default
|
|
172
|
-
// ttsc-owned cache therefore keeps up to 8 GiB and trims oldest objects toward
|
|
173
|
-
// 6 GiB. The newest target-sized set used within an hour remains protected so
|
|
174
|
-
// crossing the ceiling cannot immediately force another cold build.
|
|
175
|
-
const GO_BUILD_CACHE_GC_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
176
|
-
const GO_BUILD_CACHE_MAX_BYTES = 8 * 1024 * 1024 * 1024;
|
|
177
|
-
const GO_BUILD_CACHE_TARGET_BYTES = 6 * 1024 * 1024 * 1024;
|
|
178
|
-
const GO_BUILD_CACHE_PROTECTED_AGE_MS = 60 * 60 * 1000;
|
|
179
|
-
const GO_BUILD_CACHE_GC_MARKER_FILE = ".ttsc-gc";
|
|
180
|
-
const GO_BUILD_CACHE_LEASE_DIR = ".ttsc-build-leases";
|
|
181
|
-
const GO_BUILD_CACHE_MAINTENANCE_DIR = ".ttsc-maintenance";
|
|
182
|
-
const GO_BUILD_CACHE_COORDINATION_STALE_MS = 60 * 60 * 1000;
|
|
183
|
-
const GO_BUILD_CACHE_MAINTENANCE_STALE_MS = 60 * 1000;
|
|
184
|
-
const GO_BUILD_CACHE_COORDINATION_CLOCK_SKEW_MS = 5 * 60 * 1000;
|
|
185
|
-
const GO_BUILD_CACHE_COORDINATION_HEARTBEAT_MS = 5_000;
|
|
186
|
-
const GO_BUILD_CACHE_COORDINATION_POLL_MS = 25;
|
|
187
|
-
// Go amortizes cache-hit mtime writes over one hour. An object used inside
|
|
188
|
-
// ttsc's one-hour protection window may therefore still carry an mtime almost
|
|
189
|
-
// one additional hour old.
|
|
190
|
-
const GO_BUILD_CACHE_ACCESS_MTIME_GRANULARITY_MS = 60 * 60 * 1000;
|
|
191
|
-
const DEFAULT_SOURCE_BUILD_FILESYSTEM = Object.freeze({
|
|
192
|
-
readFile: (location) => node_fs_1.default.readFileSync(location),
|
|
193
|
-
});
|
|
194
|
-
/**
|
|
195
|
-
* Build one Go source plugin into a cached executable.
|
|
196
|
-
*
|
|
197
|
-
* `opts.env` is the effective environment for this build — the caller merges `{
|
|
198
|
-
* ...process.env, ...context.env }` so a programmatic `TtscCompiler` instance
|
|
199
|
-
* can pin its own Go toolchain (`TTSC_GO_BINARY`), Go build cache
|
|
200
|
-
* (`TTSC_GO_CACHE_DIR`), and Go build variables (`GOFLAGS`, `CGO_*`, …) without
|
|
201
|
-
* mutating the shared `process.env`. CLI callers omit it and inherit
|
|
202
|
-
* `process.env`, so ambient behavior is unchanged.
|
|
203
|
-
*/
|
|
204
|
-
function buildSourcePlugin(opts) {
|
|
205
|
-
const env = opts.env ?? process.env;
|
|
206
|
-
const { dir, entry, source } = resolveSourceBuildTarget(opts);
|
|
207
|
-
const overlayDirs = [...(opts.overlayDirs ?? findTtscOverlayDirs())].sort();
|
|
208
|
-
const contributors = opts.contributors ?? [];
|
|
209
|
-
const compiler = resolveGoCompiler(env);
|
|
210
|
-
const goBinary = resolveGoToolForBuild(compiler.binary, env, dir);
|
|
211
|
-
ensureExecutableGoToolchain(goBinary, compiler.bundled);
|
|
212
|
-
const key = computeCacheKey({
|
|
213
|
-
contributors,
|
|
214
|
-
dir,
|
|
215
|
-
entry,
|
|
216
|
-
env,
|
|
217
|
-
filesystem: opts.filesystem,
|
|
218
|
-
goBinary,
|
|
219
|
-
overlayDirs,
|
|
220
|
-
ttscVersion: opts.ttscVersion,
|
|
221
|
-
tsgoVersion: opts.tsgoVersion,
|
|
222
|
-
});
|
|
223
|
-
const paths = resolveSourceBuildCachePaths(opts.baseDir, opts.cacheDir, env);
|
|
224
|
-
const managePluginCache = !opts.cacheDir && !env.TTSC_CACHE_DIR;
|
|
225
|
-
const manageGoBuildCache = shouldManageSourceBuildCaches(paths, opts.cacheDir, env);
|
|
226
|
-
const pluginRoot = managePluginCache
|
|
227
|
-
? canonicalPluginCacheRoot(paths.pluginRoot)
|
|
228
|
-
: paths.pluginRoot;
|
|
229
|
-
maybePruneSourceBuildCaches({ ...paths, pluginRoot }, opts.cacheDir, env);
|
|
230
|
-
const cacheDir = managePluginCache
|
|
231
|
-
? canonicalPluginCacheEntry(pluginRoot, key)
|
|
232
|
-
: node_path_1.default.join(pluginRoot, key);
|
|
233
|
-
const binaryName = process.platform === "win32" ? "plugin.exe" : "plugin";
|
|
234
|
-
const binaryPath = node_path_1.default.join(cacheDir, binaryName);
|
|
235
|
-
if (node_fs_1.default.existsSync(binaryPath)) {
|
|
236
|
-
touchCacheEntry(cacheDir);
|
|
237
|
-
return binaryPath;
|
|
238
|
-
}
|
|
239
|
-
node_fs_1.default.mkdirSync(cacheDir, { recursive: true });
|
|
240
|
-
const label = opts.label ?? "source plugin";
|
|
241
|
-
const quiet = opts.quiet === true;
|
|
242
|
-
const built = buildUnderPluginLock(cacheDir, binaryPath, { label, pluginName: opts.pluginName, quiet }, () => compileSourcePlugin({
|
|
243
|
-
binaryPath,
|
|
244
|
-
cacheDir,
|
|
245
|
-
contributors,
|
|
246
|
-
dir,
|
|
247
|
-
entry,
|
|
248
|
-
env,
|
|
249
|
-
goBinary,
|
|
250
|
-
normalizeGoToolPermissions: compiler.bundled,
|
|
251
|
-
key,
|
|
252
|
-
label,
|
|
253
|
-
goBuildCacheRoot: paths.goBuildRoot,
|
|
254
|
-
manageGoBuildCache,
|
|
255
|
-
overlayDirs,
|
|
256
|
-
pluginName: opts.pluginName,
|
|
257
|
-
quiet,
|
|
258
|
-
source,
|
|
259
|
-
}));
|
|
260
|
-
if (managePluginCache) {
|
|
261
|
-
// The pre-build daily pass cannot account for the binary this cold build
|
|
262
|
-
// just published. Enforce the size policy after publication, once this
|
|
263
|
-
// process has released its per-key build lock.
|
|
264
|
-
prunePluginCacheRoot(pluginRoot, {
|
|
265
|
-
force: true,
|
|
266
|
-
protectedEntries: [cacheDir],
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return built;
|
|
270
|
-
}
|
|
271
|
-
/** Run the actual `go build` and publish the binary; assumes the lock is held. */
|
|
272
|
-
function compileSourcePlugin(opts) {
|
|
273
|
-
if (!opts.quiet) {
|
|
274
|
-
const extra = opts.contributors.length === 0
|
|
275
|
-
? ""
|
|
276
|
-
: ` + ${opts.contributors.length} contributor(s): ${opts.contributors
|
|
277
|
-
.map((c) => c.name)
|
|
278
|
-
.join(", ")}`;
|
|
279
|
-
process.stderr.write(`ttsc: building ${opts.label} "${opts.pluginName}" from ${opts.source}${extra} ` +
|
|
280
|
-
`(this runs once per cache key and can take several minutes on a cold Go cache) ` +
|
|
281
|
-
`See https://ttsc.dev/docs/ttsc/compile#plugin-cache to persist it across builds.\n`);
|
|
282
|
-
}
|
|
283
|
-
const scratchDir = (0, createCanonicalTempDirectory_1.createCanonicalTempDirectory)(`ttsc-plugin-${opts.key}-`);
|
|
284
|
-
try {
|
|
285
|
-
materializeScratchDir(opts.dir, scratchDir);
|
|
286
|
-
const goModReader = createGoModReader(opts.goBinary, opts.pluginName, opts.env);
|
|
287
|
-
if (opts.contributors.length > 0) {
|
|
288
|
-
mergeContributors({
|
|
289
|
-
contributors: opts.contributors,
|
|
290
|
-
entry: opts.entry,
|
|
291
|
-
goModReader,
|
|
292
|
-
pluginName: opts.pluginName,
|
|
293
|
-
scratchDir,
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
writeGoWork(scratchDir, opts.overlayDirs, opts.goBinary, opts.pluginName, opts.env);
|
|
297
|
-
const scratchBinaryName = process.platform === "win32" ? ".ttsc-plugin.exe" : ".ttsc-plugin";
|
|
298
|
-
let attemptedGoBuildCacheRoot;
|
|
299
|
-
try {
|
|
300
|
-
withGoBuildCacheLease(opts.goBuildCacheRoot, opts.manageGoBuildCache, (goBuildCacheRoot) => {
|
|
301
|
-
attemptedGoBuildCacheRoot = goBuildCacheRoot;
|
|
302
|
-
runGoBuild(scratchDir, opts.entry, scratchBinaryName, opts.pluginName, opts.goBinary, goBuildCacheRoot, opts.env, opts.normalizeGoToolPermissions);
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
finally {
|
|
306
|
-
if (opts.manageGoBuildCache && attemptedGoBuildCacheRoot !== undefined) {
|
|
307
|
-
// The daily pre-build pass cannot see objects the build is about to
|
|
308
|
-
// add, including objects left behind by a failed compile. Enforce the
|
|
309
|
-
// size policy after every actual cold-build attempt so churn cannot
|
|
310
|
-
// grow the cache unchecked behind a fresh daily marker.
|
|
311
|
-
pruneGoBuildCacheRoot(attemptedGoBuildCacheRoot, { force: true });
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
const builtBinary = node_path_1.default.join(scratchDir, scratchBinaryName);
|
|
315
|
-
publishBuiltBinary(builtBinary, opts.binaryPath);
|
|
316
|
-
touchCacheEntry(opts.cacheDir);
|
|
317
|
-
return opts.binaryPath;
|
|
318
|
-
}
|
|
319
|
-
finally {
|
|
320
|
-
node_fs_1.default.rmSync(scratchDir, { recursive: true, force: true });
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Build a source plugin while holding an exclusive cross-process lock for its
|
|
325
|
-
* cache key, so concurrent fan-out (parallel suites, a benchmark, a worker
|
|
326
|
-
* pool) runs the `go build` once instead of once per process.
|
|
327
|
-
*
|
|
328
|
-
* `<cacheDir>.lock.v2` is a persistent coordination directory. The adjacent
|
|
329
|
-
* `<cacheDir>.lock` path remains reserved for legacy holders and is never
|
|
330
|
-
* reused for a v2 generation: an old holder or stale legacy reclaimer can
|
|
331
|
-
* therefore remove only the legacy path, never a v2 successor. A contender
|
|
332
|
-
* writes a non-empty candidate and atomically renames it to `current`; only one
|
|
333
|
-
* rename wins. The winner builds and publishes while every loser polls and
|
|
334
|
-
* reuses the resulting binary. A loser distinguishes two ways a generation
|
|
335
|
-
* stops blocking:
|
|
336
|
-
*
|
|
337
|
-
* - `released`: the holder retired `current` itself — it published, or its build
|
|
338
|
-
* threw and its `finally` freed the key. The loser simply retries the
|
|
339
|
-
* ordinary acquisition; nothing is stale and nothing is reported.
|
|
340
|
-
* - `abandoned`: `current` still exists but its owner is provably dead, it is an
|
|
341
|
-
* old metadata-less legacy lock, or the wait budget
|
|
342
|
-
* (`PLUGIN_BUILD_LOCK_STEAL_MS`) expired. Only then does the loser report and
|
|
343
|
-
* retire precisely that generation before retrying.
|
|
344
|
-
*
|
|
345
|
-
* Retired generations remain as non-empty tombstones. Release and reclaim both
|
|
346
|
-
* rename `current` to the observed generation's deterministic tombstone path.
|
|
347
|
-
* Once generation A is retired, a stale observer or old finalizer for A cannot
|
|
348
|
-
* rename successor B there because replacing the non-empty tombstone fails
|
|
349
|
-
* atomically. `publishBuiltBinary`'s atomic rename remains defense in depth.
|
|
350
|
-
*/
|
|
351
|
-
function buildUnderPluginLock(cacheDir, binaryPath, lockInfo, build) {
|
|
352
|
-
const lockDir = `${cacheDir}.lock`;
|
|
353
|
-
for (;;) {
|
|
354
|
-
if (node_fs_1.default.existsSync(binaryPath)) {
|
|
355
|
-
touchCacheEntry(cacheDir);
|
|
356
|
-
return binaryPath;
|
|
357
|
-
}
|
|
358
|
-
let lease;
|
|
359
|
-
try {
|
|
360
|
-
lease = acquirePluginBuildLock(lockDir);
|
|
361
|
-
}
|
|
362
|
-
catch {
|
|
363
|
-
// An unusable coordination directory must not silently skip the build.
|
|
364
|
-
// Atomic publication still preserves binary integrity.
|
|
365
|
-
return build();
|
|
366
|
-
}
|
|
367
|
-
if (lease === null) {
|
|
368
|
-
const waited = waitForPluginBinary({
|
|
369
|
-
binaryPath,
|
|
370
|
-
lockDir,
|
|
371
|
-
lockInfo,
|
|
372
|
-
timeoutMs: PLUGIN_BUILD_LOCK_STEAL_MS,
|
|
373
|
-
});
|
|
374
|
-
if (waited.outcome === "published") {
|
|
375
|
-
touchCacheEntry(cacheDir);
|
|
376
|
-
return binaryPath;
|
|
377
|
-
}
|
|
378
|
-
if (waited.outcome === "abandoned") {
|
|
379
|
-
// Retire only the generation that produced this observation. Losing
|
|
380
|
-
// the rename race means another waiter (or the holder's normal
|
|
381
|
-
// finalizer) already made progress, so do not report a stale result as
|
|
382
|
-
// an abandonment.
|
|
383
|
-
if (reclaimPluginBuildLock(lockDir, waited.fence)) {
|
|
384
|
-
reportPluginLockSteal(lockDir, binaryPath, lockInfo, waited.reason);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
// "released" needs no repair: the holder freed the key normally (its
|
|
388
|
-
// build published or failed), so retry the ordinary atomic acquisition.
|
|
389
|
-
// Reporting a steal or force-removing the path here would misclassify a
|
|
390
|
-
// routine handoff as abandonment (issue #421).
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
try {
|
|
394
|
-
// Re-check under the lock: a previous holder may have just published.
|
|
395
|
-
if (node_fs_1.default.existsSync(binaryPath)) {
|
|
396
|
-
touchCacheEntry(cacheDir);
|
|
397
|
-
return binaryPath;
|
|
398
|
-
}
|
|
399
|
-
return build();
|
|
400
|
-
}
|
|
401
|
-
finally {
|
|
402
|
-
releasePluginBuildLock(lockDir, lease);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Atomically acquire the current generation in a v2 coordination directory.
|
|
408
|
-
*
|
|
409
|
-
* A non-empty candidate is renamed to `current`. Directory rename cannot
|
|
410
|
-
* replace a non-empty `current`, so exactly one contender wins without an
|
|
411
|
-
* empty-owner publication window. `null` means either another v2 holder won or
|
|
412
|
-
* the path is a legacy lock that must be observed before it can be reclaimed.
|
|
413
|
-
*
|
|
414
|
-
* Exported for deterministic multi-process tests.
|
|
415
|
-
*/
|
|
416
|
-
function acquirePluginBuildLock(lockDir) {
|
|
417
|
-
// A legacy holder owns the old path. Never publish v2 ownership into that
|
|
418
|
-
// deletable namespace; wait until the legacy generation is released or
|
|
419
|
-
// reclaimed, then use the orthogonal persistent v2 directory.
|
|
420
|
-
if (pluginBuildLockPathExists(lockDir)) {
|
|
421
|
-
return null;
|
|
422
|
-
}
|
|
423
|
-
const protocolDir = pluginBuildLockProtocolDir(lockDir);
|
|
424
|
-
ensurePluginBuildLockProtocol(protocolDir);
|
|
425
|
-
// Close the initialization window as far as the legacy protocol permits. A
|
|
426
|
-
// legacy holder that appeared while v2 was initialized still blocks this
|
|
427
|
-
// acquisition. (A legacy executable cannot provide a true cross-path CAS.)
|
|
428
|
-
if (pluginBuildLockPathExists(lockDir)) {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
const generation = node_crypto_1.default.randomBytes(16).toString("hex");
|
|
432
|
-
const candidateDir = node_path_1.default.join(protocolDir, `candidate-${generation}`);
|
|
433
|
-
node_fs_1.default.mkdirSync(candidateDir);
|
|
434
|
-
try {
|
|
435
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(candidateDir, PLUGIN_BUILD_LOCK_GENERATION_FILE), `${generation}\n`, { encoding: "utf8", flag: "wx" });
|
|
436
|
-
writePluginBuildLockOwner(candidateDir, generation);
|
|
437
|
-
try {
|
|
438
|
-
node_fs_1.default.renameSync(candidateDir, node_path_1.default.join(protocolDir, PLUGIN_BUILD_LOCK_CURRENT_DIR));
|
|
439
|
-
}
|
|
440
|
-
catch (error) {
|
|
441
|
-
if (isMissingPathError(error) ||
|
|
442
|
-
isRenameDestinationOccupied(error, node_path_1.default.join(protocolDir, PLUGIN_BUILD_LOCK_CURRENT_DIR))) {
|
|
443
|
-
return null;
|
|
444
|
-
}
|
|
445
|
-
throw error;
|
|
446
|
-
}
|
|
447
|
-
return { protocol: "v2", generation };
|
|
448
|
-
}
|
|
449
|
-
finally {
|
|
450
|
-
// The candidate name contains this process's random generation and can
|
|
451
|
-
// never alias `current` or another contender's candidate.
|
|
452
|
-
node_fs_1.default.rmSync(candidateDir, { force: true, recursive: true });
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
/** Retire a held generation during the holder's `finally`. */
|
|
456
|
-
function releasePluginBuildLock(lockDir, lease) {
|
|
457
|
-
return retireV2PluginBuildLock(pluginBuildLockProtocolDir(lockDir), lease.generation);
|
|
458
|
-
}
|
|
459
|
-
/**
|
|
460
|
-
* Retire exactly the generation carried by an abandoned observation.
|
|
461
|
-
*
|
|
462
|
-
* Exported for deterministic multi-process tests.
|
|
463
|
-
*/
|
|
464
|
-
function reclaimPluginBuildLock(lockDir, fence) {
|
|
465
|
-
if (fence.protocol === "v2") {
|
|
466
|
-
return retireV2PluginBuildLock(pluginBuildLockProtocolDir(lockDir), fence.generation);
|
|
467
|
-
}
|
|
468
|
-
return retireLegacyPluginBuildLock(lockDir, fence.generation);
|
|
469
|
-
}
|
|
470
|
-
function pluginBuildLockProtocolDir(lockDir) {
|
|
471
|
-
return `${lockDir}${PLUGIN_BUILD_LOCK_V2_SUFFIX}`;
|
|
472
|
-
}
|
|
473
|
-
function ensurePluginBuildLockProtocol(protocolDir) {
|
|
474
|
-
if (isPluginBuildLockProtocolV2(protocolDir)) {
|
|
475
|
-
return;
|
|
476
|
-
}
|
|
477
|
-
const generation = node_crypto_1.default.randomBytes(16).toString("hex");
|
|
478
|
-
const candidateDir = `${protocolDir}.candidate-${generation}`;
|
|
479
|
-
node_fs_1.default.mkdirSync(candidateDir);
|
|
480
|
-
try {
|
|
481
|
-
node_fs_1.default.mkdirSync(node_path_1.default.join(candidateDir, PLUGIN_BUILD_LOCK_RETIRED_DIR));
|
|
482
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(candidateDir, PLUGIN_BUILD_LOCK_PROTOCOL_FILE), PLUGIN_BUILD_LOCK_PROTOCOL, { encoding: "utf8", flag: "wx" });
|
|
483
|
-
try {
|
|
484
|
-
node_fs_1.default.renameSync(candidateDir, protocolDir);
|
|
485
|
-
}
|
|
486
|
-
catch (error) {
|
|
487
|
-
if (isRenameDestinationOccupied(error, protocolDir) &&
|
|
488
|
-
isPluginBuildLockProtocolV2(protocolDir)) {
|
|
489
|
-
return;
|
|
490
|
-
}
|
|
491
|
-
throw error;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
finally {
|
|
495
|
-
node_fs_1.default.rmSync(candidateDir, { force: true, recursive: true });
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
function isPluginBuildLockProtocolV2(lockDir) {
|
|
499
|
-
try {
|
|
500
|
-
const stats = node_fs_1.default.lstatSync(lockDir);
|
|
501
|
-
if (!stats.isDirectory() || stats.isSymbolicLink())
|
|
502
|
-
return false;
|
|
503
|
-
return (node_fs_1.default.readFileSync(node_path_1.default.join(lockDir, PLUGIN_BUILD_LOCK_PROTOCOL_FILE), "utf8") === PLUGIN_BUILD_LOCK_PROTOCOL);
|
|
504
|
-
}
|
|
505
|
-
catch {
|
|
506
|
-
return false;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
function retireV2PluginBuildLock(lockDir, generation) {
|
|
510
|
-
if (!isPluginBuildLockGeneration(generation))
|
|
511
|
-
return false;
|
|
512
|
-
const retiredDir = node_path_1.default.join(lockDir, PLUGIN_BUILD_LOCK_RETIRED_DIR);
|
|
513
|
-
try {
|
|
514
|
-
node_fs_1.default.mkdirSync(retiredDir);
|
|
515
|
-
}
|
|
516
|
-
catch (error) {
|
|
517
|
-
if (error.code !== "EEXIST") {
|
|
518
|
-
if (isMissingPathError(error))
|
|
519
|
-
return false;
|
|
520
|
-
throw error;
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
const destination = node_path_1.default.join(retiredDir, generation);
|
|
524
|
-
try {
|
|
525
|
-
node_fs_1.default.renameSync(node_path_1.default.join(lockDir, PLUGIN_BUILD_LOCK_CURRENT_DIR), destination);
|
|
526
|
-
return true;
|
|
527
|
-
}
|
|
528
|
-
catch (error) {
|
|
529
|
-
if (isMissingPathError(error) ||
|
|
530
|
-
isRenameDestinationOccupied(error, destination)) {
|
|
531
|
-
return false;
|
|
532
|
-
}
|
|
533
|
-
throw error;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
function retireLegacyPluginBuildLock(lockDir, generation) {
|
|
537
|
-
if (!isPluginBuildLockGeneration(generation))
|
|
538
|
-
return false;
|
|
539
|
-
const captured = readLegacyPluginBuildLockFence(node_path_1.default.join(lockDir, PLUGIN_BUILD_LOCK_LEGACY_FENCE_DIR));
|
|
540
|
-
if (captured?.fence.generation !== generation) {
|
|
541
|
-
return false;
|
|
542
|
-
}
|
|
543
|
-
const destination = `${lockDir}.retired-${generation}`;
|
|
544
|
-
try {
|
|
545
|
-
node_fs_1.default.renameSync(lockDir, destination);
|
|
546
|
-
return true;
|
|
547
|
-
}
|
|
548
|
-
catch (error) {
|
|
549
|
-
if (isMissingPathError(error) ||
|
|
550
|
-
isRenameDestinationOccupied(error, destination)) {
|
|
551
|
-
return false;
|
|
552
|
-
}
|
|
553
|
-
throw error;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
function isMissingPathError(error) {
|
|
557
|
-
const code = error.code;
|
|
558
|
-
return code === "ENOENT" || code === "ENOTDIR";
|
|
559
|
-
}
|
|
560
|
-
function isRenameDestinationOccupied(error, destination) {
|
|
561
|
-
const code = error.code;
|
|
562
|
-
if (code === "EEXIST" || code === "ENOTEMPTY") {
|
|
563
|
-
return true;
|
|
564
|
-
}
|
|
565
|
-
return (code === "EACCES" || code === "EPERM") && node_fs_1.default.existsSync(destination);
|
|
566
|
-
}
|
|
567
|
-
/**
|
|
568
|
-
* Poll for the locked builder to publish its binary, up to `timeoutMs`.
|
|
569
|
-
*
|
|
570
|
-
* Exported for unit tests.
|
|
571
|
-
*/
|
|
572
|
-
function waitForPluginBinary(opts) {
|
|
573
|
-
const startedAt = Date.now();
|
|
574
|
-
let nextStatusAt = startedAt + PLUGIN_BUILD_LOCK_STATUS_MS;
|
|
575
|
-
for (;;) {
|
|
576
|
-
if (node_fs_1.default.existsSync(opts.binaryPath)) {
|
|
577
|
-
return { outcome: "published" };
|
|
578
|
-
}
|
|
579
|
-
const now = Date.now();
|
|
580
|
-
const lock = inspectPluginBuildLock(opts.lockDir, now);
|
|
581
|
-
if (lock.state === "released") {
|
|
582
|
-
// The holder retired its generation between the binary check above and
|
|
583
|
-
// this observation. That is a normal release, not abandonment: prefer the
|
|
584
|
-
// binary when it landed inside that window, otherwise hand the free key
|
|
585
|
-
// back to the caller.
|
|
586
|
-
return node_fs_1.default.existsSync(opts.binaryPath)
|
|
587
|
-
? { outcome: "published" }
|
|
588
|
-
: { outcome: "released" };
|
|
589
|
-
}
|
|
590
|
-
if (lock.state === "abandoned") {
|
|
591
|
-
return {
|
|
592
|
-
outcome: "abandoned",
|
|
593
|
-
reason: lock.reason,
|
|
594
|
-
fence: lock.fence,
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
if (now - startedAt > opts.timeoutMs) {
|
|
598
|
-
return {
|
|
599
|
-
outcome: "abandoned",
|
|
600
|
-
reason: `timed out after ${formatDuration(now - startedAt)}`,
|
|
601
|
-
fence: lock.fence,
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
if (!opts.lockInfo.quiet && now >= nextStatusAt) {
|
|
605
|
-
reportPluginLockWait({
|
|
606
|
-
binaryPath: opts.binaryPath,
|
|
607
|
-
elapsedMs: now - startedAt,
|
|
608
|
-
lockDir: opts.lockDir,
|
|
609
|
-
lockInfo: opts.lockInfo,
|
|
610
|
-
owner: lock.owner,
|
|
611
|
-
});
|
|
612
|
-
nextStatusAt = now + PLUGIN_BUILD_LOCK_STATUS_MS;
|
|
613
|
-
}
|
|
614
|
-
sleepSync(PLUGIN_BUILD_LOCK_POLL_MS);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
function writePluginBuildLockOwner(generationDir, generation) {
|
|
618
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(generationDir, PLUGIN_BUILD_LOCK_OWNER_FILE), `${JSON.stringify({
|
|
619
|
-
generation,
|
|
620
|
-
hostname: node_os_1.default.hostname(),
|
|
621
|
-
pid: process.pid,
|
|
622
|
-
startedAt: new Date().toISOString(),
|
|
623
|
-
}, null, 2)}\n`, "utf8");
|
|
624
|
-
}
|
|
625
|
-
/**
|
|
626
|
-
* Classify the current state of a plugin build lock directory.
|
|
627
|
-
*
|
|
628
|
-
* Exported for unit tests.
|
|
629
|
-
*/
|
|
630
|
-
function inspectPluginBuildLock(lockDir, now) {
|
|
631
|
-
const protocolDir = pluginBuildLockProtocolDir(lockDir);
|
|
632
|
-
for (;;) {
|
|
633
|
-
if (isPluginBuildLockProtocolV2(protocolDir)) {
|
|
634
|
-
const v2 = inspectV2PluginBuildLock(protocolDir, now);
|
|
635
|
-
if (v2.state !== "released") {
|
|
636
|
-
return v2;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
const legacy = captureLegacyPluginBuildLockFence(lockDir);
|
|
640
|
-
if (legacy !== null) {
|
|
641
|
-
return inspectLegacyPluginBuildLock(lockDir, now, legacy);
|
|
642
|
-
}
|
|
643
|
-
if (pluginBuildLockAgeMs(lockDir, now) === null) {
|
|
644
|
-
return { state: "released" };
|
|
645
|
-
}
|
|
646
|
-
// The path changed while its legacy fence was being captured. Re-observe
|
|
647
|
-
// the replacement rather than attaching the old state to a new owner.
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
function inspectV2PluginBuildLock(lockDir, now) {
|
|
651
|
-
const generationDir = node_path_1.default.join(lockDir, PLUGIN_BUILD_LOCK_CURRENT_DIR);
|
|
652
|
-
const generation = readPluginBuildLockGeneration(generationDir);
|
|
653
|
-
if (generation === null) {
|
|
654
|
-
if (pluginBuildLockAgeMs(generationDir, now) === null) {
|
|
655
|
-
return { state: "released" };
|
|
656
|
-
}
|
|
657
|
-
throw new Error(`ttsc plugin build lock has no valid ${PLUGIN_BUILD_LOCK_GENERATION_FILE}: ${generationDir}`);
|
|
658
|
-
}
|
|
659
|
-
const fence = { protocol: "v2", generation };
|
|
660
|
-
const owner = readPluginBuildLockOwner(generationDir);
|
|
661
|
-
if (owner !== null) {
|
|
662
|
-
const label = describePluginBuildLockOwner(owner);
|
|
663
|
-
if (isLocalHostName(owner.hostname) && !isProcessAlive(owner.pid)) {
|
|
664
|
-
return {
|
|
665
|
-
state: "abandoned",
|
|
666
|
-
reason: `${label} is no longer running`,
|
|
667
|
-
fence,
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
return {
|
|
671
|
-
state: "active",
|
|
672
|
-
owner: label,
|
|
673
|
-
fence,
|
|
674
|
-
};
|
|
675
|
-
}
|
|
676
|
-
const ageMs = pluginBuildLockAgeMs(generationDir, now);
|
|
677
|
-
if (ageMs === null) {
|
|
678
|
-
return { state: "released" };
|
|
679
|
-
}
|
|
680
|
-
if (ageMs > PLUGIN_BUILD_LOCK_LEGACY_STALE_MS) {
|
|
681
|
-
return {
|
|
682
|
-
state: "abandoned",
|
|
683
|
-
reason: `lock generation has no ${PLUGIN_BUILD_LOCK_OWNER_FILE} and is ` +
|
|
684
|
-
`${formatDuration(ageMs)} old`,
|
|
685
|
-
fence,
|
|
686
|
-
};
|
|
687
|
-
}
|
|
688
|
-
return {
|
|
689
|
-
state: "active",
|
|
690
|
-
owner: `lock generation with no ${PLUGIN_BUILD_LOCK_OWNER_FILE}`,
|
|
691
|
-
fence,
|
|
692
|
-
};
|
|
693
|
-
}
|
|
694
|
-
function inspectLegacyPluginBuildLock(lockDir, now, legacy) {
|
|
695
|
-
const owner = readPluginBuildLockOwner(lockDir);
|
|
696
|
-
if (owner !== null) {
|
|
697
|
-
const label = describePluginBuildLockOwner(owner);
|
|
698
|
-
if (isLocalHostName(owner.hostname) && !isProcessAlive(owner.pid)) {
|
|
699
|
-
return {
|
|
700
|
-
state: "abandoned",
|
|
701
|
-
reason: `${label} is no longer running`,
|
|
702
|
-
fence: legacy.fence,
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
return {
|
|
706
|
-
state: "active",
|
|
707
|
-
owner: label,
|
|
708
|
-
fence: legacy.fence,
|
|
709
|
-
};
|
|
710
|
-
}
|
|
711
|
-
const ageMs = Math.max(0, now - legacy.legacyMtimeMs);
|
|
712
|
-
if (ageMs > PLUGIN_BUILD_LOCK_LEGACY_STALE_MS) {
|
|
713
|
-
return {
|
|
714
|
-
state: "abandoned",
|
|
715
|
-
reason: `legacy lock has no ${PLUGIN_BUILD_LOCK_OWNER_FILE} and is ` +
|
|
716
|
-
`${formatDuration(ageMs)} old`,
|
|
717
|
-
fence: legacy.fence,
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
return {
|
|
721
|
-
state: "active",
|
|
722
|
-
owner: `legacy lock with no ${PLUGIN_BUILD_LOCK_OWNER_FILE}`,
|
|
723
|
-
fence: legacy.fence,
|
|
724
|
-
};
|
|
725
|
-
}
|
|
726
|
-
function captureLegacyPluginBuildLockFence(lockDir) {
|
|
727
|
-
if (isPluginBuildLockProtocolV2(lockDir)) {
|
|
728
|
-
return null;
|
|
729
|
-
}
|
|
730
|
-
let legacyMtimeMs;
|
|
731
|
-
try {
|
|
732
|
-
legacyMtimeMs = node_fs_1.default.statSync(lockDir).mtimeMs;
|
|
733
|
-
}
|
|
734
|
-
catch (error) {
|
|
735
|
-
if (isMissingPathError(error))
|
|
736
|
-
return null;
|
|
737
|
-
throw error;
|
|
738
|
-
}
|
|
739
|
-
const fenceDir = node_path_1.default.join(lockDir, PLUGIN_BUILD_LOCK_LEGACY_FENCE_DIR);
|
|
740
|
-
let captured = readLegacyPluginBuildLockFence(fenceDir);
|
|
741
|
-
if (captured === null) {
|
|
742
|
-
const generation = node_crypto_1.default.randomBytes(16).toString("hex");
|
|
743
|
-
// Keep candidates beside the legacy lock. Creating one inside `lockDir`
|
|
744
|
-
// would advance its mtime before a contender publishes the shared fence;
|
|
745
|
-
// a concurrent contender could then record an old lock as freshly created.
|
|
746
|
-
const candidateDir = `${lockDir}.legacy-candidate-${generation}`;
|
|
747
|
-
try {
|
|
748
|
-
node_fs_1.default.mkdirSync(candidateDir);
|
|
749
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(candidateDir, PLUGIN_BUILD_LOCK_LEGACY_FENCE_RECORD), `${JSON.stringify({ generation, legacyMtimeMs })}\n`, "utf8");
|
|
750
|
-
try {
|
|
751
|
-
node_fs_1.default.renameSync(candidateDir, fenceDir);
|
|
752
|
-
captured = {
|
|
753
|
-
fence: { protocol: "legacy", generation },
|
|
754
|
-
legacyMtimeMs,
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
catch (error) {
|
|
758
|
-
if (isRenameDestinationOccupied(error, fenceDir)) {
|
|
759
|
-
captured = readLegacyPluginBuildLockFence(fenceDir);
|
|
760
|
-
}
|
|
761
|
-
else if (isMissingPathError(error)) {
|
|
762
|
-
return null;
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
throw error;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
catch (error) {
|
|
770
|
-
if (isMissingPathError(error)) {
|
|
771
|
-
return null;
|
|
772
|
-
}
|
|
773
|
-
throw error;
|
|
774
|
-
}
|
|
775
|
-
finally {
|
|
776
|
-
node_fs_1.default.rmSync(candidateDir, { force: true, recursive: true });
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
if (captured === null) {
|
|
780
|
-
throw new Error(`invalid legacy plugin build lock fence: ${fenceDir}`);
|
|
781
|
-
}
|
|
782
|
-
// A stale observer can resume after the legacy holder released or another
|
|
783
|
-
// process retired the path. Confirm both the legacy layout and token after
|
|
784
|
-
// publication; v2 ownership is kept in the orthogonal sibling directory.
|
|
785
|
-
const confirmed = readLegacyPluginBuildLockFence(fenceDir);
|
|
786
|
-
if (isPluginBuildLockProtocolV2(lockDir) ||
|
|
787
|
-
confirmed === null ||
|
|
788
|
-
confirmed.fence.generation !== captured.fence.generation) {
|
|
789
|
-
return null;
|
|
790
|
-
}
|
|
791
|
-
return captured;
|
|
792
|
-
}
|
|
793
|
-
function readLegacyPluginBuildLockFence(fenceDir) {
|
|
794
|
-
try {
|
|
795
|
-
const parsed = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(fenceDir, PLUGIN_BUILD_LOCK_LEGACY_FENCE_RECORD), "utf8"));
|
|
796
|
-
if (!isPluginBuildLockGeneration(parsed.generation) ||
|
|
797
|
-
typeof parsed.legacyMtimeMs !== "number" ||
|
|
798
|
-
!Number.isFinite(parsed.legacyMtimeMs) ||
|
|
799
|
-
parsed.legacyMtimeMs < 0) {
|
|
800
|
-
return null;
|
|
801
|
-
}
|
|
802
|
-
return {
|
|
803
|
-
fence: { protocol: "legacy", generation: parsed.generation },
|
|
804
|
-
legacyMtimeMs: parsed.legacyMtimeMs,
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
catch {
|
|
808
|
-
return null;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
function readPluginBuildLockGeneration(generationDir) {
|
|
812
|
-
try {
|
|
813
|
-
const generation = node_fs_1.default
|
|
814
|
-
.readFileSync(node_path_1.default.join(generationDir, PLUGIN_BUILD_LOCK_GENERATION_FILE), "utf8")
|
|
815
|
-
.trim();
|
|
816
|
-
return isPluginBuildLockGeneration(generation) ? generation : null;
|
|
817
|
-
}
|
|
818
|
-
catch {
|
|
819
|
-
return null;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
function isPluginBuildLockGeneration(value) {
|
|
823
|
-
return typeof value === "string" && /^[0-9a-f]{32}$/.test(value);
|
|
824
|
-
}
|
|
825
|
-
function readPluginBuildLockOwner(lockDir) {
|
|
826
|
-
try {
|
|
827
|
-
const parsed = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(lockDir, PLUGIN_BUILD_LOCK_OWNER_FILE), "utf8"));
|
|
828
|
-
if (typeof parsed.hostname !== "string" ||
|
|
829
|
-
!Number.isInteger(parsed.pid) ||
|
|
830
|
-
typeof parsed.pid !== "number" ||
|
|
831
|
-
parsed.pid <= 0) {
|
|
832
|
-
return null;
|
|
833
|
-
}
|
|
834
|
-
return {
|
|
835
|
-
hostname: parsed.hostname,
|
|
836
|
-
pid: parsed.pid,
|
|
837
|
-
startedAt: typeof parsed.startedAt === "string" ? parsed.startedAt : undefined,
|
|
838
|
-
};
|
|
839
|
-
}
|
|
840
|
-
catch {
|
|
841
|
-
return null;
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
/**
|
|
845
|
-
* Age of an observed lock directory, or `null` when it no longer exists. The
|
|
846
|
-
* holder may have retired it between the caller's checks. "Missing" is a
|
|
847
|
-
* observation, never encoded as a numeric age: the previous
|
|
848
|
-
* `Number.POSITIVE_INFINITY` encoding made a just-released lock look like an
|
|
849
|
-
* infinitely old abandoned legacy lock (issue #421).
|
|
850
|
-
*
|
|
851
|
-
* A stat failure that does not prove absence (e.g. `EPERM`) clamps to age 0:
|
|
852
|
-
* the lock is treated as fresh so a waiter never steals on ambiguous evidence,
|
|
853
|
-
* while the caller's wait budget still bounds the stall.
|
|
854
|
-
*/
|
|
855
|
-
function pluginBuildLockAgeMs(lockDir, now) {
|
|
856
|
-
try {
|
|
857
|
-
return Math.max(0, now - node_fs_1.default.statSync(lockDir).mtimeMs);
|
|
858
|
-
}
|
|
859
|
-
catch (error) {
|
|
860
|
-
const code = error.code;
|
|
861
|
-
return code === "ENOENT" || code === "ENOTDIR" ? null : 0;
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
function pluginBuildLockPathExists(lockDir) {
|
|
865
|
-
try {
|
|
866
|
-
const stats = node_fs_1.default.lstatSync(lockDir);
|
|
867
|
-
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
868
|
-
throw new Error(`ttsc: unsafe plugin build lock path: ${lockDir}`);
|
|
869
|
-
}
|
|
870
|
-
return true;
|
|
871
|
-
}
|
|
872
|
-
catch (error) {
|
|
873
|
-
if (isMissingPathError(error))
|
|
874
|
-
return false;
|
|
875
|
-
throw error;
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
function isLocalHostName(hostname) {
|
|
879
|
-
return hostname.toLowerCase() === node_os_1.default.hostname().toLowerCase();
|
|
880
|
-
}
|
|
881
|
-
function isProcessAlive(pid) {
|
|
882
|
-
try {
|
|
883
|
-
process.kill(pid, 0);
|
|
884
|
-
return true;
|
|
885
|
-
}
|
|
886
|
-
catch (error) {
|
|
887
|
-
return error.code === "EPERM";
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
function describePluginBuildLockOwner(owner) {
|
|
891
|
-
const started = owner.startedAt === undefined ? "" : ` started at ${owner.startedAt}`;
|
|
892
|
-
return `pid ${owner.pid} on ${owner.hostname}${started}`;
|
|
893
|
-
}
|
|
894
|
-
function reportPluginLockWait(opts) {
|
|
895
|
-
process.stderr.write(`ttsc: waiting for ${opts.lockInfo.label} "${opts.lockInfo.pluginName}" ` +
|
|
896
|
-
`cache lock after ${formatDuration(opts.elapsedMs)}; ` +
|
|
897
|
-
`lock=${opts.lockDir}; binary=${opts.binaryPath}; owner=${opts.owner}\n`);
|
|
898
|
-
}
|
|
899
|
-
function reportPluginLockSteal(lockDir, binaryPath, lockInfo, reason) {
|
|
900
|
-
if (lockInfo.quiet)
|
|
901
|
-
return;
|
|
902
|
-
process.stderr.write(`ttsc: reclaiming abandoned ${lockInfo.label} "${lockInfo.pluginName}" ` +
|
|
903
|
-
`cache lock at ${lockDir}; binary=${binaryPath} (${reason})\n`);
|
|
904
|
-
}
|
|
905
|
-
/**
|
|
906
|
-
* Render a millisecond duration for lock diagnostics (`137ms`, `42s`, `9m 3s`).
|
|
907
|
-
*
|
|
908
|
-
* Total over every number: no caller produces a non-finite duration anymore
|
|
909
|
-
* (the lock state machine reports "released" instead of an Infinity age), but
|
|
910
|
-
* as defense in depth a non-finite input renders as `an unknown time` so no
|
|
911
|
-
* public diagnostic can ever print `Infinitym NaNs` again (issue #421).
|
|
912
|
-
*
|
|
913
|
-
* Exported for unit tests.
|
|
914
|
-
*/
|
|
915
|
-
function formatDuration(ms) {
|
|
916
|
-
if (!Number.isFinite(ms)) {
|
|
917
|
-
return "an unknown time";
|
|
918
|
-
}
|
|
919
|
-
if (ms < 1_000) {
|
|
920
|
-
return `${Math.max(0, Math.round(ms))}ms`;
|
|
921
|
-
}
|
|
922
|
-
const seconds = Math.floor(ms / 1_000);
|
|
923
|
-
const minutes = Math.floor(seconds / 60);
|
|
924
|
-
const remainder = seconds % 60;
|
|
925
|
-
if (minutes === 0) {
|
|
926
|
-
return `${seconds}s`;
|
|
927
|
-
}
|
|
928
|
-
return `${minutes}m ${remainder}s`;
|
|
929
|
-
}
|
|
930
|
-
/** Block the current (synchronous) thread for `ms` without busy-spinning. */
|
|
931
|
-
function sleepSync(ms) {
|
|
932
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Copy every contributor's Go source into a sub-package of the host module and
|
|
936
|
-
* synthesize a blank-import file alongside the host's entry package so each
|
|
937
|
-
* contributor's `init()` runs before `main`.
|
|
938
|
-
*
|
|
939
|
-
* - Sources land at `<scratch>/<CONTRIB_DIRNAME>/<name>/` (recursive copy with
|
|
940
|
-
* the same pruning rules used for the host source).
|
|
941
|
-
* - The entry directory receives `<CONTRIBUTIONS_FILE_NAME>` containing one
|
|
942
|
-
* blank-import per contributor. The host's module path is read from the
|
|
943
|
-
* materialized go.mod, so the import path is always correct for the host
|
|
944
|
-
* plugin's actual module declaration.
|
|
945
|
-
* - Contributors that ship their own `go.mod` are rejected — the design relies on
|
|
946
|
-
* the contributor living inside the host's module so that workspace overlay
|
|
947
|
-
* rules and the host's `go.sum` cover transitive dependencies. This also
|
|
948
|
-
* closes the supply-chain hole where a contributor could otherwise pull in
|
|
949
|
-
* arbitrary Go modules.
|
|
950
|
-
*/
|
|
951
|
-
function mergeContributors(opts) {
|
|
952
|
-
const hostModulePath = opts.goModReader.read(opts.scratchDir).modulePath;
|
|
953
|
-
if (hostModulePath === null || hostModulePath === "") {
|
|
954
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" cannot accept contributors because its module ` +
|
|
955
|
-
`root has no resolvable go.mod module path`);
|
|
956
|
-
}
|
|
957
|
-
const contribRoot = node_path_1.default.join(opts.scratchDir, CONTRIB_DIRNAME);
|
|
958
|
-
// Refuse to merge when the host plugin's own source already owns a
|
|
959
|
-
// `contrib/` directory. We'd otherwise silently merge contributor
|
|
960
|
-
// files into a pre-populated host package and ship a hybrid binary
|
|
961
|
-
// whose contents nobody declared. Loud failure is the only safe
|
|
962
|
-
// option — the host plugin must rename its directory or the
|
|
963
|
-
// contributor system must use a different sub-package root.
|
|
964
|
-
if (node_fs_1.default.existsSync(contribRoot)) {
|
|
965
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" already ships a ${CONTRIB_DIRNAME}/ directory in its source; ` +
|
|
966
|
-
`contributor merge would silently overwrite. Rename the host plugin's directory to a different name.`);
|
|
967
|
-
}
|
|
968
|
-
node_fs_1.default.mkdirSync(contribRoot, { recursive: true });
|
|
969
|
-
// Sort contributors by name so the synthesized `ttsc_contributions.go`
|
|
970
|
-
// emits blank imports in a deterministic order independent of
|
|
971
|
-
// declaration order. The cache key is already sort-stable
|
|
972
|
-
// (`computeCacheKey` sorts contributors by name), so without this
|
|
973
|
-
// matching sort the SAME cache key could correspond to two distinct
|
|
974
|
-
// binaries whose `init()` sequence across contributors differs by
|
|
975
|
-
// import order.
|
|
976
|
-
const sortedContributors = [...opts.contributors].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
977
|
-
const imports = [];
|
|
978
|
-
for (const contributor of sortedContributors) {
|
|
979
|
-
if (node_fs_1.default.existsSync(node_path_1.default.join(contributor.source, "go.mod"))) {
|
|
980
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" contributor "${contributor.name}" must ship Go ` +
|
|
981
|
-
`source as a package, not a module (go.mod found at ${contributor.source}/go.mod). ` +
|
|
982
|
-
`Remove go.mod so the contributor compiles inside the host module's dependency graph.`);
|
|
983
|
-
}
|
|
984
|
-
const target = node_path_1.default.join(contribRoot, contributor.name);
|
|
985
|
-
if (node_fs_1.default.existsSync(target)) {
|
|
986
|
-
// Defensive: validatePluginContributors already rejects duplicate
|
|
987
|
-
// names, and the contribRoot-existence guard above blocks the
|
|
988
|
-
// host plugin from pre-shipping a `contrib/` directory. Reaching
|
|
989
|
-
// this branch implies an upstream contract break. Fail loud
|
|
990
|
-
// rather than overwrite.
|
|
991
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" contributor "${contributor.name}" target ${target} already exists; ` +
|
|
992
|
-
`contributor names must be unique within one plugin build`);
|
|
993
|
-
}
|
|
994
|
-
node_fs_1.default.cpSync(contributor.source, target, {
|
|
995
|
-
recursive: true,
|
|
996
|
-
filter: (src) => {
|
|
997
|
-
const base = node_path_1.default.basename(src);
|
|
998
|
-
if (shouldPruneDirectory(base))
|
|
999
|
-
return false;
|
|
1000
|
-
if (shouldOmitSourceFile(base))
|
|
1001
|
-
return false;
|
|
1002
|
-
return true;
|
|
1003
|
-
},
|
|
1004
|
-
});
|
|
1005
|
-
imports.push(`${hostModulePath}/${CONTRIB_DIRNAME}/${contributor.name}`);
|
|
1006
|
-
}
|
|
1007
|
-
const entryDir = node_path_1.default.resolve(opts.scratchDir, opts.entry);
|
|
1008
|
-
node_fs_1.default.mkdirSync(entryDir, { recursive: true });
|
|
1009
|
-
const contributionsPath = node_path_1.default.join(entryDir, CONTRIBUTIONS_FILE_NAME);
|
|
1010
|
-
// Same reasoning as the contribRoot guard: when entry resolves to the
|
|
1011
|
-
// module root (`entry === "."`), entryDir == scratchDir and a
|
|
1012
|
-
// pre-existing `ttsc_contributions.go` from the host plugin's own
|
|
1013
|
-
// source would be silently overwritten by the generator below.
|
|
1014
|
-
if (node_fs_1.default.existsSync(contributionsPath)) {
|
|
1015
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" already ships ${CONTRIBUTIONS_FILE_NAME} in its entry package; ` +
|
|
1016
|
-
`that filename is reserved for the contributor blank-import generator. Rename the host's file.`);
|
|
1017
|
-
}
|
|
1018
|
-
writeContributionsFile(contributionsPath, imports);
|
|
1019
|
-
}
|
|
1020
|
-
function writeContributionsFile(filePath, imports) {
|
|
1021
|
-
const importLines = imports
|
|
1022
|
-
.map((spec) => `\t_ ${JSON.stringify(spec)}`)
|
|
1023
|
-
.join("\n");
|
|
1024
|
-
const body = `// Code generated by ttsc — DO NOT EDIT.
|
|
1025
|
-
//
|
|
1026
|
-
// This file is synthesized by ttsc's plugin builder when the host plugin
|
|
1027
|
-
// descriptor declares "contributors". The blank imports below pull each
|
|
1028
|
-
// contributor sub-package into the build so its init() runs before main.
|
|
1029
|
-
|
|
1030
|
-
package main
|
|
1031
|
-
|
|
1032
|
-
import (
|
|
1033
|
-
${importLines}
|
|
1034
|
-
)
|
|
1035
|
-
`;
|
|
1036
|
-
node_fs_1.default.writeFileSync(filePath, body, "utf8");
|
|
1037
|
-
}
|
|
1038
|
-
function publishBuiltBinary(builtBinary, binaryPath) {
|
|
1039
|
-
const pending = `${binaryPath}.${process.pid}.${Date.now()}-${Math.random()
|
|
1040
|
-
.toString(16)
|
|
1041
|
-
.slice(2)}.tmp`;
|
|
1042
|
-
node_fs_1.default.copyFileSync(builtBinary, pending);
|
|
1043
|
-
if (process.platform !== "win32") {
|
|
1044
|
-
node_fs_1.default.chmodSync(pending, 0o755);
|
|
1045
|
-
}
|
|
1046
|
-
try {
|
|
1047
|
-
node_fs_1.default.renameSync(pending, binaryPath);
|
|
1048
|
-
}
|
|
1049
|
-
catch (error) {
|
|
1050
|
-
node_fs_1.default.rmSync(pending, { force: true });
|
|
1051
|
-
const code = error.code;
|
|
1052
|
-
if ((code === "EEXIST" || code === "EPERM" || code === "EACCES") &&
|
|
1053
|
-
node_fs_1.default.existsSync(binaryPath)) {
|
|
1054
|
-
return;
|
|
1055
|
-
}
|
|
1056
|
-
throw error;
|
|
1057
|
-
}
|
|
1058
|
-
finally {
|
|
1059
|
-
// Best-effort sweep of any leftover `.tmp` siblings from a prior
|
|
1060
|
-
// crash between copyFileSync and renameSync. Same-directory pending
|
|
1061
|
-
// names guarantee the rename stays a same-filesystem atomic op, so
|
|
1062
|
-
// we accept the GC cost rather than move pending files to os.tmpdir.
|
|
1063
|
-
pruneOrphanPendingBinaries(binaryPath);
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
function pruneOrphanPendingBinaries(binaryPath) {
|
|
1067
|
-
// Only sweep pending files owned by THIS process. Concurrent ttsc
|
|
1068
|
-
// invocations (two `ttsc --watch` shells against the same project)
|
|
1069
|
-
// may have their own `<binary>.<their-pid>.*.tmp` mid-flight, and
|
|
1070
|
-
// deleting them would race their renameSync into ENOENT.
|
|
1071
|
-
try {
|
|
1072
|
-
const dir = node_path_1.default.dirname(binaryPath);
|
|
1073
|
-
const prefix = `${node_path_1.default.basename(binaryPath)}.${process.pid}.`;
|
|
1074
|
-
for (const name of node_fs_1.default.readdirSync(dir)) {
|
|
1075
|
-
if (name.startsWith(prefix) && name.endsWith(".tmp")) {
|
|
1076
|
-
node_fs_1.default.rmSync(node_path_1.default.join(dir, name), { force: true });
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
catch {
|
|
1081
|
-
// Best-effort; never mask the underlying publish outcome.
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
function resolveSourceBuildTarget(opts) {
|
|
1085
|
-
const source = node_path_1.default.isAbsolute(opts.source)
|
|
1086
|
-
? opts.source
|
|
1087
|
-
: node_path_1.default.resolve(opts.baseDir, opts.source);
|
|
1088
|
-
if (!node_fs_1.default.existsSync(source)) {
|
|
1089
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" source does not exist: ${source}`);
|
|
1090
|
-
}
|
|
1091
|
-
const stat = node_fs_1.default.statSync(source);
|
|
1092
|
-
const packageDir = stat.isFile() && node_path_1.default.basename(source) === "go.mod"
|
|
1093
|
-
? node_path_1.default.dirname(source)
|
|
1094
|
-
: stat.isDirectory()
|
|
1095
|
-
? source
|
|
1096
|
-
: null;
|
|
1097
|
-
if (packageDir === null) {
|
|
1098
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" source must be a Go package directory or go.mod file: ${source}`);
|
|
1099
|
-
}
|
|
1100
|
-
const goMod = (0, paths_1.findNearestGoMod)(packageDir, GO_MOD_SEARCH_MAX_DEPTH);
|
|
1101
|
-
if (goMod === null) {
|
|
1102
|
-
throw new Error(`ttsc: plugin "${opts.pluginName}" source must be inside a Go module with go.mod within ${GO_MOD_SEARCH_MAX_DEPTH} parent directories: ${source}`);
|
|
1103
|
-
}
|
|
1104
|
-
const dir = node_path_1.default.dirname(goMod);
|
|
1105
|
-
const rel = node_path_1.default.relative(dir, packageDir).replace(/\\/g, "/");
|
|
1106
|
-
return {
|
|
1107
|
-
dir,
|
|
1108
|
-
entry: rel === "" ? "." : `./${rel}`,
|
|
1109
|
-
source,
|
|
1110
|
-
};
|
|
1111
|
-
}
|
|
1112
|
-
function materializeScratchDir(source, scratch) {
|
|
1113
|
-
node_fs_1.default.mkdirSync(scratch, { recursive: true });
|
|
1114
|
-
node_fs_1.default.cpSync(source, scratch, {
|
|
1115
|
-
recursive: true,
|
|
1116
|
-
filter: (src) => {
|
|
1117
|
-
const base = node_path_1.default.basename(src);
|
|
1118
|
-
if (shouldPruneDirectory(base))
|
|
1119
|
-
return false;
|
|
1120
|
-
if (shouldOmitSourceFile(base))
|
|
1121
|
-
return false;
|
|
1122
|
-
return true;
|
|
1123
|
-
},
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
|
-
function writeGoWork(scratchDir, useDirs, goBinary, pluginName, env) {
|
|
1127
|
-
const goModReader = createGoModReader(goBinary, pluginName, env);
|
|
1128
|
-
validateSourceReplacements(scratchDir, useDirs, goModReader, pluginName);
|
|
1129
|
-
const sourceInfo = goModReader.read(scratchDir);
|
|
1130
|
-
const effectiveUseDirs = sourceInfo.modulePath === TTSC_GO_MODULE_PATH
|
|
1131
|
-
? useDirs.filter((dir) => {
|
|
1132
|
-
const modulePath = goModReader.read(dir).modulePath;
|
|
1133
|
-
return modulePath !== null && !isTtscManagedModulePath(modulePath);
|
|
1134
|
-
})
|
|
1135
|
-
: useDirs;
|
|
1136
|
-
const useLines = ["\t."];
|
|
1137
|
-
for (const dir of effectiveUseDirs) {
|
|
1138
|
-
useLines.push(`\t${formatGoWorkPath(dir)}`);
|
|
1139
|
-
}
|
|
1140
|
-
const replaceLines = sourceBuildWorkspaceReplacements(effectiveUseDirs, goModReader);
|
|
1141
|
-
const replaceBlock = replaceLines.length === 0 ? "" : `\n\n${replaceLines.join("\n")}\n`;
|
|
1142
|
-
const goWork = `go 1.26\n\nuse (\n${useLines.join("\n")}\n)${replaceBlock}`;
|
|
1143
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(scratchDir, "go.work"), goWork, "utf8");
|
|
1144
|
-
}
|
|
1145
|
-
function validateSourceReplacements(scratchDir, useDirs, goModReader, pluginName) {
|
|
1146
|
-
const sourceInfo = goModReader.read(scratchDir);
|
|
1147
|
-
if (sourceInfo.modulePath === TTSC_GO_MODULE_PATH) {
|
|
1148
|
-
return;
|
|
1149
|
-
}
|
|
1150
|
-
const sourceReplacements = sourceInfo.replacements;
|
|
1151
|
-
if (sourceReplacements.length === 0) {
|
|
1152
|
-
return;
|
|
1153
|
-
}
|
|
1154
|
-
const overlayModules = collectOverlayModulePaths(useDirs, goModReader);
|
|
1155
|
-
for (const replacement of sourceReplacements) {
|
|
1156
|
-
if (isTtscManagedModulePath(replacement.modulePath) ||
|
|
1157
|
-
overlayModules.has(replacement.modulePath)) {
|
|
1158
|
-
throw new Error(`ttsc: plugin "${pluginName}" go.mod replaces ttsc-managed module ` +
|
|
1159
|
-
`${JSON.stringify(replacement.modulePath)}. Remove this replace directive; ` +
|
|
1160
|
-
`ttsc supplies its own compiler and shim modules while building source plugins.`);
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
function sourceBuildWorkspaceReplacements(useDirs, goModReader) {
|
|
1165
|
-
const ttscRoot = useDirs.find((dir) => goModReader.read(dir).modulePath === TTSC_GO_MODULE_PATH);
|
|
1166
|
-
if (!ttscRoot) {
|
|
1167
|
-
return [];
|
|
1168
|
-
}
|
|
1169
|
-
return [
|
|
1170
|
-
`replace ${TTSC_GO_MODULE_PATH} v0.0.0 => ${formatGoWorkPath(ttscRoot)}`,
|
|
1171
|
-
];
|
|
1172
|
-
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Format an absolute filesystem path as a single `go.work`/`go.mod` token.
|
|
1175
|
-
*
|
|
1176
|
-
* The modfile grammar shared by `go.mod` and `go.work` (parsed by
|
|
1177
|
-
* `golang.org/x/mod/modfile`) is whitespace-tokenized, so a `use`/`replace`
|
|
1178
|
-
* path that contains a space — a home or project directory such as `/Users/John
|
|
1179
|
-
* Smith/...` or `C:\Users\John Smith\...` — must be emitted as a quoted string
|
|
1180
|
-
* or `go` cannot parse the generated `go.work`. Normalize Windows separators to
|
|
1181
|
-
* `/` (the workspace convention) and then delegate to
|
|
1182
|
-
* {@link autoQuoteGoModToken}, which mirrors `modfile.AutoQuote`.
|
|
1183
|
-
*
|
|
1184
|
-
* Separator normalization is itself a quoting trigger. A Windows UNC
|
|
1185
|
-
* (`\\server\share\...`) or extended-length (`\\?\C:\...`) path normalizes into
|
|
1186
|
-
* a token that starts with `//`, and the modfile lexer reads `//` as a line
|
|
1187
|
-
* comment wherever it appears. Emitted bare, such a token turns its whole
|
|
1188
|
-
* `use`/`replace` line into a comment: `go` exits 0, reports nothing, and the
|
|
1189
|
-
* overlay module simply disappears from the workspace.
|
|
1190
|
-
*
|
|
1191
|
-
* Exported for unit tests.
|
|
1192
|
-
*/
|
|
1193
|
-
function formatGoWorkPath(p) {
|
|
1194
|
-
return autoQuoteGoModToken(p.replace(/\\/g, "/"));
|
|
1195
|
-
}
|
|
1196
|
-
/**
|
|
1197
|
-
* Quote `token` for a `go.mod`/`go.work` line exactly as
|
|
1198
|
-
* `golang.org/x/mod/modfile`'s `AutoQuote` does: return it unchanged when it is
|
|
1199
|
-
* already a clean bare token, otherwise return its Go double-quoted form so the
|
|
1200
|
-
* value round-trips through the modfile lexer. A clean bare token is therefore
|
|
1201
|
-
* emitted byte-for-byte as before; only tokens that would otherwise be split or
|
|
1202
|
-
* interpreted as comments are quoted.
|
|
1203
|
-
*
|
|
1204
|
-
* Exported for unit tests.
|
|
1205
|
-
*/
|
|
1206
|
-
function autoQuoteGoModToken(token) {
|
|
1207
|
-
return mustQuoteGoModToken(token) ? goQuoteString(token) : token;
|
|
1208
|
-
}
|
|
1209
|
-
// Mirror `modfile.MustQuote`: report whether `s` must be quoted to appear as a
|
|
1210
|
-
// single token on a modfile line.
|
|
1211
|
-
function mustQuoteGoModToken(s) {
|
|
1212
|
-
for (const ch of s) {
|
|
1213
|
-
if (ch === " " || ch === '"' || ch === "'" || ch === "`") {
|
|
1214
|
-
return true;
|
|
1215
|
-
}
|
|
1216
|
-
if (ch === "(" ||
|
|
1217
|
-
ch === ")" ||
|
|
1218
|
-
ch === "[" ||
|
|
1219
|
-
ch === "]" ||
|
|
1220
|
-
ch === "{" ||
|
|
1221
|
-
ch === "}" ||
|
|
1222
|
-
ch === ",") {
|
|
1223
|
-
// Go tests `len(s) > 1` (byte length): a lone bracket/comma is a legal
|
|
1224
|
-
// bare token, but one embedded in a longer token forces quoting.
|
|
1225
|
-
if (Buffer.byteLength(s, "utf8") > 1) {
|
|
1226
|
-
return true;
|
|
1227
|
-
}
|
|
1228
|
-
continue;
|
|
1229
|
-
}
|
|
1230
|
-
if (!isGoPrintable(ch)) {
|
|
1231
|
-
return true;
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
return s === "" || s.includes("//") || s.includes("/*");
|
|
1235
|
-
}
|
|
1236
|
-
// Mirror `strconv.Quote`: wrap in double quotes, backslash-escape `"` and `\`,
|
|
1237
|
-
// emit Go-printable runes verbatim (including the ASCII space and printable
|
|
1238
|
-
// Unicode), and escape everything else with Go's `\a\b\f\n\r\t\v` / `\xNN` /
|
|
1239
|
-
// `\uNNNN` / `\UNNNNNNNN` forms so the token round-trips through
|
|
1240
|
-
// `strconv.Unquote` in the modfile lexer.
|
|
1241
|
-
function goQuoteString(s) {
|
|
1242
|
-
let out = '"';
|
|
1243
|
-
for (const ch of s) {
|
|
1244
|
-
if (ch === '"' || ch === "\\") {
|
|
1245
|
-
out += `\\${ch}`;
|
|
1246
|
-
continue;
|
|
1247
|
-
}
|
|
1248
|
-
if (isGoPrintable(ch)) {
|
|
1249
|
-
out += ch;
|
|
1250
|
-
continue;
|
|
1251
|
-
}
|
|
1252
|
-
out += escapeGoRune(ch);
|
|
1253
|
-
}
|
|
1254
|
-
return `${out}"`;
|
|
1255
|
-
}
|
|
1256
|
-
function escapeGoRune(ch) {
|
|
1257
|
-
switch (ch) {
|
|
1258
|
-
case "\x07":
|
|
1259
|
-
return "\\a";
|
|
1260
|
-
case "\b":
|
|
1261
|
-
return "\\b";
|
|
1262
|
-
case "\f":
|
|
1263
|
-
return "\\f";
|
|
1264
|
-
case "\n":
|
|
1265
|
-
return "\\n";
|
|
1266
|
-
case "\r":
|
|
1267
|
-
return "\\r";
|
|
1268
|
-
case "\t":
|
|
1269
|
-
return "\\t";
|
|
1270
|
-
case "\v":
|
|
1271
|
-
return "\\v";
|
|
1272
|
-
default: {
|
|
1273
|
-
const cp = ch.codePointAt(0) ?? 0;
|
|
1274
|
-
if (cp < 0x20 || cp === 0x7f) {
|
|
1275
|
-
return `\\x${cp.toString(16).padStart(2, "0")}`;
|
|
1276
|
-
}
|
|
1277
|
-
if (cp < 0x10000) {
|
|
1278
|
-
return `\\u${cp.toString(16).padStart(4, "0")}`;
|
|
1279
|
-
}
|
|
1280
|
-
return `\\U${cp.toString(16).padStart(8, "0")}`;
|
|
1281
|
-
}
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
// `strconv.IsPrint`: the graphic categories except that the ONLY spacing
|
|
1285
|
-
// character is the ASCII space (U+0020); other Unicode spaces are escaped.
|
|
1286
|
-
const GO_PRINTABLE_RE = /^[\p{L}\p{M}\p{N}\p{P}\p{S}]$/u;
|
|
1287
|
-
function isGoPrintable(ch) {
|
|
1288
|
-
return ch === " " || GO_PRINTABLE_RE.test(ch);
|
|
1289
|
-
}
|
|
1290
|
-
function createGoModReader(goBinary, pluginName, env) {
|
|
1291
|
-
const cache = new Map();
|
|
1292
|
-
return {
|
|
1293
|
-
read(dir) {
|
|
1294
|
-
const resolved = node_path_1.default.resolve(dir);
|
|
1295
|
-
const cached = cache.get(resolved);
|
|
1296
|
-
if (cached !== undefined) {
|
|
1297
|
-
return cached;
|
|
1298
|
-
}
|
|
1299
|
-
const info = readGoModInfo(resolved, goBinary, pluginName, env);
|
|
1300
|
-
cache.set(resolved, info);
|
|
1301
|
-
return info;
|
|
1302
|
-
},
|
|
1303
|
-
};
|
|
1304
|
-
}
|
|
1305
|
-
function readGoModInfo(dir, goBinary, pluginName, env) {
|
|
1306
|
-
if (!node_fs_1.default.existsSync(node_path_1.default.join(dir, "go.mod"))) {
|
|
1307
|
-
return emptyGoModInfo();
|
|
1308
|
-
}
|
|
1309
|
-
const result = spawnGoTool(goBinary, ["mod", "edit", "-json"], {
|
|
1310
|
-
cwd: dir,
|
|
1311
|
-
encoding: "utf8",
|
|
1312
|
-
env: goBuildEnv(goBinary, undefined, env),
|
|
1313
|
-
windowsHide: true,
|
|
1314
|
-
});
|
|
1315
|
-
if (result.error) {
|
|
1316
|
-
if (result.error.code === "ENOENT") {
|
|
1317
|
-
throw new Error(goToolchainNotFoundMessage(pluginName));
|
|
1318
|
-
}
|
|
1319
|
-
throw new Error(`ttsc: reading go.mod for plugin "${pluginName}" failed to spawn ${goBinary}: ${result.error.message}`);
|
|
1320
|
-
}
|
|
1321
|
-
if (result.status !== 0) {
|
|
1322
|
-
throw new Error(`ttsc: reading go.mod for plugin "${pluginName}" failed:\n${result.stderr || result.stdout}`);
|
|
1323
|
-
}
|
|
1324
|
-
let json;
|
|
1325
|
-
try {
|
|
1326
|
-
json = JSON.parse(result.stdout);
|
|
1327
|
-
}
|
|
1328
|
-
catch (error) {
|
|
1329
|
-
throw new Error(`ttsc: reading go.mod for plugin "${pluginName}" returned invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
1330
|
-
}
|
|
1331
|
-
return {
|
|
1332
|
-
modulePath: json.Module?.Path ?? null,
|
|
1333
|
-
replacements: (json.Replace ?? [])
|
|
1334
|
-
.map(jsonReplacementToGoModReplacement)
|
|
1335
|
-
.filter((replacement) => replacement !== null),
|
|
1336
|
-
};
|
|
1337
|
-
}
|
|
1338
|
-
function emptyGoModInfo() {
|
|
1339
|
-
return {
|
|
1340
|
-
modulePath: null,
|
|
1341
|
-
replacements: [],
|
|
1342
|
-
};
|
|
1343
|
-
}
|
|
1344
|
-
function jsonReplacementToGoModReplacement(replacement) {
|
|
1345
|
-
const modulePath = replacement.Old?.Path;
|
|
1346
|
-
if (modulePath === undefined) {
|
|
1347
|
-
return null;
|
|
1348
|
-
}
|
|
1349
|
-
return {
|
|
1350
|
-
modulePath,
|
|
1351
|
-
};
|
|
1352
|
-
}
|
|
1353
|
-
function collectOverlayModulePaths(dirs, goModReader) {
|
|
1354
|
-
const out = new Set();
|
|
1355
|
-
for (const dir of dirs) {
|
|
1356
|
-
const modulePath = goModReader.read(dir).modulePath;
|
|
1357
|
-
if (modulePath !== null) {
|
|
1358
|
-
out.add(modulePath);
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
return out;
|
|
1362
|
-
}
|
|
1363
|
-
function isTtscManagedModulePath(modulePath) {
|
|
1364
|
-
return (modulePath === TTSC_GO_MODULE_PATH ||
|
|
1365
|
-
modulePath === TSGO_GO_MODULE_PATH ||
|
|
1366
|
-
modulePath.startsWith("github.com/microsoft/typescript-go/shim/"));
|
|
1367
|
-
}
|
|
1368
|
-
function runGoBuild(cwd, entry, binaryName, pluginName, goBinary, goBuildCacheRoot, env, normalizeGoToolPermissions) {
|
|
1369
|
-
ensureExecutableGoToolchain(goBinary, normalizeGoToolPermissions);
|
|
1370
|
-
const result = spawnGoTool(goBinary, ["build", "-o", binaryName, entry], {
|
|
1371
|
-
cwd,
|
|
1372
|
-
encoding: "utf8",
|
|
1373
|
-
env: goBuildEnv(goBinary, goBuildCacheRoot, env),
|
|
1374
|
-
windowsHide: true,
|
|
1375
|
-
});
|
|
1376
|
-
if (result.error) {
|
|
1377
|
-
if (result.error.code === "ENOENT") {
|
|
1378
|
-
throw new Error(goToolchainNotFoundMessage(pluginName));
|
|
1379
|
-
}
|
|
1380
|
-
throw new Error(`ttsc: building plugin "${pluginName}" failed to spawn ${goBinary}: ${result.error.message}`);
|
|
1381
|
-
}
|
|
1382
|
-
if (result.status !== 0) {
|
|
1383
|
-
throw new Error(`ttsc: building plugin "${pluginName}" via "go build" failed:\n${result.stderr || result.stdout}`);
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
function goToolchainNotFoundMessage(pluginName) {
|
|
1387
|
-
return (`ttsc: building plugin "${pluginName}" failed because the Go toolchain was not found. ` +
|
|
1388
|
-
`Reinstall ttsc with optional dependencies so the bundled Go compiler is present, ` +
|
|
1389
|
-
`or set TTSC_GO_BINARY to an absolute path.`);
|
|
1390
|
-
}
|
|
1391
|
-
function spawnGoTool(goBinary, args, options) {
|
|
1392
|
-
// The child's streams go to files rather than pipes, so no output ceiling
|
|
1393
|
-
// applies: `spawnSync` only bounds what it must hold in this process's
|
|
1394
|
-
// memory, and a `go build` that says a great deal is not a failure to invent
|
|
1395
|
-
// a limit for. See `captureProcessOutput`.
|
|
1396
|
-
const capture = (0, captureProcessOutput_1.captureProcessOutput)();
|
|
1397
|
-
const spawnOptions = {
|
|
1398
|
-
...options,
|
|
1399
|
-
stdio: ["ignore", capture.stdoutFd, capture.stderrFd],
|
|
1400
|
-
};
|
|
1401
|
-
try {
|
|
1402
|
-
const result = spawnGoToolProcess(goBinary, args, spawnOptions, {
|
|
1403
|
-
stderr: capture.stderrPath,
|
|
1404
|
-
stdout: capture.stdoutPath,
|
|
1405
|
-
});
|
|
1406
|
-
const stdout = capture.read("stdout", "utf8");
|
|
1407
|
-
const stderr = capture.read("stderr", "utf8");
|
|
1408
|
-
return {
|
|
1409
|
-
...result,
|
|
1410
|
-
output: [null, stdout, stderr],
|
|
1411
|
-
stderr,
|
|
1412
|
-
stdout,
|
|
1413
|
-
};
|
|
1414
|
-
}
|
|
1415
|
-
finally {
|
|
1416
|
-
capture.dispose();
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
/**
|
|
1420
|
-
* Launch the Go tool, routing through cmd.exe only where Windows needs a
|
|
1421
|
-
* wrapper. Output routing is the caller's concern; this owns process
|
|
1422
|
-
* selection.
|
|
1423
|
-
*/
|
|
1424
|
-
function spawnGoToolProcess(goBinary, args, options, output) {
|
|
1425
|
-
if (process.platform !== "win32") {
|
|
1426
|
-
return (0, spawnSyncResilient_1.spawnSyncResilient)(goBinary, args, options, output);
|
|
1427
|
-
}
|
|
1428
|
-
const inheritedEnv = options.env ?? process.env;
|
|
1429
|
-
const resolved = resolveWindowsGoTool(goBinary, inheritedEnv, spawnWorkingDirectory(options.cwd));
|
|
1430
|
-
if (!resolved.wrapper) {
|
|
1431
|
-
return (0, node_child_process_1.spawnSync)(goBinary, [...args], options);
|
|
1432
|
-
}
|
|
1433
|
-
// Preserve the native spawn ENOENT contract before cmd.exe becomes the
|
|
1434
|
-
// actual child process. The callers use that code for the install guidance.
|
|
1435
|
-
if (resolved.location === null) {
|
|
1436
|
-
return (0, node_child_process_1.spawnSync)(goBinary, [...args], options);
|
|
1437
|
-
}
|
|
1438
|
-
const shim = createWindowsGoCommandShim([resolved.location, ...args]);
|
|
1439
|
-
return (0, node_child_process_1.spawnSync)(readWindowsEnvironmentValue(inheritedEnv, "COMSPEC") ??
|
|
1440
|
-
readWindowsEnvironmentValue(process.env, "COMSPEC") ??
|
|
1441
|
-
"cmd.exe", windowsGoCommandArgs(shim.payload), {
|
|
1442
|
-
...options,
|
|
1443
|
-
env: { ...inheritedEnv, ...shim.environment },
|
|
1444
|
-
shell: false,
|
|
1445
|
-
// The /c payload is already one fully quoted Windows command line.
|
|
1446
|
-
windowsVerbatimArguments: true,
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
/** Build the fixed cmd.exe switch sequence for one already quoted payload. */
|
|
1450
|
-
function windowsGoCommandArgs(payload) {
|
|
1451
|
-
return ["/d", "/v:off", "/s", "/c", payload];
|
|
1452
|
-
}
|
|
1453
|
-
function spawnWorkingDirectory(cwd) {
|
|
1454
|
-
if (cwd === undefined)
|
|
1455
|
-
return process.cwd();
|
|
1456
|
-
return node_path_1.default.resolve(typeof cwd === "string" ? cwd : (0, node_url_1.fileURLToPath)(cwd));
|
|
1457
|
-
}
|
|
1458
|
-
function isWindowsCommandWrapper(location) {
|
|
1459
|
-
return process.platform === "win32" && /\.(?:bat|cmd)$/i.test(location);
|
|
1460
|
-
}
|
|
1461
|
-
/** Pass volatile cmd wrapper arguments through one-pass environment expansion. */
|
|
1462
|
-
function createWindowsGoCommandShim(args) {
|
|
1463
|
-
const prefix = `TTSC_GO_COMMAND_SHIM_${node_crypto_1.default
|
|
1464
|
-
.randomBytes(8)
|
|
1465
|
-
.toString("hex")
|
|
1466
|
-
.toUpperCase()}_ARG_`;
|
|
1467
|
-
const environment = Object.fromEntries(args.map((arg, index) => [prefix + index, quoteWindowsCommandArg(arg)]));
|
|
1468
|
-
return {
|
|
1469
|
-
environment,
|
|
1470
|
-
// cmd expands each placeholder exactly once. Percent-shaped text inside an
|
|
1471
|
-
// expanded value is not scanned as a second environment reference.
|
|
1472
|
-
payload: `"${args.map((_, index) => `%${prefix}${index}%`).join(" ")}"`,
|
|
1473
|
-
};
|
|
1474
|
-
}
|
|
1475
|
-
/** Quote one argv value for the Windows command-line parser used by cmd. */
|
|
1476
|
-
function quoteWindowsCommandArg(arg) {
|
|
1477
|
-
return `"${String(arg)
|
|
1478
|
-
.replace(/(\\*)"/g, '$1$1\\"')
|
|
1479
|
-
.replace(/(\\*)$/, "$1$1")}"`;
|
|
1480
|
-
}
|
|
1481
|
-
function goBuildEnv(goBinary, goBuildCacheRoot, effectiveEnv = process.env) {
|
|
1482
|
-
const env = { ...effectiveEnv };
|
|
1483
|
-
env.GOWORK = "auto";
|
|
1484
|
-
// Only the actual `go build` needs ttsc's GOCACHE; read-only metadata spawns
|
|
1485
|
-
// (`go mod edit`, `go env`, `go version`) call goBuildEnv with no cache root
|
|
1486
|
-
// and inherit the ambient GOCACHE, which they never write to anyway. GOCACHE
|
|
1487
|
-
// is not part of the plugin cache key, so this cannot affect it.
|
|
1488
|
-
if (goBuildCacheRoot) {
|
|
1489
|
-
env.GOCACHE = goBuildCacheRoot;
|
|
1490
|
-
}
|
|
1491
|
-
const goRoot = inferGoRoot(goBinary);
|
|
1492
|
-
if (goRoot && !env.GOROOT) {
|
|
1493
|
-
env.GOROOT = goRoot;
|
|
1494
|
-
}
|
|
1495
|
-
return env;
|
|
1496
|
-
}
|
|
1497
|
-
function inferGoRoot(goBinary) {
|
|
1498
|
-
if (!node_path_1.default.isAbsolute(goBinary))
|
|
1499
|
-
return null;
|
|
1500
|
-
const binDir = node_path_1.default.dirname(goBinary);
|
|
1501
|
-
if (node_path_1.default.basename(binDir) !== "bin")
|
|
1502
|
-
return null;
|
|
1503
|
-
const goRoot = node_path_1.default.dirname(binDir);
|
|
1504
|
-
return node_fs_1.default.existsSync(node_path_1.default.join(goRoot, "src", "runtime")) ? goRoot : null;
|
|
1505
|
-
}
|
|
1506
|
-
function ensureExecutableGoToolchain(goBinary, normalizeBundledPermissions) {
|
|
1507
|
-
if (process.platform === "win32")
|
|
1508
|
-
return;
|
|
1509
|
-
if (!node_path_1.default.isAbsolute(goBinary) || !node_fs_1.default.existsSync(goBinary))
|
|
1510
|
-
return;
|
|
1511
|
-
try {
|
|
1512
|
-
ensureExecutableFile(goBinary, normalizeBundledPermissions);
|
|
1513
|
-
const goRoot = inferGoRoot(goBinary);
|
|
1514
|
-
if (!goRoot)
|
|
1515
|
-
return;
|
|
1516
|
-
const gofmt = node_path_1.default.join(node_path_1.default.dirname(goBinary), "gofmt");
|
|
1517
|
-
if (node_fs_1.default.existsSync(gofmt)) {
|
|
1518
|
-
ensureExecutableFile(gofmt, normalizeBundledPermissions);
|
|
1519
|
-
}
|
|
1520
|
-
const toolDir = node_path_1.default.join(goRoot, "pkg", "tool");
|
|
1521
|
-
if (!node_fs_1.default.existsSync(toolDir))
|
|
1522
|
-
return;
|
|
1523
|
-
for (const file of walkToolFiles(toolDir)) {
|
|
1524
|
-
ensureExecutableFile(file, normalizeBundledPermissions);
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
catch {
|
|
1528
|
-
// Let the subsequent go build spawn fail with the real OS error.
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
/** Repair tool execution without widening an explicitly selected toolchain. */
|
|
1532
|
-
function ensureExecutableFile(file, normalizeBundledPermissions) {
|
|
1533
|
-
const mode = node_fs_1.default.statSync(file).mode & 0o7777;
|
|
1534
|
-
if (normalizeBundledPermissions) {
|
|
1535
|
-
if (mode !== 0o755)
|
|
1536
|
-
node_fs_1.default.chmodSync(file, 0o755);
|
|
1537
|
-
}
|
|
1538
|
-
else if ((mode & 0o111) === 0) {
|
|
1539
|
-
node_fs_1.default.chmodSync(file, mode | 0o100);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
function walkToolFiles(dir) {
|
|
1543
|
-
const out = [];
|
|
1544
|
-
let entries;
|
|
1545
|
-
try {
|
|
1546
|
-
entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
1547
|
-
}
|
|
1548
|
-
catch {
|
|
1549
|
-
return out;
|
|
1550
|
-
}
|
|
1551
|
-
for (const entry of entries) {
|
|
1552
|
-
const file = node_path_1.default.join(dir, entry.name);
|
|
1553
|
-
if (entry.isDirectory()) {
|
|
1554
|
-
out.push(...walkToolFiles(file));
|
|
1555
|
-
}
|
|
1556
|
-
else if (entry.isFile()) {
|
|
1557
|
-
out.push(file);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
return out;
|
|
1561
|
-
}
|
|
1562
|
-
function findTtscOverlayDirs() {
|
|
1563
|
-
const ttscRoot = node_path_1.default.resolve(__dirname, "..", "..", "..");
|
|
1564
|
-
const dirs = [];
|
|
1565
|
-
if (node_fs_1.default.existsSync(node_path_1.default.join(ttscRoot, "go.mod"))) {
|
|
1566
|
-
dirs.push(ttscRoot);
|
|
1567
|
-
}
|
|
1568
|
-
const shimRoot = node_path_1.default.join(ttscRoot, "shim");
|
|
1569
|
-
if (node_fs_1.default.existsSync(shimRoot)) {
|
|
1570
|
-
walkForGoMod(shimRoot, dirs);
|
|
1571
|
-
}
|
|
1572
|
-
dirs.sort();
|
|
1573
|
-
return dirs;
|
|
1574
|
-
}
|
|
1575
|
-
function walkForGoMod(dir, out) {
|
|
1576
|
-
let entries;
|
|
1577
|
-
try {
|
|
1578
|
-
entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
1579
|
-
}
|
|
1580
|
-
catch {
|
|
1581
|
-
return;
|
|
1582
|
-
}
|
|
1583
|
-
let hasGoMod = false;
|
|
1584
|
-
for (const entry of entries) {
|
|
1585
|
-
if (entry.isFile() && entry.name === "go.mod") {
|
|
1586
|
-
hasGoMod = true;
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
if (hasGoMod) {
|
|
1590
|
-
out.push(dir);
|
|
1591
|
-
}
|
|
1592
|
-
for (const entry of entries) {
|
|
1593
|
-
if (!entry.isDirectory())
|
|
1594
|
-
continue;
|
|
1595
|
-
if (shouldPruneDirectory(entry.name))
|
|
1596
|
-
continue;
|
|
1597
|
-
walkForGoMod(node_path_1.default.join(dir, entry.name), out);
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
/**
|
|
1601
|
-
* Resolve the directory where compiled plugin binaries are cached.
|
|
1602
|
-
*
|
|
1603
|
-
* Delegates to {@link resolveSourceBuildCachePaths}; kept as a thin accessor for
|
|
1604
|
-
* callers (and tests) that only need the plugin-binary root. Triggers the
|
|
1605
|
-
* opportunistic project-cache GC as a side effect for the default location.
|
|
1606
|
-
*/
|
|
1607
|
-
function resolvePluginCacheRoot(projectRoot, cacheDir, env = process.env) {
|
|
1608
|
-
const paths = resolveSourceBuildCachePaths(projectRoot, cacheDir, env);
|
|
1609
|
-
maybePruneSourceBuildCaches(paths, cacheDir, env);
|
|
1610
|
-
return paths.pluginRoot;
|
|
1611
|
-
}
|
|
1612
|
-
/**
|
|
1613
|
-
* Resolve all source-plugin build cache directories for one invocation.
|
|
1614
|
-
*
|
|
1615
|
-
* `pluginRoot` stores compiled plugin binaries; `goBuildRoot` is the Go object
|
|
1616
|
-
* cache passed as `GOCACHE` while ttsc builds those binaries. The default Go
|
|
1617
|
-
* cache lives under `root`; an explicit `TTSC_GO_CACHE_DIR` or `GOCACHE` keeps
|
|
1618
|
-
* its independently resolved location and ownership policy.
|
|
1619
|
-
*/
|
|
1620
|
-
function resolveSourceBuildCachePaths(projectRoot, cacheDir, env = process.env) {
|
|
1621
|
-
const root = resolveSourceBuildCacheRoot(projectRoot, cacheDir, env);
|
|
1622
|
-
const goBuild = resolveGoBuildCacheRoot(root, projectRoot, env);
|
|
1623
|
-
return {
|
|
1624
|
-
root,
|
|
1625
|
-
pluginRoot: node_path_1.default.join(root, PLUGIN_CACHE_DIRNAME),
|
|
1626
|
-
goBuildRoot: goBuild.root,
|
|
1627
|
-
goBuildRootSource: goBuild.source,
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
1630
|
-
/**
|
|
1631
|
-
* Resolve the cache root for one invocation.
|
|
1632
|
-
*
|
|
1633
|
-
* Priority:
|
|
1634
|
-
*
|
|
1635
|
-
* 1. Explicit `cacheDir` option (resolved relative to `projectRoot`);
|
|
1636
|
-
* 2. `TTSC_CACHE_DIR` environment variable (resolved absolute);
|
|
1637
|
-
* 3. `<workspaceRoot>/node_modules/.cache/ttsc` — project-local by default.
|
|
1638
|
-
*
|
|
1639
|
-
* There is deliberately NO global (`~/.cache`) fallback: the cache is scoped to
|
|
1640
|
-
* the workspace so it can never accumulate machine-wide, and `rm -rf
|
|
1641
|
-
* node_modules` reclaims it.
|
|
1642
|
-
*/
|
|
1643
|
-
function resolveSourceBuildCacheRoot(projectRoot, cacheDir, env) {
|
|
1644
|
-
if (cacheDir) {
|
|
1645
|
-
return node_path_1.default.resolve(projectRoot, cacheDir);
|
|
1646
|
-
}
|
|
1647
|
-
if (env.TTSC_CACHE_DIR) {
|
|
1648
|
-
// Anchor a relative TTSC_CACHE_DIR to the project root (not the process
|
|
1649
|
-
// cwd) so a programmatic host whose cwd differs from the project still
|
|
1650
|
-
// resolves — and later cleans — the same cache. Absolute values pass
|
|
1651
|
-
// through path.resolve unchanged.
|
|
1652
|
-
return node_path_1.default.resolve(projectRoot, env.TTSC_CACHE_DIR);
|
|
1653
|
-
}
|
|
1654
|
-
return node_path_1.default.join(resolveWorkspaceRoot(projectRoot), NODE_MODULES_DIRNAME, LOCAL_CACHE_PARENT_DIRNAME, TTSC_CACHE_DIRNAME);
|
|
1655
|
-
}
|
|
1656
|
-
/**
|
|
1657
|
-
* Resolve the monorepo/workspace root for `projectRoot` so every package shares
|
|
1658
|
-
* one cache and a plugin builds once per workspace, not once per package.
|
|
1659
|
-
*
|
|
1660
|
-
* Walks up from `projectRoot` and returns, in order of preference: the NEAREST
|
|
1661
|
-
* ancestor that is a workspace root (holds `pnpm-workspace.yaml`, or a
|
|
1662
|
-
* `package.json` with a `workspaces` field); else the nearest ancestor that
|
|
1663
|
-
* already contains a `node_modules` directory; else `projectRoot` itself.
|
|
1664
|
-
*
|
|
1665
|
-
* Nearest (not highest) so an unrelated ancestor that happens to declare
|
|
1666
|
-
* `workspaces` — for example a `package.json` in the user's home directory —
|
|
1667
|
-
* cannot pull the cache above the project's real monorepo root.
|
|
1668
|
-
*/
|
|
1669
|
-
function resolveWorkspaceRoot(projectRoot) {
|
|
1670
|
-
let dir = node_path_1.default.resolve(projectRoot);
|
|
1671
|
-
let nearestNodeModulesOwner = null;
|
|
1672
|
-
for (;;) {
|
|
1673
|
-
if (isWorkspaceRootDir(dir)) {
|
|
1674
|
-
return dir;
|
|
1675
|
-
}
|
|
1676
|
-
if (nearestNodeModulesOwner === null &&
|
|
1677
|
-
node_fs_1.default.existsSync(node_path_1.default.join(dir, NODE_MODULES_DIRNAME))) {
|
|
1678
|
-
nearestNodeModulesOwner = dir;
|
|
1679
|
-
}
|
|
1680
|
-
const parent = node_path_1.default.dirname(dir);
|
|
1681
|
-
if (parent === dir) {
|
|
1682
|
-
break;
|
|
1683
|
-
}
|
|
1684
|
-
dir = parent;
|
|
1685
|
-
}
|
|
1686
|
-
return nearestNodeModulesOwner ?? node_path_1.default.resolve(projectRoot);
|
|
1687
|
-
}
|
|
1688
|
-
function isWorkspaceRootDir(dir) {
|
|
1689
|
-
for (const marker of WORKSPACE_ROOT_MARKER_FILES) {
|
|
1690
|
-
if (node_fs_1.default.existsSync(node_path_1.default.join(dir, marker))) {
|
|
1691
|
-
return true;
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
return packageJsonDeclaresWorkspaces(node_path_1.default.join(dir, "package.json"));
|
|
1695
|
-
}
|
|
1696
|
-
function packageJsonDeclaresWorkspaces(packageJsonPath) {
|
|
1697
|
-
let text;
|
|
1698
|
-
try {
|
|
1699
|
-
text = node_fs_1.default.readFileSync(packageJsonPath, "utf8");
|
|
1700
|
-
}
|
|
1701
|
-
catch {
|
|
1702
|
-
return false;
|
|
1703
|
-
}
|
|
1704
|
-
try {
|
|
1705
|
-
const workspaces = JSON.parse(text)
|
|
1706
|
-
.workspaces;
|
|
1707
|
-
// A real workspace root declares a NON-EMPTY package list (an array, or an
|
|
1708
|
-
// object with a `packages` array). Ignore `false`, `[]`, `null`, or `{}` so
|
|
1709
|
-
// a disabled or empty declaration on an unrelated ancestor cannot hijack
|
|
1710
|
-
// the cache location.
|
|
1711
|
-
if (Array.isArray(workspaces)) {
|
|
1712
|
-
return workspaces.length > 0;
|
|
1713
|
-
}
|
|
1714
|
-
if (workspaces !== null && typeof workspaces === "object") {
|
|
1715
|
-
const packages = workspaces.packages;
|
|
1716
|
-
return Array.isArray(packages) && packages.length > 0;
|
|
1717
|
-
}
|
|
1718
|
-
return false;
|
|
1719
|
-
}
|
|
1720
|
-
catch {
|
|
1721
|
-
return false;
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
function resolveGoBuildCacheRoot(root, projectRoot, env) {
|
|
1725
|
-
if (env.TTSC_GO_CACHE_DIR) {
|
|
1726
|
-
// Anchor a relative TTSC_GO_CACHE_DIR to the project root, matching
|
|
1727
|
-
// TTSC_CACHE_DIR, so the build and a later `clean` from a different cwd
|
|
1728
|
-
// agree on the directory. Absolute values pass through unchanged.
|
|
1729
|
-
return {
|
|
1730
|
-
root: node_path_1.default.resolve(projectRoot, env.TTSC_GO_CACHE_DIR),
|
|
1731
|
-
source: "TTSC_GO_CACHE_DIR",
|
|
1732
|
-
};
|
|
1733
|
-
}
|
|
1734
|
-
if (env.GOCACHE && env.GOCACHE.length > 0) {
|
|
1735
|
-
return {
|
|
1736
|
-
root: env.GOCACHE,
|
|
1737
|
-
source: "GOCACHE",
|
|
1738
|
-
};
|
|
1739
|
-
}
|
|
1740
|
-
return {
|
|
1741
|
-
root: node_path_1.default.join(root, GO_BUILD_CACHE_DIRNAME),
|
|
1742
|
-
source: "ttsc-cache",
|
|
1743
|
-
};
|
|
1744
|
-
}
|
|
1745
|
-
function maybePruneSourceBuildCaches(paths, cacheDir, env = process.env) {
|
|
1746
|
-
// GC only the default (workspace-local) location. When the user pins an
|
|
1747
|
-
// explicit `cacheDir`/`TTSC_CACHE_DIR`, they own its lifetime, so ttsc must
|
|
1748
|
-
// not delete entries out from under them. `env` is the effective instance
|
|
1749
|
-
// environment so a programmatic caller that pins `TTSC_CACHE_DIR` only in
|
|
1750
|
-
// `context.env` is honored without leaning on the shared `process.env`.
|
|
1751
|
-
if (!cacheDir && !env.TTSC_CACHE_DIR) {
|
|
1752
|
-
prunePluginCacheRoot(paths.pluginRoot);
|
|
1753
|
-
if (paths.goBuildRootSource === "ttsc-cache") {
|
|
1754
|
-
pruneGoBuildCacheRoot(paths.goBuildRoot);
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
/** Report whether this invocation owns and automatically maintains both caches. */
|
|
1759
|
-
function shouldManageSourceBuildCaches(paths, cacheDir, env) {
|
|
1760
|
-
return (!cacheDir && !env.TTSC_CACHE_DIR && paths.goBuildRootSource === "ttsc-cache");
|
|
1761
|
-
}
|
|
1762
|
-
/**
|
|
1763
|
-
* Return every directory `ttsc clean` should remove for `projectRoot`.
|
|
1764
|
-
*
|
|
1765
|
-
* Covers the resolved plugin-binary root, a safely named nested `go-build/`, a
|
|
1766
|
-
* ttsc-owned Go build cache that lives OUTSIDE that root (`TTSC_GO_CACHE_DIR`),
|
|
1767
|
-
* and the two legacy project-local caches. A user-provided `GOCACHE` is never
|
|
1768
|
-
* removed. Pure over `env`, so the CLI passes `process.env` and a programmatic
|
|
1769
|
-
* caller can pass an injected environment.
|
|
1770
|
-
*/
|
|
1771
|
-
function resolveCleanTargets(projectRoot, cacheDir, env = process.env) {
|
|
1772
|
-
const paths = resolveSourceBuildCachePaths(projectRoot, cacheDir, env);
|
|
1773
|
-
// Remove ttsc-OWNED directories only, never the parent cache root.
|
|
1774
|
-
const targets = [paths.pluginRoot];
|
|
1775
|
-
// ttsc's nested `<root>/go-build` is only safe to delete when we are certain
|
|
1776
|
-
// the root belongs to ttsc: the default `node_modules/.cache/ttsc`, or a root
|
|
1777
|
-
// the user explicitly named `ttsc`. Under a shared root (e.g.
|
|
1778
|
-
// `TTSC_CACHE_DIR=~/.cache`) a bare `<root>/go-build` could be the user's
|
|
1779
|
-
// machine-wide GOCACHE, so it must never be removed by name.
|
|
1780
|
-
const isTtscOwnedRoot = (!cacheDir && !env.TTSC_CACHE_DIR) ||
|
|
1781
|
-
node_path_1.default.basename(paths.root) === TTSC_CACHE_DIRNAME;
|
|
1782
|
-
if (isTtscOwnedRoot) {
|
|
1783
|
-
targets.push(node_path_1.default.join(paths.root, GO_BUILD_CACHE_DIRNAME));
|
|
1784
|
-
}
|
|
1785
|
-
// An explicit TTSC_GO_CACHE_DIR is a ttsc-dedicated external cache; a
|
|
1786
|
-
// user-provided GOCACHE (source "GOCACHE") is never removed.
|
|
1787
|
-
if (paths.goBuildRootSource === "TTSC_GO_CACHE_DIR") {
|
|
1788
|
-
targets.push(paths.goBuildRoot);
|
|
1789
|
-
}
|
|
1790
|
-
targets.push(node_path_1.default.join(projectRoot, NODE_MODULES_DIRNAME, ".ttsc"));
|
|
1791
|
-
targets.push(node_path_1.default.join(projectRoot, ".ttsc"));
|
|
1792
|
-
return targets;
|
|
1793
|
-
}
|
|
1794
|
-
/**
|
|
1795
|
-
* Machine-global cache directories created by pre-0.17 ttsc releases (XDG /
|
|
1796
|
-
* AppData / Library / `~/.cache`). ttsc no longer writes to any of these, but
|
|
1797
|
-
* an upgraded machine can still hold a multi-GB orphaned cache here, so `ttsc
|
|
1798
|
-
* clean` offers them for removal to reclaim that disk. Each entry is the whole
|
|
1799
|
-
* `<userCacheRoot>/ttsc` directory (both its `plugins` and `go-build`), which
|
|
1800
|
-
* was entirely ttsc-owned in those releases and is safe to remove.
|
|
1801
|
-
*/
|
|
1802
|
-
function legacyGlobalCacheTargets() {
|
|
1803
|
-
const roots = new Set();
|
|
1804
|
-
const home = node_os_1.default.homedir();
|
|
1805
|
-
const xdg = process.env.XDG_CACHE_HOME;
|
|
1806
|
-
if (xdg && node_path_1.default.isAbsolute(xdg)) {
|
|
1807
|
-
roots.add(node_path_1.default.join(xdg, TTSC_CACHE_DIRNAME));
|
|
1808
|
-
}
|
|
1809
|
-
if (process.platform === "win32") {
|
|
1810
|
-
const local = process.env.LOCALAPPDATA;
|
|
1811
|
-
if (local && node_path_1.default.isAbsolute(local)) {
|
|
1812
|
-
roots.add(node_path_1.default.join(local, TTSC_CACHE_DIRNAME));
|
|
1813
|
-
}
|
|
1814
|
-
if (home) {
|
|
1815
|
-
roots.add(node_path_1.default.join(home, "AppData", "Local", TTSC_CACHE_DIRNAME));
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
else if (process.platform === "darwin" && home) {
|
|
1819
|
-
roots.add(node_path_1.default.join(home, "Library", "Caches", TTSC_CACHE_DIRNAME));
|
|
1820
|
-
}
|
|
1821
|
-
if (home) {
|
|
1822
|
-
roots.add(node_path_1.default.join(home, ".cache", TTSC_CACHE_DIRNAME));
|
|
1823
|
-
}
|
|
1824
|
-
return [...roots];
|
|
1825
|
-
}
|
|
1826
|
-
/** Report whether `child` equals `parent` or is nested beneath it. */
|
|
1827
|
-
function isPathWithin(child, parent) {
|
|
1828
|
-
const rel = node_path_1.default.relative(parent, child);
|
|
1829
|
-
return (rel === "" ||
|
|
1830
|
-
(rel !== ".." && !rel.startsWith(`..${node_path_1.default.sep}`) && !node_path_1.default.isAbsolute(rel)));
|
|
1831
|
-
}
|
|
1832
|
-
function resolveGoCompiler(env = process.env) {
|
|
1833
|
-
const explicit = env.TTSC_GO_BINARY;
|
|
1834
|
-
if (explicit && explicit.length > 0) {
|
|
1835
|
-
return { binary: explicit, bundled: false };
|
|
1836
|
-
}
|
|
1837
|
-
try {
|
|
1838
|
-
return {
|
|
1839
|
-
binary: (0, node_module_1.createRequire)(__filename).resolve(`@ttsc/${process.platform}-${process.arch}/bin/go/bin/${process.platform === "win32" ? "go.exe" : "go"}`),
|
|
1840
|
-
bundled: true,
|
|
1841
|
-
};
|
|
1842
|
-
}
|
|
1843
|
-
catch {
|
|
1844
|
-
/* fall through */
|
|
1845
|
-
}
|
|
1846
|
-
const platformPackage = node_path_1.default.resolve(__dirname, "..", "..", "..", "..", `ttsc-${process.platform}-${process.arch}`, "bin", "go", "bin", process.platform === "win32" ? "go.exe" : "go");
|
|
1847
|
-
if (node_fs_1.default.existsSync(platformPackage)) {
|
|
1848
|
-
return { binary: platformPackage, bundled: true };
|
|
1849
|
-
}
|
|
1850
|
-
const local = node_path_1.default.resolve(__dirname, "..", "..", "..", "..", "native", "go", "bin", process.platform === "win32" ? "go.exe" : "go");
|
|
1851
|
-
if (node_fs_1.default.existsSync(local))
|
|
1852
|
-
return { binary: local, bundled: true };
|
|
1853
|
-
const homeSdk = node_path_1.default.join(env.HOME ?? "", "go-sdk", "go", "bin", process.platform === "win32" ? "go.exe" : "go");
|
|
1854
|
-
if (node_fs_1.default.existsSync(homeSdk))
|
|
1855
|
-
return { binary: homeSdk, bundled: false };
|
|
1856
|
-
return { binary: "go", bundled: false };
|
|
1857
|
-
}
|
|
1858
|
-
/**
|
|
1859
|
-
* Compute a deterministic SHA-256 cache key for a plugin build.
|
|
1860
|
-
*
|
|
1861
|
-
* The key covers every input that can produce a different binary: ttsc/tsgo
|
|
1862
|
-
* versions, platform, entry package, Go compiler identity, Go build environment
|
|
1863
|
-
* variables, overlay module sources, plugin source files, and contributor
|
|
1864
|
-
* source files. Contributors are sorted by name so declaration order does not
|
|
1865
|
-
* affect the key.
|
|
1866
|
-
*
|
|
1867
|
-
* Exposed for testing and for the `ttsc cache` CLI command.
|
|
1868
|
-
*/
|
|
1869
|
-
function computeCacheKey(inputs) {
|
|
1870
|
-
const env = inputs.env ?? process.env;
|
|
1871
|
-
const filesystem = {
|
|
1872
|
-
readFile: inputs.filesystem?.readFile ?? DEFAULT_SOURCE_BUILD_FILESYSTEM.readFile,
|
|
1873
|
-
};
|
|
1874
|
-
const goBinary = inputs.goBinary === undefined
|
|
1875
|
-
? undefined
|
|
1876
|
-
: resolveGoToolForBuild(inputs.goBinary, env, inputs.dir);
|
|
1877
|
-
const hash = node_crypto_1.default.createHash("sha256");
|
|
1878
|
-
hash.update(`ttsc=${inputs.ttscVersion}\n`);
|
|
1879
|
-
hash.update(`tsgo=${inputs.tsgoVersion}\n`);
|
|
1880
|
-
hash.update(`platform=${process.platform}/${process.arch}\n`);
|
|
1881
|
-
hash.update(`entry=${inputs.entry}\n`);
|
|
1882
|
-
if (goBinary !== undefined) {
|
|
1883
|
-
hash.update(`go=${resolveGoCompilerIdentity(goBinary, env, inputs.dir)}\n`);
|
|
1884
|
-
}
|
|
1885
|
-
hashGoBuildEnvironment(hash, goBinary, inputs.dir, env, filesystem);
|
|
1886
|
-
hashExternalGoBuildEnvironment(hash, env);
|
|
1887
|
-
hashSourceDirectory(hash, "plugin", inputs.dir);
|
|
1888
|
-
for (const [index, dir] of [...(inputs.overlayDirs ?? [])].sort().entries()) {
|
|
1889
|
-
hashSourceDirectory(hash, `overlay:${index}`, dir);
|
|
1890
|
-
}
|
|
1891
|
-
// Hash contributors in sorted-by-name order so two consumers with the
|
|
1892
|
-
// same logical set produce the same key regardless of declaration order
|
|
1893
|
-
// in the host's plugin descriptor.
|
|
1894
|
-
const sortedContributors = [...(inputs.contributors ?? [])].sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1);
|
|
1895
|
-
for (const contributor of sortedContributors) {
|
|
1896
|
-
hashSourceDirectory(hash, `contributor:${contributor.name}`, contributor.source);
|
|
1897
|
-
}
|
|
1898
|
-
return hash.digest("hex").slice(0, 32);
|
|
1899
|
-
}
|
|
1900
|
-
function hashSourceDirectory(hash, label, root) {
|
|
1901
|
-
hash.update(`dir=${label}\n`);
|
|
1902
|
-
for (const file of collectSourceFiles(root)) {
|
|
1903
|
-
const rel = node_path_1.default.relative(root, file).replace(/\\/g, "/");
|
|
1904
|
-
hash.update(`f=${rel}\n`);
|
|
1905
|
-
hash.update(node_fs_1.default.readFileSync(file));
|
|
1906
|
-
hash.update("\n");
|
|
1907
|
-
}
|
|
1908
|
-
}
|
|
1909
|
-
function collectSourceFiles(root) {
|
|
1910
|
-
const out = [];
|
|
1911
|
-
walk(root, out);
|
|
1912
|
-
out.sort();
|
|
1913
|
-
return out;
|
|
1914
|
-
}
|
|
1915
|
-
function walk(dir, out) {
|
|
1916
|
-
let entries;
|
|
1917
|
-
try {
|
|
1918
|
-
entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
1919
|
-
}
|
|
1920
|
-
catch {
|
|
1921
|
-
return;
|
|
1922
|
-
}
|
|
1923
|
-
for (const entry of entries) {
|
|
1924
|
-
const full = node_path_1.default.join(dir, entry.name);
|
|
1925
|
-
if (entry.isDirectory()) {
|
|
1926
|
-
if (shouldPruneDirectory(entry.name))
|
|
1927
|
-
continue;
|
|
1928
|
-
walk(full, out);
|
|
1929
|
-
continue;
|
|
1930
|
-
}
|
|
1931
|
-
if (!entry.isFile())
|
|
1932
|
-
continue;
|
|
1933
|
-
if (shouldOmitSourceFile(entry.name))
|
|
1934
|
-
continue;
|
|
1935
|
-
if (!isHashableFile(entry.name))
|
|
1936
|
-
continue;
|
|
1937
|
-
out.push(full);
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
function shouldPruneDirectory(name) {
|
|
1941
|
-
return PRUNE_DIRS.has(name);
|
|
1942
|
-
}
|
|
1943
|
-
function shouldOmitSourceFile(name) {
|
|
1944
|
-
if (GENERATED_WORKSPACE_FILES.has(name))
|
|
1945
|
-
return true;
|
|
1946
|
-
// npm-pack tarballs and macOS/Windows editor sidecars are local
|
|
1947
|
-
// build artifacts that drift independently of the Go source. They
|
|
1948
|
-
// would otherwise enter the cache key and bust the cached binary on
|
|
1949
|
-
// every unrelated `npm pack` or editor save.
|
|
1950
|
-
if (name.endsWith(".tgz") || name.endsWith(".tar.gz"))
|
|
1951
|
-
return true;
|
|
1952
|
-
if (name === ".DS_Store" || name === "Thumbs.db")
|
|
1953
|
-
return true;
|
|
1954
|
-
return false;
|
|
1955
|
-
}
|
|
1956
|
-
function isHashableFile(name) {
|
|
1957
|
-
return !name.endsWith("~");
|
|
1958
|
-
}
|
|
1959
|
-
// Per-process memo for the Go compiler identity. `computeCacheKey` runs once
|
|
1960
|
-
// per source plugin, so an N-plugin project that points every plugin at the
|
|
1961
|
-
// same toolchain would otherwise pay N `go version` spawns plus N ~150MB
|
|
1962
|
-
// binary hashes for a value that does not change between plugins. The result
|
|
1963
|
-
// is a pure function of the go binary's resolved real path plus its on-disk
|
|
1964
|
-
// content; the memo key therefore mixes the resolved real path with a cheap
|
|
1965
|
-
// content signature (filesystem identity, mode, byte size, and nanosecond
|
|
1966
|
-
// change/modify times). That signature changes if a long-lived host rewrites
|
|
1967
|
-
// or atomically replaces the binary between calls, so the memo
|
|
1968
|
-
// re-derives the identity exactly as the un-memoized code would and the
|
|
1969
|
-
// cache-key bytes stay byte-for-byte identical to today. The selected compiler
|
|
1970
|
-
// path is shared by every build subprocess on Windows, while `go version` uses
|
|
1971
|
-
// the same effective cwd and environment as the cache-key `go env` query. The
|
|
1972
|
-
// memo key includes that context so an environment-sensitive wrapper cannot
|
|
1973
|
-
// lend its version result to another compiler invocation.
|
|
1974
|
-
const goCompilerIdentityCache = new Map();
|
|
1975
|
-
function resolveGoCompilerIdentity(goBinary, env = process.env, cwd = process.cwd()) {
|
|
1976
|
-
const selected = resolveGoToolForBuild(goBinary, env, cwd);
|
|
1977
|
-
const resolved = process.platform === "win32"
|
|
1978
|
-
? resolveRealPath(selected)
|
|
1979
|
-
: resolveExecutableIdentityPath(selected, env, cwd);
|
|
1980
|
-
const compilerEnv = goBuildEnv(selected, undefined, env);
|
|
1981
|
-
const memoKey = goCompilerIdentityMemoKey(goBinary, resolved, compilerEnv, cwd);
|
|
1982
|
-
if (memoKey !== null) {
|
|
1983
|
-
const cached = goCompilerIdentityCache.get(memoKey);
|
|
1984
|
-
if (cached !== undefined) {
|
|
1985
|
-
return cached;
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
const identity = computeGoCompilerIdentity(selected, resolved, compilerEnv, cwd);
|
|
1989
|
-
if (memoKey !== null) {
|
|
1990
|
-
goCompilerIdentityCache.set(memoKey, identity);
|
|
1991
|
-
}
|
|
1992
|
-
return identity;
|
|
1993
|
-
}
|
|
1994
|
-
// Build a memo key that pins both the resolved binary path and its current
|
|
1995
|
-
// content. Returns null (skip caching, recompute) when the binary cannot be
|
|
1996
|
-
// stat-ed, so the rare unstattable case never serves a stale identity.
|
|
1997
|
-
function goCompilerIdentityMemoKey(goBinary, resolved, env, cwd) {
|
|
1998
|
-
try {
|
|
1999
|
-
const stat = node_fs_1.default.statSync(resolved, { bigint: true });
|
|
2000
|
-
const context = node_crypto_1.default.createHash("sha256");
|
|
2001
|
-
context.update(cwd);
|
|
2002
|
-
for (const [key, value] of Object.entries(env).sort(([left], [right]) => left === right ? 0 : left < right ? -1 : 1)) {
|
|
2003
|
-
if (value === undefined)
|
|
2004
|
-
continue;
|
|
2005
|
-
context.update(`\0${key.length}:${key}${value.length}:${value}`);
|
|
2006
|
-
}
|
|
2007
|
-
return [
|
|
2008
|
-
goBinary,
|
|
2009
|
-
resolved,
|
|
2010
|
-
stat.dev,
|
|
2011
|
-
stat.ino,
|
|
2012
|
-
stat.mode,
|
|
2013
|
-
stat.size,
|
|
2014
|
-
stat.mtimeNs,
|
|
2015
|
-
stat.ctimeNs,
|
|
2016
|
-
context.digest("hex"),
|
|
2017
|
-
].join("\0");
|
|
2018
|
-
}
|
|
2019
|
-
catch {
|
|
2020
|
-
return null;
|
|
2021
|
-
}
|
|
2022
|
-
}
|
|
2023
|
-
function computeGoCompilerIdentity(goBinary, resolved, env, cwd) {
|
|
2024
|
-
if (!node_fs_1.default.existsSync(resolved)) {
|
|
2025
|
-
return "missing";
|
|
2026
|
-
}
|
|
2027
|
-
const version = spawnGoTool(goBinary, ["version"], {
|
|
2028
|
-
cwd,
|
|
2029
|
-
encoding: "utf8",
|
|
2030
|
-
env,
|
|
2031
|
-
windowsHide: true,
|
|
2032
|
-
});
|
|
2033
|
-
const versionText = version.error !== undefined
|
|
2034
|
-
? (version.error.code ?? version.error.message)
|
|
2035
|
-
: `${version.status ?? 0}:${version.stdout}${version.stderr}`;
|
|
2036
|
-
const binaryHash = hashFile(resolved);
|
|
2037
|
-
return `sha256:${binaryHash}:${versionText}`;
|
|
2038
|
-
}
|
|
2039
|
-
function resolveExecutableIdentityPath(binary, env = process.env, cwd = process.cwd()) {
|
|
2040
|
-
const resolved = findExecutablePath(binary, env, cwd);
|
|
2041
|
-
return resolved === null ? binary : resolveRealPath(resolved);
|
|
2042
|
-
}
|
|
2043
|
-
/** Pin Windows PATH and command-wrapper lookup to one build-wide target. */
|
|
2044
|
-
function resolveGoToolForBuild(binary, env, cwd) {
|
|
2045
|
-
if (process.platform !== "win32")
|
|
2046
|
-
return binary;
|
|
2047
|
-
return resolveWindowsGoTool(binary, env, cwd).location ?? binary;
|
|
2048
|
-
}
|
|
2049
|
-
function findExecutablePath(binary, env, cwd) {
|
|
2050
|
-
for (const candidate of executableSearchBases(binary, env, cwd)) {
|
|
2051
|
-
const resolved = findExecutableCandidate(candidate, env);
|
|
2052
|
-
if (resolved !== null)
|
|
2053
|
-
return resolved;
|
|
2054
|
-
}
|
|
2055
|
-
return null;
|
|
2056
|
-
}
|
|
2057
|
-
/** Preserve libuv's native target before falling back to cmd/bat wrappers. */
|
|
2058
|
-
function resolveWindowsGoTool(binary, env, cwd) {
|
|
2059
|
-
const candidates = executableSearchBases(binary, env, cwd);
|
|
2060
|
-
if (isWindowsCommandWrapper(binary)) {
|
|
2061
|
-
return {
|
|
2062
|
-
location: candidates.find(isExecutableFile) ?? null,
|
|
2063
|
-
wrapper: true,
|
|
2064
|
-
};
|
|
2065
|
-
}
|
|
2066
|
-
const hasExtension = windowsFileNameHasExtension(binary);
|
|
2067
|
-
for (const candidate of candidates) {
|
|
2068
|
-
if (hasExtension && isExecutableFile(candidate)) {
|
|
2069
|
-
return { location: candidate, wrapper: false };
|
|
2070
|
-
}
|
|
2071
|
-
for (const extension of [".com", ".exe"]) {
|
|
2072
|
-
const executable = candidate + extension;
|
|
2073
|
-
if (isExecutableFile(executable)) {
|
|
2074
|
-
return { location: executable, wrapper: false };
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
const wrapperExtensions = windowsExecutableExtensions(env).filter((ext) => /\.(?:bat|cmd)$/i.test(ext));
|
|
2079
|
-
for (const candidate of candidates) {
|
|
2080
|
-
for (const extension of wrapperExtensions) {
|
|
2081
|
-
const executable = candidate + extension;
|
|
2082
|
-
if (isExecutableFile(executable)) {
|
|
2083
|
-
return { location: executable, wrapper: true };
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
|
-
return { location: null, wrapper: false };
|
|
2088
|
-
}
|
|
2089
|
-
function executableSearchBases(binary, env, cwd) {
|
|
2090
|
-
if (node_path_1.default.isAbsolute(binary))
|
|
2091
|
-
return [binary];
|
|
2092
|
-
if (hasPathQualifier(binary))
|
|
2093
|
-
return [node_path_1.default.resolve(cwd, binary)];
|
|
2094
|
-
const directories = process.platform === "win32"
|
|
2095
|
-
? splitWindowsSearchPath(readPathEnvironment(env))
|
|
2096
|
-
// libuv skips only genuinely empty slices. A quoted-empty slice
|
|
2097
|
-
// survives that check, unquotes to "", and therefore names cwd.
|
|
2098
|
-
.filter((entry) => entry.length > 0)
|
|
2099
|
-
.map(unquoteWindowsSearchEntry)
|
|
2100
|
-
: readPathEnvironment(env).split(node_path_1.default.delimiter);
|
|
2101
|
-
const noDefaultCurrentDirectory = process.platform === "win32"
|
|
2102
|
-
? readWindowsEnvironmentValue(process.env, "NoDefaultCurrentDirectoryInExePath")
|
|
2103
|
-
: undefined;
|
|
2104
|
-
if (process.platform === "win32" && noDefaultCurrentDirectory === undefined) {
|
|
2105
|
-
directories.unshift(cwd);
|
|
2106
|
-
}
|
|
2107
|
-
return directories.map((dir) => node_path_1.default.resolve(cwd, dir, binary));
|
|
2108
|
-
}
|
|
2109
|
-
function findExecutableCandidate(candidate, env) {
|
|
2110
|
-
if (isExecutableFile(candidate))
|
|
2111
|
-
return candidate;
|
|
2112
|
-
if (process.platform !== "win32")
|
|
2113
|
-
return null;
|
|
2114
|
-
// Probe every PATHEXT extension, not just `.exe`, so a compiler backed by a
|
|
2115
|
-
// `.cmd`/`.bat` wrapper is both launched correctly and hashed into the cache
|
|
2116
|
-
// key. Otherwise the wrapper reads as missing and changes do not invalidate
|
|
2117
|
-
// the cached plugin binary.
|
|
2118
|
-
for (const ext of windowsExecutableExtensions(env)) {
|
|
2119
|
-
const executable = `${candidate}${ext}`;
|
|
2120
|
-
if (isExecutableFile(executable))
|
|
2121
|
-
return executable;
|
|
2122
|
-
}
|
|
2123
|
-
return null;
|
|
2124
|
-
}
|
|
2125
|
-
function isExecutableFile(location) {
|
|
2126
|
-
try {
|
|
2127
|
-
return node_fs_1.default.statSync(location).isFile();
|
|
2128
|
-
}
|
|
2129
|
-
catch {
|
|
2130
|
-
return false;
|
|
2131
|
-
}
|
|
2132
|
-
}
|
|
2133
|
-
function hasPathQualifier(location) {
|
|
2134
|
-
return (location.includes(node_path_1.default.sep) ||
|
|
2135
|
-
(process.platform === "win32" &&
|
|
2136
|
-
(location.includes("/") || /^[a-zA-Z]:/.test(location))));
|
|
2137
|
-
}
|
|
2138
|
-
function windowsFileNameHasExtension(location) {
|
|
2139
|
-
const name = node_path_1.default.basename(location);
|
|
2140
|
-
const dot = name.indexOf(".");
|
|
2141
|
-
return dot >= 0 && dot < name.length - 1;
|
|
2142
|
-
}
|
|
2143
|
-
function splitWindowsSearchPath(value) {
|
|
2144
|
-
const entries = [];
|
|
2145
|
-
let start = 0;
|
|
2146
|
-
let quote = "";
|
|
2147
|
-
for (let index = 0; index < value.length; index++) {
|
|
2148
|
-
const character = value[index];
|
|
2149
|
-
if (quote !== "") {
|
|
2150
|
-
if (character === quote)
|
|
2151
|
-
quote = "";
|
|
2152
|
-
}
|
|
2153
|
-
else if ((character === '"' || character === "'") && index === start) {
|
|
2154
|
-
quote = character;
|
|
2155
|
-
}
|
|
2156
|
-
else if (character === ";") {
|
|
2157
|
-
entries.push(value.slice(start, index));
|
|
2158
|
-
start = index + 1;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
entries.push(value.slice(start));
|
|
2162
|
-
return entries;
|
|
2163
|
-
}
|
|
2164
|
-
function unquoteWindowsSearchEntry(location) {
|
|
2165
|
-
const first = location[0];
|
|
2166
|
-
const withoutFirst = first === '"' || first === "'" ? location.slice(1) : location;
|
|
2167
|
-
const last = withoutFirst[withoutFirst.length - 1];
|
|
2168
|
-
return last === '"' || last === "'"
|
|
2169
|
-
? withoutFirst.slice(0, -1)
|
|
2170
|
-
: withoutFirst;
|
|
2171
|
-
}
|
|
2172
|
-
function windowsExecutableExtensions(env = process.env) {
|
|
2173
|
-
const pathext = readWindowsEnvironmentValue(env, "PATHEXT");
|
|
2174
|
-
const raw = pathext && pathext.length > 0 ? pathext : ".COM;.EXE;.BAT;.CMD";
|
|
2175
|
-
return splitWindowsSearchPath(raw)
|
|
2176
|
-
.map(unquoteWindowsSearchEntry)
|
|
2177
|
-
.map((ext) => ext.toLowerCase())
|
|
2178
|
-
.filter((ext) => ext.length > 0);
|
|
2179
|
-
}
|
|
2180
|
-
function readPathEnvironment(env = process.env) {
|
|
2181
|
-
return process.platform === "win32"
|
|
2182
|
-
? (readWindowsEnvironmentValue(env, "PATH") ??
|
|
2183
|
-
readWindowsEnvironmentValue(process.env, "PATH") ??
|
|
2184
|
-
"")
|
|
2185
|
-
: (env.PATH ?? "/usr/bin:/bin");
|
|
2186
|
-
}
|
|
2187
|
-
function readWindowsEnvironmentValue(env, name) {
|
|
2188
|
-
const exact = env[name];
|
|
2189
|
-
if (exact !== undefined)
|
|
2190
|
-
return exact;
|
|
2191
|
-
const normalized = name.toLowerCase();
|
|
2192
|
-
const key = Object.keys(env)
|
|
2193
|
-
.filter((candidate) => candidate.toLowerCase() === normalized)
|
|
2194
|
-
.sort()[0];
|
|
2195
|
-
return key === undefined ? undefined : env[key];
|
|
2196
|
-
}
|
|
2197
|
-
function resolveRealPath(location) {
|
|
2198
|
-
try {
|
|
2199
|
-
return node_fs_1.default.realpathSync(location);
|
|
2200
|
-
}
|
|
2201
|
-
catch {
|
|
2202
|
-
return location;
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2205
|
-
function hashFile(file) {
|
|
2206
|
-
const hash = node_crypto_1.default.createHash("sha256");
|
|
2207
|
-
hash.update(node_fs_1.default.readFileSync(file));
|
|
2208
|
-
return hash.digest("hex");
|
|
2209
|
-
}
|
|
2210
|
-
function hashGoBuildEnvironment(hash, goBinary, cwd, env, filesystem) {
|
|
2211
|
-
const values = resolveGoBuildEnvironment(goBinary, cwd, env, filesystem);
|
|
2212
|
-
for (const key of GO_BUILD_ENV_KEYS) {
|
|
2213
|
-
const value = values.get(key);
|
|
2214
|
-
if (value !== undefined && value !== "") {
|
|
2215
|
-
hash.update(`${key}=${value}\n`);
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
function resolveGoBuildEnvironment(goBinary, cwd, env, filesystem) {
|
|
2220
|
-
const values = new Map();
|
|
2221
|
-
if (goBinary !== undefined) {
|
|
2222
|
-
const result = spawnGoTool(goBinary, ["env", "-json", ...GO_BUILD_ENV_KEYS], {
|
|
2223
|
-
cwd,
|
|
2224
|
-
encoding: "utf8",
|
|
2225
|
-
env: goBuildEnv(goBinary, undefined, env),
|
|
2226
|
-
windowsHide: true,
|
|
2227
|
-
});
|
|
2228
|
-
if (result.error === undefined && result.status === 0) {
|
|
2229
|
-
try {
|
|
2230
|
-
const parsed = JSON.parse(result.stdout);
|
|
2231
|
-
for (const key of GO_BUILD_ENV_KEYS) {
|
|
2232
|
-
const raw = parsed[key];
|
|
2233
|
-
if (typeof raw === "string" && raw !== "") {
|
|
2234
|
-
values.set(key, normalizeGoBuildEnvValue(key, raw, env, filesystem));
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
catch {
|
|
2239
|
-
// Fall back to the effective env below; a cache key is still better
|
|
2240
|
-
// than failing before `go build` can produce the actionable error.
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
}
|
|
2244
|
-
for (const key of GO_BUILD_ENV_KEYS) {
|
|
2245
|
-
if (values.has(key))
|
|
2246
|
-
continue;
|
|
2247
|
-
const value = env[key];
|
|
2248
|
-
if (value !== undefined && value !== "") {
|
|
2249
|
-
values.set(key, normalizeGoBuildEnvValue(key, value, env, filesystem));
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
return values;
|
|
2253
|
-
}
|
|
2254
|
-
function normalizeGoBuildEnvValue(key, value, env, filesystem) {
|
|
2255
|
-
if (key === "GOROOT") {
|
|
2256
|
-
return resolveGoRootCacheIdentity(value, filesystem);
|
|
2257
|
-
}
|
|
2258
|
-
if (GO_BUILD_COMMAND_ENV_KEYS.has(key)) {
|
|
2259
|
-
return `${value}\0${resolveCommandCacheIdentity(value, env)}`;
|
|
2260
|
-
}
|
|
2261
|
-
return value;
|
|
2262
|
-
}
|
|
2263
|
-
function resolveCommandCacheIdentity(command, env) {
|
|
2264
|
-
const executable = firstCommandToken(command);
|
|
2265
|
-
if (executable === null) {
|
|
2266
|
-
return "command:empty";
|
|
2267
|
-
}
|
|
2268
|
-
const resolved = resolveExecutableIdentityPath(executable, env);
|
|
2269
|
-
if (!node_fs_1.default.existsSync(resolved)) {
|
|
2270
|
-
return `command:missing:${executable}`;
|
|
2271
|
-
}
|
|
2272
|
-
try {
|
|
2273
|
-
return `command:sha256:${hashFile(resolved)}`;
|
|
2274
|
-
}
|
|
2275
|
-
catch {
|
|
2276
|
-
return `command:unreadable:${resolved}`;
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
function firstCommandToken(command) {
|
|
2280
|
-
const trimmed = command.trim();
|
|
2281
|
-
if (trimmed === "") {
|
|
2282
|
-
return null;
|
|
2283
|
-
}
|
|
2284
|
-
const quote = trimmed[0];
|
|
2285
|
-
if (quote === "'" || quote === '"') {
|
|
2286
|
-
const end = trimmed.indexOf(quote, 1);
|
|
2287
|
-
return end === -1 ? trimmed.slice(1) : trimmed.slice(1, end);
|
|
2288
|
-
}
|
|
2289
|
-
return trimmed.split(/\s+/)[0] ?? null;
|
|
2290
|
-
}
|
|
2291
|
-
function hashExternalGoBuildEnvironment(hash, env) {
|
|
2292
|
-
for (const key of EXTERNAL_GO_BUILD_ENV_KEYS) {
|
|
2293
|
-
const value = env[key];
|
|
2294
|
-
if (value !== undefined && value !== "") {
|
|
2295
|
-
hash.update(`${key}=${value}\n`);
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
}
|
|
2299
|
-
// GOROOT is immutable during normal use but contributes roughly 140 MiB of
|
|
2300
|
-
// source/tool content to every plugin key. Retain only the final pathless
|
|
2301
|
-
// content identity, guarded by a fresh metadata manifest on every call. A
|
|
2302
|
-
// changed or incomplete manifest falls through to the historical full read.
|
|
2303
|
-
const goRootIdentityCache = new Map();
|
|
2304
|
-
function resolveGoRootCacheIdentity(goRoot, filesystem) {
|
|
2305
|
-
const resolved = resolveRealPath(goRoot);
|
|
2306
|
-
if (!node_fs_1.default.existsSync(resolved)) {
|
|
2307
|
-
return `missing:${goRoot}`;
|
|
2308
|
-
}
|
|
2309
|
-
const snapshot = collectGoRootIdentitySnapshot(resolved);
|
|
2310
|
-
if (snapshot.complete) {
|
|
2311
|
-
const cached = goRootIdentityCache.get(resolved);
|
|
2312
|
-
if (cached?.signature === snapshot.signature) {
|
|
2313
|
-
return cached.identity;
|
|
2314
|
-
}
|
|
2315
|
-
}
|
|
2316
|
-
const hash = node_crypto_1.default.createHash("sha256");
|
|
2317
|
-
for (const file of snapshot.files) {
|
|
2318
|
-
const relative = node_path_1.default.relative(resolved, file).replace(/\\/g, "/");
|
|
2319
|
-
hash.update(`f=${relative}\n`);
|
|
2320
|
-
hash.update(filesystem.readFile(file));
|
|
2321
|
-
hash.update("\n");
|
|
2322
|
-
}
|
|
2323
|
-
const identity = `sha256:${hash.digest("hex")}`;
|
|
2324
|
-
if (snapshot.complete) {
|
|
2325
|
-
goRootIdentityCache.set(resolved, {
|
|
2326
|
-
identity,
|
|
2327
|
-
signature: snapshot.signature,
|
|
2328
|
-
});
|
|
2329
|
-
}
|
|
2330
|
-
return identity;
|
|
2331
|
-
}
|
|
2332
|
-
function collectGoRootIdentitySnapshot(root) {
|
|
2333
|
-
const out = [];
|
|
2334
|
-
const state = { complete: true };
|
|
2335
|
-
walkGoRootIdentity(root, root, out, state);
|
|
2336
|
-
out.sort();
|
|
2337
|
-
const signature = node_crypto_1.default.createHash("sha256");
|
|
2338
|
-
for (const file of out) {
|
|
2339
|
-
const relative = node_path_1.default.relative(root, file).replace(/\\/g, "/");
|
|
2340
|
-
try {
|
|
2341
|
-
const stats = node_fs_1.default.statSync(file, { bigint: true });
|
|
2342
|
-
if (!stats.isFile()) {
|
|
2343
|
-
state.complete = false;
|
|
2344
|
-
continue;
|
|
2345
|
-
}
|
|
2346
|
-
signature.update([
|
|
2347
|
-
relative,
|
|
2348
|
-
stats.dev,
|
|
2349
|
-
stats.ino,
|
|
2350
|
-
stats.mode,
|
|
2351
|
-
stats.size,
|
|
2352
|
-
stats.mtimeNs,
|
|
2353
|
-
stats.ctimeNs,
|
|
2354
|
-
].join("\0"));
|
|
2355
|
-
signature.update("\n");
|
|
2356
|
-
}
|
|
2357
|
-
catch {
|
|
2358
|
-
state.complete = false;
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return {
|
|
2362
|
-
complete: state.complete,
|
|
2363
|
-
files: out,
|
|
2364
|
-
signature: signature.digest("hex"),
|
|
2365
|
-
};
|
|
2366
|
-
}
|
|
2367
|
-
function walkGoRootIdentity(root, dir, out, state) {
|
|
2368
|
-
let entries;
|
|
2369
|
-
try {
|
|
2370
|
-
entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
2371
|
-
}
|
|
2372
|
-
catch {
|
|
2373
|
-
state.complete = false;
|
|
2374
|
-
return;
|
|
2375
|
-
}
|
|
2376
|
-
for (const entry of entries) {
|
|
2377
|
-
const file = node_path_1.default.join(dir, entry.name);
|
|
2378
|
-
const rel = node_path_1.default.relative(root, file).replace(/\\/g, "/");
|
|
2379
|
-
if (entry.isDirectory()) {
|
|
2380
|
-
if (shouldHashGoRootPath(rel, true)) {
|
|
2381
|
-
walkGoRootIdentity(root, file, out, state);
|
|
2382
|
-
}
|
|
2383
|
-
}
|
|
2384
|
-
else if (entry.isFile() && shouldHashGoRootPath(rel, false)) {
|
|
2385
|
-
out.push(file);
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
}
|
|
2389
|
-
function shouldHashGoRootPath(rel, isDir) {
|
|
2390
|
-
if (rel === "")
|
|
2391
|
-
return true;
|
|
2392
|
-
const parts = rel.split("/");
|
|
2393
|
-
if (parts.includes(".git") || parts.includes("testdata"))
|
|
2394
|
-
return false;
|
|
2395
|
-
if (!isDir && rel.endsWith("_test.go"))
|
|
2396
|
-
return false;
|
|
2397
|
-
const first = parts[0];
|
|
2398
|
-
if (parts.length === 1) {
|
|
2399
|
-
if (isDir)
|
|
2400
|
-
return ["bin", "pkg", "src", "lib"].includes(first);
|
|
2401
|
-
return ["VERSION", "go.env"].includes(first);
|
|
2402
|
-
}
|
|
2403
|
-
if (first === "bin") {
|
|
2404
|
-
if (isDir)
|
|
2405
|
-
return true;
|
|
2406
|
-
const base = node_path_1.default.basename(rel);
|
|
2407
|
-
return (base === "go" ||
|
|
2408
|
-
base === "go.exe" ||
|
|
2409
|
-
base === "gofmt" ||
|
|
2410
|
-
base === "gofmt.exe");
|
|
2411
|
-
}
|
|
2412
|
-
if (first === "pkg") {
|
|
2413
|
-
const second = parts[1];
|
|
2414
|
-
return second === "tool" || second === "include";
|
|
2415
|
-
}
|
|
2416
|
-
if (first === "src") {
|
|
2417
|
-
if (!isDir && parts.length === 2) {
|
|
2418
|
-
return ["go.mod", "go.sum"].includes(parts[1]);
|
|
2419
|
-
}
|
|
2420
|
-
return parts[1] !== "cmd";
|
|
2421
|
-
}
|
|
2422
|
-
if (first === "lib") {
|
|
2423
|
-
return parts[1] === "time";
|
|
2424
|
-
}
|
|
2425
|
-
return false;
|
|
2426
|
-
}
|
|
2427
|
-
function touchCacheEntry(cacheDir) {
|
|
2428
|
-
try {
|
|
2429
|
-
node_fs_1.default.mkdirSync(cacheDir, { recursive: true });
|
|
2430
|
-
replaceCacheMetadataFile(node_path_1.default.join(cacheDir, CACHE_LAST_USED_FILE), `${Date.now()}\n`);
|
|
2431
|
-
}
|
|
2432
|
-
catch {
|
|
2433
|
-
// Cache hits must not fail because metadata touch failed.
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
function prunePluginCacheRoot(root, options = {}) {
|
|
2437
|
-
try {
|
|
2438
|
-
const cacheRoot = canonicalPluginCacheRoot(root);
|
|
2439
|
-
const marker = node_path_1.default.join(cacheRoot, CACHE_GC_MARKER_FILE);
|
|
2440
|
-
const now = options.now ?? Date.now();
|
|
2441
|
-
const lastRun = readTimestamp(marker);
|
|
2442
|
-
if (options.force !== true &&
|
|
2443
|
-
lastRun !== null &&
|
|
2444
|
-
lastRun <= now &&
|
|
2445
|
-
now - lastRun < PLUGIN_CACHE_GC_INTERVAL_MS) {
|
|
2446
|
-
return;
|
|
2447
|
-
}
|
|
2448
|
-
const remainingBytes = prunePluginCacheEntries(cacheRoot, {
|
|
2449
|
-
maxBytes: options.maxBytes ?? PLUGIN_CACHE_MAX_BYTES,
|
|
2450
|
-
now,
|
|
2451
|
-
protectedEntries: canonicalPluginCacheProtectedEntries(cacheRoot, options.protectedEntries ?? []),
|
|
2452
|
-
protectedAgeMs: options.protectedAgeMs ?? PLUGIN_CACHE_PROTECTED_AGE_MS,
|
|
2453
|
-
targetBytes: options.targetBytes ?? PLUGIN_CACHE_TARGET_BYTES,
|
|
2454
|
-
});
|
|
2455
|
-
const maxBytes = options.maxBytes ?? PLUGIN_CACHE_MAX_BYTES;
|
|
2456
|
-
const protectedAgeMs = options.protectedAgeMs ?? PLUGIN_CACHE_PROTECTED_AGE_MS;
|
|
2457
|
-
const markerTimestamp = remainingBytes > maxBytes
|
|
2458
|
-
? now - PLUGIN_CACHE_GC_INTERVAL_MS + protectedAgeMs
|
|
2459
|
-
: now;
|
|
2460
|
-
replaceCacheMetadataFile(marker, `${markerTimestamp}\n`);
|
|
2461
|
-
}
|
|
2462
|
-
catch {
|
|
2463
|
-
// Plugin-cache GC is opportunistic; builds still proceed when it fails.
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
/** Resolve explicit GC exclusions without allowing an alias outside root. */
|
|
2467
|
-
function canonicalPluginCacheProtectedEntries(root, entries) {
|
|
2468
|
-
const protectedEntries = new Set();
|
|
2469
|
-
for (const entry of entries) {
|
|
2470
|
-
const candidate = node_path_1.default.resolve(entry);
|
|
2471
|
-
const stats = node_fs_1.default.lstatSync(candidate);
|
|
2472
|
-
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
2473
|
-
throw new Error(`ttsc: unsafe protected plugin cache entry: ${entry}`);
|
|
2474
|
-
}
|
|
2475
|
-
const physical = node_fs_1.default.realpathSync.native(candidate);
|
|
2476
|
-
if (node_path_1.default.dirname(physical) !== root) {
|
|
2477
|
-
throw new Error(`ttsc: protected plugin cache entry escaped root: ${entry}`);
|
|
2478
|
-
}
|
|
2479
|
-
protectedEntries.add(physical);
|
|
2480
|
-
}
|
|
2481
|
-
return protectedEntries;
|
|
2482
|
-
}
|
|
2483
|
-
/** Pin the default plugin cache to one ordinary physical directory. */
|
|
2484
|
-
function canonicalPluginCacheRoot(root) {
|
|
2485
|
-
node_fs_1.default.mkdirSync(root, { recursive: true });
|
|
2486
|
-
const physicalParent = node_fs_1.default.realpathSync.native(node_path_1.default.dirname(root));
|
|
2487
|
-
const stats = node_fs_1.default.lstatSync(root);
|
|
2488
|
-
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
2489
|
-
throw new Error(`ttsc: unsafe plugin cache root: ${root}`);
|
|
2490
|
-
}
|
|
2491
|
-
// If an ancestor alias is retargeted after this point, all later cache work
|
|
2492
|
-
// stays on the original physical directory rather than following it.
|
|
2493
|
-
const physicalRoot = node_fs_1.default.realpathSync.native(root);
|
|
2494
|
-
if (node_path_1.default.dirname(physicalRoot) !== physicalParent) {
|
|
2495
|
-
throw new Error(`ttsc: plugin cache root escaped its parent: ${root}`);
|
|
2496
|
-
}
|
|
2497
|
-
return physicalRoot;
|
|
2498
|
-
}
|
|
2499
|
-
/** Create one content-addressed cache entry without following a leaf alias. */
|
|
2500
|
-
function canonicalPluginCacheEntry(root, key) {
|
|
2501
|
-
const directory = node_path_1.default.join(root, key);
|
|
2502
|
-
node_fs_1.default.mkdirSync(directory, { recursive: true });
|
|
2503
|
-
const stats = node_fs_1.default.lstatSync(directory);
|
|
2504
|
-
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
2505
|
-
throw new Error(`ttsc: unsafe plugin cache entry: ${directory}`);
|
|
2506
|
-
}
|
|
2507
|
-
const physicalDirectory = node_fs_1.default.realpathSync.native(directory);
|
|
2508
|
-
if (node_path_1.default.dirname(physicalDirectory) !== root) {
|
|
2509
|
-
throw new Error(`ttsc: plugin cache entry escaped its root: ${directory}`);
|
|
2510
|
-
}
|
|
2511
|
-
return physicalDirectory;
|
|
2512
|
-
}
|
|
2513
|
-
function prunePluginCacheEntries(root, options) {
|
|
2514
|
-
const entries = collectPluginCacheEntries(root, options.now);
|
|
2515
|
-
for (const entry of entries) {
|
|
2516
|
-
if (options.now - entry.lastUsedAt <= PLUGIN_CACHE_ENTRY_MAX_AGE_MS ||
|
|
2517
|
-
options.protectedEntries.has(entry.dir) ||
|
|
2518
|
-
pluginCacheEntryHasActiveBuild(entry, options.now)) {
|
|
2519
|
-
continue;
|
|
2520
|
-
}
|
|
2521
|
-
removeCacheEntry(entry);
|
|
2522
|
-
}
|
|
2523
|
-
const remaining = collectPluginCacheEntries(root, options.now);
|
|
2524
|
-
let total = remaining.reduce((sum, entry) => sum + entry.size, 0);
|
|
2525
|
-
if (total <= options.maxBytes) {
|
|
2526
|
-
return total;
|
|
2527
|
-
}
|
|
2528
|
-
const protectedEntries = new Set(options.protectedEntries);
|
|
2529
|
-
let protectedBytes = 0;
|
|
2530
|
-
for (const entry of [...remaining].sort((a, b) => b.lastUsedAt - a.lastUsedAt)) {
|
|
2531
|
-
if (pluginCacheEntryHasActiveBuild(entry, options.now)) {
|
|
2532
|
-
protectedEntries.add(entry.dir);
|
|
2533
|
-
continue;
|
|
2534
|
-
}
|
|
2535
|
-
if (options.now - entry.lastUsedAt > options.protectedAgeMs)
|
|
2536
|
-
continue;
|
|
2537
|
-
if (protectedBytes >= options.targetBytes)
|
|
2538
|
-
continue;
|
|
2539
|
-
if (protectedBytes + entry.size > options.targetBytes)
|
|
2540
|
-
continue;
|
|
2541
|
-
protectedEntries.add(entry.dir);
|
|
2542
|
-
protectedBytes += entry.size;
|
|
2543
|
-
}
|
|
2544
|
-
for (const entry of remaining.sort((a, b) => a.lastUsedAt - b.lastUsedAt)) {
|
|
2545
|
-
if (total <= options.targetBytes) {
|
|
2546
|
-
return total;
|
|
2547
|
-
}
|
|
2548
|
-
if (protectedEntries.has(entry.dir))
|
|
2549
|
-
continue;
|
|
2550
|
-
if (removeCacheEntry(entry))
|
|
2551
|
-
total -= entry.size;
|
|
2552
|
-
}
|
|
2553
|
-
return total;
|
|
2554
|
-
}
|
|
2555
|
-
/** Conservatively protect an entry while any build generation owns its key. */
|
|
2556
|
-
function pluginCacheEntryHasActiveBuild(entry, now) {
|
|
2557
|
-
const lockDir = `${entry.dir}.lock`;
|
|
2558
|
-
try {
|
|
2559
|
-
return inspectPluginBuildLock(lockDir, now).state === "active";
|
|
2560
|
-
}
|
|
2561
|
-
catch {
|
|
2562
|
-
// Malformed or unreadable coordination state cannot disprove ownership.
|
|
2563
|
-
return true;
|
|
2564
|
-
}
|
|
2565
|
-
}
|
|
2566
|
-
/**
|
|
2567
|
-
* Opportunistically bound one ttsc-owned Go object cache.
|
|
2568
|
-
*
|
|
2569
|
-
* A maintenance intent blocks new build leases. If any existing lease remains,
|
|
2570
|
-
* maintenance yields without touching the cache; the next invocation retries.
|
|
2571
|
-
* Only Go's two-hex object directories are scanned, so coordination metadata
|
|
2572
|
-
* and Go's own trim marker remain outside the size policy.
|
|
2573
|
-
*/
|
|
2574
|
-
function pruneGoBuildCacheRoot(root, options = {}) {
|
|
2575
|
-
let intent;
|
|
2576
|
-
try {
|
|
2577
|
-
const cacheRoot = canonicalGoBuildCacheRoot(root);
|
|
2578
|
-
const marker = node_path_1.default.join(cacheRoot, GO_BUILD_CACHE_GC_MARKER_FILE);
|
|
2579
|
-
const now = options.now ?? Date.now();
|
|
2580
|
-
const lastRun = readTimestamp(marker);
|
|
2581
|
-
if (options.force !== true &&
|
|
2582
|
-
lastRun !== null &&
|
|
2583
|
-
lastRun <= now &&
|
|
2584
|
-
now - lastRun < GO_BUILD_CACHE_GC_INTERVAL_MS) {
|
|
2585
|
-
return;
|
|
2586
|
-
}
|
|
2587
|
-
intent = createGoBuildCacheCoordinationRecord(cacheRoot, GO_BUILD_CACHE_MAINTENANCE_DIR);
|
|
2588
|
-
if (!intent.startHeartbeat()) {
|
|
2589
|
-
// Maintenance is opportunistic. Without an independent heartbeat a
|
|
2590
|
-
// synchronous scan could look abandoned while it is still deleting, so
|
|
2591
|
-
// yield instead of weakening the build/maintenance exclusion.
|
|
2592
|
-
return;
|
|
2593
|
-
}
|
|
2594
|
-
if (collectLiveGoBuildCacheCoordinationRecords(cacheRoot, GO_BUILD_CACHE_LEASE_DIR, now).length !== 0) {
|
|
2595
|
-
return;
|
|
2596
|
-
}
|
|
2597
|
-
const remainingBytes = pruneGoBuildCacheEntries(cacheRoot, {
|
|
2598
|
-
maxBytes: options.maxBytes ?? GO_BUILD_CACHE_MAX_BYTES,
|
|
2599
|
-
now,
|
|
2600
|
-
protectedAgeMs: options.protectedAgeMs ?? GO_BUILD_CACHE_PROTECTED_AGE_MS,
|
|
2601
|
-
targetBytes: options.targetBytes ?? GO_BUILD_CACHE_TARGET_BYTES,
|
|
2602
|
-
});
|
|
2603
|
-
// If recent protection or a transient delete failure left the cache above
|
|
2604
|
-
// the ceiling, retry after the protection window instead of suppressing
|
|
2605
|
-
// every maintenance attempt for a full day.
|
|
2606
|
-
const maxBytes = options.maxBytes ?? GO_BUILD_CACHE_MAX_BYTES;
|
|
2607
|
-
const protectedAgeMs = options.protectedAgeMs ?? GO_BUILD_CACHE_PROTECTED_AGE_MS;
|
|
2608
|
-
const markerTimestamp = remainingBytes > maxBytes
|
|
2609
|
-
? now - GO_BUILD_CACHE_GC_INTERVAL_MS + protectedAgeMs
|
|
2610
|
-
: now;
|
|
2611
|
-
replaceCacheMetadataFile(marker, `${markerTimestamp}\n`);
|
|
2612
|
-
}
|
|
2613
|
-
catch {
|
|
2614
|
-
// Go-cache GC is opportunistic; builds still proceed when it fails.
|
|
2615
|
-
}
|
|
2616
|
-
finally {
|
|
2617
|
-
intent?.finish();
|
|
2618
|
-
}
|
|
2619
|
-
}
|
|
2620
|
-
/**
|
|
2621
|
-
* Run one Go build under a cross-process cache lease when ttsc owns the cache.
|
|
2622
|
-
*
|
|
2623
|
-
* The lease is published before checking maintenance. A maintenance process
|
|
2624
|
-
* that arrived first keeps its intent visible, so this builder withdraws and
|
|
2625
|
-
* retries; one that arrives second sees the lease and yields. That ordering
|
|
2626
|
-
* closes the scan/start race without serializing independent Go builds.
|
|
2627
|
-
*/
|
|
2628
|
-
function withGoBuildCacheLease(root, managed, callback) {
|
|
2629
|
-
if (!managed) {
|
|
2630
|
-
return callback(root);
|
|
2631
|
-
}
|
|
2632
|
-
const cacheRoot = canonicalGoBuildCacheRoot(root);
|
|
2633
|
-
const started = Date.now();
|
|
2634
|
-
for (;;) {
|
|
2635
|
-
const lease = createGoBuildCacheCoordinationRecord(cacheRoot, GO_BUILD_CACHE_LEASE_DIR);
|
|
2636
|
-
const maintenance = collectLiveGoBuildCacheCoordinationRecords(cacheRoot, GO_BUILD_CACHE_MAINTENANCE_DIR, Date.now());
|
|
2637
|
-
if (maintenance.length === 0) {
|
|
2638
|
-
try {
|
|
2639
|
-
if (!lease.startHeartbeat()) {
|
|
2640
|
-
throw new Error(`ttsc: unable to start Go build cache lease heartbeat at ${cacheRoot}`);
|
|
2641
|
-
}
|
|
2642
|
-
return callback(cacheRoot);
|
|
2643
|
-
}
|
|
2644
|
-
finally {
|
|
2645
|
-
lease.finish();
|
|
2646
|
-
}
|
|
2647
|
-
}
|
|
2648
|
-
lease.finish();
|
|
2649
|
-
if (Date.now() - started > PLUGIN_BUILD_LOCK_STEAL_MS) {
|
|
2650
|
-
throw new Error(`ttsc: timed out waiting for Go build cache maintenance at ${cacheRoot}`);
|
|
2651
|
-
}
|
|
2652
|
-
sleepSync(GO_BUILD_CACHE_COORDINATION_POLL_MS);
|
|
2653
|
-
}
|
|
2654
|
-
}
|
|
2655
|
-
/**
|
|
2656
|
-
* Create and pin the owned Go cache to an ordinary physical directory.
|
|
2657
|
-
*
|
|
2658
|
-
* The leaf may be user-controlled inside `node_modules/.cache`; accepting a
|
|
2659
|
-
* symlink or junction there would let LRU deletion escape into an arbitrary
|
|
2660
|
-
* two-hex directory. Returning the canonical spelling also keeps the build,
|
|
2661
|
-
* leases, and maintenance on the same directory if an ancestor alias moves.
|
|
2662
|
-
*/
|
|
2663
|
-
function canonicalGoBuildCacheRoot(root) {
|
|
2664
|
-
node_fs_1.default.mkdirSync(root, { recursive: true });
|
|
2665
|
-
const physicalParent = node_fs_1.default.realpathSync.native(node_path_1.default.dirname(root));
|
|
2666
|
-
const stats = node_fs_1.default.lstatSync(root);
|
|
2667
|
-
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
2668
|
-
throw new Error(`ttsc: unsafe Go build cache root: ${root}`);
|
|
2669
|
-
}
|
|
2670
|
-
const physicalRoot = node_fs_1.default.realpathSync.native(root);
|
|
2671
|
-
if (node_path_1.default.dirname(physicalRoot) !== physicalParent) {
|
|
2672
|
-
throw new Error(`ttsc: Go build cache root escaped its parent: ${root}`);
|
|
2673
|
-
}
|
|
2674
|
-
return physicalRoot;
|
|
2675
|
-
}
|
|
2676
|
-
/** Prune oldest Go cache objects to the requested deterministic size target. */
|
|
2677
|
-
function pruneGoBuildCacheEntries(root, options) {
|
|
2678
|
-
const entries = collectGoBuildCacheObjects(root);
|
|
2679
|
-
let total = entries.reduce((sum, entry) => sum + entry.size, 0);
|
|
2680
|
-
if (total <= options.maxBytes) {
|
|
2681
|
-
return total;
|
|
2682
|
-
}
|
|
2683
|
-
// Protect the newest recent objects only up to one target-sized cohort
|
|
2684
|
-
// reserve. Protecting every object younger than an hour would let repeated
|
|
2685
|
-
// 2.9 GiB cold builds grow without bound during that hour.
|
|
2686
|
-
const protectedFiles = new Set();
|
|
2687
|
-
let protectedBytes = 0;
|
|
2688
|
-
for (const entry of [...entries].sort((a, b) => b.lastUsedAt - a.lastUsedAt)) {
|
|
2689
|
-
if (options.now - entry.lastUsedAt >
|
|
2690
|
-
options.protectedAgeMs + GO_BUILD_CACHE_ACCESS_MTIME_GRANULARITY_MS) {
|
|
2691
|
-
continue;
|
|
2692
|
-
}
|
|
2693
|
-
if (protectedBytes >= options.targetBytes) {
|
|
2694
|
-
break;
|
|
2695
|
-
}
|
|
2696
|
-
if (protectedBytes + entry.size > options.targetBytes) {
|
|
2697
|
-
break;
|
|
2698
|
-
}
|
|
2699
|
-
protectedFiles.add(entry.file);
|
|
2700
|
-
protectedBytes += entry.size;
|
|
2701
|
-
}
|
|
2702
|
-
for (const entry of entries.sort((a, b) => a.lastUsedAt - b.lastUsedAt)) {
|
|
2703
|
-
if (total <= options.targetBytes) {
|
|
2704
|
-
return total;
|
|
2705
|
-
}
|
|
2706
|
-
if (protectedFiles.has(entry.file)) {
|
|
2707
|
-
continue;
|
|
2708
|
-
}
|
|
2709
|
-
try {
|
|
2710
|
-
node_fs_1.default.rmSync(entry.file, { force: true });
|
|
2711
|
-
total -= entry.size;
|
|
2712
|
-
}
|
|
2713
|
-
catch {
|
|
2714
|
-
// A concurrent antivirus/indexer can transiently hold a file on Windows.
|
|
2715
|
-
}
|
|
2716
|
-
}
|
|
2717
|
-
return total;
|
|
2718
|
-
}
|
|
2719
|
-
function collectGoBuildCacheObjects(root) {
|
|
2720
|
-
const output = [];
|
|
2721
|
-
let buckets;
|
|
2722
|
-
try {
|
|
2723
|
-
buckets = node_fs_1.default.readdirSync(root, { withFileTypes: true });
|
|
2724
|
-
}
|
|
2725
|
-
catch {
|
|
2726
|
-
return output;
|
|
2727
|
-
}
|
|
2728
|
-
for (const bucket of buckets) {
|
|
2729
|
-
if (!bucket.isDirectory() || !/^[0-9a-f]{2}$/.test(bucket.name)) {
|
|
2730
|
-
continue;
|
|
2731
|
-
}
|
|
2732
|
-
const directory = node_path_1.default.join(root, bucket.name);
|
|
2733
|
-
let files;
|
|
2734
|
-
try {
|
|
2735
|
-
files = node_fs_1.default.readdirSync(directory, { withFileTypes: true });
|
|
2736
|
-
}
|
|
2737
|
-
catch {
|
|
2738
|
-
continue;
|
|
2739
|
-
}
|
|
2740
|
-
for (const file of files) {
|
|
2741
|
-
if (!file.isFile()) {
|
|
2742
|
-
continue;
|
|
2743
|
-
}
|
|
2744
|
-
const absolute = node_path_1.default.join(directory, file.name);
|
|
2745
|
-
try {
|
|
2746
|
-
const stats = node_fs_1.default.statSync(absolute);
|
|
2747
|
-
output.push({
|
|
2748
|
-
file: absolute,
|
|
2749
|
-
lastUsedAt: stats.mtimeMs,
|
|
2750
|
-
size: stats.size,
|
|
2751
|
-
});
|
|
2752
|
-
}
|
|
2753
|
-
catch { }
|
|
2754
|
-
}
|
|
2755
|
-
}
|
|
2756
|
-
return output;
|
|
2757
|
-
}
|
|
2758
|
-
function createGoBuildCacheCoordinationRecord(root, directoryName) {
|
|
2759
|
-
const directory = goBuildCacheCoordinationDirectory(root, directoryName, true);
|
|
2760
|
-
const record = node_path_1.default.join(directory, `${process.pid}-${node_crypto_1.default.randomBytes(16).toString("hex")}.json`);
|
|
2761
|
-
const metadata = {
|
|
2762
|
-
directoryName,
|
|
2763
|
-
hostname: node_os_1.default.hostname(),
|
|
2764
|
-
pid: process.pid,
|
|
2765
|
-
startedAt: Date.now(),
|
|
2766
|
-
};
|
|
2767
|
-
writeGoBuildCacheCoordinationRecord(record, metadata, "active");
|
|
2768
|
-
let heartbeat;
|
|
2769
|
-
return {
|
|
2770
|
-
file: record,
|
|
2771
|
-
finish: () => {
|
|
2772
|
-
heartbeat?.stop();
|
|
2773
|
-
heartbeat = undefined;
|
|
2774
|
-
// A failed unlink must not leave a completed task looking active until
|
|
2775
|
-
// its stale timeout. Persist completion first; collectors discard it.
|
|
2776
|
-
try {
|
|
2777
|
-
writeGoBuildCacheCoordinationRecord(record, metadata, "complete");
|
|
2778
|
-
}
|
|
2779
|
-
catch { }
|
|
2780
|
-
try {
|
|
2781
|
-
node_fs_1.default.rmSync(record, { force: true });
|
|
2782
|
-
}
|
|
2783
|
-
catch { }
|
|
2784
|
-
},
|
|
2785
|
-
startHeartbeat: () => {
|
|
2786
|
-
heartbeat ??= startGoBuildCacheHeartbeat(record);
|
|
2787
|
-
return heartbeat !== undefined;
|
|
2788
|
-
},
|
|
2789
|
-
};
|
|
2790
|
-
}
|
|
2791
|
-
function writeGoBuildCacheCoordinationRecord(file, metadata, status) {
|
|
2792
|
-
replaceCacheMetadataFile(file, `${JSON.stringify({ ...metadata, status, version: 1 })}\n`);
|
|
2793
|
-
}
|
|
2794
|
-
/** Refresh one synchronous cache task's record from a background worker. */
|
|
2795
|
-
function startGoBuildCacheHeartbeat(file) {
|
|
2796
|
-
const control = new SharedArrayBuffer(4);
|
|
2797
|
-
const state = new Int32Array(control);
|
|
2798
|
-
try {
|
|
2799
|
-
const worker = new node_worker_threads_1.Worker([
|
|
2800
|
-
'const fs = process.getBuiltinModule("node:fs");',
|
|
2801
|
-
'const { workerData } = process.getBuiltinModule("node:worker_threads");',
|
|
2802
|
-
"const state = new Int32Array(workerData.control);",
|
|
2803
|
-
"for (;;) {",
|
|
2804
|
-
" const result = Atomics.wait(state, 0, 0, workerData.interval);",
|
|
2805
|
-
' if (result !== "timed-out" || Atomics.load(state, 0) !== 0) break;',
|
|
2806
|
-
" try {",
|
|
2807
|
-
" const now = new Date();",
|
|
2808
|
-
" fs.utimesSync(workerData.file, now, now);",
|
|
2809
|
-
" } catch {}",
|
|
2810
|
-
"}",
|
|
2811
|
-
].join("\n"), {
|
|
2812
|
-
eval: true,
|
|
2813
|
-
workerData: {
|
|
2814
|
-
control,
|
|
2815
|
-
file,
|
|
2816
|
-
interval: GO_BUILD_CACHE_COORDINATION_HEARTBEAT_MS,
|
|
2817
|
-
},
|
|
2818
|
-
});
|
|
2819
|
-
worker.unref();
|
|
2820
|
-
return {
|
|
2821
|
-
stop: () => {
|
|
2822
|
-
Atomics.store(state, 0, 1);
|
|
2823
|
-
Atomics.notify(state, 0);
|
|
2824
|
-
void worker.terminate();
|
|
2825
|
-
},
|
|
2826
|
-
};
|
|
2827
|
-
}
|
|
2828
|
-
catch { }
|
|
2829
|
-
// Node's permission model can deny Worker construction while still allowing
|
|
2830
|
-
// the child process required for `go build`. The fallback inherits only the
|
|
2831
|
-
// low standard descriptors and checks its parent PID. An IPC channel would
|
|
2832
|
-
// allocate another high descriptor and recreate Darwin's spawn EBADF limit.
|
|
2833
|
-
try {
|
|
2834
|
-
const child = (0, node_child_process_1.spawn)(process.execPath, [
|
|
2835
|
-
"-e",
|
|
2836
|
-
[
|
|
2837
|
-
'const fs = require("node:fs");',
|
|
2838
|
-
"const file = process.argv[1];",
|
|
2839
|
-
"const interval = Number(process.argv[2]);",
|
|
2840
|
-
"const parent = Number(process.argv[3]);",
|
|
2841
|
-
"const timer = setInterval(() => {",
|
|
2842
|
-
" try { process.kill(parent, 0); } catch { clearInterval(timer); process.exit(0); }",
|
|
2843
|
-
" try {",
|
|
2844
|
-
" const now = new Date();",
|
|
2845
|
-
" fs.utimesSync(file, now, now);",
|
|
2846
|
-
" } catch {}",
|
|
2847
|
-
"}, interval);",
|
|
2848
|
-
].join("\n"),
|
|
2849
|
-
file,
|
|
2850
|
-
String(GO_BUILD_CACHE_COORDINATION_HEARTBEAT_MS),
|
|
2851
|
-
String(process.pid),
|
|
2852
|
-
], {
|
|
2853
|
-
stdio: [0, 1, 2],
|
|
2854
|
-
windowsHide: true,
|
|
2855
|
-
});
|
|
2856
|
-
child.unref();
|
|
2857
|
-
return {
|
|
2858
|
-
stop: () => {
|
|
2859
|
-
child.kill();
|
|
2860
|
-
},
|
|
2861
|
-
};
|
|
2862
|
-
}
|
|
2863
|
-
catch {
|
|
2864
|
-
return undefined;
|
|
2865
|
-
}
|
|
2866
|
-
}
|
|
2867
|
-
function collectLiveGoBuildCacheCoordinationRecords(root, directoryName, now) {
|
|
2868
|
-
const directory = goBuildCacheCoordinationDirectory(root, directoryName, false);
|
|
2869
|
-
if (directory === undefined)
|
|
2870
|
-
return [];
|
|
2871
|
-
let records;
|
|
2872
|
-
try {
|
|
2873
|
-
records = node_fs_1.default.readdirSync(directory, { withFileTypes: true });
|
|
2874
|
-
}
|
|
2875
|
-
catch (error) {
|
|
2876
|
-
if (error.code === "ENOENT")
|
|
2877
|
-
return [];
|
|
2878
|
-
throw error;
|
|
2879
|
-
}
|
|
2880
|
-
const live = [];
|
|
2881
|
-
for (const record of records) {
|
|
2882
|
-
if (!record.isFile()) {
|
|
2883
|
-
continue;
|
|
2884
|
-
}
|
|
2885
|
-
const file = node_path_1.default.join(directory, record.name);
|
|
2886
|
-
if (goBuildCacheCoordinationRecordIsLive(file, directoryName, now)) {
|
|
2887
|
-
live.push(file);
|
|
2888
|
-
continue;
|
|
2889
|
-
}
|
|
2890
|
-
try {
|
|
2891
|
-
node_fs_1.default.rmSync(file, { force: true });
|
|
2892
|
-
}
|
|
2893
|
-
catch { }
|
|
2894
|
-
}
|
|
2895
|
-
return live;
|
|
2896
|
-
}
|
|
2897
|
-
/**
|
|
2898
|
-
* Resolve one private coordination directory without following a project-
|
|
2899
|
-
* supplied symlink or junction outside the owned Go cache.
|
|
2900
|
-
*/
|
|
2901
|
-
function goBuildCacheCoordinationDirectory(root, directoryName, create) {
|
|
2902
|
-
if (create)
|
|
2903
|
-
node_fs_1.default.mkdirSync(root, { recursive: true });
|
|
2904
|
-
const directory = node_path_1.default.join(root, directoryName);
|
|
2905
|
-
if (create) {
|
|
2906
|
-
try {
|
|
2907
|
-
node_fs_1.default.mkdirSync(directory);
|
|
2908
|
-
}
|
|
2909
|
-
catch (error) {
|
|
2910
|
-
if (error.code !== "EEXIST")
|
|
2911
|
-
throw error;
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
let stats;
|
|
2915
|
-
try {
|
|
2916
|
-
stats = node_fs_1.default.lstatSync(directory);
|
|
2917
|
-
}
|
|
2918
|
-
catch (error) {
|
|
2919
|
-
if (!create && error.code === "ENOENT") {
|
|
2920
|
-
return undefined;
|
|
2921
|
-
}
|
|
2922
|
-
throw error;
|
|
2923
|
-
}
|
|
2924
|
-
if (!stats.isDirectory() || stats.isSymbolicLink()) {
|
|
2925
|
-
throw new Error(`ttsc: unsafe Go build cache coordination directory: ${directory}`);
|
|
2926
|
-
}
|
|
2927
|
-
const physicalRoot = node_fs_1.default.realpathSync.native(root);
|
|
2928
|
-
const physicalDirectory = node_fs_1.default.realpathSync.native(directory);
|
|
2929
|
-
if (node_path_1.default.dirname(physicalDirectory) !== physicalRoot) {
|
|
2930
|
-
throw new Error(`ttsc: Go build cache coordination directory escaped its root: ${directory}`);
|
|
2931
|
-
}
|
|
2932
|
-
return physicalDirectory;
|
|
2933
|
-
}
|
|
2934
|
-
function goBuildCacheCoordinationRecordIsLive(file, directoryName, now) {
|
|
2935
|
-
let contents;
|
|
2936
|
-
try {
|
|
2937
|
-
contents = node_fs_1.default.readFileSync(file, "utf8");
|
|
2938
|
-
const parsed = JSON.parse(contents);
|
|
2939
|
-
if (parsed.status === "complete")
|
|
2940
|
-
return false;
|
|
2941
|
-
// Parse valid records for forward compatibility, but do not equate a PID's
|
|
2942
|
-
// lifetime with one task. A failed unlink can leave a record owned by a
|
|
2943
|
-
// still-running Vite process, while a dead Node parent can leave its
|
|
2944
|
-
// spawnSync Go child alive. The heartbeat/grace below models the task.
|
|
2945
|
-
void parsed;
|
|
2946
|
-
}
|
|
2947
|
-
catch { }
|
|
2948
|
-
try {
|
|
2949
|
-
const age = now - node_fs_1.default.statSync(file).mtimeMs;
|
|
2950
|
-
if (age < -GO_BUILD_CACHE_COORDINATION_CLOCK_SKEW_MS) {
|
|
2951
|
-
// A restored cache can carry a far-future timestamp, but the same state
|
|
2952
|
-
// also occurs when the system clock moves backward during a real build.
|
|
2953
|
-
// Rebase the record and grant one ordinary grace period; an active
|
|
2954
|
-
// heartbeat keeps refreshing it, while an orphan then expires normally.
|
|
2955
|
-
// Treat a failed rebase as live too: the safe failure mode is to defer
|
|
2956
|
-
// opportunistic maintenance, never to delete under a possibly live Go.
|
|
2957
|
-
// Replace the directory entry rather than changing its inode in place.
|
|
2958
|
-
// A restored or user-modified cache can contain a hard-linked record;
|
|
2959
|
-
// utimesSync(file) would then mutate metadata outside the owned cache.
|
|
2960
|
-
if (contents !== undefined) {
|
|
2961
|
-
try {
|
|
2962
|
-
replaceCacheMetadataFile(file, contents);
|
|
2963
|
-
}
|
|
2964
|
-
catch { }
|
|
2965
|
-
}
|
|
2966
|
-
return true;
|
|
2967
|
-
}
|
|
2968
|
-
const staleMs = directoryName === GO_BUILD_CACHE_MAINTENANCE_DIR
|
|
2969
|
-
? GO_BUILD_CACHE_MAINTENANCE_STALE_MS
|
|
2970
|
-
: GO_BUILD_CACHE_COORDINATION_STALE_MS;
|
|
2971
|
-
return age <= staleMs;
|
|
2972
|
-
}
|
|
2973
|
-
catch (error) {
|
|
2974
|
-
return error.code !== "ENOENT";
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
function collectPluginCacheEntries(root, now) {
|
|
2978
|
-
const entries = [];
|
|
2979
|
-
let dirents;
|
|
2980
|
-
try {
|
|
2981
|
-
dirents = node_fs_1.default.readdirSync(root, { withFileTypes: true });
|
|
2982
|
-
}
|
|
2983
|
-
catch {
|
|
2984
|
-
return entries;
|
|
2985
|
-
}
|
|
2986
|
-
for (const dirent of dirents) {
|
|
2987
|
-
if (!dirent.isDirectory() ||
|
|
2988
|
-
dirent.name.endsWith(".lock") ||
|
|
2989
|
-
dirent.name.includes(".lock.")) {
|
|
2990
|
-
continue;
|
|
2991
|
-
}
|
|
2992
|
-
const dir = node_path_1.default.join(root, dirent.name);
|
|
2993
|
-
const lastUsedAt = readCacheEntryLastUsedAt(dir, now);
|
|
2994
|
-
entries.push({
|
|
2995
|
-
dir,
|
|
2996
|
-
lastUsedAt,
|
|
2997
|
-
size: directorySize(dir),
|
|
2998
|
-
});
|
|
2999
|
-
}
|
|
3000
|
-
return entries;
|
|
3001
|
-
}
|
|
3002
|
-
function readCacheEntryLastUsedAt(dir, now) {
|
|
3003
|
-
const touched = readTimestamp(node_path_1.default.join(dir, CACHE_LAST_USED_FILE));
|
|
3004
|
-
if (touched !== null) {
|
|
3005
|
-
return touched;
|
|
3006
|
-
}
|
|
3007
|
-
for (const name of ["plugin", "plugin.exe"]) {
|
|
3008
|
-
try {
|
|
3009
|
-
return node_fs_1.default.statSync(node_path_1.default.join(dir, name)).mtimeMs;
|
|
3010
|
-
}
|
|
3011
|
-
catch { }
|
|
3012
|
-
}
|
|
3013
|
-
try {
|
|
3014
|
-
return node_fs_1.default.statSync(dir).mtimeMs;
|
|
3015
|
-
}
|
|
3016
|
-
catch {
|
|
3017
|
-
return now;
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
function readTimestamp(file) {
|
|
3021
|
-
try {
|
|
3022
|
-
const text = node_fs_1.default.readFileSync(file, "utf8").trim();
|
|
3023
|
-
const value = Number(text);
|
|
3024
|
-
if (Number.isFinite(value)) {
|
|
3025
|
-
return value;
|
|
3026
|
-
}
|
|
3027
|
-
}
|
|
3028
|
-
catch { }
|
|
3029
|
-
try {
|
|
3030
|
-
return node_fs_1.default.statSync(file).mtimeMs;
|
|
3031
|
-
}
|
|
3032
|
-
catch {
|
|
3033
|
-
return null;
|
|
3034
|
-
}
|
|
3035
|
-
}
|
|
3036
|
-
/** Replace cache metadata without following a pre-existing link or hard link. */
|
|
3037
|
-
function replaceCacheMetadataFile(file, contents) {
|
|
3038
|
-
const temporary = node_path_1.default.join(node_path_1.default.dirname(file), `.${node_path_1.default.basename(file)}.${process.pid}-${node_crypto_1.default
|
|
3039
|
-
.randomBytes(16)
|
|
3040
|
-
.toString("hex")}.tmp`);
|
|
3041
|
-
try {
|
|
3042
|
-
node_fs_1.default.writeFileSync(temporary, contents, { encoding: "utf8", flag: "wx" });
|
|
3043
|
-
// rename replaces the directory entry itself. Unlike writeFile(file), it
|
|
3044
|
-
// cannot follow a symlink or mutate another hard link to the old inode.
|
|
3045
|
-
node_fs_1.default.renameSync(temporary, file);
|
|
3046
|
-
}
|
|
3047
|
-
finally {
|
|
3048
|
-
try {
|
|
3049
|
-
node_fs_1.default.rmSync(temporary, { force: true });
|
|
3050
|
-
}
|
|
3051
|
-
catch { }
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
function directorySize(dir) {
|
|
3055
|
-
let total = 0;
|
|
3056
|
-
let entries;
|
|
3057
|
-
try {
|
|
3058
|
-
entries = node_fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
3059
|
-
}
|
|
3060
|
-
catch {
|
|
3061
|
-
return total;
|
|
3062
|
-
}
|
|
3063
|
-
for (const entry of entries) {
|
|
3064
|
-
const file = node_path_1.default.join(dir, entry.name);
|
|
3065
|
-
try {
|
|
3066
|
-
if (entry.isDirectory()) {
|
|
3067
|
-
total += directorySize(file);
|
|
3068
|
-
}
|
|
3069
|
-
else if (entry.isFile()) {
|
|
3070
|
-
total += node_fs_1.default.statSync(file).size;
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
catch { }
|
|
3074
|
-
}
|
|
3075
|
-
return total;
|
|
3076
|
-
}
|
|
3077
|
-
function removeCacheEntry(entry) {
|
|
3078
|
-
try {
|
|
3079
|
-
node_fs_1.default.rmSync(entry.dir, { recursive: true, force: true });
|
|
3080
|
-
return !node_fs_1.default.existsSync(entry.dir);
|
|
3081
|
-
}
|
|
3082
|
-
catch {
|
|
3083
|
-
// Windows may reject removal while a plugin binary is still running.
|
|
3084
|
-
return false;
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
//# sourceMappingURL=buildSourcePlugin.js.map
|