mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 15:58:57 +00:00
PerformanceObserver.supportedEntryTypes
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
.fingerprint = 0xda130f3af836cea0,
|
.fingerprint = 0xda130f3af836cea0,
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.v8 = .{
|
.v8 = .{
|
||||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/beb187f3337a8c458e1917dc0105003fb7ae1b2f.tar.gz",
|
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/0d19781ccec829640e4f07591cbc166fa7dbe139.tar.gz",
|
||||||
.hash = "v8-0.0.0-xddH6x_gAwAgDtdWGHjv52NsW07MQnfpUQDpZn7RR43Y",
|
.hash = "v8-0.0.0-xddH6wTgAwALFCYoZbUIqtsRyP6mr69N7aKT_cySHKN2",
|
||||||
},
|
},
|
||||||
//.v8 = .{ .path = "../zig-v8-fork" }
|
//.v8 = .{ .path = "../zig-v8-fork" }
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -196,9 +196,15 @@ fn promiseRejectCallback(v8_msg: v8.C_PromiseRejectMessage) callconv(.c) void {
|
|||||||
const context = Context.fromIsolate(isolate);
|
const context = Context.fromIsolate(isolate);
|
||||||
|
|
||||||
const value =
|
const value =
|
||||||
if (msg.getValue()) |v8_value| context.valueToString(v8_value, .{}) catch |err| @errorName(err) else "no value";
|
if (msg.getValue()) |v8_value|
|
||||||
|
context.valueToString(v8_value, .{}) catch |err| @errorName(err)
|
||||||
|
else "no value"
|
||||||
|
;
|
||||||
|
|
||||||
log.debug(.js, "unhandled rejection", .{ .value = value });
|
log.debug(.js, "unhandled rejection", .{
|
||||||
|
.value = value,
|
||||||
|
.stack = context.stackTrace() catch |err| @errorName(err) orelse "???"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give it a Zig struct, get back a v8.FunctionTemplate.
|
// Give it a Zig struct, get back a v8.FunctionTemplate.
|
||||||
@@ -232,8 +238,13 @@ pub fn attachClass(comptime JsApi: type, isolate: v8.Isolate, template: v8.Funct
|
|||||||
const js_name = v8.String.initUtf8(isolate, name).toName();
|
const js_name = v8.String.initUtf8(isolate, name).toName();
|
||||||
const getter_callback = v8.FunctionTemplate.initCallback(isolate, value.getter);
|
const getter_callback = v8.FunctionTemplate.initCallback(isolate, value.getter);
|
||||||
if (value.setter == null) {
|
if (value.setter == null) {
|
||||||
template_proto.setAccessorGetter(js_name, getter_callback);
|
if (value.static) {
|
||||||
|
template.setAccessorGetter(js_name, getter_callback);
|
||||||
} else {
|
} else {
|
||||||
|
template_proto.setAccessorGetter(js_name, getter_callback);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std.debug.assert(value.static == false);
|
||||||
const setter_callback = v8.FunctionTemplate.initCallback(isolate, value.setter);
|
const setter_callback = v8.FunctionTemplate.initCallback(isolate, value.setter);
|
||||||
template_proto.setAccessorGetterAndSetter(js_name, getter_callback, setter_callback);
|
template_proto.setAccessorGetterAndSetter(js_name, getter_callback, setter_callback);
|
||||||
}
|
}
|
||||||
@@ -265,8 +276,11 @@ pub fn attachClass(comptime JsApi: type, isolate: v8.Isolate, template: v8.Funct
|
|||||||
const js_name = v8.Symbol.getIterator(isolate).toName();
|
const js_name = v8.Symbol.getIterator(isolate).toName();
|
||||||
template_proto.set(js_name, function_template, v8.PropertyAttribute.None);
|
template_proto.set(js_name, function_template, v8.PropertyAttribute.None);
|
||||||
},
|
},
|
||||||
bridge.Property.Int => {
|
bridge.Property => {
|
||||||
const js_value = js.simpleZigValueToJs(isolate, value.int, true, false);
|
const js_value = switch (value) {
|
||||||
|
.int => |v| js.simpleZigValueToJs(isolate, v, true, false),
|
||||||
|
};
|
||||||
|
|
||||||
const js_name = v8.String.initUtf8(isolate, name).toName();
|
const js_name = v8.String.initUtf8(isolate, name).toName();
|
||||||
// apply it both to the type itself
|
// apply it both to the type itself
|
||||||
template.set(js_name, js_value, v8.PropertyAttribute.ReadOnly + v8.PropertyAttribute.DontDelete);
|
template.set(js_name, js_value, v8.PropertyAttribute.ReadOnly + v8.PropertyAttribute.DontDelete);
|
||||||
|
|||||||
@@ -57,8 +57,12 @@ pub fn Builder(comptime T: type) type {
|
|||||||
return Callable.init(T, func, opts);
|
return Callable.init(T, func, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn property(value: anytype) Property.GetType(@TypeOf(value)) {
|
pub fn property(value: anytype) Property {
|
||||||
return Property.GetType(@TypeOf(value)).init(value);
|
switch (@typeInfo(@TypeOf(value))) {
|
||||||
|
.comptime_int, .int => return .{.int = value},
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
|
@compileError("Property for " ++ @typeName(@TypeOf(value)) ++ " hasn't been defined yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prototypeChain() [prototypeChainLength(T)]js.PrototypeChainEntry {
|
pub fn prototypeChain() [prototypeChainLength(T)]js.PrototypeChainEntry {
|
||||||
@@ -146,17 +150,22 @@ pub const Function = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub const Accessor = struct {
|
pub const Accessor = struct {
|
||||||
|
static: bool = false,
|
||||||
getter: ?*const fn (?*const v8.C_FunctionCallbackInfo) callconv(.c) void = null,
|
getter: ?*const fn (?*const v8.C_FunctionCallbackInfo) callconv(.c) void = null,
|
||||||
setter: ?*const fn (?*const v8.C_FunctionCallbackInfo) callconv(.c) void = null,
|
setter: ?*const fn (?*const v8.C_FunctionCallbackInfo) callconv(.c) void = null,
|
||||||
|
|
||||||
const Opts = struct {
|
const Opts = struct {
|
||||||
|
static: bool = false,
|
||||||
cache: ?[]const u8 = null, // @ZIGDOM
|
cache: ?[]const u8 = null, // @ZIGDOM
|
||||||
as_typed_array: bool = false,
|
as_typed_array: bool = false,
|
||||||
null_as_undefined: bool = false,
|
null_as_undefined: bool = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn init(comptime T: type, comptime getter: anytype, comptime setter: anytype, comptime opts: Opts) Accessor {
|
fn init(comptime T: type, comptime getter: anytype, comptime setter: anytype, comptime opts: Opts) Accessor {
|
||||||
var accessor = Accessor{};
|
var accessor = Accessor{
|
||||||
|
.static = opts.static,
|
||||||
|
};
|
||||||
|
|
||||||
if (@typeInfo(@TypeOf(getter)) != .null) {
|
if (@typeInfo(@TypeOf(getter)) != .null) {
|
||||||
accessor.getter = struct {
|
accessor.getter = struct {
|
||||||
fn wrap(raw_info: ?*const v8.C_FunctionCallbackInfo) callconv(.c) void {
|
fn wrap(raw_info: ?*const v8.C_FunctionCallbackInfo) callconv(.c) void {
|
||||||
@@ -321,20 +330,8 @@ pub const Callable = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Property = struct {
|
pub const Property = union(enum) {
|
||||||
fn GetType(comptime T: type) type {
|
|
||||||
switch (@typeInfo(T)) {
|
|
||||||
.comptime_int, .int => return Int,
|
|
||||||
else => @compileError("Property for " ++ @typeName(T) ++ " hasn't been defined yet"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const Int = struct {
|
|
||||||
int: i64,
|
int: i64,
|
||||||
pub fn init(value: i64) Int {
|
|
||||||
return .{ .int = value };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Given a Type, returns the length of the prototype chain, including self
|
// Given a Type, returns the length of the prototype chain, including self
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ pub fn takeRecords(_: *const PerformanceObserver) []const Entry {
|
|||||||
return &.{};
|
return &.{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getSupportedEntryTypes(_: *const PerformanceObserver) [][]const u8 {
|
||||||
|
return &.{};
|
||||||
|
}
|
||||||
|
|
||||||
pub const JsApi = struct {
|
pub const JsApi = struct {
|
||||||
pub const bridge = js.Bridge(PerformanceObserver);
|
pub const bridge = js.Bridge(PerformanceObserver);
|
||||||
|
|
||||||
@@ -64,4 +68,5 @@ pub const JsApi = struct {
|
|||||||
pub const observe = bridge.function(PerformanceObserver.observe, .{});
|
pub const observe = bridge.function(PerformanceObserver.observe, .{});
|
||||||
pub const disconnect = bridge.function(PerformanceObserver.disconnect, .{});
|
pub const disconnect = bridge.function(PerformanceObserver.disconnect, .{});
|
||||||
pub const takeRecords = bridge.function(PerformanceObserver.takeRecords, .{});
|
pub const takeRecords = bridge.function(PerformanceObserver.takeRecords, .{});
|
||||||
|
pub const supportedEntryTypes = bridge.accessor(PerformanceObserver.getSupportedEntryTypes, null, .{.static = true});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user