drone-path 0.8.1 → 0.9.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/CHANGELOG.md +32 -0
- package/README.md +17 -24
- package/THIRD-PARTY-NOTICES.md +7 -0
- package/app/main.mjs +82 -28
- package/app/preload.cjs +3 -0
- package/dist/appassets.js +2 -11
- package/dist/apppaths.js +2 -10
- package/dist/appsession.js +59 -25
- package/dist/appstate.js +0 -18
- package/dist/assets.js +0 -7
- package/dist/buildinfo.js +71 -0
- package/dist/cammeta.js +123 -84
- package/dist/changeset-gate.js +0 -7
- package/dist/cli.js +0 -15
- package/dist/config.js +40 -52
- package/dist/configfile.js +0 -8
- package/dist/decimate.js +2 -12
- package/dist/exportjob.js +3 -19
- package/dist/ff.js +0 -8
- package/dist/fftools.js +0 -10
- package/dist/geo.js +3 -13
- package/dist/inputs.js +0 -4
- package/dist/manual/anchors.js +1 -7
- package/dist/manual/build.js +0 -6
- package/dist/manual/cliref.js +0 -6
- package/dist/manual/links.js +0 -17
- package/dist/manual/markdown.js +2 -10
- package/dist/manual/model.js +0 -3
- package/dist/manual/module.js +0 -3
- package/dist/manual/nav.js +0 -2
- package/dist/manual/reference.js +1 -4
- package/dist/page.js +3 -26
- package/dist/paths.js +0 -12
- package/dist/plan.js +1 -18
- package/dist/png.js +0 -3
- package/dist/proto.js +4 -4
- package/dist/range.js +0 -8
- package/dist/render.js +3 -53
- package/dist/renderer/dom.js +0 -6
- package/dist/renderer/framemath.js +0 -4
- package/dist/renderer/leaflet.js +0 -4
- package/dist/renderer/scene.js +10 -34
- package/dist/renderer/theme.js +58 -10
- package/dist/renderer/tilesources.js +0 -10
- package/dist/renderer/trail.js +1 -12
- package/dist/restyle.js +1 -9
- package/dist/run.js +45 -46
- package/dist/serve.js +0 -13
- package/dist/srt.js +30 -8
- package/dist/summary.js +0 -3
- package/dist/telemetry-json-schema.js +23 -0
- package/dist/telemetry-json.js +107 -0
- package/dist/telemetry-math.js +9 -45
- package/dist/telemetry.js +52 -9
- package/dist/tilecache.js +0 -5
- package/dist/tiles.js +1 -31
- package/dist/tracing.js +3 -27
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# drone-path
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
- **New:** The flight trail is now configurable: `--trail-color <hex>`
|
|
6
|
+
(RGB or RGBA hex like `#e63946` or `#e63946cc`, `#` optional) and the
|
|
7
|
+
`trailColor` setting recolor the flight trail, the drone marker and
|
|
8
|
+
the HUD accents. Glow and casing are derived from the chosen color,
|
|
9
|
+
so the layered trail stays readable on both map styles; omitting the
|
|
10
|
+
option keeps the per-style theme defaults.
|
|
11
|
+
- **New:** `--telemetry-json <file>` exports per-frame telemetry —
|
|
12
|
+
time, position, altitude, body and gimbal attitude, heading and
|
|
13
|
+
camera exposure — as one versioned JSON document with a record per
|
|
14
|
+
source frame; the schema is checked in as
|
|
15
|
+
`docs/telemetry-json.schema.json`. The desktop workspace writes the
|
|
16
|
+
same document through Export telemetry…, straight from the loaded
|
|
17
|
+
recording (the In–Out segment or the full recording) and
|
|
18
|
+
byte-identical to the CLI output.
|
|
19
|
+
- **New:** The desktop workspace has a top menu bar with the workspace
|
|
20
|
+
actions moved into it: **File** holds Open… (Ctrl+O), Export video…,
|
|
21
|
+
Export telemetry…, Settings and Exit, **View** holds Swap (S), and
|
|
22
|
+
right-aligned **Help** holds Documentation and About. It follows
|
|
23
|
+
Windows menu conventions (click or Alt opens, hover switches, arrows
|
|
24
|
+
navigate, Enter/Space activate, Esc closes, Alt+F/V/H mnemonics) with
|
|
25
|
+
the accent-forward menu state styling. "Export…" is now "Export
|
|
26
|
+
video…" on every surface, the header and status footer keep only
|
|
27
|
+
their informational content, the auto-hidden native Electron menu is
|
|
28
|
+
gone, and Exit still guards against closing during a running export.
|
|
29
|
+
- **New:** **Help → About** shows the drone / path lockup, the running
|
|
30
|
+
build's version — `MAJOR.MINOR.PATCH` for releases,
|
|
31
|
+
`MAJOR.MINOR.PATCH+<short commit>` for every other build, injected at
|
|
32
|
+
build time — an MIT license line, and a link that opens the
|
|
33
|
+
`MrManny/drone-path` repository in the default browser.
|
|
34
|
+
|
|
3
35
|
## 0.8.1
|
|
4
36
|
|
|
5
37
|
- **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
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
so that I can overlay it in the actual footage of my drone flight
|
|
8
|
-
videos.
|
|
9
|
-
|
|
10
|
-
Currently, it supports two main ways to acquire the geo-coordinates from
|
|
11
|
-
DJI's telemetry:
|
|
7
|
+
It reads geo-coordinates from DJI's telemetry in two ways:
|
|
12
8
|
|
|
13
9
|
- if an `.SRT` sidecar is available, that will be used,
|
|
14
|
-
- otherwise it tries to parse the embedded
|
|
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.
|
|
10
|
+
- otherwise it tries to parse the embedded CAM meta (DVTM) stream
|
|
11
|
+
(DJI's protobuf format).
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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.
|
|
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
|
|
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,
|
|
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,
|
|
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
|

|
|
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
|
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -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/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, ipcMain, 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,13 +20,14 @@ import {
|
|
|
20
20
|
rememberOpenedFile,
|
|
21
21
|
writeAppState,
|
|
22
22
|
} from '../dist/appstate.js';
|
|
23
|
-
import { createAppSession, parsePickRequest } from '../dist/appsession.js';
|
|
23
|
+
import { createAppSession, parsePickRequest, parseTelemetrySaveRequest } from '../dist/appsession.js';
|
|
24
24
|
import { parseExportRequest, parseSettingsPatch } from '../dist/config.js';
|
|
25
25
|
import { resolveConfig } from '../dist/configfile.js';
|
|
26
26
|
import { ERROR_PREFIX, errorMessage } from '../dist/errors.js';
|
|
27
27
|
import { createExportRunner } from '../dist/exportjob.js';
|
|
28
28
|
import { requireTools } from '../dist/ff.js';
|
|
29
29
|
import { resolveFfTools } from '../dist/fftools.js';
|
|
30
|
+
import { videoBaseName } from '../dist/inputs.js';
|
|
30
31
|
import { rangePlan } from '../dist/range.js';
|
|
31
32
|
import { outputPathFor } from '../dist/run.js';
|
|
32
33
|
import { createTileTraffic } from '../dist/tiles.js';
|
|
@@ -72,9 +73,10 @@ function createShellState() {
|
|
|
72
73
|
updates: null,
|
|
73
74
|
// A downloaded update waits even if its announcement raced the renderer.
|
|
74
75
|
updateReady: false,
|
|
75
|
-
// The
|
|
76
|
-
// renderer may reveal or open.
|
|
76
|
+
// The destinations of the last successful export and the last telemetry
|
|
77
|
+
// JSON save: the only paths the renderer may reveal or open.
|
|
77
78
|
lastExportOut: null,
|
|
79
|
+
lastTelemetryOut: null,
|
|
78
80
|
closePromptOpen: false,
|
|
79
81
|
pendingClose: false,
|
|
80
82
|
};
|
|
@@ -198,14 +200,36 @@ function assertTrusted(event) {
|
|
|
198
200
|
}
|
|
199
201
|
}
|
|
200
202
|
|
|
201
|
-
|
|
203
|
+
// The reveal/open guard: the renderer may only name a file this shell wrote
|
|
204
|
+
// (the last export or the last telemetry document, both set only by trusted
|
|
205
|
+
// handlers), never an arbitrary path.
|
|
206
|
+
function knownOutputOf(state, payload) {
|
|
202
207
|
const out = payload && typeof payload === 'object' ? payload.out : null;
|
|
203
|
-
if (typeof out !== 'string' || out !== state.lastExportOut) {
|
|
204
|
-
throw new Error('unknown
|
|
208
|
+
if (typeof out !== 'string' || (out !== state.lastExportOut && out !== state.lastTelemetryOut)) {
|
|
209
|
+
throw new Error('unknown output');
|
|
205
210
|
}
|
|
206
211
|
return out;
|
|
207
212
|
}
|
|
208
213
|
|
|
214
|
+
// The native dialog confirmed the name as typed, but the extension may have
|
|
215
|
+
// been appended after it: re-check the final path on every platform so an
|
|
216
|
+
// existing file is never replaced without a confirmation.
|
|
217
|
+
async function confirmReplace(state, chosen) {
|
|
218
|
+
if (!fs.existsSync(chosen)) return true;
|
|
219
|
+
const box = {
|
|
220
|
+
type: 'warning',
|
|
221
|
+
buttons: ['Replace', 'Cancel'],
|
|
222
|
+
defaultId: 1,
|
|
223
|
+
cancelId: 1,
|
|
224
|
+
message: `Replace ${path.basename(chosen)}?`,
|
|
225
|
+
detail: chosen,
|
|
226
|
+
};
|
|
227
|
+
const confirm = state.win
|
|
228
|
+
? await dialog.showMessageBox(state.win, box)
|
|
229
|
+
: await dialog.showMessageBox(box);
|
|
230
|
+
return confirm.response === 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
209
233
|
// The backing services behind the window: tool check, config, tile cache and
|
|
210
234
|
// the recording session.
|
|
211
235
|
async function initServices(state) {
|
|
@@ -288,7 +312,7 @@ function registerIpcHandlers(state) {
|
|
|
288
312
|
? path.resolve(path.dirname(video), state.config.outDir)
|
|
289
313
|
: null;
|
|
290
314
|
const options = {
|
|
291
|
-
title: 'Export
|
|
315
|
+
title: 'Export video',
|
|
292
316
|
defaultPath: outputPathFor(video, { ...state.config, outDir }),
|
|
293
317
|
filters: [{ name: 'MP4 video', extensions: ['mp4'] }],
|
|
294
318
|
};
|
|
@@ -299,25 +323,48 @@ function registerIpcHandlers(state) {
|
|
|
299
323
|
const chosen = result.filePath.toLowerCase().endsWith('.mp4')
|
|
300
324
|
? result.filePath
|
|
301
325
|
: `${result.filePath}.mp4`;
|
|
302
|
-
|
|
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
|
-
}
|
|
326
|
+
if (!(await confirmReplace(state, chosen))) return { ok: false, canceled: true };
|
|
319
327
|
return { ok: true, path: chosen };
|
|
320
328
|
});
|
|
329
|
+
ipcMain.handle('dronepath:telemetry:pick-output', async (event) => {
|
|
330
|
+
assertTrusted(event);
|
|
331
|
+
const video = state.session ? state.session.videoPath() : null;
|
|
332
|
+
if (!video) return { ok: false, error: 'no recording loaded' };
|
|
333
|
+
// The export dialog's default folder, named after the recording
|
|
334
|
+
// (<basename>.telemetry.json).
|
|
335
|
+
const outDir = state.config.outDir
|
|
336
|
+
? path.resolve(path.dirname(video), state.config.outDir)
|
|
337
|
+
: null;
|
|
338
|
+
const exportDefault = outputPathFor(video, { ...state.config, outDir });
|
|
339
|
+
const options = {
|
|
340
|
+
title: 'Export telemetry',
|
|
341
|
+
defaultPath: path.join(path.dirname(exportDefault), `${videoBaseName(video)}.telemetry.json`),
|
|
342
|
+
filters: [{ name: 'JSON document', extensions: ['json'] }],
|
|
343
|
+
};
|
|
344
|
+
const result = state.win
|
|
345
|
+
? await dialog.showSaveDialog(state.win, options)
|
|
346
|
+
: await dialog.showSaveDialog(options);
|
|
347
|
+
if (result.canceled || !result.filePath) return { ok: false, canceled: true };
|
|
348
|
+
const chosen = result.filePath.toLowerCase().endsWith('.json')
|
|
349
|
+
? result.filePath
|
|
350
|
+
: `${result.filePath}.json`;
|
|
351
|
+
if (!(await confirmReplace(state, chosen))) return { ok: false, canceled: true };
|
|
352
|
+
return { ok: true, path: chosen };
|
|
353
|
+
});
|
|
354
|
+
ipcMain.handle('dronepath:telemetry:save', (event, raw) => {
|
|
355
|
+
assertTrusted(event);
|
|
356
|
+
try {
|
|
357
|
+
const video = state.session ? state.session.videoPath() : null;
|
|
358
|
+
if (!video) return { ok: false, error: 'no recording loaded' };
|
|
359
|
+
const request = parseTelemetrySaveRequest(raw);
|
|
360
|
+
state.session.saveTelemetryJson(request.outPath, request.range);
|
|
361
|
+
state.lastTelemetryOut = request.outPath;
|
|
362
|
+
log(`telemetry JSON: wrote ${request.outPath}`);
|
|
363
|
+
return { ok: true };
|
|
364
|
+
} catch (e) {
|
|
365
|
+
return { ok: false, error: errorMessage(e) };
|
|
366
|
+
}
|
|
367
|
+
});
|
|
321
368
|
ipcMain.handle('dronepath:export:start', (event, raw) => {
|
|
322
369
|
assertTrusted(event);
|
|
323
370
|
try {
|
|
@@ -337,7 +384,7 @@ function registerIpcHandlers(state) {
|
|
|
337
384
|
ipcMain.handle('dronepath:export:reveal', (event, payload) => {
|
|
338
385
|
assertTrusted(event);
|
|
339
386
|
try {
|
|
340
|
-
shell.showItemInFolder(
|
|
387
|
+
shell.showItemInFolder(knownOutputOf(state, payload));
|
|
341
388
|
return { ok: true };
|
|
342
389
|
} catch (e) {
|
|
343
390
|
return { ok: false, error: errorMessage(e) };
|
|
@@ -346,7 +393,7 @@ function registerIpcHandlers(state) {
|
|
|
346
393
|
ipcMain.handle('dronepath:export:open', async (event, payload) => {
|
|
347
394
|
assertTrusted(event);
|
|
348
395
|
try {
|
|
349
|
-
const error = await shell.openPath(
|
|
396
|
+
const error = await shell.openPath(knownOutputOf(state, payload));
|
|
350
397
|
return error ? { ok: false, error } : { ok: true };
|
|
351
398
|
} catch (e) {
|
|
352
399
|
return { ok: false, error: errorMessage(e) };
|
|
@@ -365,6 +412,11 @@ function registerIpcHandlers(state) {
|
|
|
365
412
|
assertTrusted(event);
|
|
366
413
|
return { ready: state.updateReady };
|
|
367
414
|
});
|
|
415
|
+
ipcMain.handle('dronepath:window:close', (event) => {
|
|
416
|
+
assertTrusted(event);
|
|
417
|
+
// The window's close handler runs the running-export guard.
|
|
418
|
+
if (state.win && !state.win.isDestroyed()) state.win.close();
|
|
419
|
+
});
|
|
368
420
|
}
|
|
369
421
|
|
|
370
422
|
function installProtocolHandler(state) {
|
|
@@ -383,6 +435,9 @@ function ensureUiExport() {
|
|
|
383
435
|
}
|
|
384
436
|
|
|
385
437
|
function createWindow(state) {
|
|
438
|
+
// The in-app menu bar owns all workspace commands; a native Alt/F10 menu
|
|
439
|
+
// would compete with it, so none is installed (Windows and Linux).
|
|
440
|
+
Menu.setApplicationMenu(null);
|
|
386
441
|
state.win = new BrowserWindow({
|
|
387
442
|
width: 1600,
|
|
388
443
|
height: 950,
|
|
@@ -392,7 +447,6 @@ function createWindow(state) {
|
|
|
392
447
|
minHeight: 600,
|
|
393
448
|
// Match --page in ui/app/globals.css so startup shows one background.
|
|
394
449
|
backgroundColor: '#232323',
|
|
395
|
-
autoHideMenuBar: true,
|
|
396
450
|
// The loaded page's <title> takes over after load (ui/app/layout.tsx).
|
|
397
451
|
title: 'Drone Path',
|
|
398
452
|
// Windows renders an ICO best, Linux a PNG (Electron docs); both are
|
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
|
-
//
|
|
29
|
-
//
|
|
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
|
-
|
|
5
|
+
const MEDIA_URL = APP_ORIGIN + MEDIA_PATH;
|
|
8
6
|
export const TILE_BASE = APP_ORIGIN + '/tiles';
|
|
9
|
-
|
|
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
|
}
|
package/dist/appsession.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
// Session vocabulary and state machine for the desktop app, free of Electron
|
|
2
|
-
// APIs: pick -> validate -> prepare -> hold one prepared recording.
|
|
3
1
|
import fs from 'node:fs';
|
|
4
2
|
import path from 'node:path';
|
|
5
3
|
import { TILE_BASE, mediaUrlFor } from './apppaths.js';
|
|
6
|
-
import { STYLE_VALUES, VIEW_VALUES, asNumber } from './config.js';
|
|
4
|
+
import { STYLE_VALUES, VIEW_VALUES, asNumber, asTrailColor, parseFrameRange, } from './config.js';
|
|
7
5
|
import { errorMessage } from './errors.js';
|
|
8
6
|
import { isRecordingName } from './inputs.js';
|
|
9
7
|
import { buildSceneData } from './page.js';
|
|
10
|
-
import { prepareSession, recordingPageOpts } from './run.js';
|
|
11
|
-
|
|
8
|
+
import { prepareSession, recordingPageOpts, resolveRange, telemetryExportInput, } from './run.js';
|
|
9
|
+
import { buildTelemetryDocument, serializeTelemetryDocument } from './telemetry-json.js';
|
|
12
10
|
export function frameExactDuration(probe) {
|
|
13
11
|
return probe.frames / probe.fps.value;
|
|
14
12
|
}
|
|
15
|
-
// The IPC boundary's vocabulary check: whatever the renderer sends, the
|
|
16
|
-
// preparation only ever plans from a valid look.
|
|
17
13
|
export function parsePickRequest(raw) {
|
|
18
14
|
const input = typeof raw === 'object' && raw !== null ? raw : {};
|
|
19
15
|
const look = typeof input.settings === 'object' && input.settings !== null
|
|
@@ -38,6 +34,7 @@ export function parsePickRequest(raw) {
|
|
|
38
34
|
throw new Error('intro must be 0 or more');
|
|
39
35
|
if (!(outroSec >= 0))
|
|
40
36
|
throw new Error('outro must be 0 or more');
|
|
37
|
+
const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
|
|
41
38
|
const chips = typeof hud === 'object' && hud !== null ? hud : {};
|
|
42
39
|
return {
|
|
43
40
|
settings: {
|
|
@@ -48,29 +45,49 @@ export function parsePickRequest(raw) {
|
|
|
48
45
|
hud: { heading: !!chips.heading, alt: !!chips.alt, speed: !!chips.speed },
|
|
49
46
|
introSec,
|
|
50
47
|
outroSec,
|
|
48
|
+
trailColor,
|
|
51
49
|
},
|
|
52
50
|
};
|
|
53
51
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
export function parseTelemetrySaveRequest(raw) {
|
|
53
|
+
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
54
|
+
throw new Error('invalid telemetry save request');
|
|
55
|
+
}
|
|
56
|
+
const r = raw;
|
|
57
|
+
for (const key of Object.keys(r)) {
|
|
58
|
+
if (key !== 'outPath' && key !== 'range') {
|
|
59
|
+
throw new Error(`unknown telemetry save request key ${key}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (typeof r.outPath !== 'string' || !r.outPath) {
|
|
63
|
+
throw new Error('invalid telemetry save request: outPath');
|
|
64
|
+
}
|
|
65
|
+
if (!r.outPath.toLowerCase().endsWith('.json')) {
|
|
66
|
+
throw new Error(`invalid telemetry save request: outPath must be a .json file: ${r.outPath}`);
|
|
67
|
+
}
|
|
68
|
+
const range = r.range === undefined || r.range === null ? null : parseFrameRange(r.range);
|
|
69
|
+
return { outPath: r.outPath, range };
|
|
70
|
+
}
|
|
57
71
|
export const prepareUiSession = async (videoPath, config, log, onProgress, deps) => {
|
|
58
72
|
const prep = await prepareSession(videoPath, config, log, {
|
|
59
73
|
onProgress,
|
|
60
74
|
deps,
|
|
61
75
|
});
|
|
62
76
|
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
session: {
|
|
78
|
+
scene: buildSceneData(recordingPageOpts(prep, config), TILE_BASE),
|
|
79
|
+
video: {
|
|
80
|
+
src: mediaUrlFor(videoPath),
|
|
81
|
+
fps: prep.probe.fps.value,
|
|
82
|
+
frames: prep.probe.frames,
|
|
83
|
+
width: prep.probe.width,
|
|
84
|
+
height: prep.probe.height,
|
|
85
|
+
},
|
|
86
|
+
tileBase: TILE_BASE,
|
|
87
|
+
bbox: prep.tel.bbox,
|
|
88
|
+
durationSec: frameExactDuration(prep.probe),
|
|
70
89
|
},
|
|
71
|
-
|
|
72
|
-
bbox: prep.tel.bbox,
|
|
73
|
-
durationSec: frameExactDuration(prep.probe),
|
|
90
|
+
telemetry: telemetryExportInput(prep),
|
|
74
91
|
};
|
|
75
92
|
};
|
|
76
93
|
function isReadableVideo(filePath) {
|
|
@@ -83,13 +100,25 @@ function isReadableVideo(filePath) {
|
|
|
83
100
|
return false;
|
|
84
101
|
}
|
|
85
102
|
}
|
|
103
|
+
function segmentTelemetryInput(input, range) {
|
|
104
|
+
const segment = resolveRange(range, input.frameCount);
|
|
105
|
+
if (!segment)
|
|
106
|
+
return input;
|
|
107
|
+
return {
|
|
108
|
+
...input,
|
|
109
|
+
frameCount: segment.end - segment.start + 1,
|
|
110
|
+
frames: input.frames.slice(segment.start, segment.end + 1),
|
|
111
|
+
headingDeg: input.headingDeg.slice(segment.start, segment.end + 1),
|
|
112
|
+
frameStart: segment.start,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
86
115
|
export function createAppSession(options) {
|
|
87
116
|
const { config, pickFile } = options;
|
|
88
117
|
const prepare = options.prepare ?? prepareUiSession;
|
|
89
118
|
const log = options.log ?? (() => { });
|
|
90
119
|
const onPreparing = options.onPreparing ?? (() => { });
|
|
91
120
|
const onPrepareProgress = options.onPrepareProgress ?? (() => { });
|
|
92
|
-
let
|
|
121
|
+
let prepared = null;
|
|
93
122
|
let videoPath = null;
|
|
94
123
|
let picking = false;
|
|
95
124
|
return {
|
|
@@ -107,9 +136,7 @@ export function createAppSession(options) {
|
|
|
107
136
|
return { ok: false, error: `not a readable .mp4 file: ${resolved}` };
|
|
108
137
|
}
|
|
109
138
|
onPreparing(resolved);
|
|
110
|
-
|
|
111
|
-
// scene matches what the player shows.
|
|
112
|
-
session = await prepare(resolved, { ...config, ...request.settings }, log, onPrepareProgress);
|
|
139
|
+
prepared = await prepare(resolved, { ...config, ...request.settings }, log, onPrepareProgress);
|
|
113
140
|
videoPath = resolved;
|
|
114
141
|
log(`loaded: ${resolved}`);
|
|
115
142
|
return { ok: true };
|
|
@@ -122,7 +149,14 @@ export function createAppSession(options) {
|
|
|
122
149
|
picking = false;
|
|
123
150
|
}
|
|
124
151
|
},
|
|
125
|
-
getSession: () => session,
|
|
152
|
+
getSession: () => prepared?.session ?? null,
|
|
126
153
|
videoPath: () => videoPath,
|
|
154
|
+
saveTelemetryJson(file, range) {
|
|
155
|
+
if (!prepared)
|
|
156
|
+
throw new Error('no recording loaded');
|
|
157
|
+
const doc = buildTelemetryDocument(segmentTelemetryInput(prepared.telemetry, range));
|
|
158
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
159
|
+
fs.writeFileSync(file, serializeTelemetryDocument(doc));
|
|
160
|
+
},
|
|
127
161
|
};
|
|
128
162
|
}
|
package/dist/appstate.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// The desktop app's per-user state: the settings panel's last look in
|
|
2
|
-
// option-vocabulary values and the folder the last recording was opened from.
|
|
3
|
-
// Parsing and merging stay pure; the file I/O below them is the thin shell the
|
|
4
|
-
// app seeds from and flushes to.
|
|
5
1
|
import fs from 'node:fs';
|
|
6
2
|
import path from 'node:path';
|
|
7
3
|
import { DEFAULT_CONFIG, SETTINGS_KEYS, formatHud, parseSettingsPatch } from './config.js';
|
|
@@ -9,10 +5,6 @@ export const APP_STATE_VERSION = 1;
|
|
|
9
5
|
export function emptyAppState() {
|
|
10
6
|
return { settings: null, lastOpenDir: null };
|
|
11
7
|
}
|
|
12
|
-
// Older settings objects read tolerantly: a key their writer did not know
|
|
13
|
-
// starts at its documented default, so an upgrade keeps the look the user
|
|
14
|
-
// chose. A present-but-mistyped value (null included) stays the parser's
|
|
15
|
-
// business and fails the state.
|
|
16
8
|
function fillMissingSettings(raw) {
|
|
17
9
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
|
|
18
10
|
return raw;
|
|
@@ -23,9 +15,6 @@ function fillMissingSettings(raw) {
|
|
|
23
15
|
}
|
|
24
16
|
return filled;
|
|
25
17
|
}
|
|
26
|
-
// The state falls back as a whole: a file whose shape this build cannot read
|
|
27
|
-
// is outdated or corrupt, and keeping parts of it would restore a look the
|
|
28
|
-
// user never chose.
|
|
29
18
|
export function parseAppState(raw) {
|
|
30
19
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
31
20
|
throw new Error('invalid app state');
|
|
@@ -48,8 +37,6 @@ export function parseAppState(raw) {
|
|
|
48
37
|
const lastOpenDir = typeof r.lastOpenDir === 'string' ? r.lastOpenDir : null;
|
|
49
38
|
return { settings, lastOpenDir };
|
|
50
39
|
}
|
|
51
|
-
// The file's option values use the config-file spelling (the HUD spec as its
|
|
52
|
-
// CLI string), so a state file reads like .dronepath.json.
|
|
53
40
|
export function serializeAppState(state) {
|
|
54
41
|
const out = { version: APP_STATE_VERSION };
|
|
55
42
|
if (state.settings) {
|
|
@@ -64,23 +51,18 @@ export function serializeAppState(state) {
|
|
|
64
51
|
out.lastOpenDir = state.lastOpenDir;
|
|
65
52
|
return `${JSON.stringify(out, null, 2)}\n`;
|
|
66
53
|
}
|
|
67
|
-
// The persisted look seeds the panel and the export base; machine-owned values
|
|
68
|
-
// always stay whatever the config layers resolved.
|
|
69
54
|
export function applyAppState(config, state) {
|
|
70
55
|
if (!state.settings)
|
|
71
56
|
return config;
|
|
72
57
|
return {
|
|
73
58
|
...config,
|
|
74
59
|
...state.settings,
|
|
75
|
-
// hud is an object; the winner is copied so no two configs share it.
|
|
76
60
|
hud: { ...state.settings.hud },
|
|
77
61
|
};
|
|
78
62
|
}
|
|
79
63
|
export function rememberOpenedFile(state, filePath) {
|
|
80
64
|
return { ...state, lastOpenDir: path.dirname(filePath) };
|
|
81
65
|
}
|
|
82
|
-
// A missing or unusable state file is a fresh install: never a failure the
|
|
83
|
-
// launch would die on.
|
|
84
66
|
export function readAppState(file) {
|
|
85
67
|
let text;
|
|
86
68
|
try {
|
package/dist/assets.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// Pure URL-to-file routing shared by the render server and the app bundle:
|
|
2
|
-
// maps a request pathname to the resource that backs it. The route guards
|
|
3
|
-
// and the tile acceptance policy live here so they stay unit-testable; the
|
|
4
|
-
// servers only perform the I/O.
|
|
5
1
|
import path from 'node:path';
|
|
6
2
|
import { parseTilePathname, tilePaths } from './tilecache.js';
|
|
7
3
|
export const MIME = {
|
|
@@ -32,9 +28,6 @@ export function resolveTileRoute(pathname, tileCache, policy) {
|
|
|
32
28
|
placeholderPath: paths.placeholder,
|
|
33
29
|
};
|
|
34
30
|
}
|
|
35
|
-
// Serves /leaflet/*, /tiles/* and /renderer/*: the whitelist guards decide
|
|
36
|
-
// what may be served, and every /tiles/ URL is claimed (missing tiles are the
|
|
37
|
-
// caller's 404).
|
|
38
31
|
export function resolveAsset(url, routes) {
|
|
39
32
|
if (url.startsWith('/leaflet/')) {
|
|
40
33
|
const rel = url.slice('/leaflet/'.length);
|