@@ -6,6 +6,11 @@ pub const MemorySettings = extern struct {
66 max_allowed_memory_usage : usize ,
77};
88
9+ pub const SourceLocationBytes = extern struct {
10+ start : usize ,
11+ end : usize ,
12+ };
13+
914inline fn auto_disable () void {
1015 if (comptime bun .FeatureFlags .disable_lolhtml )
1116 unreachable ;
@@ -313,6 +318,7 @@ pub const TextChunk = opaque {
313318 extern fn lol_html_text_chunk_is_removed (chunk : * const TextChunk ) bool ;
314319 extern fn lol_html_text_chunk_user_data_set (chunk : * const TextChunk , user_data : ? * anyopaque ) void ;
315320 extern fn lol_html_text_chunk_user_data_get (chunk : * const TextChunk ) ? * anyopaque ;
321+ extern fn lol_html_text_chunk_source_location_bytes (chunk : * const TextChunk ) SourceLocationBytes ;
316322
317323 pub const Content = extern struct {
318324 ptr : [* ]const u8 ,
@@ -383,6 +389,10 @@ pub const TextChunk = opaque {
383389 auto_disable ();
384390 return @as (? * Type , @ptrCast (@alignCast (this .lol_html_text_chunk_user_data_get ())));
385391 }
392+ pub fn getSourceLocationBytes (this : * const TextChunk ) SourceLocationBytes {
393+ auto_disable ();
394+ return this .lol_html_text_chunk_source_location_bytes ();
395+ }
386396};
387397pub const Element = opaque {
388398 extern fn lol_html_element_get_attribute (element : * const Element , name : [* ]const u8 , name_len : usize ) HTMLString ;
@@ -404,6 +414,7 @@ pub const Element = opaque {
404414 extern fn lol_html_element_user_data_get (element : * const Element ) ? * anyopaque ;
405415 extern fn lol_html_element_add_end_tag_handler (element : * Element , end_tag_handler : lol_html_end_tag_handler_t , user_data : ? * anyopaque ) c_int ;
406416 extern fn lol_html_element_clear_end_tag_handlers (element : * Element ) void ;
417+ extern fn lol_html_element_source_location_bytes (element : * const Element ) SourceLocationBytes ;
407418
408419 pub fn getAttribute (element : * const Element , name : []const u8 ) HTMLString {
409420 auto_disable ();
@@ -554,6 +565,11 @@ pub const Element = opaque {
554565 pub fn attributes (element : * const Element ) ? * Attribute.Iterator {
555566 return lol_html_attributes_iterator_get (element );
556567 }
568+
569+ pub fn getSourceLocationBytes (element : * const Element ) SourceLocationBytes {
570+ auto_disable ();
571+ return lol_html_element_source_location_bytes (element );
572+ }
557573};
558574
559575pub const HTMLString = extern struct {
@@ -608,6 +624,7 @@ pub const EndTag = opaque {
608624 extern fn lol_html_end_tag_remove (end_tag : * EndTag ) void ;
609625 extern fn lol_html_end_tag_name_get (end_tag : * const EndTag ) HTMLString ;
610626 extern fn lol_html_end_tag_name_set (end_tag : * EndTag , name : [* ]const u8 , name_len : usize ) c_int ;
627+ extern fn lol_html_end_tag_source_location_bytes (end_tag : * const EndTag ) SourceLocationBytes ;
611628
612629 pub fn before (end_tag : * EndTag , content : []const u8 , is_html : bool ) Error ! void {
613630 auto_disable ();
@@ -644,6 +661,11 @@ pub const EndTag = opaque {
644661 else = > unreachable ,
645662 };
646663 }
664+
665+ pub fn getSourceLocationBytes (end_tag : * const EndTag ) SourceLocationBytes {
666+ auto_disable ();
667+ return lol_html_end_tag_source_location_bytes (end_tag );
668+ }
647669};
648670
649671pub const Attribute = opaque {
@@ -684,6 +706,7 @@ pub const Comment = opaque {
684706 extern fn lol_html_comment_is_removed (comment : * const Comment ) bool ;
685707 extern fn lol_html_comment_user_data_set (comment : * const Comment , user_data : ? * anyopaque ) void ;
686708 extern fn lol_html_comment_user_data_get (comment : * const Comment ) ? * anyopaque ;
709+ extern fn lol_html_comment_source_location_bytes (comment : * const Comment ) SourceLocationBytes ;
687710
688711 pub fn getText (comment : * const Comment ) HTMLString {
689712 auto_disable ();
@@ -728,6 +751,11 @@ pub const Comment = opaque {
728751
729752 pub const isRemoved = lol_html_comment_is_removed ;
730753 pub const remove = lol_html_comment_remove ;
754+
755+ pub fn getSourceLocationBytes (comment : * const Comment ) SourceLocationBytes {
756+ auto_disable ();
757+ return lol_html_comment_source_location_bytes (comment );
758+ }
731759};
732760
733761pub const Directive = enum (c_uint ) {
@@ -797,6 +825,7 @@ pub const DocType = opaque {
797825 extern fn lol_html_doctype_user_data_get (doctype : * const DocType ) ? * anyopaque ;
798826 extern fn lol_html_doctype_remove (doctype : * DocType ) void ;
799827 extern fn lol_html_doctype_is_removed (doctype : * const DocType ) bool ;
828+ extern fn lol_html_doctype_source_location_bytes (doctype : * const DocType ) SourceLocationBytes ;
800829
801830 pub const Callback = * const fn (* DocType , ? * anyopaque ) callconv (.C ) Directive ;
802831
@@ -820,6 +849,10 @@ pub const DocType = opaque {
820849 auto_disable ();
821850 return this .lol_html_doctype_is_removed ();
822851 }
852+ pub fn getSourceLocationBytes (this : * const DocType ) SourceLocationBytes {
853+ auto_disable ();
854+ return this .lol_html_doctype_source_location_bytes ();
855+ }
823856};
824857
825858pub const Encoding = enum {
0 commit comments