puppeteer-bidi 0.0.1.beta2 → 0.0.1.beta3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e48c2e579cbfaa59695d2bef7808b5d1e06a6eaabc32373c76922bb1546bc1b1
4
- data.tar.gz: 1b7c45fd354031cbeb4fb79c44de2b60dfeb3daee83347c852cfb3ead069813e
3
+ metadata.gz: 4a297f926102da482b6ffaecf8f894cb95dffb910f6743ebc75d0414f1aae00f
4
+ data.tar.gz: 81c8b08b57b53ca739af7e864723686965278d60bd5d0d1197aff31dd37b299f
5
5
  SHA512:
6
- metadata.gz: e871963ebf26bcd8739be7860c50f62fbb39869950f9a674369f6685a6971fa669d6d1df69b9e684adada354c6219fb11e5982a8c2103cac6425d5e32eb8dbb1
7
- data.tar.gz: d3b5db4e138484081966a678e8e2f9f70d5c9031fcadd00631368920abbf8eb92d2f1f92beea34d48272b87e3bf63521a9e57d71e339667f2113d87fc8f3c495
6
+ metadata.gz: 519a8a8e1dccfc046de5c8bea356a59d3b5e40e79e8040f85fbbe370f1530170ccbd555b32a242841d132130ef4da85eeedc58bac3f554ab34159faa0b807826
7
+ data.tar.gz: d60e4cb2eb5caf33a055d394861814f4ecd3f8b561796ff5cb69cce17a5efe59ae3e07cc98e9e5c46b90a68944f20090cfccb6726849cf774f0f0f015fbffaf1
data/CLAUDE.md CHANGED
@@ -86,14 +86,15 @@ Use [rbs-inline](https://github.com/soutaro/rbs-inline) for type annotations in
86
86
  class Example
87
87
  attr_reader :name #: String
88
88
 
89
- # @rbs name: String
89
+ # @rbs name: String -- The name to set
90
90
  # @rbs return: void
91
91
  def initialize(name)
92
92
  @name = name
93
93
  end
94
94
 
95
- # @rbs selector: String
96
- # @rbs return: ElementHandle?
95
+ # Query for an element matching the selector
96
+ # @rbs selector: String -- CSS selector to query
97
+ # @rbs return: ElementHandle? -- Matching element or nil
97
98
  def query_selector(selector)
98
99
  # ...
99
100
  end
@@ -103,8 +104,10 @@ end
103
104
  **Conventions:**
104
105
  - Use `A?` for nullable types (not `A | nil`)
105
106
  - Use `A | B | nil` for union types with nil
106
- - Add space around `--` for inline comments: `# @rbs name: String -- the name`
107
+ - **Always include descriptions** with `--` separator: `# @rbs name: String -- the name`
107
108
  - Public methods should have type annotations
109
+ - **Do NOT use `@rbs!` blocks** - RubyMine IDE doesn't recognize them
110
+ - **Use direct union types** instead of type aliases: `BrowserTarget | PageTarget | FrameTarget` not `target`
108
111
 
109
112
  **Generate RBS files:**
110
113
  ```bash
@@ -135,7 +138,6 @@ bundle exec steep check # Run type checker
135
138
  2. **`sig/_supplementary.rbs`** - Types rbs-inline cannot generate
136
139
  - `extend self` pattern: Add `extend ModuleName` declaration
137
140
  - Singleton pattern: Add `extend Singleton::SingletonClassMethods`
138
- - Union type aliases that rbs-inline doesn't preserve
139
141
 
140
142
  **Common Issues:**
141
143
 
@@ -68,17 +68,12 @@ module Puppeteer
68
68
  }
69
69
  end
70
70
 
71
- # @rbs!
72
- # type launch_options = {
73
- # ?executable_path: String,
74
- # ?user_data_dir: String,
75
- # ?headless: bool,
76
- # ?args: Array[String],
77
- # ?timeout: Numeric
78
- # }
79
-
80
71
  # Launch a new Firefox browser instance
81
- # @rbs **options: launch_options -- Launch options
72
+ # @rbs executable_path: String
73
+ # @rbs user_data_dir: String
74
+ # @rbs headless: bool
75
+ # @rbs args: Array[String]
76
+ # @rbs timeout: Numeric
82
77
  # @rbs return: Browser -- Browser instance
83
78
  def self.launch(**options)
84
79
  launcher = BrowserLauncher.new(
@@ -163,8 +158,8 @@ module Puppeteer
163
158
 
164
159
  # Wait until a target (top-level browsing context) satisfies the predicate.
165
160
  # @rbs timeout: Integer? -- Timeout in milliseconds (default: 30000)
166
- # @rbs &predicate: (target) -> boolish -- Predicate evaluated against each Target
167
- # @rbs return: target -- Matching target
161
+ # @rbs &predicate: (BrowserTarget | PageTarget | FrameTarget) -> boolish -- Predicate evaluated against each Target
162
+ # @rbs return: BrowserTarget | PageTarget | FrameTarget -- Matching target
168
163
  def wait_for_target(timeout: nil, &predicate)
169
164
  predicate ||= ->(_target) { true }
170
165
  timeout_ms = timeout || 30_000
@@ -256,8 +251,8 @@ module Puppeteer
256
251
 
257
252
  private
258
253
 
259
- # @rbs &block: (target) -> void -- Block to yield each target to
260
- # @rbs return: Enumerator[target, void] -- Enumerator of targets
254
+ # @rbs &block: (BrowserTarget | PageTarget | FrameTarget) -> void -- Block to yield each target to
255
+ # @rbs return: Enumerator[BrowserTarget | PageTarget | FrameTarget, void] -- Enumerator of targets
261
256
  def each_target(&block)
262
257
  return enum_for(:each_target) unless block_given?
263
258
  return unless @core_browser
@@ -279,8 +274,8 @@ module Puppeteer
279
274
  end
280
275
  end
281
276
 
282
- # @rbs predicate: ^(target) -> boolish -- Predicate to match targets
283
- # @rbs return: target? -- Matching target or nil
277
+ # @rbs predicate: ^(BrowserTarget | PageTarget | FrameTarget) -> boolish -- Predicate to match targets
278
+ # @rbs return: (BrowserTarget | PageTarget | FrameTarget)? -- Matching target or nil
284
279
  def find_target(predicate)
285
280
  each_target do |target|
286
281
  return target if predicate.call(target)
@@ -80,7 +80,7 @@ module Puppeteer
80
80
  end
81
81
 
82
82
  # Get request initiator information
83
- # @rbs return: Hash[String, untyped]? -- Initiator info
83
+ # @rbs return: untyped -- Initiator info (mixed String/Symbol keys)
84
84
  def initiator
85
85
  initiator_data = @event['initiator']
86
86
  return nil unless initiator_data
@@ -7,7 +7,7 @@ module Puppeteer
7
7
  # Provides shared lifecycle management for WaitTask instances.
8
8
  # https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/api/Realm.ts
9
9
  class Realm
10
- attr_reader :task_manager #: TaskManager
10
+ attr_reader :task_manager #: Puppeteer::Bidi::TaskManager
11
11
 
12
12
  # @rbs timeout_settings: TimeoutSettings -- Timeout settings
13
13
  # @rbs return: void
@@ -3,9 +3,6 @@
3
3
 
4
4
  module Puppeteer
5
5
  module Bidi
6
- # @rbs!
7
- # type Target = BrowserTarget | PageTarget | FrameTarget
8
-
9
6
  class BrowserTarget
10
7
  # @rbs browser: Browser
11
8
  # @rbs return: void
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # rbs_inline: enabled
2
3
 
3
4
  module Puppeteer
4
5
  module Bidi
@@ -6,27 +7,31 @@ module Puppeteer
6
7
  # This is a faithful port of Puppeteer's TaskManager implementation:
7
8
  # https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/common/WaitTask.ts
8
9
  class TaskManager
10
+ # @rbs return: void
9
11
  def initialize
10
12
  @tasks = Set.new
11
13
  end
12
14
 
13
15
  # Add a task to the manager
14
16
  # Corresponds to Puppeteer's add(task: WaitTask<any>): void
15
- # @param task [WaitTask] Task to add
17
+ # @rbs task: WaitTask -- Task to add
18
+ # @rbs return: void
16
19
  def add(task)
17
20
  @tasks.add(task)
18
21
  end
19
22
 
20
23
  # Delete a task from the manager
21
24
  # Corresponds to Puppeteer's delete(task: WaitTask<any>): void
22
- # @param task [WaitTask] Task to delete
25
+ # @rbs task: WaitTask -- Task to delete
26
+ # @rbs return: void
23
27
  def delete(task)
24
28
  @tasks.delete(task)
25
29
  end
26
30
 
27
31
  # Terminate all tasks with an optional error
28
32
  # Corresponds to Puppeteer's terminateAll(error?: Error): void
29
- # @param error [Exception, nil] Error to terminate with
33
+ # @rbs error: Exception? -- Error to terminate with
34
+ # @rbs return: void
30
35
  def terminate_all(error = nil)
31
36
  @tasks.each do |task|
32
37
  task.terminate(error)
@@ -36,6 +41,7 @@ module Puppeteer
36
41
 
37
42
  # Rerun all tasks in parallel
38
43
  # Corresponds to Puppeteer's async rerunAll(): Promise<void>
44
+ # @rbs return: void
39
45
  def rerun_all
40
46
  @tasks.each(&:rerun)
41
47
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Puppeteer
4
4
  module Bidi
5
- VERSION = "0.0.1.beta2"
5
+ VERSION = "0.0.1.beta3"
6
6
  end
7
7
  end
@@ -32,17 +32,12 @@ require "puppeteer/bidi/browser"
32
32
 
33
33
  module Puppeteer
34
34
  module Bidi
35
- # @rbs!
36
- # type launch_options = {
37
- # ?executable_path: String,
38
- # ?user_data_dir: String,
39
- # ?headless: bool,
40
- # ?args: Array[String],
41
- # ?timeout: Numeric
42
- # }
43
-
44
35
  # Launch a new browser instance
45
- # @rbs **options: launch_options -- Launch options
36
+ # @rbs executable_path: String
37
+ # @rbs user_data_dir: String
38
+ # @rbs headless: bool
39
+ # @rbs args: Array[String]
40
+ # @rbs timeout: Numeric
46
41
  # @rbs return: Browser -- Browser instance
47
42
  def self.launch(**options)
48
43
  Browser.launch(**options)
data/sig/_external.rbs CHANGED
@@ -126,9 +126,3 @@ class DateTime
126
126
  def to_time: () -> Time
127
127
  end
128
128
 
129
- # Puppeteer::Bidi types that rbs-inline doesn't generate correctly
130
- module Puppeteer
131
- module Bidi
132
- type target = BrowserTarget | PageTarget | FrameTarget
133
- end
134
- end
@@ -22,12 +22,14 @@ module Puppeteer
22
22
  # @rbs return: void
23
23
  def initialize: (connection: Connection, launcher: BrowserLauncher?, core_browser: Core::Browser, session: Core::Session) -> void
24
24
 
25
- type launch_options = { ?executable_path: String, ?user_data_dir: String, ?headless: bool, ?args: Array[String], ?timeout: Numeric }
26
-
27
25
  # Launch a new Firefox browser instance
28
- # @rbs **options: launch_options -- Launch options
26
+ # @rbs executable_path: String
27
+ # @rbs user_data_dir: String
28
+ # @rbs headless: bool
29
+ # @rbs args: Array[String]
30
+ # @rbs timeout: Numeric
29
31
  # @rbs return: Browser -- Browser instance
30
- def self.launch: (**launch_options options) -> Browser
32
+ def self.launch: (**untyped options) -> Browser
31
33
 
32
34
  # Connect to an existing Firefox browser instance
33
35
  # @rbs ws_endpoint: String -- WebSocket endpoint URL
@@ -61,9 +63,9 @@ module Puppeteer
61
63
 
62
64
  # Wait until a target (top-level browsing context) satisfies the predicate.
63
65
  # @rbs timeout: Integer? -- Timeout in milliseconds (default: 30000)
64
- # @rbs &predicate: (target) -> boolish -- Predicate evaluated against each Target
65
- # @rbs return: target -- Matching target
66
- def wait_for_target: (?timeout: Integer?) { (target) -> boolish } -> target
66
+ # @rbs &predicate: (BrowserTarget | PageTarget | FrameTarget) -> boolish -- Predicate evaluated against each Target
67
+ # @rbs return: BrowserTarget | PageTarget | FrameTarget -- Matching target
68
+ def wait_for_target: (?timeout: Integer?) { (BrowserTarget | PageTarget | FrameTarget) -> boolish } -> (BrowserTarget | PageTarget | FrameTarget)
67
69
 
68
70
  # Wait for browser process to exit
69
71
  # @rbs return: void
@@ -71,13 +73,13 @@ module Puppeteer
71
73
 
72
74
  private
73
75
 
74
- # @rbs &block: (target) -> void -- Block to yield each target to
75
- # @rbs return: Enumerator[target, void] -- Enumerator of targets
76
- def each_target: () { (target) -> void } -> Enumerator[target, void]
76
+ # @rbs &block: (BrowserTarget | PageTarget | FrameTarget) -> void -- Block to yield each target to
77
+ # @rbs return: Enumerator[BrowserTarget | PageTarget | FrameTarget, void] -- Enumerator of targets
78
+ def each_target: () { (BrowserTarget | PageTarget | FrameTarget) -> void } -> Enumerator[BrowserTarget | PageTarget | FrameTarget, void]
77
79
 
78
- # @rbs predicate: ^(target) -> boolish -- Predicate to match targets
79
- # @rbs return: target? -- Matching target or nil
80
- def find_target: (^(target) -> boolish predicate) -> target?
80
+ # @rbs predicate: ^(BrowserTarget | PageTarget | FrameTarget) -> boolish -- Predicate to match targets
81
+ # @rbs return: (BrowserTarget | PageTarget | FrameTarget)? -- Matching target or nil
82
+ def find_target: (^(BrowserTarget | PageTarget | FrameTarget) -> boolish predicate) -> (BrowserTarget | PageTarget | FrameTarget)?
81
83
 
82
84
  # @rbs user_context: Core::UserContext -- User context to get browser context for
83
85
  # @rbs return: BrowserContext? -- Browser context or nil
@@ -50,8 +50,8 @@ module Puppeteer
50
50
  def last_redirect: () -> Request?
51
51
 
52
52
  # Get request initiator information
53
- # @rbs return: Hash[String, untyped]? -- Initiator info
54
- def initiator: () -> Hash[String, untyped]?
53
+ # @rbs return: untyped -- Initiator info (mixed String/Symbol keys)
54
+ def initiator: () -> untyped
55
55
 
56
56
  # Check if the request is blocked
57
57
  # @rbs return: bool -- Whether the request is blocked
@@ -6,7 +6,7 @@ module Puppeteer
6
6
  # Provides shared lifecycle management for WaitTask instances.
7
7
  # https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/api/Realm.ts
8
8
  class Realm
9
- attr_reader task_manager: TaskManager
9
+ attr_reader task_manager: Puppeteer::Bidi::TaskManager
10
10
 
11
11
  # @rbs timeout_settings: TimeoutSettings -- Timeout settings
12
12
  # @rbs return: void
@@ -0,0 +1,36 @@
1
+ # Generated from lib/puppeteer/bidi/task_manager.rb with RBS::Inline
2
+
3
+ module Puppeteer
4
+ module Bidi
5
+ # TaskManager tracks active WaitTask instances to enable coordinated lifecycle management
6
+ # This is a faithful port of Puppeteer's TaskManager implementation:
7
+ # https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/common/WaitTask.ts
8
+ class TaskManager
9
+ # @rbs return: void
10
+ def initialize: () -> void
11
+
12
+ # Add a task to the manager
13
+ # Corresponds to Puppeteer's add(task: WaitTask<any>): void
14
+ # @rbs task: WaitTask -- Task to add
15
+ # @rbs return: void
16
+ def add: (WaitTask task) -> void
17
+
18
+ # Delete a task from the manager
19
+ # Corresponds to Puppeteer's delete(task: WaitTask<any>): void
20
+ # @rbs task: WaitTask -- Task to delete
21
+ # @rbs return: void
22
+ def delete: (WaitTask task) -> void
23
+
24
+ # Terminate all tasks with an optional error
25
+ # Corresponds to Puppeteer's terminateAll(error?: Error): void
26
+ # @rbs error: Exception? -- Error to terminate with
27
+ # @rbs return: void
28
+ def terminate_all: (?Exception? error) -> void
29
+
30
+ # Rerun all tasks in parallel
31
+ # Corresponds to Puppeteer's async rerunAll(): Promise<void>
32
+ # @rbs return: void
33
+ def rerun_all: () -> void
34
+ end
35
+ end
36
+ end
@@ -2,12 +2,14 @@
2
2
 
3
3
  module Puppeteer
4
4
  module Bidi
5
- type launch_options = { ?executable_path: String, ?user_data_dir: String, ?headless: bool, ?args: Array[String], ?timeout: Numeric }
6
-
7
5
  # Launch a new browser instance
8
- # @rbs **options: launch_options -- Launch options
6
+ # @rbs executable_path: String
7
+ # @rbs user_data_dir: String
8
+ # @rbs headless: bool
9
+ # @rbs args: Array[String]
10
+ # @rbs timeout: Numeric
9
11
  # @rbs return: Browser -- Browser instance
10
- def self.launch: (**launch_options options) -> Browser
12
+ def self.launch: (**untyped options) -> Browser
11
13
 
12
14
  # Connect to an existing browser instance
13
15
  # @rbs ws_endpoint: String -- WebSocket endpoint URL
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppeteer-bidi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta2
4
+ version: 0.0.1.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
@@ -180,6 +180,7 @@ files:
180
180
  - sig/puppeteer/bidi/realm.rbs
181
181
  - sig/puppeteer/bidi/serializer.rbs
182
182
  - sig/puppeteer/bidi/target.rbs
183
+ - sig/puppeteer/bidi/task_manager.rbs
183
184
  - sig/puppeteer/bidi/timeout_settings.rbs
184
185
  - sig/puppeteer/bidi/transport.rbs
185
186
  - sig/puppeteer/bidi/wait_task.rbs