webtap-tool 0.5.0__tar.gz → 0.5.1__tar.gz

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.

Potentially problematic release.


This version of webtap-tool might be problematic. Click here for more details.

Files changed (58) hide show
  1. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/CHANGELOG.md +15 -0
  2. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/PKG-INFO +1 -1
  3. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/pyproject.toml +1 -1
  4. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/javascript.py +25 -7
  5. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/.gitignore +0 -0
  6. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/ARCHITECTURE.md +0 -0
  7. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/README.md +0 -0
  8. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/data/filters.json +0 -0
  9. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/extension/content.js +0 -0
  10. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/extension/manifest.json +0 -0
  11. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/extension/sidepanel.html +0 -0
  12. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/extension/sidepanel.js +0 -0
  13. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/llms.txt +0 -0
  14. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/VISION.md +0 -0
  15. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/__init__.py +0 -0
  16. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/api.py +0 -0
  17. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/app.py +0 -0
  18. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/cdp/README.md +0 -0
  19. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/cdp/__init__.py +0 -0
  20. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/cdp/query.py +0 -0
  21. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/cdp/schema/README.md +0 -0
  22. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/cdp/schema/cdp_protocol.json +0 -0
  23. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/cdp/schema/cdp_version.json +0 -0
  24. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/cdp/session.py +0 -0
  25. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/DEVELOPER_GUIDE.md +0 -0
  26. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/TIPS.md +0 -0
  27. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/__init__.py +0 -0
  28. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/_builders.py +0 -0
  29. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/_tips.py +0 -0
  30. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/_utils.py +0 -0
  31. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/body.py +0 -0
  32. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/connection.py +0 -0
  33. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/console.py +0 -0
  34. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/events.py +0 -0
  35. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/fetch.py +0 -0
  36. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/filters.py +0 -0
  37. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/inspect.py +0 -0
  38. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/launch.py +0 -0
  39. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/navigation.py +0 -0
  40. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/network.py +0 -0
  41. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/selections.py +0 -0
  42. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/server.py +0 -0
  43. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/commands/setup.py +0 -0
  44. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/filters.py +0 -0
  45. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/README.md +0 -0
  46. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/__init__.py +0 -0
  47. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/body.py +0 -0
  48. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/console.py +0 -0
  49. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/dom.py +0 -0
  50. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/fetch.py +0 -0
  51. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/main.py +0 -0
  52. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/network.py +0 -0
  53. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/setup/__init__.py +0 -0
  54. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/setup/chrome.py +0 -0
  55. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/setup/desktop.py +0 -0
  56. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/setup/extension.py +0 -0
  57. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/setup/filters.py +0 -0
  58. {webtap_tool-0.5.0 → webtap_tool-0.5.1}/src/webtap/services/setup/platform.py +0 -0
@@ -15,6 +15,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
15
 
16
16
  ### Removed
17
17
 
18
+ ## [0.5.1] - 2025-10-09
19
+
20
+ ### Added
21
+ - **js() persist parameter**: New `persist` parameter to control variable scope across calls (default: False)
22
+
23
+ ### Changed
24
+ - **js() default scope**: Fresh scope by default (IIFE wrapping) to prevent const/let redeclaration errors
25
+ - **js() selection wrapping**: Selection parameter always uses fresh scope to avoid element redeclaration
26
+
27
+ ### Fixed
28
+ - **js() redeclaration errors**: Fixed "Identifier 'element' has already been declared" when using selection parameter multiple times
29
+ - **js() const/let errors**: Fixed redeclaration errors when running multiple js() calls with const/let
30
+
31
+ ### Removed
32
+
18
33
  ## [0.5.0] - 2025-10-09
19
34
 
20
35
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: webtap-tool
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Terminal-based web page inspector for AI debugging sessions
5
5
  Author-email: Fredrik Angelsen <fredrikangelsen@gmail.com>
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "webtap-tool"
3
- version = "0.5.0"
3
+ version = "0.5.1"
4
4
  description = "Terminal-based web page inspector for AI debugging sessions"
5
5
  readme = "README.md"
6
6
  authors = [
@@ -15,26 +15,39 @@ mcp_desc = get_mcp_description("js")
15
15
  },
16
16
  fastmcp={"type": "tool", "description": mcp_desc} if mcp_desc else {"type": "tool"},
17
17
  )
18
- def js(state, code: str, selection: int = None, wait_return: bool = True, await_promise: bool = False) -> dict: # pyright: ignore[reportArgumentType]
18
+ def js(
19
+ state,
20
+ code: str,
21
+ selection: int = None,
22
+ persist: bool = False,
23
+ wait_return: bool = True,
24
+ await_promise: bool = False,
25
+ ) -> dict: # pyright: ignore[reportArgumentType]
19
26
  """Execute JavaScript in the browser with optional element selection.
20
27
 
21
28
  Args:
22
29
  code: JavaScript code to execute (use 'element' variable if selection provided)
23
30
  selection: Browser element selection number (e.g., 1 for #1) - makes element available
31
+ persist: Keep variables in global scope across calls (default: False, uses fresh scope)
24
32
  wait_return: Wait for and return result (default: True)
25
33
  await_promise: Await promises before returning (default: False)
26
34
 
27
35
  Examples:
36
+ # Default: fresh scope (no redeclaration errors)
37
+ js("const x = 1") # ✓ x isolated
38
+ js("const x = 2") # ✓ No error, fresh scope
28
39
  js("document.title") # Get page title
29
- js("document.body.innerText.length") # Get text length
30
- js("console.log('test')", wait_return=False) # Fire and forget
31
40
  js("[...document.links].map(a => a.href)") # Get all links
32
41
 
33
- # With browser element selection
34
- js("element.offsetWidth", selection=1) # Use element #1 from browser()
42
+ # With browser element selection (always fresh scope)
43
+ js("element.offsetWidth", selection=1) # Use element #1
35
44
  js("element.classList", selection=2) # Use element #2
36
45
  js("element.getBoundingClientRect()", selection=1)
37
46
 
47
+ # Persistent scope: keep variables across calls
48
+ js("var data = fetch('/api')", persist=True) # data persists
49
+ js("data.json()", persist=True) # Access data from previous call
50
+
38
51
  # Async operations
39
52
  js("fetch('/api').then(r => r.json())", await_promise=True)
40
53
 
@@ -74,8 +87,13 @@ def js(state, code: str, selection: int = None, wait_return: bool = True, await_
74
87
  if not js_path:
75
88
  return error_response(f"Selection #{selection} has no jsPath")
76
89
 
77
- # Wrap code with element variable
78
- code = f"const element = {js_path}; {code}"
90
+ # Wrap code with element variable in fresh scope (IIFE)
91
+ # Selection always uses fresh scope to avoid element redeclaration errors
92
+ code = f"(() => {{ const element = {js_path}; return ({code}); }})()"
93
+ elif not persist:
94
+ # Default: wrap in IIFE for fresh scope (avoids const/let redeclaration errors)
95
+ code = f"(() => {{ return ({code}); }})()"
96
+ # else: persist=True, use code as-is (global scope)
79
97
 
80
98
  result = state.cdp.execute(
81
99
  "Runtime.evaluate", {"expression": code, "returnByValue": wait_return, "awaitPromise": await_promise}
File without changes
File without changes
File without changes
File without changes