drone-path 0.9.0 → 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.
- package/CHANGELOG.md +11 -0
- package/README.md +3 -3
- package/THIRD-PARTY-NOTICES.md +7 -7
- package/app/ipc.mjs +178 -0
- package/app/main.mjs +4 -198
- package/dist/appsession.js +25 -59
- package/dist/appstate.js +22 -20
- package/dist/cammeta.js +4 -5
- package/dist/cli.js +3 -21
- package/dist/config.js +190 -129
- package/dist/ff.js +2 -19
- package/dist/frametime.js +32 -0
- package/dist/png.js +1 -18
- package/dist/render.js +35 -112
- package/dist/run.js +49 -112
- package/dist/telemetry-json.js +33 -27
- package/dist/telemetry-math.js +2 -1
- package/dist/telemetry.js +18 -14
- package/dist/tiles.js +30 -86
- package/package.json +7 -8
- package/dist/renderer/leaflet.js +0 -1
- package/dist/tracing.js +0 -184
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
+
|
|
3
14
|
## 0.9.0
|
|
4
15
|
|
|
5
16
|
- **New:** The flight trail is now configurable: `--trail-color <hex>`
|
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@ ready to overlay in your drone flight footage.
|
|
|
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
|
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.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,
|
|
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,17 +20,15 @@ import {
|
|
|
20
20
|
rememberOpenedFile,
|
|
21
21
|
writeAppState,
|
|
22
22
|
} from '../dist/appstate.js';
|
|
23
|
-
import { createAppSession
|
|
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
|
-
import { videoBaseName } from '../dist/inputs.js';
|
|
31
29
|
import { rangePlan } from '../dist/range.js';
|
|
32
|
-
import { outputPathFor } from '../dist/run.js';
|
|
33
30
|
import { createTileTraffic } from '../dist/tiles.js';
|
|
31
|
+
import { registerIpcHandlers } from './ipc.mjs';
|
|
34
32
|
import { initUpdates } from './update.mjs';
|
|
35
33
|
|
|
36
34
|
const SCHEME = 'app';
|
|
@@ -191,45 +189,6 @@ async function handleRequest(state, request) {
|
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
191
|
|
|
194
|
-
// Only this app's window may drive the session state machine.
|
|
195
|
-
function assertTrusted(event) {
|
|
196
|
-
const url = (event.senderFrame && event.senderFrame.url) || '';
|
|
197
|
-
const devOk = DEV_URL !== null && url.startsWith(DEV_URL);
|
|
198
|
-
if (!url.startsWith(APP_ORIGIN + '/') && !devOk) {
|
|
199
|
-
throw new Error('untrusted ipc sender');
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
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) {
|
|
207
|
-
const out = payload && typeof payload === 'object' ? payload.out : null;
|
|
208
|
-
if (typeof out !== 'string' || (out !== state.lastExportOut && out !== state.lastTelemetryOut)) {
|
|
209
|
-
throw new Error('unknown output');
|
|
210
|
-
}
|
|
211
|
-
return out;
|
|
212
|
-
}
|
|
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
|
-
|
|
233
192
|
// The backing services behind the window: tool check, config, tile cache and
|
|
234
193
|
// the recording session.
|
|
235
194
|
async function initServices(state) {
|
|
@@ -266,159 +225,6 @@ function initExportRunner(state) {
|
|
|
266
225
|
});
|
|
267
226
|
}
|
|
268
227
|
|
|
269
|
-
function registerIpcHandlers(state) {
|
|
270
|
-
ipcMain.handle('dronepath:pick', (event, raw) => {
|
|
271
|
-
assertTrusted(event);
|
|
272
|
-
try {
|
|
273
|
-
return state.session.pick(parsePickRequest(raw));
|
|
274
|
-
} catch (e) {
|
|
275
|
-
return { ok: false, error: errorMessage(e) };
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
ipcMain.handle('dronepath:session', (event) => {
|
|
279
|
-
assertTrusted(event);
|
|
280
|
-
return state.session.getSession();
|
|
281
|
-
});
|
|
282
|
-
ipcMain.handle('dronepath:settings', (event) => {
|
|
283
|
-
assertTrusted(event);
|
|
284
|
-
return state.config;
|
|
285
|
-
});
|
|
286
|
-
ipcMain.handle('dronepath:settings:save', (event, raw) => {
|
|
287
|
-
assertTrusted(event);
|
|
288
|
-
let settings;
|
|
289
|
-
try {
|
|
290
|
-
settings = parseSettingsPatch(raw, 'settings');
|
|
291
|
-
} catch (e) {
|
|
292
|
-
return { ok: false, error: errorMessage(e) };
|
|
293
|
-
}
|
|
294
|
-
state.appState = { ...state.appState, settings };
|
|
295
|
-
state.config = applyAppState(state.config, state.appState);
|
|
296
|
-
try {
|
|
297
|
-
writeAppState(appStateFile(), state.appState);
|
|
298
|
-
} catch (e) {
|
|
299
|
-
// The look still applies when the state file cannot be written.
|
|
300
|
-
log(`app state not saved: ${errorMessage(e)}`);
|
|
301
|
-
}
|
|
302
|
-
return { ok: true };
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
ipcMain.handle('dronepath:export:pick-output', async (event) => {
|
|
306
|
-
assertTrusted(event);
|
|
307
|
-
const video = state.session ? state.session.videoPath() : null;
|
|
308
|
-
if (!video) return { ok: false, error: 'no recording loaded' };
|
|
309
|
-
// The CLI's default naming, with a relative out dir anchored at the
|
|
310
|
-
// recording: the app process has no meaningful working directory.
|
|
311
|
-
const outDir = state.config.outDir
|
|
312
|
-
? path.resolve(path.dirname(video), state.config.outDir)
|
|
313
|
-
: null;
|
|
314
|
-
const options = {
|
|
315
|
-
title: 'Export video',
|
|
316
|
-
defaultPath: outputPathFor(video, { ...state.config, outDir }),
|
|
317
|
-
filters: [{ name: 'MP4 video', extensions: ['mp4'] }],
|
|
318
|
-
};
|
|
319
|
-
const result = state.win
|
|
320
|
-
? await dialog.showSaveDialog(state.win, options)
|
|
321
|
-
: await dialog.showSaveDialog(options);
|
|
322
|
-
if (result.canceled || !result.filePath) return { ok: false, canceled: true };
|
|
323
|
-
const chosen = result.filePath.toLowerCase().endsWith('.mp4')
|
|
324
|
-
? result.filePath
|
|
325
|
-
: `${result.filePath}.mp4`;
|
|
326
|
-
if (!(await confirmReplace(state, chosen))) return { ok: false, canceled: true };
|
|
327
|
-
return { ok: true, path: chosen };
|
|
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
|
-
});
|
|
368
|
-
ipcMain.handle('dronepath:export:start', (event, raw) => {
|
|
369
|
-
assertTrusted(event);
|
|
370
|
-
try {
|
|
371
|
-
const video = state.session ? state.session.videoPath() : null;
|
|
372
|
-
if (!video) return { ok: false, error: 'no recording loaded' };
|
|
373
|
-
state.exportRunner.start(video, parseExportRequest(raw, state.config));
|
|
374
|
-
return { ok: true };
|
|
375
|
-
} catch (e) {
|
|
376
|
-
return { ok: false, error: errorMessage(e) };
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
ipcMain.handle('dronepath:export:cancel', (event) => {
|
|
380
|
-
assertTrusted(event);
|
|
381
|
-
state.exportRunner.cancel();
|
|
382
|
-
return { ok: true };
|
|
383
|
-
});
|
|
384
|
-
ipcMain.handle('dronepath:export:reveal', (event, payload) => {
|
|
385
|
-
assertTrusted(event);
|
|
386
|
-
try {
|
|
387
|
-
shell.showItemInFolder(knownOutputOf(state, payload));
|
|
388
|
-
return { ok: true };
|
|
389
|
-
} catch (e) {
|
|
390
|
-
return { ok: false, error: errorMessage(e) };
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
ipcMain.handle('dronepath:export:open', async (event, payload) => {
|
|
394
|
-
assertTrusted(event);
|
|
395
|
-
try {
|
|
396
|
-
const error = await shell.openPath(knownOutputOf(state, payload));
|
|
397
|
-
return error ? { ok: false, error } : { ok: true };
|
|
398
|
-
} catch (e) {
|
|
399
|
-
return { ok: false, error: errorMessage(e) };
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
ipcMain.handle('dronepath:update:restart', (event) => {
|
|
403
|
-
assertTrusted(event);
|
|
404
|
-
if (!state.updates) return { ok: false, error: 'this build does not self-update' };
|
|
405
|
-
// No pendingClose here: the prompt never opens over a running export, and
|
|
406
|
-
// a failed restart must not poison the export close guard.
|
|
407
|
-
return state.updates.restart({
|
|
408
|
-
onError: (message) => sendToWindow(state, 'dronepath:update:restart-failed', message),
|
|
409
|
-
});
|
|
410
|
-
});
|
|
411
|
-
ipcMain.handle('dronepath:update:state', (event) => {
|
|
412
|
-
assertTrusted(event);
|
|
413
|
-
return { ready: state.updateReady };
|
|
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
|
-
});
|
|
420
|
-
}
|
|
421
|
-
|
|
422
228
|
function installProtocolHandler(state) {
|
|
423
229
|
protocol.handle(SCHEME, (request) =>
|
|
424
230
|
handleRequest(state, request).catch((e) => {
|
|
@@ -536,7 +342,7 @@ async function startup() {
|
|
|
536
342
|
sendToWindow(state, 'dronepath:update:ready');
|
|
537
343
|
},
|
|
538
344
|
});
|
|
539
|
-
registerIpcHandlers(state);
|
|
345
|
+
registerIpcHandlers(state, { devUrl: DEV_URL, log, sendToWindow });
|
|
540
346
|
installProtocolHandler(state);
|
|
541
347
|
ensureUiExport();
|
|
542
348
|
createWindow(state);
|
package/dist/appsession.js
CHANGED
|
@@ -1,72 +1,40 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
3
4
|
import { TILE_BASE, mediaUrlFor } from './apppaths.js';
|
|
4
|
-
import {
|
|
5
|
+
import { parseFrameRange, parseLookSettings, parseValue, resolveRange, strictShape, } from './config.js';
|
|
5
6
|
import { errorMessage } from './errors.js';
|
|
7
|
+
import { timeAt } from './frametime.js';
|
|
6
8
|
import { isRecordingName } from './inputs.js';
|
|
7
9
|
import { buildSceneData } from './page.js';
|
|
8
|
-
import { prepareSession, recordingPageOpts,
|
|
9
|
-
import {
|
|
10
|
+
import { prepareSession, recordingPageOpts, telemetryExportInput, } from './run.js';
|
|
11
|
+
import { writeTelemetryDocument } from './telemetry-json.js';
|
|
10
12
|
export function frameExactDuration(probe) {
|
|
11
|
-
return probe.frames
|
|
13
|
+
return timeAt(probe.frames, probe.fps.value);
|
|
12
14
|
}
|
|
13
15
|
export function parsePickRequest(raw) {
|
|
14
16
|
const input = typeof raw === 'object' && raw !== null ? raw : {};
|
|
15
|
-
|
|
16
|
-
? input.settings
|
|
17
|
-
: {};
|
|
18
|
-
const { style, view, hud } = look;
|
|
19
|
-
if (typeof style !== 'string' || !STYLE_VALUES.includes(style)) {
|
|
20
|
-
throw new Error(`unknown map style: ${String(style)}`);
|
|
21
|
-
}
|
|
22
|
-
if (typeof view !== 'string' || !VIEW_VALUES.includes(view)) {
|
|
23
|
-
throw new Error(`unknown view: ${String(view)}`);
|
|
24
|
-
}
|
|
25
|
-
const zoom = asNumber(look.zoom, 'zoom');
|
|
26
|
-
const zoomOut = asNumber(look.zoomOut, 'zoom-out');
|
|
27
|
-
if (!(zoom >= 0))
|
|
28
|
-
throw new Error('zoom must be >= 0 (0 = auto-fit)');
|
|
29
|
-
if (!(zoomOut >= 0))
|
|
30
|
-
throw new Error('zoom-out must be >= 0');
|
|
31
|
-
const introSec = asNumber(look.introSec, 'intro');
|
|
32
|
-
const outroSec = asNumber(look.outroSec, 'outro');
|
|
33
|
-
if (!(introSec >= 0))
|
|
34
|
-
throw new Error('intro must be 0 or more');
|
|
35
|
-
if (!(outroSec >= 0))
|
|
36
|
-
throw new Error('outro must be 0 or more');
|
|
37
|
-
const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
|
|
38
|
-
const chips = typeof hud === 'object' && hud !== null ? hud : {};
|
|
39
|
-
return {
|
|
40
|
-
settings: {
|
|
41
|
-
style: style,
|
|
42
|
-
view: view,
|
|
43
|
-
zoom,
|
|
44
|
-
zoomOut,
|
|
45
|
-
hud: { heading: !!chips.heading, alt: !!chips.alt, speed: !!chips.speed },
|
|
46
|
-
introSec,
|
|
47
|
-
outroSec,
|
|
48
|
-
trailColor,
|
|
49
|
-
},
|
|
50
|
-
};
|
|
17
|
+
return { settings: parseLookSettings(input.settings) };
|
|
51
18
|
}
|
|
19
|
+
const TELEMETRY_SAVE_SHAPE = {
|
|
20
|
+
outPath: z.unknown().optional(),
|
|
21
|
+
range: z.unknown().optional(),
|
|
22
|
+
};
|
|
52
23
|
export function parseTelemetrySaveRequest(raw) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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}`);
|
|
24
|
+
const request = parseValue(strictShape(TELEMETRY_SAVE_SHAPE, {
|
|
25
|
+
invalid: 'invalid telemetry save request',
|
|
26
|
+
unknownKey: (key) => `unknown telemetry save request key ${key}`,
|
|
27
|
+
}), raw);
|
|
28
|
+
const outPath = parseValue(z
|
|
29
|
+
.string({ error: () => 'invalid telemetry save request: outPath' })
|
|
30
|
+
.min(1, { error: () => 'invalid telemetry save request: outPath' }), request.outPath);
|
|
31
|
+
if (!outPath.toLowerCase().endsWith('.json')) {
|
|
32
|
+
throw new Error(`invalid telemetry save request: outPath must be a .json file: ${outPath}`);
|
|
67
33
|
}
|
|
68
|
-
const range =
|
|
69
|
-
|
|
34
|
+
const range = request.range === undefined || request.range === null
|
|
35
|
+
? null
|
|
36
|
+
: parseFrameRange(request.range);
|
|
37
|
+
return { outPath, range };
|
|
70
38
|
}
|
|
71
39
|
export const prepareUiSession = async (videoPath, config, log, onProgress, deps) => {
|
|
72
40
|
const prep = await prepareSession(videoPath, config, log, {
|
|
@@ -154,9 +122,7 @@ export function createAppSession(options) {
|
|
|
154
122
|
saveTelemetryJson(file, range) {
|
|
155
123
|
if (!prepared)
|
|
156
124
|
throw new Error('no recording loaded');
|
|
157
|
-
|
|
158
|
-
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
159
|
-
fs.writeFileSync(file, serializeTelemetryDocument(doc));
|
|
125
|
+
writeTelemetryDocument(file, segmentTelemetryInput(prepared.telemetry, range));
|
|
160
126
|
},
|
|
161
127
|
};
|
|
162
128
|
}
|
package/dist/appstate.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import {
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { DEFAULT_CONFIG, SETTINGS_KEYS, formatHud, parseSettingsPatch, parseValue, strictShape, } from './config.js';
|
|
4
5
|
export const APP_STATE_VERSION = 1;
|
|
5
6
|
export function emptyAppState() {
|
|
6
7
|
return { settings: null, lastOpenDir: null };
|
|
@@ -15,27 +16,28 @@ function fillMissingSettings(raw) {
|
|
|
15
16
|
}
|
|
16
17
|
return filled;
|
|
17
18
|
}
|
|
19
|
+
const APP_STATE_SHAPE = {
|
|
20
|
+
version: z.unknown().optional(),
|
|
21
|
+
settings: z.unknown().optional(),
|
|
22
|
+
lastOpenDir: z.unknown().optional(),
|
|
23
|
+
};
|
|
24
|
+
const LAST_OPEN_DIR = z
|
|
25
|
+
.optional(z.nullable(z.string({
|
|
26
|
+
error: (issue) => `invalid app state: lastOpenDir: ${String(issue.input)}`,
|
|
27
|
+
})))
|
|
28
|
+
.transform((value) => value ?? null);
|
|
18
29
|
export function parseAppState(raw) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (r.version !== APP_STATE_VERSION) {
|
|
29
|
-
throw new Error(`unsupported app state version: ${String(r.version)}`);
|
|
30
|
-
}
|
|
31
|
-
const settings = r.settings === undefined || r.settings === null
|
|
30
|
+
const state = parseValue(strictShape(APP_STATE_SHAPE, {
|
|
31
|
+
invalid: 'invalid app state',
|
|
32
|
+
unknownKey: (key) => `unknown app state key ${key}`,
|
|
33
|
+
}), raw);
|
|
34
|
+
parseValue(z.literal(APP_STATE_VERSION, {
|
|
35
|
+
error: (issue) => `unsupported app state version: ${String(issue.input)}`,
|
|
36
|
+
}), state.version);
|
|
37
|
+
const settings = state.settings === undefined || state.settings === null
|
|
32
38
|
? null
|
|
33
|
-
: parseSettingsPatch(fillMissingSettings(
|
|
34
|
-
|
|
35
|
-
throw new Error(`invalid app state: lastOpenDir: ${String(r.lastOpenDir)}`);
|
|
36
|
-
}
|
|
37
|
-
const lastOpenDir = typeof r.lastOpenDir === 'string' ? r.lastOpenDir : null;
|
|
38
|
-
return { settings, lastOpenDir };
|
|
39
|
+
: parseSettingsPatch(fillMissingSettings(state.settings), 'app state');
|
|
40
|
+
return { settings, lastOpenDir: parseValue(LAST_OPEN_DIR, state.lastOpenDir) };
|
|
39
41
|
}
|
|
40
42
|
export function serializeAppState(state) {
|
|
41
43
|
const out = { version: APP_STATE_VERSION };
|
package/dist/cammeta.js
CHANGED
|
@@ -304,22 +304,21 @@ function spreadSampleTimes(samples, durationSec) {
|
|
|
304
304
|
sample.tSec = (k / Math.max(1, samples.length - 1)) * span;
|
|
305
305
|
});
|
|
306
306
|
}
|
|
307
|
+
// Resolves to null only when the video carries no CAM meta stream at all; a
|
|
308
|
+
// present stream that yields nothing decodable resolves to empty samples so
|
|
309
|
+
// callers can tell absence from a stream without GPS fix pairs.
|
|
307
310
|
export async function parseCamMeta(tools, videoPath, durationSec, opts = {}) {
|
|
308
311
|
const streamIndex = await findCamMetaIndex(tools, videoPath);
|
|
309
312
|
if (streamIndex === null)
|
|
310
313
|
return null;
|
|
311
314
|
const packets = await listCamMetaPackets(tools, videoPath, streamIndex);
|
|
312
315
|
const buf = await dumpCamMetaStream(tools, videoPath, streamIndex);
|
|
313
|
-
if (buf.length === 0)
|
|
314
|
-
return null;
|
|
315
316
|
const sizeSum = packets.reduce((sum, packet) => sum + (Number.isFinite(packet.size) ? packet.size : 0), 0);
|
|
316
|
-
if (packets.length > 0 && sizeSum === buf.length) {
|
|
317
|
+
if (buf.length > 0 && packets.length > 0 && sizeSum === buf.length) {
|
|
317
318
|
const { samples, noLock, provenance } = decodePacketSamples(buf, packets, opts.keepAll === true);
|
|
318
319
|
return { samples, noLock, method: 'dvtm-packets', ...provenance };
|
|
319
320
|
}
|
|
320
321
|
const samples = scanBufferForGpsPairs(buf);
|
|
321
|
-
if (samples.length === 0)
|
|
322
|
-
return null;
|
|
323
322
|
spreadSampleTimes(samples, durationSec);
|
|
324
323
|
return {
|
|
325
324
|
samples,
|