diff --git a/core/src/wasm.cpp b/core/src/wasm.cpp index 1f0f383feed..6289bf35f92 100644 --- a/core/src/wasm.cpp +++ b/core/src/wasm.cpp @@ -340,6 +340,23 @@ km_core_state_get_actions_wasm(km_core_state const *state) { return actions_wasm; } +int +km_core_state_options_update_wasm( + km_core_state const *state, + const std::vector& new_options +) { + km_core_option_item* options_c = new km_core_option_item[new_options.size() + 1]; + for (size_t i = 0; i < new_options.size(); ++i) { + options_c[i].key = new_options[i].key.c_str(); + options_c[i].value = new_options[i].value.c_str(); + options_c[i].scope = new_options[i].scope; + } + options_c[new_options.size()] = KM_CORE_OPTIONS_END; + km_core_status status = km_core_state_options_update(const_cast(state), options_c); + delete[] options_c; + return status; +} + const CoreReturn* km_core_context_get_wasm( km_core_context const* context @@ -484,6 +501,8 @@ EMSCRIPTEN_BINDINGS(core_interface) { em::function("state_get_actions(state)", &km_core_state_get_actions_wasm, em::allow_raw_pointers()); + em::function("state_options_update(state, new_options)", &km_core_state_options_update_wasm, em::allow_raw_pointers()); + em::function("context_get(context)", &km_core_context_get_wasm, em::allow_raw_pointers()); em::function("context_set(context, context_items)", &km_core_context_set_wasm, em::allow_raw_pointers()); } diff --git a/web/src/engine/src/core-adapter/index.ts b/web/src/engine/src/core-adapter/index.ts index 9052d97a9d0..f5a4ff2c785 100644 --- a/web/src/engine/src/core-adapter/index.ts +++ b/web/src/engine/src/core-adapter/index.ts @@ -1,3 +1,3 @@ export { KM_Core, KM_CORE_STATUS, KM_CORE_OPTION_SCOPE, KM_CORE_KMX_ENV, KM_CORE_CT } from './KM_Core.js'; -import { type km_core_keyboard, type km_core_state, type km_core_context, type km_core_context_item, type km_core_context_items } from './import/core/keymancore.js'; -export { km_core_keyboard, km_core_state, km_core_context, km_core_context_item, km_core_context_items }; +import { type km_core_keyboard, type km_core_state, type km_core_context, type km_core_context_item, type km_core_context_items, type km_core_option_item } from './import/core/keymancore.js'; +export { km_core_keyboard, km_core_state, km_core_context, km_core_context_item, km_core_context_items, km_core_option_item };