mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Adapt to js_exec changes in zig-js-runtime
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
committed by
Pierre Tachoire
parent
f8395fec5c
commit
b8ec53f708
18
src/main.zig
18
src/main.zig
@@ -37,7 +37,7 @@ fn execJS(
|
||||
js_env: *jsruntime.Env,
|
||||
) anyerror!void {
|
||||
// start JS env
|
||||
try js_env.start(alloc);
|
||||
try js_env.start();
|
||||
defer js_env.stop();
|
||||
|
||||
// alias global as self and window
|
||||
@@ -45,6 +45,11 @@ fn execJS(
|
||||
window.replaceDocument(doc);
|
||||
try js_env.bindGlobal(window);
|
||||
|
||||
// try catch
|
||||
var try_catch: jsruntime.TryCatch = undefined;
|
||||
try_catch.init(js_env.*);
|
||||
defer try_catch.deinit();
|
||||
|
||||
while (true) {
|
||||
|
||||
// read cmd
|
||||
@@ -57,11 +62,12 @@ fn execJS(
|
||||
break;
|
||||
}
|
||||
|
||||
const res = try js_env.execTryCatch(alloc, cmd, "cdp");
|
||||
if (res.success) {
|
||||
std.debug.print("-> {s}\n", .{res.result});
|
||||
}
|
||||
_ = try conn.stream.write(res.result);
|
||||
const res = try js_env.exec(cmd, "cdp");
|
||||
const res_str = try res.toString(alloc, js_env.*);
|
||||
defer alloc.free(res_str);
|
||||
std.debug.print("-> {s}\n", .{res_str});
|
||||
|
||||
_ = try conn.stream.write(res_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user