@@ -157,16 +157,16 @@ pub const Session = struct {
157157
158158 const ContextT = @TypeOf (ctx );
159159 const InspectorContainer = switch (@typeInfo (ContextT )) {
160- .Struct = > ContextT ,
161- .Pointer = > | ptr | ptr .child ,
162- .Void = > NoopInspector ,
160+ .@"struct" = > ContextT ,
161+ .pointer = > | ptr | ptr .child ,
162+ .void = > NoopInspector ,
163163 else = > @compileError ("invalid context type" ),
164164 };
165165
166166 // const ctx_opaque = @as(*anyopaque, @ptrCast(ctx));
167167 self .inspector = try jsruntime .Inspector .init (
168168 arena ,
169- self .env , // TODO: change to 'env' when https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
169+ & self .env ,
170170 if (@TypeOf (ctx ) == void ) @constCast (@ptrCast (&{})) else ctx ,
171171 InspectorContainer .onInspectorResponse ,
172172 InspectorContainer .onInspectorEvent ,
@@ -232,7 +232,7 @@ pub const Session = struct {
232232
233233 // load polyfills
234234 // TODO: change to 'env' when https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
235- try polyfill .load (self .arena .allocator (), self .env );
235+ try polyfill .load (self .arena .allocator (), & self .env );
236236
237237 // inspector
238238 self .contextCreated (page , aux_data );
@@ -265,7 +265,7 @@ pub const Session = struct {
265265
266266 fn contextCreated (self : * Session , page : * Page , aux_data : ? []const u8 ) void {
267267 log .debug ("inspector context created" , .{});
268- self .inspector .contextCreated (self .env , "" , page .origin orelse "://" , aux_data );
268+ self .inspector .contextCreated (& self .env , "" , page .origin orelse "://" , aux_data );
269269 }
270270};
271271
@@ -317,15 +317,15 @@ pub const Page = struct {
317317 pub fn wait (self : * Page ) ! void {
318318 // try catch
319319 var try_catch : jsruntime.TryCatch = undefined ;
320- try_catch .init (self .session .env );
320+ try_catch .init (& self .session .env );
321321 defer try_catch .deinit ();
322322
323323 self .session .env .wait () catch | err | {
324324 // the js env could not be started if the document wasn't an HTML.
325325 if (err == error .EnvNotStarted ) return ;
326326
327327 const arena = self .arena ;
328- if (try try_catch .err (arena , self .session .env )) | msg | {
328+ if (try try_catch .err (arena , & self .session .env )) | msg | {
329329 defer arena .free (msg );
330330 log .info ("wait error: {s}" , .{msg });
331331 return ;
@@ -592,9 +592,7 @@ pub const Page = struct {
592592 // TODO handle charset attribute
593593 const opt_text = try parser .nodeTextContent (parser .elementToNode (s .element ));
594594 if (opt_text ) | text | {
595- // TODO: change to &self.session.env when
596- // https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
597- try s .eval (self .arena , self .session .env , text );
595+ try s .eval (self .arena , & self .session .env , text );
598596 return ;
599597 }
600598
@@ -657,11 +655,8 @@ pub const Page = struct {
657655 // received.
658656 fn fetchScript (self : * const Page , s : * const Script ) ! void {
659657 const arena = self .arena ;
660-
661658 const body = try self .fetchData (arena , s .src , null );
662- // TODO: change to &self.session.env when
663- // https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
664- try s .eval (arena , self .session .env , body );
659+ try s .eval (arena , & self .session .env , body );
665660 }
666661
667662 const Script = struct {
@@ -684,9 +679,8 @@ pub const Page = struct {
684679
685680 return .{
686681 .element = e ,
687- .kind = kind (try parser .elementGetAttribute (e , "type" )),
682+ .kind = parseKind (try parser .elementGetAttribute (e , "type" )),
688683 .is_async = try parser .elementGetAttribute (e , "async" ) != null ,
689-
690684 .src = try parser .elementGetAttribute (e , "src" ) orelse "inline" ,
691685 };
692686 }
@@ -696,15 +690,15 @@ pub const Page = struct {
696690 // > type indicates that the script is a "classic script", containing
697691 // > JavaScript code.
698692 // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attribute_is_not_set_default_an_empty_string_or_a_javascript_mime_type
699- fn kind (stype : ? []const u8 ) Kind {
693+ fn parseKind (stype : ? []const u8 ) Kind {
700694 if (stype == null or stype .? .len == 0 ) return .javascript ;
701695 if (std .mem .eql (u8 , stype .? , "application/javascript" )) return .javascript ;
702696 if (std .mem .eql (u8 , stype .? , "module" )) return .module ;
703697
704698 return .unknown ;
705699 }
706700
707- fn eval (self : Script , arena : Allocator , env : Env , body : []const u8 ) ! void {
701+ fn eval (self : Script , arena : Allocator , env : * const Env , body : []const u8 ) ! void {
708702 var try_catch : jsruntime.TryCatch = undefined ;
709703 try_catch .init (env );
710704 defer try_catch .deinit ();
0 commit comments