Improve the debug ergonomics of the Env generic.

Previously, we were passing our WebAPIs directly as an anonymous tuple. This
resulted in Env(T) having an _awful_ name - a name composed of hundreds of
classes.

By wrapping the anonymous tuple into a normal struct, the Env now gets a sane
name which helps improve stack traces (and profiling, and debugging, ...)
This commit is contained in:
Karl Seguin
2025-05-03 17:34:31 +08:00
parent 7741de7ae0
commit 5f05de30a6
3 changed files with 40 additions and 24 deletions

View File

@@ -26,7 +26,7 @@ pub const allocator = std.testing.allocator;
// browser.Env or the browser.SessionState
pub fn Runner(comptime State: type, comptime Global: type, comptime types: anytype) type {
const AdjustedTypes = if (Global == void) generate.Tuple(.{ types, DefaultGlobal }) else types;
const Env = js.Env(State, AdjustedTypes{});
const Env = js.Env(State, struct {pub const Interfaces = AdjustedTypes;});
return struct {
env: *Env,