@@ -20,15 +20,15 @@ def default_config(config)
2020 config
2121 end
2222
23- def mermaids_to_images ( passed_config , src : '.' , dest : '.' , type : 'pdf' )
23+ def mermaids_to_images ( passed_config , src : '.' , dest : '.' , type : 'pdf' , timeout : 10_000 )
2424 config = default_config ( passed_config )
2525 Playwright . create ( playwright_cli_executable_path : config [ :playwright_path ] ) do |playwright |
26- playwright . chromium . launch ( headless : true ) do |browser |
26+ playwright . chromium . launch ( headless : true , timeout : timeout ) do |browser |
2727 page = browser . new_page
2828 Dir . glob ( File . join ( src , '*.html' ) ) . each do |entry |
2929 id = File . basename ( entry ) . sub ( '.html' , '' )
30- page . goto ( "file:///#{ File . absolute_path ( entry ) } " )
31- page . locator ( 'svg' ) . wait_for ( state : 'visible' )
30+ page . goto ( "file:///#{ File . absolute_path ( entry ) } " , timeout : timeout )
31+ page . locator ( 'svg' ) . wait_for ( state : 'visible' , timeout : timeout )
3232 sleep ( 1 )
3333 1 . upto ( 4 ) do
3434 bounds = page . locator ( 'svg' ) . bounding_box
@@ -46,7 +46,8 @@ def mermaids_to_images(passed_config, src: '.', dest: '.', type: 'pdf')
4646 page . set_viewport_size ( { width : x + width , height : y + height } )
4747
4848 if type == 'png'
49- page . screenshot ( path : File . join ( dest , "#{ id } .png" ) , clip : { x : x , y : y , width : width , height : height } )
49+ page . screenshot ( path : File . join ( dest , "#{ id } .png" ) , clip : { x : x , y : y , width : width , height : height } ,
50+ timeout : timeout )
5051 break
5152 end
5253
0 commit comments