ttsc 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/cmd/ttsc/api_compile.go +3 -2
- package/cmd/ttsc/api_transform.go +1 -1
- package/cmd/ttsc/build.go +5 -4
- package/cmd/ttsc-cache/account.go +16 -0
- package/cmd/ttsc-cache/account_test.go +91 -0
- package/cmd/ttsc-cache/main.go +1 -1
- package/cmd/ttsc-cache/protocol_test.go +2 -2
- package/cmd/ttsc-cache/publisher_seal_test.go +1 -1
- package/cmd/ttsc-cache/stock_go_failure_test.go +1 -1
- package/cmd/ttsc-cache/stock_go_test.go +2 -2
- package/cmd/ttsc-cache/store.go +5 -0
- package/cmd/ttsc-cache/tuple.go +6 -2
- package/cmd/ttsc-cache/tuple_test.go +1 -1
- package/cmd/ttscgraph/main.go +6 -1
- package/cmd/ttscgraph/run_help_version_and_bad_flags_exit_codes_test.go +6 -1
- package/cmd/ttscgraph/serve.go +22 -20
- package/cmd/ttscgraph/serve_alternative_members_and_reads_refresh_test.go +95 -0
- package/cmd/ttscgraph/serve_shards.go +26 -15
- package/cmd/ttscgraph/serve_shards_abandoned_generation_converges_on_retry_test.go +2 -2
- package/cmd/ttscgraph/serve_shards_delete_removed_source_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_prune_unreferenced_external_endpoints_test.go +1 -1
- package/cmd/ttscgraph/serve_shards_publish_created_source_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_refresh_cross_file_implementation_test.go +2 -2
- package/cmd/ttscgraph/serve_shards_refresh_dependent_diagnostics_test.go +3 -3
- package/cmd/ttscgraph/serve_shards_rename_moves_source_identity_test.go +5 -5
- package/cmd/ttscgraph/serve_shards_reuse_unaffected_sources_test.go +8 -8
- package/cmd/ttscgraph/serve_source_encoding_test.go +2 -2
- package/driver/build_information_uses_selected_output_identity_test.go +5 -4
- package/driver/check_observations.go +1 -1
- package/driver/config_discovery.go +5 -1
- package/driver/declaration_shape.go +15 -21
- package/driver/diagnostics_preamble.go +2 -2
- package/driver/emit_containment.go +11 -14
- package/driver/emit_plugin.go +51 -43
- package/driver/emit_plugin_output.go +6 -5
- package/driver/emit_provenance.go +12 -15
- package/driver/graph.go +8 -8
- package/driver/host.go +15 -5
- package/driver/input_observation.go +22 -21
- package/driver/input_observation_test.go +11 -10
- package/driver/overlay.go +11 -11
- package/driver/program.go +102 -51
- package/driver/resolution_candidates.go +50 -32
- package/driver/resolution_candidates_test.go +18 -5
- package/driver/rewrite.go +11 -13
- package/driver/session.go +13 -7
- package/driver/target_ts70.go +85 -0
- package/driver/target_ts71.go +97 -0
- package/driver/transform_dependencies.go +1 -1
- package/driver/transform_source_map.go +21 -20
- package/go.mod +3 -3
- package/go.sum +4 -4
- package/internal/graph/alternative_member_declarations_resolve_uses_test.go +145 -0
- package/internal/graph/assigned_implementations_of_declaration_file_symbols_leave_no_edge_source_test.go +2 -2
- package/internal/graph/assigned_implementations_of_node_modules_symbols_leave_no_edge_source_test.go +2 -2
- package/internal/graph/build.go +75 -33
- package/internal/graph/build_files_reuses_committed_cross_file_endpoints_test.go +4 -4
- package/internal/graph/build_records_a_node_per_top_level_declaration_test.go +1 -1
- package/internal/graph/declaration_members.go +143 -0
- package/internal/graph/decorators_capture_name_and_literal_arguments_test.go +3 -3
- package/internal/graph/doc_tags.go +2 -2
- package/internal/graph/dump_paths.go +6 -5
- package/internal/graph/duplicate_variable_object_members_keep_first_declaration_test.go +1 -1
- package/internal/graph/edges.go +151 -68
- package/internal/graph/edges_cover_class_level_references_test.go +5 -5
- package/internal/graph/enum_initializer_calls_are_edges_test.go +2 -2
- package/internal/graph/enum_members_carry_their_names_on_the_enum_node_test.go +6 -6
- package/internal/graph/exports.go +6 -6
- package/internal/graph/file_diagnostics_match_tsgo_code_and_location_test.go +2 -2
- package/internal/graph/file_diagnostics_report_code_column_and_message_test.go +1 -1
- package/internal/graph/function_locals_do_not_collide_test.go +3 -3
- package/internal/graph/heritage_edges_cover_implements_and_interface_extends_test.go +5 -5
- package/internal/graph/heritage_edges_keep_extends_and_implements_to_same_base_test.go +2 -2
- package/internal/graph/heritage_edges_record_extends_versus_implements_origin_test.go +3 -3
- package/internal/graph/heritage_edges_traverse_barrels_and_stop_at_external_leaves_test.go +3 -3
- package/internal/graph/literals.go +3 -3
- package/internal/graph/literals_are_absent_when_the_type_admits_more_than_it_can_name_test.go +2 -2
- package/internal/graph/literals_cover_enum_members_the_graph_has_no_nodes_for_test.go +4 -4
- package/internal/graph/literals_do_not_depend_on_declaration_line_wrapping_test.go +2 -2
- package/internal/graph/literals_render_every_value_in_typescript_source_form_test.go +1 -1
- package/internal/graph/literals_resolve_through_alias_indirection_test.go +3 -3
- package/internal/graph/member_relation_edges_follow_checker_validity_test.go +7 -7
- package/internal/graph/member_relation_edges_preserve_checker_boundaries_test.go +19 -19
- package/internal/graph/member_relation_edges_reject_checker_invalid_pairs_test.go +11 -11
- package/internal/graph/namespace_dotted_form_qualifies_deeply_test.go +2 -2
- package/internal/graph/namespace_members_become_qualified_nodes_and_edges_test.go +7 -7
- package/internal/graph/namespace_private_declarations_keep_lexical_identity_test.go +85 -0
- package/internal/graph/nodes_are_marked_exported_through_the_export_table_test.go +2 -2
- package/internal/graph/object_literal_declarations_resolve_calls_test.go +9 -9
- package/internal/graph/object_literal_members_ride_on_the_snapshot_test.go +1 -1
- package/internal/graph/overload_implementation_replaces_signature_test.go +2 -2
- package/internal/graph/property_member_edges_remain_owner_visible_test.go +6 -6
- package/internal/graph/resolve.go +37 -12
- package/internal/graph/resolve_unwraps_barrel_reexport_to_real_declaration_test.go +6 -6
- package/internal/graph/source.go +1 -1
- package/internal/graph/type_ref_edges_cover_typeof_as_satisfies_test.go +7 -7
- package/internal/graph/type_ref_edges_resolve_named_types_across_files_test.go +2 -2
- package/internal/graph/value_access_edges_cover_properties_test.go +5 -5
- package/internal/graph/value_call_edges_attribute_function_assignments_to_members_test.go +3 -3
- package/internal/graph/value_call_edges_cover_jsx_components_test.go +2 -2
- package/internal/graph/value_call_edges_cover_methods_and_constructors_test.go +3 -3
- package/internal/graph/value_call_edges_cover_variable_bound_callables_test.go +2 -2
- package/internal/graph/value_call_edges_do_not_double_record_invoked_member_access_test.go +4 -4
- package/internal/graph/value_call_edges_record_construct_versus_call_origin_test.go +3 -3
- package/internal/graph/value_call_edges_resolve_across_files_and_dedupe_test.go +2 -2
- package/internal/graph/value_call_edges_skip_self_and_unresolved_test.go +4 -4
- package/internal/graph/value_reads_cover_expression_positions_test.go +88 -0
- package/lib/compiler/internal/buildNativeCompiler.d.ts +5 -2
- package/lib/compiler/internal/buildNativeCompiler.js +12 -4
- package/lib/compiler/internal/buildNativeCompiler.js.map +1 -1
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js +1 -1
- package/lib/flags/COMPILER_ENUM_WHITESPACE.js.map +1 -1
- package/lib/flags/COMPILER_OPTIONS.js +1079 -149
- package/lib/flags/COMPILER_OPTIONS.js.map +1 -1
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js +1 -1
- package/lib/flags/COMPILER_OPTION_ASCII_FOLDS.js.map +1 -1
- package/lib/flags/COMPILER_OPTION_KINDS.js +1 -1
- package/lib/flags/COMPILER_OPTION_KINDS.js.map +1 -1
- package/lib/flags/CompilerOptionSpec.d.ts +9 -2
- package/lib/internal/pluginSource.d.ts +1 -0
- package/lib/internal/pluginSource.js +1 -0
- package/lib/internal/pluginSource.js.map +1 -1
- package/lib/launcher/internal/TypeScriptSyncApi.d.ts +140 -0
- package/lib/launcher/internal/TypeScriptSyncApi.js +99 -0
- package/lib/launcher/internal/TypeScriptSyncApi.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootInMemory.d.ts +80 -0
- package/lib/launcher/internal/buildSingleRootInMemory.js +253 -0
- package/lib/launcher/internal/buildSingleRootInMemory.js.map +1 -0
- package/lib/launcher/internal/buildSingleRootProject.d.ts +22 -18
- package/lib/launcher/internal/buildSingleRootProject.js +27 -18
- package/lib/launcher/internal/buildSingleRootProject.js.map +1 -1
- package/lib/launcher/internal/compilerArgsAsConfigOptions.d.ts +39 -0
- package/lib/launcher/internal/compilerArgsAsConfigOptions.js +115 -0
- package/lib/launcher/internal/compilerArgsAsConfigOptions.js.map +1 -0
- package/lib/plugin/CapabilityPluginResolver.js +3 -0
- package/lib/plugin/CapabilityPluginResolver.js.map +1 -1
- package/lib/plugin/internal/load/loadProjectPlugins.js +6 -2
- package/lib/plugin/internal/load/loadProjectPlugins.js.map +1 -1
- package/lib/plugin/internal/source/CompilerTarget.d.ts +127 -0
- package/lib/plugin/internal/source/CompilerTarget.js +231 -0
- package/lib/plugin/internal/source/CompilerTarget.js.map +1 -0
- package/lib/plugin/internal/source/NativeSourcePackages.js +6 -5
- package/lib/plugin/internal/source/NativeSourcePackages.js.map +1 -1
- package/lib/plugin/internal/source/SourcePluginAdmission.d.ts +18 -1
- package/lib/plugin/internal/source/SourcePluginAdmission.js +24 -2
- package/lib/plugin/internal/source/SourcePluginAdmission.js.map +1 -1
- package/lib/plugin/internal/source/SourcePluginWorkspace.d.ts +6 -3
- package/lib/plugin/internal/source/SourcePluginWorkspace.js +31 -13
- package/lib/plugin/internal/source/SourcePluginWorkspace.js.map +1 -1
- package/lib/plugin/internal/source/buildSourcePlugin.js +3 -1
- package/lib/plugin/internal/source/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.d.ts +1 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js +9 -1
- package/lib/plugin/internal/source/hashPluginBuildEnvironment.js.map +1 -1
- package/package.json +14 -9
- package/shim/ast/enums_gen.go +1 -0
- package/shim/ast/go.mod +2 -2
- package/shim/ast/go.sum +4 -4
- package/shim/ast/neutral.go +141 -0
- package/shim/astnav/go.mod +2 -2
- package/shim/astnav/go.sum +4 -4
- package/shim/bundled/go.mod +2 -2
- package/shim/bundled/go.sum +4 -4
- package/shim/checker/go.mod +2 -2
- package/shim/checker/go.sum +4 -4
- package/shim/compiler/go.mod +2 -2
- package/shim/compiler/go.sum +4 -4
- package/shim/compiler/neutral.go +213 -0
- package/shim/core/go.mod +2 -2
- package/shim/core/go.sum +4 -4
- package/shim/diagnosticwriter/go.mod +2 -2
- package/shim/diagnosticwriter/go.sum +4 -4
- package/shim/lsp/go.mod +2 -2
- package/shim/lsp/go.sum +4 -4
- package/shim/parser/go.mod +2 -2
- package/shim/parser/go.sum +4 -4
- package/shim/printer/go.mod +2 -2
- package/shim/printer/go.sum +4 -4
- package/shim/scanner/go.mod +2 -2
- package/shim/scanner/go.sum +4 -4
- package/shim/stringutil/go.mod +1 -1
- package/shim/stringutil/go.sum +2 -2
- package/shim/stringutil/shim.go +15 -0
- package/shim/transformers/go.mod +2 -2
- package/shim/transformers/go.sum +4 -4
- package/shim/tsoptions/go.mod +2 -2
- package/shim/tsoptions/go.sum +4 -4
- package/shim/tsoptions/neutral.go +56 -0
- package/shim/tspath/go.mod +1 -1
- package/shim/tspath/go.sum +2 -2
- package/shim/tspath/neutral.go +150 -0
- package/shim/tspath/typed_paths.go +266 -0
- package/shim/vfs/cachedvfs/go.mod +2 -2
- package/shim/vfs/cachedvfs/go.sum +4 -4
- package/shim/vfs/go.mod +2 -2
- package/shim/vfs/go.sum +4 -4
- package/shim/vfs/neutral.go +20 -0
- package/shim/vfs/osvfs/go.mod +2 -2
- package/shim/vfs/osvfs/go.sum +4 -4
- package/src/compiler/internal/buildNativeCompiler.ts +13 -4
- package/src/flags/COMPILER_ENUM_WHITESPACE.ts +1 -1
- package/src/flags/COMPILER_OPTIONS.ts +1080 -150
- package/src/flags/COMPILER_OPTION_ASCII_FOLDS.ts +1 -1
- package/src/flags/COMPILER_OPTION_KINDS.ts +1 -1
- package/src/flags/CompilerOptionSpec.ts +11 -2
- package/src/internal/pluginSource.ts +1 -0
- package/src/launcher/internal/TypeScriptSyncApi.ts +186 -0
- package/src/launcher/internal/buildSingleRootInMemory.ts +319 -0
- package/src/launcher/internal/buildSingleRootProject.ts +26 -18
- package/src/launcher/internal/compilerArgsAsConfigOptions.ts +112 -0
- package/src/plugin/CapabilityPluginResolver.ts +4 -1
- package/src/plugin/internal/load/loadProjectPlugins.ts +12 -2
- package/src/plugin/internal/source/CompilerTarget.ts +249 -0
- package/src/plugin/internal/source/NativeSourcePackages.ts +10 -4
- package/src/plugin/internal/source/SourcePluginAdmission.ts +28 -2
- package/src/plugin/internal/source/SourcePluginWorkspace.ts +45 -19
- package/src/plugin/internal/source/buildSourcePlugin.ts +3 -1
- package/src/plugin/internal/source/hashPluginBuildEnvironment.ts +9 -1
- package/targets/7.1/bridge/ast/enums_gen.go +174 -0
- package/targets/7.1/bridge/ast/extra-shim.json +4 -0
- package/targets/7.1/bridge/ast/go.mod +14 -0
- package/targets/7.1/bridge/ast/go.sum +20 -0
- package/targets/7.1/bridge/ast/lint.go +1412 -0
- package/targets/7.1/bridge/ast/neutral.go +141 -0
- package/targets/7.1/bridge/ast/parent.go +60 -0
- package/targets/7.1/bridge/ast/safe_text.go +108 -0
- package/targets/7.1/bridge/ast/shim.go +1656 -0
- package/targets/7.1/bridge/ast/surface.go +686 -0
- package/targets/7.1/bridge/ast/test/next_jsdoc_comment_location_reaches_variable_statement_test.go +51 -0
- package/targets/7.1/bridge/ast/test/node_text_joins_multi_hop_qualified_name_test.go +47 -0
- package/targets/7.1/bridge/ast/test/node_text_joins_one_hop_qualified_name_test.go +35 -0
- package/targets/7.1/bridge/ast/test/node_text_returns_empty_for_nil_test.go +31 -0
- package/targets/7.1/bridge/ast/test/node_text_returns_identifier_text_test.go +34 -0
- package/targets/7.1/bridge/ast/test/node_text_skips_empty_qualified_left_test.go +60 -0
- package/targets/7.1/bridge/astnav/go.mod +14 -0
- package/targets/7.1/bridge/astnav/go.sum +22 -0
- package/targets/7.1/bridge/astnav/shim.go +24 -0
- package/targets/7.1/bridge/bundled/extra-shim.json +1 -0
- package/targets/7.1/bridge/bundled/go.mod +10 -0
- package/targets/7.1/bridge/bundled/go.sum +10 -0
- package/targets/7.1/bridge/bundled/shim.go +24 -0
- package/targets/7.1/bridge/checker/enums_gen.go +150 -0
- package/targets/7.1/bridge/checker/extra-shim.json +37 -0
- package/targets/7.1/bridge/checker/go.mod +15 -0
- package/targets/7.1/bridge/checker/go.sum +24 -0
- package/targets/7.1/bridge/checker/node_builder_fields_gen.go +19 -0
- package/targets/7.1/bridge/checker/shim.go +1390 -0
- package/targets/7.1/bridge/compiler/contentmapper_process.go +70 -0
- package/targets/7.1/bridge/compiler/emit_sourcemap.go +296 -0
- package/targets/7.1/bridge/compiler/emitassemble.go +81 -0
- package/targets/7.1/bridge/compiler/emithook.go +44 -0
- package/targets/7.1/bridge/compiler/extra-shim.json +4 -0
- package/targets/7.1/bridge/compiler/go.mod +15 -0
- package/targets/7.1/bridge/compiler/go.sum +24 -0
- package/targets/7.1/bridge/compiler/incremental.go +185 -0
- package/targets/7.1/bridge/compiler/neutral.go +256 -0
- package/targets/7.1/bridge/compiler/resolution.go +571 -0
- package/targets/7.1/bridge/compiler/shim.go +70 -0
- package/targets/7.1/bridge/core/enums_gen.go +15 -0
- package/targets/7.1/bridge/core/extra-shim.json +4 -0
- package/targets/7.1/bridge/core/go.mod +7 -0
- package/targets/7.1/bridge/core/go.sum +8 -0
- package/targets/7.1/bridge/core/modulekind.go +19 -0
- package/targets/7.1/bridge/core/shim.go +272 -0
- package/targets/7.1/bridge/diagnosticwriter/go.mod +14 -0
- package/targets/7.1/bridge/diagnosticwriter/go.sum +20 -0
- package/targets/7.1/bridge/diagnosticwriter/lint.go +411 -0
- package/targets/7.1/bridge/diagnosticwriter/shim.go +56 -0
- package/targets/7.1/bridge/lsp/extra-shim.json +4 -0
- package/targets/7.1/bridge/lsp/go.mod +16 -0
- package/targets/7.1/bridge/lsp/go.sum +26 -0
- package/targets/7.1/bridge/lsp/shim.go +112 -0
- package/targets/7.1/bridge/parser/extra-shim.json +4 -0
- package/targets/7.1/bridge/parser/go.mod +14 -0
- package/targets/7.1/bridge/parser/go.sum +24 -0
- package/targets/7.1/bridge/parser/shim.go +61 -0
- package/targets/7.1/bridge/printer/emithost.go +69 -0
- package/targets/7.1/bridge/printer/go.mod +15 -0
- package/targets/7.1/bridge/printer/go.sum +24 -0
- package/targets/7.1/bridge/printer/shim.go +168 -0
- package/targets/7.1/bridge/printer/sourcemap.go +49 -0
- package/targets/7.1/bridge/scanner/extra-shim.json +4 -0
- package/targets/7.1/bridge/scanner/go.mod +14 -0
- package/targets/7.1/bridge/scanner/go.sum +20 -0
- package/targets/7.1/bridge/scanner/regexp.go +42 -0
- package/targets/7.1/bridge/scanner/shim.go +137 -0
- package/targets/7.1/bridge/stringutil/extra-shim.json +1 -0
- package/targets/7.1/bridge/stringutil/go.mod +5 -0
- package/targets/7.1/bridge/stringutil/go.sum +2 -0
- package/targets/7.1/bridge/stringutil/shim.go +131 -0
- package/targets/7.1/bridge/transformers/go.mod +15 -0
- package/targets/7.1/bridge/transformers/go.sum +24 -0
- package/targets/7.1/bridge/transformers/shim.go +24 -0
- package/targets/7.1/bridge/tsoptions/command_line_raw.go +44 -0
- package/targets/7.1/bridge/tsoptions/extra-shim.json +4 -0
- package/targets/7.1/bridge/tsoptions/go.mod +15 -0
- package/targets/7.1/bridge/tsoptions/go.sum +24 -0
- package/targets/7.1/bridge/tsoptions/neutral.go +47 -0
- package/targets/7.1/bridge/tsoptions/shim.go +193 -0
- package/targets/7.1/bridge/tspath/extra-shim.json +4 -0
- package/targets/7.1/bridge/tspath/go.mod +5 -0
- package/targets/7.1/bridge/tspath/go.sum +6 -0
- package/targets/7.1/bridge/tspath/neutral.go +142 -0
- package/targets/7.1/bridge/tspath/shim.go +382 -0
- package/targets/7.1/bridge/vfs/cachedvfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/cachedvfs/go.mod +5 -0
- package/targets/7.1/bridge/vfs/cachedvfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/cachedvfs/shim.go +12 -0
- package/targets/7.1/bridge/vfs/decode.go +26 -0
- package/targets/7.1/bridge/vfs/decode_test.go +42 -0
- package/targets/7.1/bridge/vfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/go.mod +10 -0
- package/targets/7.1/bridge/vfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/neutral.go +23 -0
- package/targets/7.1/bridge/vfs/osvfs/extra-shim.json +4 -0
- package/targets/7.1/bridge/vfs/osvfs/go.mod +10 -0
- package/targets/7.1/bridge/vfs/osvfs/go.sum +10 -0
- package/targets/7.1/bridge/vfs/osvfs/shim.go +14 -0
- package/targets/7.1/bridge/vfs/shim.go +27 -0
- package/targets/7.1/facade/ast/facade_gen.go +2691 -0
- package/targets/7.1/facade/ast/go.mod +20 -0
- package/targets/7.1/facade/ast/go.sum +20 -0
- package/targets/7.1/facade/astnav/facade_gen.go +15 -0
- package/targets/7.1/facade/astnav/go.mod +22 -0
- package/targets/7.1/facade/astnav/go.sum +22 -0
- package/targets/7.1/facade/bundled/facade_gen.go +32 -0
- package/targets/7.1/facade/bundled/go.mod +21 -0
- package/targets/7.1/facade/bundled/go.sum +10 -0
- package/targets/7.1/facade/checker/facade_gen.go +563 -0
- package/targets/7.1/facade/checker/go.mod +26 -0
- package/targets/7.1/facade/checker/go.sum +24 -0
- package/targets/7.1/facade/compiler/facade_gen.go +198 -0
- package/targets/7.1/facade/compiler/go.mod +41 -0
- package/targets/7.1/facade/compiler/go.sum +24 -0
- package/targets/7.1/facade/core/facade_gen.go +130 -0
- package/targets/7.1/facade/core/go.mod +12 -0
- package/targets/7.1/facade/core/go.sum +8 -0
- package/targets/7.1/facade/diagnosticwriter/facade_gen.go +36 -0
- package/targets/7.1/facade/diagnosticwriter/go.mod +22 -0
- package/targets/7.1/facade/diagnosticwriter/go.sum +20 -0
- package/targets/7.1/facade/lsp/facade_gen.go +31 -0
- package/targets/7.1/facade/lsp/go.mod +19 -0
- package/targets/7.1/facade/lsp/go.sum +26 -0
- package/targets/7.1/facade/parser/facade_gen.go +102 -0
- package/targets/7.1/facade/parser/go.mod +25 -0
- package/targets/7.1/facade/parser/go.sum +24 -0
- package/targets/7.1/facade/printer/facade_gen.go +74 -0
- package/targets/7.1/facade/printer/go.mod +26 -0
- package/targets/7.1/facade/printer/go.sum +24 -0
- package/targets/7.1/facade/scanner/facade_gen.go +191 -0
- package/targets/7.1/facade/scanner/go.mod +25 -0
- package/targets/7.1/facade/scanner/go.sum +20 -0
- package/targets/7.1/facade/stringutil/facade_gen.go +176 -0
- package/targets/7.1/facade/stringutil/go.mod +9 -0
- package/targets/7.1/facade/stringutil/go.sum +2 -0
- package/targets/7.1/facade/transformers/facade_gen.go +12 -0
- package/targets/7.1/facade/transformers/go.mod +18 -0
- package/targets/7.1/facade/transformers/go.sum +24 -0
- package/targets/7.1/facade/tsoptions/facade_gen.go +274 -0
- package/targets/7.1/facade/tsoptions/go.mod +32 -0
- package/targets/7.1/facade/tsoptions/go.sum +24 -0
- package/targets/7.1/facade/tspath/facade_gen.go +550 -0
- package/targets/7.1/facade/tspath/go.mod +9 -0
- package/targets/7.1/facade/tspath/go.sum +6 -0
- package/targets/7.1/facade/vfs/cachedvfs/facade_gen.go +17 -0
- package/targets/7.1/facade/vfs/cachedvfs/go.mod +18 -0
- package/targets/7.1/facade/vfs/cachedvfs/go.sum +10 -0
- package/targets/7.1/facade/vfs/facade_gen.go +47 -0
- package/targets/7.1/facade/vfs/go.mod +18 -0
- package/targets/7.1/facade/vfs/go.sum +10 -0
- package/targets/7.1/facade/vfs/osvfs/facade_gen.go +20 -0
- package/targets/7.1/facade/vfs/osvfs/go.mod +21 -0
- package/targets/7.1/facade/vfs/osvfs/go.sum +10 -0
- package/tools/gen_facade/committed_facades_match_their_bridges_test.go +57 -0
- package/tools/gen_facade/facade_manifest_points_into_the_bridge_root_test.go +75 -0
- package/tools/gen_facade/facade_spells_internal_types_through_bridge_aliases_test.go +75 -0
- package/tools/gen_facade/facade_types_are_their_bridge_types_test.go +99 -0
- package/tools/gen_facade/go.mod +10 -0
- package/tools/gen_facade/go.sum +8 -0
- package/tools/gen_facade/main.go +734 -0
- package/tools/gen_shims/go.mod +4 -4
- package/tools/gen_shims/go.sum +6 -6
- package/tools/gen_shims/main.go +124 -66
- package/tools/gen_shims/mirror_structs_terminate_on_unexported_cycles_test.go +101 -0
- package/tools/shim_audit/baseline-7.1.json +720 -0
- package/tools/shim_audit/baseline.json +5 -4
- package/tools/shim_audit/go.mod +4 -4
- package/tools/shim_audit/go.sum +6 -6
- package/tools/shim_audit/linkname_signatures.go +178 -0
- package/tools/shim_audit/linkname_signatures_match_their_targets_test.go +64 -0
- package/tools/shim_audit/linkname_targets_follow_the_audited_compiler_test.go +38 -0
- package/tools/shim_audit/main.go +29 -4
- package/tools/shim_audit/neutral_api.go +160 -0
- package/tools/shim_audit/neutral_api_must_match_across_targets_test.go +74 -0
- package/utility/host.go +5 -4
- package/utility/preamble_output.go +15 -15
- package/utility/serve.go +1 -1
package/driver/emit_plugin.go
CHANGED
|
@@ -7,6 +7,7 @@ import (
|
|
|
7
7
|
"sync"
|
|
8
8
|
|
|
9
9
|
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
10
|
+
shimchecker "github.com/microsoft/typescript-go/shim/checker"
|
|
10
11
|
shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
11
12
|
shimcore "github.com/microsoft/typescript-go/shim/core"
|
|
12
13
|
shimprinter "github.com/microsoft/typescript-go/shim/printer"
|
|
@@ -15,31 +16,32 @@ import (
|
|
|
15
16
|
)
|
|
16
17
|
|
|
17
18
|
// pluginEmitHost implements printer.EmitHost (and, structurally,
|
|
18
|
-
// SourceFileMayBeEmittedHost
|
|
19
|
-
//
|
|
20
|
-
//
|
|
19
|
+
// SourceFileMayBeEmittedHost, OutputPathsHost and, on TypeScript 7.1,
|
|
20
|
+
// SourceMapHost — their methods are a subset) by delegating to the driver
|
|
21
|
+
// Program, exactly like tsgo's internal emitHost. Its emit resolver comes from
|
|
22
|
+
// the program's single checker, guarded to the program's original member
|
|
23
|
+
// accesses. The methods whose names or types differ between compiler targets
|
|
24
|
+
// live in target_ts70.go and target_ts71.go.
|
|
21
25
|
type pluginEmitHost struct {
|
|
22
|
-
program
|
|
23
|
-
|
|
26
|
+
program *shimcompiler.Program
|
|
27
|
+
checker *shimchecker.Checker
|
|
28
|
+
originalMembers map[*shimast.Node]struct{}
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
func (h *pluginEmitHost) Options() *shimcore.CompilerOptions { return h.program.Options() }
|
|
27
32
|
func (h *pluginEmitHost) SourceFiles() []*shimast.SourceFile { return h.program.SourceFiles() }
|
|
28
|
-
func (h *pluginEmitHost)
|
|
29
|
-
return h.program.
|
|
33
|
+
func (h *pluginEmitHost) CommonSourceDirectory() shimtspath.RootedDirectoryPath {
|
|
34
|
+
return h.program.CommonSourceDirectory()
|
|
35
|
+
}
|
|
36
|
+
func (h *pluginEmitHost) IsEmitBlocked(file shimtspath.RootedFilePath) bool {
|
|
37
|
+
return h.program.IsEmitBlocked(file)
|
|
30
38
|
}
|
|
31
|
-
func (h *pluginEmitHost)
|
|
32
|
-
func (h *pluginEmitHost) CommonSourceDirectory() string { return h.program.CommonSourceDirectory() }
|
|
33
|
-
func (h *pluginEmitHost) IsEmitBlocked(file string) bool { return h.program.IsEmitBlocked(file) }
|
|
34
|
-
func (h *pluginEmitHost) WriteFile(fileName string, text string) error {
|
|
39
|
+
func (h *pluginEmitHost) WriteFile(fileName shimtspath.RootedFilePath, text string) error {
|
|
35
40
|
return h.program.Host().FS().WriteFile(fileName, text)
|
|
36
41
|
}
|
|
37
42
|
func (h *pluginEmitHost) GetEmitModuleFormatOfFile(file shimast.HasFileName) shimcore.ModuleKind {
|
|
38
43
|
return h.program.GetEmitModuleFormatOfFile(file)
|
|
39
44
|
}
|
|
40
|
-
func (h *pluginEmitHost) GetEmitResolver() shimprinter.EmitResolver {
|
|
41
|
-
return h.emitResolver
|
|
42
|
-
}
|
|
43
45
|
|
|
44
46
|
// guardedEmitResolver only resolves member accesses from the program's input
|
|
45
47
|
// trees. ParseNode follows original links but trusts the synthesized flag:
|
|
@@ -67,7 +69,7 @@ func collectOriginalMembers(node *shimast.Node, members map[*shimast.Node]struct
|
|
|
67
69
|
return false
|
|
68
70
|
})
|
|
69
71
|
}
|
|
70
|
-
func (h *pluginEmitHost) GetProjectReferenceFromSource(path shimtspath.
|
|
72
|
+
func (h *pluginEmitHost) GetProjectReferenceFromSource(path shimtspath.PathKey) *shimtsoptions.SourceOutputAndProjectReference {
|
|
71
73
|
return h.program.GetProjectReferenceFromSource(path)
|
|
72
74
|
}
|
|
73
75
|
func (h *pluginEmitHost) IsSourceFileFromExternalLibrary(file *shimast.SourceFile) bool {
|
|
@@ -79,8 +81,12 @@ func (h *pluginEmitHost) IsSourceFileFromExternalLibrary(file *shimast.SourceFil
|
|
|
79
81
|
// used by builtin transforms; they do not make every arbitrary constructed tree
|
|
80
82
|
// valid. Injected bindings must use the supported generated-name policy and
|
|
81
83
|
// preserve the original links needed by the particular transformation.
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
+
// Build returned nodes with ec.Factory, or with a factory created inside the
|
|
85
|
+
// call. A package-global or retained factory shares one node arena across files
|
|
86
|
+
// and Programs, so once distinct Programs emit at the same time its nodes race
|
|
87
|
+
// and can print under another file. Returning nil leaves the file unchanged.
|
|
88
|
+
// This is the AST-integration contract that replaces text-splice: a plugin
|
|
89
|
+
// returns AST, not text. The shape mirrors a
|
|
84
90
|
// classic source-file transformer, with EmitContext supplied on each call;
|
|
85
91
|
// adapting an existing transformer still requires the native AST and context
|
|
86
92
|
// APIs rather than only changing its function signature.
|
|
@@ -88,7 +94,7 @@ func (h *pluginEmitHost) IsSourceFileFromExternalLibrary(file *shimast.SourceFil
|
|
|
88
94
|
// @evidence contracts/common.md#principled-implementation Generated AST identity belongs to the shared emit context, allowing builtin import and module transforms to interpret plugin nodes.
|
|
89
95
|
// @evidence contracts/common.md#clear-and-simple-design A per-source callback returns an optional replacement; the host owns ordering and printing.
|
|
90
96
|
// @evidence contracts/common.md#prohibited-implementation-shortcuts The supported AST factory and original links replace textual alias guesses or patched compiler methods.
|
|
91
|
-
// @evidence contracts/common.md#meaningful-documentation Native prose specifies context identity, nil behavior, and source transformation following the documentation skill.
|
|
97
|
+
// @evidence contracts/common.md#meaningful-documentation Native prose specifies context identity, the per-file factory requirement and its concurrency consequence, nil behavior, and source transformation following the documentation skill.
|
|
92
98
|
// @evidenceExclude contracts/portability.md#os-neutral-implementation The callback signature defines AST work rather than native path or process operations.
|
|
93
99
|
// @evidenceExclude contracts/performance.md#efficient-algorithms Concrete callbacks select their algorithms; the signature performs no traversal.
|
|
94
100
|
// @evidenceExclude contracts/performance.md#reuse-equivalent-work The signature owns no shared-work coordinator.
|
|
@@ -239,7 +245,9 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
239
245
|
}
|
|
240
246
|
return p.pluginEmitDiagnostics("analysis-only emit", result.Diagnostics)
|
|
241
247
|
}
|
|
242
|
-
|
|
248
|
+
// noEmit returned above, so this applies exactly noEmitOnError's
|
|
249
|
+
// whole-program diagnostic gate.
|
|
250
|
+
if result := handleNoEmit(context.Background(), p.TSProgram); result != nil {
|
|
243
251
|
return p.pluginEmitDiagnostics("pre-emit checking", result.Diagnostics)
|
|
244
252
|
}
|
|
245
253
|
hasTransform := false
|
|
@@ -251,15 +259,15 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
251
259
|
}
|
|
252
260
|
if !hasTransform {
|
|
253
261
|
correctSourceMap := p.NewSourceMapCorrector()
|
|
254
|
-
result, diagnostics, err := p.EmitAllRaw(func(fileName, text string, data *shimcompiler.WriteFileData) error {
|
|
255
|
-
corrected, err := correctSourceMap(fileName, text)
|
|
262
|
+
result, diagnostics, err := p.EmitAllRaw(func(fileName shimtspath.RootedFilePath, text string, data *shimcompiler.WriteFileData) error {
|
|
263
|
+
corrected, err := correctSourceMap(string(fileName), text)
|
|
256
264
|
if err != nil {
|
|
257
265
|
return err
|
|
258
266
|
}
|
|
259
267
|
if writeFile != nil {
|
|
260
268
|
return writeFile(fileName, corrected, data)
|
|
261
269
|
}
|
|
262
|
-
return DefaultWriteFile(fileName, corrected)
|
|
270
|
+
return DefaultWriteFile(string(fileName), corrected)
|
|
263
271
|
})
|
|
264
272
|
if err != nil || result == nil {
|
|
265
273
|
return diagnostics, err
|
|
@@ -276,15 +284,15 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
276
284
|
for _, sf := range p.TSProgram.SourceFiles() {
|
|
277
285
|
collectOriginalMembers(sf.AsNode(), members)
|
|
278
286
|
}
|
|
279
|
-
host := &pluginEmitHost{program: p.TSProgram,
|
|
287
|
+
host := &pluginEmitHost{program: p.TSProgram, checker: p.Checker, originalMembers: members}
|
|
280
288
|
|
|
281
289
|
// noEmitOnError applies to the whole build. The JS lane runs before the
|
|
282
290
|
// declaration lane, so defer callbacks until both have succeeded. Outside
|
|
283
291
|
// that option keep upstream's emit-despite-errors behavior.
|
|
284
292
|
output := newPluginEmitOutput(writeFile, options.NoEmitOnError.IsTrue())
|
|
285
293
|
correctSourceMap := p.NewSourceMapCorrector()
|
|
286
|
-
for _, sf := range shimcompiler.
|
|
287
|
-
paths := shimcompiler.
|
|
294
|
+
for _, sf := range shimcompiler.SourceFilesToEmit(host) {
|
|
295
|
+
paths := shimcompiler.OutputPathsFor(sf, options, host)
|
|
288
296
|
if paths.JsFilePath() != "" && !p.outputEscapesOutDir(paths.JsFilePath()) {
|
|
289
297
|
ec := shimprinter.NewEmitContext()
|
|
290
298
|
out := sf
|
|
@@ -330,9 +338,7 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
330
338
|
// Marks accumulate on the checker and are never cleared, so marking one
|
|
331
339
|
// fixed tree per file also stops a second emit on the same Program from
|
|
332
340
|
// inheriting the first pass's plugin-tree marks.
|
|
333
|
-
|
|
334
|
-
out = tr.TransformSourceFile(out)
|
|
335
|
-
}
|
|
341
|
+
out = applyScriptTransformers(ec, host, sf, out)
|
|
336
342
|
// Print through the source-map-aware helper for an external sourceMap or
|
|
337
343
|
// an inlineSourceMap trailer, and an emitBOM leading mark: the hand-assembled
|
|
338
344
|
// emit pipeline does not run tsgo's emitter, so everything printSourceFile
|
|
@@ -346,26 +352,24 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
346
352
|
// the external `.js.map` and an inline base64 map embedded in the JS.
|
|
347
353
|
if p.SourcePreamble != "" {
|
|
348
354
|
var err error
|
|
349
|
-
if printed.JS, err = correctSourceMap(paths.JsFilePath(), printed.JS); err != nil {
|
|
355
|
+
if printed.JS, err = correctSourceMap(string(paths.JsFilePath()), printed.JS); err != nil {
|
|
350
356
|
return nil, err
|
|
351
357
|
}
|
|
352
358
|
if printed.MapPath != "" {
|
|
353
|
-
if printed.MapText, err = correctSourceMap(printed.MapPath, printed.MapText); err != nil {
|
|
359
|
+
if printed.MapText, err = correctSourceMap(string(printed.MapPath), printed.MapText); err != nil {
|
|
354
360
|
return nil, err
|
|
355
361
|
}
|
|
356
362
|
}
|
|
357
363
|
}
|
|
358
364
|
// The emitter hands its writeFile callback a WriteFileData for the
|
|
359
|
-
// JavaScript and
|
|
360
|
-
// `writeText
|
|
361
|
-
// same. See writePluginEmitOutput for what the struct
|
|
362
|
-
// why the remaining fields stay zero.
|
|
363
|
-
if err := p.writePluginEmitOutput(paths.JsFilePath(), printed.JS,
|
|
364
|
-
SourceMapUrlPos: printed.SourceMapUrlPos,
|
|
365
|
-
}, output.write); err != nil {
|
|
365
|
+
// JavaScript and, for the map, nil on TypeScript 7.0 or one carrying only
|
|
366
|
+
// the emitted source file on 7.1 (printSourceFile's `writeText` call), so
|
|
367
|
+
// this lane does the same. See writePluginEmitOutput for what the struct
|
|
368
|
+
// carries here and why the remaining fields stay zero.
|
|
369
|
+
if err := p.writePluginEmitOutput(paths.JsFilePath(), printed.JS, scriptWriteFileData(sf, printed.SourceMapUrlPos), output.write); err != nil {
|
|
366
370
|
return nil, fmt.Errorf("driver: native plugin JavaScript emit failed: %w", err)
|
|
367
371
|
}
|
|
368
|
-
if err := p.writePluginEmitOutput(printed.MapPath, printed.MapText,
|
|
372
|
+
if err := p.writePluginEmitOutput(printed.MapPath, printed.MapText, sourceMapWriteFileData(sf), output.write); err != nil {
|
|
369
373
|
return nil, fmt.Errorf("driver: native plugin source map emit failed: %w", err)
|
|
370
374
|
}
|
|
371
375
|
}
|
|
@@ -374,7 +378,7 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
374
378
|
// so it also runs for a JavaScript-only `incremental` / `composite` project
|
|
375
379
|
// that has no declarations to write at all.
|
|
376
380
|
if !options.GetEmitDeclarations() && !p.emitsBuildInfo() {
|
|
377
|
-
if result :=
|
|
381
|
+
if result := handleNoEmit(context.Background(), p.TSProgram); result != nil {
|
|
378
382
|
return p.pluginEmitDiagnostics("JavaScript emit", result.Diagnostics)
|
|
379
383
|
}
|
|
380
384
|
return nil, output.flush()
|
|
@@ -398,7 +402,7 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
398
402
|
var wfMu sync.Mutex
|
|
399
403
|
result := p.emitProgram(shimcompiler.EmitOptions{
|
|
400
404
|
EmitOnly: shimcompiler.EmitOnlyDts,
|
|
401
|
-
WriteFile: func(fileName
|
|
405
|
+
WriteFile: func(fileName shimtspath.RootedFilePath, text string, data *shimcompiler.WriteFileData) error {
|
|
402
406
|
wfMu.Lock()
|
|
403
407
|
defer wfMu.Unlock()
|
|
404
408
|
if p.outputEscapesOutDir(fileName) {
|
|
@@ -407,7 +411,7 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
407
411
|
}
|
|
408
412
|
return nil
|
|
409
413
|
}
|
|
410
|
-
corrected, err := correctSourceMap(fileName, text)
|
|
414
|
+
corrected, err := correctSourceMap(string(fileName), text)
|
|
411
415
|
if err != nil {
|
|
412
416
|
return err
|
|
413
417
|
}
|
|
@@ -435,6 +439,10 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
435
439
|
// when none was written. PrintFileWithSourceMap records it exactly where
|
|
436
440
|
// printSourceFile does, so a consumer that relocates or rewrites the trailer
|
|
437
441
|
// works the same on both lanes.
|
|
442
|
+
// - SourceFile, on TypeScript 7.1: the program source file the artifact was
|
|
443
|
+
// emitted from, the file as parsed rather than the transformed tree,
|
|
444
|
+
// exactly as the emitter's own field names its input file. The map carries
|
|
445
|
+
// only this; on 7.0, where the field does not exist, the map gets nil.
|
|
438
446
|
// - Diagnostics: always empty. The emitter's field carries its accumulated
|
|
439
447
|
// emitterDiagnostics, which on the JavaScript lane are its own write
|
|
440
448
|
// failures; here a write failure is returned as an `error` from
|
|
@@ -450,12 +458,12 @@ func (p *Program) EmitWithPluginTransformers(transforms []PluginTransform, write
|
|
|
450
458
|
// Nothing on this lane reads the struct back afterwards: unlike tsgo's emitter,
|
|
451
459
|
// EmitWithPluginTransformers builds no EmitResult, so there is no EmittedFiles
|
|
452
460
|
// list for a callee-set SkippedDtsWrite to keep a file out of.
|
|
453
|
-
func (p *Program) writePluginEmitOutput(fileName, text string, data *shimcompiler.WriteFileData, writeFile shimcompiler.WriteFile) error {
|
|
461
|
+
func (p *Program) writePluginEmitOutput(fileName shimtspath.RootedFilePath, text string, data *shimcompiler.WriteFileData, writeFile shimcompiler.WriteFile) error {
|
|
454
462
|
if fileName == "" || p.outputEscapesOutDir(fileName) {
|
|
455
463
|
return nil
|
|
456
464
|
}
|
|
457
465
|
if writeFile != nil {
|
|
458
466
|
return writeFile(fileName, text, data)
|
|
459
467
|
}
|
|
460
|
-
return DefaultWriteFile(fileName, text)
|
|
468
|
+
return DefaultWriteFile(string(fileName), text)
|
|
461
469
|
}
|
|
@@ -6,6 +6,7 @@ import (
|
|
|
6
6
|
|
|
7
7
|
shimast "github.com/microsoft/typescript-go/shim/ast"
|
|
8
8
|
shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
9
|
+
shimtspath "github.com/microsoft/typescript-go/shim/tspath"
|
|
9
10
|
)
|
|
10
11
|
|
|
11
12
|
// PluginEmitError reports compiler errors from a native plugin emit. The same
|
|
@@ -63,7 +64,7 @@ func (p *Program) pluginEmitDiagnostics(phase string, raw []*shimast.Diagnostic)
|
|
|
63
64
|
Diagnostics: diagnostics,
|
|
64
65
|
Phase: phase,
|
|
65
66
|
Declarations: p.TSProgram.Options().GetEmitDeclarations(),
|
|
66
|
-
cwd: p.TSProgram.GetCurrentDirectory(),
|
|
67
|
+
cwd: string(p.TSProgram.GetCurrentDirectory()),
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -74,22 +75,22 @@ type pluginEmitOutput struct {
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
type pluginEmitFile struct {
|
|
77
|
-
name
|
|
78
|
+
name shimtspath.RootedFilePath
|
|
78
79
|
text string
|
|
79
80
|
data *shimcompiler.WriteFileData
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
func newPluginEmitOutput(writeFile shimcompiler.WriteFile, buffered bool) *pluginEmitOutput {
|
|
83
84
|
if writeFile == nil {
|
|
84
|
-
writeFile = func(name, text string, _ *shimcompiler.WriteFileData) error {
|
|
85
|
-
return DefaultWriteFile(name, text)
|
|
85
|
+
writeFile = func(name shimtspath.RootedFilePath, text string, _ *shimcompiler.WriteFileData) error {
|
|
86
|
+
return DefaultWriteFile(string(name), text)
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
return &pluginEmitOutput{writeFile: writeFile, buffered: buffered}
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
// The caller serializes declaration writes; JavaScript and flush are serial.
|
|
92
|
-
func (o *pluginEmitOutput) write(name, text string, data *shimcompiler.WriteFileData) error {
|
|
93
|
+
func (o *pluginEmitOutput) write(name shimtspath.RootedFilePath, text string, data *shimcompiler.WriteFileData) error {
|
|
93
94
|
if !o.buffered {
|
|
94
95
|
return o.writeFile(name, text, data)
|
|
95
96
|
}
|
|
@@ -52,43 +52,40 @@ func (p *Program) NewEmitProvenanceRecorder(writeFile shimcompiler.WriteFile) (s
|
|
|
52
52
|
program := p.TSProgram
|
|
53
53
|
observer := p.inputObserver
|
|
54
54
|
cwd := program.GetCurrentDirectory()
|
|
55
|
-
|
|
55
|
+
caseSensitivity := shimcompiler.ProgramCaseSensitivity(program)
|
|
56
56
|
nativePath := func(name string) string {
|
|
57
57
|
return filepath.FromSlash(shimtspath.GetNormalizedAbsolutePath(name, cwd))
|
|
58
58
|
}
|
|
59
59
|
coordinateKey := func(name string) string {
|
|
60
|
-
return shimtspath.
|
|
61
|
-
shimtspath.NormalizePath(nativePath(name)),
|
|
62
|
-
caseSensitive,
|
|
63
|
-
)
|
|
60
|
+
return shimtspath.Canonicalize(caseSensitivity, shimtspath.NormalizePath(nativePath(name)))
|
|
64
61
|
}
|
|
65
62
|
candidates := map[string][]string{}
|
|
66
63
|
host := &pluginEmitHost{program: program}
|
|
67
|
-
for _, source := range shimcompiler.
|
|
68
|
-
output := shimcompiler.
|
|
69
|
-
switch strings.ToLower(filepath.Ext(output)) {
|
|
64
|
+
for _, source := range shimcompiler.SourceFilesToEmit(host) {
|
|
65
|
+
output := shimcompiler.OutputPathsFor(source, program.Options(), host).JsFilePath()
|
|
66
|
+
switch strings.ToLower(filepath.Ext(string(output))) {
|
|
70
67
|
case ".js", ".jsx", ".mjs", ".cjs":
|
|
71
|
-
key := coordinateKey(output)
|
|
72
|
-
candidates[key] = append(candidates[key], nativePath(source.FileName()))
|
|
68
|
+
key := coordinateKey(string(output))
|
|
69
|
+
candidates[key] = append(candidates[key], nativePath(string(source.FileName())))
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
72
|
if writeFile == nil {
|
|
76
|
-
writeFile = func(name, text string, _ *shimcompiler.WriteFileData) error {
|
|
77
|
-
return DefaultWriteFile(name, text)
|
|
73
|
+
writeFile = func(name shimtspath.RootedFilePath, text string, _ *shimcompiler.WriteFileData) error {
|
|
74
|
+
return DefaultWriteFile(string(name), text)
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
written := map[string]string{}
|
|
81
78
|
var mu sync.Mutex
|
|
82
|
-
record := func(name, text string, data *shimcompiler.WriteFileData) error {
|
|
79
|
+
record := func(name shimtspath.RootedFilePath, text string, data *shimcompiler.WriteFileData) error {
|
|
83
80
|
mu.Lock()
|
|
84
81
|
defer mu.Unlock()
|
|
85
82
|
if err := writeFile(name, text, data); err != nil {
|
|
86
83
|
return err
|
|
87
84
|
}
|
|
88
85
|
if data == nil || !data.SkippedDtsWrite {
|
|
89
|
-
switch strings.ToLower(filepath.Ext(name)) {
|
|
86
|
+
switch strings.ToLower(filepath.Ext(string(name))) {
|
|
90
87
|
case ".js", ".jsx", ".mjs", ".cjs":
|
|
91
|
-
written[nativePath(name)] = coordinateKey(name)
|
|
88
|
+
written[nativePath(string(name))] = coordinateKey(string(name))
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
91
|
return nil
|
package/driver/graph.go
CHANGED
|
@@ -103,10 +103,10 @@ func NewTransformGraph(prog *Program, cwd string) *TransformGraph {
|
|
|
103
103
|
}
|
|
104
104
|
for _, file := range prog.TSProgram.SourceFiles() {
|
|
105
105
|
fileName := file.FileName()
|
|
106
|
-
if strings.HasPrefix(fileName, bundledScheme) {
|
|
106
|
+
if strings.HasPrefix(string(fileName), bundledScheme) {
|
|
107
107
|
continue
|
|
108
108
|
}
|
|
109
|
-
key := TransformOutputKey(cwd, fileName)
|
|
109
|
+
key := TransformOutputKey(cwd, string(fileName))
|
|
110
110
|
if shimcompiler.FileAffectsGlobalScope(file) {
|
|
111
111
|
graph.Globals = append(graph.Globals, key)
|
|
112
112
|
}
|
|
@@ -216,17 +216,17 @@ func referenceTargets(prog *Program, cwd string, file *ast.SourceFile) []string
|
|
|
216
216
|
paths := shimcompiler.GetReferencedFilePaths(prog.TSProgram, file)
|
|
217
217
|
targets := make([]string, 0, len(paths))
|
|
218
218
|
for _, referencedPath := range paths {
|
|
219
|
-
// Referenced paths are case-canonicalized tspath.
|
|
219
|
+
// Referenced paths are case-canonicalized tspath.PathKey values; recover the
|
|
220
220
|
// resident source and its real spelling from the Program. The incremental
|
|
221
221
|
// helper can retain a raw extensionless project-reference directive even
|
|
222
222
|
// when no corresponding source became resident. That spelling is a
|
|
223
223
|
// resolver candidate, not a realized graph edge, and has no compiler-time
|
|
224
224
|
// content proof.
|
|
225
|
-
resolved := prog.TSProgram.GetSourceFileByPath(shimtspath.
|
|
226
|
-
if resolved == nil || resolved == file || strings.HasPrefix(resolved.FileName(), bundledScheme) {
|
|
225
|
+
resolved := prog.TSProgram.GetSourceFileByPath(shimtspath.PathKey(referencedPath))
|
|
226
|
+
if resolved == nil || resolved == file || strings.HasPrefix(string(resolved.FileName()), bundledScheme) {
|
|
227
227
|
continue
|
|
228
228
|
}
|
|
229
|
-
targets = append(targets, TransformOutputKey(cwd, resolved.FileName()))
|
|
229
|
+
targets = append(targets, TransformOutputKey(cwd, string(resolved.FileName())))
|
|
230
230
|
}
|
|
231
231
|
sort.Strings(targets)
|
|
232
232
|
return targets
|
|
@@ -241,10 +241,10 @@ func configChain(prog *Program, cwd string) []string {
|
|
|
241
241
|
return configs
|
|
242
242
|
}
|
|
243
243
|
if source := parsed.ConfigFile.SourceFile; source != nil {
|
|
244
|
-
configs = append(configs, TransformOutputKey(cwd, source.FileName()))
|
|
244
|
+
configs = append(configs, TransformOutputKey(cwd, string(source.FileName())))
|
|
245
245
|
}
|
|
246
246
|
for _, extended := range parsed.ExtendedSourceFiles() {
|
|
247
|
-
configs = append(configs, TransformOutputKey(cwd, extended))
|
|
247
|
+
configs = append(configs, TransformOutputKey(cwd, string(extended)))
|
|
248
248
|
}
|
|
249
249
|
return configs
|
|
250
250
|
}
|
package/driver/host.go
CHANGED
|
@@ -12,6 +12,7 @@ package driver
|
|
|
12
12
|
import (
|
|
13
13
|
"github.com/microsoft/typescript-go/shim/bundled"
|
|
14
14
|
shimcompiler "github.com/microsoft/typescript-go/shim/compiler"
|
|
15
|
+
shimtspath "github.com/microsoft/typescript-go/shim/tspath"
|
|
15
16
|
"github.com/microsoft/typescript-go/shim/vfs"
|
|
16
17
|
"github.com/microsoft/typescript-go/shim/vfs/cachedvfs"
|
|
17
18
|
"github.com/microsoft/typescript-go/shim/vfs/osvfs"
|
|
@@ -34,21 +35,30 @@ func DefaultFS() vfs.FS {
|
|
|
34
35
|
return bundled.WrapFS(cachedvfs.From(osvfs.FS()))
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
// DefaultHost returns a CompilerHost
|
|
38
|
-
//
|
|
38
|
+
// DefaultHost returns a CompilerHost over fs that can find tsgo's bundled
|
|
39
|
+
// library files via `bundled.LibPath()`. On the TypeScript 7.0 target the host
|
|
40
|
+
// carries cwd as the Program's working directory; on 7.1 the parsed command
|
|
41
|
+
// line's base directory anchors a Program, and cwd is unused.
|
|
39
42
|
// The constructor retains the supplied cwd and FS without independently
|
|
40
43
|
// normalizing or probing that anchor. In noembed builds the native library
|
|
41
44
|
// provider initializes a process-wide disk location, which can perform native
|
|
42
45
|
// queries or panic if its required library layout is unavailable.
|
|
43
46
|
//
|
|
44
|
-
// @evidence contracts/common.md#principled-implementation The supplied FS and cwd are passed to the upstream CompilerHost with the matching bundled-library location.
|
|
47
|
+
// @evidence contracts/common.md#principled-implementation The supplied FS and cwd are passed to the target's upstream CompilerHost constructor through shimcompiler.NewHost with the matching bundled-library location.
|
|
45
48
|
// @evidence contracts/common.md#clear-and-simple-design Host construction stays in one adapter used by initial and incremental program creation.
|
|
46
49
|
// @evidence contracts/common.md#prohibited-implementation-shortcuts The supported CompilerHost constructor owns behavior without an injected foreign-method replacement.
|
|
47
|
-
// @evidence contracts/common.md#meaningful-documentation Native prose names
|
|
50
|
+
// @evidence contracts/common.md#meaningful-documentation Native prose names each target's use of cwd and bundled library lookup under documentation-skill guidance.
|
|
48
51
|
// @evidence contracts/portability.md#os-neutral-implementation The host uses the supplied filesystem's native capabilities and upstream path handling rather than hardcoded OS path rules.
|
|
49
52
|
// @evidence contracts/performance.md#bound-retention-and-release-resources The new host transfers its cwd/library strings and supplied FS reference to the caller; keeping it reachable also keeps that FS stack and its caches reachable. The factory adds no separate host cache, handle or release operation.
|
|
50
53
|
// @evidence contracts/performance.md#efficient-algorithms Host allocation initializes fixed fields; embedded library location is a constant, while first noembed location initialization can query executable/realpath/library metadata under the native provider's once cache. This constructor does not parse source files, but delegated location work is not universally a fixed field assignment.
|
|
51
54
|
// @evidenceExclude contracts/performance.md#reuse-equivalent-work Each returned host retains its supplied cwd/FS without a driver-owned cache or request coordinator; the native library provider owns any process-wide location sharing.
|
|
52
55
|
func DefaultHost(cwd string, fs vfs.FS) shimcompiler.CompilerHost {
|
|
53
|
-
return shimcompiler.
|
|
56
|
+
return shimcompiler.NewHost(shimtspath.RootedDirectoryPath(cwd), fs, shimtspath.RootedDirectoryPath(bundled.LibPath()))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// projectHost is DefaultHost for a Program built from a parsed project: on the
|
|
60
|
+
// TypeScript 7.1 target, hosts transforms the project's content-mapped files
|
|
61
|
+
// through its content mappers. A nil hosts yields DefaultHost's host.
|
|
62
|
+
func projectHost(hosts *shimcompiler.ProjectHosts, cwd string, fs vfs.FS) shimcompiler.CompilerHost {
|
|
63
|
+
return hosts.Host(shimtspath.RootedDirectoryPath(cwd), fs, shimtspath.RootedDirectoryPath(bundled.LibPath()))
|
|
54
64
|
}
|
|
@@ -142,7 +142,7 @@ type observedInput struct {
|
|
|
142
142
|
// of attaching post-compile disk hashes to an earlier result.
|
|
143
143
|
type inputObservationFS struct {
|
|
144
144
|
vfs.FS
|
|
145
|
-
|
|
145
|
+
caseSensitivity shimtspath.CaseSensitivity
|
|
146
146
|
mu sync.Mutex
|
|
147
147
|
observations map[string]observedInput
|
|
148
148
|
observationOrder []string
|
|
@@ -152,14 +152,15 @@ type inputObservationFS struct {
|
|
|
152
152
|
func newInputObservationFS(inner vfs.FS) *inputObservationFS {
|
|
153
153
|
return &inputObservationFS{
|
|
154
154
|
FS: inner,
|
|
155
|
-
|
|
155
|
+
caseSensitivity: vfs.CaseSensitivityOf(inner),
|
|
156
156
|
observations: map[string]observedInput{},
|
|
157
157
|
observationSpellings: map[string]string{},
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
func (fs *inputObservationFS) FileExists(
|
|
162
|
-
exists := fs.FS.FileExists(
|
|
161
|
+
func (fs *inputObservationFS) FileExists(file shimtspath.RootedFilePath) bool {
|
|
162
|
+
exists := fs.FS.FileExists(file)
|
|
163
|
+
path := shimtspath.RootedPath(file)
|
|
163
164
|
proof := TransformInputObservation{FileExists: boolPointer(exists)}
|
|
164
165
|
if exists {
|
|
165
166
|
// Existence participates in resolution, but only ReadFile returns bytes
|
|
@@ -171,8 +172,9 @@ func (fs *inputObservationFS) FileExists(path string) bool {
|
|
|
171
172
|
return exists
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
func (fs *inputObservationFS) ReadFile(
|
|
175
|
-
contents, ok := fs.FS.ReadFile(
|
|
175
|
+
func (fs *inputObservationFS) ReadFile(file shimtspath.RootedFilePath) (string, bool) {
|
|
176
|
+
contents, ok := fs.FS.ReadFile(file)
|
|
177
|
+
path := shimtspath.RootedPath(file)
|
|
176
178
|
if ok {
|
|
177
179
|
digest := sha256.Sum256([]byte(contents))
|
|
178
180
|
hash := hex.EncodeToString(digest[:])
|
|
@@ -192,8 +194,9 @@ func (fs *inputObservationFS) ReadFile(path string) (string, bool) {
|
|
|
192
194
|
return contents, ok
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
func (fs *inputObservationFS) DirectoryExists(
|
|
196
|
-
exists := fs.FS.DirectoryExists(
|
|
197
|
+
func (fs *inputObservationFS) DirectoryExists(directory shimtspath.RootedDirectoryPath) bool {
|
|
198
|
+
exists := fs.FS.DirectoryExists(directory)
|
|
199
|
+
path := shimtspath.RootedPath(directory)
|
|
197
200
|
proof := TransformInputObservation{DirectoryExists: boolPointer(exists)}
|
|
198
201
|
if exists {
|
|
199
202
|
proof.Realpath = fs.currentRealpath(path)
|
|
@@ -202,9 +205,9 @@ func (fs *inputObservationFS) DirectoryExists(path string) bool {
|
|
|
202
205
|
return exists
|
|
203
206
|
}
|
|
204
207
|
|
|
205
|
-
func (fs *inputObservationFS) GetAccessibleEntries(
|
|
206
|
-
entries := fs.FS.GetAccessibleEntries(
|
|
207
|
-
fs.observe(
|
|
208
|
+
func (fs *inputObservationFS) GetAccessibleEntries(directory shimtspath.RootedDirectoryPath) vfs.Entries {
|
|
209
|
+
entries := fs.FS.GetAccessibleEntries(directory)
|
|
210
|
+
fs.observe(shimtspath.RootedPath(directory), observedInput{
|
|
208
211
|
proof: TransformInputObservation{
|
|
209
212
|
AccessibleEntries: &TransformInputEntriesObservation{
|
|
210
213
|
Directories: append([]string{}, entries.Directories...),
|
|
@@ -215,7 +218,7 @@ func (fs *inputObservationFS) GetAccessibleEntries(path string) vfs.Entries {
|
|
|
215
218
|
return entries
|
|
216
219
|
}
|
|
217
220
|
|
|
218
|
-
func (fs *inputObservationFS) Stat(path
|
|
221
|
+
func (fs *inputObservationFS) Stat(path shimtspath.RootedPath) vfs.FileInfo {
|
|
219
222
|
info := fs.FS.Stat(path)
|
|
220
223
|
kind := "missing"
|
|
221
224
|
if info == nil {
|
|
@@ -242,16 +245,16 @@ func (fs *inputObservationFS) Stat(path string) vfs.FileInfo {
|
|
|
242
245
|
return info
|
|
243
246
|
}
|
|
244
247
|
|
|
245
|
-
func (fs *inputObservationFS) Realpath(path
|
|
248
|
+
func (fs *inputObservationFS) Realpath(path shimtspath.RootedPath) shimtspath.RootedPath {
|
|
246
249
|
realpath := fs.FS.Realpath(path)
|
|
247
250
|
fs.observe(path, observedInput{
|
|
248
|
-
proof: TransformInputObservation{Realpath: realpathObservation(realpath)},
|
|
251
|
+
proof: TransformInputObservation{Realpath: realpathObservation(string(realpath))},
|
|
249
252
|
})
|
|
250
253
|
return realpath
|
|
251
254
|
}
|
|
252
255
|
|
|
253
|
-
func (fs *inputObservationFS) currentRealpath(path
|
|
254
|
-
return realpathObservation(fs.FS.Realpath(path))
|
|
256
|
+
func (fs *inputObservationFS) currentRealpath(path shimtspath.RootedPath) *TransformInputRealpathObservation {
|
|
257
|
+
return realpathObservation(string(fs.FS.Realpath(path)))
|
|
255
258
|
}
|
|
256
259
|
|
|
257
260
|
func realpathObservation(realpath string) *TransformInputRealpathObservation {
|
|
@@ -272,13 +275,11 @@ func (fs *inputObservationFS) observationKey(path string) string {
|
|
|
272
275
|
if !filepath.IsAbs(path) {
|
|
273
276
|
return ""
|
|
274
277
|
}
|
|
275
|
-
return shimtspath.
|
|
276
|
-
shimtspath.NormalizePath(path),
|
|
277
|
-
fs.caseSensitive,
|
|
278
|
-
)
|
|
278
|
+
return shimtspath.Canonicalize(fs.caseSensitivity, shimtspath.NormalizePath(path))
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
func (fs *inputObservationFS) observe(
|
|
281
|
+
func (fs *inputObservationFS) observe(rooted shimtspath.RootedPath, next observedInput) {
|
|
282
|
+
path := string(rooted)
|
|
282
283
|
key := fs.observationKey(path)
|
|
283
284
|
if key == "" {
|
|
284
285
|
return
|
|
@@ -9,6 +9,7 @@ import (
|
|
|
9
9
|
"runtime"
|
|
10
10
|
"testing"
|
|
11
11
|
|
|
12
|
+
shimtspath "github.com/microsoft/typescript-go/shim/tspath"
|
|
12
13
|
"github.com/samchon/ttsc/packages/ttsc/driver/windowsjunction"
|
|
13
14
|
)
|
|
14
15
|
|
|
@@ -23,13 +24,13 @@ func TestInputObservationFSRejectsRestoredContent(t *testing.T) {
|
|
|
23
24
|
t.Fatal(err)
|
|
24
25
|
}
|
|
25
26
|
observed := newInputObservationFS(DefaultFS())
|
|
26
|
-
if contents, ok := observed.ReadFile(file); !ok || contents != "A" {
|
|
27
|
+
if contents, ok := observed.ReadFile(shimtspath.RootedFilePathFromAbsolute(file)); !ok || contents != "A" {
|
|
27
28
|
t.Fatalf("first read = %q, %v", contents, ok)
|
|
28
29
|
}
|
|
29
30
|
if err := os.WriteFile(file, []byte("B"), 0o644); err != nil {
|
|
30
31
|
t.Fatal(err)
|
|
31
32
|
}
|
|
32
|
-
if contents, ok := observed.ReadFile(file); !ok || contents != "B" {
|
|
33
|
+
if contents, ok := observed.ReadFile(shimtspath.RootedFilePathFromAbsolute(file)); !ok || contents != "B" {
|
|
33
34
|
t.Fatalf("second read = %q, %v", contents, ok)
|
|
34
35
|
}
|
|
35
36
|
if err := os.WriteFile(file, []byte("A"), 0o644); err != nil {
|
|
@@ -53,16 +54,16 @@ func TestInputObservationFSProvesReadBytesAndMissingCandidates(t *testing.T) {
|
|
|
53
54
|
t.Fatal(err)
|
|
54
55
|
}
|
|
55
56
|
observed := newInputObservationFS(DefaultFS())
|
|
56
|
-
if !observed.FileExists(file) {
|
|
57
|
+
if !observed.FileExists(shimtspath.RootedFilePathFromAbsolute(file)) {
|
|
57
58
|
t.Fatal("selected file was not found")
|
|
58
59
|
}
|
|
59
60
|
if _, _, failure := observed.proof(file); failure != inputProofContentUnavailable {
|
|
60
61
|
t.Fatalf("existence-only proof failure = %q, want %q", failure, inputProofContentUnavailable)
|
|
61
62
|
}
|
|
62
|
-
if _, ok := observed.ReadFile(file); !ok {
|
|
63
|
+
if _, ok := observed.ReadFile(shimtspath.RootedFilePathFromAbsolute(file)); !ok {
|
|
63
64
|
t.Fatal("selected file was not read")
|
|
64
65
|
}
|
|
65
|
-
if observed.FileExists(missing) {
|
|
66
|
+
if observed.FileExists(shimtspath.RootedFilePathFromAbsolute(missing)) {
|
|
66
67
|
t.Fatal("missing candidate unexpectedly exists")
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -109,10 +110,10 @@ func testInputObservationFSKeepsFileAndDirectoryPredicatesIndependent(t *testing
|
|
|
109
110
|
t.Fatal(err)
|
|
110
111
|
}
|
|
111
112
|
observed := newInputObservationFS(DefaultFS())
|
|
112
|
-
if observed.FileExists(directory) {
|
|
113
|
+
if observed.FileExists(shimtspath.RootedFilePathFromAbsolute(directory)) {
|
|
113
114
|
t.Fatal("directory unexpectedly satisfied FileExists")
|
|
114
115
|
}
|
|
115
|
-
if !observed.DirectoryExists(directory) {
|
|
116
|
+
if !observed.DirectoryExists(shimtspath.RootedDirectoryPathFromAbsolute(directory)) {
|
|
116
117
|
t.Fatal("directory did not satisfy DirectoryExists")
|
|
117
118
|
}
|
|
118
119
|
|
|
@@ -310,7 +311,7 @@ func TestInputObservationFSHashesCompilerDecodedText(t *testing.T) {
|
|
|
310
311
|
t.Fatal(err)
|
|
311
312
|
}
|
|
312
313
|
observed := newInputObservationFS(DefaultFS())
|
|
313
|
-
contents, ok := observed.ReadFile(file)
|
|
314
|
+
contents, ok := observed.ReadFile(shimtspath.RootedFilePathFromAbsolute(file))
|
|
314
315
|
if !ok || contents != text {
|
|
315
316
|
t.Fatalf("compiler read = %q, %v; want decoded text", contents, ok)
|
|
316
317
|
}
|
|
@@ -349,10 +350,10 @@ func TestInputObservationFSJoinsSelectedAliasProbeToPhysicalRead(t *testing.T) {
|
|
|
349
350
|
}
|
|
350
351
|
lexical := filepath.Join(alias, "value.js")
|
|
351
352
|
observed := newInputObservationFS(DefaultFS())
|
|
352
|
-
if !observed.FileExists(lexical) {
|
|
353
|
+
if !observed.FileExists(shimtspath.RootedFilePathFromAbsolute(lexical)) {
|
|
353
354
|
t.Fatal("selected lexical alias was not found")
|
|
354
355
|
}
|
|
355
|
-
if _, ok := observed.ReadFile(physical); !ok {
|
|
356
|
+
if _, ok := observed.ReadFile(shimtspath.RootedFilePathFromAbsolute(physical)); !ok {
|
|
356
357
|
t.Fatal("selected physical source was not read")
|
|
357
358
|
}
|
|
358
359
|
|