tauri-plugin-debug-tools 0.1.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.
- package/AGENTS.md +346 -0
- package/LICENSE +21 -0
- package/README.md +303 -0
- package/dist-js/consoleLogger.d.ts +92 -0
- package/dist-js/consoleLogger.d.ts.map +1 -0
- package/dist-js/consoleLogger.js +317 -0
- package/dist-js/debugBridge.d.ts +50 -0
- package/dist-js/debugBridge.d.ts.map +1 -0
- package/dist-js/debugBridge.js +66 -0
- package/dist-js/index.d.ts +3 -0
- package/dist-js/index.d.ts.map +1 -0
- package/dist-js/index.js +2 -0
- package/dist-js/logAdapter.d.ts +36 -0
- package/dist-js/logAdapter.d.ts.map +1 -0
- package/dist-js/logAdapter.js +42 -0
- package/dist-js/screenshotHelper.d.ts +60 -0
- package/dist-js/screenshotHelper.d.ts.map +1 -0
- package/dist-js/screenshotHelper.js +100 -0
- package/examples/.vscode/extensions.json +3 -0
- package/examples/README.md +51 -0
- package/examples/bun.lock +265 -0
- package/examples/package.json +19 -0
- package/examples/src/assets/javascript.svg +1 -0
- package/examples/src/assets/tauri.svg +6 -0
- package/examples/src/index.html +56 -0
- package/examples/src/main.js +91 -0
- package/examples/src/styles.css +112 -0
- package/examples/src-tauri/Cargo.lock +5674 -0
- package/examples/src-tauri/Cargo.toml +25 -0
- package/examples/src-tauri/build.rs +3 -0
- package/examples/src-tauri/capabilities/default.json +7 -0
- package/examples/src-tauri/icons/128x128.png +0 -0
- package/examples/src-tauri/icons/128x128@2x.png +0 -0
- package/examples/src-tauri/icons/32x32.png +0 -0
- package/examples/src-tauri/icons/Square107x107Logo.png +0 -0
- package/examples/src-tauri/icons/Square142x142Logo.png +0 -0
- package/examples/src-tauri/icons/Square150x150Logo.png +0 -0
- package/examples/src-tauri/icons/Square284x284Logo.png +0 -0
- package/examples/src-tauri/icons/Square30x30Logo.png +0 -0
- package/examples/src-tauri/icons/Square310x310Logo.png +0 -0
- package/examples/src-tauri/icons/Square44x44Logo.png +0 -0
- package/examples/src-tauri/icons/Square71x71Logo.png +0 -0
- package/examples/src-tauri/icons/Square89x89Logo.png +0 -0
- package/examples/src-tauri/icons/StoreLogo.png +0 -0
- package/examples/src-tauri/icons/icon.icns +0 -0
- package/examples/src-tauri/icons/icon.ico +0 -0
- package/examples/src-tauri/icons/icon.png +0 -0
- package/examples/src-tauri/src/lib.rs +15 -0
- package/examples/src-tauri/src/main.rs +6 -0
- package/examples/src-tauri/tauri.conf.json +33 -0
- package/examples/tests/e2e.mac.test.ts +203 -0
- package/examples/tests/e2e.test.ts +131 -0
- package/examples/vitest.config.ts +10 -0
- package/guest-js/consoleLogger.ts +369 -0
- package/guest-js/debugBridge.ts +93 -0
- package/guest-js/index.ts +2 -0
- package/guest-js/logAdapter.ts +62 -0
- package/guest-js/screenshotHelper.ts +122 -0
- package/package.json +84 -0
- package/permissions/autogenerated/commands/append_debug_logs.toml +13 -0
- package/permissions/autogenerated/commands/capture_webview_state.toml +13 -0
- package/permissions/autogenerated/commands/get_console_logs.toml +13 -0
- package/permissions/autogenerated/commands/reset_debug_logs.toml +13 -0
- package/permissions/autogenerated/commands/send_debug_command.toml +13 -0
- package/permissions/autogenerated/commands/write_debug_snapshot.toml +13 -0
- package/permissions/autogenerated/reference.md +201 -0
- package/permissions/debug-with-logging.toml +26 -0
- package/permissions/default.toml +26 -0
- package/permissions/schemas/schema.json +384 -0
- package/skills/debug-tauri/SKILL.md +114 -0
- package/skills/debug-tauri/references/IPC_COMMANDS.md +196 -0
- package/skills/debug-tauri/references/LOGGING.md +195 -0
- package/skills/debug-tauri/references/MIGRATION.md +487 -0
- package/skills/debug-tauri/references/REFERENCE.md +206 -0
- package/skills/debug-tauri/references/REPORT_TEMPLATE.md +166 -0
- package/skills/debug-tauri/references/SCREENSHOTS.md +193 -0
- package/skills/debug-tauri/references/TROUBLESHOOTING.md +144 -0
- package/skills/debug-tauri/scripts/analyze_logs.sh +127 -0
- package/skills/debug-tauri/scripts/capture.sh +89 -0
- package/skills/debug-tauri/scripts/validate_setup.sh +181 -0
- package/src/commands.rs +147 -0
- package/src/lib.rs +41 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Tauri WebView Debugger - Detailed Reference
|
|
2
|
+
|
|
3
|
+
## Table of Contents
|
|
4
|
+
- Tauri IPC command list
|
|
5
|
+
- macOS screencapture commands
|
|
6
|
+
- WebGPU Debug API (planned for Phase 4)
|
|
7
|
+
- Process information
|
|
8
|
+
- Troubleshooting
|
|
9
|
+
- File path references
|
|
10
|
+
- Reference links
|
|
11
|
+
|
|
12
|
+
## Tauri IPC command list
|
|
13
|
+
|
|
14
|
+
### capture_webview_state
|
|
15
|
+
|
|
16
|
+
Get the WebView internal state as JSON.
|
|
17
|
+
|
|
18
|
+
**TypeScript implementation:**
|
|
19
|
+
```typescript
|
|
20
|
+
import { captureWebViewState } from "@/lib/debugBridge";
|
|
21
|
+
|
|
22
|
+
const state = await captureWebViewState();
|
|
23
|
+
console.log(state);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Response example:**
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"url": "http://localhost:5173",
|
|
30
|
+
"title": "iori",
|
|
31
|
+
"user_agent": "TauriWebView/2.0",
|
|
32
|
+
"viewport": {
|
|
33
|
+
"width": 1200,
|
|
34
|
+
"height": 800
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### get_console_logs
|
|
40
|
+
|
|
41
|
+
Get console logs (currently returns an empty array).
|
|
42
|
+
|
|
43
|
+
**Future implementation:**
|
|
44
|
+
Hook `console.log` and similar calls on the frontend and send as Tauri events.
|
|
45
|
+
|
|
46
|
+
### send_debug_command
|
|
47
|
+
|
|
48
|
+
Send a debug command to the WebView (event-based).
|
|
49
|
+
|
|
50
|
+
**Example:**
|
|
51
|
+
```typescript
|
|
52
|
+
import { sendDebugCommand } from "@/lib/debugBridge";
|
|
53
|
+
|
|
54
|
+
await sendDebugCommand("get_gpu_state", { includeBuffers: true });
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### take_screenshot
|
|
58
|
+
|
|
59
|
+
Request a screenshot (system command recommended).
|
|
60
|
+
|
|
61
|
+
**Error message:**
|
|
62
|
+
```
|
|
63
|
+
Use system screencapture command instead.
|
|
64
|
+
Run: screencapture -x -T 0 /tmp/tauri_screenshot.png
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## macOS screencapture commands
|
|
68
|
+
|
|
69
|
+
### Full screen capture
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
screencapture -x -T 0 /tmp/screenshot.png
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Options:**
|
|
76
|
+
- `-x`: Disable sound
|
|
77
|
+
- `-T <seconds>`: Delay (0 = immediate)
|
|
78
|
+
|
|
79
|
+
### Window selection (interactive)
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
screencapture -w /tmp/window_screenshot.png
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The user clicks a window to select it.
|
|
86
|
+
|
|
87
|
+
### Specify a window ID for a specific process
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Get the window ID
|
|
91
|
+
osascript -e 'tell application "System Events" to get unix id of first process whose name is "<app-binary-name>"'
|
|
92
|
+
|
|
93
|
+
# Capture using that ID
|
|
94
|
+
screencapture -l <window-id> /tmp/tauri_window.png
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## WebGPU Debug API (planned for Phase 4)
|
|
98
|
+
|
|
99
|
+
### captureWebGPUState()
|
|
100
|
+
|
|
101
|
+
Capture WebGPU state comprehensively.
|
|
102
|
+
|
|
103
|
+
**Return value:**
|
|
104
|
+
```typescript
|
|
105
|
+
{
|
|
106
|
+
deviceInfo: GPUAdapterInfo,
|
|
107
|
+
bufferStats: {
|
|
108
|
+
particleBuffer: { size: number, usage: number },
|
|
109
|
+
uniformBuffer: { size: number, usage: number },
|
|
110
|
+
},
|
|
111
|
+
computeResults: Float32Array,
|
|
112
|
+
performanceMetrics: {
|
|
113
|
+
fps: number,
|
|
114
|
+
frameTime: number,
|
|
115
|
+
memoryUsage: number
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### getDeviceInfo()
|
|
121
|
+
|
|
122
|
+
Get GPU device information.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const info = await getDeviceInfo();
|
|
126
|
+
// { vendor: "Apple", architecture: "..." }
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### exportComputeResults()
|
|
130
|
+
|
|
131
|
+
Export compute shader results to the CPU.
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
const results = await exportComputeResults();
|
|
135
|
+
// Float32Array(100000) - particle position data
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### getPerformanceMetrics()
|
|
139
|
+
|
|
140
|
+
Get performance metrics.
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
const metrics = await getPerformanceMetrics();
|
|
144
|
+
// { fps: 60, frameTime: 16.67, memoryUsage: 197 }
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Process information
|
|
148
|
+
|
|
149
|
+
### Check running Tauri processes
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
ps aux | grep <app-binary-name> | grep -v grep
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Example output:**
|
|
156
|
+
```
|
|
157
|
+
user 94678 1.6 0.3 440546784 197920 s011 S+ 11:47AM 0:12.85 target/debug/<app-binary-name>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Process details
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
ps -p 94678 -o pid,vsz,rss,%cpu,%mem,command
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Troubleshooting
|
|
167
|
+
|
|
168
|
+
### Error: "Main window not found"
|
|
169
|
+
|
|
170
|
+
**Cause**: The main window is not running or the label differs.
|
|
171
|
+
|
|
172
|
+
**Fix:**
|
|
173
|
+
1. Ensure the app is running (e.g. `tauri dev`)
|
|
174
|
+
2. Ensure `tauri.conf.json` has `windows.label` set to "main"
|
|
175
|
+
|
|
176
|
+
### Error: "Process not found"
|
|
177
|
+
|
|
178
|
+
**Cause**: The target process is not running.
|
|
179
|
+
|
|
180
|
+
**Fix:**
|
|
181
|
+
```bash
|
|
182
|
+
# Example: from the project root
|
|
183
|
+
tauri dev
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Screenshot cannot be captured
|
|
187
|
+
|
|
188
|
+
**Cause**: Screen recording is not allowed in macOS privacy settings.
|
|
189
|
+
|
|
190
|
+
**Fix:**
|
|
191
|
+
1. System Settings > Privacy & Security > Screen Recording
|
|
192
|
+
2. Select Screen Recording
|
|
193
|
+
3. Add Terminal (or the launcher) to the allowed list
|
|
194
|
+
|
|
195
|
+
## File path references
|
|
196
|
+
|
|
197
|
+
### Reference (optional)
|
|
198
|
+
|
|
199
|
+
- If there is a debug command implementation such as `src-tauri/src/commands/debug.rs`, you can collect logs with `append_debug_logs` and similar commands.
|
|
200
|
+
- If you provide a frontend bridge like `src/lib/debugBridge.ts`, it becomes easier to fetch state via IPC.
|
|
201
|
+
|
|
202
|
+
## Reference links
|
|
203
|
+
|
|
204
|
+
- [Tauri IPC Commands](https://v2.tauri.app/develop/calling-rust/)
|
|
205
|
+
- [Claude Code Skills Documentation](https://code.claude.com/docs/ja/skills)
|
|
206
|
+
- [macOS screencapture man page](https://ss64.com/osx/screencapture.html)
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Debug Report Template
|
|
2
|
+
|
|
3
|
+
Use this exact structure for consistency:
|
|
4
|
+
|
|
5
|
+
````markdown
|
|
6
|
+
# Tauri Debug Report - [YYYY-MM-DD HH:MM]
|
|
7
|
+
|
|
8
|
+
## Screenshot
|
|
9
|
+
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
## Process Status
|
|
13
|
+
|
|
14
|
+
- Status: [Running/Not Running]
|
|
15
|
+
- PID: [pid]
|
|
16
|
+
- Memory (RSS): [MB]
|
|
17
|
+
- CPU: [percentage]%
|
|
18
|
+
- Command: [command line]
|
|
19
|
+
|
|
20
|
+
## Console Logs
|
|
21
|
+
|
|
22
|
+
### Error Count: [N]
|
|
23
|
+
|
|
24
|
+
### Warning Count: [N]
|
|
25
|
+
|
|
26
|
+
### Recent Errors
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
[error logs from last 5 entries]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Recent Warnings
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
[warning logs from last 5 entries]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Log Statistics
|
|
39
|
+
|
|
40
|
+
- Total logs: [N]
|
|
41
|
+
- Errors: [N]
|
|
42
|
+
- Warnings: [N]
|
|
43
|
+
- Info: [N]
|
|
44
|
+
- Debug: [N]
|
|
45
|
+
|
|
46
|
+
## WebView State
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"url": "...",
|
|
51
|
+
"title": "...",
|
|
52
|
+
"user_agent": "...",
|
|
53
|
+
"viewport": {
|
|
54
|
+
"width": ...,
|
|
55
|
+
"height": ...
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Visual Analysis
|
|
61
|
+
|
|
62
|
+
### UI State
|
|
63
|
+
|
|
64
|
+
[Description of visible UI elements, current screen, navigation state]
|
|
65
|
+
|
|
66
|
+
### Identified Issues
|
|
67
|
+
|
|
68
|
+
- [ ] Issue 1: [description with location/screenshot reference]
|
|
69
|
+
- [ ] Issue 2: [description with location/screenshot reference]
|
|
70
|
+
- [ ] Issue 3: [description with location/screenshot reference]
|
|
71
|
+
|
|
72
|
+
### Layout Problems
|
|
73
|
+
|
|
74
|
+
[Any layout issues, misalignments, overflow, or rendering problems]
|
|
75
|
+
|
|
76
|
+
### Error Indicators
|
|
77
|
+
|
|
78
|
+
[Visible error messages, banners, toast notifications, console output]
|
|
79
|
+
|
|
80
|
+
## Performance Analysis
|
|
81
|
+
|
|
82
|
+
### Memory Usage
|
|
83
|
+
|
|
84
|
+
- RSS: [MB]
|
|
85
|
+
- VSZ: [MB]
|
|
86
|
+
- Trend: [increasing/stable/decreasing]
|
|
87
|
+
|
|
88
|
+
### CPU Usage
|
|
89
|
+
|
|
90
|
+
- Current: [%]
|
|
91
|
+
- Average: [%]
|
|
92
|
+
- Spikes: [yes/no, describe if yes]
|
|
93
|
+
|
|
94
|
+
### Rendering
|
|
95
|
+
|
|
96
|
+
- FPS: [if available]
|
|
97
|
+
- Frame drops: [yes/no]
|
|
98
|
+
- GPU usage: [if available]
|
|
99
|
+
|
|
100
|
+
## Root Cause Analysis
|
|
101
|
+
|
|
102
|
+
### Primary Cause
|
|
103
|
+
|
|
104
|
+
[Analysis based on collected evidence from logs, screenshots, and state]
|
|
105
|
+
|
|
106
|
+
### Contributing Factors
|
|
107
|
+
|
|
108
|
+
1. [Factor 1]
|
|
109
|
+
2. [Factor 2]
|
|
110
|
+
3. [Factor 3]
|
|
111
|
+
|
|
112
|
+
### Evidence
|
|
113
|
+
|
|
114
|
+
- Log evidence: [specific errors/warnings]
|
|
115
|
+
- Visual evidence: [screenshot observations]
|
|
116
|
+
- State evidence: [WebView state anomalies]
|
|
117
|
+
|
|
118
|
+
## Recommendations
|
|
119
|
+
|
|
120
|
+
### Immediate Actions
|
|
121
|
+
|
|
122
|
+
1. **[Action 1]**
|
|
123
|
+
- Implementation: [specific code changes or commands]
|
|
124
|
+
- Expected outcome: [what should change]
|
|
125
|
+
- Risk: [low/medium/high]
|
|
126
|
+
|
|
127
|
+
2. **[Action 2]**
|
|
128
|
+
- Implementation: [specific code changes or commands]
|
|
129
|
+
- Expected outcome: [what should change]
|
|
130
|
+
- Risk: [low/medium/high]
|
|
131
|
+
|
|
132
|
+
### Long-term Improvements
|
|
133
|
+
|
|
134
|
+
1. [Improvement 1 with rationale]
|
|
135
|
+
2. [Improvement 2 with rationale]
|
|
136
|
+
3. [Improvement 3 with rationale]
|
|
137
|
+
|
|
138
|
+
## Next Steps
|
|
139
|
+
|
|
140
|
+
- [ ] Implement fix for [specific issue]
|
|
141
|
+
- [ ] Test in [environment/scenario]
|
|
142
|
+
- [ ] Monitor [specific metric/behavior]
|
|
143
|
+
- [ ] Document changes in [location]
|
|
144
|
+
- [ ] Verify fix with [validation method]
|
|
145
|
+
|
|
146
|
+
## Additional Notes
|
|
147
|
+
|
|
148
|
+
[Any other observations, edge cases, or relevant context]
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
**Report generated by**: [Your name/automated tool]
|
|
153
|
+
**Review status**: [Pending/Reviewed/Implemented]
|
|
154
|
+
````
|
|
155
|
+
|
|
156
|
+
## Usage Tips
|
|
157
|
+
|
|
158
|
+
1. **Fill sections progressively** as you complete each debug workflow step
|
|
159
|
+
2. **Be specific** in root cause analysis - avoid vague statements
|
|
160
|
+
3. **Include evidence** - reference specific log lines, screenshot areas
|
|
161
|
+
4. **Actionable recommendations** - provide exact commands or code changes
|
|
162
|
+
5. **Track progress** - check off items as you implement fixes
|
|
163
|
+
|
|
164
|
+
## Example Report
|
|
165
|
+
|
|
166
|
+
See `examples/sample_debug_report.md` (if created) for a filled example.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Screenshot Capture Reference
|
|
2
|
+
|
|
3
|
+
## Official Plugin (Recommended)
|
|
4
|
+
|
|
5
|
+
Use `tauri-plugin-screenshots` for cross-platform screenshot capture.
|
|
6
|
+
|
|
7
|
+
### Quick Start
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { captureMainWindow } from "tauri-plugin-debug-tools/screenshotHelper";
|
|
11
|
+
|
|
12
|
+
// Capture main window as base64 PNG
|
|
13
|
+
const screenshot = await captureMainWindow();
|
|
14
|
+
if (screenshot) {
|
|
15
|
+
console.log("Screenshot captured successfully");
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Available Methods
|
|
20
|
+
|
|
21
|
+
#### captureMainWindow()
|
|
22
|
+
|
|
23
|
+
Captures the first available window.
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { captureMainWindow } from "tauri-plugin-debug-tools/screenshotHelper";
|
|
27
|
+
|
|
28
|
+
const imagePath = await captureMainWindow();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Returns**: `string | null` - Base64 PNG data or null if no windows
|
|
32
|
+
|
|
33
|
+
#### captureAllWindows()
|
|
34
|
+
|
|
35
|
+
Captures all application windows.
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { captureAllWindows } from "tauri-plugin-debug-tools/screenshotHelper";
|
|
39
|
+
|
|
40
|
+
const screenshots = await captureAllWindows();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Returns**: `string[]` - Array of base64 PNG data
|
|
44
|
+
|
|
45
|
+
#### capturePrimaryMonitor()
|
|
46
|
+
|
|
47
|
+
Captures the primary display.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { capturePrimaryMonitor } from "tauri-plugin-debug-tools/screenshotHelper";
|
|
51
|
+
|
|
52
|
+
const monitorScreenshot = await capturePrimaryMonitor();
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Returns**: `string | null` - Base64 PNG data or null if no monitors
|
|
56
|
+
|
|
57
|
+
### Advanced Usage
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import {
|
|
61
|
+
getScreenshotableWindows,
|
|
62
|
+
getWindowScreenshot,
|
|
63
|
+
getScreenshotableMonitors,
|
|
64
|
+
getMonitorScreenshot,
|
|
65
|
+
} from "tauri-plugin-screenshots-api";
|
|
66
|
+
|
|
67
|
+
// List available windows
|
|
68
|
+
const windows = await getScreenshotableWindows();
|
|
69
|
+
console.log(windows); // [{ id: 1, title: "My App" }, ...]
|
|
70
|
+
|
|
71
|
+
// Capture specific window
|
|
72
|
+
const screenshot = await getWindowScreenshot(windows[0].id);
|
|
73
|
+
|
|
74
|
+
// List available monitors
|
|
75
|
+
const monitors = await getScreenshotableMonitors();
|
|
76
|
+
|
|
77
|
+
// Capture specific monitor
|
|
78
|
+
const monitorShot = await getMonitorScreenshot(monitors[0].id);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Platform Support
|
|
82
|
+
|
|
83
|
+
- ✅ **macOS**: Full support
|
|
84
|
+
- ✅ **Windows**: Full support
|
|
85
|
+
- ✅ **Linux**: Full support (X11/Wayland)
|
|
86
|
+
|
|
87
|
+
### Permissions
|
|
88
|
+
|
|
89
|
+
Add to app capabilities:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"permissions": ["screenshots:default"]
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Legacy: macOS screencapture Command
|
|
98
|
+
|
|
99
|
+
### Full Screen Capture
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
screencapture -x -T 0 /tmp/screenshot.png
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Options:**
|
|
106
|
+
|
|
107
|
+
- `-x`: Disable sound
|
|
108
|
+
- `-T <seconds>`: Delay time (0 = execute immediately)
|
|
109
|
+
|
|
110
|
+
### Window Selection (Interactive)
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
screencapture -w /tmp/window_screenshot.png
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
User clicks to select the window.
|
|
117
|
+
|
|
118
|
+
### Specific Process Window by ID
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Get window ID
|
|
122
|
+
osascript -e 'tell application "System Events" to get unix id of first process whose name is "<app-binary-name>"'
|
|
123
|
+
|
|
124
|
+
# Capture by ID
|
|
125
|
+
screencapture -l <window-id> /tmp/tauri_window.png
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Automated Capture (Legacy)
|
|
129
|
+
|
|
130
|
+
**Deprecated**: Use official plugin API instead.
|
|
131
|
+
|
|
132
|
+
Legacy script for macOS only:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
TAURI_APP_NAME=<your-app> scripts/capture.sh
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
This script:
|
|
139
|
+
|
|
140
|
+
1. Verifies the app is running
|
|
141
|
+
2. Captures a timestamped screenshot
|
|
142
|
+
3. Returns the screenshot path
|
|
143
|
+
|
|
144
|
+
**Migration**: Replace with `captureMainWindow()` from plugin API for cross-platform support.
|
|
145
|
+
|
|
146
|
+
## Troubleshooting
|
|
147
|
+
|
|
148
|
+
### Error: Screenshot Not Captured
|
|
149
|
+
|
|
150
|
+
**Cause**: macOS privacy settings deny screen recording permission.
|
|
151
|
+
|
|
152
|
+
**Solution:**
|
|
153
|
+
|
|
154
|
+
1. System Preferences > Security & Privacy > Privacy
|
|
155
|
+
2. Select "Screen Recording"
|
|
156
|
+
3. Add Terminal (or execution source) to allowed list
|
|
157
|
+
|
|
158
|
+
### Permission Check
|
|
159
|
+
|
|
160
|
+
Run validation script:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
scripts/validate_setup.sh
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
This checks screen recording permissions and other debug requirements.
|
|
167
|
+
|
|
168
|
+
## Legacy: Platform-Specific CLI Tools
|
|
169
|
+
|
|
170
|
+
**Deprecated**: Use official plugin API for unified cross-platform support.
|
|
171
|
+
|
|
172
|
+
### Linux (Legacy)
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# Using scrot
|
|
176
|
+
scrot /tmp/screenshot.png
|
|
177
|
+
|
|
178
|
+
# Using gnome-screenshot
|
|
179
|
+
gnome-screenshot -f /tmp/screenshot.png
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Windows (Legacy)
|
|
183
|
+
|
|
184
|
+
```powershell
|
|
185
|
+
# Using PowerShell
|
|
186
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
187
|
+
[System.Windows.Forms.SendKeys]::SendWait("{PRTSC}")
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## References
|
|
191
|
+
|
|
192
|
+
- [tauri-plugin-screenshots Repository](https://github.com/ayangweb/tauri-plugin-screenshots)
|
|
193
|
+
- [macOS screencapture man page](https://ss64.com/osx/screencapture.html) (legacy)
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Troubleshooting Guide
|
|
2
|
+
|
|
3
|
+
## Common Errors
|
|
4
|
+
|
|
5
|
+
### "Main window not found"
|
|
6
|
+
|
|
7
|
+
**Cause**: Main window is not launched or has different label name.
|
|
8
|
+
|
|
9
|
+
**Solution:**
|
|
10
|
+
|
|
11
|
+
1. Verify app is running: `ps aux | grep <app-binary-name>`
|
|
12
|
+
2. Check `tauri.conf.json` has `windows.label` set to "main"
|
|
13
|
+
3. Start app if not running: `tauri dev`
|
|
14
|
+
|
|
15
|
+
### "Process not found"
|
|
16
|
+
|
|
17
|
+
**Cause**: Target process is not running.
|
|
18
|
+
|
|
19
|
+
**Solution:**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Start app from project root
|
|
23
|
+
tauri dev
|
|
24
|
+
|
|
25
|
+
# Or for production build
|
|
26
|
+
./target/release/<app-binary-name>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Verify process:**
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
TAURI_APP_NAME=<your-app> scripts/capture.sh
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Screenshot Capture Fails
|
|
36
|
+
|
|
37
|
+
**Cause**: macOS privacy settings deny screen recording.
|
|
38
|
+
|
|
39
|
+
**Solution:**
|
|
40
|
+
|
|
41
|
+
1. System Preferences > Security & Privacy > Privacy
|
|
42
|
+
2. Select "Screen Recording"
|
|
43
|
+
3. Add Terminal (or IDE) to allowed list
|
|
44
|
+
4. Restart terminal/IDE
|
|
45
|
+
|
|
46
|
+
**Quick check:**
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
scripts/validate_setup.sh
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Console Logs Empty
|
|
53
|
+
|
|
54
|
+
**Cause**: Frontend logger not initialized or logs not being captured.
|
|
55
|
+
|
|
56
|
+
**Solutions:**
|
|
57
|
+
|
|
58
|
+
**Option 1**: Ensure frontend logger is initialized
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
import { initConsoleLogger } from "tauri-plugin-debug-tools/consoleLogger";
|
|
62
|
+
|
|
63
|
+
initConsoleLogger();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Option 2**: Check log file exists
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
ls -lh /tmp/tauri_console_logs.jsonl
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**Option 3**: Use IPC method
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const logs = await invoke("plugin:debug-tools|get_console_logs");
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### WebView State Returns Null
|
|
79
|
+
|
|
80
|
+
**Cause**: WebView not fully initialized or permissions issue.
|
|
81
|
+
|
|
82
|
+
**Solutions:**
|
|
83
|
+
|
|
84
|
+
1. Wait for WebView ready event
|
|
85
|
+
2. Verify debug permissions in `capabilities/default.json`
|
|
86
|
+
3. Check Tauri version compatibility (requires v2.0+)
|
|
87
|
+
|
|
88
|
+
### Permission Denied Errors
|
|
89
|
+
|
|
90
|
+
**Cause**: Missing debug permissions in app capabilities.
|
|
91
|
+
|
|
92
|
+
**Solution:**
|
|
93
|
+
|
|
94
|
+
Add to `src-tauri/capabilities/default.json`:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"permissions": [
|
|
99
|
+
"debug-tools:allow-capture-webview-state",
|
|
100
|
+
"debug-tools:allow-get-console-logs",
|
|
101
|
+
"debug-tools:allow-send-debug-command"
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Validation Checklist
|
|
107
|
+
|
|
108
|
+
Run this before debugging:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
scripts/validate_setup.sh
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Manual checks:
|
|
115
|
+
|
|
116
|
+
- [ ] App is running (verify with `ps aux | grep <app-name>`)
|
|
117
|
+
- [ ] Screen recording permission granted (macOS)
|
|
118
|
+
- [ ] Debug permissions enabled in capabilities
|
|
119
|
+
- [ ] Frontend logger initialized (if using log collection)
|
|
120
|
+
- [ ] Tauri version >= 2.0
|
|
121
|
+
|
|
122
|
+
## Getting Help
|
|
123
|
+
|
|
124
|
+
If issues persist:
|
|
125
|
+
|
|
126
|
+
1. Check plugin version compatibility
|
|
127
|
+
2. Review Tauri logs: `tauri dev --verbose`
|
|
128
|
+
3. Validate setup: `scripts/validate_setup.sh`
|
|
129
|
+
4. Consult [Tauri documentation](https://v2.tauri.app)
|
|
130
|
+
|
|
131
|
+
## File Path References
|
|
132
|
+
|
|
133
|
+
**Debug command implementation:**
|
|
134
|
+
|
|
135
|
+
- `src-tauri/src/commands/debug.rs` (if exists)
|
|
136
|
+
|
|
137
|
+
**Frontend bridge:**
|
|
138
|
+
|
|
139
|
+
- `src/lib/debugBridge.ts` (recommended location)
|
|
140
|
+
|
|
141
|
+
**Log output:**
|
|
142
|
+
|
|
143
|
+
- `/tmp/tauri_console_logs.jsonl` (default)
|
|
144
|
+
- `/tmp/tauri_debug_*.png` (screenshots)
|