From 4c7d06fc72be2ce1af1489884ed810116e09117b Mon Sep 17 00:00:00 2001 From: LongYinan Date: Wed, 10 Apr 2024 10:08:57 +0900 Subject: [PATCH] feat(cli): support wasm32-wasipxx targets (#2030) * chore(examples): update wasi binding template * wasm32-wasip1 --- cli/src/api/new.ts | 15 ++ cli/src/api/templates/ci-template.ts | 20 +- cli/src/api/templates/ci.yml.ts | 10 +- cli/src/utils/target.ts | 5 +- examples/napi/example.wasi-browser.js | 369 ++++++++++++++------------ examples/napi/example.wasi.cjs | 363 +++++++++++++------------ examples/napi/wasi-worker.mjs | 16 +- 7 files changed, 434 insertions(+), 364 deletions(-) diff --git a/cli/src/api/new.ts b/cli/src/api/new.ts index 78abc61d..cc7267ae 100644 --- a/cli/src/api/new.ts +++ b/cli/src/api/new.ts @@ -1,3 +1,4 @@ +import { execSync } from 'node:child_process' import path from 'node:path' import { @@ -61,6 +62,20 @@ function processOptions(options: RawNewOptions) { throw new Error('At least one target must be enabled') } } + if ( + options.targets.some((target) => target === 'wasm32-wasi-preview1-threads') + ) { + const out = execSync(`rustup target list`, { + encoding: 'utf8', + }) + if (out.includes('wasm32-wasip1-threads')) { + options.targets.map((target) => + target === 'wasm32-wasi-preview1-threads' + ? 'wasm32-wasip1-threads' + : target, + ) + } + } return applyDefaultNewOptions(options) as NewOptions } diff --git a/cli/src/api/templates/ci-template.ts b/cli/src/api/templates/ci-template.ts index f9750498..f8243ebb 100644 --- a/cli/src/api/templates/ci-template.ts +++ b/cli/src/api/templates/ci-template.ts @@ -1,6 +1,14 @@ import type { SupportedPackageManager } from '../../utils/config.js' -export const YAML = (packageManager: SupportedPackageManager) => ` +export type WasiTargetName = + | 'wasm32-wasi-preview1-threads' + | 'wasm32-wasip1-threads' + | 'wasm32-wasip2' + +export const YAML = ( + packageManager: SupportedPackageManager, + wasiTargetName?: WasiTargetName, +) => ` name: CI env: @@ -94,6 +102,8 @@ jobs: - host: ubuntu-latest target: 'wasm32-wasi-preview1-threads' build: ${packageManager} build --platform --target wasm32-wasi-preview1-threads + target: '${wasiTargetName}' + build: ${packageManager} build --platform --target ${wasiTargetName} name: stable - \${{ matrix.settings.target }} - node@20 runs-on: \${{ matrix.settings.host }} @@ -156,7 +166,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 - if: matrix.settings.target != 'wasm32-wasi-preview1-threads' + if: matrix.settings.target != '${wasiTargetName}' with: name: bindings-\${{ matrix.settings.target }} path: "*.node" @@ -164,7 +174,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v4 - if: matrix.settings.target == 'wasm32-wasi-preview1-threads' + if: matrix.settings.target == '${wasiTargetName}' with: name: bindings-\${{ matrix.settings.target }} path: "*.wasm" @@ -177,7 +187,7 @@ jobs: - uses: actions/checkout@v4 - name: Build id: build - uses: cross-platform-actions/action@v0.21.1 + uses: cross-platform-actions/action@v0.23.0 timeout-minutes: 30 env: DEBUG: 'napi:*' @@ -511,7 +521,7 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v4 with: - name: bindings-wasm32-wasi-preview1-threads + name: bindings-${wasiTargetName} path: . - name: List packages run: ls -R . diff --git a/cli/src/api/templates/ci.yml.ts b/cli/src/api/templates/ci.yml.ts index 7346f11d..68fa9606 100644 --- a/cli/src/api/templates/ci.yml.ts +++ b/cli/src/api/templates/ci.yml.ts @@ -7,7 +7,7 @@ import { parseTriple, } from '../../utils/index.js' -import { YAML } from './ci-template.js' +import { type WasiTargetName, YAML } from './ci-template.js' const BUILD_FREEBSD = 'build-freebsd' const TEST_MACOS_WINDOWS = 'test-macOS-windows-binding' @@ -22,6 +22,7 @@ const UNIVERSAL_MACOS = 'universal-macOS' export const createGithubActionsCIYml = ( targets: string[], packageManager: SupportedPackageManager, + wasiTargetName?: WasiTargetName, ) => { const allTargets = new Set( targets.flatMap((t) => { @@ -36,7 +37,7 @@ export const createGithubActionsCIYml = ( }), ) - const fullTemplate = load(YAML(packageManager)) as any + const fullTemplate = load(YAML(packageManager, wasiTargetName)) as any const requiredSteps = [] const enableWindowsX86 = allTargets.has('x86_64-pc-windows-msvc') @@ -48,7 +49,10 @@ export const createGithubActionsCIYml = ( const enableLinuxArm7 = allTargets.has('armv7-unknown-linux-gnueabihf') const enableFreeBSD = allTargets.has('x86_64-unknown-freebsd') const enableMacOSUni = allTargets.has('universal-apple-darwin') - const enableWasi = allTargets.has('wasm32-wasi-preview1-threads') + const enableWasi = + allTargets.has('wasm32-wasi-preview1-threads') || + allTargets.has('wasm32-wasip1-threads') || + allTargets.has('wasm32-wasip2') fullTemplate.jobs.build.strategy.matrix.settings = fullTemplate.jobs.build.strategy.matrix.settings.filter( ({ target }: { target: string }) => allTargets.has(target), diff --git a/cli/src/utils/target.ts b/cli/src/utils/target.ts index fb58cba3..e900b721 100644 --- a/cli/src/utils/target.ts +++ b/cli/src/utils/target.ts @@ -109,7 +109,10 @@ export interface Target { * - `abi` = The ABI, for example `gnu`, `android`, `eabi`, etc. */ export function parseTriple(rawTriple: string): Target { - if (rawTriple === 'wasm32-wasi-preview1-threads') { + if ( + rawTriple === 'wasm32-wasi-preview1-threads' || + rawTriple.startsWith('wasm32-wasip') + ) { return { triple: rawTriple, platformArchABI: 'wasm32-wasi', diff --git a/examples/napi/example.wasi-browser.js b/examples/napi/example.wasi-browser.js index 6dcf1bef..5fd277c0 100644 --- a/examples/napi/example.wasi-browser.js +++ b/examples/napi/example.wasi-browser.js @@ -168,220 +168,230 @@ function __napi_rs_initialize_modules(__napiInstance) { __napiInstance.exports['__napi_register__either_from_objects_133']?.() __napiInstance.exports['__napi_register__either_bool_or_function_134']?.() __napiInstance.exports['__napi_register__promise_in_either_135']?.() - __napiInstance.exports['__napi_register__Kind_136']?.() - __napiInstance.exports['__napi_register__Empty_137']?.() - __napiInstance.exports['__napi_register__Status_138']?.() - __napiInstance.exports['__napi_register__CustomNumEnum_139']?.() - __napiInstance.exports['__napi_register__enum_to_i32_140']?.() - __napiInstance.exports['__napi_register__SkippedEnums_141']?.() - __napiInstance.exports['__napi_register__run_script_142']?.() - __napiInstance.exports['__napi_register__get_module_file_name_143']?.() - __napiInstance.exports['__napi_register__throw_syntax_error_144']?.() - __napiInstance.exports['__napi_register__throw_error_145']?.() - __napiInstance.exports['__napi_register__panic_146']?.() - __napiInstance.exports['__napi_register__receive_string_147']?.() - __napiInstance.exports['__napi_register__custom_status_code_148']?.() - __napiInstance.exports['__napi_register__throw_async_error_149']?.() - __napiInstance.exports['__napi_register__create_external_150']?.() - __napiInstance.exports['__napi_register__create_external_string_151']?.() - __napiInstance.exports['__napi_register__get_external_152']?.() - __napiInstance.exports['__napi_register__mutate_external_153']?.() - __napiInstance.exports['__napi_register__validate_array_154']?.() - __napiInstance.exports['__napi_register__validate_buffer_155']?.() - __napiInstance.exports['__napi_register__validate_typed_array_156']?.() - __napiInstance.exports['__napi_register__validate_typed_array_slice_157']?.() + __napiInstance.exports['__napi_register__either_bool_or_tuple_136']?.() + __napiInstance.exports['__napi_register__Kind_137']?.() + __napiInstance.exports['__napi_register__Empty_138']?.() + __napiInstance.exports['__napi_register__Status_139']?.() + __napiInstance.exports['__napi_register__StringEnum_140']?.() + __napiInstance.exports['__napi_register__CustomNumEnum_141']?.() + __napiInstance.exports['__napi_register__enum_to_i32_142']?.() + __napiInstance.exports['__napi_register__SkippedEnums_143']?.() + __napiInstance.exports['__napi_register__run_script_144']?.() + __napiInstance.exports['__napi_register__get_module_file_name_145']?.() + __napiInstance.exports['__napi_register__throw_syntax_error_146']?.() + __napiInstance.exports['__napi_register__throw_error_147']?.() + __napiInstance.exports['__napi_register__panic_148']?.() + __napiInstance.exports['__napi_register__receive_string_149']?.() + __napiInstance.exports['__napi_register__custom_status_code_150']?.() + __napiInstance.exports['__napi_register__throw_async_error_151']?.() + __napiInstance.exports['__napi_register__create_external_152']?.() + __napiInstance.exports['__napi_register__create_external_string_153']?.() + __napiInstance.exports['__napi_register__get_external_154']?.() + __napiInstance.exports['__napi_register__mutate_external_155']?.() + __napiInstance.exports['__napi_register__validate_array_156']?.() + __napiInstance.exports['__napi_register__validate_buffer_157']?.() + __napiInstance.exports['__napi_register__validate_typed_array_158']?.() + __napiInstance.exports['__napi_register__validate_typed_array_slice_159']?.() __napiInstance.exports[ - '__napi_register__validate_uint8_clamped_slice_158' + '__napi_register__validate_uint8_clamped_slice_160' ]?.() - __napiInstance.exports['__napi_register__validate_buffer_slice_159']?.() - __napiInstance.exports['__napi_register__validate_bigint_160']?.() - __napiInstance.exports['__napi_register__validate_boolean_161']?.() - __napiInstance.exports['__napi_register__validate_date_162']?.() - __napiInstance.exports['__napi_register__validate_date_time_163']?.() - __napiInstance.exports['__napi_register__validate_external_164']?.() - __napiInstance.exports['__napi_register__validate_function_165']?.() - __napiInstance.exports['__napi_register__validate_hash_map_166']?.() - __napiInstance.exports['__napi_register__validate_null_167']?.() - __napiInstance.exports['__napi_register__validate_undefined_168']?.() - __napiInstance.exports['__napi_register__validate_number_169']?.() - __napiInstance.exports['__napi_register__validate_promise_170']?.() - __napiInstance.exports['__napi_register__validate_string_171']?.() - __napiInstance.exports['__napi_register__validate_symbol_172']?.() - __napiInstance.exports['__napi_register__validate_optional_173']?.() - __napiInstance.exports['__napi_register__return_undefined_if_invalid_174']?.() + __napiInstance.exports['__napi_register__validate_buffer_slice_161']?.() + __napiInstance.exports['__napi_register__validate_bigint_162']?.() + __napiInstance.exports['__napi_register__validate_boolean_163']?.() + __napiInstance.exports['__napi_register__validate_date_164']?.() + __napiInstance.exports['__napi_register__validate_date_time_165']?.() + __napiInstance.exports['__napi_register__validate_external_166']?.() + __napiInstance.exports['__napi_register__validate_function_167']?.() + __napiInstance.exports['__napi_register__validate_hash_map_168']?.() + __napiInstance.exports['__napi_register__validate_null_169']?.() + __napiInstance.exports['__napi_register__validate_undefined_170']?.() + __napiInstance.exports['__napi_register__validate_number_171']?.() + __napiInstance.exports['__napi_register__validate_promise_172']?.() + __napiInstance.exports['__napi_register__validate_string_173']?.() + __napiInstance.exports['__napi_register__validate_symbol_174']?.() + __napiInstance.exports['__napi_register__validate_optional_175']?.() + __napiInstance.exports['__napi_register__return_undefined_if_invalid_176']?.() __napiInstance.exports[ - '__napi_register__return_undefined_if_invalid_promise_175' + '__napi_register__return_undefined_if_invalid_promise_177' ]?.() - __napiInstance.exports['__napi_register__ts_rename_176']?.() + __napiInstance.exports['__napi_register__ts_rename_178']?.() __napiInstance.exports[ - '__napi_register__override_individual_arg_on_function_177' + '__napi_register__override_individual_arg_on_function_179' ]?.() __napiInstance.exports[ - '__napi_register__override_individual_arg_on_function_with_cb_arg_178' + '__napi_register__override_individual_arg_on_function_with_cb_arg_180' ]?.() - __napiInstance.exports['__napi_register__call0_179']?.() - __napiInstance.exports['__napi_register__call1_180']?.() - __napiInstance.exports['__napi_register__call2_181']?.() - __napiInstance.exports['__napi_register__apply0_182']?.() - __napiInstance.exports['__napi_register__apply1_183']?.() - __napiInstance.exports['__napi_register__call_function_184']?.() - __napiInstance.exports['__napi_register__call_function_with_arg_185']?.() + __napiInstance.exports['__napi_register__call0_181']?.() + __napiInstance.exports['__napi_register__call1_182']?.() + __napiInstance.exports['__napi_register__call2_183']?.() + __napiInstance.exports['__napi_register__apply0_184']?.() + __napiInstance.exports['__napi_register__apply1_185']?.() + __napiInstance.exports['__napi_register__call_function_186']?.() + __napiInstance.exports['__napi_register__call_function_with_arg_187']?.() __napiInstance.exports[ - '__napi_register__create_reference_on_function_186' + '__napi_register__create_reference_on_function_188' ]?.() __napiInstance.exports[ - '__napi_register__call_function_with_arg_and_ctx_187' + '__napi_register__call_function_with_arg_and_ctx_189' ]?.() - __napiInstance.exports['__napi_register__reference_as_callback_188']?.() - __napiInstance.exports['__napi_register__Fib_struct_189']?.() - __napiInstance.exports['__napi_register__Fib_impl_190']?.() - __napiInstance.exports['__napi_register__Fib_impl_192']?.() - __napiInstance.exports['__napi_register__Fib2_struct_193']?.() - __napiInstance.exports['__napi_register__Fib2_impl_194']?.() - __napiInstance.exports['__napi_register__Fib2_impl_196']?.() - __napiInstance.exports['__napi_register__Fib3_struct_197']?.() - __napiInstance.exports['__napi_register__Fib3_impl_198']?.() - __napiInstance.exports['__napi_register__ALIGNMENT_199']?.() - __napiInstance.exports['__napi_register__xxh64_200']?.() - __napiInstance.exports['__napi_register__xxh128_201']?.() - __napiInstance.exports['__napi_register__Xxh3_struct_202']?.() - __napiInstance.exports['__napi_register__Xxh3_impl_206']?.() - __napiInstance.exports['__napi_register__xxh2_plus_207']?.() - __napiInstance.exports['__napi_register__xxh3_xxh64_alias_208']?.() - __napiInstance.exports['__napi_register__xxh64_alias_209']?.() - __napiInstance.exports['__napi_register__get_mapping_210']?.() - __napiInstance.exports['__napi_register__sum_mapping_211']?.() - __napiInstance.exports['__napi_register__get_btree_mapping_212']?.() - __napiInstance.exports['__napi_register__sum_btree_mapping_213']?.() - __napiInstance.exports['__napi_register__get_index_mapping_214']?.() - __napiInstance.exports['__napi_register__sum_index_mapping_215']?.() - __napiInstance.exports['__napi_register__indexmap_passthrough_216']?.() - __napiInstance.exports['__napi_register__map_option_217']?.() - __napiInstance.exports['__napi_register__return_null_218']?.() - __napiInstance.exports['__napi_register__return_undefined_219']?.() - __napiInstance.exports['__napi_register__UseNullableStruct_struct_220']?.() - __napiInstance.exports['__napi_register__NotUseNullableStruct_struct_221']?.() + __napiInstance.exports['__napi_register__reference_as_callback_190']?.() __napiInstance.exports[ - '__napi_register__DefaultUseNullableStruct_struct_222' + '__napi_register__build_threadsafe_function_from_function_191' ]?.() - __napiInstance.exports['__napi_register__UseNullableClass_struct_223']?.() - __napiInstance.exports['__napi_register__NotUseNullableClass_struct_224']?.() + __napiInstance.exports['__napi_register__Fib_struct_192']?.() + __napiInstance.exports['__napi_register__Fib_impl_193']?.() + __napiInstance.exports['__napi_register__Fib_impl_195']?.() + __napiInstance.exports['__napi_register__Fib2_struct_196']?.() + __napiInstance.exports['__napi_register__Fib2_impl_197']?.() + __napiInstance.exports['__napi_register__Fib2_impl_199']?.() + __napiInstance.exports['__napi_register__Fib3_struct_200']?.() + __napiInstance.exports['__napi_register__Fib3_impl_201']?.() + __napiInstance.exports['__napi_register__ALIGNMENT_202']?.() + __napiInstance.exports['__napi_register__xxh64_203']?.() + __napiInstance.exports['__napi_register__xxh128_204']?.() + __napiInstance.exports['__napi_register__Xxh3_struct_205']?.() + __napiInstance.exports['__napi_register__Xxh3_impl_209']?.() + __napiInstance.exports['__napi_register__xxh2_plus_210']?.() + __napiInstance.exports['__napi_register__xxh3_xxh64_alias_211']?.() + __napiInstance.exports['__napi_register__xxh64_alias_212']?.() + __napiInstance.exports['__napi_register__get_mapping_213']?.() + __napiInstance.exports['__napi_register__sum_mapping_214']?.() + __napiInstance.exports['__napi_register__get_btree_mapping_215']?.() + __napiInstance.exports['__napi_register__sum_btree_mapping_216']?.() + __napiInstance.exports['__napi_register__get_index_mapping_217']?.() + __napiInstance.exports['__napi_register__sum_index_mapping_218']?.() + __napiInstance.exports['__napi_register__indexmap_passthrough_219']?.() + __napiInstance.exports['__napi_register__map_option_220']?.() + __napiInstance.exports['__napi_register__return_null_221']?.() + __napiInstance.exports['__napi_register__return_undefined_222']?.() + __napiInstance.exports['__napi_register__UseNullableStruct_struct_223']?.() + __napiInstance.exports['__napi_register__NotUseNullableStruct_struct_224']?.() __napiInstance.exports[ - '__napi_register__DefaultUseNullableClass_struct_225' + '__napi_register__DefaultUseNullableStruct_struct_225' ]?.() - __napiInstance.exports['__napi_register__add_226']?.() - __napiInstance.exports['__napi_register__fibonacci_227']?.() - __napiInstance.exports['__napi_register__list_obj_keys_228']?.() - __napiInstance.exports['__napi_register__create_obj_229']?.() - __napiInstance.exports['__napi_register__get_global_230']?.() - __napiInstance.exports['__napi_register__get_undefined_231']?.() - __napiInstance.exports['__napi_register__get_null_232']?.() - __napiInstance.exports['__napi_register__AllOptionalObject_struct_233']?.() - __napiInstance.exports['__napi_register__receive_all_optional_object_234']?.() - __napiInstance.exports['__napi_register__AliasedEnum_235']?.() + __napiInstance.exports['__napi_register__UseNullableClass_struct_226']?.() + __napiInstance.exports['__napi_register__NotUseNullableClass_struct_227']?.() __napiInstance.exports[ - '__napi_register__StructContainsAliasedEnum_struct_236' + '__napi_register__DefaultUseNullableClass_struct_228' ]?.() - __napiInstance.exports['__napi_register__fn_received_aliased_237']?.() - __napiInstance.exports['__napi_register__StrictObject_struct_238']?.() - __napiInstance.exports['__napi_register__receive_strict_object_239']?.() - __napiInstance.exports['__napi_register__get_str_from_object_240']?.() - __napiInstance.exports['__napi_register__TsTypeChanged_struct_241']?.() - __napiInstance.exports['__napi_register__create_obj_with_property_242']?.() - __napiInstance.exports['__napi_register__getter_from_obj_243']?.() - __napiInstance.exports['__napi_register__ObjectOnlyFromJs_struct_244']?.() - __napiInstance.exports['__napi_register__receive_object_only_from_js_245']?.() - __napiInstance.exports['__napi_register__async_plus_100_246']?.() - __napiInstance.exports['__napi_register__JsRepo_struct_247']?.() - __napiInstance.exports['__napi_register__JsRepo_impl_250']?.() - __napiInstance.exports['__napi_register__JsRemote_struct_251']?.() - __napiInstance.exports['__napi_register__JsRemote_impl_254']?.() - __napiInstance.exports['__napi_register__CSSRuleList_struct_255']?.() - __napiInstance.exports['__napi_register__CSSRuleList_impl_259']?.() - __napiInstance.exports['__napi_register__CSSStyleSheet_struct_260']?.() - __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_struct_261']?.() - __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_impl_263']?.() - __napiInstance.exports['__napi_register__CSSStyleSheet_impl_267']?.() - __napiInstance.exports['__napi_register__PackageJson_struct_268']?.() - __napiInstance.exports['__napi_register__read_package_json_269']?.() - __napiInstance.exports['__napi_register__get_package_json_name_270']?.() - __napiInstance.exports['__napi_register__test_serde_roundtrip_271']?.() + __napiInstance.exports['__napi_register__add_229']?.() + __napiInstance.exports['__napi_register__fibonacci_230']?.() + __napiInstance.exports['__napi_register__list_obj_keys_231']?.() + __napiInstance.exports['__napi_register__create_obj_232']?.() + __napiInstance.exports['__napi_register__get_global_233']?.() + __napiInstance.exports['__napi_register__get_undefined_234']?.() + __napiInstance.exports['__napi_register__get_null_235']?.() + __napiInstance.exports['__napi_register__AllOptionalObject_struct_236']?.() + __napiInstance.exports['__napi_register__receive_all_optional_object_237']?.() + __napiInstance.exports['__napi_register__AliasedEnum_238']?.() __napiInstance.exports[ - '__napi_register__test_serde_big_number_precision_272' + '__napi_register__StructContainsAliasedEnum_struct_239' ]?.() - __napiInstance.exports['__napi_register__return_from_shared_crate_273']?.() - __napiInstance.exports['__napi_register__contains_274']?.() - __napiInstance.exports['__napi_register__concat_str_275']?.() - __napiInstance.exports['__napi_register__concat_utf16_276']?.() - __napiInstance.exports['__napi_register__concat_latin1_277']?.() - __napiInstance.exports['__napi_register__roundtrip_str_278']?.() - __napiInstance.exports['__napi_register__set_symbol_in_obj_279']?.() - __napiInstance.exports['__napi_register__create_symbol_280']?.() - __napiInstance.exports['__napi_register__create_symbol_for_281']?.() - __napiInstance.exports['__napi_register__DelaySum_impl_282']?.() - __napiInstance.exports['__napi_register__without_abort_controller_283']?.() - __napiInstance.exports['__napi_register__with_abort_controller_284']?.() - __napiInstance.exports['__napi_register__AsyncTaskVoidReturn_impl_285']?.() - __napiInstance.exports['__napi_register__async_task_void_return_286']?.() + __napiInstance.exports['__napi_register__fn_received_aliased_240']?.() + __napiInstance.exports['__napi_register__StrictObject_struct_241']?.() + __napiInstance.exports['__napi_register__receive_strict_object_242']?.() + __napiInstance.exports['__napi_register__get_str_from_object_243']?.() + __napiInstance.exports['__napi_register__TsTypeChanged_struct_244']?.() + __napiInstance.exports['__napi_register__create_obj_with_property_245']?.() + __napiInstance.exports['__napi_register__getter_from_obj_246']?.() + __napiInstance.exports['__napi_register__ObjectOnlyFromJs_struct_247']?.() + __napiInstance.exports['__napi_register__receive_object_only_from_js_248']?.() __napiInstance.exports[ - '__napi_register__AsyncTaskOptionalReturn_impl_287' + '__napi_register__object_get_named_property_should_perform_typecheck_249' ]?.() - __napiInstance.exports['__napi_register__async_task_optional_return_288']?.() - __napiInstance.exports['__napi_register__call_threadsafe_function_289']?.() + __napiInstance.exports['__napi_register__ObjectOnlyToJs_struct_250']?.() + __napiInstance.exports['__napi_register__return_object_only_to_js_251']?.() + __napiInstance.exports['__napi_register__async_plus_100_252']?.() + __napiInstance.exports['__napi_register__JsRepo_struct_253']?.() + __napiInstance.exports['__napi_register__JsRepo_impl_256']?.() + __napiInstance.exports['__napi_register__JsRemote_struct_257']?.() + __napiInstance.exports['__napi_register__JsRemote_impl_260']?.() + __napiInstance.exports['__napi_register__CSSRuleList_struct_261']?.() + __napiInstance.exports['__napi_register__CSSRuleList_impl_265']?.() + __napiInstance.exports['__napi_register__CSSStyleSheet_struct_266']?.() + __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_struct_267']?.() + __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_impl_269']?.() + __napiInstance.exports['__napi_register__CSSStyleSheet_impl_273']?.() + __napiInstance.exports['__napi_register__PackageJson_struct_274']?.() + __napiInstance.exports['__napi_register__read_package_json_275']?.() + __napiInstance.exports['__napi_register__get_package_json_name_276']?.() + __napiInstance.exports['__napi_register__test_serde_roundtrip_277']?.() __napiInstance.exports[ - '__napi_register__call_long_threadsafe_function_290' + '__napi_register__test_serde_big_number_precision_278' + ]?.() + __napiInstance.exports['__napi_register__return_from_shared_crate_279']?.() + __napiInstance.exports['__napi_register__contains_280']?.() + __napiInstance.exports['__napi_register__concat_str_281']?.() + __napiInstance.exports['__napi_register__concat_utf16_282']?.() + __napiInstance.exports['__napi_register__concat_latin1_283']?.() + __napiInstance.exports['__napi_register__roundtrip_str_284']?.() + __napiInstance.exports['__napi_register__set_symbol_in_obj_285']?.() + __napiInstance.exports['__napi_register__create_symbol_286']?.() + __napiInstance.exports['__napi_register__create_symbol_for_287']?.() + __napiInstance.exports['__napi_register__DelaySum_impl_288']?.() + __napiInstance.exports['__napi_register__without_abort_controller_289']?.() + __napiInstance.exports['__napi_register__with_abort_controller_290']?.() + __napiInstance.exports['__napi_register__AsyncTaskVoidReturn_impl_291']?.() + __napiInstance.exports['__napi_register__async_task_void_return_292']?.() + __napiInstance.exports[ + '__napi_register__AsyncTaskOptionalReturn_impl_293' + ]?.() + __napiInstance.exports['__napi_register__async_task_optional_return_294']?.() + __napiInstance.exports['__napi_register__call_threadsafe_function_295']?.() + __napiInstance.exports[ + '__napi_register__call_long_threadsafe_function_296' ]?.() __napiInstance.exports[ - '__napi_register__threadsafe_function_throw_error_291' + '__napi_register__threadsafe_function_throw_error_297' ]?.() __napiInstance.exports[ - '__napi_register__threadsafe_function_fatal_mode_292' + '__napi_register__threadsafe_function_fatal_mode_298' ]?.() __napiInstance.exports[ - '__napi_register__threadsafe_function_fatal_mode_error_293' + '__napi_register__threadsafe_function_fatal_mode_error_299' ]?.() __napiInstance.exports[ - '__napi_register__threadsafe_function_closure_capture_294' + '__napi_register__threadsafe_function_closure_capture_300' ]?.() - __napiInstance.exports['__napi_register__tsfn_call_with_callback_295']?.() - __napiInstance.exports['__napi_register__tsfn_async_call_296']?.() - __napiInstance.exports['__napi_register__accept_threadsafe_function_297']?.() + __napiInstance.exports['__napi_register__tsfn_call_with_callback_301']?.() + __napiInstance.exports['__napi_register__tsfn_async_call_302']?.() + __napiInstance.exports['__napi_register__accept_threadsafe_function_303']?.() __napiInstance.exports[ - '__napi_register__accept_threadsafe_function_fatal_298' + '__napi_register__accept_threadsafe_function_fatal_304' ]?.() __napiInstance.exports[ - '__napi_register__accept_threadsafe_function_tuple_args_299' + '__napi_register__accept_threadsafe_function_tuple_args_305' ]?.() - __napiInstance.exports['__napi_register__tsfn_return_promise_300']?.() - __napiInstance.exports['__napi_register__tsfn_return_promise_timeout_301']?.() - __napiInstance.exports['__napi_register__tsfn_throw_from_js_302']?.() - __napiInstance.exports['__napi_register__get_buffer_303']?.() - __napiInstance.exports['__napi_register__append_buffer_304']?.() - __napiInstance.exports['__napi_register__get_empty_buffer_305']?.() - __napiInstance.exports['__napi_register__convert_u32_array_306']?.() - __napiInstance.exports['__napi_register__create_external_typed_array_307']?.() - __napiInstance.exports['__napi_register__mutate_typed_array_308']?.() - __napiInstance.exports['__napi_register__deref_uint8_array_309']?.() - __napiInstance.exports['__napi_register__buffer_pass_through_310']?.() - __napiInstance.exports['__napi_register__array_buffer_pass_through_311']?.() - __napiInstance.exports['__napi_register__accept_slice_312']?.() - __napiInstance.exports['__napi_register__u8_array_to_array_313']?.() - __napiInstance.exports['__napi_register__i8_array_to_array_314']?.() - __napiInstance.exports['__napi_register__u16_array_to_array_315']?.() - __napiInstance.exports['__napi_register__i16_array_to_array_316']?.() - __napiInstance.exports['__napi_register__u32_array_to_array_317']?.() - __napiInstance.exports['__napi_register__i32_array_to_array_318']?.() - __napiInstance.exports['__napi_register__f32_array_to_array_319']?.() - __napiInstance.exports['__napi_register__f64_array_to_array_320']?.() - __napiInstance.exports['__napi_register__u64_array_to_array_321']?.() - __napiInstance.exports['__napi_register__i64_array_to_array_322']?.() - __napiInstance.exports['__napi_register__accept_uint8_clamped_slice_323']?.() + __napiInstance.exports['__napi_register__tsfn_return_promise_306']?.() + __napiInstance.exports['__napi_register__tsfn_return_promise_timeout_307']?.() + __napiInstance.exports['__napi_register__tsfn_throw_from_js_308']?.() + __napiInstance.exports['__napi_register__get_buffer_309']?.() + __napiInstance.exports['__napi_register__append_buffer_310']?.() + __napiInstance.exports['__napi_register__get_empty_buffer_311']?.() + __napiInstance.exports['__napi_register__convert_u32_array_312']?.() + __napiInstance.exports['__napi_register__create_external_typed_array_313']?.() + __napiInstance.exports['__napi_register__mutate_typed_array_314']?.() + __napiInstance.exports['__napi_register__deref_uint8_array_315']?.() + __napiInstance.exports['__napi_register__buffer_pass_through_316']?.() + __napiInstance.exports['__napi_register__array_buffer_pass_through_317']?.() + __napiInstance.exports['__napi_register__accept_slice_318']?.() + __napiInstance.exports['__napi_register__u8_array_to_array_319']?.() + __napiInstance.exports['__napi_register__i8_array_to_array_320']?.() + __napiInstance.exports['__napi_register__u16_array_to_array_321']?.() + __napiInstance.exports['__napi_register__i16_array_to_array_322']?.() + __napiInstance.exports['__napi_register__u32_array_to_array_323']?.() + __napiInstance.exports['__napi_register__i32_array_to_array_324']?.() + __napiInstance.exports['__napi_register__f32_array_to_array_325']?.() + __napiInstance.exports['__napi_register__f64_array_to_array_326']?.() + __napiInstance.exports['__napi_register__u64_array_to_array_327']?.() + __napiInstance.exports['__napi_register__i64_array_to_array_328']?.() + __napiInstance.exports['__napi_register__accept_uint8_clamped_slice_329']?.() __napiInstance.exports[ - '__napi_register__accept_uint8_clamped_slice_and_buffer_slice_324' + '__napi_register__accept_uint8_clamped_slice_and_buffer_slice_330' ]?.() - __napiInstance.exports['__napi_register__AsyncBuffer_impl_325']?.() - __napiInstance.exports['__napi_register__async_reduce_buffer_326']?.() - __napiInstance.exports['__napi_register__async_buffer_to_array_327']?.() + __napiInstance.exports['__napi_register__AsyncBuffer_impl_331']?.() + __napiInstance.exports['__napi_register__async_reduce_buffer_332']?.() + __napiInstance.exports['__napi_register__async_buffer_to_array_333']?.() } export const Animal = __napiModule.exports.Animal export const AnimalWithDefaultConstructor = @@ -456,6 +466,8 @@ export const bigintFromI128 = __napiModule.exports.bigintFromI128 export const bigintFromI64 = __napiModule.exports.bigintFromI64 export const bigintGetU64AsString = __napiModule.exports.bigintGetU64AsString export const bufferPassThrough = __napiModule.exports.bufferPassThrough +export const buildThreadsafeFunctionFromFunction = + __napiModule.exports.buildThreadsafeFunctionFromFunction export const call0 = __napiModule.exports.call0 export const call1 = __napiModule.exports.call1 export const call2 = __napiModule.exports.call2 @@ -504,6 +516,7 @@ export const derefUint8Array = __napiModule.exports.derefUint8Array export const either3 = __napiModule.exports.either3 export const either4 = __napiModule.exports.either4 export const eitherBoolOrFunction = __napiModule.exports.eitherBoolOrFunction +export const eitherBoolOrTuple = __napiModule.exports.eitherBoolOrTuple export const eitherFromObjects = __napiModule.exports.eitherFromObjects export const eitherFromOption = __napiModule.exports.eitherFromOption export const eitherStringOrNumber = __napiModule.exports.eitherStringOrNumber @@ -541,6 +554,8 @@ export const listObjKeys = __napiModule.exports.listObjKeys export const mapOption = __napiModule.exports.mapOption export const mutateExternal = __napiModule.exports.mutateExternal export const mutateTypedArray = __napiModule.exports.mutateTypedArray +export const objectGetNamedPropertyShouldPerformTypecheck = + __napiModule.exports.objectGetNamedPropertyShouldPerformTypecheck export const optionEnd = __napiModule.exports.optionEnd export const optionOnly = __napiModule.exports.optionOnly export const optionStart = __napiModule.exports.optionStart @@ -573,6 +588,7 @@ export const returnEitherClass = __napiModule.exports.returnEitherClass export const returnFromSharedCrate = __napiModule.exports.returnFromSharedCrate export const returnJsFunction = __napiModule.exports.returnJsFunction export const returnNull = __napiModule.exports.returnNull +export const returnObjectOnlyToJs = __napiModule.exports.returnObjectOnlyToJs export const returnUndefined = __napiModule.exports.returnUndefined export const returnUndefinedIfInvalid = __napiModule.exports.returnUndefinedIfInvalid @@ -582,6 +598,7 @@ export const roundtripStr = __napiModule.exports.roundtripStr export const runScript = __napiModule.exports.runScript export const setSymbolInObj = __napiModule.exports.setSymbolInObj export const Status = __napiModule.exports.Status +export const StringEnum = __napiModule.exports.StringEnum export const sumBtreeMapping = __napiModule.exports.sumBtreeMapping export const sumIndexMapping = __napiModule.exports.sumIndexMapping export const sumMapping = __napiModule.exports.sumMapping diff --git a/examples/napi/example.wasi.cjs b/examples/napi/example.wasi.cjs index 71b0610e..37a55d6a 100644 --- a/examples/napi/example.wasi.cjs +++ b/examples/napi/example.wasi.cjs @@ -163,182 +163,188 @@ function __napi_rs_initialize_modules(__napiInstance) { __napiInstance.exports['__napi_register__either_from_objects_133']?.() __napiInstance.exports['__napi_register__either_bool_or_function_134']?.() __napiInstance.exports['__napi_register__promise_in_either_135']?.() - __napiInstance.exports['__napi_register__Kind_136']?.() - __napiInstance.exports['__napi_register__Empty_137']?.() - __napiInstance.exports['__napi_register__Status_138']?.() - __napiInstance.exports['__napi_register__CustomNumEnum_139']?.() - __napiInstance.exports['__napi_register__enum_to_i32_140']?.() - __napiInstance.exports['__napi_register__SkippedEnums_141']?.() - __napiInstance.exports['__napi_register__run_script_142']?.() - __napiInstance.exports['__napi_register__get_module_file_name_143']?.() - __napiInstance.exports['__napi_register__throw_syntax_error_144']?.() - __napiInstance.exports['__napi_register__throw_error_145']?.() - __napiInstance.exports['__napi_register__panic_146']?.() - __napiInstance.exports['__napi_register__receive_string_147']?.() - __napiInstance.exports['__napi_register__custom_status_code_148']?.() - __napiInstance.exports['__napi_register__throw_async_error_149']?.() - __napiInstance.exports['__napi_register__create_external_150']?.() - __napiInstance.exports['__napi_register__create_external_string_151']?.() - __napiInstance.exports['__napi_register__get_external_152']?.() - __napiInstance.exports['__napi_register__mutate_external_153']?.() - __napiInstance.exports['__napi_register__validate_array_154']?.() - __napiInstance.exports['__napi_register__validate_buffer_155']?.() - __napiInstance.exports['__napi_register__validate_typed_array_156']?.() - __napiInstance.exports['__napi_register__validate_typed_array_slice_157']?.() - __napiInstance.exports['__napi_register__validate_uint8_clamped_slice_158']?.() - __napiInstance.exports['__napi_register__validate_buffer_slice_159']?.() - __napiInstance.exports['__napi_register__validate_bigint_160']?.() - __napiInstance.exports['__napi_register__validate_boolean_161']?.() - __napiInstance.exports['__napi_register__validate_date_162']?.() - __napiInstance.exports['__napi_register__validate_date_time_163']?.() - __napiInstance.exports['__napi_register__validate_external_164']?.() - __napiInstance.exports['__napi_register__validate_function_165']?.() - __napiInstance.exports['__napi_register__validate_hash_map_166']?.() - __napiInstance.exports['__napi_register__validate_null_167']?.() - __napiInstance.exports['__napi_register__validate_undefined_168']?.() - __napiInstance.exports['__napi_register__validate_number_169']?.() - __napiInstance.exports['__napi_register__validate_promise_170']?.() - __napiInstance.exports['__napi_register__validate_string_171']?.() - __napiInstance.exports['__napi_register__validate_symbol_172']?.() - __napiInstance.exports['__napi_register__validate_optional_173']?.() - __napiInstance.exports['__napi_register__return_undefined_if_invalid_174']?.() - __napiInstance.exports['__napi_register__return_undefined_if_invalid_promise_175']?.() - __napiInstance.exports['__napi_register__ts_rename_176']?.() - __napiInstance.exports['__napi_register__override_individual_arg_on_function_177']?.() - __napiInstance.exports['__napi_register__override_individual_arg_on_function_with_cb_arg_178']?.() - __napiInstance.exports['__napi_register__call0_179']?.() - __napiInstance.exports['__napi_register__call1_180']?.() - __napiInstance.exports['__napi_register__call2_181']?.() - __napiInstance.exports['__napi_register__apply0_182']?.() - __napiInstance.exports['__napi_register__apply1_183']?.() - __napiInstance.exports['__napi_register__call_function_184']?.() - __napiInstance.exports['__napi_register__call_function_with_arg_185']?.() - __napiInstance.exports['__napi_register__create_reference_on_function_186']?.() - __napiInstance.exports['__napi_register__call_function_with_arg_and_ctx_187']?.() - __napiInstance.exports['__napi_register__reference_as_callback_188']?.() - __napiInstance.exports['__napi_register__Fib_struct_189']?.() - __napiInstance.exports['__napi_register__Fib_impl_190']?.() - __napiInstance.exports['__napi_register__Fib_impl_192']?.() - __napiInstance.exports['__napi_register__Fib2_struct_193']?.() - __napiInstance.exports['__napi_register__Fib2_impl_194']?.() - __napiInstance.exports['__napi_register__Fib2_impl_196']?.() - __napiInstance.exports['__napi_register__Fib3_struct_197']?.() - __napiInstance.exports['__napi_register__Fib3_impl_198']?.() - __napiInstance.exports['__napi_register__ALIGNMENT_199']?.() - __napiInstance.exports['__napi_register__xxh64_200']?.() - __napiInstance.exports['__napi_register__xxh128_201']?.() - __napiInstance.exports['__napi_register__Xxh3_struct_202']?.() - __napiInstance.exports['__napi_register__Xxh3_impl_206']?.() - __napiInstance.exports['__napi_register__xxh2_plus_207']?.() - __napiInstance.exports['__napi_register__xxh3_xxh64_alias_208']?.() - __napiInstance.exports['__napi_register__xxh64_alias_209']?.() - __napiInstance.exports['__napi_register__get_mapping_210']?.() - __napiInstance.exports['__napi_register__sum_mapping_211']?.() - __napiInstance.exports['__napi_register__get_btree_mapping_212']?.() - __napiInstance.exports['__napi_register__sum_btree_mapping_213']?.() - __napiInstance.exports['__napi_register__get_index_mapping_214']?.() - __napiInstance.exports['__napi_register__sum_index_mapping_215']?.() - __napiInstance.exports['__napi_register__indexmap_passthrough_216']?.() - __napiInstance.exports['__napi_register__map_option_217']?.() - __napiInstance.exports['__napi_register__return_null_218']?.() - __napiInstance.exports['__napi_register__return_undefined_219']?.() - __napiInstance.exports['__napi_register__UseNullableStruct_struct_220']?.() - __napiInstance.exports['__napi_register__NotUseNullableStruct_struct_221']?.() - __napiInstance.exports['__napi_register__DefaultUseNullableStruct_struct_222']?.() - __napiInstance.exports['__napi_register__UseNullableClass_struct_223']?.() - __napiInstance.exports['__napi_register__NotUseNullableClass_struct_224']?.() - __napiInstance.exports['__napi_register__DefaultUseNullableClass_struct_225']?.() - __napiInstance.exports['__napi_register__add_226']?.() - __napiInstance.exports['__napi_register__fibonacci_227']?.() - __napiInstance.exports['__napi_register__list_obj_keys_228']?.() - __napiInstance.exports['__napi_register__create_obj_229']?.() - __napiInstance.exports['__napi_register__get_global_230']?.() - __napiInstance.exports['__napi_register__get_undefined_231']?.() - __napiInstance.exports['__napi_register__get_null_232']?.() - __napiInstance.exports['__napi_register__AllOptionalObject_struct_233']?.() - __napiInstance.exports['__napi_register__receive_all_optional_object_234']?.() - __napiInstance.exports['__napi_register__AliasedEnum_235']?.() - __napiInstance.exports['__napi_register__StructContainsAliasedEnum_struct_236']?.() - __napiInstance.exports['__napi_register__fn_received_aliased_237']?.() - __napiInstance.exports['__napi_register__StrictObject_struct_238']?.() - __napiInstance.exports['__napi_register__receive_strict_object_239']?.() - __napiInstance.exports['__napi_register__get_str_from_object_240']?.() - __napiInstance.exports['__napi_register__TsTypeChanged_struct_241']?.() - __napiInstance.exports['__napi_register__create_obj_with_property_242']?.() - __napiInstance.exports['__napi_register__getter_from_obj_243']?.() - __napiInstance.exports['__napi_register__ObjectOnlyFromJs_struct_244']?.() - __napiInstance.exports['__napi_register__receive_object_only_from_js_245']?.() - __napiInstance.exports['__napi_register__async_plus_100_246']?.() - __napiInstance.exports['__napi_register__JsRepo_struct_247']?.() - __napiInstance.exports['__napi_register__JsRepo_impl_250']?.() - __napiInstance.exports['__napi_register__JsRemote_struct_251']?.() - __napiInstance.exports['__napi_register__JsRemote_impl_254']?.() - __napiInstance.exports['__napi_register__CSSRuleList_struct_255']?.() - __napiInstance.exports['__napi_register__CSSRuleList_impl_259']?.() - __napiInstance.exports['__napi_register__CSSStyleSheet_struct_260']?.() - __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_struct_261']?.() - __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_impl_263']?.() - __napiInstance.exports['__napi_register__CSSStyleSheet_impl_267']?.() - __napiInstance.exports['__napi_register__PackageJson_struct_268']?.() - __napiInstance.exports['__napi_register__read_package_json_269']?.() - __napiInstance.exports['__napi_register__get_package_json_name_270']?.() - __napiInstance.exports['__napi_register__test_serde_roundtrip_271']?.() - __napiInstance.exports['__napi_register__test_serde_big_number_precision_272']?.() - __napiInstance.exports['__napi_register__return_from_shared_crate_273']?.() - __napiInstance.exports['__napi_register__contains_274']?.() - __napiInstance.exports['__napi_register__concat_str_275']?.() - __napiInstance.exports['__napi_register__concat_utf16_276']?.() - __napiInstance.exports['__napi_register__concat_latin1_277']?.() - __napiInstance.exports['__napi_register__roundtrip_str_278']?.() - __napiInstance.exports['__napi_register__set_symbol_in_obj_279']?.() - __napiInstance.exports['__napi_register__create_symbol_280']?.() - __napiInstance.exports['__napi_register__create_symbol_for_281']?.() - __napiInstance.exports['__napi_register__DelaySum_impl_282']?.() - __napiInstance.exports['__napi_register__without_abort_controller_283']?.() - __napiInstance.exports['__napi_register__with_abort_controller_284']?.() - __napiInstance.exports['__napi_register__AsyncTaskVoidReturn_impl_285']?.() - __napiInstance.exports['__napi_register__async_task_void_return_286']?.() - __napiInstance.exports['__napi_register__AsyncTaskOptionalReturn_impl_287']?.() - __napiInstance.exports['__napi_register__async_task_optional_return_288']?.() - __napiInstance.exports['__napi_register__call_threadsafe_function_289']?.() - __napiInstance.exports['__napi_register__call_long_threadsafe_function_290']?.() - __napiInstance.exports['__napi_register__threadsafe_function_throw_error_291']?.() - __napiInstance.exports['__napi_register__threadsafe_function_fatal_mode_292']?.() - __napiInstance.exports['__napi_register__threadsafe_function_fatal_mode_error_293']?.() - __napiInstance.exports['__napi_register__threadsafe_function_closure_capture_294']?.() - __napiInstance.exports['__napi_register__tsfn_call_with_callback_295']?.() - __napiInstance.exports['__napi_register__tsfn_async_call_296']?.() - __napiInstance.exports['__napi_register__accept_threadsafe_function_297']?.() - __napiInstance.exports['__napi_register__accept_threadsafe_function_fatal_298']?.() - __napiInstance.exports['__napi_register__accept_threadsafe_function_tuple_args_299']?.() - __napiInstance.exports['__napi_register__tsfn_return_promise_300']?.() - __napiInstance.exports['__napi_register__tsfn_return_promise_timeout_301']?.() - __napiInstance.exports['__napi_register__tsfn_throw_from_js_302']?.() - __napiInstance.exports['__napi_register__get_buffer_303']?.() - __napiInstance.exports['__napi_register__append_buffer_304']?.() - __napiInstance.exports['__napi_register__get_empty_buffer_305']?.() - __napiInstance.exports['__napi_register__convert_u32_array_306']?.() - __napiInstance.exports['__napi_register__create_external_typed_array_307']?.() - __napiInstance.exports['__napi_register__mutate_typed_array_308']?.() - __napiInstance.exports['__napi_register__deref_uint8_array_309']?.() - __napiInstance.exports['__napi_register__buffer_pass_through_310']?.() - __napiInstance.exports['__napi_register__array_buffer_pass_through_311']?.() - __napiInstance.exports['__napi_register__accept_slice_312']?.() - __napiInstance.exports['__napi_register__u8_array_to_array_313']?.() - __napiInstance.exports['__napi_register__i8_array_to_array_314']?.() - __napiInstance.exports['__napi_register__u16_array_to_array_315']?.() - __napiInstance.exports['__napi_register__i16_array_to_array_316']?.() - __napiInstance.exports['__napi_register__u32_array_to_array_317']?.() - __napiInstance.exports['__napi_register__i32_array_to_array_318']?.() - __napiInstance.exports['__napi_register__f32_array_to_array_319']?.() - __napiInstance.exports['__napi_register__f64_array_to_array_320']?.() - __napiInstance.exports['__napi_register__u64_array_to_array_321']?.() - __napiInstance.exports['__napi_register__i64_array_to_array_322']?.() - __napiInstance.exports['__napi_register__accept_uint8_clamped_slice_323']?.() - __napiInstance.exports['__napi_register__accept_uint8_clamped_slice_and_buffer_slice_324']?.() - __napiInstance.exports['__napi_register__AsyncBuffer_impl_325']?.() - __napiInstance.exports['__napi_register__async_reduce_buffer_326']?.() - __napiInstance.exports['__napi_register__async_buffer_to_array_327']?.() + __napiInstance.exports['__napi_register__either_bool_or_tuple_136']?.() + __napiInstance.exports['__napi_register__Kind_137']?.() + __napiInstance.exports['__napi_register__Empty_138']?.() + __napiInstance.exports['__napi_register__Status_139']?.() + __napiInstance.exports['__napi_register__StringEnum_140']?.() + __napiInstance.exports['__napi_register__CustomNumEnum_141']?.() + __napiInstance.exports['__napi_register__enum_to_i32_142']?.() + __napiInstance.exports['__napi_register__SkippedEnums_143']?.() + __napiInstance.exports['__napi_register__run_script_144']?.() + __napiInstance.exports['__napi_register__get_module_file_name_145']?.() + __napiInstance.exports['__napi_register__throw_syntax_error_146']?.() + __napiInstance.exports['__napi_register__throw_error_147']?.() + __napiInstance.exports['__napi_register__panic_148']?.() + __napiInstance.exports['__napi_register__receive_string_149']?.() + __napiInstance.exports['__napi_register__custom_status_code_150']?.() + __napiInstance.exports['__napi_register__throw_async_error_151']?.() + __napiInstance.exports['__napi_register__create_external_152']?.() + __napiInstance.exports['__napi_register__create_external_string_153']?.() + __napiInstance.exports['__napi_register__get_external_154']?.() + __napiInstance.exports['__napi_register__mutate_external_155']?.() + __napiInstance.exports['__napi_register__validate_array_156']?.() + __napiInstance.exports['__napi_register__validate_buffer_157']?.() + __napiInstance.exports['__napi_register__validate_typed_array_158']?.() + __napiInstance.exports['__napi_register__validate_typed_array_slice_159']?.() + __napiInstance.exports['__napi_register__validate_uint8_clamped_slice_160']?.() + __napiInstance.exports['__napi_register__validate_buffer_slice_161']?.() + __napiInstance.exports['__napi_register__validate_bigint_162']?.() + __napiInstance.exports['__napi_register__validate_boolean_163']?.() + __napiInstance.exports['__napi_register__validate_date_164']?.() + __napiInstance.exports['__napi_register__validate_date_time_165']?.() + __napiInstance.exports['__napi_register__validate_external_166']?.() + __napiInstance.exports['__napi_register__validate_function_167']?.() + __napiInstance.exports['__napi_register__validate_hash_map_168']?.() + __napiInstance.exports['__napi_register__validate_null_169']?.() + __napiInstance.exports['__napi_register__validate_undefined_170']?.() + __napiInstance.exports['__napi_register__validate_number_171']?.() + __napiInstance.exports['__napi_register__validate_promise_172']?.() + __napiInstance.exports['__napi_register__validate_string_173']?.() + __napiInstance.exports['__napi_register__validate_symbol_174']?.() + __napiInstance.exports['__napi_register__validate_optional_175']?.() + __napiInstance.exports['__napi_register__return_undefined_if_invalid_176']?.() + __napiInstance.exports['__napi_register__return_undefined_if_invalid_promise_177']?.() + __napiInstance.exports['__napi_register__ts_rename_178']?.() + __napiInstance.exports['__napi_register__override_individual_arg_on_function_179']?.() + __napiInstance.exports['__napi_register__override_individual_arg_on_function_with_cb_arg_180']?.() + __napiInstance.exports['__napi_register__call0_181']?.() + __napiInstance.exports['__napi_register__call1_182']?.() + __napiInstance.exports['__napi_register__call2_183']?.() + __napiInstance.exports['__napi_register__apply0_184']?.() + __napiInstance.exports['__napi_register__apply1_185']?.() + __napiInstance.exports['__napi_register__call_function_186']?.() + __napiInstance.exports['__napi_register__call_function_with_arg_187']?.() + __napiInstance.exports['__napi_register__create_reference_on_function_188']?.() + __napiInstance.exports['__napi_register__call_function_with_arg_and_ctx_189']?.() + __napiInstance.exports['__napi_register__reference_as_callback_190']?.() + __napiInstance.exports['__napi_register__build_threadsafe_function_from_function_191']?.() + __napiInstance.exports['__napi_register__Fib_struct_192']?.() + __napiInstance.exports['__napi_register__Fib_impl_193']?.() + __napiInstance.exports['__napi_register__Fib_impl_195']?.() + __napiInstance.exports['__napi_register__Fib2_struct_196']?.() + __napiInstance.exports['__napi_register__Fib2_impl_197']?.() + __napiInstance.exports['__napi_register__Fib2_impl_199']?.() + __napiInstance.exports['__napi_register__Fib3_struct_200']?.() + __napiInstance.exports['__napi_register__Fib3_impl_201']?.() + __napiInstance.exports['__napi_register__ALIGNMENT_202']?.() + __napiInstance.exports['__napi_register__xxh64_203']?.() + __napiInstance.exports['__napi_register__xxh128_204']?.() + __napiInstance.exports['__napi_register__Xxh3_struct_205']?.() + __napiInstance.exports['__napi_register__Xxh3_impl_209']?.() + __napiInstance.exports['__napi_register__xxh2_plus_210']?.() + __napiInstance.exports['__napi_register__xxh3_xxh64_alias_211']?.() + __napiInstance.exports['__napi_register__xxh64_alias_212']?.() + __napiInstance.exports['__napi_register__get_mapping_213']?.() + __napiInstance.exports['__napi_register__sum_mapping_214']?.() + __napiInstance.exports['__napi_register__get_btree_mapping_215']?.() + __napiInstance.exports['__napi_register__sum_btree_mapping_216']?.() + __napiInstance.exports['__napi_register__get_index_mapping_217']?.() + __napiInstance.exports['__napi_register__sum_index_mapping_218']?.() + __napiInstance.exports['__napi_register__indexmap_passthrough_219']?.() + __napiInstance.exports['__napi_register__map_option_220']?.() + __napiInstance.exports['__napi_register__return_null_221']?.() + __napiInstance.exports['__napi_register__return_undefined_222']?.() + __napiInstance.exports['__napi_register__UseNullableStruct_struct_223']?.() + __napiInstance.exports['__napi_register__NotUseNullableStruct_struct_224']?.() + __napiInstance.exports['__napi_register__DefaultUseNullableStruct_struct_225']?.() + __napiInstance.exports['__napi_register__UseNullableClass_struct_226']?.() + __napiInstance.exports['__napi_register__NotUseNullableClass_struct_227']?.() + __napiInstance.exports['__napi_register__DefaultUseNullableClass_struct_228']?.() + __napiInstance.exports['__napi_register__add_229']?.() + __napiInstance.exports['__napi_register__fibonacci_230']?.() + __napiInstance.exports['__napi_register__list_obj_keys_231']?.() + __napiInstance.exports['__napi_register__create_obj_232']?.() + __napiInstance.exports['__napi_register__get_global_233']?.() + __napiInstance.exports['__napi_register__get_undefined_234']?.() + __napiInstance.exports['__napi_register__get_null_235']?.() + __napiInstance.exports['__napi_register__AllOptionalObject_struct_236']?.() + __napiInstance.exports['__napi_register__receive_all_optional_object_237']?.() + __napiInstance.exports['__napi_register__AliasedEnum_238']?.() + __napiInstance.exports['__napi_register__StructContainsAliasedEnum_struct_239']?.() + __napiInstance.exports['__napi_register__fn_received_aliased_240']?.() + __napiInstance.exports['__napi_register__StrictObject_struct_241']?.() + __napiInstance.exports['__napi_register__receive_strict_object_242']?.() + __napiInstance.exports['__napi_register__get_str_from_object_243']?.() + __napiInstance.exports['__napi_register__TsTypeChanged_struct_244']?.() + __napiInstance.exports['__napi_register__create_obj_with_property_245']?.() + __napiInstance.exports['__napi_register__getter_from_obj_246']?.() + __napiInstance.exports['__napi_register__ObjectOnlyFromJs_struct_247']?.() + __napiInstance.exports['__napi_register__receive_object_only_from_js_248']?.() + __napiInstance.exports['__napi_register__object_get_named_property_should_perform_typecheck_249']?.() + __napiInstance.exports['__napi_register__ObjectOnlyToJs_struct_250']?.() + __napiInstance.exports['__napi_register__return_object_only_to_js_251']?.() + __napiInstance.exports['__napi_register__async_plus_100_252']?.() + __napiInstance.exports['__napi_register__JsRepo_struct_253']?.() + __napiInstance.exports['__napi_register__JsRepo_impl_256']?.() + __napiInstance.exports['__napi_register__JsRemote_struct_257']?.() + __napiInstance.exports['__napi_register__JsRemote_impl_260']?.() + __napiInstance.exports['__napi_register__CSSRuleList_struct_261']?.() + __napiInstance.exports['__napi_register__CSSRuleList_impl_265']?.() + __napiInstance.exports['__napi_register__CSSStyleSheet_struct_266']?.() + __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_struct_267']?.() + __napiInstance.exports['__napi_register__AnotherCSSStyleSheet_impl_269']?.() + __napiInstance.exports['__napi_register__CSSStyleSheet_impl_273']?.() + __napiInstance.exports['__napi_register__PackageJson_struct_274']?.() + __napiInstance.exports['__napi_register__read_package_json_275']?.() + __napiInstance.exports['__napi_register__get_package_json_name_276']?.() + __napiInstance.exports['__napi_register__test_serde_roundtrip_277']?.() + __napiInstance.exports['__napi_register__test_serde_big_number_precision_278']?.() + __napiInstance.exports['__napi_register__return_from_shared_crate_279']?.() + __napiInstance.exports['__napi_register__contains_280']?.() + __napiInstance.exports['__napi_register__concat_str_281']?.() + __napiInstance.exports['__napi_register__concat_utf16_282']?.() + __napiInstance.exports['__napi_register__concat_latin1_283']?.() + __napiInstance.exports['__napi_register__roundtrip_str_284']?.() + __napiInstance.exports['__napi_register__set_symbol_in_obj_285']?.() + __napiInstance.exports['__napi_register__create_symbol_286']?.() + __napiInstance.exports['__napi_register__create_symbol_for_287']?.() + __napiInstance.exports['__napi_register__DelaySum_impl_288']?.() + __napiInstance.exports['__napi_register__without_abort_controller_289']?.() + __napiInstance.exports['__napi_register__with_abort_controller_290']?.() + __napiInstance.exports['__napi_register__AsyncTaskVoidReturn_impl_291']?.() + __napiInstance.exports['__napi_register__async_task_void_return_292']?.() + __napiInstance.exports['__napi_register__AsyncTaskOptionalReturn_impl_293']?.() + __napiInstance.exports['__napi_register__async_task_optional_return_294']?.() + __napiInstance.exports['__napi_register__call_threadsafe_function_295']?.() + __napiInstance.exports['__napi_register__call_long_threadsafe_function_296']?.() + __napiInstance.exports['__napi_register__threadsafe_function_throw_error_297']?.() + __napiInstance.exports['__napi_register__threadsafe_function_fatal_mode_298']?.() + __napiInstance.exports['__napi_register__threadsafe_function_fatal_mode_error_299']?.() + __napiInstance.exports['__napi_register__threadsafe_function_closure_capture_300']?.() + __napiInstance.exports['__napi_register__tsfn_call_with_callback_301']?.() + __napiInstance.exports['__napi_register__tsfn_async_call_302']?.() + __napiInstance.exports['__napi_register__accept_threadsafe_function_303']?.() + __napiInstance.exports['__napi_register__accept_threadsafe_function_fatal_304']?.() + __napiInstance.exports['__napi_register__accept_threadsafe_function_tuple_args_305']?.() + __napiInstance.exports['__napi_register__tsfn_return_promise_306']?.() + __napiInstance.exports['__napi_register__tsfn_return_promise_timeout_307']?.() + __napiInstance.exports['__napi_register__tsfn_throw_from_js_308']?.() + __napiInstance.exports['__napi_register__get_buffer_309']?.() + __napiInstance.exports['__napi_register__append_buffer_310']?.() + __napiInstance.exports['__napi_register__get_empty_buffer_311']?.() + __napiInstance.exports['__napi_register__convert_u32_array_312']?.() + __napiInstance.exports['__napi_register__create_external_typed_array_313']?.() + __napiInstance.exports['__napi_register__mutate_typed_array_314']?.() + __napiInstance.exports['__napi_register__deref_uint8_array_315']?.() + __napiInstance.exports['__napi_register__buffer_pass_through_316']?.() + __napiInstance.exports['__napi_register__array_buffer_pass_through_317']?.() + __napiInstance.exports['__napi_register__accept_slice_318']?.() + __napiInstance.exports['__napi_register__u8_array_to_array_319']?.() + __napiInstance.exports['__napi_register__i8_array_to_array_320']?.() + __napiInstance.exports['__napi_register__u16_array_to_array_321']?.() + __napiInstance.exports['__napi_register__i16_array_to_array_322']?.() + __napiInstance.exports['__napi_register__u32_array_to_array_323']?.() + __napiInstance.exports['__napi_register__i32_array_to_array_324']?.() + __napiInstance.exports['__napi_register__f32_array_to_array_325']?.() + __napiInstance.exports['__napi_register__f64_array_to_array_326']?.() + __napiInstance.exports['__napi_register__u64_array_to_array_327']?.() + __napiInstance.exports['__napi_register__i64_array_to_array_328']?.() + __napiInstance.exports['__napi_register__accept_uint8_clamped_slice_329']?.() + __napiInstance.exports['__napi_register__accept_uint8_clamped_slice_and_buffer_slice_330']?.() + __napiInstance.exports['__napi_register__AsyncBuffer_impl_331']?.() + __napiInstance.exports['__napi_register__async_reduce_buffer_332']?.() + __napiInstance.exports['__napi_register__async_buffer_to_array_333']?.() } module.exports.Animal = __napiModule.exports.Animal module.exports.AnimalWithDefaultConstructor = __napiModule.exports.AnimalWithDefaultConstructor @@ -403,6 +409,7 @@ module.exports.bigintFromI128 = __napiModule.exports.bigintFromI128 module.exports.bigintFromI64 = __napiModule.exports.bigintFromI64 module.exports.bigintGetU64AsString = __napiModule.exports.bigintGetU64AsString module.exports.bufferPassThrough = __napiModule.exports.bufferPassThrough +module.exports.buildThreadsafeFunctionFromFunction = __napiModule.exports.buildThreadsafeFunctionFromFunction module.exports.call0 = __napiModule.exports.call0 module.exports.call1 = __napiModule.exports.call1 module.exports.call2 = __napiModule.exports.call2 @@ -442,6 +449,7 @@ module.exports.derefUint8Array = __napiModule.exports.derefUint8Array module.exports.either3 = __napiModule.exports.either3 module.exports.either4 = __napiModule.exports.either4 module.exports.eitherBoolOrFunction = __napiModule.exports.eitherBoolOrFunction +module.exports.eitherBoolOrTuple = __napiModule.exports.eitherBoolOrTuple module.exports.eitherFromObjects = __napiModule.exports.eitherFromObjects module.exports.eitherFromOption = __napiModule.exports.eitherFromOption module.exports.eitherStringOrNumber = __napiModule.exports.eitherStringOrNumber @@ -479,6 +487,7 @@ module.exports.listObjKeys = __napiModule.exports.listObjKeys module.exports.mapOption = __napiModule.exports.mapOption module.exports.mutateExternal = __napiModule.exports.mutateExternal module.exports.mutateTypedArray = __napiModule.exports.mutateTypedArray +module.exports.objectGetNamedPropertyShouldPerformTypecheck = __napiModule.exports.objectGetNamedPropertyShouldPerformTypecheck module.exports.optionEnd = __napiModule.exports.optionEnd module.exports.optionOnly = __napiModule.exports.optionOnly module.exports.optionStart = __napiModule.exports.optionStart @@ -505,6 +514,7 @@ module.exports.returnEitherClass = __napiModule.exports.returnEitherClass module.exports.returnFromSharedCrate = __napiModule.exports.returnFromSharedCrate module.exports.returnJsFunction = __napiModule.exports.returnJsFunction module.exports.returnNull = __napiModule.exports.returnNull +module.exports.returnObjectOnlyToJs = __napiModule.exports.returnObjectOnlyToJs module.exports.returnUndefined = __napiModule.exports.returnUndefined module.exports.returnUndefinedIfInvalid = __napiModule.exports.returnUndefinedIfInvalid module.exports.returnUndefinedIfInvalidPromise = __napiModule.exports.returnUndefinedIfInvalidPromise @@ -512,6 +522,7 @@ module.exports.roundtripStr = __napiModule.exports.roundtripStr module.exports.runScript = __napiModule.exports.runScript module.exports.setSymbolInObj = __napiModule.exports.setSymbolInObj module.exports.Status = __napiModule.exports.Status +module.exports.StringEnum = __napiModule.exports.StringEnum module.exports.sumBtreeMapping = __napiModule.exports.sumBtreeMapping module.exports.sumIndexMapping = __napiModule.exports.sumIndexMapping module.exports.sumMapping = __napiModule.exports.sumMapping diff --git a/examples/napi/wasi-worker.mjs b/examples/napi/wasi-worker.mjs index 11e930b1..4824a274 100644 --- a/examples/napi/wasi-worker.mjs +++ b/examples/napi/wasi-worker.mjs @@ -1,11 +1,12 @@ import fs from "node:fs"; import { createRequire } from "node:module"; +import { WASI } from "node:wasi"; import { parentPort, Worker } from "node:worker_threads"; -import { instantiateNapiModuleSync, MessageHandler, WASI } from "@napi-rs/wasm-runtime"; - const require = createRequire(import.meta.url); +const { instantiateNapiModuleSync, MessageHandler, getDefaultContext } = require("@napi-rs/wasm-runtime"); + if (parentPort) { parentPort.on("message", (data) => { globalThis.onmessage({ data }); @@ -26,13 +27,22 @@ Object.assign(globalThis, { }, }); +const emnapiContext = getDefaultContext() + const handler = new MessageHandler({ onLoad({ wasmModule, wasmMemory }) { - const wasi = new WASI({ fs }); + const wasi = new WASI({ + version: 'preview1', + env: process.env, + preopens: { + '/': '/', + }, + }); return instantiateNapiModuleSync(wasmModule, { childThread: true, wasi, + context: emnapiContext, overwriteImports(importObject) { importObject.env = { ...importObject.env,