Commit 919e9f3
authored
fix: support file exports in Tauri webview (#763)
* fix: support file exports in Tauri webview
Adds a cross-platform download utility (src/util/export.ts) that
detects Tauri webview at runtime and uses native save dialog +
filesystem plugins instead of the browser download pattern which
doesn't work in webviews.
All 5 export functions (categories JSON, bucket JSON, all buckets
JSON, bucket CSV, report JSON/CSV) now use the shared utility.
Browser behavior is unchanged — the utility falls back to the
existing Blob + createObjectURL pattern in non-Tauri contexts.
Requires companion change in aw-tauri to register tauri-plugin-fs
and add fs:default permission.
Fixes ActivityWatch/aw-tauri#199
* fix: use bundler-ignore comments for optional Tauri plugin imports
The @tauri-apps/plugin-dialog and @tauri-apps/plugin-fs modules are not
in package.json since they're only available in the aw-tauri runtime.
The dynamic imports with try/catch already handle graceful fallback, but
bundlers (webpack, vite) still try to resolve modules at build time.
Add webpackIgnore and @vite-ignore magic comments to skip static resolution
while keeping the dynamic import pattern intact.
* fix: use new Function() to bypass bundler static analysis for Tauri imports
webpack4 doesn't support /* webpackIgnore */ magic comments, and rollup
ignores /* @vite-ignore */ during production builds. Using new Function()
to create a runtime-only dynamic import bypasses static analysis in both
bundlers while still working correctly in the Tauri webview at runtime.
* fix: guard against empty events array in export_csv1 parent cd5aafe commit 919e9f3
File tree
5 files changed
+138
-47
lines changed- src
- util
- views
- settings
5 files changed
+138
-47
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
| 51 | + | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
| |||
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 102 | + | |
| 103 | + | |
106 | 104 | | |
107 | 105 | | |
108 | 106 | | |
| |||
160 | 158 | | |
161 | 159 | | |
162 | 160 | | |
| 161 | + | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| |||
255 | 254 | | |
256 | 255 | | |
257 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
258 | 269 | | |
259 | 270 | | |
260 | 271 | | |
261 | | - | |
| 272 | + | |
262 | 273 | | |
263 | 274 | | |
264 | 275 | | |
| |||
267 | 278 | | |
268 | 279 | | |
269 | 280 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
| 281 | + | |
275 | 282 | | |
276 | 283 | | |
277 | | - | |
278 | | - | |
279 | | - | |
| 284 | + | |
280 | 285 | | |
281 | 286 | | |
282 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
164 | | - | |
| 165 | + | |
165 | 166 | | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 167 | + | |
174 | 168 | | |
175 | 169 | | |
176 | | - | |
| 170 | + | |
177 | 171 | | |
178 | 172 | | |
179 | 173 | | |
180 | 174 | | |
181 | 175 | | |
182 | 176 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
| 177 | + | |
191 | 178 | | |
192 | 179 | | |
193 | 180 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 110 | + | |
123 | 111 | | |
124 | 112 | | |
125 | 113 | | |
| |||
0 commit comments