diff --git a/CHANGELOG.md b/CHANGELOG.md index 7228a6e..caa288b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ -## [2.3.0] 2024-07 +## [3.0.0] 2024-08-07 + +This update restructures the project to move all modules under the `chrobot` namespace. + +- All `protocol` modules are now under `chrobot/protocol` +- `chrome` is now `chrobot/chrome` +- `browser_install` is now `chrobot/install` + +## [2.3.0] 2024-08-07 - Add query selectors that run on elements (Remote Objects) diff --git a/README.md b/README.md index 2b0fffb..8e0a047 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ Install as an Elixir dependency with mix # in your mix.exs defp deps do [ - {:chrobot, "~> 2.2.3", app: false, manager: :rebar3} + {:chrobot, "~> 3.0.0", app: false, manager: :rebar3} ] end ``` @@ -70,16 +70,16 @@ Chrobot will automatically pick up this local installation when started via the You can run the browser installer tool from gleam like so: ```sh -gleam run -m browser_install +gleam run -m chrobot/install ``` Or when using Elixir with Mix: ```sh -mix run -e :browser_install.main +mix run -e :chrobot@install.main ``` -Please [check the `install` docs for more information](https://hexdocs.pm/chrobot/browser_install.html) – this installation method will not work everywhere and comes with some caveats! +Please [check the `install` docs for more information](https://hexdocs.pm/chrobot/chrobot/install.html) – this installation method will not work everywhere and comes with some caveats! #### GitHub Actions diff --git a/gleam.toml b/gleam.toml index 204de85..a114499 100644 --- a/gleam.toml +++ b/gleam.toml @@ -1,5 +1,5 @@ name = "chrobot" -version = "2.3.0" +version = "3.0.0" description = "A browser automation tool and interface to the Chrome DevTools Protocol." licences = ["MIT"] diff --git a/src/chrobot.gleam b/src/chrobot.gleam index 5a6d9bd..5dea773 100644 --- a/src/chrobot.gleam +++ b/src/chrobot.gleam @@ -26,25 +26,24 @@ //// to treat the pages you are operating on as a secure context. //// +import chrobot/chrome.{type RequestError} import chrobot/internal/keymap import chrobot/internal/utils -import chrome.{type RequestError} +import chrobot/protocol +import chrobot/protocol/input +import chrobot/protocol/page +import chrobot/protocol/runtime +import chrobot/protocol/target import gleam/bit_array import gleam/bool import gleam/dynamic import gleam/erlang/process.{type Subject} -import gleam/io import gleam/json import gleam/list import gleam/option.{type Option, None, Some} import gleam/otp/task import gleam/result import gleam/string -import protocol -import protocol/input -import protocol/page -import protocol/runtime -import protocol/target import simplifile as file /// Holds information about the current page, @@ -86,7 +85,7 @@ pub fn launch() -> Result(Subject(chrome.Message), chrome.LaunchError) { utils.hint( "You can install a local version of chrome for testing with this command:", ) - utils.show_cmd("gleam run -m browser_install") + utils.show_cmd("gleam run -m chrobot/install") launch_result } other -> other @@ -105,7 +104,7 @@ pub fn launch_window() -> Result(Subject(chrome.Message), chrome.LaunchError) { utils.hint( "You can install a local version of chrome for testing with this command:", ) - utils.show_cmd("gleam run -m browser_install") + utils.show_cmd("gleam run -m chrobot/install") launch_result } other -> other @@ -832,7 +831,7 @@ fn pass_session(session_id: target.SessionID) -> Option(String) { /// ```gleam /// import chrobot.{open, page_caller} /// import gleam/option.{None} -/// import protocol/page +/// import chrobot/protocol/page /// pub fn main() { /// let assert Ok(browser) = chrobot.launch() /// let assert Ok(page) = open(browser, "https://example.com", 5000) diff --git a/src/chrome.gleam b/src/chrobot/chrome.gleam similarity index 100% rename from src/chrome.gleam rename to src/chrobot/chrome.gleam diff --git a/src/browser_install.gleam b/src/chrobot/install.gleam similarity index 99% rename from src/browser_install.gleam rename to src/chrobot/install.gleam index e7eddb0..ab044e4 100644 --- a/src/browser_install.gleam +++ b/src/chrobot/install.gleam @@ -6,7 +6,7 @@ //// You may run browser installation directly with //// //// ```sh -//// gleam run -m browser_install +//// gleam run -m chrobot/install //// ``` //// When running directly, you can configure the browser version to install by setting the `CHROBOT_TARGET_VERSION` environment variable, //// it will default to `latest`. @@ -81,8 +81,8 @@ //// xdg-utils //// ``` +import chrobot/chrome import chrobot/internal/utils -import chrome import filepath as path import gleam/dynamic import gleam/erlang/os diff --git a/src/protocol.gleam b/src/chrobot/protocol.gleam similarity index 98% rename from src/protocol.gleam rename to src/chrobot/protocol.gleam index dbf2ee4..986d1f1 100644 --- a/src/protocol.gleam +++ b/src/chrobot/protocol.gleam @@ -77,7 +77,7 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- const version_major = "1" diff --git a/src/protocol/browser.gleam b/src/chrobot/protocol/browser.gleam similarity index 97% rename from src/protocol/browser.gleam rename to src/chrobot/protocol/browser.gleam index e343dda..2a1fe0e 100644 --- a/src/protocol/browser.gleam +++ b/src/chrobot/protocol/browser.gleam @@ -7,11 +7,11 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome import gleam/dynamic import gleam/json import gleam/option diff --git a/src/protocol/debugger.gleam b/src/chrobot/protocol/debugger.gleam similarity index 99% rename from src/protocol/debugger.gleam rename to src/chrobot/protocol/debugger.gleam index e18cbc1..72f0421 100644 --- a/src/protocol/debugger.gleam +++ b/src/chrobot/protocol/debugger.gleam @@ -8,16 +8,16 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/runtime /// Breakpoint identifier. pub type BreakpointId { @@ -33,8 +33,7 @@ pub fn encode__breakpoint_id(value__: BreakpointId) { @internal pub fn decode__breakpoint_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(BreakpointId, dynamic.string) + value__ |> dynamic.decode1(BreakpointId, dynamic.string) } /// Call frame identifier. @@ -51,8 +50,7 @@ pub fn encode__call_frame_id(value__: CallFrameId) { @internal pub fn decode__call_frame_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(CallFrameId, dynamic.string) + value__ |> dynamic.decode1(CallFrameId, dynamic.string) } /// Location in the source code. diff --git a/src/protocol/dom.gleam b/src/chrobot/protocol/dom.gleam similarity index 99% rename from src/protocol/dom.gleam rename to src/chrobot/protocol/dom.gleam index e056176..b3d4830 100644 --- a/src/protocol/dom.gleam +++ b/src/chrobot/protocol/dom.gleam @@ -13,16 +13,16 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/runtime /// Unique DOM node identifier. pub type NodeId { @@ -38,8 +38,7 @@ pub fn encode__node_id(value__: NodeId) { @internal pub fn decode__node_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(NodeId, dynamic.int) + value__ |> dynamic.decode1(NodeId, dynamic.int) } /// Unique DOM node identifier used to reference a node that may not have been pushed to the @@ -57,8 +56,7 @@ pub fn encode__backend_node_id(value__: BackendNodeId) { @internal pub fn decode__backend_node_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(BackendNodeId, dynamic.int) + value__ |> dynamic.decode1(BackendNodeId, dynamic.int) } /// Backend node with a friendly name. @@ -719,8 +717,7 @@ pub fn encode__quad(value__: Quad) { @internal pub fn decode__quad(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(Quad, dynamic.list(dynamic.float)) + value__ |> dynamic.decode1(Quad, dynamic.list(dynamic.float)) } /// Box model. diff --git a/src/protocol/dom_debugger.gleam b/src/chrobot/protocol/dom_debugger.gleam similarity index 98% rename from src/protocol/dom_debugger.gleam rename to src/chrobot/protocol/dom_debugger.gleam index 27e5016..fd96590 100644 --- a/src/protocol/dom_debugger.gleam +++ b/src/chrobot/protocol/dom_debugger.gleam @@ -8,17 +8,17 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/dom +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/dom -import protocol/runtime /// DOM breakpoint type. pub type DOMBreakpointType { diff --git a/src/protocol/emulation.gleam b/src/chrobot/protocol/emulation.gleam similarity index 99% rename from src/protocol/emulation.gleam rename to src/chrobot/protocol/emulation.gleam index 3298deb..2a3ac3e 100644 --- a/src/protocol/emulation.gleam +++ b/src/chrobot/protocol/emulation.gleam @@ -7,15 +7,15 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- import chrobot/internal/utils +import chrobot/protocol/dom import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/dom /// Screen orientation. pub type ScreenOrientation { diff --git a/src/protocol/fetch.gleam b/src/chrobot/protocol/fetch.gleam similarity index 98% rename from src/protocol/fetch.gleam rename to src/chrobot/protocol/fetch.gleam index 0808e37..35abfad 100644 --- a/src/protocol/fetch.gleam +++ b/src/chrobot/protocol/fetch.gleam @@ -7,17 +7,17 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/io +import chrobot/protocol/network import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/io -import protocol/network /// Unique request identifier. pub type RequestId { @@ -33,8 +33,7 @@ pub fn encode__request_id(value__: RequestId) { @internal pub fn decode__request_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(RequestId, dynamic.string) + value__ |> dynamic.decode1(RequestId, dynamic.string) } /// Stages of the request to handle. Request will intercept before the request is diff --git a/src/protocol/input.gleam b/src/chrobot/protocol/input.gleam similarity index 99% rename from src/protocol/input.gleam rename to src/chrobot/protocol/input.gleam index 72133e2..21090d2 100644 --- a/src/protocol/input.gleam +++ b/src/chrobot/protocol/input.gleam @@ -7,7 +7,7 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- import chrobot/internal/utils @@ -163,8 +163,7 @@ pub fn encode__time_since_epoch(value__: TimeSinceEpoch) { @internal pub fn decode__time_since_epoch(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(TimeSinceEpoch, dynamic.float) + value__ |> dynamic.decode1(TimeSinceEpoch, dynamic.float) } /// Dispatches a key event to the page. diff --git a/src/protocol/io.gleam b/src/chrobot/protocol/io.gleam similarity index 95% rename from src/protocol/io.gleam rename to src/chrobot/protocol/io.gleam index 944b84e..9ba1f48 100644 --- a/src/protocol/io.gleam +++ b/src/chrobot/protocol/io.gleam @@ -7,16 +7,16 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/runtime /// This is either obtained from another method or specified as `blob:` where /// `` is an UUID of a Blob. @@ -33,8 +33,7 @@ pub fn encode__stream_handle(value__: StreamHandle) { @internal pub fn decode__stream_handle(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(StreamHandle, dynamic.string) + value__ |> dynamic.decode1(StreamHandle, dynamic.string) } /// This type is not part of the protocol spec, it has been generated dynamically diff --git a/src/protocol/log.gleam b/src/chrobot/protocol/log.gleam similarity index 98% rename from src/protocol/log.gleam rename to src/chrobot/protocol/log.gleam index f820ce6..67dbaef 100644 --- a/src/protocol/log.gleam +++ b/src/chrobot/protocol/log.gleam @@ -7,16 +7,16 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- import chrobot/internal/utils +import chrobot/protocol/network +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/network -import protocol/runtime /// Log entry. pub type LogEntry { diff --git a/src/protocol/network.gleam b/src/chrobot/protocol/network.gleam similarity index 99% rename from src/protocol/network.gleam rename to src/chrobot/protocol/network.gleam index 4f41a35..adcf624 100644 --- a/src/protocol/network.gleam +++ b/src/chrobot/protocol/network.gleam @@ -8,19 +8,19 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/runtime +import chrobot/protocol/security import gleam/dict import gleam/dynamic import gleam/json import gleam/list import gleam/option import gleam/result -import protocol/runtime -import protocol/security /// Resource type as it was perceived by the rendering engine. pub type ResourceType { @@ -116,8 +116,7 @@ pub fn encode__loader_id(value__: LoaderId) { @internal pub fn decode__loader_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(LoaderId, dynamic.string) + value__ |> dynamic.decode1(LoaderId, dynamic.string) } /// Unique request identifier. @@ -134,8 +133,7 @@ pub fn encode__request_id(value__: RequestId) { @internal pub fn decode__request_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(RequestId, dynamic.string) + value__ |> dynamic.decode1(RequestId, dynamic.string) } /// Unique intercepted request identifier. @@ -152,8 +150,7 @@ pub fn encode__interception_id(value__: InterceptionId) { @internal pub fn decode__interception_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(InterceptionId, dynamic.string) + value__ |> dynamic.decode1(InterceptionId, dynamic.string) } /// Network level fetch failure reason. @@ -238,8 +235,7 @@ pub fn encode__time_since_epoch(value__: TimeSinceEpoch) { @internal pub fn decode__time_since_epoch(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(TimeSinceEpoch, dynamic.float) + value__ |> dynamic.decode1(TimeSinceEpoch, dynamic.float) } /// Monotonically increasing time in seconds since an arbitrary point in the past. @@ -256,8 +252,7 @@ pub fn encode__monotonic_time(value__: MonotonicTime) { @internal pub fn decode__monotonic_time(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(MonotonicTime, dynamic.float) + value__ |> dynamic.decode1(MonotonicTime, dynamic.float) } /// Request / response headers as keys / values of JSON object. diff --git a/src/protocol/page.gleam b/src/chrobot/protocol/page.gleam similarity index 99% rename from src/protocol/page.gleam rename to src/chrobot/protocol/page.gleam index 93f3390..5fddcc2 100644 --- a/src/protocol/page.gleam +++ b/src/chrobot/protocol/page.gleam @@ -7,18 +7,18 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/dom +import chrobot/protocol/network +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/dom -import protocol/network -import protocol/runtime /// Unique frame identifier. pub type FrameId { @@ -34,8 +34,7 @@ pub fn encode__frame_id(value__: FrameId) { @internal pub fn decode__frame_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(FrameId, dynamic.string) + value__ |> dynamic.decode1(FrameId, dynamic.string) } /// Information about the Frame on the page. @@ -152,8 +151,7 @@ pub fn encode__script_identifier(value__: ScriptIdentifier) { @internal pub fn decode__script_identifier(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(ScriptIdentifier, dynamic.string) + value__ |> dynamic.decode1(ScriptIdentifier, dynamic.string) } /// Transition type. diff --git a/src/protocol/performance.gleam b/src/chrobot/protocol/performance.gleam similarity index 97% rename from src/protocol/performance.gleam rename to src/chrobot/protocol/performance.gleam index 2773280..6f7cbbc 100644 --- a/src/protocol/performance.gleam +++ b/src/chrobot/protocol/performance.gleam @@ -7,11 +7,11 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome import gleam/dynamic import gleam/json import gleam/option diff --git a/src/protocol/profiler.gleam b/src/chrobot/protocol/profiler.gleam similarity index 99% rename from src/protocol/profiler.gleam rename to src/chrobot/protocol/profiler.gleam index 972fd0f..3dd7548 100644 --- a/src/protocol/profiler.gleam +++ b/src/chrobot/protocol/profiler.gleam @@ -7,16 +7,16 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option import gleam/result -import protocol/runtime /// Profile node. Holds callsite information, execution statistics and child nodes. pub type ProfileNode { diff --git a/src/protocol/runtime.gleam b/src/chrobot/protocol/runtime.gleam similarity index 99% rename from src/protocol/runtime.gleam rename to src/chrobot/protocol/runtime.gleam index 25a11a6..a752e6e 100644 --- a/src/protocol/runtime.gleam +++ b/src/chrobot/protocol/runtime.gleam @@ -11,11 +11,11 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome import gleam/dict import gleam/dynamic import gleam/json @@ -37,8 +37,7 @@ pub fn encode__script_id(value__: ScriptId) { @internal pub fn decode__script_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(ScriptId, dynamic.string) + value__ |> dynamic.decode1(ScriptId, dynamic.string) } /// Represents options for serialization. Overrides `generatePreview` and `returnByValue`. @@ -306,8 +305,7 @@ pub fn encode__remote_object_id(value__: RemoteObjectId) { @internal pub fn decode__remote_object_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(RemoteObjectId, dynamic.string) + value__ |> dynamic.decode1(RemoteObjectId, dynamic.string) } /// Primitive value which cannot be JSON-stringified. Includes values `-0`, `NaN`, `Infinity`, @@ -325,8 +323,7 @@ pub fn encode__unserializable_value(value__: UnserializableValue) { @internal pub fn decode__unserializable_value(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(UnserializableValue, dynamic.string) + value__ |> dynamic.decode1(UnserializableValue, dynamic.string) } /// Mirror object referencing original JavaScript object. @@ -754,8 +751,7 @@ pub fn encode__execution_context_id(value__: ExecutionContextId) { @internal pub fn decode__execution_context_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(ExecutionContextId, dynamic.int) + value__ |> dynamic.decode1(ExecutionContextId, dynamic.int) } /// Description of an isolated world. @@ -923,8 +919,7 @@ pub fn encode__timestamp(value__: Timestamp) { @internal pub fn decode__timestamp(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(Timestamp, dynamic.float) + value__ |> dynamic.decode1(Timestamp, dynamic.float) } /// Number of milliseconds. @@ -941,8 +936,7 @@ pub fn encode__time_delta(value__: TimeDelta) { @internal pub fn decode__time_delta(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(TimeDelta, dynamic.float) + value__ |> dynamic.decode1(TimeDelta, dynamic.float) } /// Stack entry for runtime errors and assertions. diff --git a/src/protocol/security.gleam b/src/chrobot/protocol/security.gleam similarity index 98% rename from src/protocol/security.gleam rename to src/chrobot/protocol/security.gleam index 8efb53a..b6dae3d 100644 --- a/src/protocol/security.gleam +++ b/src/chrobot/protocol/security.gleam @@ -7,7 +7,7 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- import chrobot/internal/utils @@ -30,8 +30,7 @@ pub fn encode__certificate_id(value__: CertificateId) { @internal pub fn decode__certificate_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(CertificateId, dynamic.int) + value__ |> dynamic.decode1(CertificateId, dynamic.int) } /// A description of mixed content (HTTP resources on HTTPS pages), as defined by diff --git a/src/protocol/target.gleam b/src/chrobot/protocol/target.gleam similarity index 98% rename from src/protocol/target.gleam rename to src/chrobot/protocol/target.gleam index cdd273e..61a12e4 100644 --- a/src/protocol/target.gleam +++ b/src/chrobot/protocol/target.gleam @@ -7,11 +7,11 @@ // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- +import chrobot/chrome import chrobot/internal/utils -import chrome import gleam/dynamic import gleam/json import gleam/option @@ -30,8 +30,7 @@ pub fn encode__target_id(value__: TargetID) { @internal pub fn decode__target_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(TargetID, dynamic.string) + value__ |> dynamic.decode1(TargetID, dynamic.string) } /// Unique identifier of attached debugging session. @@ -48,8 +47,7 @@ pub fn encode__session_id(value__: SessionID) { @internal pub fn decode__session_id(value__: dynamic.Dynamic) { - value__ - |> dynamic.decode1(SessionID, dynamic.string) + value__ |> dynamic.decode1(SessionID, dynamic.string) } pub type TargetInfo { diff --git a/src/chrobot_ffi.erl b/src/chrobot_ffi.erl index ea7f91f..66291cb 100644 --- a/src/chrobot_ffi.erl +++ b/src/chrobot_ffi.erl @@ -8,7 +8,7 @@ % FFI to interact with the browser via a port from erlang % since gleam does not really support ports yet. -% module: chrome.gleam +% module: chrobot/chrome.gleam % The port is opened with the option "nouse_stdio" % which makes it use file descriptors 3 and 4 for stdin and stdout @@ -38,7 +38,7 @@ send_to_port(Port, BinaryString) -> % --------------------------------------------------- % Utils for the installer script -% module: browser_install.gleam +% module: chrobot/install.gleam % Get the architecture of the system get_arch() -> diff --git a/test/chrobot_test.gleam b/test/chrobot_test.gleam index 46290cb..3885cd4 100644 --- a/test/chrobot_test.gleam +++ b/test/chrobot_test.gleam @@ -1,7 +1,7 @@ import birdie import chrobot +import chrobot/chrome import chrobot/internal/utils -import chrome import gleam/dynamic import gleam/erlang/process import gleam/io @@ -46,7 +46,7 @@ pub fn main() { utils.hint( "Consider installing a local version of chrome for the project:", ) - utils.show_cmd("gleam run -m browser_install") + utils.show_cmd("gleam run -m chrobot/install") } } panic as "See output above!" diff --git a/test/chrome_test.gleam b/test/chrome_test.gleam index ef58c66..e1cef75 100644 --- a/test/chrome_test.gleam +++ b/test/chrome_test.gleam @@ -1,4 +1,4 @@ -import chrome +import chrobot/chrome import gleam/erlang/os import gleam/json import gleam/list diff --git a/test/codegen/generate_bindings.gleam b/test/codegen/generate_bindings.gleam index 4bfcee6..0d13d5a 100644 --- a/test/codegen/generate_bindings.gleam +++ b/test/codegen/generate_bindings.gleam @@ -227,12 +227,13 @@ pub fn main() { let stable_protocol = get_stable_protocol(protocol, False, False) io.println("Stable protocol (experimental items removed):") print_protocol_stats(stable_protocol) - let target = "src/protocol.gleam" + let target = "src/chrobot/protocol.gleam" io.println("Writing root protocol module to: " <> target) let assert Ok(_) = file.write(gen_root_module(stable_protocol), to: target) let assert Ok(_) = file.create_directory_all("src/protocol") list.each(stable_protocol.domains, fn(domain) { - let target = "src/protocol/" <> snake_case(domain.domain) <> ".gleam" + let target = + "src/chrobot/protocol/" <> snake_case(domain.domain) <> ".gleam" io.println("Writing domain module to: " <> target) let assert Ok(_) = file.write(gen_domain_module(stable_protocol, domain), to: target) @@ -913,7 +914,7 @@ fn gen_preamble(protocol: Protocol) { " // --------------------------------------------------------------------------- // | !!!!!! This is an autogenerated file - Do not edit manually !!!!!! | -// | Run ` gleam run -m scripts/generate_protocol_bindings.sh` to regenerate.| +// | Run `codegen.sh` to regenerate. | // --------------------------------------------------------------------------- //// > ⚙️ This module was generated from the Chrome DevTools Protocol version **" <> protocol.version.major <> "." <> protocol.version.minor <> "**\n" } @@ -957,11 +958,11 @@ fn gen_imports(domain: Domain) { let domain_imports = option.unwrap(domain.dependencies, []) |> list.map(fn(dependency) { - "import protocol/" <> snake_case(dependency) <> "\n" + "import chrobot/protocol/" <> snake_case(dependency) <> "\n" }) [ - "import chrome\n", + "import chrobot/chrome\n", "import gleam/dict\n", "import gleam/list\n", "import gleam/dynamic\n", diff --git a/test/protocol/runtime_test.gleam b/test/protocol/runtime_test.gleam index 09ffbf3..29e429d 100644 --- a/test/protocol/runtime_test.gleam +++ b/test/protocol/runtime_test.gleam @@ -1,11 +1,11 @@ import birdie -import chrome +import chrobot/chrome +import chrobot/protocol/runtime import gleam/dynamic import gleam/json import gleam/option.{type Option, None, Some} import gleam/string import gleeunit/should -import protocol/runtime import simplifile as file /// This module havs some types with dynamic values. diff --git a/test/test_utils.gleam b/test/test_utils.gleam index a625293..f34d520 100644 --- a/test/test_utils.gleam +++ b/test/test_utils.gleam @@ -1,7 +1,7 @@ //// Shared test utilities import chrobot -import chrome +import chrobot/chrome import gleam/erlang/os import gleeunit/should import simplifile as file