drone-path 0.8.1 → 0.10.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +18 -25
  3. package/THIRD-PARTY-NOTICES.md +14 -7
  4. package/app/ipc.mjs +178 -0
  5. package/app/main.mjs +10 -150
  6. package/app/preload.cjs +3 -0
  7. package/dist/appassets.js +2 -11
  8. package/dist/apppaths.js +2 -10
  9. package/dist/appsession.js +59 -59
  10. package/dist/appstate.js +22 -38
  11. package/dist/assets.js +0 -7
  12. package/dist/buildinfo.js +71 -0
  13. package/dist/cammeta.js +127 -89
  14. package/dist/changeset-gate.js +0 -7
  15. package/dist/cli.js +3 -36
  16. package/dist/config.js +216 -167
  17. package/dist/configfile.js +0 -8
  18. package/dist/decimate.js +2 -12
  19. package/dist/exportjob.js +3 -19
  20. package/dist/ff.js +2 -27
  21. package/dist/fftools.js +0 -10
  22. package/dist/frametime.js +32 -0
  23. package/dist/geo.js +3 -13
  24. package/dist/inputs.js +0 -4
  25. package/dist/manual/anchors.js +1 -7
  26. package/dist/manual/build.js +0 -6
  27. package/dist/manual/cliref.js +0 -6
  28. package/dist/manual/links.js +0 -17
  29. package/dist/manual/markdown.js +2 -10
  30. package/dist/manual/model.js +0 -3
  31. package/dist/manual/module.js +0 -3
  32. package/dist/manual/nav.js +0 -2
  33. package/dist/manual/reference.js +1 -4
  34. package/dist/page.js +3 -26
  35. package/dist/paths.js +0 -12
  36. package/dist/plan.js +1 -18
  37. package/dist/png.js +1 -21
  38. package/dist/proto.js +4 -4
  39. package/dist/range.js +0 -8
  40. package/dist/render.js +38 -165
  41. package/dist/renderer/dom.js +0 -6
  42. package/dist/renderer/framemath.js +0 -4
  43. package/dist/renderer/scene.js +10 -34
  44. package/dist/renderer/theme.js +58 -10
  45. package/dist/renderer/tilesources.js +0 -10
  46. package/dist/renderer/trail.js +1 -12
  47. package/dist/restyle.js +1 -9
  48. package/dist/run.js +79 -143
  49. package/dist/serve.js +0 -13
  50. package/dist/srt.js +30 -8
  51. package/dist/summary.js +0 -3
  52. package/dist/telemetry-json-schema.js +23 -0
  53. package/dist/telemetry-json.js +113 -0
  54. package/dist/telemetry-math.js +11 -46
  55. package/dist/telemetry.js +58 -11
  56. package/dist/tilecache.js +0 -5
  57. package/dist/tiles.js +31 -117
  58. package/package.json +15 -13
  59. package/dist/renderer/leaflet.js +0 -5
  60. package/dist/tracing.js +0 -208
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # drone-path
2
2
 
3
+ ## 0.10.0
4
+
5
+ - **New:** Telemetry now comes from the embedded CAM meta (DVTM) stream
6
+ whenever a recording has one; the `.SRT` sidecar is only used when no
7
+ CAM meta stream is present. A CAM meta stream without GPS positions
8
+ fails the run with a clear error instead of silently falling back to
9
+ the sidecar.
10
+ - **New:** The opt-in OpenTelemetry trace export is removed along with
11
+ its `OTEL_*` environment variables. Stage logs, progress reporting
12
+ and rendered output are unchanged.
13
+
14
+ ## 0.9.0
15
+
16
+ - **New:** The flight trail is now configurable: `--trail-color <hex>`
17
+ (RGB or RGBA hex like `#e63946` or `#e63946cc`, `#` optional) and the
18
+ `trailColor` setting recolor the flight trail, the drone marker and
19
+ the HUD accents. Glow and casing are derived from the chosen color,
20
+ so the layered trail stays readable on both map styles; omitting the
21
+ option keeps the per-style theme defaults.
22
+ - **New:** `--telemetry-json <file>` exports per-frame telemetry —
23
+ time, position, altitude, body and gimbal attitude, heading and
24
+ camera exposure — as one versioned JSON document with a record per
25
+ source frame; the schema is checked in as
26
+ `docs/telemetry-json.schema.json`. The desktop workspace writes the
27
+ same document through Export telemetry…, straight from the loaded
28
+ recording (the In–Out segment or the full recording) and
29
+ byte-identical to the CLI output.
30
+ - **New:** The desktop workspace has a top menu bar with the workspace
31
+ actions moved into it: **File** holds Open… (Ctrl+O), Export video…,
32
+ Export telemetry…, Settings and Exit, **View** holds Swap (S), and
33
+ right-aligned **Help** holds Documentation and About. It follows
34
+ Windows menu conventions (click or Alt opens, hover switches, arrows
35
+ navigate, Enter/Space activate, Esc closes, Alt+F/V/H mnemonics) with
36
+ the accent-forward menu state styling. "Export…" is now "Export
37
+ video…" on every surface, the header and status footer keep only
38
+ their informational content, the auto-hidden native Electron menu is
39
+ gone, and Exit still guards against closing during a running export.
40
+ - **New:** **Help → About** shows the drone / path lockup, the running
41
+ build's version — `MAJOR.MINOR.PATCH` for releases,
42
+ `MAJOR.MINOR.PATCH+<short commit>` for every other build, injected at
43
+ build time — an MIT license line, and a link that opens the
44
+ `MrManny/drone-path` repository in the default browser.
45
+
3
46
  ## 0.8.1
4
47
 
5
48
  - **Fixed:** The GitHub repository moved to `MrManny/drone-path`:
package/README.md CHANGED
@@ -1,26 +1,18 @@
1
1
  # Drone Path
2
2
 
3
- This handy little tool allows you to render flight-path map videos
4
- from DJI drone recordings (DJI Neo 2 and similar).
3
+ This handy little tool renders flight-path map videos from DJI drone
4
+ recordings (DJI Neo 2 and similar): the actual flight path on a 2D map,
5
+ ready to overlay in your drone flight footage.
5
6
 
6
- I wanted a tool to render the actual flight-path on a 2d map,
7
- so that I can overlay it in the actual footage of my drone flight
8
- videos.
7
+ It reads geo-coordinates from DJI's telemetry in two ways:
9
8
 
10
- Currently, it supports two main ways to acquire the geo-coordinates from
11
- DJI's telemetry:
9
+ - the embedded CAM meta (DVTM) stream (DJI's protobuf format) is used when
10
+ the recording has one,
11
+ - otherwise an `.SRT` sidecar next to the recording is used.
12
12
 
13
- - if an `.SRT` sidecar is available, that will be used,
14
- - otherwise it tries to parse the embedded `CAM` meta stream (DJI's protobuf format).
15
-
16
- It is a CLI tool, since I plan to support agentic use cases.
17
- Meaning, if an agent wants to use it to help you create flight-path videos,
18
- that's all cool with me.
19
-
20
- For us humans, there is a desktop app (see *Desktop app*): it opens a window
21
- where you pick a recording and watch its flight path on the map in sync with
22
- the footage. The player opens as soon as the map tiles around the drone are
23
- ready and the rest of the map keeps loading in the background.
13
+ It is a CLI tool first, so agents can drive it too — that's all cool with me.
14
+ For us humans, there is a [desktop app](docs/user/desktop-app.md): pick a
15
+ recording and watch its flight path on the map in sync with the footage.
24
16
 
25
17
  ## Quick start
26
18
 
@@ -33,12 +25,15 @@ npx drone-path "my-flight.mp4"
33
25
 
34
26
  # topographic map, altitude + speed HUD
35
27
  npx drone-path "my-flight.mp4" --style topo --hud heading,alt,speed
28
+
29
+ # per-frame telemetry JSON alongside the render (one recording per run)
30
+ npx drone-path "my-flight.mp4" --telemetry-json "my-flight.telemetry.json"
36
31
  ```
37
32
 
38
33
  Output lands in the `out/` folder as `<basename>_map.mp4`; both the folder
39
- and the name are configurable. This needs Node.js 24 or newer and
34
+ and the name are configurable. Requirements: Node.js 24 or 26 and
40
35
  ffmpeg/ffprobe — bundled with the desktop app and the npm package,
41
- overridable via `--ffmpeg`/`--ffprobe`, with a `PATH` fallback; all
36
+ overridable via `--ffmpeg`/`--ffprobe`, with a `PATH` fallback. All
42
37
  requirements and install options are in
43
38
  [Getting started](docs/user/getting-started.md).
44
39
 
@@ -48,7 +43,7 @@ The user manual lives in [docs/user/](docs/user/README.md); the desktop app
48
43
  ships the same pages as offline help. Highlights:
49
44
 
50
45
  - [Getting started](docs/user/getting-started.md) — requirements, install options, and your first render.
51
- - [Desktop app](docs/user/desktop-app.md) — loading a recording, reviewing a flight, and exporting video from the app.
46
+ - [Desktop app](docs/user/desktop-app.md) — loading a recording, reviewing a flight, exporting video, and saving telemetry JSON from the app.
52
47
  - [Keyboard shortcuts](docs/user/keyboard-shortcuts.md) — every shortcut of the review player at a glance.
53
48
  - [CLI usage](docs/user/cli.md) — inputs, examples, and example output.
54
49
  - [CLI and config reference](docs/user/cli-reference.md) — every option and config key with its default.
@@ -65,8 +60,8 @@ For reviewing flights without the terminal, grab the packaged desktop app
65
60
  The app shows the footage and the synchronized flight map side by side —
66
61
  swappable to a map overlay — on one shared timeline;
67
62
  [the manual](docs/user/desktop-app.md) walks through loading a recording,
68
- reviewing a flight, looping a passage, and exporting. The look settings carry
69
- over between launches.
63
+ reviewing a flight, looping a passage, exporting, and saving the per-frame
64
+ telemetry JSON. The look settings carry over between launches.
70
65
 
71
66
  ![Desktop app: drone footage beside the synchronized flight map](docs/images/app-main-window.jpg)
72
67
 
@@ -77,8 +72,6 @@ with the flight trail, drone position and HUD chips on one shared timeline.*
77
72
 
78
73
  If you want or need specific features, feel free to open an issue in this
79
74
  repository's issue tracker.
80
- I plan to maintain this project for a good bit, and hopefully making it more
81
- useful for people in the long run.
82
75
 
83
76
  ## License
84
77
 
@@ -1,12 +1,12 @@
1
1
  # Third-party notices
2
2
 
3
- This repository vendors two icons from the [Lucide](https://lucide.dev) icon
4
- set as TypeScript components under `ui/icons/`: `CloseIcon` ("x") and
5
- `SettingsIcon` ("settings"). They are used unmodified except for JSX
6
- serialization and fixed sizing. The ISC License below applies to both; the MIT
7
- License additionally applies to `CloseIcon` ("x"), which Lucide derives from
8
- the Feather project. The other glyphs under `ui/icons/` are original work in
9
- the Lucide style and are not covered by these licenses.
3
+ The UI icons render from the [Lucide](https://lucide.dev) icon set via the
4
+ `lucide-react` npm package, a runtime dependency of the UI bundle; the
5
+ package's own LICENSE file ships with every install. Lucide releases its icons
6
+ under the ISC License below. Icons Lucide derives from the Feather project
7
+ additionally carry the MIT License below — among the icons this app renders,
8
+ `x`, `power`, `info` and `help-circle` are Feather-derived. `ui/icons/` holds
9
+ only the GitHub brand mark; see its note below.
10
10
 
11
11
  ## Lucide — ISC License
12
12
 
@@ -75,3 +75,10 @@ the npm install. The `ffmpeg-ffprobe-static` wrapper code itself is not part of
75
75
  the desktop distribution; its LICENSE file is BSD-3-Clause (Copyright (c) 2020,
76
76
  Eugene Ware and contributors) while its npm metadata declares
77
77
  GPL-3.0-or-later.
78
+
79
+ ## GitHub mark
80
+
81
+ `ui/icons/GitHubIcon.tsx` draws the GitHub octocat mark, used nominatively and
82
+ solely to link to the project's own GitHub repository from the About dialog.
83
+ The mark is a trademark of GitHub, Inc.; this use implies no affiliation with
84
+ or endorsement by GitHub.
package/app/ipc.mjs ADDED
@@ -0,0 +1,178 @@
1
+ // IPC for the app window: handlers throw plain Errors and the handle()
2
+ // envelope answers the renderer with { ok: false, error }.
3
+
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+
7
+ import { dialog, ipcMain, shell } from 'electron';
8
+
9
+ import { parsePickRequest, parseTelemetrySaveRequest } from '../dist/appsession.js';
10
+ import { applyAppState, writeAppState } from '../dist/appstate.js';
11
+ import { APP_ORIGIN, appStateFile } from '../dist/apppaths.js';
12
+ import { parseExportRequest, parseSettingsPatch } from '../dist/config.js';
13
+ import { errorMessage } from '../dist/errors.js';
14
+ import { videoBaseName } from '../dist/inputs.js';
15
+ import { outputPathFor } from '../dist/run.js';
16
+
17
+ // Only this app's window may drive the session state machine.
18
+ function assertTrusted(event, devUrl) {
19
+ const url = (event.senderFrame && event.senderFrame.url) || '';
20
+ const devOk = devUrl !== null && url.startsWith(devUrl);
21
+ if (!url.startsWith(APP_ORIGIN + '/') && !devOk) {
22
+ throw new Error('untrusted ipc sender');
23
+ }
24
+ }
25
+
26
+ function handle(devUrl, channel, fn) {
27
+ ipcMain.handle(channel, async (event, ...args) => {
28
+ // Outside the envelope: an untrusted sender must see a rejected promise,
29
+ // never a well-formed reply.
30
+ assertTrusted(event, devUrl);
31
+ try {
32
+ return await fn(...args);
33
+ } catch (e) {
34
+ return { ok: false, error: errorMessage(e) };
35
+ }
36
+ });
37
+ }
38
+
39
+ function requireVideo(state) {
40
+ const video = state.session ? state.session.videoPath() : null;
41
+ if (!video) throw new Error('no recording loaded');
42
+ return video;
43
+ }
44
+
45
+ // The reveal/open guard: the renderer may only name a file this shell wrote
46
+ // (the last export or the last telemetry document, both set only by trusted
47
+ // handlers), never an arbitrary path.
48
+ function knownOutputOf(state, payload) {
49
+ const out = payload && typeof payload === 'object' ? payload.out : null;
50
+ if (typeof out !== 'string' || (out !== state.lastExportOut && out !== state.lastTelemetryOut)) {
51
+ throw new Error('unknown output');
52
+ }
53
+ return out;
54
+ }
55
+
56
+ // The native dialog confirmed the name as typed, but the extension may have
57
+ // been appended after it: re-check the final path on every platform so an
58
+ // existing file is never replaced without a confirmation.
59
+ async function confirmReplace(state, chosen) {
60
+ if (!fs.existsSync(chosen)) return true;
61
+ const box = {
62
+ type: 'warning',
63
+ buttons: ['Replace', 'Cancel'],
64
+ defaultId: 1,
65
+ cancelId: 1,
66
+ message: `Replace ${path.basename(chosen)}?`,
67
+ detail: chosen,
68
+ };
69
+ const confirm = state.win
70
+ ? await dialog.showMessageBox(state.win, box)
71
+ : await dialog.showMessageBox(box);
72
+ return confirm.response === 0;
73
+ }
74
+
75
+ export function registerIpcHandlers(state, { devUrl, log, sendToWindow }) {
76
+ handle(devUrl, 'dronepath:pick', (raw) => state.session.pick(parsePickRequest(raw)));
77
+ handle(devUrl, 'dronepath:session', () => state.session.getSession());
78
+ handle(devUrl, 'dronepath:settings', () => state.config);
79
+ handle(devUrl, 'dronepath:settings:save', (raw) => {
80
+ const settings = parseSettingsPatch(raw, 'settings');
81
+ state.appState = { ...state.appState, settings };
82
+ state.config = applyAppState(state.config, state.appState);
83
+ try {
84
+ writeAppState(appStateFile(), state.appState);
85
+ } catch (e) {
86
+ // The look still applies when the state file cannot be written.
87
+ log(`app state not saved: ${errorMessage(e)}`);
88
+ }
89
+ return { ok: true };
90
+ });
91
+
92
+ handle(devUrl, 'dronepath:export:pick-output', async () => {
93
+ const video = requireVideo(state);
94
+ // The CLI's default naming, with a relative out dir anchored at the
95
+ // recording: the app process has no meaningful working directory.
96
+ const outDir = state.config.outDir
97
+ ? path.resolve(path.dirname(video), state.config.outDir)
98
+ : null;
99
+ const options = {
100
+ title: 'Export video',
101
+ defaultPath: outputPathFor(video, { ...state.config, outDir }),
102
+ filters: [{ name: 'MP4 video', extensions: ['mp4'] }],
103
+ };
104
+ const result = state.win
105
+ ? await dialog.showSaveDialog(state.win, options)
106
+ : await dialog.showSaveDialog(options);
107
+ if (result.canceled || !result.filePath) return { ok: false, canceled: true };
108
+ const chosen = result.filePath.toLowerCase().endsWith('.mp4')
109
+ ? result.filePath
110
+ : `${result.filePath}.mp4`;
111
+ if (!(await confirmReplace(state, chosen))) return { ok: false, canceled: true };
112
+ return { ok: true, path: chosen };
113
+ });
114
+ handle(devUrl, 'dronepath:telemetry:pick-output', async () => {
115
+ const video = requireVideo(state);
116
+ // The export dialog's default folder, named after the recording
117
+ // (<basename>.telemetry.json).
118
+ const outDir = state.config.outDir
119
+ ? path.resolve(path.dirname(video), state.config.outDir)
120
+ : null;
121
+ const exportDefault = outputPathFor(video, { ...state.config, outDir });
122
+ const options = {
123
+ title: 'Export telemetry',
124
+ defaultPath: path.join(path.dirname(exportDefault), `${videoBaseName(video)}.telemetry.json`),
125
+ filters: [{ name: 'JSON document', extensions: ['json'] }],
126
+ };
127
+ const result = state.win
128
+ ? await dialog.showSaveDialog(state.win, options)
129
+ : await dialog.showSaveDialog(options);
130
+ if (result.canceled || !result.filePath) return { ok: false, canceled: true };
131
+ const chosen = result.filePath.toLowerCase().endsWith('.json')
132
+ ? result.filePath
133
+ : `${result.filePath}.json`;
134
+ if (!(await confirmReplace(state, chosen))) return { ok: false, canceled: true };
135
+ return { ok: true, path: chosen };
136
+ });
137
+ handle(devUrl, 'dronepath:telemetry:save', (raw) => {
138
+ requireVideo(state);
139
+ const request = parseTelemetrySaveRequest(raw);
140
+ state.session.saveTelemetryJson(request.outPath, request.range);
141
+ state.lastTelemetryOut = request.outPath;
142
+ log(`telemetry JSON: wrote ${request.outPath}`);
143
+ return { ok: true };
144
+ });
145
+
146
+ handle(devUrl, 'dronepath:export:start', (raw) => {
147
+ const video = requireVideo(state);
148
+ state.exportRunner.start(video, parseExportRequest(raw, state.config));
149
+ return { ok: true };
150
+ });
151
+ handle(devUrl, 'dronepath:export:cancel', () => {
152
+ state.exportRunner.cancel();
153
+ return { ok: true };
154
+ });
155
+ handle(devUrl, 'dronepath:export:reveal', (payload) => {
156
+ shell.showItemInFolder(knownOutputOf(state, payload));
157
+ return { ok: true };
158
+ });
159
+ handle(devUrl, 'dronepath:export:open', async (payload) => {
160
+ const error = await shell.openPath(knownOutputOf(state, payload));
161
+ return error ? { ok: false, error } : { ok: true };
162
+ });
163
+
164
+ handle(devUrl, 'dronepath:update:restart', () => {
165
+ if (!state.updates) return { ok: false, error: 'this build does not self-update' };
166
+ // No pendingClose here: the prompt never opens over a running export, and
167
+ // a failed restart must not poison the export close guard.
168
+ return state.updates.restart({
169
+ onError: (message) => sendToWindow(state, 'dronepath:update:restart-failed', message),
170
+ });
171
+ });
172
+ handle(devUrl, 'dronepath:update:state', () => ({ ready: state.updateReady }));
173
+
174
+ handle(devUrl, 'dronepath:window:close', () => {
175
+ // The window's close handler runs the running-export guard.
176
+ if (state.win && !state.win.isDestroyed()) state.win.close();
177
+ });
178
+ }
package/app/main.mjs CHANGED
@@ -9,7 +9,7 @@ import process from 'node:process';
9
9
  import { Readable } from 'node:stream';
10
10
  import { pathToFileURL } from 'node:url';
11
11
 
12
- import { app, BrowserWindow, dialog, ipcMain, net, protocol, shell } from 'electron';
12
+ import { app, BrowserWindow, dialog, Menu, net, protocol, shell } from 'electron';
13
13
 
14
14
  import { resolveAppAsset } from '../dist/appassets.js';
15
15
  import { APP_ORIGIN, appStateFile, uiExportRoot } from '../dist/apppaths.js';
@@ -20,16 +20,15 @@ import {
20
20
  rememberOpenedFile,
21
21
  writeAppState,
22
22
  } from '../dist/appstate.js';
23
- import { createAppSession, parsePickRequest } from '../dist/appsession.js';
24
- import { parseExportRequest, parseSettingsPatch } from '../dist/config.js';
23
+ import { createAppSession } from '../dist/appsession.js';
25
24
  import { resolveConfig } from '../dist/configfile.js';
26
25
  import { ERROR_PREFIX, errorMessage } from '../dist/errors.js';
27
26
  import { createExportRunner } from '../dist/exportjob.js';
28
27
  import { requireTools } from '../dist/ff.js';
29
28
  import { resolveFfTools } from '../dist/fftools.js';
30
29
  import { rangePlan } from '../dist/range.js';
31
- import { outputPathFor } from '../dist/run.js';
32
30
  import { createTileTraffic } from '../dist/tiles.js';
31
+ import { registerIpcHandlers } from './ipc.mjs';
33
32
  import { initUpdates } from './update.mjs';
34
33
 
35
34
  const SCHEME = 'app';
@@ -72,9 +71,10 @@ function createShellState() {
72
71
  updates: null,
73
72
  // A downloaded update waits even if its announcement raced the renderer.
74
73
  updateReady: false,
75
- // The destination of the last successful export: the only path the
76
- // renderer may reveal or open.
74
+ // The destinations of the last successful export and the last telemetry
75
+ // JSON save: the only paths the renderer may reveal or open.
77
76
  lastExportOut: null,
77
+ lastTelemetryOut: null,
78
78
  closePromptOpen: false,
79
79
  pendingClose: false,
80
80
  };
@@ -189,23 +189,6 @@ async function handleRequest(state, request) {
189
189
  }
190
190
  }
191
191
 
192
- // Only this app's window may drive the session state machine.
193
- function assertTrusted(event) {
194
- const url = (event.senderFrame && event.senderFrame.url) || '';
195
- const devOk = DEV_URL !== null && url.startsWith(DEV_URL);
196
- if (!url.startsWith(APP_ORIGIN + '/') && !devOk) {
197
- throw new Error('untrusted ipc sender');
198
- }
199
- }
200
-
201
- function exportOutputOf(state, payload) {
202
- const out = payload && typeof payload === 'object' ? payload.out : null;
203
- if (typeof out !== 'string' || out !== state.lastExportOut) {
204
- throw new Error('unknown export output');
205
- }
206
- return out;
207
- }
208
-
209
192
  // The backing services behind the window: tool check, config, tile cache and
210
193
  // the recording session.
211
194
  async function initServices(state) {
@@ -242,131 +225,6 @@ function initExportRunner(state) {
242
225
  });
243
226
  }
244
227
 
245
- function registerIpcHandlers(state) {
246
- ipcMain.handle('dronepath:pick', (event, raw) => {
247
- assertTrusted(event);
248
- try {
249
- return state.session.pick(parsePickRequest(raw));
250
- } catch (e) {
251
- return { ok: false, error: errorMessage(e) };
252
- }
253
- });
254
- ipcMain.handle('dronepath:session', (event) => {
255
- assertTrusted(event);
256
- return state.session.getSession();
257
- });
258
- ipcMain.handle('dronepath:settings', (event) => {
259
- assertTrusted(event);
260
- return state.config;
261
- });
262
- ipcMain.handle('dronepath:settings:save', (event, raw) => {
263
- assertTrusted(event);
264
- let settings;
265
- try {
266
- settings = parseSettingsPatch(raw, 'settings');
267
- } catch (e) {
268
- return { ok: false, error: errorMessage(e) };
269
- }
270
- state.appState = { ...state.appState, settings };
271
- state.config = applyAppState(state.config, state.appState);
272
- try {
273
- writeAppState(appStateFile(), state.appState);
274
- } catch (e) {
275
- // The look still applies when the state file cannot be written.
276
- log(`app state not saved: ${errorMessage(e)}`);
277
- }
278
- return { ok: true };
279
- });
280
-
281
- ipcMain.handle('dronepath:export:pick-output', async (event) => {
282
- assertTrusted(event);
283
- const video = state.session ? state.session.videoPath() : null;
284
- if (!video) return { ok: false, error: 'no recording loaded' };
285
- // The CLI's default naming, with a relative out dir anchored at the
286
- // recording: the app process has no meaningful working directory.
287
- const outDir = state.config.outDir
288
- ? path.resolve(path.dirname(video), state.config.outDir)
289
- : null;
290
- const options = {
291
- title: 'Export flight map',
292
- defaultPath: outputPathFor(video, { ...state.config, outDir }),
293
- filters: [{ name: 'MP4 video', extensions: ['mp4'] }],
294
- };
295
- const result = state.win
296
- ? await dialog.showSaveDialog(state.win, options)
297
- : await dialog.showSaveDialog(options);
298
- if (result.canceled || !result.filePath) return { ok: false, canceled: true };
299
- const chosen = result.filePath.toLowerCase().endsWith('.mp4')
300
- ? result.filePath
301
- : `${result.filePath}.mp4`;
302
- // The native dialog confirmed the name as typed, but `.mp4` may have been
303
- // appended after it: re-check the final path on every platform so an
304
- // existing file is never replaced without a confirmation.
305
- if (fs.existsSync(chosen)) {
306
- const box = {
307
- type: 'warning',
308
- buttons: ['Replace', 'Cancel'],
309
- defaultId: 1,
310
- cancelId: 1,
311
- message: `Replace ${path.basename(chosen)}?`,
312
- detail: chosen,
313
- };
314
- const confirm = state.win
315
- ? await dialog.showMessageBox(state.win, box)
316
- : await dialog.showMessageBox(box);
317
- if (confirm.response !== 0) return { ok: false, canceled: true };
318
- }
319
- return { ok: true, path: chosen };
320
- });
321
- ipcMain.handle('dronepath:export:start', (event, raw) => {
322
- assertTrusted(event);
323
- try {
324
- const video = state.session ? state.session.videoPath() : null;
325
- if (!video) return { ok: false, error: 'no recording loaded' };
326
- state.exportRunner.start(video, parseExportRequest(raw, state.config));
327
- return { ok: true };
328
- } catch (e) {
329
- return { ok: false, error: errorMessage(e) };
330
- }
331
- });
332
- ipcMain.handle('dronepath:export:cancel', (event) => {
333
- assertTrusted(event);
334
- state.exportRunner.cancel();
335
- return { ok: true };
336
- });
337
- ipcMain.handle('dronepath:export:reveal', (event, payload) => {
338
- assertTrusted(event);
339
- try {
340
- shell.showItemInFolder(exportOutputOf(state, payload));
341
- return { ok: true };
342
- } catch (e) {
343
- return { ok: false, error: errorMessage(e) };
344
- }
345
- });
346
- ipcMain.handle('dronepath:export:open', async (event, payload) => {
347
- assertTrusted(event);
348
- try {
349
- const error = await shell.openPath(exportOutputOf(state, payload));
350
- return error ? { ok: false, error } : { ok: true };
351
- } catch (e) {
352
- return { ok: false, error: errorMessage(e) };
353
- }
354
- });
355
- ipcMain.handle('dronepath:update:restart', (event) => {
356
- assertTrusted(event);
357
- if (!state.updates) return { ok: false, error: 'this build does not self-update' };
358
- // No pendingClose here: the prompt never opens over a running export, and
359
- // a failed restart must not poison the export close guard.
360
- return state.updates.restart({
361
- onError: (message) => sendToWindow(state, 'dronepath:update:restart-failed', message),
362
- });
363
- });
364
- ipcMain.handle('dronepath:update:state', (event) => {
365
- assertTrusted(event);
366
- return { ready: state.updateReady };
367
- });
368
- }
369
-
370
228
  function installProtocolHandler(state) {
371
229
  protocol.handle(SCHEME, (request) =>
372
230
  handleRequest(state, request).catch((e) => {
@@ -383,6 +241,9 @@ function ensureUiExport() {
383
241
  }
384
242
 
385
243
  function createWindow(state) {
244
+ // The in-app menu bar owns all workspace commands; a native Alt/F10 menu
245
+ // would compete with it, so none is installed (Windows and Linux).
246
+ Menu.setApplicationMenu(null);
386
247
  state.win = new BrowserWindow({
387
248
  width: 1600,
388
249
  height: 950,
@@ -392,7 +253,6 @@ function createWindow(state) {
392
253
  minHeight: 600,
393
254
  // Match --page in ui/app/globals.css so startup shows one background.
394
255
  backgroundColor: '#232323',
395
- autoHideMenuBar: true,
396
256
  // The loaded page's <title> takes over after load (ui/app/layout.tsx).
397
257
  title: 'Drone Path',
398
258
  // Windows renders an ICO best, Linux a PNG (Electron docs); both are
@@ -482,7 +342,7 @@ async function startup() {
482
342
  sendToWindow(state, 'dronepath:update:ready');
483
343
  },
484
344
  });
485
- registerIpcHandlers(state);
345
+ registerIpcHandlers(state, { devUrl: DEV_URL, log, sendToWindow });
486
346
  installProtocolHandler(state);
487
347
  ensureUiExport();
488
348
  createWindow(state);
package/app/preload.cjs CHANGED
@@ -14,6 +14,8 @@ contextBridge.exposeInMainWorld('dronepath', {
14
14
  getSettings: () => ipcRenderer.invoke('dronepath:settings'),
15
15
  saveSettings: (patch) => ipcRenderer.invoke('dronepath:settings:save', patch),
16
16
  pickExportOutput: () => ipcRenderer.invoke('dronepath:export:pick-output'),
17
+ pickTelemetryOutput: () => ipcRenderer.invoke('dronepath:telemetry:pick-output'),
18
+ saveTelemetryJson: (request) => ipcRenderer.invoke('dronepath:telemetry:save', request),
17
19
  startExport: (request) => ipcRenderer.invoke('dronepath:export:start', request),
18
20
  cancelExport: () => ipcRenderer.invoke('dronepath:export:cancel'),
19
21
  revealExportOutput: (payload) => ipcRenderer.invoke('dronepath:export:reveal', payload),
@@ -28,4 +30,5 @@ contextBridge.exposeInMainWorld('dronepath', {
28
30
  subscribe('dronepath:update:restart-failed', (message) => cb(message)),
29
31
  getUpdateState: () => ipcRenderer.invoke('dronepath:update:state'),
30
32
  restartToUpdate: () => ipcRenderer.invoke('dronepath:update:restart'),
33
+ closeWindow: () => ipcRenderer.invoke('dronepath:window:close'),
31
34
  });
package/dist/appassets.js CHANGED
@@ -1,20 +1,12 @@
1
- // Pure routing for the app's custom-scheme server: maps a request pathname to
2
- // the resource that backs it. The Electron glue performs the I/O; the
3
- // path-traversal guard lives here so it stays unit-testable.
4
1
  import path from 'node:path';
5
2
  import { mimeFor, resolveTileRoute } from './assets.js';
6
3
  import { MEDIA_PATH } from './apppaths.js';
7
- /** Resolves an already-decoded URL pathname (e.g. "/index.html"). */
8
4
  export function resolveAppAsset(pathname, routes) {
9
5
  if (pathname === MEDIA_PATH) {
10
6
  return routes.videoPath
11
7
  ? { kind: 'video', filePath: routes.videoPath }
12
8
  : { kind: 'not-found' };
13
9
  }
14
- // Every known style routes into the shared cache ({ anyStyle: true }):
15
- // live restyle switches styles without a reload, so no single style owns
16
- // the tile route. Anything tile-shaped but not a tile resolves like any
17
- // other static path.
18
10
  const tile = resolveTileRoute(pathname, routes.tileCache, { anyStyle: true });
19
11
  if (tile) {
20
12
  return { kind: 'tile', ...tile };
@@ -25,9 +17,8 @@ function exportFile(pathname, exportRoot) {
25
17
  let rel = pathname.replace(/^\/+/, '');
26
18
  if (rel === '' || rel.endsWith('/'))
27
19
  rel += 'index.html';
28
- // URL pathnames are POSIX-style; a drive prefix or backslash marks a
29
- // Windows-flavored path that POSIX resolution would mistake for a plain
30
- // file name. Refuse it outright so the guard behaves the same on every OS.
20
+ // Windows drive prefixes or backslashes would be a plain file name to POSIX
21
+ // resolution; refuse them so the guard works the same on every OS.
31
22
  if (rel.split('/').some((s) => s.includes('\\') || /^[a-zA-Z]:/.test(s))) {
32
23
  return { kind: 'not-found' };
33
24
  }
package/dist/apppaths.js CHANGED
@@ -1,28 +1,20 @@
1
- // URL and path layout for the desktop app: the custom-scheme vocabulary,
2
- // build-artifact locations and the per-user state file have exactly one home.
3
1
  import os from 'node:os';
4
2
  import path from 'node:path';
5
3
  export const APP_ORIGIN = 'app://bundle';
6
4
  export const MEDIA_PATH = '/media/video';
7
- export const MEDIA_URL = APP_ORIGIN + MEDIA_PATH;
5
+ const MEDIA_URL = APP_ORIGIN + MEDIA_PATH;
8
6
  export const TILE_BASE = APP_ORIGIN + '/tiles';
9
- /** The media URL for one recording: the query names the file, so a reload
10
- * can never replay another recording's bytes from a URL-keyed cache. */
7
+ // The ?v= query names the file so a reload can never replay another recording's bytes from a URL-keyed cache.
11
8
  export function mediaUrlFor(videoPath) {
12
9
  return `${MEDIA_URL}?v=${encodeURIComponent(videoPath)}`;
13
10
  }
14
- /** The Next.js static export (ui/out) next to the app shell directory. */
15
11
  export function uiExportRoot(shellDir) {
16
12
  return path.join(shellDir, '..', 'ui', 'out');
17
13
  }
18
- // The per-user data root (LOCALAPPDATA on Windows, the cache convention
19
- // elsewhere): the tile cache and the state file share it, so one machine-local
20
- // place holds everything the app keeps per user.
21
14
  export function userDataDir() {
22
15
  const base = process.env['LOCALAPPDATA'] ?? path.join(os.homedir(), '.cache');
23
16
  return path.join(base, 'drone-path');
24
17
  }
25
- /** The per-user state file the desktop app restores its settings from. */
26
18
  export function appStateFile() {
27
19
  return path.join(userDataDir(), 'state.json');
28
20
  }