Adopt global Types changes in jsruntime

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
Francis Bouvier
2024-01-10 11:56:53 +01:00
parent c812ff300a
commit a5dfa6cb44
20 changed files with 49 additions and 69 deletions

View File

@@ -5,6 +5,8 @@ const jsruntime = @import("jsruntime");
const parser = @import("netsurf.zig");
const DOM = @import("dom.zig");
pub const Types = jsruntime.reflect(DOM.Interfaces);
const socket_path = "/tmp/browsercore-server.sock";
var doc: *parser.DocumentHTML = undefined;
@@ -13,11 +15,10 @@ var server: std.net.StreamServer = undefined;
fn execJS(
alloc: std.mem.Allocator,
js_env: *jsruntime.Env,
comptime apis: []jsruntime.API,
) !void {
) anyerror!void {
// start JS env
try js_env.start(alloc, apis);
try js_env.start(alloc);
defer js_env.stop();
// alias global as self and window
@@ -25,7 +26,7 @@ fn execJS(
try js_env.attachObject(try js_env.getGlobal(), "window", null);
// add document object
try js_env.addObject(apis, doc, "document");
try js_env.addObject(doc, "document");
while (true) {
@@ -49,9 +50,6 @@ fn execJS(
pub fn main() !void {
// generate APIs
const apis = comptime jsruntime.compile(DOM.Interfaces);
// create v8 vm
const vm = jsruntime.VM.init();
defer vm.deinit();
@@ -86,5 +84,5 @@ pub fn main() !void {
try server.listen(addr);
std.debug.print("Listening on: {s}...\n", .{socket_path});
try jsruntime.loadEnv(&arena, execJS, apis);
try jsruntime.loadEnv(&arena, execJS);
}