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

@@ -7,16 +7,17 @@ const DOM = @import("dom.zig");
const html_test = @import("html_test.zig").html;
pub const Types = jsruntime.reflect(DOM.Interfaces);
var doc: *parser.DocumentHTML = 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
@@ -24,17 +25,14 @@ 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");
// launch shellExec
try jsruntime.shellExec(alloc, js_env, apis);
try jsruntime.shellExec(alloc, js_env);
}
pub fn main() !void {
// generate APIs
const apis = comptime jsruntime.compile(DOM.Interfaces);
// allocator
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
@@ -55,5 +53,5 @@ pub fn main() !void {
defer vm.deinit();
// launch shell
try jsruntime.shell(&arena, apis, execJS, .{ .app_name = "browsercore" });
try jsruntime.shell(&arena, execJS, .{ .app_name = "browsercore" });
}