Skip to content

Commit

Permalink
Restructure (#16)
Browse files Browse the repository at this point in the history
* restructure modules under chrobot namespace

* regenerate protocol bindings

* prepare release

* adjust readme
  • Loading branch information
JonasGruenwald authored Sep 7, 2024
1 parent 3c93ba8 commit e0971a7
Show file tree
Hide file tree
Showing 29 changed files with 108 additions and 124 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion gleam.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
19 changes: 9 additions & 10 deletions src/chrobot.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/browser_install.gleam → src/chrobot/install.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/protocol.gleam → src/chrobot/protocol.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand All @@ -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.
Expand Down
15 changes: 6 additions & 9 deletions src/protocol/dom.gleam → src/chrobot/protocol/dom.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 5 additions & 6 deletions src/protocol/fetch.gleam → src/chrobot/protocol/fetch.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/protocol/input.gleam → src/chrobot/protocol/input.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 4 additions & 5 deletions src/protocol/io.gleam → src/chrobot/protocol/io.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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:<uuid>` where
/// `<uuid>` is an UUID of a Blob.
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/protocol/log.gleam → src/chrobot/protocol/log.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading

0 comments on commit e0971a7

Please sign in to comment.