@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,656 @@
|
|
|
1
|
+
const SOUNDSCRIPT_CLASS_TAG = '__soundscript_class_tag__';
|
|
2
|
+
const SOUNDSCRIPT_CLASS_CONSTRUCT = '__soundscript_class_construct';
|
|
3
|
+
const SOUNDSCRIPT_CLASS_BASE_CONSTRUCTOR = '__soundscript_class_base_constructor';
|
|
4
|
+
const SOUNDSCRIPT_CLOSURE_REF = Symbol('soundscript_closure_ref');
|
|
5
|
+
const SOUNDSCRIPT_SYNC_AWARE = Symbol('soundscript_sync_aware');
|
|
6
|
+
function isWebAssemblyModule(value) {
|
|
7
|
+
return typeof WebAssembly.Module === 'function' && value instanceof WebAssembly.Module;
|
|
8
|
+
}
|
|
9
|
+
function isResponseLike(value) {
|
|
10
|
+
return typeof Response === 'function' && value instanceof Response;
|
|
11
|
+
}
|
|
12
|
+
function isUrlLike(value) {
|
|
13
|
+
return typeof URL === 'function' && value instanceof URL;
|
|
14
|
+
}
|
|
15
|
+
function isArrayBufferLike(value) {
|
|
16
|
+
return typeof ArrayBuffer === 'function' && value instanceof ArrayBuffer ||
|
|
17
|
+
typeof SharedArrayBuffer === 'function' && value instanceof SharedArrayBuffer;
|
|
18
|
+
}
|
|
19
|
+
async function loadNodeFileUrl(url) {
|
|
20
|
+
if (url.protocol !== 'file:' || !(typeof process === 'object' && process?.versions?.node)) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const fs = await import('node:fs/promises');
|
|
24
|
+
const bytes = await fs.readFile(url);
|
|
25
|
+
return bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
|
|
26
|
+
}
|
|
27
|
+
async function loadDenoFileUrl(url) {
|
|
28
|
+
const denoNamespace = globalThis.Deno;
|
|
29
|
+
if (!denoNamespace || url.protocol !== 'file:') {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
return await denoNamespace.readFile(url);
|
|
33
|
+
}
|
|
34
|
+
async function loadWasmInstantiateSource(wasmSource) {
|
|
35
|
+
if (isWebAssemblyModule(wasmSource)) {
|
|
36
|
+
return wasmSource;
|
|
37
|
+
}
|
|
38
|
+
if (ArrayBuffer.isView(wasmSource)) {
|
|
39
|
+
return wasmSource;
|
|
40
|
+
}
|
|
41
|
+
if (isArrayBufferLike(wasmSource)) {
|
|
42
|
+
return new Uint8Array(wasmSource);
|
|
43
|
+
}
|
|
44
|
+
if (typeof wasmSource === 'string') {
|
|
45
|
+
const response = await fetch(wasmSource);
|
|
46
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
47
|
+
}
|
|
48
|
+
if (isUrlLike(wasmSource)) {
|
|
49
|
+
const denoBytes = await loadDenoFileUrl(wasmSource);
|
|
50
|
+
if (denoBytes) {
|
|
51
|
+
return denoBytes;
|
|
52
|
+
}
|
|
53
|
+
const nodeBytes = await loadNodeFileUrl(wasmSource);
|
|
54
|
+
if (nodeBytes) {
|
|
55
|
+
return nodeBytes;
|
|
56
|
+
}
|
|
57
|
+
const response = await fetch(wasmSource);
|
|
58
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
59
|
+
}
|
|
60
|
+
if (isResponseLike(wasmSource)) {
|
|
61
|
+
return new Uint8Array(await wasmSource.arrayBuffer());
|
|
62
|
+
}
|
|
63
|
+
return wasmSource;
|
|
64
|
+
}
|
|
65
|
+
function createJsHostImports(instanceCell) {
|
|
66
|
+
const heapIdentityCache = new WeakMap();
|
|
67
|
+
const hostParamIdentityCache = new WeakMap();
|
|
68
|
+
const hostPromiseToInternalCache = new WeakMap();
|
|
69
|
+
const internalPromiseToHostCache = new WeakMap();
|
|
70
|
+
const classConstructorWrappers = new Map();
|
|
71
|
+
const getClassMethodSyncExportName = (tag, propertyName) => `__soundscript_sync_class_method_${tag}__${[...new TextEncoder().encode(propertyName)]
|
|
72
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
73
|
+
.join('')}`;
|
|
74
|
+
const getClassMethodSyncFromHostExportName = (tag, propertyName) => `__soundscript_sync_from_class_method_${tag}__${[...new TextEncoder().encode(propertyName)]
|
|
75
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
76
|
+
.join('')}`;
|
|
77
|
+
const getClassStaticMethodSyncExportName = (tag, propertyName) => `__soundscript_sync_class_static_method_${tag}__${[...new TextEncoder().encode(propertyName)]
|
|
78
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
79
|
+
.join('')}`;
|
|
80
|
+
const getClassStaticMethodSyncFromHostExportName = (tag, propertyName) => `__soundscript_sync_from_class_static_method_${tag}__${[...new TextEncoder().encode(propertyName)]
|
|
81
|
+
.map((byte) => byte.toString(16).padStart(2, '0'))
|
|
82
|
+
.join('')}`;
|
|
83
|
+
const expectHeapIdentityKey = (value) => {
|
|
84
|
+
if ((typeof value !== 'object' && typeof value !== 'function') ||
|
|
85
|
+
value === null) {
|
|
86
|
+
throw new TypeError('Expected wasm heap reference for host identity cache.');
|
|
87
|
+
}
|
|
88
|
+
return value;
|
|
89
|
+
};
|
|
90
|
+
const getOrCreateHostClassConstructor = (tag) => {
|
|
91
|
+
const existing = classConstructorWrappers.get(tag);
|
|
92
|
+
if (existing) {
|
|
93
|
+
return existing;
|
|
94
|
+
}
|
|
95
|
+
const wrapper = function SoundscriptClassWrapper(...args) {
|
|
96
|
+
if (new.target === undefined) {
|
|
97
|
+
throw new TypeError('Class constructors must be invoked with new.');
|
|
98
|
+
}
|
|
99
|
+
const construct = wrapper[SOUNDSCRIPT_CLASS_CONSTRUCT];
|
|
100
|
+
if (typeof construct !== 'function') {
|
|
101
|
+
throw new TypeError('Compiled class constructor wrapper is missing construct hook.');
|
|
102
|
+
}
|
|
103
|
+
return construct(...args);
|
|
104
|
+
};
|
|
105
|
+
Object.defineProperty(wrapper, 'name', {
|
|
106
|
+
configurable: true,
|
|
107
|
+
value: `SoundscriptClass${tag}`,
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(wrapper, Symbol.hasInstance, {
|
|
110
|
+
configurable: true,
|
|
111
|
+
value(instance) {
|
|
112
|
+
if (typeof instance !== 'object' || instance === null) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return wrapper.prototype.isPrototypeOf(instance);
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
Object.defineProperty(wrapper.prototype, 'constructor', {
|
|
119
|
+
configurable: true,
|
|
120
|
+
enumerable: false,
|
|
121
|
+
value: wrapper,
|
|
122
|
+
writable: true,
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(wrapper, SOUNDSCRIPT_CLASS_TAG, {
|
|
125
|
+
configurable: true,
|
|
126
|
+
enumerable: false,
|
|
127
|
+
value: Number(tag),
|
|
128
|
+
writable: true,
|
|
129
|
+
});
|
|
130
|
+
classConstructorWrappers.set(tag, wrapper);
|
|
131
|
+
return wrapper;
|
|
132
|
+
};
|
|
133
|
+
const syncClassPrototype = (value) => {
|
|
134
|
+
if (typeof value !== 'object' || value === null) {
|
|
135
|
+
throw new TypeError('Expected JS object for soundscript_object.sync_class_prototype.');
|
|
136
|
+
}
|
|
137
|
+
const objectRecord = value;
|
|
138
|
+
const tag = objectRecord[SOUNDSCRIPT_CLASS_TAG];
|
|
139
|
+
if (typeof tag !== 'number') {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
Object.setPrototypeOf(value, getOrCreateHostClassConstructor(Number(tag)).prototype);
|
|
143
|
+
};
|
|
144
|
+
const syncHostBoundaryValue = (value) => {
|
|
145
|
+
if (Array.isArray(value)) {
|
|
146
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
147
|
+
value[index] = syncHostBoundaryValue(value[index]);
|
|
148
|
+
}
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
if (typeof value === 'object' && value !== null) {
|
|
152
|
+
syncClassPrototype(value);
|
|
153
|
+
}
|
|
154
|
+
return value;
|
|
155
|
+
};
|
|
156
|
+
const wrapHostMethodIfNeeded = (target, propertyName, value) => {
|
|
157
|
+
if (typeof value !== 'function') {
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
if (value[SOUNDSCRIPT_SYNC_AWARE] === true) {
|
|
161
|
+
return value;
|
|
162
|
+
}
|
|
163
|
+
const tag = target[SOUNDSCRIPT_CLASS_TAG];
|
|
164
|
+
const closureRef = value[SOUNDSCRIPT_CLOSURE_REF];
|
|
165
|
+
if (typeof tag !== 'number' || closureRef === undefined) {
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
const instance = instanceCell.instance;
|
|
169
|
+
if (!instance) {
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
172
|
+
const syncExportName = typeof target === 'function'
|
|
173
|
+
? getClassStaticMethodSyncExportName(Number(tag), propertyName)
|
|
174
|
+
: getClassMethodSyncExportName(Number(tag), propertyName);
|
|
175
|
+
const syncFromHostExportName = typeof target === 'function'
|
|
176
|
+
? getClassStaticMethodSyncFromHostExportName(Number(tag), propertyName)
|
|
177
|
+
: getClassMethodSyncFromHostExportName(Number(tag), propertyName);
|
|
178
|
+
const sync = instance.exports[syncExportName];
|
|
179
|
+
const syncFromHost = instance.exports[syncFromHostExportName];
|
|
180
|
+
if (typeof sync !== 'function' && typeof syncFromHost !== 'function') {
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
const callable = value;
|
|
184
|
+
const wrapped = function (...args) {
|
|
185
|
+
if (typeof syncFromHost === 'function') {
|
|
186
|
+
syncFromHost(closureRef, target);
|
|
187
|
+
}
|
|
188
|
+
const result = callable.apply(this, args);
|
|
189
|
+
if (typeof sync === 'function') {
|
|
190
|
+
sync(closureRef, target);
|
|
191
|
+
}
|
|
192
|
+
return result;
|
|
193
|
+
};
|
|
194
|
+
Object.defineProperty(wrapped, SOUNDSCRIPT_CLOSURE_REF, {
|
|
195
|
+
configurable: true,
|
|
196
|
+
enumerable: false,
|
|
197
|
+
value: closureRef,
|
|
198
|
+
writable: false,
|
|
199
|
+
});
|
|
200
|
+
return wrapped;
|
|
201
|
+
};
|
|
202
|
+
return {
|
|
203
|
+
soundscript_array: {
|
|
204
|
+
empty: () => [],
|
|
205
|
+
empty_number: () => [],
|
|
206
|
+
empty_boolean: () => [],
|
|
207
|
+
clear: (value) => {
|
|
208
|
+
if (!Array.isArray(value)) {
|
|
209
|
+
throw new TypeError('Expected JS array for soundscript_array.clear.');
|
|
210
|
+
}
|
|
211
|
+
value.length = 0;
|
|
212
|
+
},
|
|
213
|
+
length: (value) => {
|
|
214
|
+
if (!Array.isArray(value)) {
|
|
215
|
+
throw new TypeError('Expected JS array for soundscript_array.length.');
|
|
216
|
+
}
|
|
217
|
+
return value.length;
|
|
218
|
+
},
|
|
219
|
+
same: (left, right) => Number(Object.is(left, right)),
|
|
220
|
+
get: (value, index) => {
|
|
221
|
+
if (!Array.isArray(value)) {
|
|
222
|
+
throw new TypeError('Expected JS array for soundscript_array.get.');
|
|
223
|
+
}
|
|
224
|
+
return value[Number(index)];
|
|
225
|
+
},
|
|
226
|
+
get_number: (value, index) => {
|
|
227
|
+
if (!Array.isArray(value)) {
|
|
228
|
+
throw new TypeError('Expected JS array for soundscript_array.get_number.');
|
|
229
|
+
}
|
|
230
|
+
return Number(value[Number(index)]);
|
|
231
|
+
},
|
|
232
|
+
get_boolean: (value, index) => {
|
|
233
|
+
if (!Array.isArray(value)) {
|
|
234
|
+
throw new TypeError('Expected JS array for soundscript_array.get_boolean.');
|
|
235
|
+
}
|
|
236
|
+
return Boolean(value[Number(index)]) ? 1 : 0;
|
|
237
|
+
},
|
|
238
|
+
push: (target, value) => {
|
|
239
|
+
if (!Array.isArray(target)) {
|
|
240
|
+
throw new TypeError('Expected JS array for soundscript_array.push.');
|
|
241
|
+
}
|
|
242
|
+
target.push(syncHostBoundaryValue(value));
|
|
243
|
+
},
|
|
244
|
+
push_number: (target, value) => {
|
|
245
|
+
if (!Array.isArray(target)) {
|
|
246
|
+
throw new TypeError('Expected JS array for soundscript_array.push_number.');
|
|
247
|
+
}
|
|
248
|
+
target.push(Number(value));
|
|
249
|
+
},
|
|
250
|
+
push_boolean: (target, value) => {
|
|
251
|
+
if (!Array.isArray(target)) {
|
|
252
|
+
throw new TypeError('Expected JS array for soundscript_array.push_boolean.');
|
|
253
|
+
}
|
|
254
|
+
target.push(Boolean(value));
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
soundscript_length_view: {
|
|
258
|
+
length: (value) => {
|
|
259
|
+
if (value === null ||
|
|
260
|
+
value === undefined ||
|
|
261
|
+
(!Array.isArray(value) && typeof value !== 'string' &&
|
|
262
|
+
(typeof value !== 'object' || value === null || !('length' in value)))) {
|
|
263
|
+
throw new TypeError('Expected string, array, or length-bearing object.');
|
|
264
|
+
}
|
|
265
|
+
return Number(value.length);
|
|
266
|
+
},
|
|
267
|
+
from_length: (value) => ({ length: Number(value) }),
|
|
268
|
+
},
|
|
269
|
+
soundscript_object: new Proxy({}, {
|
|
270
|
+
get(_target, property) {
|
|
271
|
+
if (property === 'same') {
|
|
272
|
+
return (left, right) => Number(left === right);
|
|
273
|
+
}
|
|
274
|
+
if (property === 'empty') {
|
|
275
|
+
return () => ({});
|
|
276
|
+
}
|
|
277
|
+
if (property === 'lookup_cached') {
|
|
278
|
+
return (value) => heapIdentityCache.get(expectHeapIdentityKey(value)) ?? null;
|
|
279
|
+
}
|
|
280
|
+
if (property === 'remember_cached') {
|
|
281
|
+
return (value, hostValue) => {
|
|
282
|
+
heapIdentityCache.set(expectHeapIdentityKey(value), hostValue);
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
if (property === 'get_class_tag') {
|
|
286
|
+
return (value) => {
|
|
287
|
+
if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {
|
|
288
|
+
throw new TypeError('Expected JS object or function for soundscript_object.get_class_tag.');
|
|
289
|
+
}
|
|
290
|
+
const objectRecord = value;
|
|
291
|
+
return typeof objectRecord[SOUNDSCRIPT_CLASS_TAG] === 'number'
|
|
292
|
+
? Number(objectRecord[SOUNDSCRIPT_CLASS_TAG])
|
|
293
|
+
: -1;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (property === 'set_class_tag') {
|
|
297
|
+
return (value, next) => {
|
|
298
|
+
if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {
|
|
299
|
+
throw new TypeError('Expected JS object or function for soundscript_object.set_class_tag.');
|
|
300
|
+
}
|
|
301
|
+
Object.defineProperty(value, SOUNDSCRIPT_CLASS_TAG, {
|
|
302
|
+
configurable: true,
|
|
303
|
+
enumerable: false,
|
|
304
|
+
value: Number(next),
|
|
305
|
+
writable: true,
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
if (property === 'class_constructor_from_tag') {
|
|
310
|
+
return (tag) => getOrCreateHostClassConstructor(Number(tag));
|
|
311
|
+
}
|
|
312
|
+
if (property === 'sync_class_prototype') {
|
|
313
|
+
return syncClassPrototype;
|
|
314
|
+
}
|
|
315
|
+
if (typeof property !== 'string') {
|
|
316
|
+
return undefined;
|
|
317
|
+
}
|
|
318
|
+
const expectMapValue = (value) => {
|
|
319
|
+
if (!(value instanceof Map)) {
|
|
320
|
+
throw new TypeError('Expected JS Map for soundscript_object collection host boundary.');
|
|
321
|
+
}
|
|
322
|
+
return value;
|
|
323
|
+
};
|
|
324
|
+
const expectSetValue = (value) => {
|
|
325
|
+
if (!(value instanceof Set)) {
|
|
326
|
+
throw new TypeError('Expected JS Set for soundscript_object collection host boundary.');
|
|
327
|
+
}
|
|
328
|
+
return value;
|
|
329
|
+
};
|
|
330
|
+
if (property === 'map_keys') {
|
|
331
|
+
return (value) => Array.from(expectMapValue(value).keys(), (entry) => String(entry));
|
|
332
|
+
}
|
|
333
|
+
if (property === 'map_values_number') {
|
|
334
|
+
return (value) => Array.from(expectMapValue(value).values(), (entry) => Number(entry));
|
|
335
|
+
}
|
|
336
|
+
if (property === 'map_values_boolean') {
|
|
337
|
+
return (value) => Array.from(expectMapValue(value).values(), (entry) => Boolean(entry));
|
|
338
|
+
}
|
|
339
|
+
if (property === 'map_values_string') {
|
|
340
|
+
return (value) => Array.from(expectMapValue(value).values(), (entry) => String(entry));
|
|
341
|
+
}
|
|
342
|
+
if (property === 'set_values_number') {
|
|
343
|
+
return (value) => Array.from(expectSetValue(value).values(), (entry) => Number(entry));
|
|
344
|
+
}
|
|
345
|
+
if (property === 'set_values_boolean') {
|
|
346
|
+
return (value) => Array.from(expectSetValue(value).values(), (entry) => Boolean(entry));
|
|
347
|
+
}
|
|
348
|
+
if (property === 'set_values_string') {
|
|
349
|
+
return (value) => Array.from(expectSetValue(value).values(), (entry) => String(entry));
|
|
350
|
+
}
|
|
351
|
+
if (property === 'set_values_key') {
|
|
352
|
+
return () => '__set_values';
|
|
353
|
+
}
|
|
354
|
+
const match = /^(get_number|get_boolean|get_closure|set_number|set_boolean|set_closure|has|get_tagged|set_tagged):(.*)$/
|
|
355
|
+
.exec(property);
|
|
356
|
+
const paramCacheMatch = /^(lookup_param_cached|remember_param_cached):(.*)$/.exec(property);
|
|
357
|
+
if (paramCacheMatch) {
|
|
358
|
+
const kind = paramCacheMatch[1];
|
|
359
|
+
const cacheKey = decodeURIComponent(paramCacheMatch[2]);
|
|
360
|
+
const expectHostIdentityKey = (value) => {
|
|
361
|
+
if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {
|
|
362
|
+
throw new TypeError('Expected JS object for soundscript_object param identity cache.');
|
|
363
|
+
}
|
|
364
|
+
return value;
|
|
365
|
+
};
|
|
366
|
+
if (kind === 'lookup_param_cached') {
|
|
367
|
+
return (value) => hostParamIdentityCache.get(expectHostIdentityKey(value))?.get(cacheKey) ?? null;
|
|
368
|
+
}
|
|
369
|
+
return (value, heapValue) => {
|
|
370
|
+
const hostKey = expectHostIdentityKey(value);
|
|
371
|
+
const existing = hostParamIdentityCache.get(hostKey);
|
|
372
|
+
if (existing) {
|
|
373
|
+
existing.set(cacheKey, heapValue);
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const created = new Map();
|
|
377
|
+
created.set(cacheKey, heapValue);
|
|
378
|
+
hostParamIdentityCache.set(hostKey, created);
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
if (!match) {
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
const kind = match[1];
|
|
385
|
+
const propertyName = decodeURIComponent(match[2]);
|
|
386
|
+
const expectObjectRecord = (value) => {
|
|
387
|
+
if ((typeof value !== 'object' && typeof value !== 'function') || value === null) {
|
|
388
|
+
throw new TypeError('Expected JS object or function for soundscript_object host boundary.');
|
|
389
|
+
}
|
|
390
|
+
return value;
|
|
391
|
+
};
|
|
392
|
+
switch (kind) {
|
|
393
|
+
case 'has':
|
|
394
|
+
return (value) => Number(Object.prototype.hasOwnProperty.call(expectObjectRecord(value), propertyName));
|
|
395
|
+
case 'get_number':
|
|
396
|
+
return (value) => Number(expectObjectRecord(value)[propertyName]);
|
|
397
|
+
case 'get_boolean':
|
|
398
|
+
return (value) => Number(Boolean(expectObjectRecord(value)[propertyName]));
|
|
399
|
+
case 'get_closure':
|
|
400
|
+
return (value) => {
|
|
401
|
+
const objectRecord = expectObjectRecord(value);
|
|
402
|
+
const propertyValue = objectRecord[propertyName];
|
|
403
|
+
return typeof propertyValue === 'function'
|
|
404
|
+
? propertyValue.bind(value)
|
|
405
|
+
: propertyValue;
|
|
406
|
+
};
|
|
407
|
+
case 'get_tagged':
|
|
408
|
+
return (value) => expectObjectRecord(value)[propertyName];
|
|
409
|
+
case 'set_number':
|
|
410
|
+
return (value, next) => {
|
|
411
|
+
expectObjectRecord(value)[propertyName] = Number(next);
|
|
412
|
+
};
|
|
413
|
+
case 'set_boolean':
|
|
414
|
+
return (value, next) => {
|
|
415
|
+
expectObjectRecord(value)[propertyName] = next !== 0;
|
|
416
|
+
};
|
|
417
|
+
case 'set_closure':
|
|
418
|
+
return (value, next) => {
|
|
419
|
+
const objectRecord = expectObjectRecord(value);
|
|
420
|
+
objectRecord[propertyName] = wrapHostMethodIfNeeded(objectRecord, propertyName, next);
|
|
421
|
+
};
|
|
422
|
+
case 'set_tagged':
|
|
423
|
+
return (value, next) => {
|
|
424
|
+
const objectRecord = expectObjectRecord(value);
|
|
425
|
+
objectRecord[propertyName] = syncHostBoundaryValue(next);
|
|
426
|
+
if (propertyName === SOUNDSCRIPT_CLASS_BASE_CONSTRUCTOR &&
|
|
427
|
+
typeof value === 'function' &&
|
|
428
|
+
typeof next === 'function') {
|
|
429
|
+
Object.setPrototypeOf(value, next);
|
|
430
|
+
if (typeof value.prototype === 'object' &&
|
|
431
|
+
value.prototype !== null &&
|
|
432
|
+
typeof next.prototype === 'object' &&
|
|
433
|
+
next.prototype !== null) {
|
|
434
|
+
Object.setPrototypeOf(value.prototype, next.prototype);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
default:
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
}),
|
|
443
|
+
soundscript_string: {
|
|
444
|
+
empty: () => '',
|
|
445
|
+
from_char_code: (value) => String.fromCharCode(Number(value)),
|
|
446
|
+
length: (value) => String(value).length,
|
|
447
|
+
char_at: (value, index) => String(value).charAt(Number(index)),
|
|
448
|
+
char_code_at: (value, index) => String(value).charCodeAt(Number(index)),
|
|
449
|
+
to_upper_case: (value) => String(value).toUpperCase(),
|
|
450
|
+
to_lower_case: (value) => String(value).toLowerCase(),
|
|
451
|
+
trim: (value) => String(value).trim(),
|
|
452
|
+
trim_start: (value) => String(value).trimStart(),
|
|
453
|
+
trim_end: (value) => String(value).trimEnd(),
|
|
454
|
+
starts_with: (value, search) => Number(String(value).startsWith(String(search))),
|
|
455
|
+
ends_with: (value, search) => Number(String(value).endsWith(String(search))),
|
|
456
|
+
includes: (value, search) => Number(String(value).includes(String(search))),
|
|
457
|
+
index_of: (value, search) => String(value).indexOf(String(search)),
|
|
458
|
+
last_index_of: (value, search) => String(value).lastIndexOf(String(search)),
|
|
459
|
+
slice: (value, start, end, hasEnd) => hasEnd
|
|
460
|
+
? String(value).slice(Number(start), Number(end))
|
|
461
|
+
: String(value).slice(Number(start)),
|
|
462
|
+
substring: (value, start, end, hasEnd) => hasEnd
|
|
463
|
+
? String(value).substring(Number(start), Number(end))
|
|
464
|
+
: String(value).substring(Number(start)),
|
|
465
|
+
concat: (left, right) => String(left) + String(right),
|
|
466
|
+
equals: (left, right) => Number(String(left) === String(right)),
|
|
467
|
+
},
|
|
468
|
+
soundscript_tagged: {
|
|
469
|
+
undefined_value: () => undefined,
|
|
470
|
+
type_tag: (value) => {
|
|
471
|
+
if (value === undefined) {
|
|
472
|
+
return 0;
|
|
473
|
+
}
|
|
474
|
+
if (typeof value === 'boolean') {
|
|
475
|
+
return 1;
|
|
476
|
+
}
|
|
477
|
+
if (typeof value === 'number') {
|
|
478
|
+
return 2;
|
|
479
|
+
}
|
|
480
|
+
if (typeof value === 'string') {
|
|
481
|
+
return 3;
|
|
482
|
+
}
|
|
483
|
+
if (typeof value === 'object' || typeof value === 'function') {
|
|
484
|
+
if (value === null) {
|
|
485
|
+
return 6;
|
|
486
|
+
}
|
|
487
|
+
return 4;
|
|
488
|
+
}
|
|
489
|
+
if (value === null) {
|
|
490
|
+
return 6;
|
|
491
|
+
}
|
|
492
|
+
throw new Error(`Unsupported tagged host value: ${String(value)}`);
|
|
493
|
+
},
|
|
494
|
+
number_value: (value) => Number(value),
|
|
495
|
+
boolean_value: (value) => Number(Boolean(value)),
|
|
496
|
+
from_number: (value) => Number(value),
|
|
497
|
+
from_boolean: (value) => value !== 0,
|
|
498
|
+
},
|
|
499
|
+
soundscript_closure: new Proxy({}, {
|
|
500
|
+
get(_target, property) {
|
|
501
|
+
if (typeof property !== 'string') {
|
|
502
|
+
return undefined;
|
|
503
|
+
}
|
|
504
|
+
const callMatch = /^call_(\d+)$/.exec(property);
|
|
505
|
+
if (callMatch) {
|
|
506
|
+
return (callback, ...args) => {
|
|
507
|
+
if (typeof callback !== 'function') {
|
|
508
|
+
throw new TypeError('Expected JS function for soundscript_closure.call.');
|
|
509
|
+
}
|
|
510
|
+
return callback(...args);
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
const toHostSyncMatch = /^to_host_sync_(\d+):(.*)$/.exec(property);
|
|
514
|
+
if (toHostSyncMatch) {
|
|
515
|
+
const signatureId = Number(toHostSyncMatch[1]);
|
|
516
|
+
const syncExportName = decodeURIComponent(toHostSyncMatch[2] ?? '');
|
|
517
|
+
return (target, closure) => {
|
|
518
|
+
const wrapped = (...args) => {
|
|
519
|
+
const instance = instanceCell.instance;
|
|
520
|
+
if (!instance) {
|
|
521
|
+
throw new Error('Closure export wrapper invoked before instantiation completed.');
|
|
522
|
+
}
|
|
523
|
+
const invoke = instance.exports[`__soundscript_closure_invoke_${signatureId}`];
|
|
524
|
+
if (typeof invoke !== 'function') {
|
|
525
|
+
throw new Error(`Missing exported closure invoker for signature ${signatureId}.`);
|
|
526
|
+
}
|
|
527
|
+
const sync = instance.exports[syncExportName];
|
|
528
|
+
if (typeof sync !== 'function') {
|
|
529
|
+
throw new Error(`Missing exported closure sync helper ${syncExportName}.`);
|
|
530
|
+
}
|
|
531
|
+
const syncFromHostExportName = syncExportName.startsWith('__soundscript_sync_class_method_')
|
|
532
|
+
? syncExportName.replace('__soundscript_sync_class_method_', '__soundscript_sync_from_class_method_')
|
|
533
|
+
: syncExportName.startsWith('__soundscript_sync_class_static_method_')
|
|
534
|
+
? syncExportName.replace('__soundscript_sync_class_static_method_', '__soundscript_sync_from_class_static_method_')
|
|
535
|
+
: null;
|
|
536
|
+
const syncFromHost = syncFromHostExportName
|
|
537
|
+
? instance.exports[syncFromHostExportName]
|
|
538
|
+
: undefined;
|
|
539
|
+
if (typeof syncFromHost === 'function') {
|
|
540
|
+
syncFromHost(closure, target);
|
|
541
|
+
}
|
|
542
|
+
const result = invoke(closure, ...args);
|
|
543
|
+
sync(closure, target);
|
|
544
|
+
return result;
|
|
545
|
+
};
|
|
546
|
+
Object.defineProperty(wrapped, SOUNDSCRIPT_CLOSURE_REF, {
|
|
547
|
+
configurable: true,
|
|
548
|
+
enumerable: false,
|
|
549
|
+
value: closure,
|
|
550
|
+
writable: false,
|
|
551
|
+
});
|
|
552
|
+
Object.defineProperty(wrapped, SOUNDSCRIPT_SYNC_AWARE, {
|
|
553
|
+
configurable: true,
|
|
554
|
+
enumerable: false,
|
|
555
|
+
value: true,
|
|
556
|
+
writable: false,
|
|
557
|
+
});
|
|
558
|
+
return wrapped;
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
const toHostMatch = /^to_host_(\d+)$/.exec(property);
|
|
562
|
+
if (toHostMatch) {
|
|
563
|
+
const signatureId = Number(toHostMatch[1]);
|
|
564
|
+
return (closure) => {
|
|
565
|
+
const wrapped = (...args) => {
|
|
566
|
+
const instance = instanceCell.instance;
|
|
567
|
+
if (!instance) {
|
|
568
|
+
throw new Error('Closure export wrapper invoked before instantiation completed.');
|
|
569
|
+
}
|
|
570
|
+
const invoke = instance.exports[`__soundscript_closure_invoke_${signatureId}`];
|
|
571
|
+
if (typeof invoke !== 'function') {
|
|
572
|
+
throw new Error(`Missing exported closure invoker for signature ${signatureId}.`);
|
|
573
|
+
}
|
|
574
|
+
return invoke(closure, ...args);
|
|
575
|
+
};
|
|
576
|
+
Object.defineProperty(wrapped, SOUNDSCRIPT_CLOSURE_REF, {
|
|
577
|
+
configurable: true,
|
|
578
|
+
enumerable: false,
|
|
579
|
+
value: closure,
|
|
580
|
+
writable: false,
|
|
581
|
+
});
|
|
582
|
+
return wrapped;
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
return undefined;
|
|
586
|
+
},
|
|
587
|
+
}),
|
|
588
|
+
soundscript_promise: {
|
|
589
|
+
to_internal: (value, candidate) => {
|
|
590
|
+
if (!(value instanceof Promise)) {
|
|
591
|
+
throw new TypeError('Expected JS Promise for soundscript_promise.to_internal.');
|
|
592
|
+
}
|
|
593
|
+
const candidateKey = expectHeapIdentityKey(candidate);
|
|
594
|
+
const existing = hostPromiseToInternalCache.get(value);
|
|
595
|
+
if (existing) {
|
|
596
|
+
return existing;
|
|
597
|
+
}
|
|
598
|
+
const instance = instanceCell.instance;
|
|
599
|
+
if (!instance) {
|
|
600
|
+
throw new Error('Promise bridge invoked before instantiation completed.');
|
|
601
|
+
}
|
|
602
|
+
const fulfill = instance.exports.__soundscript_promise_bridge_fulfill;
|
|
603
|
+
const reject = instance.exports.__soundscript_promise_bridge_reject;
|
|
604
|
+
if (typeof fulfill !== 'function' || typeof reject !== 'function') {
|
|
605
|
+
throw new Error('Missing exported Promise bridge helpers.');
|
|
606
|
+
}
|
|
607
|
+
hostPromiseToInternalCache.set(value, candidateKey);
|
|
608
|
+
internalPromiseToHostCache.set(candidateKey, value);
|
|
609
|
+
value.then((resolved) => {
|
|
610
|
+
fulfill(candidateKey, resolved);
|
|
611
|
+
}, (reason) => {
|
|
612
|
+
reject(candidateKey, reason);
|
|
613
|
+
});
|
|
614
|
+
return candidateKey;
|
|
615
|
+
},
|
|
616
|
+
to_host: (value) => {
|
|
617
|
+
const internalPromise = expectHeapIdentityKey(value);
|
|
618
|
+
const existing = internalPromiseToHostCache.get(internalPromise);
|
|
619
|
+
if (existing) {
|
|
620
|
+
return existing;
|
|
621
|
+
}
|
|
622
|
+
const instance = instanceCell.instance;
|
|
623
|
+
if (!instance) {
|
|
624
|
+
throw new Error('Promise bridge invoked before instantiation completed.');
|
|
625
|
+
}
|
|
626
|
+
const attach = instance.exports.__soundscript_promise_then_host;
|
|
627
|
+
if (typeof attach !== 'function') {
|
|
628
|
+
throw new Error('Missing exported Promise host attachment helper.');
|
|
629
|
+
}
|
|
630
|
+
const created = new Promise((resolve, reject) => {
|
|
631
|
+
attach(internalPromise, resolve, reject);
|
|
632
|
+
});
|
|
633
|
+
internalPromiseToHostCache.set(internalPromise, created);
|
|
634
|
+
return created;
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
export async function instantiateSoundscriptWasmModule(wasmSource, options = {}) {
|
|
640
|
+
const source = await loadWasmInstantiateSource(wasmSource);
|
|
641
|
+
const instanceCell = { instance: null };
|
|
642
|
+
const userImports = options.imports ?? {};
|
|
643
|
+
const importedHostFunctions = userImports.soundscript_host_function ?? {};
|
|
644
|
+
const hostFunctionImports = Object.fromEntries(Object.entries({
|
|
645
|
+
...importedHostFunctions,
|
|
646
|
+
...(options.hostFunctions ?? {}),
|
|
647
|
+
}).map(([name, func]) => [name, (...args) => func(...args)]));
|
|
648
|
+
const instantiated = await WebAssembly.instantiate(source, {
|
|
649
|
+
...createJsHostImports(instanceCell),
|
|
650
|
+
...userImports,
|
|
651
|
+
soundscript_host_function: hostFunctionImports,
|
|
652
|
+
});
|
|
653
|
+
const instance = 'instance' in instantiated ? instantiated.instance : instantiated;
|
|
654
|
+
instanceCell.instance = instance;
|
|
655
|
+
return instance;
|
|
656
|
+
}
|