@soundscript/soundscript 0.1.13 → 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,764 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _JsonLikeParser_instances, _JsonLikeParser_index, _JsonLikeParser_text, _JsonLikeParser_consumeKeyword, _JsonLikeParser_parseArray, _JsonLikeParser_parseNumber, _JsonLikeParser_parseObject, _JsonLikeParser_parseString, _JsonLikeParser_consumeDigits, _JsonLikeParser_skipWhitespace, _JsonLikeParser_isDigit, _JsonLikeParser_error;
|
|
13
|
+
import { Failure } from '@soundscript/soundscript/failures';
|
|
14
|
+
import { isErr, resultOf } from '@soundscript/soundscript/result';
|
|
15
|
+
import { F32, F64, format as formatNumeric, I8, I16, I32, I64, isNumeric, toHostNumber, U8, U16, U32, U64, } from './numerics.js';
|
|
16
|
+
const MAX_SAFE_INTEGER_BIGINT = BigInt(Number.MAX_SAFE_INTEGER);
|
|
17
|
+
const MIN_SAFE_INTEGER_BIGINT = BigInt(Number.MIN_SAFE_INTEGER);
|
|
18
|
+
export class JsonParseFailure extends Failure {
|
|
19
|
+
constructor(cause) {
|
|
20
|
+
super('Failed to parse JSON.', { cause });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class JsonStringifyFailure extends Failure {
|
|
24
|
+
constructor(cause) {
|
|
25
|
+
super('Failed to stringify JSON.', { cause });
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function parseJson(text, options = {}) {
|
|
29
|
+
return resultOf(() => {
|
|
30
|
+
const parsed = options.int64 === 'lossless' ? parseLosslessJson(text) : JSON.parse(text);
|
|
31
|
+
return options.numerics === 'tagged'
|
|
32
|
+
? decodeTaggedMachineJsonValue(parsed)
|
|
33
|
+
: parsed;
|
|
34
|
+
}, (cause) => new JsonParseFailure(cause));
|
|
35
|
+
}
|
|
36
|
+
export function stringifyJson(value, options = {}) {
|
|
37
|
+
return resultOf(() => {
|
|
38
|
+
if (options.numerics) {
|
|
39
|
+
const normalized = normalizeMachineJsonLikeValue(value, new Set(), options.numerics, 'root');
|
|
40
|
+
const encoded = stringifyJsonLikeInternal(normalized, new Set(), options.bigint ?? 'reject', 'root');
|
|
41
|
+
if (encoded === undefined) {
|
|
42
|
+
throw new TypeError('JSON stringification produced no top-level value.');
|
|
43
|
+
}
|
|
44
|
+
return encoded;
|
|
45
|
+
}
|
|
46
|
+
if (options.int64 === 'string') {
|
|
47
|
+
return stringifyJsonWithInt64Mode(value, 'string');
|
|
48
|
+
}
|
|
49
|
+
if (options.int64 === 'lossless') {
|
|
50
|
+
return stringifyJsonWithInt64Mode(value, 'lossless');
|
|
51
|
+
}
|
|
52
|
+
const encoded = JSON.stringify(value);
|
|
53
|
+
if (encoded === undefined) {
|
|
54
|
+
throw new TypeError('JSON.stringify returned undefined for a JsonValue input.');
|
|
55
|
+
}
|
|
56
|
+
return encoded;
|
|
57
|
+
}, (cause) => new JsonStringifyFailure(cause));
|
|
58
|
+
}
|
|
59
|
+
export function parseAndDecode(text, decoder) {
|
|
60
|
+
const parsed = parseJson(text);
|
|
61
|
+
return isErr(parsed) ? parsed : decoder.decode(parsed.value);
|
|
62
|
+
}
|
|
63
|
+
export function encodeAndStringify(value, encoder) {
|
|
64
|
+
const encoded = encoder.encode(value);
|
|
65
|
+
return isErr(encoded) ? encoded : stringifyJson(encoded.value);
|
|
66
|
+
}
|
|
67
|
+
export function isJsonValue(value) {
|
|
68
|
+
return isJsonValueInternal(value, new Set());
|
|
69
|
+
}
|
|
70
|
+
export function parseJsonLike(text) {
|
|
71
|
+
return resultOf(() => {
|
|
72
|
+
const parser = new JsonLikeParser(text);
|
|
73
|
+
const value = parser.parseValue();
|
|
74
|
+
parser.finish();
|
|
75
|
+
return value;
|
|
76
|
+
}, (cause) => new JsonParseFailure(cause));
|
|
77
|
+
}
|
|
78
|
+
export function stringifyJsonLike(value, options = {}) {
|
|
79
|
+
return resultOf(() => {
|
|
80
|
+
const encoded = stringifyJsonLikeInternal(value, new Set(), options.bigint ?? 'reject', 'root');
|
|
81
|
+
if (encoded === undefined) {
|
|
82
|
+
throw new TypeError('JSON-like stringification produced no top-level value.');
|
|
83
|
+
}
|
|
84
|
+
return encoded;
|
|
85
|
+
}, (cause) => new JsonStringifyFailure(cause));
|
|
86
|
+
}
|
|
87
|
+
export function decodeJson(text, decoder) {
|
|
88
|
+
const parsed = parseJsonLike(text);
|
|
89
|
+
return isErr(parsed) ? parsed : decoder.decode(parsed.value);
|
|
90
|
+
}
|
|
91
|
+
export function encodeJson(value, encoder, options = {}) {
|
|
92
|
+
const encoded = encoder.encode(value);
|
|
93
|
+
return isErr(encoded) ? encoded : stringifyJsonLike(encoded.value, options);
|
|
94
|
+
}
|
|
95
|
+
export function isJsonLikeValue(value) {
|
|
96
|
+
return isJsonLikeValueInternal(value, new Set());
|
|
97
|
+
}
|
|
98
|
+
function stringifyJsonWithInt64Mode(value, int64Mode) {
|
|
99
|
+
return stringifyJsonWithInt64ModeInternal(value, int64Mode, new Set());
|
|
100
|
+
}
|
|
101
|
+
function stringifyJsonWithInt64ModeInternal(value, int64Mode, visited) {
|
|
102
|
+
switch (typeof value) {
|
|
103
|
+
case 'string':
|
|
104
|
+
return JSON.stringify(value);
|
|
105
|
+
case 'number': {
|
|
106
|
+
const encoded = JSON.stringify(value);
|
|
107
|
+
if (encoded === undefined) {
|
|
108
|
+
throw new TypeError('JSON.stringify returned undefined for a numeric input.');
|
|
109
|
+
}
|
|
110
|
+
return encoded;
|
|
111
|
+
}
|
|
112
|
+
case 'bigint':
|
|
113
|
+
return int64Mode === 'string'
|
|
114
|
+
? JSON.stringify(value.toString())
|
|
115
|
+
: value.toString();
|
|
116
|
+
case 'boolean':
|
|
117
|
+
return value ? 'true' : 'false';
|
|
118
|
+
case 'object':
|
|
119
|
+
if (value === null) {
|
|
120
|
+
return 'null';
|
|
121
|
+
}
|
|
122
|
+
if (visited.has(value)) {
|
|
123
|
+
throw new TypeError('Could not stringify cyclic JSON value.');
|
|
124
|
+
}
|
|
125
|
+
visited.add(value);
|
|
126
|
+
try {
|
|
127
|
+
if (Array.isArray(value)) {
|
|
128
|
+
return `[${value.map((entry) => stringifyJsonWithInt64ModeInternal(entry, int64Mode, visited)).join(',')}]`;
|
|
129
|
+
}
|
|
130
|
+
const fields = Object.keys(value).map((key) => `${JSON.stringify(key)}:${stringifyJsonWithInt64ModeInternal(value[key], int64Mode, visited)}`);
|
|
131
|
+
return `{${fields.join(',')}}`;
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
visited.delete(value);
|
|
135
|
+
}
|
|
136
|
+
default:
|
|
137
|
+
throw new TypeError(`Unsupported JSON value kind: ${typeof value}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function parseLosslessJson(text) {
|
|
141
|
+
const parser = new LosslessJsonParser(text);
|
|
142
|
+
const value = parser.parseValue();
|
|
143
|
+
parser.skipWhitespace();
|
|
144
|
+
if (!parser.isAtEnd()) {
|
|
145
|
+
parser.fail('Unexpected trailing characters.');
|
|
146
|
+
}
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
function isJsonValueInternal(value, visited) {
|
|
150
|
+
switch (typeof value) {
|
|
151
|
+
case 'string':
|
|
152
|
+
case 'number':
|
|
153
|
+
case 'boolean':
|
|
154
|
+
return true;
|
|
155
|
+
case 'object':
|
|
156
|
+
if (value === null) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (visited.has(value)) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
visited.add(value);
|
|
163
|
+
try {
|
|
164
|
+
if (Array.isArray(value)) {
|
|
165
|
+
return value.every((entry) => isJsonValueInternal(entry, visited));
|
|
166
|
+
}
|
|
167
|
+
for (const key of Object.keys(value)) {
|
|
168
|
+
if (!isJsonValueInternal(value[key], visited)) {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
visited.delete(value);
|
|
176
|
+
}
|
|
177
|
+
default:
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function isJsonLikeValueInternal(value, visited) {
|
|
182
|
+
switch (typeof value) {
|
|
183
|
+
case 'string':
|
|
184
|
+
case 'number':
|
|
185
|
+
case 'boolean':
|
|
186
|
+
case 'bigint':
|
|
187
|
+
case 'undefined':
|
|
188
|
+
return true;
|
|
189
|
+
case 'object':
|
|
190
|
+
if (value === null) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
if (visited.has(value)) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
visited.add(value);
|
|
197
|
+
try {
|
|
198
|
+
if (Array.isArray(value)) {
|
|
199
|
+
return value.every((entry) => isJsonLikeValueInternal(entry, visited));
|
|
200
|
+
}
|
|
201
|
+
for (const key of Object.keys(value)) {
|
|
202
|
+
if (!isJsonLikeValueInternal(value[key], visited)) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
visited.delete(value);
|
|
210
|
+
}
|
|
211
|
+
default:
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function normalizeMachineJsonLikeValue(value, visited, numericMode, position) {
|
|
216
|
+
if (isNumeric(value)) {
|
|
217
|
+
return normalizeMachineNumericJsonValue(value, numericMode);
|
|
218
|
+
}
|
|
219
|
+
switch (typeof value) {
|
|
220
|
+
case 'string':
|
|
221
|
+
case 'number':
|
|
222
|
+
case 'boolean':
|
|
223
|
+
case 'bigint':
|
|
224
|
+
return value;
|
|
225
|
+
case 'undefined':
|
|
226
|
+
return position === 'array' ? null : undefined;
|
|
227
|
+
case 'object':
|
|
228
|
+
if (value === null) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
if (visited.has(value)) {
|
|
232
|
+
throw new TypeError('Converting circular structure to machine JSON text.');
|
|
233
|
+
}
|
|
234
|
+
visited.add(value);
|
|
235
|
+
try {
|
|
236
|
+
if (Array.isArray(value)) {
|
|
237
|
+
return value.map((entry) => normalizeMachineJsonLikeValue(entry, visited, numericMode, 'array') ?? null);
|
|
238
|
+
}
|
|
239
|
+
const result = {};
|
|
240
|
+
for (const key of Object.keys(value)) {
|
|
241
|
+
const normalized = normalizeMachineJsonLikeValue(value[key], visited, numericMode, 'object');
|
|
242
|
+
if (normalized !== undefined) {
|
|
243
|
+
result[key] = normalized;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
visited.delete(value);
|
|
250
|
+
}
|
|
251
|
+
default:
|
|
252
|
+
throw new TypeError(`Unsupported machine JSON value kind: ${typeof value}`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function normalizeMachineNumericJsonValue(value, numericMode) {
|
|
256
|
+
switch (numericMode) {
|
|
257
|
+
case 'tagged':
|
|
258
|
+
return value.toJSON();
|
|
259
|
+
case 'decimal-string':
|
|
260
|
+
return formatNumeric(value);
|
|
261
|
+
case 'json-number':
|
|
262
|
+
switch (value.__soundscript_numeric_kind) {
|
|
263
|
+
case 'i64':
|
|
264
|
+
case 'u64':
|
|
265
|
+
throw new TypeError('json-number machine JSON mode does not support bigint-backed machine numerics.');
|
|
266
|
+
default:
|
|
267
|
+
return toHostNumber(value);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function decodeTaggedMachineJsonValue(value) {
|
|
272
|
+
if (Array.isArray(value)) {
|
|
273
|
+
return value.map((entry) => decodeTaggedMachineJsonValue(entry));
|
|
274
|
+
}
|
|
275
|
+
if (value && typeof value === 'object') {
|
|
276
|
+
const taggedNumeric = decodeTaggedMachineNumeric(value);
|
|
277
|
+
if (taggedNumeric) {
|
|
278
|
+
return taggedNumeric;
|
|
279
|
+
}
|
|
280
|
+
const result = {};
|
|
281
|
+
for (const key of Object.keys(value)) {
|
|
282
|
+
result[key] = decodeTaggedMachineJsonValue(value[key]);
|
|
283
|
+
}
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
return value;
|
|
287
|
+
}
|
|
288
|
+
function decodeTaggedMachineNumeric(value) {
|
|
289
|
+
const numericKind = value['$numeric'];
|
|
290
|
+
const numericValue = value['value'];
|
|
291
|
+
const keys = Object.keys(value);
|
|
292
|
+
if (typeof numericKind !== 'string' ||
|
|
293
|
+
typeof numericValue !== 'string' ||
|
|
294
|
+
keys.length !== 2 ||
|
|
295
|
+
!keys.includes('$numeric') ||
|
|
296
|
+
!keys.includes('value')) {
|
|
297
|
+
return undefined;
|
|
298
|
+
}
|
|
299
|
+
switch (numericKind) {
|
|
300
|
+
case 'f64':
|
|
301
|
+
return F64.parse(numericValue);
|
|
302
|
+
case 'f32':
|
|
303
|
+
return F32.parse(numericValue);
|
|
304
|
+
case 'i8':
|
|
305
|
+
return I8.parse(numericValue);
|
|
306
|
+
case 'i16':
|
|
307
|
+
return I16.parse(numericValue);
|
|
308
|
+
case 'i32':
|
|
309
|
+
return I32.parse(numericValue);
|
|
310
|
+
case 'i64':
|
|
311
|
+
return I64.parse(numericValue);
|
|
312
|
+
case 'u8':
|
|
313
|
+
return U8.parse(numericValue);
|
|
314
|
+
case 'u16':
|
|
315
|
+
return U16.parse(numericValue);
|
|
316
|
+
case 'u32':
|
|
317
|
+
return U32.parse(numericValue);
|
|
318
|
+
case 'u64':
|
|
319
|
+
return U64.parse(numericValue);
|
|
320
|
+
default:
|
|
321
|
+
return undefined;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function stringifyJsonLikeInternal(value, visited, bigintMode, position) {
|
|
325
|
+
switch (typeof value) {
|
|
326
|
+
case 'string':
|
|
327
|
+
return JSON.stringify(value);
|
|
328
|
+
case 'number':
|
|
329
|
+
return Number.isFinite(value) ? JSON.stringify(value) : 'null';
|
|
330
|
+
case 'boolean':
|
|
331
|
+
return value ? 'true' : 'false';
|
|
332
|
+
case 'bigint':
|
|
333
|
+
switch (bigintMode) {
|
|
334
|
+
case 'string':
|
|
335
|
+
return JSON.stringify(value.toString());
|
|
336
|
+
case 'number':
|
|
337
|
+
return value.toString();
|
|
338
|
+
case 'reject':
|
|
339
|
+
throw new TypeError('Encountered bigint while stringifying JSON-like data.');
|
|
340
|
+
}
|
|
341
|
+
case 'undefined':
|
|
342
|
+
return position === 'array' ? 'null' : undefined;
|
|
343
|
+
case 'object':
|
|
344
|
+
if (value === null) {
|
|
345
|
+
return 'null';
|
|
346
|
+
}
|
|
347
|
+
if (visited.has(value)) {
|
|
348
|
+
throw new TypeError('Converting circular structure to JSON-like text.');
|
|
349
|
+
}
|
|
350
|
+
visited.add(value);
|
|
351
|
+
try {
|
|
352
|
+
if (Array.isArray(value)) {
|
|
353
|
+
return `[${value.map((entry) => stringifyJsonLikeInternal(entry, visited, bigintMode, 'array') ?? 'null').join(',')}]`;
|
|
354
|
+
}
|
|
355
|
+
const encodedProperties = [];
|
|
356
|
+
for (const key of Object.keys(value)) {
|
|
357
|
+
const encodedValue = stringifyJsonLikeInternal(value[key], visited, bigintMode, 'object');
|
|
358
|
+
if (encodedValue === undefined) {
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
encodedProperties.push(`${JSON.stringify(key)}:${encodedValue}`);
|
|
362
|
+
}
|
|
363
|
+
return `{${encodedProperties.join(',')}}`;
|
|
364
|
+
}
|
|
365
|
+
finally {
|
|
366
|
+
visited.delete(value);
|
|
367
|
+
}
|
|
368
|
+
default:
|
|
369
|
+
throw new TypeError('Encountered an unsupported JSON-like value.');
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
class LosslessJsonParser {
|
|
373
|
+
constructor(text) {
|
|
374
|
+
this.index = 0;
|
|
375
|
+
this.text = text;
|
|
376
|
+
}
|
|
377
|
+
fail(message) {
|
|
378
|
+
throw new SyntaxError(`${message} At character ${this.index}.`);
|
|
379
|
+
}
|
|
380
|
+
isAtEnd() {
|
|
381
|
+
return this.index >= this.text.length;
|
|
382
|
+
}
|
|
383
|
+
skipWhitespace() {
|
|
384
|
+
while (!this.isAtEnd() && /\s/u.test(this.text[this.index])) {
|
|
385
|
+
this.index += 1;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
parseValue() {
|
|
389
|
+
this.skipWhitespace();
|
|
390
|
+
if (this.isAtEnd()) {
|
|
391
|
+
this.fail('Unexpected end of JSON input.');
|
|
392
|
+
}
|
|
393
|
+
const current = this.text[this.index];
|
|
394
|
+
switch (current) {
|
|
395
|
+
case '"':
|
|
396
|
+
return this.parseString();
|
|
397
|
+
case '{':
|
|
398
|
+
return this.parseObject();
|
|
399
|
+
case '[':
|
|
400
|
+
return this.parseArray();
|
|
401
|
+
case 't':
|
|
402
|
+
this.consumeKeyword('true');
|
|
403
|
+
return true;
|
|
404
|
+
case 'f':
|
|
405
|
+
this.consumeKeyword('false');
|
|
406
|
+
return false;
|
|
407
|
+
case 'n':
|
|
408
|
+
this.consumeKeyword('null');
|
|
409
|
+
return null;
|
|
410
|
+
default:
|
|
411
|
+
if (current === '-' || isAsciiDigit(current)) {
|
|
412
|
+
return this.parseNumber();
|
|
413
|
+
}
|
|
414
|
+
this.fail(`Unexpected token ${JSON.stringify(current)}.`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
consumeKeyword(keyword) {
|
|
418
|
+
if (!this.text.startsWith(keyword, this.index)) {
|
|
419
|
+
this.fail(`Expected ${keyword}.`);
|
|
420
|
+
}
|
|
421
|
+
this.index += keyword.length;
|
|
422
|
+
}
|
|
423
|
+
parseString() {
|
|
424
|
+
let result = '';
|
|
425
|
+
this.index += 1;
|
|
426
|
+
while (!this.isAtEnd()) {
|
|
427
|
+
const current = this.text[this.index];
|
|
428
|
+
if (current === '"') {
|
|
429
|
+
this.index += 1;
|
|
430
|
+
return result;
|
|
431
|
+
}
|
|
432
|
+
if (current === '\\') {
|
|
433
|
+
this.index += 1;
|
|
434
|
+
if (this.isAtEnd()) {
|
|
435
|
+
this.fail('Unexpected end of escape sequence.');
|
|
436
|
+
}
|
|
437
|
+
result += this.parseEscapeSequence();
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
result += current;
|
|
441
|
+
this.index += 1;
|
|
442
|
+
}
|
|
443
|
+
this.fail('Unterminated string literal.');
|
|
444
|
+
}
|
|
445
|
+
parseEscapeSequence() {
|
|
446
|
+
const current = this.text[this.index];
|
|
447
|
+
this.index += 1;
|
|
448
|
+
switch (current) {
|
|
449
|
+
case '"':
|
|
450
|
+
case '\\':
|
|
451
|
+
case '/':
|
|
452
|
+
return current;
|
|
453
|
+
case 'b':
|
|
454
|
+
return '\b';
|
|
455
|
+
case 'f':
|
|
456
|
+
return '\f';
|
|
457
|
+
case 'n':
|
|
458
|
+
return '\n';
|
|
459
|
+
case 'r':
|
|
460
|
+
return '\r';
|
|
461
|
+
case 't':
|
|
462
|
+
return '\t';
|
|
463
|
+
case 'u': {
|
|
464
|
+
const hex = this.text.slice(this.index, this.index + 4);
|
|
465
|
+
if (!/^[0-9A-Fa-f]{4}$/u.test(hex)) {
|
|
466
|
+
this.fail('Invalid unicode escape.');
|
|
467
|
+
}
|
|
468
|
+
this.index += 4;
|
|
469
|
+
return String.fromCharCode(Number.parseInt(hex, 16));
|
|
470
|
+
}
|
|
471
|
+
default:
|
|
472
|
+
this.fail(`Invalid escape sequence \\${current}.`);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
parseArray() {
|
|
476
|
+
const result = [];
|
|
477
|
+
this.index += 1;
|
|
478
|
+
this.skipWhitespace();
|
|
479
|
+
if (this.text[this.index] === ']') {
|
|
480
|
+
this.index += 1;
|
|
481
|
+
return result;
|
|
482
|
+
}
|
|
483
|
+
while (true) {
|
|
484
|
+
result.push(this.parseValue());
|
|
485
|
+
this.skipWhitespace();
|
|
486
|
+
const current = this.text[this.index];
|
|
487
|
+
if (current === ']') {
|
|
488
|
+
this.index += 1;
|
|
489
|
+
return result;
|
|
490
|
+
}
|
|
491
|
+
if (current !== ',') {
|
|
492
|
+
this.fail('Expected , or ] in array literal.');
|
|
493
|
+
}
|
|
494
|
+
this.index += 1;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
parseObject() {
|
|
498
|
+
const result = {};
|
|
499
|
+
this.index += 1;
|
|
500
|
+
this.skipWhitespace();
|
|
501
|
+
if (this.text[this.index] === '}') {
|
|
502
|
+
this.index += 1;
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
while (true) {
|
|
506
|
+
this.skipWhitespace();
|
|
507
|
+
if (this.text[this.index] !== '"') {
|
|
508
|
+
this.fail('Expected string key in object literal.');
|
|
509
|
+
}
|
|
510
|
+
const key = this.parseString();
|
|
511
|
+
this.skipWhitespace();
|
|
512
|
+
if (this.text[this.index] !== ':') {
|
|
513
|
+
this.fail('Expected : after object key.');
|
|
514
|
+
}
|
|
515
|
+
this.index += 1;
|
|
516
|
+
result[key] = this.parseValue();
|
|
517
|
+
this.skipWhitespace();
|
|
518
|
+
const current = this.text[this.index];
|
|
519
|
+
if (current === '}') {
|
|
520
|
+
this.index += 1;
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
523
|
+
if (current !== ',') {
|
|
524
|
+
this.fail('Expected , or } in object literal.');
|
|
525
|
+
}
|
|
526
|
+
this.index += 1;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
parseNumber() {
|
|
530
|
+
const start = this.index;
|
|
531
|
+
if (this.text[this.index] === '-') {
|
|
532
|
+
this.index += 1;
|
|
533
|
+
}
|
|
534
|
+
if (this.text[this.index] === '0') {
|
|
535
|
+
this.index += 1;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
this.consumeDigits();
|
|
539
|
+
}
|
|
540
|
+
let isInteger = true;
|
|
541
|
+
if (this.text[this.index] === '.') {
|
|
542
|
+
isInteger = false;
|
|
543
|
+
this.index += 1;
|
|
544
|
+
this.consumeDigits();
|
|
545
|
+
}
|
|
546
|
+
const exponentMarker = this.text[this.index];
|
|
547
|
+
if (exponentMarker === 'e' || exponentMarker === 'E') {
|
|
548
|
+
isInteger = false;
|
|
549
|
+
this.index += 1;
|
|
550
|
+
const sign = this.text[this.index];
|
|
551
|
+
if (sign === '+' || sign === '-') {
|
|
552
|
+
this.index += 1;
|
|
553
|
+
}
|
|
554
|
+
this.consumeDigits();
|
|
555
|
+
}
|
|
556
|
+
const token = this.text.slice(start, this.index);
|
|
557
|
+
if (!isInteger) {
|
|
558
|
+
return Number(token);
|
|
559
|
+
}
|
|
560
|
+
if (token === '-0') {
|
|
561
|
+
return -0;
|
|
562
|
+
}
|
|
563
|
+
const bigintValue = BigInt(token);
|
|
564
|
+
return bigintValue <= MAX_SAFE_INTEGER_BIGINT && bigintValue >= MIN_SAFE_INTEGER_BIGINT
|
|
565
|
+
? Number(token)
|
|
566
|
+
: bigintValue;
|
|
567
|
+
}
|
|
568
|
+
consumeDigits() {
|
|
569
|
+
const start = this.index;
|
|
570
|
+
while (!this.isAtEnd() && isAsciiDigit(this.text[this.index])) {
|
|
571
|
+
this.index += 1;
|
|
572
|
+
}
|
|
573
|
+
if (start === this.index) {
|
|
574
|
+
this.fail('Expected digits.');
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
class JsonLikeParser {
|
|
579
|
+
constructor(text) {
|
|
580
|
+
_JsonLikeParser_instances.add(this);
|
|
581
|
+
_JsonLikeParser_index.set(this, 0);
|
|
582
|
+
_JsonLikeParser_text.set(this, void 0);
|
|
583
|
+
__classPrivateFieldSet(this, _JsonLikeParser_text, text, "f");
|
|
584
|
+
}
|
|
585
|
+
finish() {
|
|
586
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
587
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_index, "f") !== __classPrivateFieldGet(this, _JsonLikeParser_text, "f").length) {
|
|
588
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Unexpected trailing JSON input');
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
parseValue() {
|
|
592
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
593
|
+
const current = __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")];
|
|
594
|
+
switch (current) {
|
|
595
|
+
case '{':
|
|
596
|
+
return __classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_parseObject).call(this);
|
|
597
|
+
case '[':
|
|
598
|
+
return __classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_parseArray).call(this);
|
|
599
|
+
case '"':
|
|
600
|
+
return __classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_parseString).call(this);
|
|
601
|
+
case 't':
|
|
602
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_consumeKeyword).call(this, 'true');
|
|
603
|
+
return true;
|
|
604
|
+
case 'f':
|
|
605
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_consumeKeyword).call(this, 'false');
|
|
606
|
+
return false;
|
|
607
|
+
case 'n':
|
|
608
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_consumeKeyword).call(this, 'null');
|
|
609
|
+
return null;
|
|
610
|
+
default:
|
|
611
|
+
if (current === '-' || __classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_isDigit).call(this, current)) {
|
|
612
|
+
return __classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_parseNumber).call(this);
|
|
613
|
+
}
|
|
614
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Unexpected token in JSON input');
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
_JsonLikeParser_index = new WeakMap(), _JsonLikeParser_text = new WeakMap(), _JsonLikeParser_instances = new WeakSet(), _JsonLikeParser_consumeKeyword = function _JsonLikeParser_consumeKeyword(keyword) {
|
|
619
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f").slice(__classPrivateFieldGet(this, _JsonLikeParser_index, "f"), __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + keyword.length) !== keyword) {
|
|
620
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, `Expected ${keyword}`);
|
|
621
|
+
}
|
|
622
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + keyword.length, "f");
|
|
623
|
+
}, _JsonLikeParser_parseArray = function _JsonLikeParser_parseArray() {
|
|
624
|
+
const values = [];
|
|
625
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
626
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
627
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] === ']') {
|
|
628
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
629
|
+
return values;
|
|
630
|
+
}
|
|
631
|
+
while (true) {
|
|
632
|
+
values.push(this.parseValue());
|
|
633
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
634
|
+
const current = __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")];
|
|
635
|
+
if (current === ']') {
|
|
636
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
637
|
+
return values;
|
|
638
|
+
}
|
|
639
|
+
if (current !== ',') {
|
|
640
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Expected , or ] in JSON array');
|
|
641
|
+
}
|
|
642
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
643
|
+
}
|
|
644
|
+
}, _JsonLikeParser_parseNumber = function _JsonLikeParser_parseNumber() {
|
|
645
|
+
const start = __classPrivateFieldGet(this, _JsonLikeParser_index, "f");
|
|
646
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] === '-') {
|
|
647
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
648
|
+
}
|
|
649
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] === '0') {
|
|
650
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
651
|
+
}
|
|
652
|
+
else {
|
|
653
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_consumeDigits).call(this);
|
|
654
|
+
}
|
|
655
|
+
let isInteger = true;
|
|
656
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] === '.') {
|
|
657
|
+
isInteger = false;
|
|
658
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
659
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_consumeDigits).call(this);
|
|
660
|
+
}
|
|
661
|
+
const exponent = __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")];
|
|
662
|
+
if (exponent === 'e' || exponent === 'E') {
|
|
663
|
+
isInteger = false;
|
|
664
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
665
|
+
const sign = __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")];
|
|
666
|
+
if (sign === '+' || sign === '-') {
|
|
667
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
668
|
+
}
|
|
669
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_consumeDigits).call(this);
|
|
670
|
+
}
|
|
671
|
+
const token = __classPrivateFieldGet(this, _JsonLikeParser_text, "f").slice(start, __classPrivateFieldGet(this, _JsonLikeParser_index, "f"));
|
|
672
|
+
if (!isInteger) {
|
|
673
|
+
return Number(token);
|
|
674
|
+
}
|
|
675
|
+
const bigintValue = BigInt(token);
|
|
676
|
+
const numberValue = Number(token);
|
|
677
|
+
return Number.isSafeInteger(numberValue) && BigInt(numberValue) === bigintValue
|
|
678
|
+
? numberValue
|
|
679
|
+
: bigintValue;
|
|
680
|
+
}, _JsonLikeParser_parseObject = function _JsonLikeParser_parseObject() {
|
|
681
|
+
const object = {};
|
|
682
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
683
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
684
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] === '}') {
|
|
685
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
686
|
+
return object;
|
|
687
|
+
}
|
|
688
|
+
while (true) {
|
|
689
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
690
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] !== '"') {
|
|
691
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Expected string key in JSON object');
|
|
692
|
+
}
|
|
693
|
+
const key = __classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_parseString).call(this);
|
|
694
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
695
|
+
if (__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] !== ':') {
|
|
696
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Expected : in JSON object');
|
|
697
|
+
}
|
|
698
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
699
|
+
object[key] = this.parseValue();
|
|
700
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_skipWhitespace).call(this);
|
|
701
|
+
const current = __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")];
|
|
702
|
+
if (current === '}') {
|
|
703
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
704
|
+
return object;
|
|
705
|
+
}
|
|
706
|
+
if (current !== ',') {
|
|
707
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Expected , or } in JSON object');
|
|
708
|
+
}
|
|
709
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
710
|
+
}
|
|
711
|
+
}, _JsonLikeParser_parseString = function _JsonLikeParser_parseString() {
|
|
712
|
+
const start = __classPrivateFieldGet(this, _JsonLikeParser_index, "f");
|
|
713
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
714
|
+
while (__classPrivateFieldGet(this, _JsonLikeParser_index, "f") < __classPrivateFieldGet(this, _JsonLikeParser_text, "f").length) {
|
|
715
|
+
const current = __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")];
|
|
716
|
+
if (current === '"') {
|
|
717
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
718
|
+
const parsed = JSON.parse(__classPrivateFieldGet(this, _JsonLikeParser_text, "f").slice(start, __classPrivateFieldGet(this, _JsonLikeParser_index, "f")));
|
|
719
|
+
if (typeof parsed !== 'string') {
|
|
720
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Expected string literal.');
|
|
721
|
+
}
|
|
722
|
+
return parsed;
|
|
723
|
+
}
|
|
724
|
+
if (current === '\\') {
|
|
725
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
726
|
+
const escaped = __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")];
|
|
727
|
+
if (escaped === undefined) {
|
|
728
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Unterminated string escape');
|
|
729
|
+
}
|
|
730
|
+
if (escaped === 'u') {
|
|
731
|
+
for (let index = 0; index < 4; index += 1) {
|
|
732
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
733
|
+
if (!/[0-9A-Fa-f]/u.test(__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] ?? '')) {
|
|
734
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Invalid unicode escape');
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
else if (current !== undefined && current <= '\u001F') {
|
|
740
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Invalid control character in string literal');
|
|
741
|
+
}
|
|
742
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
743
|
+
}
|
|
744
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Unterminated string literal');
|
|
745
|
+
}, _JsonLikeParser_consumeDigits = function _JsonLikeParser_consumeDigits() {
|
|
746
|
+
const start = __classPrivateFieldGet(this, _JsonLikeParser_index, "f");
|
|
747
|
+
while (__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_isDigit).call(this, __classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")])) {
|
|
748
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
749
|
+
}
|
|
750
|
+
if (start === __classPrivateFieldGet(this, _JsonLikeParser_index, "f")) {
|
|
751
|
+
__classPrivateFieldGet(this, _JsonLikeParser_instances, "m", _JsonLikeParser_error).call(this, 'Expected digit in JSON number');
|
|
752
|
+
}
|
|
753
|
+
}, _JsonLikeParser_skipWhitespace = function _JsonLikeParser_skipWhitespace() {
|
|
754
|
+
while (/\s/u.test(__classPrivateFieldGet(this, _JsonLikeParser_text, "f")[__classPrivateFieldGet(this, _JsonLikeParser_index, "f")] ?? '')) {
|
|
755
|
+
__classPrivateFieldSet(this, _JsonLikeParser_index, __classPrivateFieldGet(this, _JsonLikeParser_index, "f") + 1, "f");
|
|
756
|
+
}
|
|
757
|
+
}, _JsonLikeParser_isDigit = function _JsonLikeParser_isDigit(value) {
|
|
758
|
+
return value !== undefined && value >= '0' && value <= '9';
|
|
759
|
+
}, _JsonLikeParser_error = function _JsonLikeParser_error(message) {
|
|
760
|
+
throw new SyntaxError(`${message} at position ${__classPrivateFieldGet(this, _JsonLikeParser_index, "f")}.`);
|
|
761
|
+
};
|
|
762
|
+
function isAsciiDigit(text) {
|
|
763
|
+
return text >= '0' && text <= '9';
|
|
764
|
+
}
|