mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-30 15:41:48 +00:00
get: upgrade jsruntime API changes
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
|
const Types = @import("root").Types;
|
||||||
|
|
||||||
const parser = @import("../netsurf.zig");
|
const parser = @import("../netsurf.zig");
|
||||||
const Loader = @import("loader.zig").Loader;
|
const Loader = @import("loader.zig").Loader;
|
||||||
const Dump = @import("dump.zig");
|
const Dump = @import("dump.zig");
|
||||||
@@ -8,10 +10,8 @@ const Mime = @import("mime.zig");
|
|||||||
const jsruntime = @import("jsruntime");
|
const jsruntime = @import("jsruntime");
|
||||||
const Loop = jsruntime.Loop;
|
const Loop = jsruntime.Loop;
|
||||||
const Env = jsruntime.Env;
|
const Env = jsruntime.Env;
|
||||||
const TPL = jsruntime.TPL;
|
|
||||||
|
|
||||||
const apiweb = @import("../apiweb.zig");
|
const apiweb = @import("../apiweb.zig");
|
||||||
const apis = jsruntime.compile(apiweb.Interfaces);
|
|
||||||
|
|
||||||
const Window = @import("../html/window.zig").Window;
|
const Window = @import("../html/window.zig").Window;
|
||||||
const Walker = @import("../dom/html_collection.zig").WalkerDepthFirst;
|
const Walker = @import("../dom/html_collection.zig").WalkerDepthFirst;
|
||||||
@@ -61,12 +61,12 @@ pub const Browser = struct {
|
|||||||
pub const Session = struct {
|
pub const Session = struct {
|
||||||
arena: std.heap.ArenaAllocator,
|
arena: std.heap.ArenaAllocator,
|
||||||
uri: []const u8,
|
uri: []const u8,
|
||||||
tpls: [apis.len]TPL = undefined,
|
|
||||||
|
|
||||||
// TODO handle proxy
|
// TODO handle proxy
|
||||||
loader: Loader = undefined,
|
loader: Loader = undefined,
|
||||||
env: Env = undefined,
|
env: Env = undefined,
|
||||||
loop: Loop = undefined,
|
loop: Loop = undefined,
|
||||||
|
jstypes: [Types.len]usize = undefined,
|
||||||
|
|
||||||
window: Window,
|
window: Window,
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ pub const Session = struct {
|
|||||||
self.loop = try Loop.init(aallocator);
|
self.loop = try Loop.init(aallocator);
|
||||||
self.env = try Env.init(aallocator, &self.loop);
|
self.env = try Env.init(aallocator, &self.loop);
|
||||||
|
|
||||||
try self.env.load(apis, &self.tpls);
|
try self.env.load(&self.jstypes);
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@@ -226,13 +226,13 @@ pub const Page = struct {
|
|||||||
|
|
||||||
// start JS env
|
// start JS env
|
||||||
log.debug("start js env", .{});
|
log.debug("start js env", .{});
|
||||||
try self.env.start(self.allocator, apis);
|
try self.env.start(self.allocator);
|
||||||
|
|
||||||
// add global objects
|
// add global objects
|
||||||
log.debug("setup global env", .{});
|
log.debug("setup global env", .{});
|
||||||
try self.env.addObject(apis, self.window, "window");
|
try self.env.addObject(self.window, "window");
|
||||||
try self.env.addObject(apis, self.window, "self");
|
try self.env.addObject(self.window, "self");
|
||||||
try self.env.addObject(apis, html_doc, "document");
|
try self.env.addObject(html_doc, "document");
|
||||||
|
|
||||||
// browse the DOM tree to retrieve scripts
|
// browse the DOM tree to retrieve scripts
|
||||||
var sasync = std.ArrayList(*parser.Element).init(self.allocator);
|
var sasync = std.ArrayList(*parser.Element).init(self.allocator);
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const Browser = @import("browser/browser.zig").Browser;
|
const Browser = @import("browser/browser.zig").Browser;
|
||||||
|
|
||||||
|
const jsruntime = @import("jsruntime");
|
||||||
|
const apiweb = @import("apiweb.zig");
|
||||||
|
pub const Types = jsruntime.reflect(apiweb.Interfaces);
|
||||||
|
|
||||||
pub const std_options = struct {
|
pub const std_options = struct {
|
||||||
pub const log_level = .debug;
|
pub const log_level = .debug;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user