drone-path 0.9.0 → 0.11.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 +64 -0
- package/README.md +16 -14
- package/THIRD-PARTY-NOTICES.md +7 -7
- package/app/ipc.d.mts +43 -0
- package/app/ipc.mjs +216 -0
- package/app/main.mjs +10 -204
- package/dist/appsession.js +34 -75
- package/dist/appstate.js +24 -21
- package/dist/buildinfo.js +9 -16
- package/dist/cammeta-decode.js +237 -0
- package/dist/cammeta.js +8 -247
- package/dist/cli.js +40 -32
- package/dist/config.js +333 -173
- package/dist/configfile.js +20 -7
- package/dist/errors.js +30 -0
- package/dist/exec-tool.js +13 -0
- package/dist/exportjob.js +7 -7
- package/dist/{fftools.js → ffmpeg-tools.js} +5 -4
- package/dist/{ff.js → ffmpeg.js} +14 -29
- package/dist/frametime.js +32 -0
- package/dist/geo.js +1 -1
- package/dist/manual/build.js +5 -10
- package/dist/manual/cliref.js +4 -1
- package/dist/manual/reference.js +6 -11
- package/dist/{run.js → pipeline.js} +100 -143
- package/dist/png.js +1 -18
- package/dist/{proto.js → protobuf-wire.js} +5 -5
- package/dist/range.js +3 -3
- package/dist/{page.js → render-page.js} +2 -2
- package/dist/render.js +25 -115
- package/dist/renderer/boot.js +2 -2
- package/dist/renderer/dom.js +32 -10
- package/dist/renderer/scene.js +14 -6
- package/dist/restyle.js +1 -1
- package/dist/serve.js +1 -31
- package/dist/srt.js +2 -2
- package/dist/telemetry-json-schema.js +6 -11
- package/dist/telemetry-json.js +46 -27
- package/dist/telemetry-math.js +3 -2
- package/dist/{summary.js → telemetry-summary.js} +4 -4
- package/dist/telemetry.js +32 -18
- package/dist/tiles.js +30 -86
- package/dist/track-format.js +13 -0
- package/dist/track-geojson.js +44 -0
- package/dist/track-gpx.js +34 -0
- package/dist/track-kml.js +47 -0
- package/dist/track-kmz.js +68 -0
- package/dist/track-write.js +41 -0
- package/dist/track.js +79 -0
- package/package.json +13 -14
- package/dist/tracing.js +0 -184
- /package/dist/{renderer/leaflet.js → logging.js} +0 -0
- /package/dist/{inputs.js → recordings.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,69 @@
|
|
|
1
1
|
# drone-path
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
- **New:** Flight track files: `--track-out <file>` writes the decoded
|
|
6
|
+
flight track in the format the file extension picks — GPX (`.gpx`),
|
|
7
|
+
GeoJSON (`.geojson`), KML/KMZ (`.kml`/`.kmz`) — or the existing
|
|
8
|
+
telemetry JSON document (`.json`, unchanged bytes). Vertices sit at
|
|
9
|
+
decoded GPS fixes with telemetry gaps breaking the line, altitude is
|
|
10
|
+
the absolute/GPS altitude in meters above mean sea level, and times
|
|
11
|
+
appear only where a recording carries trustworthy UTC — none does
|
|
12
|
+
today (the CAM-meta device timestamp counts since power-up), so KML
|
|
13
|
+
exports plain line segments instead of a timed flythrough. The
|
|
14
|
+
desktop **Export telemetry…** dialog offers the same five formats and
|
|
15
|
+
honors the In–Out range; for the same recording and range the app and
|
|
16
|
+
the CLI write byte-identical files. `--telemetry-json <file>` is a
|
|
17
|
+
deprecated alias of `--track-out <file>.json` — same output, warns on
|
|
18
|
+
use, removed in a future version — and mixing the two spellings in
|
|
19
|
+
one run is an error. A frame range of a single frame is now valid
|
|
20
|
+
everywhere ranges are accepted.
|
|
21
|
+
- **New:** The timeline shows a lone in or out point as a half-open
|
|
22
|
+
In–Out segment — the in point runs to the end of the recording, the
|
|
23
|
+
out point from its start — and the readout names the same passage.
|
|
24
|
+
Playback wrap and both exports honor a lone point, setting a point
|
|
25
|
+
past the other replaces it, and the readout announces point changes
|
|
26
|
+
to screen readers.
|
|
27
|
+
- **New:** The app's copy is unified and the dialogs are polished: the
|
|
28
|
+
marked range is the In–Out segment with "Set in point" / "Set out
|
|
29
|
+
point" controls and an `in 0:12 · out 0:34` readout, the export flow
|
|
30
|
+
says "export" throughout with codec and encode-speed labels, every
|
|
31
|
+
failure reads as a sentence with a next step (raw text under
|
|
32
|
+
"Technical details"), and a failed update restart is reported. Each
|
|
33
|
+
dialog dismisses through its header ✕ alone, the export-done dialog
|
|
34
|
+
leads with "Export finished." and one accent primary (**Reveal in
|
|
35
|
+
folder**), output paths wrap with a full-path tooltip, and export and
|
|
36
|
+
telemetry phase text is announced in a live region and keeps keyboard
|
|
37
|
+
focus through phase changes.
|
|
38
|
+
- **New:** Accessibility hardening for the menu bar and dialogs: AltGr
|
|
39
|
+
characters type normally in every field, Left/Right move between the
|
|
40
|
+
menu labels with disabled rows announcing themselves, Tab stays
|
|
41
|
+
inside dialogs and the Help overlay, and the timeline scrubber
|
|
42
|
+
announces times instead of raw frame numbers.
|
|
43
|
+
- **New:** The transport and loop controls are compact and stable: the
|
|
44
|
+
Play/Pause button is icon-only with a tooltip and accessible name,
|
|
45
|
+
the in/out-point buttons form one group beside a fixed readout slot,
|
|
46
|
+
and toggling playback or marking points no longer shifts neighboring
|
|
47
|
+
controls. The ALT/SPD readouts sit in a strip along the map card's
|
|
48
|
+
bottom edge, the Map appearance popover docks left of the map card
|
|
49
|
+
and opens from **File → Map appearance…**, the empty workspace drops
|
|
50
|
+
its tooling hint and status footer, the header hides the duration
|
|
51
|
+
until a recording loads, and the map card shows "Preparing map…"
|
|
52
|
+
while its tiles load.
|
|
53
|
+
- **Internal:** Code consolidation and dead-export cleanup from a
|
|
54
|
+
refactoring pass; no behavior changes.
|
|
55
|
+
|
|
56
|
+
## 0.10.0
|
|
57
|
+
|
|
58
|
+
- **New:** Telemetry now comes from the embedded CAM meta (DVTM) stream
|
|
59
|
+
whenever a recording has one; the `.SRT` sidecar is only used when no
|
|
60
|
+
CAM meta stream is present. A CAM meta stream without GPS positions
|
|
61
|
+
fails the run with a clear error instead of silently falling back to
|
|
62
|
+
the sidecar.
|
|
63
|
+
- **New:** The opt-in OpenTelemetry trace export is removed along with
|
|
64
|
+
its `OTEL_*` environment variables. Stage logs, progress reporting
|
|
65
|
+
and rendered output are unchanged.
|
|
66
|
+
|
|
3
67
|
## 0.9.0
|
|
4
68
|
|
|
5
69
|
- **New:** The flight trail is now configurable: `--trail-color <hex>`
|
package/README.md
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
This handy little tool renders flight-path map videos from DJI drone
|
|
4
4
|
recordings (DJI Neo 2 and similar): the actual flight path on a 2D map,
|
|
5
|
-
ready to overlay
|
|
5
|
+
ready to overlay over the drone recording.
|
|
6
6
|
|
|
7
7
|
It reads geo-coordinates from DJI's telemetry in two ways:
|
|
8
8
|
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
|
|
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
13
|
It is a CLI tool first, so agents can drive it too — that's all cool with me.
|
|
14
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
|
|
15
|
+
recording and watch its flight path on the map in sync as you play.
|
|
16
16
|
|
|
17
17
|
## Quick start
|
|
18
18
|
|
|
@@ -26,8 +26,9 @@ npx drone-path "my-flight.mp4"
|
|
|
26
26
|
# topographic map, altitude + speed HUD
|
|
27
27
|
npx drone-path "my-flight.mp4" --style topo --hud heading,alt,speed
|
|
28
28
|
|
|
29
|
-
#
|
|
30
|
-
|
|
29
|
+
# flight track file alongside the render (GPX, GeoJSON, KML/KMZ or the
|
|
30
|
+
# telemetry JSON document, chosen by the extension; one recording per run)
|
|
31
|
+
npx drone-path "my-flight.mp4" --track-out "my-flight.gpx"
|
|
31
32
|
```
|
|
32
33
|
|
|
33
34
|
Output lands in the `out/` folder as `<basename>_map.mp4`; both the folder
|
|
@@ -37,7 +38,7 @@ overridable via `--ffmpeg`/`--ffprobe`, with a `PATH` fallback. All
|
|
|
37
38
|
requirements and install options are in
|
|
38
39
|
[Getting started](docs/user/getting-started.md).
|
|
39
40
|
|
|
40
|
-
##
|
|
41
|
+
## User manual
|
|
41
42
|
|
|
42
43
|
The user manual lives in [docs/user/](docs/user/README.md); the desktop app
|
|
43
44
|
ships the same pages as offline help. Highlights:
|
|
@@ -57,16 +58,17 @@ For reviewing flights without the terminal, grab the packaged desktop app
|
|
|
57
58
|
[GitHub Releases](https://github.com/MrManny/drone-path/releases), or run
|
|
58
59
|
`npm run build && npm run app` from a checkout.
|
|
59
60
|
|
|
60
|
-
The app shows the
|
|
61
|
-
|
|
61
|
+
The app shows the recording and the synchronized flight map side by side —
|
|
62
|
+
togglable to a corner map overlay — on one shared timeline;
|
|
62
63
|
[the manual](docs/user/desktop-app.md) walks through loading a recording,
|
|
63
|
-
reviewing a flight,
|
|
64
|
+
reviewing a flight, marking a passage, exporting, and saving the per-frame
|
|
64
65
|
telemetry JSON. The look settings carry over between launches.
|
|
65
66
|
|
|
66
|
-

|
|
67
68
|
|
|
68
|
-
*The desktop app playing a recording:
|
|
69
|
-
with the flight trail, drone position and HUD chips on one shared
|
|
69
|
+
*The desktop app playing a recording: the recording beside the synchronized
|
|
70
|
+
flight map, with the flight trail, drone position and HUD chips on one shared
|
|
71
|
+
timeline.*
|
|
70
72
|
|
|
71
73
|
## Feature requests
|
|
72
74
|
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Third-party notices
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
License
|
|
8
|
-
|
|
9
|
-
the
|
|
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
|
|
package/app/ipc.d.mts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AppSession } from '../src/appsession.js';
|
|
2
|
+
import type { AppState } from '../src/appstate.js';
|
|
3
|
+
import type { ExportRequest, RenderConfig } from '../src/config.js';
|
|
4
|
+
import type { UpdateController } from './update.mjs';
|
|
5
|
+
|
|
6
|
+
export interface IpcWindow {
|
|
7
|
+
isDestroyed(): boolean;
|
|
8
|
+
close(): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface IpcState {
|
|
12
|
+
session: AppSession | null;
|
|
13
|
+
config: RenderConfig;
|
|
14
|
+
appState: AppState;
|
|
15
|
+
win: IpcWindow | null;
|
|
16
|
+
exportRunner: {
|
|
17
|
+
start(videoPath: string, request: ExportRequest): void;
|
|
18
|
+
cancel(): void;
|
|
19
|
+
};
|
|
20
|
+
updates: UpdateController | null;
|
|
21
|
+
updateReady: boolean;
|
|
22
|
+
lastExportOut: string | null;
|
|
23
|
+
lastTelemetryOut: string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface IpcHandlersOptions {
|
|
27
|
+
devUrl: string | null;
|
|
28
|
+
log: (message: string) => void;
|
|
29
|
+
sendToWindow(state: IpcState, channel: string, payload: unknown): void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function registerIpcHandlers(state: IpcState, options: IpcHandlersOptions): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the final save path: the typed name stands as typed when it already
|
|
36
|
+
* ends in one of the accepted extensions (any case); otherwise the default
|
|
37
|
+
* extension is appended to it.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveSavePath(
|
|
40
|
+
typedPath: string,
|
|
41
|
+
extensions: readonly string[],
|
|
42
|
+
defaultExtension: string,
|
|
43
|
+
): string;
|
package/app/ipc.mjs
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
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 { ERR_NO_RECORDING, errorMessage } from '../dist/errors.js';
|
|
14
|
+
import { videoBaseName } from '../dist/recordings.js';
|
|
15
|
+
import { outputPathFor } from '../dist/pipeline.js';
|
|
16
|
+
import { TRACK_FORMAT_VALUES } from '../dist/track-format.js';
|
|
17
|
+
|
|
18
|
+
// Only this app's window may drive the session state machine.
|
|
19
|
+
function assertTrusted(event, devUrl) {
|
|
20
|
+
const url = (event.senderFrame && event.senderFrame.url) || '';
|
|
21
|
+
const devOk = devUrl !== null && url.startsWith(devUrl);
|
|
22
|
+
if (!url.startsWith(APP_ORIGIN + '/') && !devOk) {
|
|
23
|
+
throw new Error('untrusted ipc sender');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function handle(devUrl, channel, fn) {
|
|
28
|
+
ipcMain.handle(channel, async (event, ...args) => {
|
|
29
|
+
// Outside the envelope: an untrusted sender must see a rejected promise,
|
|
30
|
+
// never a well-formed reply.
|
|
31
|
+
assertTrusted(event, devUrl);
|
|
32
|
+
try {
|
|
33
|
+
return await fn(...args);
|
|
34
|
+
} catch (e) {
|
|
35
|
+
return { ok: false, error: errorMessage(e) };
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function requireVideo(state) {
|
|
41
|
+
const video = state.session ? state.session.videoPath() : null;
|
|
42
|
+
if (!video) throw new Error(ERR_NO_RECORDING);
|
|
43
|
+
return video;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The reveal/open guard: the renderer may only name a file this shell wrote
|
|
47
|
+
// (the last export or the last telemetry document, both set only by trusted
|
|
48
|
+
// handlers), never an arbitrary path.
|
|
49
|
+
function knownOutputOf(state, payload) {
|
|
50
|
+
const out = payload && typeof payload === 'object' ? payload.out : null;
|
|
51
|
+
if (typeof out !== 'string' || (out !== state.lastExportOut && out !== state.lastTelemetryOut)) {
|
|
52
|
+
throw new Error('unknown output');
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// The native dialog confirmed the name as typed, but the extension may have
|
|
58
|
+
// been appended after it: re-check the final path on every platform so an
|
|
59
|
+
// existing file is never replaced without a confirmation.
|
|
60
|
+
async function confirmReplace(state, chosen) {
|
|
61
|
+
if (!fs.existsSync(chosen)) return true;
|
|
62
|
+
const box = {
|
|
63
|
+
type: 'warning',
|
|
64
|
+
buttons: ['Replace', 'Cancel'],
|
|
65
|
+
defaultId: 1,
|
|
66
|
+
cancelId: 1,
|
|
67
|
+
message: `Replace ${path.basename(chosen)}?`,
|
|
68
|
+
detail: chosen,
|
|
69
|
+
};
|
|
70
|
+
const confirm = state.win
|
|
71
|
+
? await dialog.showMessageBox(state.win, box)
|
|
72
|
+
: await dialog.showMessageBox(box);
|
|
73
|
+
return confirm.response === 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The CLI's default naming, with a relative out dir anchored at the
|
|
77
|
+
// recording: the app process has no meaningful working directory.
|
|
78
|
+
function exportDefaultFor(state, video) {
|
|
79
|
+
const outDir = state.config.outDir
|
|
80
|
+
? path.resolve(path.dirname(video), state.config.outDir)
|
|
81
|
+
: null;
|
|
82
|
+
return outputPathFor(video, { ...state.config, outDir });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Pure name rule for save dialogs: the typed name stands as typed when it
|
|
86
|
+
// already ends in one of the accepted extensions (any case); otherwise the
|
|
87
|
+
// default extension is appended to it as typed, so "notes.csv" becomes
|
|
88
|
+
// "notes.csv.json". The dialogs that report the result show this final name,
|
|
89
|
+
// so the append is never silent.
|
|
90
|
+
export function resolveSavePath(typedPath, extensions, defaultExtension) {
|
|
91
|
+
const lower = typedPath.toLowerCase();
|
|
92
|
+
return extensions.some((extension) => lower.endsWith(`.${extension}`))
|
|
93
|
+
? typedPath
|
|
94
|
+
: `${typedPath}.${defaultExtension}`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function pickSavePath(state, { title, defaultPath, filters, extensions, defaultExtension }) {
|
|
98
|
+
const options = { title, defaultPath, filters };
|
|
99
|
+
const result = state.win
|
|
100
|
+
? await dialog.showSaveDialog(state.win, options)
|
|
101
|
+
: await dialog.showSaveDialog(options);
|
|
102
|
+
if (result.canceled || !result.filePath) return { ok: false, canceled: true };
|
|
103
|
+
const chosen = resolveSavePath(result.filePath, extensions, defaultExtension);
|
|
104
|
+
if (!(await confirmReplace(state, chosen))) return { ok: false, canceled: true };
|
|
105
|
+
return { ok: true, path: chosen };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function registerSessionHandlers(state, devUrl) {
|
|
109
|
+
handle(devUrl, 'dronepath:pick', (raw) => state.session.pick(parsePickRequest(raw)));
|
|
110
|
+
handle(devUrl, 'dronepath:session', () => state.session.getSession());
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function registerSettingsHandlers(state, devUrl, log) {
|
|
114
|
+
handle(devUrl, 'dronepath:settings', () => state.config);
|
|
115
|
+
handle(devUrl, 'dronepath:settings:save', (raw) => {
|
|
116
|
+
const settings = parseSettingsPatch(raw, 'settings');
|
|
117
|
+
state.appState = { ...state.appState, settings };
|
|
118
|
+
state.config = applyAppState(state.config, state.appState);
|
|
119
|
+
try {
|
|
120
|
+
writeAppState(appStateFile(), state.appState);
|
|
121
|
+
} catch (e) {
|
|
122
|
+
// The look still applies when the state file cannot be written.
|
|
123
|
+
log(`app state not saved: ${errorMessage(e)}`);
|
|
124
|
+
}
|
|
125
|
+
return { ok: true };
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function registerExportHandlers(state, devUrl) {
|
|
130
|
+
handle(devUrl, 'dronepath:export:pick-output', async () => {
|
|
131
|
+
const video = requireVideo(state);
|
|
132
|
+
return pickSavePath(state, {
|
|
133
|
+
title: 'Export video',
|
|
134
|
+
defaultPath: exportDefaultFor(state, video),
|
|
135
|
+
filters: [{ name: 'MP4 video', extensions: ['mp4'] }],
|
|
136
|
+
extensions: ['mp4'],
|
|
137
|
+
defaultExtension: 'mp4',
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
handle(devUrl, 'dronepath:export:start', (raw) => {
|
|
141
|
+
const video = requireVideo(state);
|
|
142
|
+
state.exportRunner.start(video, parseExportRequest(raw, state.config));
|
|
143
|
+
return { ok: true };
|
|
144
|
+
});
|
|
145
|
+
handle(devUrl, 'dronepath:export:cancel', () => {
|
|
146
|
+
state.exportRunner.cancel();
|
|
147
|
+
return { ok: true };
|
|
148
|
+
});
|
|
149
|
+
handle(devUrl, 'dronepath:export:reveal', (payload) => {
|
|
150
|
+
shell.showItemInFolder(knownOutputOf(state, payload));
|
|
151
|
+
return { ok: true };
|
|
152
|
+
});
|
|
153
|
+
handle(devUrl, 'dronepath:export:open', async (payload) => {
|
|
154
|
+
const error = await shell.openPath(knownOutputOf(state, payload));
|
|
155
|
+
return error ? { ok: false, error } : { ok: true };
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function registerTelemetryHandlers(state, devUrl, log) {
|
|
160
|
+
handle(devUrl, 'dronepath:telemetry:pick-output', async () => {
|
|
161
|
+
const video = requireVideo(state);
|
|
162
|
+
// The export dialog's default folder, named after the recording
|
|
163
|
+
// (<basename>.telemetry.json); the typed name selects the format by its
|
|
164
|
+
// extension, with the telemetry document as the bare-name default.
|
|
165
|
+
const exportDefault = exportDefaultFor(state, video);
|
|
166
|
+
return pickSavePath(state, {
|
|
167
|
+
title: 'Export telemetry',
|
|
168
|
+
defaultPath: path.join(path.dirname(exportDefault), `${videoBaseName(video)}.telemetry.json`),
|
|
169
|
+
filters: [
|
|
170
|
+
{ name: 'Telemetry document (JSON)', extensions: ['json'] },
|
|
171
|
+
{ name: 'GPX track', extensions: ['gpx'] },
|
|
172
|
+
{ name: 'GeoJSON track', extensions: ['geojson'] },
|
|
173
|
+
{ name: 'KML track', extensions: ['kml'] },
|
|
174
|
+
{ name: 'KMZ track', extensions: ['kmz'] },
|
|
175
|
+
],
|
|
176
|
+
extensions: [...TRACK_FORMAT_VALUES],
|
|
177
|
+
defaultExtension: 'json',
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
handle(devUrl, 'dronepath:telemetry:save', (raw) => {
|
|
181
|
+
requireVideo(state);
|
|
182
|
+
const request = parseTelemetrySaveRequest(raw);
|
|
183
|
+
state.session.saveTelemetryJson(request.outPath, request.range);
|
|
184
|
+
state.lastTelemetryOut = request.outPath;
|
|
185
|
+
log(`track: wrote ${request.outPath}`);
|
|
186
|
+
return { ok: true };
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function registerUpdateHandlers(state, devUrl, sendToWindow) {
|
|
191
|
+
handle(devUrl, 'dronepath:update:restart', () => {
|
|
192
|
+
if (!state.updates) return { ok: false, error: 'this build does not self-update' };
|
|
193
|
+
// No pendingClose here: the prompt never opens over a running export, and
|
|
194
|
+
// a failed restart must not poison the export close guard.
|
|
195
|
+
return state.updates.restart({
|
|
196
|
+
onError: (message) => sendToWindow(state, 'dronepath:update:restart-failed', message),
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
handle(devUrl, 'dronepath:update:state', () => ({ ready: state.updateReady }));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function registerWindowHandlers(state, devUrl) {
|
|
203
|
+
handle(devUrl, 'dronepath:window:close', () => {
|
|
204
|
+
// The window's close handler runs the running-export guard.
|
|
205
|
+
if (state.win && !state.win.isDestroyed()) state.win.close();
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function registerIpcHandlers(state, { devUrl, log, sendToWindow }) {
|
|
210
|
+
registerSessionHandlers(state, devUrl);
|
|
211
|
+
registerSettingsHandlers(state, devUrl, log);
|
|
212
|
+
registerExportHandlers(state, devUrl);
|
|
213
|
+
registerTelemetryHandlers(state, devUrl, log);
|
|
214
|
+
registerUpdateHandlers(state, devUrl, sendToWindow);
|
|
215
|
+
registerWindowHandlers(state, devUrl);
|
|
216
|
+
}
|