mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-04-03 16:10:29 +00:00
Adds PromiseRectionCallback
Fires the window.onunhandledrejection. This API is a bit different than everything else, because it's entered from the Isolate/Env. So there's a bit more js -> webapi awareness baked into Env now to handle it. Also touched up existing Events that have .Global data and changed it to .Temp and cleaned it up in their deinit.
This commit is contained in:
@@ -323,6 +323,7 @@ pub fn zigValueToJs(self: *const Local, value: anytype, comptime opts: CallOpts)
|
||||
js.Value.Temp,
|
||||
js.Object.Global,
|
||||
js.Promise.Global,
|
||||
js.Promise.Temp,
|
||||
js.PromiseResolver.Global,
|
||||
js.Module.Global => return .{ .local = self, .handle = @ptrCast(value.local(self).handle) },
|
||||
else => {}
|
||||
@@ -619,15 +620,19 @@ fn jsValueToStruct(self: *const Local, comptime T: type, js_val: js.Value) !?T {
|
||||
return try obj.persist();
|
||||
},
|
||||
|
||||
js.Promise.Global => {
|
||||
js.Promise.Global, js.Promise.Temp => {
|
||||
if (!js_val.isPromise()) {
|
||||
return null;
|
||||
}
|
||||
const promise = js.Promise{
|
||||
.ctx = self,
|
||||
const js_promise = js.Promise{
|
||||
.local = self,
|
||||
.handle = @ptrCast(js_val.handle),
|
||||
};
|
||||
return try promise.persist();
|
||||
return switch (T) {
|
||||
js.Promise.Temp => try js_promise.temp(),
|
||||
js.Promise.Global => try js_promise.persist(),
|
||||
else => unreachable,
|
||||
};
|
||||
},
|
||||
string.String => {
|
||||
const js_str = js_val.isString() orelse return null;
|
||||
|
||||
Reference in New Issue
Block a user