@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,175 @@
|
|
|
1
|
+
import { findTemplateQuasiAtPosition, findWordAtSourcePosition, formatTemplateLiteralWithInterpolationMarkers, keywordTokenSpans, parseMacroHelperCallExpression, } from './embedded_fragment_support.js';
|
|
2
|
+
const SQL_KEYWORDS = [
|
|
3
|
+
'as',
|
|
4
|
+
'delete',
|
|
5
|
+
'from',
|
|
6
|
+
'group',
|
|
7
|
+
'having',
|
|
8
|
+
'insert',
|
|
9
|
+
'into',
|
|
10
|
+
'join',
|
|
11
|
+
'limit',
|
|
12
|
+
'offset',
|
|
13
|
+
'order',
|
|
14
|
+
'select',
|
|
15
|
+
'set',
|
|
16
|
+
'update',
|
|
17
|
+
'values',
|
|
18
|
+
'where',
|
|
19
|
+
];
|
|
20
|
+
const SQL_KEYWORD_SET = new Set(SQL_KEYWORDS);
|
|
21
|
+
const SQL_COMPLETIONS = [
|
|
22
|
+
{ label: 'SELECT', detail: 'sql keyword' },
|
|
23
|
+
{ label: 'FROM', detail: 'sql keyword' },
|
|
24
|
+
{ label: 'WHERE', detail: 'sql keyword' },
|
|
25
|
+
{ label: 'INSERT', detail: 'sql keyword' },
|
|
26
|
+
{ label: 'UPDATE', detail: 'sql keyword' },
|
|
27
|
+
{ label: 'DELETE', detail: 'sql keyword' },
|
|
28
|
+
{ label: 'ORDER BY', detail: 'sql keyword' },
|
|
29
|
+
{ label: 'GROUP BY', detail: 'sql keyword' },
|
|
30
|
+
{ label: 'LIMIT', detail: 'sql keyword' },
|
|
31
|
+
];
|
|
32
|
+
function parseSqlInterpolationExpression(text, helperName) {
|
|
33
|
+
const helperCall = parseMacroHelperCallExpression(text, helperName, ['ident', 'raw']);
|
|
34
|
+
if (!helperCall) {
|
|
35
|
+
return { kind: 'bind', expressionText: text };
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
expressionText: helperCall.argumentText,
|
|
39
|
+
kind: helperCall.helper,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function sqlIdentifierExpression(expressionText) {
|
|
43
|
+
return `('"' + String(${expressionText}).replaceAll('"', '""') + '"')`;
|
|
44
|
+
}
|
|
45
|
+
function buildSqlQueryTextExpression(template, helperName) {
|
|
46
|
+
const textParts = [];
|
|
47
|
+
const params = [];
|
|
48
|
+
let parameterIndex = 1;
|
|
49
|
+
textParts.push(JSON.stringify(template.quasis[0]?.text ?? ''));
|
|
50
|
+
for (let index = 0; index < template.expressions.length; index += 1) {
|
|
51
|
+
const interpolation = parseSqlInterpolationExpression(template.expressions[index].text(), helperName);
|
|
52
|
+
switch (interpolation.kind) {
|
|
53
|
+
case 'bind':
|
|
54
|
+
textParts.push(JSON.stringify(`$${parameterIndex}`));
|
|
55
|
+
params.push(interpolation.expressionText);
|
|
56
|
+
parameterIndex += 1;
|
|
57
|
+
break;
|
|
58
|
+
case 'ident':
|
|
59
|
+
textParts.push(sqlIdentifierExpression(interpolation.expressionText));
|
|
60
|
+
break;
|
|
61
|
+
case 'raw':
|
|
62
|
+
textParts.push(`String(${interpolation.expressionText})`);
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
textParts.push(JSON.stringify(template.quasis[index + 1]?.text ?? ''));
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
params,
|
|
69
|
+
textExpression: textParts.filter((part) => part.length > 0).join(' + ') || '""',
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const SQL_WORD_REGEX = /\b[A-Za-z_][A-Za-z0-9_]*\b/gu;
|
|
73
|
+
function sqlHover(template, sourcePosition) {
|
|
74
|
+
const quasi = findTemplateQuasiAtPosition(template, sourcePosition);
|
|
75
|
+
if (!quasi) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const word = findWordAtSourcePosition(quasi, sourcePosition, SQL_WORD_REGEX);
|
|
79
|
+
if (word && SQL_KEYWORD_SET.has(word.word.toLowerCase())) {
|
|
80
|
+
return {
|
|
81
|
+
contents: `SQL keyword \`${word.word.toUpperCase()}\`.`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
contents: 'Embedded SQL fragment. `${...}` expressions become bind parameters by default.',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function sqlCompletions(template, sourcePosition) {
|
|
89
|
+
const quasi = findTemplateQuasiAtPosition(template, sourcePosition);
|
|
90
|
+
if (!quasi) {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const prefix = quasi.text
|
|
94
|
+
.slice(0, Math.max(0, sourcePosition - quasi.span.start))
|
|
95
|
+
.match(/[A-Za-z_]*$/u)?.[0] ?? '';
|
|
96
|
+
const loweredPrefix = prefix.toLowerCase();
|
|
97
|
+
return SQL_COMPLETIONS.filter((item) => loweredPrefix.length === 0 || item.label.toLowerCase().startsWith(loweredPrefix));
|
|
98
|
+
}
|
|
99
|
+
function formatSqlText(text) {
|
|
100
|
+
const markerRegex = /__SS_SQL_HOLE_(\d+)__/gu;
|
|
101
|
+
const compact = text
|
|
102
|
+
.split('\n')
|
|
103
|
+
.map((line) => line.trim())
|
|
104
|
+
.filter((line, index, lines) => line.length > 0 || (index > 0 && index < lines.length - 1))
|
|
105
|
+
.join('\n')
|
|
106
|
+
.trim();
|
|
107
|
+
const uppercasedKeywords = compact.replace(SQL_WORD_REGEX, (word) => SQL_KEYWORD_SET.has(word.toLowerCase()) ? word.toUpperCase() : word);
|
|
108
|
+
return uppercasedKeywords
|
|
109
|
+
.split('\n')
|
|
110
|
+
.map((line, index) => {
|
|
111
|
+
const normalized = line.replace(/\s+/gu, ' ').trim();
|
|
112
|
+
if (index === 0) {
|
|
113
|
+
return normalized;
|
|
114
|
+
}
|
|
115
|
+
const upper = normalized.toUpperCase();
|
|
116
|
+
if (upper.startsWith('FROM ') ||
|
|
117
|
+
upper.startsWith('WHERE ') ||
|
|
118
|
+
upper.startsWith('ORDER BY ') ||
|
|
119
|
+
upper.startsWith('GROUP BY ') ||
|
|
120
|
+
upper.startsWith('LIMIT ') ||
|
|
121
|
+
upper.startsWith('OFFSET ') ||
|
|
122
|
+
upper.startsWith('VALUES ') ||
|
|
123
|
+
upper.startsWith('SET ') ||
|
|
124
|
+
upper.startsWith('JOIN ') ||
|
|
125
|
+
upper.startsWith('HAVING ')) {
|
|
126
|
+
return ` ${normalized}`;
|
|
127
|
+
}
|
|
128
|
+
if (markerRegex.test(normalized)) {
|
|
129
|
+
markerRegex.lastIndex = 0;
|
|
130
|
+
}
|
|
131
|
+
return ` ${normalized}`;
|
|
132
|
+
})
|
|
133
|
+
.join('\n');
|
|
134
|
+
}
|
|
135
|
+
function formatSqlTemplateLiteral(template, helperName, formatExpression) {
|
|
136
|
+
return formatTemplateLiteralWithInterpolationMarkers(template, {
|
|
137
|
+
expressionTextForIndex(index) {
|
|
138
|
+
const interpolation = parseSqlInterpolationExpression(template.expressions[index].text(), helperName);
|
|
139
|
+
return interpolation.kind === 'bind'
|
|
140
|
+
? template.expressions[index].text()
|
|
141
|
+
: `${helperName}.${interpolation.kind}(${interpolation.expressionText})`;
|
|
142
|
+
},
|
|
143
|
+
formatCombinedText: formatSqlText,
|
|
144
|
+
formatExpression,
|
|
145
|
+
markerPrefix: '__SS_SQL_HOLE_',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function createSqlEmbeddedFragment(template, helperName) {
|
|
149
|
+
return {
|
|
150
|
+
completions(sourcePosition) {
|
|
151
|
+
return sqlCompletions(template, sourcePosition);
|
|
152
|
+
},
|
|
153
|
+
format(ctx) {
|
|
154
|
+
return formatSqlTemplateLiteral(template, helperName, ctx.formatExpression);
|
|
155
|
+
},
|
|
156
|
+
hover(sourcePosition) {
|
|
157
|
+
return sqlHover(template, sourcePosition);
|
|
158
|
+
},
|
|
159
|
+
language: 'sql',
|
|
160
|
+
semanticTokens: keywordTokenSpans(template.quasis, SQL_WORD_REGEX, (word) => SQL_KEYWORD_SET.has(word.toLowerCase())),
|
|
161
|
+
span: template.span,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export function sqlFragments(ctx) {
|
|
165
|
+
const template = ctx.syntax.template(0);
|
|
166
|
+
return template ? [createSqlEmbeddedFragment(template, ctx.name)] : [];
|
|
167
|
+
}
|
|
168
|
+
export function expandSqlMacro(ctx) {
|
|
169
|
+
const template = ctx.syntax.template(0);
|
|
170
|
+
if (!template) {
|
|
171
|
+
ctx.error('sql requires a template literal operand.');
|
|
172
|
+
}
|
|
173
|
+
const { params, textExpression } = buildSqlQueryTextExpression(template, ctx.name);
|
|
174
|
+
return ctx.output.expr(ctx.quote.expr `({ text: ${textExpression}, params: [${params.join(', ')}] })`);
|
|
175
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
MacroCompletionItem,
|
|
3
|
+
MacroContext,
|
|
4
|
+
MacroEmbeddedFragment,
|
|
5
|
+
MacroTemplateOperand,
|
|
6
|
+
} from './macro_api.ts';
|
|
7
|
+
import {
|
|
8
|
+
findTemplateQuasiAtPosition,
|
|
9
|
+
findWordAtSourcePosition,
|
|
10
|
+
formatTemplateLiteralWithInterpolationMarkers,
|
|
11
|
+
keywordTokenSpans,
|
|
12
|
+
parseMacroHelperCallExpression,
|
|
13
|
+
} from './embedded_fragment_support.ts';
|
|
14
|
+
|
|
15
|
+
const SQL_KEYWORDS = [
|
|
16
|
+
'as',
|
|
17
|
+
'delete',
|
|
18
|
+
'from',
|
|
19
|
+
'group',
|
|
20
|
+
'having',
|
|
21
|
+
'insert',
|
|
22
|
+
'into',
|
|
23
|
+
'join',
|
|
24
|
+
'limit',
|
|
25
|
+
'offset',
|
|
26
|
+
'order',
|
|
27
|
+
'select',
|
|
28
|
+
'set',
|
|
29
|
+
'update',
|
|
30
|
+
'values',
|
|
31
|
+
'where',
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
const SQL_KEYWORD_SET = new Set(SQL_KEYWORDS);
|
|
35
|
+
const SQL_COMPLETIONS: readonly MacroCompletionItem[] = [
|
|
36
|
+
{ label: 'SELECT', detail: 'sql keyword' },
|
|
37
|
+
{ label: 'FROM', detail: 'sql keyword' },
|
|
38
|
+
{ label: 'WHERE', detail: 'sql keyword' },
|
|
39
|
+
{ label: 'INSERT', detail: 'sql keyword' },
|
|
40
|
+
{ label: 'UPDATE', detail: 'sql keyword' },
|
|
41
|
+
{ label: 'DELETE', detail: 'sql keyword' },
|
|
42
|
+
{ label: 'ORDER BY', detail: 'sql keyword' },
|
|
43
|
+
{ label: 'GROUP BY', detail: 'sql keyword' },
|
|
44
|
+
{ label: 'LIMIT', detail: 'sql keyword' },
|
|
45
|
+
] as const;
|
|
46
|
+
|
|
47
|
+
type SqlInterpolation =
|
|
48
|
+
| { readonly expressionText: string; readonly kind: 'bind' }
|
|
49
|
+
| { readonly expressionText: string; readonly kind: 'ident' }
|
|
50
|
+
| { readonly expressionText: string; readonly kind: 'raw' };
|
|
51
|
+
|
|
52
|
+
function parseSqlInterpolationExpression(
|
|
53
|
+
text: string,
|
|
54
|
+
helperName: string,
|
|
55
|
+
): SqlInterpolation {
|
|
56
|
+
const helperCall = parseMacroHelperCallExpression(text, helperName, ['ident', 'raw']);
|
|
57
|
+
if (!helperCall) {
|
|
58
|
+
return { kind: 'bind', expressionText: text };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
expressionText: helperCall.argumentText,
|
|
63
|
+
kind: helperCall.helper as 'ident' | 'raw',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function sqlIdentifierExpression(expressionText: string): string {
|
|
68
|
+
return `('"' + String(${expressionText}).replaceAll('"', '""') + '"')`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function buildSqlQueryTextExpression(
|
|
72
|
+
template: MacroTemplateOperand,
|
|
73
|
+
helperName: string,
|
|
74
|
+
): { params: readonly string[]; textExpression: string } {
|
|
75
|
+
const textParts: string[] = [];
|
|
76
|
+
const params: string[] = [];
|
|
77
|
+
let parameterIndex = 1;
|
|
78
|
+
|
|
79
|
+
textParts.push(JSON.stringify(template.quasis[0]?.text ?? ''));
|
|
80
|
+
for (let index = 0; index < template.expressions.length; index += 1) {
|
|
81
|
+
const interpolation = parseSqlInterpolationExpression(
|
|
82
|
+
template.expressions[index]!.text(),
|
|
83
|
+
helperName,
|
|
84
|
+
);
|
|
85
|
+
switch (interpolation.kind) {
|
|
86
|
+
case 'bind':
|
|
87
|
+
textParts.push(JSON.stringify(`$${parameterIndex}`));
|
|
88
|
+
params.push(interpolation.expressionText);
|
|
89
|
+
parameterIndex += 1;
|
|
90
|
+
break;
|
|
91
|
+
case 'ident':
|
|
92
|
+
textParts.push(sqlIdentifierExpression(interpolation.expressionText));
|
|
93
|
+
break;
|
|
94
|
+
case 'raw':
|
|
95
|
+
textParts.push(`String(${interpolation.expressionText})`);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
textParts.push(JSON.stringify(template.quasis[index + 1]?.text ?? ''));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
params,
|
|
104
|
+
textExpression: textParts.filter((part) => part.length > 0).join(' + ') || '""',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const SQL_WORD_REGEX = /\b[A-Za-z_][A-Za-z0-9_]*\b/gu;
|
|
109
|
+
|
|
110
|
+
function sqlHover(
|
|
111
|
+
template: MacroTemplateOperand,
|
|
112
|
+
sourcePosition: number,
|
|
113
|
+
): { contents: string } | null {
|
|
114
|
+
const quasi = findTemplateQuasiAtPosition(template, sourcePosition);
|
|
115
|
+
if (!quasi) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const word = findWordAtSourcePosition(quasi, sourcePosition, SQL_WORD_REGEX);
|
|
120
|
+
if (word && SQL_KEYWORD_SET.has(word.word.toLowerCase() as typeof SQL_KEYWORDS[number])) {
|
|
121
|
+
return {
|
|
122
|
+
contents: `SQL keyword \`${word.word.toUpperCase()}\`.`,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
contents: 'Embedded SQL fragment. `${...}` expressions become bind parameters by default.',
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function sqlCompletions(
|
|
132
|
+
template: MacroTemplateOperand,
|
|
133
|
+
sourcePosition: number,
|
|
134
|
+
): readonly MacroCompletionItem[] {
|
|
135
|
+
const quasi = findTemplateQuasiAtPosition(template, sourcePosition);
|
|
136
|
+
if (!quasi) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const prefix = quasi.text
|
|
141
|
+
.slice(0, Math.max(0, sourcePosition - quasi.span.start))
|
|
142
|
+
.match(/[A-Za-z_]*$/u)?.[0] ?? '';
|
|
143
|
+
const loweredPrefix = prefix.toLowerCase();
|
|
144
|
+
return SQL_COMPLETIONS.filter((item) =>
|
|
145
|
+
loweredPrefix.length === 0 || item.label.toLowerCase().startsWith(loweredPrefix)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function formatSqlText(text: string): string {
|
|
150
|
+
const markerRegex = /__SS_SQL_HOLE_(\d+)__/gu;
|
|
151
|
+
const compact = text
|
|
152
|
+
.split('\n')
|
|
153
|
+
.map((line) => line.trim())
|
|
154
|
+
.filter((line, index, lines) => line.length > 0 || (index > 0 && index < lines.length - 1))
|
|
155
|
+
.join('\n')
|
|
156
|
+
.trim();
|
|
157
|
+
|
|
158
|
+
const uppercasedKeywords = compact.replace(SQL_WORD_REGEX, (word) =>
|
|
159
|
+
SQL_KEYWORD_SET.has(word.toLowerCase() as typeof SQL_KEYWORDS[number]) ? word.toUpperCase() : word
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
return uppercasedKeywords
|
|
163
|
+
.split('\n')
|
|
164
|
+
.map((line, index) => {
|
|
165
|
+
const normalized = line.replace(/\s+/gu, ' ').trim();
|
|
166
|
+
if (index === 0) {
|
|
167
|
+
return normalized;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const upper = normalized.toUpperCase();
|
|
171
|
+
if (
|
|
172
|
+
upper.startsWith('FROM ') ||
|
|
173
|
+
upper.startsWith('WHERE ') ||
|
|
174
|
+
upper.startsWith('ORDER BY ') ||
|
|
175
|
+
upper.startsWith('GROUP BY ') ||
|
|
176
|
+
upper.startsWith('LIMIT ') ||
|
|
177
|
+
upper.startsWith('OFFSET ') ||
|
|
178
|
+
upper.startsWith('VALUES ') ||
|
|
179
|
+
upper.startsWith('SET ') ||
|
|
180
|
+
upper.startsWith('JOIN ') ||
|
|
181
|
+
upper.startsWith('HAVING ')
|
|
182
|
+
) {
|
|
183
|
+
return ` ${normalized}`;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (markerRegex.test(normalized)) {
|
|
187
|
+
markerRegex.lastIndex = 0;
|
|
188
|
+
}
|
|
189
|
+
return ` ${normalized}`;
|
|
190
|
+
})
|
|
191
|
+
.join('\n');
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function formatSqlTemplateLiteral(
|
|
195
|
+
template: MacroTemplateOperand,
|
|
196
|
+
helperName: string,
|
|
197
|
+
formatExpression: (text: string) => string,
|
|
198
|
+
): string {
|
|
199
|
+
return formatTemplateLiteralWithInterpolationMarkers(template, {
|
|
200
|
+
expressionTextForIndex(index) {
|
|
201
|
+
const interpolation = parseSqlInterpolationExpression(
|
|
202
|
+
template.expressions[index]!.text(),
|
|
203
|
+
helperName,
|
|
204
|
+
);
|
|
205
|
+
return interpolation.kind === 'bind'
|
|
206
|
+
? template.expressions[index]!.text()
|
|
207
|
+
: `${helperName}.${interpolation.kind}(${interpolation.expressionText})`;
|
|
208
|
+
},
|
|
209
|
+
formatCombinedText: formatSqlText,
|
|
210
|
+
formatExpression,
|
|
211
|
+
markerPrefix: '__SS_SQL_HOLE_',
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function createSqlEmbeddedFragment(
|
|
216
|
+
template: MacroTemplateOperand,
|
|
217
|
+
helperName: string,
|
|
218
|
+
): MacroEmbeddedFragment {
|
|
219
|
+
return {
|
|
220
|
+
completions(sourcePosition) {
|
|
221
|
+
return sqlCompletions(template, sourcePosition);
|
|
222
|
+
},
|
|
223
|
+
format(ctx) {
|
|
224
|
+
return formatSqlTemplateLiteral(template, helperName, ctx.formatExpression);
|
|
225
|
+
},
|
|
226
|
+
hover(sourcePosition) {
|
|
227
|
+
return sqlHover(template, sourcePosition);
|
|
228
|
+
},
|
|
229
|
+
language: 'sql',
|
|
230
|
+
semanticTokens: keywordTokenSpans(
|
|
231
|
+
template.quasis,
|
|
232
|
+
SQL_WORD_REGEX,
|
|
233
|
+
(word) => SQL_KEYWORD_SET.has(word.toLowerCase() as typeof SQL_KEYWORDS[number]),
|
|
234
|
+
),
|
|
235
|
+
span: template.span,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export function sqlFragments(ctx: MacroContext): readonly MacroEmbeddedFragment[] {
|
|
240
|
+
const template = ctx.syntax.template(0);
|
|
241
|
+
return template ? [createSqlEmbeddedFragment(template, ctx.name)] : [];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function expandSqlMacro(ctx: MacroContext) {
|
|
245
|
+
const template = ctx.syntax.template(0);
|
|
246
|
+
if (!template) {
|
|
247
|
+
ctx.error('sql requires a template literal operand.');
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const { params, textExpression } = buildSqlQueryTextExpression(template, ctx.name);
|
|
251
|
+
return ctx.output.expr(
|
|
252
|
+
ctx.quote.expr`({ text: ${textExpression}, params: [${params.join(', ')}] })`,
|
|
253
|
+
);
|
|
254
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SQL_STDLIB_DECLARATION_FILE, SQL_STDLIB_DECLARATION_TEXT, SQL_STDLIB_MODULE_SPECIFIER, withStdPackageModuleResolution as withSqlStdlibModuleResolution, } from './std_package_support.js';
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { STS_ASYNC_MODULE_SPECIFIER, STS_CODEC_MODULE_SPECIFIER, STS_COMPARE_MODULE_SPECIFIER, STS_DECODE_MODULE_SPECIFIER, STS_DERIVE_MODULE_SPECIFIER, STS_ENCODE_MODULE_SPECIFIER, STS_EXPERIMENTAL_COMPONENT_MODULE_SPECIFIER, STS_EXPERIMENTAL_CSS_MODULE_SPECIFIER, STS_EXPERIMENTAL_DEBUG_MODULE_SPECIFIER, STS_EXPERIMENTAL_GRAPHQL_MODULE_SPECIFIER, STS_EXPERIMENTAL_SQL_MODULE_SPECIFIER, STS_FAILURES_MODULE_SPECIFIER, STS_FETCH_MODULE_SPECIFIER, STS_HASH_MODULE_SPECIFIER, STS_HKT_MODULE_SPECIFIER, STS_JSON_MODULE_SPECIFIER, STS_MATCH_MODULE_SPECIFIER, STS_NUMERICS_MODULE_SPECIFIER, STS_PRELUDE_MODULE_SPECIFIER, STS_RANDOM_MODULE_SPECIFIER, STS_RESULT_MODULE_SPECIFIER, STS_TEXT_MODULE_SPECIFIER, STS_THUNK_MODULE_SPECIFIER, STS_TYPECLASSES_MODULE_SPECIFIER, STS_URL_MODULE_SPECIFIER, STS_VALUE_MODULE_SPECIFIER, } from '../soundscript_runtime_specifiers.js';
|
|
3
|
+
import { fileExistsSync, readTextFileSync, runtimeExecPath } from '../platform/host.js';
|
|
4
|
+
import { basename, dirname, fromFileUrl, join } from '../platform/path.js';
|
|
5
|
+
export const STDLIB_MODULE_SPECIFIER = STS_PRELUDE_MODULE_SPECIFIER;
|
|
6
|
+
export const HKT_STDLIB_MODULE_SPECIFIER = STS_HKT_MODULE_SPECIFIER;
|
|
7
|
+
export const TYPECLASSES_STDLIB_MODULE_SPECIFIER = STS_TYPECLASSES_MODULE_SPECIFIER;
|
|
8
|
+
export const RESULT_STDLIB_MODULE_SPECIFIER = STS_RESULT_MODULE_SPECIFIER;
|
|
9
|
+
export const VALUE_STDLIB_MODULE_SPECIFIER = STS_VALUE_MODULE_SPECIFIER;
|
|
10
|
+
export const MATCH_STDLIB_MODULE_SPECIFIER = STS_MATCH_MODULE_SPECIFIER;
|
|
11
|
+
export const FAILURES_STDLIB_MODULE_SPECIFIER = STS_FAILURES_MODULE_SPECIFIER;
|
|
12
|
+
export const URL_STDLIB_MODULE_SPECIFIER = STS_URL_MODULE_SPECIFIER;
|
|
13
|
+
export const FETCH_STDLIB_MODULE_SPECIFIER = STS_FETCH_MODULE_SPECIFIER;
|
|
14
|
+
export const TEXT_STDLIB_MODULE_SPECIFIER = STS_TEXT_MODULE_SPECIFIER;
|
|
15
|
+
export const RANDOM_STDLIB_MODULE_SPECIFIER = STS_RANDOM_MODULE_SPECIFIER;
|
|
16
|
+
export const JSON_STDLIB_MODULE_SPECIFIER = STS_JSON_MODULE_SPECIFIER;
|
|
17
|
+
export const COMPARE_STDLIB_MODULE_SPECIFIER = STS_COMPARE_MODULE_SPECIFIER;
|
|
18
|
+
export const HASH_STDLIB_MODULE_SPECIFIER = STS_HASH_MODULE_SPECIFIER;
|
|
19
|
+
export const DERIVE_STDLIB_MODULE_SPECIFIER = STS_DERIVE_MODULE_SPECIFIER;
|
|
20
|
+
export const DECODE_STDLIB_MODULE_SPECIFIER = STS_DECODE_MODULE_SPECIFIER;
|
|
21
|
+
export const ENCODE_STDLIB_MODULE_SPECIFIER = STS_ENCODE_MODULE_SPECIFIER;
|
|
22
|
+
export const CODEC_STDLIB_MODULE_SPECIFIER = STS_CODEC_MODULE_SPECIFIER;
|
|
23
|
+
export const ASYNC_STDLIB_MODULE_SPECIFIER = STS_ASYNC_MODULE_SPECIFIER;
|
|
24
|
+
export const THUNK_STDLIB_MODULE_SPECIFIER = STS_THUNK_MODULE_SPECIFIER;
|
|
25
|
+
export const SQL_STDLIB_MODULE_SPECIFIER = STS_EXPERIMENTAL_SQL_MODULE_SPECIFIER;
|
|
26
|
+
export const CSS_STDLIB_MODULE_SPECIFIER = STS_EXPERIMENTAL_CSS_MODULE_SPECIFIER;
|
|
27
|
+
export const GRAPHQL_STDLIB_MODULE_SPECIFIER = STS_EXPERIMENTAL_GRAPHQL_MODULE_SPECIFIER;
|
|
28
|
+
export const COMPONENT_STDLIB_MODULE_SPECIFIER = STS_EXPERIMENTAL_COMPONENT_MODULE_SPECIFIER;
|
|
29
|
+
export const DEBUG_STDLIB_MODULE_SPECIFIER = STS_EXPERIMENTAL_DEBUG_MODULE_SPECIFIER;
|
|
30
|
+
export const NUMERICS_STDLIB_MODULE_SPECIFIER = STS_NUMERICS_MODULE_SPECIFIER;
|
|
31
|
+
export const STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/index.d.ts', import.meta.url));
|
|
32
|
+
export const HKT_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/hkt.d.ts', import.meta.url));
|
|
33
|
+
export const TYPECLASSES_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/typeclasses.d.ts', import.meta.url));
|
|
34
|
+
export const RESULT_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/result.d.ts', import.meta.url));
|
|
35
|
+
export const VALUE_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/value.d.ts', import.meta.url));
|
|
36
|
+
export const MATCH_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/match.d.ts', import.meta.url));
|
|
37
|
+
export const FAILURES_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/failures.d.ts', import.meta.url));
|
|
38
|
+
export const URL_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/url.d.ts', import.meta.url));
|
|
39
|
+
export const FETCH_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/fetch.d.ts', import.meta.url));
|
|
40
|
+
export const TEXT_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/text.d.ts', import.meta.url));
|
|
41
|
+
export const RANDOM_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/random.d.ts', import.meta.url));
|
|
42
|
+
export const JSON_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/json.d.ts', import.meta.url));
|
|
43
|
+
export const COMPARE_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/compare.d.ts', import.meta.url));
|
|
44
|
+
export const HASH_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/hash.d.ts', import.meta.url));
|
|
45
|
+
export const DERIVE_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/derive.d.ts', import.meta.url));
|
|
46
|
+
export const DECODE_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/decode.d.ts', import.meta.url));
|
|
47
|
+
export const ENCODE_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/encode.d.ts', import.meta.url));
|
|
48
|
+
export const CODEC_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/codec.d.ts', import.meta.url));
|
|
49
|
+
export const ASYNC_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/async.d.ts', import.meta.url));
|
|
50
|
+
export const THUNK_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/thunk.d.ts', import.meta.url));
|
|
51
|
+
export const SQL_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/sql.d.ts', import.meta.url));
|
|
52
|
+
export const CSS_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/css.d.ts', import.meta.url));
|
|
53
|
+
export const GRAPHQL_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/graphql.d.ts', import.meta.url));
|
|
54
|
+
export const COMPONENT_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/component.d.ts', import.meta.url));
|
|
55
|
+
export const DEBUG_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/debug.d.ts', import.meta.url));
|
|
56
|
+
export const NUMERICS_STDLIB_DECLARATION_FILE = fromFileUrl(new URL('../stdlib/numerics.d.ts', import.meta.url));
|
|
57
|
+
function fileExists(path) {
|
|
58
|
+
return fileExistsSync(path);
|
|
59
|
+
}
|
|
60
|
+
export function resolveStdlibDeclarationRuntimePath(sourceFilePath, { execPath = runtimeExecPath(), } = {}) {
|
|
61
|
+
const fileName = basename(sourceFilePath);
|
|
62
|
+
const candidatePaths = [
|
|
63
|
+
sourceFilePath,
|
|
64
|
+
join(dirname(execPath), '..', 'src', 'stdlib', fileName),
|
|
65
|
+
];
|
|
66
|
+
for (const candidatePath of candidatePaths) {
|
|
67
|
+
if (fileExists(candidatePath)) {
|
|
68
|
+
return candidatePath;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return sourceFilePath;
|
|
72
|
+
}
|
|
73
|
+
function readStdlibDeclarationText(sourceFilePath) {
|
|
74
|
+
const resolvedPath = resolveStdlibDeclarationRuntimePath(sourceFilePath);
|
|
75
|
+
const overrideTexts = globalThis
|
|
76
|
+
.__STS_STDLIB_DECLARATION_TEXTS__;
|
|
77
|
+
const overrideText = overrideTexts?.[sourceFilePath] ??
|
|
78
|
+
overrideTexts?.[resolvedPath] ??
|
|
79
|
+
overrideTexts?.[basename(sourceFilePath)];
|
|
80
|
+
if (overrideText !== undefined) {
|
|
81
|
+
return overrideText;
|
|
82
|
+
}
|
|
83
|
+
return readTextFileSync(resolvedPath);
|
|
84
|
+
}
|
|
85
|
+
export const STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(STDLIB_DECLARATION_FILE);
|
|
86
|
+
export const HKT_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(HKT_STDLIB_DECLARATION_FILE);
|
|
87
|
+
export const TYPECLASSES_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(TYPECLASSES_STDLIB_DECLARATION_FILE);
|
|
88
|
+
export const RESULT_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(RESULT_STDLIB_DECLARATION_FILE);
|
|
89
|
+
export const VALUE_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(VALUE_STDLIB_DECLARATION_FILE);
|
|
90
|
+
export const MATCH_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(MATCH_STDLIB_DECLARATION_FILE);
|
|
91
|
+
export const FAILURES_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(FAILURES_STDLIB_DECLARATION_FILE);
|
|
92
|
+
export const URL_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(URL_STDLIB_DECLARATION_FILE);
|
|
93
|
+
export const FETCH_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(FETCH_STDLIB_DECLARATION_FILE);
|
|
94
|
+
export const TEXT_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(TEXT_STDLIB_DECLARATION_FILE);
|
|
95
|
+
export const RANDOM_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(RANDOM_STDLIB_DECLARATION_FILE);
|
|
96
|
+
export const JSON_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(JSON_STDLIB_DECLARATION_FILE);
|
|
97
|
+
export const COMPARE_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(COMPARE_STDLIB_DECLARATION_FILE);
|
|
98
|
+
export const HASH_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(HASH_STDLIB_DECLARATION_FILE);
|
|
99
|
+
export const DERIVE_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(DERIVE_STDLIB_DECLARATION_FILE);
|
|
100
|
+
export const DECODE_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(DECODE_STDLIB_DECLARATION_FILE);
|
|
101
|
+
export const ENCODE_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(ENCODE_STDLIB_DECLARATION_FILE);
|
|
102
|
+
export const CODEC_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(CODEC_STDLIB_DECLARATION_FILE);
|
|
103
|
+
export const ASYNC_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(ASYNC_STDLIB_DECLARATION_FILE);
|
|
104
|
+
export const THUNK_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(THUNK_STDLIB_DECLARATION_FILE);
|
|
105
|
+
export const SQL_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(SQL_STDLIB_DECLARATION_FILE);
|
|
106
|
+
export const CSS_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(CSS_STDLIB_DECLARATION_FILE);
|
|
107
|
+
export const GRAPHQL_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(GRAPHQL_STDLIB_DECLARATION_FILE);
|
|
108
|
+
export const COMPONENT_STDLIB_DECLARATION_TEXT = fileExists(COMPONENT_STDLIB_DECLARATION_FILE)
|
|
109
|
+
? readStdlibDeclarationText(COMPONENT_STDLIB_DECLARATION_FILE)
|
|
110
|
+
: undefined;
|
|
111
|
+
export const DEBUG_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(DEBUG_STDLIB_DECLARATION_FILE);
|
|
112
|
+
export const NUMERICS_STDLIB_DECLARATION_TEXT = readStdlibDeclarationText(NUMERICS_STDLIB_DECLARATION_FILE);
|
|
113
|
+
const STDLIB_DECLARATION_FILES = new Map([
|
|
114
|
+
[STDLIB_MODULE_SPECIFIER, STDLIB_DECLARATION_FILE],
|
|
115
|
+
[HKT_STDLIB_MODULE_SPECIFIER, HKT_STDLIB_DECLARATION_FILE],
|
|
116
|
+
[TYPECLASSES_STDLIB_MODULE_SPECIFIER, TYPECLASSES_STDLIB_DECLARATION_FILE],
|
|
117
|
+
[RESULT_STDLIB_MODULE_SPECIFIER, RESULT_STDLIB_DECLARATION_FILE],
|
|
118
|
+
[VALUE_STDLIB_MODULE_SPECIFIER, VALUE_STDLIB_DECLARATION_FILE],
|
|
119
|
+
[MATCH_STDLIB_MODULE_SPECIFIER, MATCH_STDLIB_DECLARATION_FILE],
|
|
120
|
+
[FAILURES_STDLIB_MODULE_SPECIFIER, FAILURES_STDLIB_DECLARATION_FILE],
|
|
121
|
+
[URL_STDLIB_MODULE_SPECIFIER, URL_STDLIB_DECLARATION_FILE],
|
|
122
|
+
[FETCH_STDLIB_MODULE_SPECIFIER, FETCH_STDLIB_DECLARATION_FILE],
|
|
123
|
+
[TEXT_STDLIB_MODULE_SPECIFIER, TEXT_STDLIB_DECLARATION_FILE],
|
|
124
|
+
[RANDOM_STDLIB_MODULE_SPECIFIER, RANDOM_STDLIB_DECLARATION_FILE],
|
|
125
|
+
[JSON_STDLIB_MODULE_SPECIFIER, JSON_STDLIB_DECLARATION_FILE],
|
|
126
|
+
[COMPARE_STDLIB_MODULE_SPECIFIER, COMPARE_STDLIB_DECLARATION_FILE],
|
|
127
|
+
[HASH_STDLIB_MODULE_SPECIFIER, HASH_STDLIB_DECLARATION_FILE],
|
|
128
|
+
[DERIVE_STDLIB_MODULE_SPECIFIER, DERIVE_STDLIB_DECLARATION_FILE],
|
|
129
|
+
[DECODE_STDLIB_MODULE_SPECIFIER, DECODE_STDLIB_DECLARATION_FILE],
|
|
130
|
+
[ENCODE_STDLIB_MODULE_SPECIFIER, ENCODE_STDLIB_DECLARATION_FILE],
|
|
131
|
+
[CODEC_STDLIB_MODULE_SPECIFIER, CODEC_STDLIB_DECLARATION_FILE],
|
|
132
|
+
[ASYNC_STDLIB_MODULE_SPECIFIER, ASYNC_STDLIB_DECLARATION_FILE],
|
|
133
|
+
[THUNK_STDLIB_MODULE_SPECIFIER, THUNK_STDLIB_DECLARATION_FILE],
|
|
134
|
+
[SQL_STDLIB_MODULE_SPECIFIER, SQL_STDLIB_DECLARATION_FILE],
|
|
135
|
+
[CSS_STDLIB_MODULE_SPECIFIER, CSS_STDLIB_DECLARATION_FILE],
|
|
136
|
+
[GRAPHQL_STDLIB_MODULE_SPECIFIER, GRAPHQL_STDLIB_DECLARATION_FILE],
|
|
137
|
+
...(COMPONENT_STDLIB_DECLARATION_TEXT === undefined
|
|
138
|
+
? []
|
|
139
|
+
: [[COMPONENT_STDLIB_MODULE_SPECIFIER, COMPONENT_STDLIB_DECLARATION_FILE]]),
|
|
140
|
+
[DEBUG_STDLIB_MODULE_SPECIFIER, DEBUG_STDLIB_DECLARATION_FILE],
|
|
141
|
+
[NUMERICS_STDLIB_MODULE_SPECIFIER, NUMERICS_STDLIB_DECLARATION_FILE],
|
|
142
|
+
]);
|
|
143
|
+
const STDLIB_DECLARATION_FILE_SET = new Set(STDLIB_DECLARATION_FILES.values());
|
|
144
|
+
const STDLIB_DECLARATION_TEXTS = new Map([
|
|
145
|
+
[STDLIB_DECLARATION_FILE, STDLIB_DECLARATION_TEXT],
|
|
146
|
+
[HKT_STDLIB_DECLARATION_FILE, HKT_STDLIB_DECLARATION_TEXT],
|
|
147
|
+
[TYPECLASSES_STDLIB_DECLARATION_FILE, TYPECLASSES_STDLIB_DECLARATION_TEXT],
|
|
148
|
+
[RESULT_STDLIB_DECLARATION_FILE, RESULT_STDLIB_DECLARATION_TEXT],
|
|
149
|
+
[VALUE_STDLIB_DECLARATION_FILE, VALUE_STDLIB_DECLARATION_TEXT],
|
|
150
|
+
[MATCH_STDLIB_DECLARATION_FILE, MATCH_STDLIB_DECLARATION_TEXT],
|
|
151
|
+
[FAILURES_STDLIB_DECLARATION_FILE, FAILURES_STDLIB_DECLARATION_TEXT],
|
|
152
|
+
[URL_STDLIB_DECLARATION_FILE, URL_STDLIB_DECLARATION_TEXT],
|
|
153
|
+
[FETCH_STDLIB_DECLARATION_FILE, FETCH_STDLIB_DECLARATION_TEXT],
|
|
154
|
+
[TEXT_STDLIB_DECLARATION_FILE, TEXT_STDLIB_DECLARATION_TEXT],
|
|
155
|
+
[RANDOM_STDLIB_DECLARATION_FILE, RANDOM_STDLIB_DECLARATION_TEXT],
|
|
156
|
+
[JSON_STDLIB_DECLARATION_FILE, JSON_STDLIB_DECLARATION_TEXT],
|
|
157
|
+
[COMPARE_STDLIB_DECLARATION_FILE, COMPARE_STDLIB_DECLARATION_TEXT],
|
|
158
|
+
[HASH_STDLIB_DECLARATION_FILE, HASH_STDLIB_DECLARATION_TEXT],
|
|
159
|
+
[DERIVE_STDLIB_DECLARATION_FILE, DERIVE_STDLIB_DECLARATION_TEXT],
|
|
160
|
+
[DECODE_STDLIB_DECLARATION_FILE, DECODE_STDLIB_DECLARATION_TEXT],
|
|
161
|
+
[ENCODE_STDLIB_DECLARATION_FILE, ENCODE_STDLIB_DECLARATION_TEXT],
|
|
162
|
+
[CODEC_STDLIB_DECLARATION_FILE, CODEC_STDLIB_DECLARATION_TEXT],
|
|
163
|
+
[ASYNC_STDLIB_DECLARATION_FILE, ASYNC_STDLIB_DECLARATION_TEXT],
|
|
164
|
+
[THUNK_STDLIB_DECLARATION_FILE, THUNK_STDLIB_DECLARATION_TEXT],
|
|
165
|
+
[SQL_STDLIB_DECLARATION_FILE, SQL_STDLIB_DECLARATION_TEXT],
|
|
166
|
+
[CSS_STDLIB_DECLARATION_FILE, CSS_STDLIB_DECLARATION_TEXT],
|
|
167
|
+
[GRAPHQL_STDLIB_DECLARATION_FILE, GRAPHQL_STDLIB_DECLARATION_TEXT],
|
|
168
|
+
...(COMPONENT_STDLIB_DECLARATION_TEXT === undefined
|
|
169
|
+
? []
|
|
170
|
+
: [[COMPONENT_STDLIB_DECLARATION_FILE, COMPONENT_STDLIB_DECLARATION_TEXT]]),
|
|
171
|
+
[DEBUG_STDLIB_DECLARATION_FILE, DEBUG_STDLIB_DECLARATION_TEXT],
|
|
172
|
+
[NUMERICS_STDLIB_DECLARATION_FILE, NUMERICS_STDLIB_DECLARATION_TEXT],
|
|
173
|
+
]);
|
|
174
|
+
const STDLIB_DECLARATION_ENTRIES_BY_SPECIFIER = new Map([...STDLIB_DECLARATION_FILES.entries()].flatMap(([specifier, fileName]) => {
|
|
175
|
+
const text = STDLIB_DECLARATION_TEXTS.get(fileName);
|
|
176
|
+
return text === undefined ? [] : [[specifier, { fileName, text }]];
|
|
177
|
+
}));
|
|
178
|
+
export function getStdlibDeclarationTexts() {
|
|
179
|
+
return STDLIB_DECLARATION_TEXTS;
|
|
180
|
+
}
|
|
181
|
+
export function getStdlibDeclarationEntriesBySpecifier() {
|
|
182
|
+
return STDLIB_DECLARATION_ENTRIES_BY_SPECIFIER;
|
|
183
|
+
}
|
|
184
|
+
function createModuleResolutionHost(baseHost) {
|
|
185
|
+
return {
|
|
186
|
+
directoryExists: baseHost.directoryExists?.bind(baseHost),
|
|
187
|
+
fileExists: baseHost.fileExists.bind(baseHost),
|
|
188
|
+
getCurrentDirectory: baseHost.getCurrentDirectory?.bind(baseHost) ??
|
|
189
|
+
(() => ts.sys.getCurrentDirectory()),
|
|
190
|
+
getDirectories: baseHost.getDirectories?.bind(baseHost),
|
|
191
|
+
readFile: baseHost.readFile.bind(baseHost),
|
|
192
|
+
realpath: baseHost.realpath?.bind(baseHost),
|
|
193
|
+
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
export function withStdPackageModuleResolution(baseHost) {
|
|
197
|
+
return {
|
|
198
|
+
...baseHost,
|
|
199
|
+
fileExists(fileName) {
|
|
200
|
+
return STDLIB_DECLARATION_FILE_SET.has(fileName) || baseHost.fileExists(fileName);
|
|
201
|
+
},
|
|
202
|
+
readFile(fileName) {
|
|
203
|
+
if (STDLIB_DECLARATION_FILE_SET.has(fileName)) {
|
|
204
|
+
return STDLIB_DECLARATION_TEXTS.get(fileName);
|
|
205
|
+
}
|
|
206
|
+
return baseHost.readFile(fileName);
|
|
207
|
+
},
|
|
208
|
+
resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, options) {
|
|
209
|
+
const fallbackHost = createModuleResolutionHost(baseHost);
|
|
210
|
+
const delegated = baseHost.resolveModuleNames?.(moduleNames, containingFile, reusedNames, redirectedReference, options ?? {});
|
|
211
|
+
return moduleNames.map((moduleName, index) => {
|
|
212
|
+
const stdlibDeclarationFile = STDLIB_DECLARATION_FILES.get(moduleName);
|
|
213
|
+
if (stdlibDeclarationFile) {
|
|
214
|
+
return {
|
|
215
|
+
resolvedFileName: stdlibDeclarationFile,
|
|
216
|
+
extension: ts.Extension.Dts,
|
|
217
|
+
isExternalLibraryImport: true,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
if (delegated?.[index]) {
|
|
221
|
+
return delegated[index];
|
|
222
|
+
}
|
|
223
|
+
const resolved = ts.resolveModuleName(moduleName, containingFile, options ?? {}, fallbackHost, undefined, redirectedReference);
|
|
224
|
+
return resolved.resolvedModule;
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
}
|