@soundscript/soundscript 0.1.12 → 0.1.15
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/package.json +15 -6
- package/project-transform/index.js +2 -0
- package/project-transform/index.ts +8 -0
- package/project-transform/src/annotation_syntax.js +948 -0
- package/project-transform/src/annotation_syntax.ts +1217 -0
- package/project-transform/src/build_package.js +475 -0
- package/project-transform/src/build_package.ts +683 -0
- package/project-transform/src/bundled/portable-web-globals.d.ts +153 -0
- package/project-transform/src/bundled/runtime_externs.js +220 -0
- package/project-transform/src/bundled/runtime_externs.ts +237 -0
- package/project-transform/src/bundled/sound-libs/lib.decorators.d.ts +385 -0
- package/project-transform/src/bundled/sound-libs/lib.decorators.legacy.d.ts +22 -0
- package/project-transform/src/bundled/sound-libs/lib.dom.asynciterable.d.ts +42 -0
- package/project-transform/src/bundled/sound-libs/lib.dom.d.ts +39440 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.collection.d.ts +149 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.core.d.ts +657 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.d.ts +28 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.generator.d.ts +77 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.iterable.d.ts +616 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.promise.d.ts +80 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.proxy.d.ts +128 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.reflect.d.ts +144 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.symbol.d.ts +46 -0
- package/project-transform/src/bundled/sound-libs/lib.es2015.symbol.wellknown.d.ts +170 -0
- package/project-transform/src/bundled/sound-libs/lib.es2016.array.include.d.ts +116 -0
- package/project-transform/src/bundled/sound-libs/lib.es2016.d.ts +21 -0
- package/project-transform/src/bundled/sound-libs/lib.es2017.arraybuffer.d.ts +21 -0
- package/project-transform/src/bundled/sound-libs/lib.es2017.d.ts +26 -0
- package/project-transform/src/bundled/sound-libs/lib.es2017.date.d.ts +31 -0
- package/project-transform/src/bundled/sound-libs/lib.es2017.object.d.ts +49 -0
- package/project-transform/src/bundled/sound-libs/lib.es2017.string.d.ts +45 -0
- package/project-transform/src/bundled/sound-libs/lib.es2017.typedarrays.d.ts +53 -0
- package/project-transform/src/bundled/sound-libs/lib.es2018.asyncgenerator.d.ts +77 -0
- package/project-transform/src/bundled/sound-libs/lib.es2018.asynciterable.d.ts +57 -0
- package/project-transform/src/bundled/sound-libs/lib.es2018.d.ts +24 -0
- package/project-transform/src/bundled/sound-libs/lib.es2018.promise.d.ts +30 -0
- package/project-transform/src/bundled/sound-libs/lib.es2018.regexp.d.ts +37 -0
- package/project-transform/src/bundled/sound-libs/lib.es2019.array.d.ts +79 -0
- package/project-transform/src/bundled/sound-libs/lib.es2019.d.ts +24 -0
- package/project-transform/src/bundled/sound-libs/lib.es2019.object.d.ts +47 -0
- package/project-transform/src/bundled/sound-libs/lib.es2019.string.d.ts +37 -0
- package/project-transform/src/bundled/sound-libs/lib.es2019.symbol.d.ts +24 -0
- package/project-transform/src/bundled/sound-libs/lib.es2020.bigint.d.ts +765 -0
- package/project-transform/src/bundled/sound-libs/lib.es2020.d.ts +27 -0
- package/project-transform/src/bundled/sound-libs/lib.es2020.date.d.ts +42 -0
- package/project-transform/src/bundled/sound-libs/lib.es2020.number.d.ts +28 -0
- package/project-transform/src/bundled/sound-libs/lib.es2020.promise.d.ts +49 -0
- package/project-transform/src/bundled/sound-libs/lib.es2020.string.d.ts +44 -0
- package/project-transform/src/bundled/sound-libs/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/project-transform/src/bundled/sound-libs/lib.es2021.d.ts +23 -0
- package/project-transform/src/bundled/sound-libs/lib.es2021.promise.d.ts +48 -0
- package/project-transform/src/bundled/sound-libs/lib.es2021.string.d.ts +33 -0
- package/project-transform/src/bundled/sound-libs/lib.es2021.weakref.d.ts +78 -0
- package/project-transform/src/bundled/sound-libs/lib.es2022.array.d.ts +121 -0
- package/project-transform/src/bundled/sound-libs/lib.es2022.d.ts +25 -0
- package/project-transform/src/bundled/sound-libs/lib.es2022.error.d.ts +75 -0
- package/project-transform/src/bundled/sound-libs/lib.es2022.object.d.ts +26 -0
- package/project-transform/src/bundled/sound-libs/lib.es2022.regexp.d.ts +39 -0
- package/project-transform/src/bundled/sound-libs/lib.es2022.string.d.ts +25 -0
- package/project-transform/src/bundled/sound-libs/lib.es2023.array.d.ts +924 -0
- package/project-transform/src/bundled/sound-libs/lib.es2023.collection.d.ts +21 -0
- package/project-transform/src/bundled/sound-libs/lib.es2023.d.ts +22 -0
- package/project-transform/src/bundled/sound-libs/lib.es2024.arraybuffer.d.ts +65 -0
- package/project-transform/src/bundled/sound-libs/lib.es2024.collection.d.ts +29 -0
- package/project-transform/src/bundled/sound-libs/lib.es2024.d.ts +26 -0
- package/project-transform/src/bundled/sound-libs/lib.es2024.object.d.ts +33 -0
- package/project-transform/src/bundled/sound-libs/lib.es2024.promise.d.ts +35 -0
- package/project-transform/src/bundled/sound-libs/lib.es2024.regexp.d.ts +25 -0
- package/project-transform/src/bundled/sound-libs/lib.es2024.string.d.ts +29 -0
- package/project-transform/src/bundled/sound-libs/lib.es5.d.ts +4924 -0
- package/project-transform/src/bundled/sound_stdlib.js +142 -0
- package/project-transform/src/bundled/sound_stdlib.ts +180 -0
- package/project-transform/src/checker/analyze_project.js +1361 -0
- package/project-transform/src/checker/analyze_project.ts +2246 -0
- package/project-transform/src/checker/diagnostics.js +112 -0
- package/project-transform/src/checker/diagnostics.ts +222 -0
- package/project-transform/src/checker/engine/context.js +235 -0
- package/project-transform/src/checker/engine/context.ts +340 -0
- package/project-transform/src/checker/engine/diagnostic_codes.js +72 -0
- package/project-transform/src/checker/engine/diagnostic_codes.ts +95 -0
- package/project-transform/src/checker/engine/facts.js +35 -0
- package/project-transform/src/checker/engine/facts.ts +48 -0
- package/project-transform/src/checker/engine/types.js +1 -0
- package/project-transform/src/checker/engine/types.ts +485 -0
- package/project-transform/src/checker/proof_escape_hatch_diagnostics.js +104 -0
- package/project-transform/src/checker/proof_escape_hatch_diagnostics.ts +173 -0
- package/project-transform/src/checker/rules/async_surface.js +231 -0
- package/project-transform/src/checker/rules/async_surface.ts +335 -0
- package/project-transform/src/checker/rules/class_lifecycle.js +798 -0
- package/project-transform/src/checker/rules/class_lifecycle.ts +1276 -0
- package/project-transform/src/checker/rules/directive_validation.js +571 -0
- package/project-transform/src/checker/rules/directive_validation.ts +938 -0
- package/project-transform/src/checker/rules/directives.js +23 -0
- package/project-transform/src/checker/rules/directives.ts +25 -0
- package/project-transform/src/checker/rules/flow.js +202 -0
- package/project-transform/src/checker/rules/flow.ts +333 -0
- package/project-transform/src/checker/rules/flow_facts.js +601 -0
- package/project-transform/src/checker/rules/flow_facts.ts +978 -0
- package/project-transform/src/checker/rules/flow_invalidation.js +1119 -0
- package/project-transform/src/checker/rules/flow_invalidation.ts +2150 -0
- package/project-transform/src/checker/rules/flow_shared.js +2822 -0
- package/project-transform/src/checker/rules/flow_shared.ts +4383 -0
- package/project-transform/src/checker/rules/foreign_boundary.js +120 -0
- package/project-transform/src/checker/rules/foreign_boundary.ts +196 -0
- package/project-transform/src/checker/rules/foreign_projection.js +279 -0
- package/project-transform/src/checker/rules/foreign_projection.ts +425 -0
- package/project-transform/src/checker/rules/generated_helpers.js +13 -0
- package/project-transform/src/checker/rules/generated_helpers.ts +18 -0
- package/project-transform/src/checker/rules/index.js +35 -0
- package/project-transform/src/checker/rules/index.ts +49 -0
- package/project-transform/src/checker/rules/namespace_object.js +845 -0
- package/project-transform/src/checker/rules/namespace_object.ts +1224 -0
- package/project-transform/src/checker/rules/non_ordinary_recovery.js +1328 -0
- package/project-transform/src/checker/rules/non_ordinary_recovery.ts +2391 -0
- package/project-transform/src/checker/rules/null_prototype.js +3 -0
- package/project-transform/src/checker/rules/null_prototype.ts +6 -0
- package/project-transform/src/checker/rules/overloads.js +181 -0
- package/project-transform/src/checker/rules/overloads.ts +317 -0
- package/project-transform/src/checker/rules/predicate_verification.js +691 -0
- package/project-transform/src/checker/rules/predicate_verification.ts +1088 -0
- package/project-transform/src/checker/rules/prototype_hardening.js +237 -0
- package/project-transform/src/checker/rules/prototype_hardening.ts +343 -0
- package/project-transform/src/checker/rules/receiver_discipline.js +263 -0
- package/project-transform/src/checker/rules/receiver_discipline.ts +356 -0
- package/project-transform/src/checker/rules/relations.js +6861 -0
- package/project-transform/src/checker/rules/relations.ts +12158 -0
- package/project-transform/src/checker/rules/resolved_builtins.js +274 -0
- package/project-transform/src/checker/rules/resolved_builtins.ts +438 -0
- package/project-transform/src/checker/rules/trust.js +217 -0
- package/project-transform/src/checker/rules/trust.ts +301 -0
- package/project-transform/src/checker/rules/type_guards.js +173 -0
- package/project-transform/src/checker/rules/type_guards.ts +257 -0
- package/project-transform/src/checker/rules/universal.js +17 -0
- package/project-transform/src/checker/rules/universal.ts +22 -0
- package/project-transform/src/checker/rules/unsafe_value_origin.js +80 -0
- package/project-transform/src/checker/rules/unsafe_value_origin.ts +125 -0
- package/project-transform/src/checker/rules/unsound_imports.js +218 -0
- package/project-transform/src/checker/rules/unsound_imports.ts +301 -0
- package/project-transform/src/checker/rules/unsound_syntax.js +1695 -0
- package/project-transform/src/checker/rules/unsound_syntax.ts +2540 -0
- package/project-transform/src/checker/rules/value_types.js +206 -0
- package/project-transform/src/checker/rules/value_types.ts +407 -0
- package/project-transform/src/checker/timing.js +43 -0
- package/project-transform/src/checker/timing.ts +78 -0
- package/project-transform/src/checker/unsupported_feature_messages.js +337 -0
- package/project-transform/src/checker/unsupported_feature_messages.ts +531 -0
- package/project-transform/src/cli.js +892 -0
- package/project-transform/src/cli.ts +1476 -0
- package/project-transform/src/compiler/compile_project.js +319 -0
- package/project-transform/src/compiler/compile_project.ts +508 -0
- package/project-transform/src/compiler/errors.js +10 -0
- package/project-transform/src/compiler/errors.ts +29 -0
- package/project-transform/src/compiler/ir.js +1 -0
- package/project-transform/src/compiler/ir.ts +1526 -0
- package/project-transform/src/compiler/lower.js +30550 -0
- package/project-transform/src/compiler/lower.ts +43645 -0
- package/project-transform/src/compiler/lower_arrays.js +140 -0
- package/project-transform/src/compiler/lower_arrays.ts +190 -0
- package/project-transform/src/compiler/lower_strings.js +121 -0
- package/project-transform/src/compiler/lower_strings.ts +198 -0
- package/project-transform/src/compiler/lower_tagged.js +329 -0
- package/project-transform/src/compiler/lower_tagged.ts +427 -0
- package/project-transform/src/compiler/lower_views.js +171 -0
- package/project-transform/src/compiler/lower_views.ts +251 -0
- package/project-transform/src/compiler/object_keys.js +25 -0
- package/project-transform/src/compiler/object_keys.ts +35 -0
- package/project-transform/src/compiler/runtime_ir.js +30 -0
- package/project-transform/src/compiler/runtime_ir.ts +727 -0
- package/project-transform/src/compiler/tagged_boundary.js +18 -0
- package/project-transform/src/compiler/tagged_boundary.ts +37 -0
- package/project-transform/src/compiler/toolchain.js +170 -0
- package/project-transform/src/compiler/toolchain.ts +229 -0
- package/project-transform/src/compiler/unicode_case_data.js +2102 -0
- package/project-transform/src/compiler/unicode_case_data.ts +2112 -0
- package/project-transform/src/compiler/wasm_js_host_runtime.js +656 -0
- package/project-transform/src/compiler/wasm_js_host_runtime.ts +762 -0
- package/project-transform/src/compiler/wat_arrays.js +3132 -0
- package/project-transform/src/compiler/wat_arrays.ts +3768 -0
- package/project-transform/src/compiler/wat_emitter.js +17952 -0
- package/project-transform/src/compiler/wat_emitter.ts +22812 -0
- package/project-transform/src/compiler/wat_strings.js +129 -0
- package/project-transform/src/compiler/wat_strings.ts +187 -0
- package/project-transform/src/compiler/wat_tagged.js +548 -0
- package/project-transform/src/compiler/wat_tagged.ts +674 -0
- package/project-transform/src/compiler_generator_runner.js +153 -0
- package/project-transform/src/compiler_generator_runner.ts +171 -0
- package/project-transform/src/compiler_object_test_helpers.js +69 -0
- package/project-transform/src/compiler_object_test_helpers.ts +96 -0
- package/project-transform/src/compiler_promise_runner.js +2116 -0
- package/project-transform/src/compiler_promise_runner.ts +2184 -0
- package/project-transform/src/compiler_test_helpers.js +854 -0
- package/project-transform/src/compiler_test_helpers.ts +1087 -0
- package/project-transform/src/config.js +568 -0
- package/project-transform/src/config.ts +892 -0
- package/project-transform/src/diagnostic_metadata.js +67 -0
- package/project-transform/src/diagnostic_metadata.ts +99 -0
- package/project-transform/src/diagnostic_reference.js +1368 -0
- package/project-transform/src/diagnostic_reference.ts +1523 -0
- package/project-transform/src/editor_diagnostics_worker.js +176 -0
- package/project-transform/src/editor_diagnostics_worker.ts +250 -0
- package/project-transform/src/editor_projection.js +224 -0
- package/project-transform/src/editor_projection.ts +421 -0
- package/project-transform/src/frontend/builtin_expanded_program_test_cleanup.js +47 -0
- package/project-transform/src/frontend/builtin_expanded_program_test_cleanup.ts +72 -0
- package/project-transform/src/frontend/builtin_macro_support.js +842 -0
- package/project-transform/src/frontend/builtin_macro_support.ts +1386 -0
- package/project-transform/src/frontend/builtin_macros.js +409 -0
- package/project-transform/src/frontend/builtin_macros.ts +542 -0
- package/project-transform/src/frontend/component_poc_runtime.js +279 -0
- package/project-transform/src/frontend/component_poc_runtime.ts +372 -0
- package/project-transform/src/frontend/css_macro.js +148 -0
- package/project-transform/src/frontend/css_macro.ts +222 -0
- package/project-transform/src/frontend/derive_macros.js +2072 -0
- package/project-transform/src/frontend/derive_macros.ts +3188 -0
- package/project-transform/src/frontend/embedded_fragment_support.js +106 -0
- package/project-transform/src/frontend/embedded_fragment_support.ts +172 -0
- package/project-transform/src/frontend/error_normalization.js +403 -0
- package/project-transform/src/frontend/error_normalization.ts +832 -0
- package/project-transform/src/frontend/error_stdlib_support.js +1 -0
- package/project-transform/src/frontend/error_stdlib_support.ts +6 -0
- package/project-transform/src/frontend/expand_project.js +169 -0
- package/project-transform/src/frontend/expand_project.ts +248 -0
- package/project-transform/src/frontend/format_soundscript.js +297 -0
- package/project-transform/src/frontend/format_soundscript.ts +582 -0
- package/project-transform/src/frontend/graphql_macro.js +174 -0
- package/project-transform/src/frontend/graphql_macro.ts +253 -0
- package/project-transform/src/frontend/hash_context.js +83 -0
- package/project-transform/src/frontend/hash_context.ts +113 -0
- package/project-transform/src/frontend/hkt_macro.js +448 -0
- package/project-transform/src/frontend/hkt_macro.ts +897 -0
- package/project-transform/src/frontend/import_binding_usage.js +190 -0
- package/project-transform/src/frontend/import_binding_usage.ts +277 -0
- package/project-transform/src/frontend/macro_advanced_backend_adapter.js +58 -0
- package/project-transform/src/frontend/macro_advanced_backend_adapter.ts +123 -0
- package/project-transform/src/frontend/macro_advanced_context.js +826 -0
- package/project-transform/src/frontend/macro_advanced_context.ts +1102 -0
- package/project-transform/src/frontend/macro_advanced_output.js +21 -0
- package/project-transform/src/frontend/macro_advanced_output.ts +41 -0
- package/project-transform/src/frontend/macro_api.js +353 -0
- package/project-transform/src/frontend/macro_api.ts +1722 -0
- package/project-transform/src/frontend/macro_api_internal.js +35 -0
- package/project-transform/src/frontend/macro_api_internal.ts +80 -0
- package/project-transform/src/frontend/macro_api_module_support.js +39 -0
- package/project-transform/src/frontend/macro_api_module_support.ts +65 -0
- package/project-transform/src/frontend/macro_backend_adapter.js +272 -0
- package/project-transform/src/frontend/macro_backend_adapter.ts +420 -0
- package/project-transform/src/frontend/macro_context.js +816 -0
- package/project-transform/src/frontend/macro_context.ts +1105 -0
- package/project-transform/src/frontend/macro_debug.js +99 -0
- package/project-transform/src/frontend/macro_debug.ts +157 -0
- package/project-transform/src/frontend/macro_definition_support.js +28 -0
- package/project-transform/src/frontend/macro_definition_support.ts +73 -0
- package/project-transform/src/frontend/macro_errors.js +40 -0
- package/project-transform/src/frontend/macro_errors.ts +70 -0
- package/project-transform/src/frontend/macro_expander.js +919 -0
- package/project-transform/src/frontend/macro_expander.ts +1611 -0
- package/project-transform/src/frontend/macro_factory_support.js +176 -0
- package/project-transform/src/frontend/macro_factory_support.ts +263 -0
- package/project-transform/src/frontend/macro_host_ast_internal.js +64 -0
- package/project-transform/src/frontend/macro_host_ast_internal.ts +109 -0
- package/project-transform/src/frontend/macro_index.js +27 -0
- package/project-transform/src/frontend/macro_index.ts +50 -0
- package/project-transform/src/frontend/macro_loader.js +281 -0
- package/project-transform/src/frontend/macro_loader.ts +506 -0
- package/project-transform/src/frontend/macro_operand_semantics.js +838 -0
- package/project-transform/src/frontend/macro_operand_semantics.ts +1489 -0
- package/project-transform/src/frontend/macro_output.js +54 -0
- package/project-transform/src/frontend/macro_output.ts +123 -0
- package/project-transform/src/frontend/macro_parser.js +611 -0
- package/project-transform/src/frontend/macro_parser.ts +832 -0
- package/project-transform/src/frontend/macro_resolver.js +69 -0
- package/project-transform/src/frontend/macro_resolver.ts +125 -0
- package/project-transform/src/frontend/macro_rewrite.js +285 -0
- package/project-transform/src/frontend/macro_rewrite.ts +442 -0
- package/project-transform/src/frontend/macro_runtime_support.js +232 -0
- package/project-transform/src/frontend/macro_runtime_support.ts +324 -0
- package/project-transform/src/frontend/macro_scanner.js +393 -0
- package/project-transform/src/frontend/macro_scanner.ts +455 -0
- package/project-transform/src/frontend/macro_semantic_backend_adapter.js +87 -0
- package/project-transform/src/frontend/macro_semantic_backend_adapter.ts +166 -0
- package/project-transform/src/frontend/macro_semantic_context.js +5 -0
- package/project-transform/src/frontend/macro_semantic_context.ts +12 -0
- package/project-transform/src/frontend/macro_semantic_output.js +24 -0
- package/project-transform/src/frontend/macro_semantic_output.ts +47 -0
- package/project-transform/src/frontend/macro_semantic_types.js +1 -0
- package/project-transform/src/frontend/macro_semantic_types.ts +98 -0
- package/project-transform/src/frontend/macro_semantics.js +1172 -0
- package/project-transform/src/frontend/macro_semantics.ts +1502 -0
- package/project-transform/src/frontend/macro_site_kind_support.js +164 -0
- package/project-transform/src/frontend/macro_site_kind_support.ts +255 -0
- package/project-transform/src/frontend/macro_syntax_internal.js +1950 -0
- package/project-transform/src/frontend/macro_syntax_internal.ts +3338 -0
- package/project-transform/src/frontend/macro_templates.js +57 -0
- package/project-transform/src/frontend/macro_templates.ts +143 -0
- package/project-transform/src/frontend/macro_test_helpers.js +82 -0
- package/project-transform/src/frontend/macro_test_helpers.ts +136 -0
- package/project-transform/src/frontend/macro_types.js +1 -0
- package/project-transform/src/frontend/macro_types.ts +103 -0
- package/project-transform/src/frontend/macro_vm.js +39 -0
- package/project-transform/src/frontend/macro_vm.ts +113 -0
- package/project-transform/src/frontend/match_macro.js +885 -0
- package/project-transform/src/frontend/match_macro.ts +1220 -0
- package/project-transform/src/frontend/numeric_normalization.js +824 -0
- package/project-transform/src/frontend/numeric_normalization.ts +1380 -0
- package/project-transform/src/frontend/numeric_prelude.js +278 -0
- package/project-transform/src/frontend/numeric_prelude.ts +370 -0
- package/project-transform/src/frontend/project_frontend.js +2396 -0
- package/project-transform/src/frontend/project_frontend.ts +3776 -0
- package/project-transform/src/frontend/project_macro_support.js +1401 -0
- package/project-transform/src/frontend/project_macro_support.ts +2137 -0
- package/project-transform/src/frontend/sql_macro.js +175 -0
- package/project-transform/src/frontend/sql_macro.ts +254 -0
- package/project-transform/src/frontend/sql_stdlib_support.js +1 -0
- package/project-transform/src/frontend/sql_stdlib_support.ts +6 -0
- package/project-transform/src/frontend/std_package_support.js +228 -0
- package/project-transform/src/frontend/std_package_support.ts +400 -0
- package/project-transform/src/frontend/value_normalization.js +306 -0
- package/project-transform/src/frontend/value_normalization.ts +599 -0
- package/project-transform/src/lsp/project_service.js +4771 -0
- package/project-transform/src/lsp/project_service.ts +7580 -0
- package/project-transform/src/lsp/protocol.js +9 -0
- package/project-transform/src/lsp/protocol.ts +38 -0
- package/project-transform/src/lsp/server.js +355 -0
- package/project-transform/src/lsp/server.ts +671 -0
- package/project-transform/src/lsp/session.js +49 -0
- package/project-transform/src/lsp/session.ts +48 -0
- package/project-transform/src/lsp/timing.js +43 -0
- package/project-transform/src/lsp/timing.ts +76 -0
- package/project-transform/src/lsp/transport.js +205 -0
- package/project-transform/src/lsp/transport.ts +253 -0
- package/project-transform/src/lsp_main.js +5 -0
- package/project-transform/src/lsp_main.ts +7 -0
- package/project-transform/src/macros.d.ts +1 -0
- package/project-transform/src/macros.js +1 -0
- package/project-transform/src/macros.ts +1 -0
- package/project-transform/src/main.js +24 -0
- package/project-transform/src/main.ts +28 -0
- package/project-transform/src/platform/host.js +264 -0
- package/project-transform/src/platform/host.ts +343 -0
- package/project-transform/src/platform/path.js +8 -0
- package/project-transform/src/platform/path.ts +20 -0
- package/project-transform/src/public_macro_api/macro_api.d.ts +1054 -0
- package/project-transform/src/public_macro_api/macro_semantic_types.d.ts +66 -0
- package/project-transform/src/public_macro_api/macro_types.d.ts +70 -0
- package/project-transform/src/run_program.js +14 -0
- package/project-transform/src/run_program.ts +33 -0
- package/project-transform/src/runtime/materialize.js +371 -0
- package/project-transform/src/runtime/materialize.ts +502 -0
- package/project-transform/src/runtime/on_demand.js +203 -0
- package/project-transform/src/runtime/on_demand.ts +305 -0
- package/project-transform/src/runtime/source_maps.js +205 -0
- package/project-transform/src/runtime/source_maps.ts +297 -0
- package/project-transform/src/runtime/transform.js +148 -0
- package/project-transform/src/runtime/transform.ts +295 -0
- package/project-transform/src/service/types.js +1 -0
- package/project-transform/src/service/types.ts +22 -0
- package/project-transform/src/soundscript_packages.js +477 -0
- package/project-transform/src/soundscript_packages.ts +754 -0
- package/project-transform/src/soundscript_runtime_specifiers.js +88 -0
- package/project-transform/src/soundscript_runtime_specifiers.ts +96 -0
- package/project-transform/src/stdlib/async.d.ts +81 -0
- package/project-transform/src/stdlib/async.js +213 -0
- package/project-transform/src/stdlib/async.ts +315 -0
- package/project-transform/src/stdlib/codec.d.ts +32 -0
- package/project-transform/src/stdlib/codec.js +30 -0
- package/project-transform/src/stdlib/codec.ts +76 -0
- package/project-transform/src/stdlib/compare.d.ts +28 -0
- package/project-transform/src/stdlib/compare.js +115 -0
- package/project-transform/src/stdlib/compare.ts +151 -0
- package/project-transform/src/stdlib/css.d.ts +16 -0
- package/project-transform/src/stdlib/css.js +9 -0
- package/project-transform/src/stdlib/css.ts +28 -0
- package/project-transform/src/stdlib/debug.d.ts +2 -0
- package/project-transform/src/stdlib/debug.js +9 -0
- package/project-transform/src/stdlib/debug.ts +10 -0
- package/project-transform/src/stdlib/decode.d.ts +86 -0
- package/project-transform/src/stdlib/decode.js +254 -0
- package/project-transform/src/stdlib/decode.ts +390 -0
- package/project-transform/src/stdlib/derive.d.ts +6 -0
- package/project-transform/src/stdlib/derive.js +7 -0
- package/project-transform/src/stdlib/derive.ts +7 -0
- package/project-transform/src/stdlib/encode.d.ts +100 -0
- package/project-transform/src/stdlib/encode.js +130 -0
- package/project-transform/src/stdlib/encode.ts +259 -0
- package/project-transform/src/stdlib/failures.d.ts +23 -0
- package/project-transform/src/stdlib/failures.js +41 -0
- package/project-transform/src/stdlib/failures.ts +64 -0
- package/project-transform/src/stdlib/fetch.d.ts +67 -0
- package/project-transform/src/stdlib/fetch.js +5 -0
- package/project-transform/src/stdlib/fetch.ts +11 -0
- package/project-transform/src/stdlib/graphql.d.ts +16 -0
- package/project-transform/src/stdlib/graphql.js +9 -0
- package/project-transform/src/stdlib/graphql.ts +28 -0
- package/project-transform/src/stdlib/hash.d.ts +34 -0
- package/project-transform/src/stdlib/hash.js +110 -0
- package/project-transform/src/stdlib/hash.ts +188 -0
- package/project-transform/src/stdlib/hkt.d.ts +40 -0
- package/project-transform/src/stdlib/hkt.js +3 -0
- package/project-transform/src/stdlib/hkt.ts +41 -0
- package/project-transform/src/stdlib/index.d.ts +9 -0
- package/project-transform/src/stdlib/index.js +15 -0
- package/project-transform/src/stdlib/index.ts +23 -0
- package/project-transform/src/stdlib/json.d.ts +125 -0
- package/project-transform/src/stdlib/json.js +764 -0
- package/project-transform/src/stdlib/json.ts +1034 -0
- package/project-transform/src/stdlib/match.d.ts +11 -0
- package/project-transform/src/stdlib/match.js +13 -0
- package/project-transform/src/stdlib/match.ts +26 -0
- package/project-transform/src/stdlib/numerics.d.ts +523 -0
- package/project-transform/src/stdlib/numerics.js +1356 -0
- package/project-transform/src/stdlib/numerics.ts +1937 -0
- package/project-transform/src/stdlib/random.d.ts +19 -0
- package/project-transform/src/stdlib/random.js +3 -0
- package/project-transform/src/stdlib/random.ts +5 -0
- package/project-transform/src/stdlib/result.d.ts +68 -0
- package/project-transform/src/stdlib/result.js +139 -0
- package/project-transform/src/stdlib/result.ts +248 -0
- package/project-transform/src/stdlib/sql.d.ts +22 -0
- package/project-transform/src/stdlib/sql.js +23 -0
- package/project-transform/src/stdlib/sql.ts +53 -0
- package/project-transform/src/stdlib/text.d.ts +24 -0
- package/project-transform/src/stdlib/text.js +3 -0
- package/project-transform/src/stdlib/text.ts +4 -0
- package/project-transform/src/stdlib/thunk.d.ts +2 -0
- package/project-transform/src/stdlib/thunk.js +9 -0
- package/project-transform/src/stdlib/thunk.ts +15 -0
- package/project-transform/src/stdlib/typeclasses.d.ts +57 -0
- package/project-transform/src/stdlib/typeclasses.js +78 -0
- package/project-transform/src/stdlib/typeclasses.ts +173 -0
- package/project-transform/src/stdlib/url.d.ts +37 -0
- package/project-transform/src/stdlib/url.js +3 -0
- package/project-transform/src/stdlib/url.ts +4 -0
- package/project-transform/src/stdlib/value.d.ts +9 -0
- package/project-transform/src/stdlib/value.js +104 -0
- package/project-transform/src/stdlib/value.ts +133 -0
- package/project-transform/src/test_installed_stdlib.js +147 -0
- package/project-transform/src/test_installed_stdlib.ts +245 -0
- package/project-transform/src/test_macro_package_fixture.js +50 -0
- package/project-transform/src/test_macro_package_fixture.ts +68 -0
- package/project-transform/src/value_deep_safe.js +191 -0
- package/project-transform/src/value_deep_safe.ts +273 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { runCli } from './cli.ts';
|
|
2
|
+
import { parseCommand } from './config.ts';
|
|
3
|
+
import { runEditorDiagnosticsWorker } from './editor_diagnostics_worker.ts';
|
|
4
|
+
import { createServer } from './lsp/server.ts';
|
|
5
|
+
import { createStdioTransport } from './lsp/transport.ts';
|
|
6
|
+
import { runtimeArgs, runtimeCwd, runtimeExit, writeStdout } from './platform/host.ts';
|
|
7
|
+
|
|
8
|
+
async function main(): Promise<void> {
|
|
9
|
+
const args = runtimeArgs();
|
|
10
|
+
const command = parseCommand(args, runtimeCwd());
|
|
11
|
+
if (command.kind === 'lsp') {
|
|
12
|
+
const transport = createStdioTransport();
|
|
13
|
+
const server = createServer(transport);
|
|
14
|
+
await server.start();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (command.kind === 'editor-worker') {
|
|
19
|
+
await runEditorDiagnosticsWorker();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const result = await runCli(args);
|
|
24
|
+
writeStdout(result.output);
|
|
25
|
+
runtimeExit(result.exitCode);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
await main();
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _AsyncHostEventQueue_items, _AsyncHostEventQueue_waiters;
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import { mkdirSync, readdirSync, readFileSync, rmSync, statSync, watch as watchPath, writeFileSync, } from 'node:fs';
|
|
9
|
+
import { copyFile as copyFileAsync, mkdir as mkdirAsync, mkdtemp as createTempDirectoryAsync, readdir as readDirectoryAsync, readFile as readFileAsync, readlink as readLinkAsync, rm as removePathAsync, symlink as createSymlinkAsync, writeFile as writeFileAsync, } from 'node:fs/promises';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import process from 'node:process';
|
|
13
|
+
import { Readable, Writable } from 'node:stream';
|
|
14
|
+
class AsyncHostEventQueue {
|
|
15
|
+
constructor() {
|
|
16
|
+
_AsyncHostEventQueue_items.set(this, []);
|
|
17
|
+
_AsyncHostEventQueue_waiters.set(this, []);
|
|
18
|
+
}
|
|
19
|
+
push(item) {
|
|
20
|
+
const waiter = __classPrivateFieldGet(this, _AsyncHostEventQueue_waiters, "f").shift();
|
|
21
|
+
if (waiter) {
|
|
22
|
+
waiter(item);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
__classPrivateFieldGet(this, _AsyncHostEventQueue_items, "f").push(item);
|
|
26
|
+
}
|
|
27
|
+
shift() {
|
|
28
|
+
const item = __classPrivateFieldGet(this, _AsyncHostEventQueue_items, "f").shift();
|
|
29
|
+
if (item !== undefined) {
|
|
30
|
+
return Promise.resolve(item);
|
|
31
|
+
}
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
__classPrivateFieldGet(this, _AsyncHostEventQueue_waiters, "f").push(resolve);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
_AsyncHostEventQueue_items = new WeakMap(), _AsyncHostEventQueue_waiters = new WeakMap();
|
|
38
|
+
function collectDirectoriesRecursive(rootPath) {
|
|
39
|
+
if (!directoryExistsSync(rootPath)) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const directories = [rootPath];
|
|
43
|
+
for (const entry of readDirectorySync(rootPath)) {
|
|
44
|
+
if (!entry.isDirectory) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
directories.push(...collectDirectoriesRecursive(join(rootPath, entry.name)));
|
|
48
|
+
}
|
|
49
|
+
return directories;
|
|
50
|
+
}
|
|
51
|
+
export function directoryExistsSync(path) {
|
|
52
|
+
try {
|
|
53
|
+
return statSync(path).isDirectory();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function fileExistsSync(path) {
|
|
60
|
+
try {
|
|
61
|
+
return statSync(path).isFile();
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function pathExistsSync(path) {
|
|
68
|
+
try {
|
|
69
|
+
statSync(path);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
export function readBytesSync(path) {
|
|
77
|
+
return readFileSync(path);
|
|
78
|
+
}
|
|
79
|
+
export function readDirectorySync(path) {
|
|
80
|
+
return readdirSync(path, { withFileTypes: true }).map((entry) => ({
|
|
81
|
+
isDirectory: entry.isDirectory(),
|
|
82
|
+
isFile: entry.isFile(),
|
|
83
|
+
isSymlink: entry.isSymbolicLink(),
|
|
84
|
+
name: entry.name,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
export async function copyFile(sourcePath, destinationPath) {
|
|
88
|
+
await copyFileAsync(sourcePath, destinationPath);
|
|
89
|
+
}
|
|
90
|
+
export async function createSymlink(targetPath, path, type) {
|
|
91
|
+
await createSymlinkAsync(targetPath, path, type);
|
|
92
|
+
}
|
|
93
|
+
export async function createTempDirectory(prefix) {
|
|
94
|
+
return await createTempDirectoryAsync(join(tmpdir(), prefix));
|
|
95
|
+
}
|
|
96
|
+
export async function makeDirectory(path) {
|
|
97
|
+
await mkdirAsync(path, { recursive: true });
|
|
98
|
+
}
|
|
99
|
+
export function makeDirectorySync(path) {
|
|
100
|
+
mkdirSync(path, { recursive: true });
|
|
101
|
+
}
|
|
102
|
+
export function readTextFileSync(path) {
|
|
103
|
+
return readFileSync(path, 'utf8');
|
|
104
|
+
}
|
|
105
|
+
export async function readDirectory(path) {
|
|
106
|
+
const entries = await readDirectoryAsync(path, { withFileTypes: true });
|
|
107
|
+
return entries.map((entry) => ({
|
|
108
|
+
isDirectory: entry.isDirectory(),
|
|
109
|
+
isFile: entry.isFile(),
|
|
110
|
+
isSymlink: entry.isSymbolicLink(),
|
|
111
|
+
name: entry.name,
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
export async function readLink(path) {
|
|
115
|
+
return await readLinkAsync(path);
|
|
116
|
+
}
|
|
117
|
+
export async function readTextFile(path) {
|
|
118
|
+
return await readFileAsync(path, 'utf8');
|
|
119
|
+
}
|
|
120
|
+
export async function removePath(path) {
|
|
121
|
+
await removePathAsync(path, { recursive: true, force: true });
|
|
122
|
+
}
|
|
123
|
+
export function removePathSync(path) {
|
|
124
|
+
rmSync(path, { recursive: true, force: true });
|
|
125
|
+
}
|
|
126
|
+
export async function readStdinText() {
|
|
127
|
+
process.stdin.setEncoding('utf8');
|
|
128
|
+
let text = '';
|
|
129
|
+
for await (const chunk of process.stdin) {
|
|
130
|
+
text += chunk;
|
|
131
|
+
}
|
|
132
|
+
return text;
|
|
133
|
+
}
|
|
134
|
+
export function runtimeExecPath() {
|
|
135
|
+
return process.execPath;
|
|
136
|
+
}
|
|
137
|
+
export function runtimeArgs() {
|
|
138
|
+
return process.argv.slice(2);
|
|
139
|
+
}
|
|
140
|
+
export function runtimeCwd() {
|
|
141
|
+
return process.cwd();
|
|
142
|
+
}
|
|
143
|
+
export function runtimeEnv(name) {
|
|
144
|
+
return process.env[name];
|
|
145
|
+
}
|
|
146
|
+
export function runtimeEnvObject() {
|
|
147
|
+
return Object.fromEntries(Object.entries(process.env).filter((entry) => {
|
|
148
|
+
return typeof entry[1] === 'string';
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
export function runtimeExit(code) {
|
|
152
|
+
process.exit(code);
|
|
153
|
+
}
|
|
154
|
+
export function runtimeStdinReadable() {
|
|
155
|
+
return Readable.toWeb(process.stdin);
|
|
156
|
+
}
|
|
157
|
+
export function runtimeStdoutWritable() {
|
|
158
|
+
return Writable.toWeb(process.stdout);
|
|
159
|
+
}
|
|
160
|
+
export async function* watchFileSystem(rootPath) {
|
|
161
|
+
const events = new AsyncHostEventQueue();
|
|
162
|
+
const watchers = new Map();
|
|
163
|
+
let closed = false;
|
|
164
|
+
let pendingPath;
|
|
165
|
+
let debounceTimer;
|
|
166
|
+
const scheduleModifyEvent = (path) => {
|
|
167
|
+
pendingPath = path;
|
|
168
|
+
if (debounceTimer) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
debounceTimer = setTimeout(() => {
|
|
172
|
+
debounceTimer = undefined;
|
|
173
|
+
events.push({
|
|
174
|
+
kind: 'modify',
|
|
175
|
+
path: pendingPath,
|
|
176
|
+
});
|
|
177
|
+
pendingPath = undefined;
|
|
178
|
+
syncWatchers();
|
|
179
|
+
}, 50);
|
|
180
|
+
};
|
|
181
|
+
const syncWatchers = () => {
|
|
182
|
+
if (closed) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const expectedPaths = new Set(collectDirectoriesRecursive(rootPath));
|
|
186
|
+
for (const [watchedPath, watcher] of watchers) {
|
|
187
|
+
if (expectedPaths.has(watchedPath)) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
watcher.close();
|
|
191
|
+
watchers.delete(watchedPath);
|
|
192
|
+
}
|
|
193
|
+
for (const watchedPath of expectedPaths) {
|
|
194
|
+
if (watchers.has(watchedPath)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const watcher = watchPath(watchedPath, (eventType, fileName) => {
|
|
198
|
+
const candidatePath = typeof fileName === 'string' && fileName.length > 0
|
|
199
|
+
? join(watchedPath, fileName)
|
|
200
|
+
: watchedPath;
|
|
201
|
+
if (eventType === 'rename') {
|
|
202
|
+
syncWatchers();
|
|
203
|
+
}
|
|
204
|
+
scheduleModifyEvent(candidatePath);
|
|
205
|
+
});
|
|
206
|
+
watcher.on('error', () => {
|
|
207
|
+
events.push({
|
|
208
|
+
kind: 'other',
|
|
209
|
+
path: watchedPath,
|
|
210
|
+
});
|
|
211
|
+
syncWatchers();
|
|
212
|
+
});
|
|
213
|
+
watchers.set(watchedPath, watcher);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
syncWatchers();
|
|
217
|
+
try {
|
|
218
|
+
while (true) {
|
|
219
|
+
yield await events.shift();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
closed = true;
|
|
224
|
+
if (debounceTimer) {
|
|
225
|
+
clearTimeout(debounceTimer);
|
|
226
|
+
}
|
|
227
|
+
for (const watcher of watchers.values()) {
|
|
228
|
+
watcher.close();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export async function runCommand(command, args, cwd) {
|
|
233
|
+
return await new Promise((resolve, reject) => {
|
|
234
|
+
const child = spawn(command, [...args], {
|
|
235
|
+
cwd,
|
|
236
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
237
|
+
});
|
|
238
|
+
let output = '';
|
|
239
|
+
child.stdout?.setEncoding('utf8');
|
|
240
|
+
child.stdout?.on('data', (chunk) => {
|
|
241
|
+
output += chunk;
|
|
242
|
+
});
|
|
243
|
+
child.stderr?.setEncoding('utf8');
|
|
244
|
+
child.stderr?.on('data', (chunk) => {
|
|
245
|
+
output += chunk;
|
|
246
|
+
});
|
|
247
|
+
child.on('error', reject);
|
|
248
|
+
child.on('close', (code) => {
|
|
249
|
+
resolve({
|
|
250
|
+
exitCode: code ?? 1,
|
|
251
|
+
output,
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
export function writeStdout(text) {
|
|
257
|
+
process.stdout.write(text);
|
|
258
|
+
}
|
|
259
|
+
export async function writeTextFile(path, text) {
|
|
260
|
+
await writeFileAsync(path, text, 'utf8');
|
|
261
|
+
}
|
|
262
|
+
export function writeTextFileSync(path, text) {
|
|
263
|
+
writeFileSync(path, text, 'utf8');
|
|
264
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import {
|
|
3
|
+
type FSWatcher,
|
|
4
|
+
mkdirSync,
|
|
5
|
+
readdirSync,
|
|
6
|
+
readFileSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
statSync,
|
|
9
|
+
watch as watchPath,
|
|
10
|
+
writeFileSync,
|
|
11
|
+
} from 'node:fs';
|
|
12
|
+
import {
|
|
13
|
+
copyFile as copyFileAsync,
|
|
14
|
+
mkdir as mkdirAsync,
|
|
15
|
+
mkdtemp as createTempDirectoryAsync,
|
|
16
|
+
readdir as readDirectoryAsync,
|
|
17
|
+
readFile as readFileAsync,
|
|
18
|
+
readlink as readLinkAsync,
|
|
19
|
+
rm as removePathAsync,
|
|
20
|
+
symlink as createSymlinkAsync,
|
|
21
|
+
writeFile as writeFileAsync,
|
|
22
|
+
} from 'node:fs/promises';
|
|
23
|
+
import { tmpdir } from 'node:os';
|
|
24
|
+
import { join } from 'node:path';
|
|
25
|
+
import process from 'node:process';
|
|
26
|
+
import { Readable, Writable } from 'node:stream';
|
|
27
|
+
|
|
28
|
+
export interface HostDirectoryEntry {
|
|
29
|
+
isDirectory: boolean;
|
|
30
|
+
isFile: boolean;
|
|
31
|
+
isSymlink: boolean;
|
|
32
|
+
name: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface HostFileSystemWatchEvent {
|
|
36
|
+
kind: 'create' | 'modify' | 'other' | 'remove';
|
|
37
|
+
path?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class AsyncHostEventQueue<T> {
|
|
41
|
+
readonly #items: T[] = [];
|
|
42
|
+
readonly #waiters: ((item: T) => void)[] = [];
|
|
43
|
+
|
|
44
|
+
push(item: T): void {
|
|
45
|
+
const waiter = this.#waiters.shift();
|
|
46
|
+
if (waiter) {
|
|
47
|
+
waiter(item);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.#items.push(item);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
shift(): Promise<T> {
|
|
55
|
+
const item = this.#items.shift();
|
|
56
|
+
if (item !== undefined) {
|
|
57
|
+
return Promise.resolve(item);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return new Promise((resolve) => {
|
|
61
|
+
this.#waiters.push(resolve);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function collectDirectoriesRecursive(rootPath: string): readonly string[] {
|
|
67
|
+
if (!directoryExistsSync(rootPath)) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const directories = [rootPath];
|
|
72
|
+
for (const entry of readDirectorySync(rootPath)) {
|
|
73
|
+
if (!entry.isDirectory) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
directories.push(...collectDirectoriesRecursive(join(rootPath, entry.name)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return directories;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function directoryExistsSync(path: string): boolean {
|
|
84
|
+
try {
|
|
85
|
+
return statSync(path).isDirectory();
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function fileExistsSync(path: string): boolean {
|
|
92
|
+
try {
|
|
93
|
+
return statSync(path).isFile();
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function pathExistsSync(path: string): boolean {
|
|
100
|
+
try {
|
|
101
|
+
statSync(path);
|
|
102
|
+
return true;
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function readBytesSync(path: string): Uint8Array {
|
|
109
|
+
return readFileSync(path);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function readDirectorySync(path: string): readonly HostDirectoryEntry[] {
|
|
113
|
+
return readdirSync(path, { withFileTypes: true }).map((entry) => ({
|
|
114
|
+
isDirectory: entry.isDirectory(),
|
|
115
|
+
isFile: entry.isFile(),
|
|
116
|
+
isSymlink: entry.isSymbolicLink(),
|
|
117
|
+
name: entry.name,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function copyFile(sourcePath: string, destinationPath: string): Promise<void> {
|
|
122
|
+
await copyFileAsync(sourcePath, destinationPath);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export async function createSymlink(
|
|
126
|
+
targetPath: string,
|
|
127
|
+
path: string,
|
|
128
|
+
type?: 'dir' | 'file' | 'junction',
|
|
129
|
+
): Promise<void> {
|
|
130
|
+
await createSymlinkAsync(targetPath, path, type);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export async function createTempDirectory(prefix: string): Promise<string> {
|
|
134
|
+
return await createTempDirectoryAsync(join(tmpdir(), prefix));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export async function makeDirectory(path: string): Promise<void> {
|
|
138
|
+
await mkdirAsync(path, { recursive: true });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function makeDirectorySync(path: string): void {
|
|
142
|
+
mkdirSync(path, { recursive: true });
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function readTextFileSync(path: string): string {
|
|
146
|
+
return readFileSync(path, 'utf8');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function readDirectory(path: string): Promise<readonly HostDirectoryEntry[]> {
|
|
150
|
+
const entries = await readDirectoryAsync(path, { withFileTypes: true });
|
|
151
|
+
return entries.map((entry) => ({
|
|
152
|
+
isDirectory: entry.isDirectory(),
|
|
153
|
+
isFile: entry.isFile(),
|
|
154
|
+
isSymlink: entry.isSymbolicLink(),
|
|
155
|
+
name: entry.name,
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export async function readLink(path: string): Promise<string> {
|
|
160
|
+
return await readLinkAsync(path);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export async function readTextFile(path: string): Promise<string> {
|
|
164
|
+
return await readFileAsync(path, 'utf8');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export async function removePath(path: string): Promise<void> {
|
|
168
|
+
await removePathAsync(path, { recursive: true, force: true });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function removePathSync(path: string): void {
|
|
172
|
+
rmSync(path, { recursive: true, force: true });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function readStdinText(): Promise<string> {
|
|
176
|
+
process.stdin.setEncoding('utf8');
|
|
177
|
+
let text = '';
|
|
178
|
+
for await (const chunk of process.stdin) {
|
|
179
|
+
text += chunk;
|
|
180
|
+
}
|
|
181
|
+
return text;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function runtimeExecPath(): string {
|
|
185
|
+
return process.execPath;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function runtimeArgs(): readonly string[] {
|
|
189
|
+
return process.argv.slice(2);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function runtimeCwd(): string {
|
|
193
|
+
return process.cwd();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function runtimeEnv(name: string): string | undefined {
|
|
197
|
+
return process.env[name];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function runtimeEnvObject(): Record<string, string> {
|
|
201
|
+
return Object.fromEntries(
|
|
202
|
+
Object.entries(process.env).filter((entry): entry is [string, string] => {
|
|
203
|
+
return typeof entry[1] === 'string';
|
|
204
|
+
}),
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function runtimeExit(code: number): never {
|
|
209
|
+
process.exit(code);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function runtimeStdinReadable(): ReadableStream<Uint8Array> {
|
|
213
|
+
return Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function runtimeStdoutWritable(): WritableStream<Uint8Array> {
|
|
217
|
+
return Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export async function* watchFileSystem(
|
|
221
|
+
rootPath: string,
|
|
222
|
+
): AsyncIterable<HostFileSystemWatchEvent> {
|
|
223
|
+
const events = new AsyncHostEventQueue<HostFileSystemWatchEvent>();
|
|
224
|
+
const watchers = new Map<string, FSWatcher>();
|
|
225
|
+
let closed = false;
|
|
226
|
+
let pendingPath: string | undefined;
|
|
227
|
+
let debounceTimer: ReturnType<typeof setTimeout> | undefined;
|
|
228
|
+
|
|
229
|
+
const scheduleModifyEvent = (path: string): void => {
|
|
230
|
+
pendingPath = path;
|
|
231
|
+
if (debounceTimer) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
debounceTimer = setTimeout(() => {
|
|
236
|
+
debounceTimer = undefined;
|
|
237
|
+
events.push({
|
|
238
|
+
kind: 'modify',
|
|
239
|
+
path: pendingPath,
|
|
240
|
+
});
|
|
241
|
+
pendingPath = undefined;
|
|
242
|
+
syncWatchers();
|
|
243
|
+
}, 50);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const syncWatchers = (): void => {
|
|
247
|
+
if (closed) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const expectedPaths = new Set(collectDirectoriesRecursive(rootPath));
|
|
252
|
+
for (const [watchedPath, watcher] of watchers) {
|
|
253
|
+
if (expectedPaths.has(watchedPath)) {
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
watcher.close();
|
|
258
|
+
watchers.delete(watchedPath);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
for (const watchedPath of expectedPaths) {
|
|
262
|
+
if (watchers.has(watchedPath)) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const watcher = watchPath(watchedPath, (eventType, fileName) => {
|
|
267
|
+
const candidatePath = typeof fileName === 'string' && fileName.length > 0
|
|
268
|
+
? join(watchedPath, fileName)
|
|
269
|
+
: watchedPath;
|
|
270
|
+
if (eventType === 'rename') {
|
|
271
|
+
syncWatchers();
|
|
272
|
+
}
|
|
273
|
+
scheduleModifyEvent(candidatePath);
|
|
274
|
+
});
|
|
275
|
+
watcher.on('error', () => {
|
|
276
|
+
events.push({
|
|
277
|
+
kind: 'other',
|
|
278
|
+
path: watchedPath,
|
|
279
|
+
});
|
|
280
|
+
syncWatchers();
|
|
281
|
+
});
|
|
282
|
+
watchers.set(watchedPath, watcher);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
syncWatchers();
|
|
287
|
+
|
|
288
|
+
try {
|
|
289
|
+
while (true) {
|
|
290
|
+
yield await events.shift();
|
|
291
|
+
}
|
|
292
|
+
} finally {
|
|
293
|
+
closed = true;
|
|
294
|
+
if (debounceTimer) {
|
|
295
|
+
clearTimeout(debounceTimer);
|
|
296
|
+
}
|
|
297
|
+
for (const watcher of watchers.values()) {
|
|
298
|
+
watcher.close();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export async function runCommand(
|
|
304
|
+
command: string,
|
|
305
|
+
args: readonly string[],
|
|
306
|
+
cwd: string,
|
|
307
|
+
): Promise<{ exitCode: number; output: string }> {
|
|
308
|
+
return await new Promise((resolve, reject) => {
|
|
309
|
+
const child = spawn(command, [...args], {
|
|
310
|
+
cwd,
|
|
311
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
312
|
+
});
|
|
313
|
+
let output = '';
|
|
314
|
+
|
|
315
|
+
child.stdout?.setEncoding('utf8');
|
|
316
|
+
child.stdout?.on('data', (chunk: string) => {
|
|
317
|
+
output += chunk;
|
|
318
|
+
});
|
|
319
|
+
child.stderr?.setEncoding('utf8');
|
|
320
|
+
child.stderr?.on('data', (chunk: string) => {
|
|
321
|
+
output += chunk;
|
|
322
|
+
});
|
|
323
|
+
child.on('error', reject);
|
|
324
|
+
child.on('close', (code) => {
|
|
325
|
+
resolve({
|
|
326
|
+
exitCode: code ?? 1,
|
|
327
|
+
output,
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function writeStdout(text: string): void {
|
|
334
|
+
process.stdout.write(text);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export async function writeTextFile(path: string, text: string): Promise<void> {
|
|
338
|
+
await writeFileAsync(path, text, 'utf8');
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function writeTextFileSync(path: string, text: string): void {
|
|
342
|
+
writeFileSync(path, text, 'utf8');
|
|
343
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
2
|
+
export { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve, } from 'node:path';
|
|
3
|
+
export function fromFileUrl(url) {
|
|
4
|
+
return fileURLToPath(url);
|
|
5
|
+
}
|
|
6
|
+
export function toFileUrl(path) {
|
|
7
|
+
return pathToFileURL(path);
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
basename,
|
|
5
|
+
dirname,
|
|
6
|
+
extname,
|
|
7
|
+
isAbsolute,
|
|
8
|
+
join,
|
|
9
|
+
normalize,
|
|
10
|
+
relative,
|
|
11
|
+
resolve,
|
|
12
|
+
} from 'node:path';
|
|
13
|
+
|
|
14
|
+
export function fromFileUrl(url: string | URL): string {
|
|
15
|
+
return fileURLToPath(url);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function toFileUrl(path: string): URL {
|
|
19
|
+
return pathToFileURL(path);
|
|
20
|
+
}
|