File tree Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Expand file tree Collapse file tree 2 files changed +39
-7
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,25 @@ def deps do
1919end
2020```
2121
22+ ### Chrome DevTools Protocol Selection
23+
24+ Chrome Remote Interface generated its API at compile time from the protocol
25+ definition released by the Chrome DevTools Team.
26+ For more info see: [ https://chromedevtools.github.io/devtools-protocol/ ] ( https://chromedevtools.github.io/devtools-protocol/ )
27+
28+ This can be overridden by setting ` CRI_PROTOCOL_VERSION ` environment variable
29+ to:
30+ * 1-2
31+ * 1-3 * default
32+ * tot
33+
34+ Example:
35+ ```
36+ CRI_PROTOCOL_VERSION=1-2 mix compile
37+ CRI_PROTOCOL_VERSION=1-3 mix compile
38+ CRI_PROTOCOL_VERSION=tot mix compile
39+ ```
40+
2241## Usage
2342
2443> Note: In these examples, it assumes you're already running chrome headless with remote debugging enabled.
Original file line number Diff line number Diff line change @@ -5,10 +5,29 @@ defmodule ChromeRemoteInterface do
55
66 alias ChromeRemoteInterface.PageSession
77
8+ @ protocol_env_key "CRI_PROTOCOL_VERSION"
9+ @ protocol_versions [ "1-2" , "1-3" , "tot" ]
10+ @ protocol_version (
11+ if ( vsn = System . get_env ( @ protocol_env_key ) ) in @ protocol_versions do
12+ vsn
13+ else
14+ "1-3"
15+ end
16+ )
17+ IO . puts ( "Compiling ChromeRemoteInterface with Chrome DevTools Protocol version: '#{ @ protocol_version } '" )
18+
19+ @ doc """
20+ Gets the current version of the Chrome Debugger Protocol
21+ """
22+ def protocol_version ( ) do
23+ @ protocol_version
24+ end
25+
826 protocol =
9- File . read! ( "priv/protocol.json" )
27+ File . read! ( "priv/#{ @ protocol_version } / protocol.json" )
1028 |> Poison . decode! ( )
1129
30+
1231 # Generate ChromeRemoteInterface.RPC Modules
1332
1433 Enum . each ( protocol [ "domains" ] , fn ( domain ) ->
@@ -58,10 +77,4 @@ defmodule ChromeRemoteInterface do
5877 end
5978 end
6079 end )
61-
62- @ protocol_version "#{ protocol [ "version" ] [ "major" ] } .#{ protocol [ "version" ] [ "minor" ] } "
63- @ doc """
64- Gets the current version of the Chrome Debugger Protocol
65- """
66- def protocol_version ( ) , do: @ protocol_version
6780end
You can’t perform that action at this time.
0 commit comments