@@ -156,16 +156,16 @@ pub const Session = struct {
156156
157157 const ContextT = @TypeOf (ctx );
158158 const InspectorContainer = switch (@typeInfo (ContextT )) {
159- .Struct = > ContextT ,
160- .Pointer = > | ptr | ptr .child ,
161- .Void = > NoopInspector ,
159+ .@"struct" = > ContextT ,
160+ .pointer = > | ptr | ptr .child ,
161+ .void = > NoopInspector ,
162162 else = > @compileError ("invalid context type" ),
163163 };
164164
165165 // const ctx_opaque = @as(*anyopaque, @ptrCast(ctx));
166166 self .inspector = try jsruntime .Inspector .init (
167167 arena ,
168- self .env , // TODO: change to 'env' when https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
168+ & self .env ,
169169 if (@TypeOf (ctx ) == void ) @constCast (@ptrCast (&{})) else ctx ,
170170 InspectorContainer .onInspectorResponse ,
171171 InspectorContainer .onInspectorEvent ,
@@ -231,7 +231,7 @@ pub const Session = struct {
231231
232232 // load polyfills
233233 // TODO: change to 'env' when https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
234- try polyfill .load (self .arena .allocator (), self .env );
234+ try polyfill .load (self .arena .allocator (), & self .env );
235235
236236 // inspector
237237 self .contextCreated (page , aux_data );
@@ -264,7 +264,7 @@ pub const Session = struct {
264264
265265 fn contextCreated (self : * Session , page : * Page , aux_data : ? []const u8 ) void {
266266 log .debug ("inspector context created" , .{});
267- self .inspector .contextCreated (self .env , "" , page .origin orelse "://" , aux_data );
267+ self .inspector .contextCreated (& self .env , "" , page .origin orelse "://" , aux_data );
268268 }
269269};
270270
@@ -316,15 +316,15 @@ pub const Page = struct {
316316 pub fn wait (self : * Page ) ! void {
317317 // try catch
318318 var try_catch : jsruntime.TryCatch = undefined ;
319- try_catch .init (self .session .env );
319+ try_catch .init (& self .session .env );
320320 defer try_catch .deinit ();
321321
322322 self .session .env .wait () catch | err | {
323323 // the js env could not be started if the document wasn't an HTML.
324324 if (err == error .EnvNotStarted ) return ;
325325
326326 const arena = self .arena ;
327- if (try try_catch .err (arena , self .session .env )) | msg | {
327+ if (try try_catch .err (arena , & self .session .env )) | msg | {
328328 defer arena .free (msg );
329329 log .info ("wait error: {s}" , .{msg });
330330 return ;
@@ -591,9 +591,7 @@ pub const Page = struct {
591591 // TODO handle charset attribute
592592 const opt_text = try parser .nodeTextContent (parser .elementToNode (s .element ));
593593 if (opt_text ) | text | {
594- // TODO: change to &self.session.env when
595- // https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
596- try s .eval (self .arena , self .session .env , text );
594+ try s .eval (self .arena , & self .session .env , text );
597595 return ;
598596 }
599597
@@ -656,11 +654,8 @@ pub const Page = struct {
656654 // received.
657655 fn fetchScript (self : * const Page , s : * const Script ) ! void {
658656 const arena = self .arena ;
659-
660657 const body = try self .fetchData (arena , s .src , null );
661- // TODO: change to &self.session.env when
662- // https://github.com/lightpanda-io/zig-js-runtime/pull/285 lands
663- try s .eval (arena , self .session .env , body );
658+ try s .eval (arena , & self .session .env , body );
664659 }
665660
666661 const Script = struct {
@@ -683,9 +678,8 @@ pub const Page = struct {
683678
684679 return .{
685680 .element = e ,
686- .kind = kind (try parser .elementGetAttribute (e , "type" )),
681+ .kind = parseKind (try parser .elementGetAttribute (e , "type" )),
687682 .is_async = try parser .elementGetAttribute (e , "async" ) != null ,
688-
689683 .src = try parser .elementGetAttribute (e , "src" ) orelse "inline" ,
690684 };
691685 }
@@ -695,15 +689,15 @@ pub const Page = struct {
695689 // > type indicates that the script is a "classic script", containing
696690 // > JavaScript code.
697691 // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attribute_is_not_set_default_an_empty_string_or_a_javascript_mime_type
698- fn kind (stype : ? []const u8 ) Kind {
692+ fn parseKind (stype : ? []const u8 ) Kind {
699693 if (stype == null or stype .? .len == 0 ) return .javascript ;
700694 if (std .mem .eql (u8 , stype .? , "application/javascript" )) return .javascript ;
701695 if (std .mem .eql (u8 , stype .? , "module" )) return .module ;
702696
703697 return .unknown ;
704698 }
705699
706- fn eval (self : Script , arena : Allocator , env : Env , body : []const u8 ) ! void {
700+ fn eval (self : Script , arena : Allocator , env : * const Env , body : []const u8 ) ! void {
707701 var try_catch : jsruntime.TryCatch = undefined ;
708702 try_catch .init (env );
709703 defer try_catch .deinit ();
0 commit comments