mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-14 23:38:57 +00:00
PerformanceObserver.supportedEntryTypes
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
.fingerprint = 0xda130f3af836cea0,
|
||||
.dependencies = .{
|
||||
.v8 = .{
|
||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/beb187f3337a8c458e1917dc0105003fb7ae1b2f.tar.gz",
|
||||
.hash = "v8-0.0.0-xddH6x_gAwAgDtdWGHjv52NsW07MQnfpUQDpZn7RR43Y",
|
||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/0d19781ccec829640e4f07591cbc166fa7dbe139.tar.gz",
|
||||
.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 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.
|
||||
@@ -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 getter_callback = v8.FunctionTemplate.initCallback(isolate, value.getter);
|
||||
if (value.setter == null) {
|
||||
template_proto.setAccessorGetter(js_name, getter_callback);
|
||||
if (value.static) {
|
||||
template.setAccessorGetter(js_name, getter_callback);
|
||||
} else {
|
||||
template_proto.setAccessorGetter(js_name, getter_callback);
|
||||
}
|
||||
} else {
|
||||
std.debug.assert(value.static == false);
|
||||
const setter_callback = v8.FunctionTemplate.initCallback(isolate, value.setter);
|
||||
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();
|
||||
template_proto.set(js_name, function_template, v8.PropertyAttribute.None);
|
||||
},
|
||||
bridge.Property.Int => {
|
||||
const js_value = js.simpleZigValueToJs(isolate, value.int, true, false);
|
||||
bridge.Property => {
|
||||
const js_value = switch (value) {
|
||||
.int => |v| js.simpleZigValueToJs(isolate, v, true, false),
|
||||
};
|
||||
|
||||
const js_name = v8.String.initUtf8(isolate, name).toName();
|
||||
// apply it both to the type itself
|
||||
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);
|
||||
}
|
||||
|
||||
pub fn property(value: anytype) Property.GetType(@TypeOf(value)) {
|
||||
return Property.GetType(@TypeOf(value)).init(value);
|
||||
pub fn property(value: anytype) Property {
|
||||
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 {
|
||||
@@ -146,17 +150,22 @@ pub const Function = struct {
|
||||
};
|
||||
|
||||
pub const Accessor = struct {
|
||||
static: bool = false,
|
||||
getter: ?*const fn (?*const v8.C_FunctionCallbackInfo) callconv(.c) void = null,
|
||||
setter: ?*const fn (?*const v8.C_FunctionCallbackInfo) callconv(.c) void = null,
|
||||
|
||||
const Opts = struct {
|
||||
static: bool = false,
|
||||
cache: ?[]const u8 = null, // @ZIGDOM
|
||||
as_typed_array: bool = false,
|
||||
null_as_undefined: bool = false,
|
||||
};
|
||||
|
||||
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) {
|
||||
accessor.getter = struct {
|
||||
fn wrap(raw_info: ?*const v8.C_FunctionCallbackInfo) callconv(.c) void {
|
||||
@@ -321,20 +330,8 @@ pub const Callable = struct {
|
||||
}
|
||||
};
|
||||
|
||||
pub const Property = struct {
|
||||
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,
|
||||
pub fn init(value: i64) Int {
|
||||
return .{ .int = value };
|
||||
}
|
||||
};
|
||||
pub const Property = union(enum) {
|
||||
int: i64,
|
||||
};
|
||||
|
||||
// Given a Type, returns the length of the prototype chain, including self
|
||||
|
||||
@@ -49,6 +49,10 @@ pub fn takeRecords(_: *const PerformanceObserver) []const Entry {
|
||||
return &.{};
|
||||
}
|
||||
|
||||
pub fn getSupportedEntryTypes(_: *const PerformanceObserver) [][]const u8 {
|
||||
return &.{};
|
||||
}
|
||||
|
||||
pub const JsApi = struct {
|
||||
pub const bridge = js.Bridge(PerformanceObserver);
|
||||
|
||||
@@ -64,4 +68,5 @@ pub const JsApi = struct {
|
||||
pub const observe = bridge.function(PerformanceObserver.observe, .{});
|
||||
pub const disconnect = bridge.function(PerformanceObserver.disconnect, .{});
|
||||
pub const takeRecords = bridge.function(PerformanceObserver.takeRecords, .{});
|
||||
pub const supportedEntryTypes = bridge.accessor(PerformanceObserver.getSupportedEntryTypes, null, .{.static = true});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user