Lightpanda: the headless browser designed for AI and automation
v8, dep: Update v8
Karl Seguind550a893301e
diff --git a/build.zig.zon b/build.zig.zonindex b69d1ef42..e9d41446a 100644--- a/build.zig.zon+++ b/build.zig.zon@@ -5,7 +5,7 @@.minimum_zig_version = "0.15.2",.dependencies = .{.v8 = .{- .url = "https://github.com/lightpanda-io/zig-v8-fork/archive/refs/tags/v0.4.8.tar.gz",+ .url = "https://github.com/lightpanda-io/zig-v8-fork/archive/3a53a258e508ea6a805654a94339b9fd006e7b2d.tar.gz",.hash = "v8-0.0.0-xddH65qdBAA1hmB-gqEmhEzO0-aXKyEsmo1s34mssemb",},// .v8 = .{ .path = "../zig-v8-fork" },diff --git a/src/browser/js/Caller.zig b/src/browser/js/Caller.zigindex 48d24a780..8b2d782cc 100644--- a/src/browser/js/Caller.zig+++ b/src/browser/js/Caller.zig@@ -183,8 +183,7 @@ pub fn getIndex(self: *Caller, comptime T: type, func: anytype, idx: u32, handleconst info = PropertyCallbackInfo{ .handle = handle };return _getIndex(T, local, func, idx, info, opts) catch |err| {handleError(T, @TypeOf(func), local, err, info, opts);- // not intercepted- return 0;+ return 1;};}@@ -210,8 +209,7 @@ pub fn getNamedIndex(self: *Caller, comptime T: type, func: anytype, name: *consconst info = PropertyCallbackInfo{ .handle = handle };return _getNamedIndex(T, local, func, name, info, opts) catch |err| {handleError(T, @TypeOf(func), local, err, info, opts);- // not intercepted- return 0;+ return 1;};}@@ -237,8 +235,7 @@ pub fn setNamedIndex(self: *Caller, comptime T: type, func: anytype, name: *consconst info = PropertyCallbackInfo{ .handle = handle };return _setNamedIndex(T, local, func, name, .{ .local = &self.local, .handle = js_value }, info, opts) catch |err| {handleError(T, @TypeOf(func), local, err, info, opts);- // not intercepted- return 0;+ return 1;};}@@ -265,7 +262,7 @@ pub fn deleteNamedIndex(self: *Caller, comptime T: type, func: anytype, name: *cconst info = PropertyCallbackInfo{ .handle = handle };return _deleteNamedIndex(T, local, func, name, info, opts) catch |err| {handleError(T, @TypeOf(func), local, err, info, opts);- return 0;+ return 1;};}@@ -291,8 +288,7 @@ pub fn getEnumerator(self: *Caller, comptime T: type, func: anytype, handle: *coconst info = PropertyCallbackInfo{ .handle = handle };return _getEnumerator(T, local, func, info, opts) catch |err| {handleError(T, @TypeOf(func), local, err, info, opts);- // not intercepted- return 0;+ return 1;};}@@ -318,13 +314,11 @@ fn handleIndexedReturn(comptime T: type, comptime F: type, comptime with_value:// if error.NotHandled is part of the error set.if (isInErrorSet(error.NotHandled, eu.error_set)) {if (err == error.NotHandled) {- // not intercepted- return 0;+ return 1;}}handleError(T, F, local, err, info, opts);- // not intercepted- return 0;+ return 1;};},else => ret,@@ -333,8 +327,7 @@ fn handleIndexedReturn(comptime T: type, comptime F: type, comptime with_value:if (comptime with_value) {info.getReturnValue().set(try local.zigValueToJs(non_error_ret, opts));}- // intercepted- return 1;+ return 0;}fn isInErrorSet(err: anyerror, comptime T: type) bool {diff --git a/src/browser/js/Env.zig b/src/browser/js/Env.zigindex 4ba3d3dd3..3a37e8d4a 100644--- a/src/browser/js/Env.zig+++ b/src/browser/js/Env.zig@@ -581,8 +581,7 @@ fn promiseRejectCallback(message_handle: v8.PromiseRejectMessage) callconv(.c) vreturn;}- const promise_handle = v8.v8__PromiseRejectMessage__GetPromise(&message_handle).?;- const v8_isolate = v8.v8__Object__GetIsolate(@ptrCast(promise_handle)).?;+ const v8_isolate = v8.v8__Isolate__GetCurrent().?;const isolate = js.Isolate{ .handle = v8_isolate };const ctx, const v8_context = Context.fromIsolate(isolate) orelse return;diff --git a/src/browser/js/Module.zig b/src/browser/js/Module.zigindex 1e290d2d6..2a331ccbf 100644--- a/src/browser/js/Module.zig+++ b/src/browser/js/Module.zig@@ -46,7 +46,6 @@ pub fn getException(self: Module) js.Value {pub fn getModuleRequests(self: Module) Requests {return .{- .context_handle = self.local.handle,.handle = v8.v8__Module__GetModuleRequests(self.handle).?,};}@@ -117,14 +116,13 @@ pub const Global = struct {const Requests = struct {handle: *const v8.FixedArray,- context_handle: *const v8.Context,pub fn len(self: Requests) usize {return @intCast(v8.v8__FixedArray__Length(self.handle));}pub fn get(self: Requests, idx: usize) Request {- return .{ .handle = v8.v8__FixedArray__Get(self.handle, self.context_handle, @intCast(idx)).? };+ return .{ .handle = v8.v8__FixedArray__Get(self.handle, @intCast(idx)).? };}};diff --git a/src/browser/js/Snapshot.zig b/src/browser/js/Snapshot.zigindex d0d606bbf..a1cfd9d2e 100644--- a/src/browser/js/Snapshot.zig+++ b/src/browser/js/Snapshot.zig@@ -798,6 +798,7 @@ fn attachClass(comptime JsApi: type, comptime flatten: bool, isolate: *v8.Isolat.deleter = null,.definer = null,.descriptor = null,+ .index_of = null,.data = null,.flags = 0,};diff --git a/src/browser/js/bridge.zig b/src/browser/js/bridge.zigindex 0afc1c85e..43db4ff34 100644--- a/src/browser/js/bridge.zig+++ b/src/browser/js/bridge.zig@@ -275,7 +275,7 @@ pub const Indexed = struct {const v8_isolate = v8.v8__PropertyCallbackInfo__GetIsolate(handle).?;var caller: Caller = undefined;if (!caller.init(v8_isolate)) {- return 0;+ return 1;}defer caller.deinit();@@ -293,7 +293,7 @@ pub const Indexed = struct {const v8_isolate = v8.v8__PropertyCallbackInfo__GetIsolate(handle).?;var caller: Caller = undefined;if (!caller.init(v8_isolate)) {- return 0;+ return 1;}defer caller.deinit();return caller.getEnumerator(T, enumerator, handle.?, .{});@@ -325,7 +325,7 @@ pub const NamedIndexed = struct {const v8_isolate = v8.v8__PropertyCallbackInfo__GetIsolate(handle).?;var caller: Caller = undefined;if (!caller.init(v8_isolate)) {- return 0;+ return 1;}defer caller.deinit();@@ -341,7 +341,7 @@ pub const NamedIndexed = struct {const v8_isolate = v8.v8__PropertyCallbackInfo__GetIsolate(handle).?;var caller: Caller = undefined;if (!caller.init(v8_isolate)) {- return 0;+ return 1;}defer caller.deinit();@@ -369,7 +369,7 @@ pub const NamedIndexed = struct {const v8_isolate = v8.v8__PropertyCallbackInfo__GetIsolate(handle).?;var caller: Caller = undefined;if (!caller.init(v8_isolate)) {- return 0;+ return 1;}defer caller.deinit();@@ -486,8 +486,8 @@ pub fn unknownWindowPropertyCallback(c_name: ?*const v8.Name, handle: ?*const v8// During snapshot creation, there's no Context in embedder data yet.// I hate this check, but there doesn't seem to be a way to add this method// to the global, without triggering it during snapshot creation.- const v8_context = v8.v8__Isolate__GetCurrentContext(v8_isolate) orelse return 0;- const ctx: *Context = @ptrCast(@alignCast(v8.v8__Context__GetAlignedPointerFromEmbedderData(v8_context, 1) orelse return 0));+ const v8_context = v8.v8__Isolate__GetCurrentContext(v8_isolate) orelse return 1;+ const ctx: *Context = @ptrCast(@alignCast(v8.v8__Context__GetAlignedPointerFromEmbedderData(v8_context, 1) orelse return 1));var caller: Caller = undefined;caller.initWithContext(ctx, v8_context);@@ -500,7 +500,7 @@ pub fn unknownWindowPropertyCallback(c_name: ?*const v8.Name, handle: ?*const v8defer hs.deinit();const property: []const u8 = js.String.toSlice(.{ .local = local, .handle = @ptrCast(c_name.?) }) catch {- return 0;+ return 1;};// Only Page contexts have document.getElementById lookup@@ -508,10 +508,10 @@ pub fn unknownWindowPropertyCallback(c_name: ?*const v8.Name, handle: ?*const v8.frame => |frame| {const document = frame.document;if (document.getElementById(property, frame)) |el| {- const js_val = local.zigValueToJs(el, .{}) catch return 0;+ const js_val = local.zigValueToJs(el, .{}) catch return 1;var pc = Caller.PropertyCallbackInfo{ .handle = handle.? };pc.getReturnValue().set(js_val);- return 1;+ return 0;}},.worker => {}, // no global lookup in a worker@@ -521,7 +521,7 @@ pub fn unknownWindowPropertyCallback(c_name: ?*const v8.Name, handle: ?*const v8if (std.mem.startsWith(u8, property, "__")) {// some frameworks will extend built-in types using a __ prefix// these should always be safe to ignore.- return 0;+ return 1;}const ignored = std.StaticStringMap(void).initComptime(.{@@ -553,13 +553,12 @@ pub fn unknownWindowPropertyCallback(c_name: ?*const v8.Name, handle: ?*const v8});if (!ignored.has(property)) {var buf: [2048]u8 = undefined;- const key = std.fmt.bufPrint(&buf, "Window:{s}", .{property}) catch return 0;- logUnknownProperty(local, key) catch return 0;+ const key = std.fmt.bufPrint(&buf, "Window:{s}", .{property}) catch return 1;+ logUnknownProperty(local, key) catch return 1;}}- // not intercepted- return 0;+ return 1;}// Only used for debugging@@ -574,7 +573,7 @@ pub fn unknownObjectPropertyCallback(comptime JsApi: type) *const fn (?*const v8var caller: Caller = undefined;if (!caller.init(v8_isolate)) {- return 0;+ return 1;}defer caller.deinit();@@ -585,45 +584,44 @@ pub fn unknownObjectPropertyCallback(comptime JsApi: type) *const fn (?*const v8defer hs.deinit();const property: []const u8 = js.String.toSlice(.{ .local = local, .handle = @ptrCast(c_name.?) }) catch {- return 0;+ return 1;};if (std.mem.startsWith(u8, property, "__")) {// some frameworks will extend built-in types using a __ prefix// these should always be safe to ignore.- return 0;+ return 1;}if (std.mem.startsWith(u8, property, "jQuery")) {- return 0;+ return 1;}if (JsApi == @import("../webapi/cdata/Text.zig").JsApi or JsApi == @import("../webapi/cdata/Comment.zig").JsApi) {if (std.mem.eql(u8, property, "tagName")) {// knockout does this, a lot.- return 0;+ return 1;}}if (JsApi == @import("../webapi/element/Html.zig").JsApi or JsApi == @import("../webapi/Element.zig").JsApi or JsApi == @import("../webapi/element/html/Custom.zig").JsApi) {// react ?- if (std.mem.eql(u8, property, "props")) return 0;- if (std.mem.eql(u8, property, "hydrated")) return 0;- if (std.mem.eql(u8, property, "isHydrated")) return 0;+ if (std.mem.eql(u8, property, "props")) return 1;+ if (std.mem.eql(u8, property, "hydrated")) return 1;+ if (std.mem.eql(u8, property, "isHydrated")) return 1;}if (JsApi == @import("../webapi/Console.zig").JsApi) {- if (std.mem.eql(u8, property, "firebug")) return 0;+ if (std.mem.eql(u8, property, "firebug")) return 1;}const ignored = std.StaticStringMap(void).initComptime(.{});if (!ignored.has(property)) {var buf: [2048]u8 = undefined;- const key = std.fmt.bufPrint(&buf, "{s}:{s}", .{ if (@hasDecl(JsApi.Meta, "name")) JsApi.Meta.name else @typeName(JsApi), property }) catch return 0;- logUnknownProperty(local, key) catch return 0;+ const key = std.fmt.bufPrint(&buf, "{s}:{s}", .{ if (@hasDecl(JsApi.Meta, "name")) JsApi.Meta.name else @typeName(JsApi), property }) catch return 1;+ logUnknownProperty(local, key) catch return 1;}- // not intercepted- return 0;+ return 1;}}.wrap;}