Skip to content

Commit 5da1b8b

Browse files
authored
Merge pull request #264 from active-group/imageexport-localbrowser
2 parents fef0bbb + 04f46db commit 5da1b8b

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs

+18-7
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ open DynamicObj
1212
module PuppeteerSharpRendererOptions =
1313

1414
let mutable launchOptions = LaunchOptions()
15-
1615
launchOptions.Timeout <- 60000
1716

17+
let mutable localBrowserExecutablePath = None
18+
19+
1820
type PuppeteerSharpRenderer() =
1921

2022
/// adapted from the original C# implementation by @ilyalatt : https://github.com/ilyalatt/Plotly.NET.PuppeteerRenderer
@@ -78,16 +80,25 @@ type PuppeteerSharpRenderer() =
7880
/// Initalizes headless browser
7981
let fetchAndLaunchBrowserAsync () =
8082
async {
81-
use browserFetcher = new BrowserFetcher()
83+
match PuppeteerSharpRendererOptions.localBrowserExecutablePath with
84+
| None ->
85+
use browserFetcher = new BrowserFetcher()
8286

83-
let! revision = browserFetcher.DownloadAsync() |> Async.AwaitTask
87+
let! revision = browserFetcher.DownloadAsync() |> Async.AwaitTask
8488

85-
let launchOptions =
86-
PuppeteerSharpRendererOptions.launchOptions
89+
let launchOptions =
90+
PuppeteerSharpRendererOptions.launchOptions
8791

88-
launchOptions.ExecutablePath <- revision.ExecutablePath
92+
launchOptions.ExecutablePath <- revision.ExecutablePath
8993

90-
return! Puppeteer.LaunchAsync(launchOptions) |> Async.AwaitTask
94+
return! Puppeteer.LaunchAsync(launchOptions) |> Async.AwaitTask
95+
| Some p ->
96+
let launchOptions =
97+
PuppeteerSharpRendererOptions.launchOptions
98+
99+
launchOptions.ExecutablePath <- p
100+
101+
return! Puppeteer.LaunchAsync(launchOptions) |> Async.AwaitTask
91102
}
92103

93104
/// Initalizes headless browser

0 commit comments

Comments
 (0)