diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-07-27 20:21:07 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-07-27 20:27:42 +0530 |
| commit | 8604765c3660dbea9cae6996d5750bfb985e6751 (patch) | |
| tree | 3a90f68dd07f8eb6a9c92d1f322162ac3b345383 /src/LuaRuntimeApi.hpp | |
| parent | c95ee83c24b79e64a91a6d3a55addcb6e7ebd11b (diff) | |
| download | null-browser-8604765c3660dbea9cae6996d5750bfb985e6751.tar.gz null-browser-8604765c3660dbea9cae6996d5750bfb985e6751.zip | |
Add web.view.run_js + change rpc js api
Diffstat (limited to '')
| -rw-r--r-- | src/LuaRuntimeApi.hpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/LuaRuntimeApi.hpp b/src/LuaRuntimeApi.hpp index 2dcba15..28ffd5f 100644 --- a/src/LuaRuntimeApi.hpp +++ b/src/LuaRuntimeApi.hpp @@ -47,6 +47,14 @@ int lua_api_view_set_html(lua_State *state) { return 1; } +int lua_api_view_run_js(lua_State *state) { + const char *js_code = lua_tostring(state, 1); + WebViewId view_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); + auto &runtime = LuaRuntime::instance(); + emit runtime.webview_js_eval_requested(js_code, view_id); + return 1; +} + int lua_api_view_create(lua_State *state) { const char *url = luaL_optstring(state, 1, ""); auto &runtime = LuaRuntime::instance(); @@ -377,6 +385,7 @@ static luaL_Reg internals_api[] = { luaL_Reg{"view_select", &lua_view_select}, luaL_Reg{"view_set_url", &lua_api_view_set_url}, luaL_Reg{"view_set_html", &lua_api_view_set_html}, + luaL_Reg{"view_run_js", &lua_api_view_run_js}, luaL_Reg{"view_open_devtools", &lua_api_view_open_devtools}, luaL_Reg{"view_scroll", &lua_api_view_scroll}, luaL_Reg{"view_scroll_to_top", &lua_api_view_scroll_top}, |
