drone-path 0.10.0 → 0.11.1

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 (48) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +16 -11
  3. package/app/ipc.d.mts +43 -0
  4. package/app/ipc.mjs +92 -54
  5. package/app/main.mjs +6 -6
  6. package/dist/appsession.js +17 -24
  7. package/dist/appstate.js +2 -1
  8. package/dist/buildinfo.js +9 -16
  9. package/dist/cammeta-decode.js +237 -0
  10. package/dist/cammeta.js +4 -242
  11. package/dist/cli.js +37 -11
  12. package/dist/config.js +181 -82
  13. package/dist/configfile.js +20 -7
  14. package/dist/errors.js +30 -0
  15. package/dist/exec-tool.js +13 -0
  16. package/dist/exportjob.js +7 -7
  17. package/dist/{fftools.js → ffmpeg-tools.js} +5 -4
  18. package/dist/{ff.js → ffmpeg.js} +12 -10
  19. package/dist/geo.js +1 -1
  20. package/dist/logging.js +1 -0
  21. package/dist/manual/build.js +5 -10
  22. package/dist/manual/cliref.js +4 -1
  23. package/dist/manual/reference.js +6 -11
  24. package/dist/{run.js → pipeline.js} +59 -39
  25. package/dist/{proto.js → protobuf-wire.js} +5 -5
  26. package/dist/range.js +3 -3
  27. package/dist/{page.js → render-page.js} +2 -2
  28. package/dist/render.js +5 -18
  29. package/dist/renderer/boot.js +2 -2
  30. package/dist/renderer/dom.js +32 -10
  31. package/dist/renderer/scene.js +14 -6
  32. package/dist/restyle.js +1 -1
  33. package/dist/serve.js +1 -31
  34. package/dist/srt.js +2 -2
  35. package/dist/telemetry-json-schema.js +6 -11
  36. package/dist/telemetry-json.js +13 -0
  37. package/dist/telemetry-math.js +1 -1
  38. package/dist/{summary.js → telemetry-summary.js} +4 -4
  39. package/dist/telemetry.js +16 -6
  40. package/dist/track-format.js +13 -0
  41. package/dist/track-geojson.js +44 -0
  42. package/dist/track-gpx.js +34 -0
  43. package/dist/track-kml.js +47 -0
  44. package/dist/track-kmz.js +68 -0
  45. package/dist/track-write.js +41 -0
  46. package/dist/track.js +79 -0
  47. package/package.json +8 -8
  48. /package/dist/{inputs.js → recordings.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,65 @@
1
1
  # drone-path
2
2
 
3
+ ## 0.11.1
4
+
5
+ - **Fixed:** Video export in the packaged desktop app ("Export video…")
6
+ works again: the app now bundles the renderer's `playwright-core` and
7
+ renders with the system browser (Google Chrome or Microsoft Edge), the
8
+ same as the CLI.
9
+
10
+ ## 0.11.0
11
+
12
+ - **New:** Flight track files: `--track-out <file>` writes the decoded
13
+ flight track in the format the file extension picks — GPX (`.gpx`),
14
+ GeoJSON (`.geojson`), KML/KMZ (`.kml`/`.kmz`) — or the existing
15
+ telemetry JSON document (`.json`, unchanged bytes). Vertices sit at
16
+ decoded GPS fixes with telemetry gaps breaking the line, altitude is
17
+ the absolute/GPS altitude in meters above mean sea level, and times
18
+ appear only where a recording carries trustworthy UTC — none does
19
+ today (the CAM-meta device timestamp counts since power-up), so KML
20
+ exports plain line segments instead of a timed flythrough. The
21
+ desktop **Export telemetry…** dialog offers the same five formats and
22
+ honors the In–Out range; for the same recording and range the app and
23
+ the CLI write byte-identical files. `--telemetry-json <file>` is a
24
+ deprecated alias of `--track-out <file>.json` — same output, warns on
25
+ use, removed in a future version — and mixing the two spellings in
26
+ one run is an error. A frame range of a single frame is now valid
27
+ everywhere ranges are accepted.
28
+ - **New:** The timeline shows a lone in or out point as a half-open
29
+ In–Out segment — the in point runs to the end of the recording, the
30
+ out point from its start — and the readout names the same passage.
31
+ Playback wrap and both exports honor a lone point, setting a point
32
+ past the other replaces it, and the readout announces point changes
33
+ to screen readers.
34
+ - **New:** The app's copy is unified and the dialogs are polished: the
35
+ marked range is the In–Out segment with "Set in point" / "Set out
36
+ point" controls and an `in 0:12 · out 0:34` readout, the export flow
37
+ says "export" throughout with codec and encode-speed labels, every
38
+ failure reads as a sentence with a next step (raw text under
39
+ "Technical details"), and a failed update restart is reported. Each
40
+ dialog dismisses through its header ✕ alone, the export-done dialog
41
+ leads with "Export finished." and one accent primary (**Reveal in
42
+ folder**), output paths wrap with a full-path tooltip, and export and
43
+ telemetry phase text is announced in a live region and keeps keyboard
44
+ focus through phase changes.
45
+ - **New:** Accessibility hardening for the menu bar and dialogs: AltGr
46
+ characters type normally in every field, Left/Right move between the
47
+ menu labels with disabled rows announcing themselves, Tab stays
48
+ inside dialogs and the Help overlay, and the timeline scrubber
49
+ announces times instead of raw frame numbers.
50
+ - **New:** The transport and loop controls are compact and stable: the
51
+ Play/Pause button is icon-only with a tooltip and accessible name,
52
+ the in/out-point buttons form one group beside a fixed readout slot,
53
+ and toggling playback or marking points no longer shifts neighboring
54
+ controls. The ALT/SPD readouts sit in a strip along the map card's
55
+ bottom edge, the Map appearance popover docks left of the map card
56
+ and opens from **File → Map appearance…**, the empty workspace drops
57
+ its tooling hint and status footer, the header hides the duration
58
+ until a recording loads, and the map card shows "Preparing map…"
59
+ while its tiles load.
60
+ - **Internal:** Code consolidation and dead-export cleanup from a
61
+ refactoring pass; no behavior changes.
62
+
3
63
  ## 0.10.0
4
64
 
5
65
  - **New:** Telemetry now comes from the embedded CAM meta (DVTM) stream
package/README.md CHANGED
@@ -1,8 +1,11 @@
1
+ > [!NOTE]
2
+ > Head's up! This repo will be restructured as a monorepo in the near future.
3
+
1
4
  # Drone Path
2
5
 
3
6
  This handy little tool renders flight-path map videos from DJI drone
4
7
  recordings (DJI Neo 2 and similar): the actual flight path on a 2D map,
5
- ready to overlay in your drone flight footage.
8
+ ready to overlay over the drone recording.
6
9
 
7
10
  It reads geo-coordinates from DJI's telemetry in two ways:
8
11
 
@@ -12,7 +15,7 @@ It reads geo-coordinates from DJI's telemetry in two ways:
12
15
 
13
16
  It is a CLI tool first, so agents can drive it too — that's all cool with me.
14
17
  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.
18
+ recording and watch its flight path on the map in sync as you play.
16
19
 
17
20
  ## Quick start
18
21
 
@@ -26,8 +29,9 @@ npx drone-path "my-flight.mp4"
26
29
  # topographic map, altitude + speed HUD
27
30
  npx drone-path "my-flight.mp4" --style topo --hud heading,alt,speed
28
31
 
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"
32
+ # flight track file alongside the render (GPX, GeoJSON, KML/KMZ or the
33
+ # telemetry JSON document, chosen by the extension; one recording per run)
34
+ npx drone-path "my-flight.mp4" --track-out "my-flight.gpx"
31
35
  ```
32
36
 
33
37
  Output lands in the `out/` folder as `<basename>_map.mp4`; both the folder
@@ -37,7 +41,7 @@ overridable via `--ffmpeg`/`--ffprobe`, with a `PATH` fallback. All
37
41
  requirements and install options are in
38
42
  [Getting started](docs/user/getting-started.md).
39
43
 
40
- ## Documentation
44
+ ## User manual
41
45
 
42
46
  The user manual lives in [docs/user/](docs/user/README.md); the desktop app
43
47
  ships the same pages as offline help. Highlights:
@@ -57,16 +61,17 @@ For reviewing flights without the terminal, grab the packaged desktop app
57
61
  [GitHub Releases](https://github.com/MrManny/drone-path/releases), or run
58
62
  `npm run build && npm run app` from a checkout.
59
63
 
60
- The app shows the footage and the synchronized flight map side by side —
61
- swappable to a map overlay — on one shared timeline;
64
+ The app shows the recording and the synchronized flight map side by side —
65
+ togglable to a corner map overlay — on one shared timeline;
62
66
  [the manual](docs/user/desktop-app.md) walks through loading a recording,
63
- reviewing a flight, looping a passage, exporting, and saving the per-frame
67
+ reviewing a flight, marking a passage, exporting, and saving the per-frame
64
68
  telemetry JSON. The look settings carry over between launches.
65
69
 
66
- ![Desktop app: drone footage beside the synchronized flight map](docs/images/app-main-window.jpg)
70
+ ![Desktop app: a drone recording beside the synchronized flight map](docs/images/app-main-window.jpg)
67
71
 
68
- *The desktop app playing a recording: footage beside the synchronized flight map,
69
- with the flight trail, drone position and HUD chips on one shared timeline.*
72
+ *The desktop app playing a recording: the recording beside the synchronized
73
+ flight map, with the flight trail, drone position and HUD chips on one shared
74
+ timeline.*
70
75
 
71
76
  ## Feature requests
72
77
 
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 CHANGED
@@ -10,9 +10,10 @@ import { parsePickRequest, parseTelemetrySaveRequest } from '../dist/appsession.
10
10
  import { applyAppState, writeAppState } from '../dist/appstate.js';
11
11
  import { APP_ORIGIN, appStateFile } from '../dist/apppaths.js';
12
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';
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';
16
17
 
17
18
  // Only this app's window may drive the session state machine.
18
19
  function assertTrusted(event, devUrl) {
@@ -38,7 +39,7 @@ function handle(devUrl, channel, fn) {
38
39
 
39
40
  function requireVideo(state) {
40
41
  const video = state.session ? state.session.videoPath() : null;
41
- if (!video) throw new Error('no recording loaded');
42
+ if (!video) throw new Error(ERR_NO_RECORDING);
42
43
  return video;
43
44
  }
44
45
 
@@ -72,9 +73,44 @@ async function confirmReplace(state, chosen) {
72
73
  return confirm.response === 0;
73
74
  }
74
75
 
75
- export function registerIpcHandlers(state, { devUrl, log, sendToWindow }) {
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) {
76
109
  handle(devUrl, 'dronepath:pick', (raw) => state.session.pick(parsePickRequest(raw)));
77
110
  handle(devUrl, 'dronepath:session', () => state.session.getSession());
111
+ }
112
+
113
+ function registerSettingsHandlers(state, devUrl, log) {
78
114
  handle(devUrl, 'dronepath:settings', () => state.config);
79
115
  handle(devUrl, 'dronepath:settings:save', (raw) => {
80
116
  const settings = parseSettingsPatch(raw, 'settings');
@@ -88,61 +124,19 @@ export function registerIpcHandlers(state, { devUrl, log, sendToWindow }) {
88
124
  }
89
125
  return { ok: true };
90
126
  });
127
+ }
91
128
 
129
+ function registerExportHandlers(state, devUrl) {
92
130
  handle(devUrl, 'dronepath:export:pick-output', async () => {
93
131
  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 = {
132
+ return pickSavePath(state, {
100
133
  title: 'Export video',
101
- defaultPath: outputPathFor(video, { ...state.config, outDir }),
134
+ defaultPath: exportDefaultFor(state, video),
102
135
  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 };
136
+ extensions: ['mp4'],
137
+ defaultExtension: 'mp4',
138
+ });
144
139
  });
145
-
146
140
  handle(devUrl, 'dronepath:export:start', (raw) => {
147
141
  const video = requireVideo(state);
148
142
  state.exportRunner.start(video, parseExportRequest(raw, state.config));
@@ -160,7 +154,40 @@ export function registerIpcHandlers(state, { devUrl, log, sendToWindow }) {
160
154
  const error = await shell.openPath(knownOutputOf(state, payload));
161
155
  return error ? { ok: false, error } : { ok: true };
162
156
  });
157
+ }
163
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) {
164
191
  handle(devUrl, 'dronepath:update:restart', () => {
165
192
  if (!state.updates) return { ok: false, error: 'this build does not self-update' };
166
193
  // No pendingClose here: the prompt never opens over a running export, and
@@ -170,9 +197,20 @@ export function registerIpcHandlers(state, { devUrl, log, sendToWindow }) {
170
197
  });
171
198
  });
172
199
  handle(devUrl, 'dronepath:update:state', () => ({ ready: state.updateReady }));
200
+ }
173
201
 
202
+ function registerWindowHandlers(state, devUrl) {
174
203
  handle(devUrl, 'dronepath:window:close', () => {
175
204
  // The window's close handler runs the running-export guard.
176
205
  if (state.win && !state.win.isDestroyed()) state.win.close();
177
206
  });
178
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
+ }
package/app/main.mjs CHANGED
@@ -24,9 +24,9 @@ import { createAppSession } from '../dist/appsession.js';
24
24
  import { resolveConfig } from '../dist/configfile.js';
25
25
  import { ERROR_PREFIX, errorMessage } from '../dist/errors.js';
26
26
  import { createExportRunner } from '../dist/exportjob.js';
27
- import { requireTools } from '../dist/ff.js';
28
- import { resolveFfTools } from '../dist/fftools.js';
29
- import { rangePlan } from '../dist/range.js';
27
+ import { requireFfmpegTools } from '../dist/ffmpeg.js';
28
+ import { resolveFfmpegTools } from '../dist/ffmpeg-tools.js';
29
+ import { planByteRange } from '../dist/range.js';
30
30
  import { createTileTraffic } from '../dist/tiles.js';
31
31
  import { registerIpcHandlers } from './ipc.mjs';
32
32
  import { initUpdates } from './update.mjs';
@@ -134,7 +134,7 @@ function handleExportDone(state, outcome) {
134
134
 
135
135
  function videoResponse(request, filePath) {
136
136
  const size = fs.statSync(filePath).size;
137
- const plan = rangePlan(request.headers.get('range') ?? undefined, size, 'video/mp4');
137
+ const plan = planByteRange(request.headers.get('range') ?? undefined, size, 'video/mp4');
138
138
  if (plan.status === 416) {
139
139
  return new Response(plan.body, { status: 416, headers: plan.headers });
140
140
  }
@@ -195,7 +195,7 @@ async function initServices(state) {
195
195
  const resolved = resolveConfig({});
196
196
  state.appState = readAppState(appStateFile());
197
197
  state.config = applyAppState(resolved.config, state.appState);
198
- await requireTools(resolveFfTools(state.config));
198
+ await requireFfmpegTools(resolveFfmpegTools(state.config));
199
199
  // One polite tile queue for the whole app: on-demand tiles and the export
200
200
  // prefetch share its request budget, and on-demand tiles the player needs
201
201
  // right now jump the queue.
@@ -297,7 +297,7 @@ function installCloseGuard(state) {
297
297
  defaultId: 1,
298
298
  cancelId: 1,
299
299
  message: 'An export is in progress',
300
- detail: 'Closing the window stops the export and removes its working file.',
300
+ detail: 'Closing the window stops the export and removes its unfinished file.',
301
301
  };
302
302
  void (state.win ? dialog.showMessageBox(state.win, box) : dialog.showMessageBox(box)).then(
303
303
  ({ response }) => {
@@ -2,19 +2,20 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { z } from 'zod';
4
4
  import { TILE_BASE, mediaUrlFor } from './apppaths.js';
5
- import { parseFrameRange, parseLookSettings, parseValue, resolveRange, strictShape, } from './config.js';
6
- import { errorMessage } from './errors.js';
5
+ import { parseFrameRange, parseAppearanceSettings, parseValue, strictShape, } from './config.js';
6
+ import { ERR_NO_RECORDING, ERR_NOT_READABLE_MP4, errorMessage } from './errors.js';
7
7
  import { timeAt } from './frametime.js';
8
- import { isRecordingName } from './inputs.js';
9
- import { buildSceneData } from './page.js';
10
- import { prepareSession, recordingPageOpts, telemetryExportInput, } from './run.js';
11
- import { writeTelemetryDocument } from './telemetry-json.js';
8
+ import { isRecordingName } from './recordings.js';
9
+ import { buildSceneData } from './render-page.js';
10
+ import { prepareSession, recordingPageOpts, telemetryExportInput, trackExportStream, } from './pipeline.js';
11
+ import { trackFormatOf } from './track-format.js';
12
+ import { writeTrackFile } from './track-write.js';
12
13
  export function frameExactDuration(probe) {
13
14
  return timeAt(probe.frames, probe.fps.value);
14
15
  }
15
16
  export function parsePickRequest(raw) {
16
17
  const input = typeof raw === 'object' && raw !== null ? raw : {};
17
- return { settings: parseLookSettings(input.settings) };
18
+ return { settings: parseAppearanceSettings(input.settings) };
18
19
  }
19
20
  const TELEMETRY_SAVE_SHAPE = {
20
21
  outPath: z.unknown().optional(),
@@ -28,8 +29,11 @@ export function parseTelemetrySaveRequest(raw) {
28
29
  const outPath = parseValue(z
29
30
  .string({ error: () => 'invalid telemetry save request: outPath' })
30
31
  .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}`);
32
+ try {
33
+ trackFormatOf(outPath);
34
+ }
35
+ catch (e) {
36
+ throw new Error(`invalid telemetry save request: outPath must be a .gpx, .geojson, .kml, .kmz or .json file: ${outPath}`, { cause: e });
33
37
  }
34
38
  const range = request.range === undefined || request.range === null
35
39
  ? null
@@ -56,6 +60,7 @@ export const prepareUiSession = async (videoPath, config, log, onProgress, deps)
56
60
  durationSec: frameExactDuration(prep.probe),
57
61
  },
58
62
  telemetry: telemetryExportInput(prep),
63
+ track: trackExportStream(prep),
59
64
  };
60
65
  };
61
66
  function isReadableVideo(filePath) {
@@ -68,18 +73,6 @@ function isReadableVideo(filePath) {
68
73
  return false;
69
74
  }
70
75
  }
71
- function segmentTelemetryInput(input, range) {
72
- const segment = resolveRange(range, input.frameCount);
73
- if (!segment)
74
- return input;
75
- return {
76
- ...input,
77
- frameCount: segment.end - segment.start + 1,
78
- frames: input.frames.slice(segment.start, segment.end + 1),
79
- headingDeg: input.headingDeg.slice(segment.start, segment.end + 1),
80
- frameStart: segment.start,
81
- };
82
- }
83
76
  export function createAppSession(options) {
84
77
  const { config, pickFile } = options;
85
78
  const prepare = options.prepare ?? prepareUiSession;
@@ -101,7 +94,7 @@ export function createAppSession(options) {
101
94
  const resolved = path.resolve(picked);
102
95
  if (!isReadableVideo(resolved)) {
103
96
  log(`rejected: ${resolved}`);
104
- return { ok: false, error: `not a readable .mp4 file: ${resolved}` };
97
+ return { ok: false, error: `${ERR_NOT_READABLE_MP4}${resolved}` };
105
98
  }
106
99
  onPreparing(resolved);
107
100
  prepared = await prepare(resolved, { ...config, ...request.settings }, log, onPrepareProgress);
@@ -121,8 +114,8 @@ export function createAppSession(options) {
121
114
  videoPath: () => videoPath,
122
115
  saveTelemetryJson(file, range) {
123
116
  if (!prepared)
124
- throw new Error('no recording loaded');
125
- writeTelemetryDocument(file, segmentTelemetryInput(prepared.telemetry, range));
117
+ throw new Error(ERR_NO_RECORDING);
118
+ writeTrackFile(file, { document: prepared.telemetry, track: prepared.track }, range);
126
119
  },
127
120
  };
128
121
  }
package/dist/appstate.js CHANGED
@@ -2,6 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { z } from 'zod';
4
4
  import { DEFAULT_CONFIG, SETTINGS_KEYS, formatHud, parseSettingsPatch, parseValue, strictShape, } from './config.js';
5
+ import { errorMessage } from './errors.js';
5
6
  export const APP_STATE_VERSION = 1;
6
7
  export function emptyAppState() {
7
8
  return { settings: null, lastOpenDir: null };
@@ -86,7 +87,7 @@ export function writeAppState(file, state) {
86
87
  fs.writeFileSync(file, serializeAppState(state));
87
88
  }
88
89
  catch (e) {
89
- throw new Error(`cannot write app state ${file}: ${e.message}`, {
90
+ throw new Error(`cannot write app state ${file}: ${errorMessage(e)}`, {
90
91
  cause: e,
91
92
  });
92
93
  }
package/dist/buildinfo.js CHANGED
@@ -1,10 +1,9 @@
1
- import { execFile } from 'node:child_process';
2
1
  import fs from 'node:fs';
3
2
  import path from 'node:path';
4
3
  import { fileURLToPath } from 'node:url';
5
- import { promisify } from 'node:util';
4
+ import { runToolMain } from './errors.js';
5
+ import { runTool } from './exec-tool.js';
6
6
  import { VERSION } from './version.js';
7
- const execFileAsync = promisify(execFile);
8
7
  export function defaultBuildinfoPaths(root) {
9
8
  return {
10
9
  moduleFile: path.join(root, 'ui', 'lib', 'buildinfo', 'generated', 'buildinfo.ts'),
@@ -33,14 +32,14 @@ export function buildBuildinfo(paths, version, probe) {
33
32
  }
34
33
  async function tryGit(args) {
35
34
  try {
36
- const { stdout } = await execFileAsync('git', [...args]);
35
+ const { stdout } = await runTool('git', [...args]);
37
36
  return stdout;
38
37
  }
39
38
  catch {
40
39
  return null;
41
40
  }
42
41
  }
43
- export async function probeGit() {
42
+ async function probeGit() {
44
43
  const head = await tryGit(['rev-parse', 'HEAD']);
45
44
  if (head === null)
46
45
  return null;
@@ -55,17 +54,11 @@ export async function probeGit() {
55
54
  };
56
55
  }
57
56
  async function main() {
58
- try {
59
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
60
- const git = buildBuildinfo(defaultBuildinfoPaths(root), VERSION, await probeGit());
61
- const detail = git === null ? 'no git' : git.tagged ? 'tagged' : `commit ${git.commit}`;
62
- process.stderr.write(`[drone-path] buildinfo: ${VERSION} (${detail})\n`);
63
- }
64
- catch (e) {
65
- process.stderr.write(`[drone-path] ERROR: ${e.message}\n`);
66
- process.exitCode = 1;
67
- }
57
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
58
+ const git = buildBuildinfo(defaultBuildinfoPaths(root), VERSION, await probeGit());
59
+ const detail = git === null ? 'no git' : git.tagged ? 'tagged' : `commit ${git.commit}`;
60
+ process.stderr.write(`[drone-path] buildinfo: ${VERSION} (${detail})\n`);
68
61
  }
69
62
  if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
70
- void main();
63
+ void runToolMain(main);
71
64
  }