browserbeam 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +32 -1
- data/lib/browserbeam/session.rb +3 -1
- data/lib/browserbeam/types.rb +8 -1
- data/lib/browserbeam/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b0481857f0872498c855f5c1cc7611f468f348e406299601fde653abb148487
|
|
4
|
+
data.tar.gz: 989f1e433800e1d2132cadb9bb83e8497884939da70deffe0e5148c21b74c647
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0605be53e22028d51513793fb6f0542caac9a131135ea1566fff865f7a5087f3c8b168569749fefc4cb1473f46b9e0accc22020c66495d4493caae72f46815f9
|
|
7
|
+
data.tar.gz: c5d700fbcac26e7757a891729071e7cb959007e0b4f8d8b7b51a16d34a145af168db7f108b726f0e24f67ed41f67d571c33db1d1992c76320a2091656fbb1764
|
data/README.md
CHANGED
|
@@ -71,7 +71,7 @@ session = client.sessions.create(
|
|
|
71
71
|
| Method | Description |
|
|
72
72
|
|--------|-------------|
|
|
73
73
|
| `session.goto(url)` | Navigate to a URL |
|
|
74
|
-
| `session.observe` | Get page state as markdown |
|
|
74
|
+
| `session.observe` | Get page state as markdown. Supports `mode: "full"` for all sections. |
|
|
75
75
|
| `session.click(ref:)` | Click an element by ref, text, or label |
|
|
76
76
|
| `session.fill(value, ref:)` | Fill an input field |
|
|
77
77
|
| `session.type(value, label:)` | Type text character by character |
|
|
@@ -87,6 +87,37 @@ session = client.sessions.create(
|
|
|
87
87
|
| `session.execute_js(code)` | Run JavaScript |
|
|
88
88
|
| `session.close` | Close the session |
|
|
89
89
|
|
|
90
|
+
## Page Map & Full Mode
|
|
91
|
+
|
|
92
|
+
The first `observe` call automatically includes a `page.map` — a lightweight structural outline of the page's landmark regions (header, nav, main, aside, footer) with CSS selectors and descriptive hints. Use it to discover what content is available outside the main area.
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
res = session.observe
|
|
96
|
+
res.page.map.each { |entry| puts "#{entry.section}: #{entry.hint}" }
|
|
97
|
+
# nav: Home · Docs · Pricing
|
|
98
|
+
# main: Getting started with Browserbeam...
|
|
99
|
+
# aside: Related posts · Popular tags
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
To re-request the map on subsequent calls:
|
|
103
|
+
|
|
104
|
+
```ruby
|
|
105
|
+
session.observe(include_page_map: true)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
When you need content from **all** page sections (sidebars, footer links, nav items), use `mode: "full"`. The response markdown is organized by region headers:
|
|
109
|
+
|
|
110
|
+
```ruby
|
|
111
|
+
full = session.observe(mode: "full", max_text_length: 20_000)
|
|
112
|
+
puts full.page.markdown.content
|
|
113
|
+
# ## [nav]
|
|
114
|
+
# Home · Docs · Pricing
|
|
115
|
+
# ## [main]
|
|
116
|
+
# ...article content...
|
|
117
|
+
# ## [aside]
|
|
118
|
+
# Related posts · ...
|
|
119
|
+
```
|
|
120
|
+
|
|
90
121
|
## Session Management
|
|
91
122
|
|
|
92
123
|
```ruby
|
data/lib/browserbeam/session.rb
CHANGED
|
@@ -27,10 +27,12 @@ module Browserbeam
|
|
|
27
27
|
act([{ goto: params }])
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
def observe(scope: nil, format: nil, include_links: nil, max_text_length: nil)
|
|
30
|
+
def observe(scope: nil, format: nil, mode: nil, include_page_map: nil, include_links: nil, max_text_length: nil)
|
|
31
31
|
params = {}
|
|
32
32
|
params[:scope] = scope if scope
|
|
33
33
|
params[:format] = format if format
|
|
34
|
+
params[:mode] = mode if mode
|
|
35
|
+
params[:include_page_map] = include_page_map unless include_page_map.nil?
|
|
34
36
|
params[:include_links] = include_links unless include_links.nil?
|
|
35
37
|
params[:max_text_length] = max_text_length if max_text_length
|
|
36
38
|
act([{ observe: params }])
|
data/lib/browserbeam/types.rb
CHANGED
|
@@ -18,6 +18,12 @@ module Browserbeam
|
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
MapEntry = Struct.new(:section, :selector, :hint, keyword_init: true) do
|
|
22
|
+
def self.from_hash(data)
|
|
23
|
+
new(section: data["section"] || "", selector: data["selector"] || "", hint: data["hint"] || "")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
Changes = Struct.new(:content_changed, :content_delta, :elements_added, :elements_removed, keyword_init: true) do
|
|
22
28
|
def self.from_hash(data)
|
|
23
29
|
return nil unless data.is_a?(Hash)
|
|
@@ -37,7 +43,7 @@ module Browserbeam
|
|
|
37
43
|
end
|
|
38
44
|
end
|
|
39
45
|
|
|
40
|
-
PageState = Struct.new(:url, :title, :stable, :markdown, :interactive_elements, :forms, :changes, :scroll, keyword_init: true) do
|
|
46
|
+
PageState = Struct.new(:url, :title, :stable, :markdown, :map, :interactive_elements, :forms, :changes, :scroll, keyword_init: true) do
|
|
41
47
|
def self.from_hash(data)
|
|
42
48
|
return nil unless data.is_a?(Hash)
|
|
43
49
|
new(
|
|
@@ -45,6 +51,7 @@ module Browserbeam
|
|
|
45
51
|
title: data["title"] || "",
|
|
46
52
|
stable: data["stable"] || false,
|
|
47
53
|
markdown: MarkdownContent.from_hash(data["markdown"]),
|
|
54
|
+
map: data["map"] ? data["map"].map { |m| MapEntry.from_hash(m) } : nil,
|
|
48
55
|
interactive_elements: (data["interactive_elements"] || []).map { |el| InteractiveElement.from_hash(el) },
|
|
49
56
|
forms: data["forms"] || [],
|
|
50
57
|
changes: Changes.from_hash(data["changes"]),
|
data/lib/browserbeam/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: browserbeam
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Browserbeam
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|