drone-path 0.13.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +20 -74
  2. package/THIRD-PARTY-NOTICES.md +3 -82
  3. package/bin/drone-path.mjs +0 -0
  4. package/dist/archive-cli.d.ts +1 -0
  5. package/dist/archive-cli.js +50 -0
  6. package/dist/archive-query-cli.d.ts +3 -0
  7. package/dist/archive-query-cli.js +128 -0
  8. package/dist/cli.d.ts +14 -0
  9. package/dist/cli.js +19 -12
  10. package/dist/version.d.ts +1 -0
  11. package/package.json +22 -68
  12. package/CHANGELOG.md +0 -349
  13. package/app/ipc.d.mts +0 -44
  14. package/app/ipc.mjs +0 -237
  15. package/app/main.mjs +0 -369
  16. package/app/preload.cjs +0 -36
  17. package/app/update-policy.d.mts +0 -6
  18. package/app/update-policy.mjs +0 -6
  19. package/app/update.d.mts +0 -10
  20. package/app/update.mjs +0 -54
  21. package/dist/appassets.js +0 -35
  22. package/dist/apppaths.js +0 -20
  23. package/dist/appsession.js +0 -121
  24. package/dist/appstate.js +0 -101
  25. package/dist/assets.js +0 -60
  26. package/dist/buildinfo.js +0 -64
  27. package/dist/cammeta-decode.js +0 -237
  28. package/dist/cammeta.js +0 -92
  29. package/dist/changeset-gate.js +0 -39
  30. package/dist/config.js +0 -631
  31. package/dist/configfile.js +0 -86
  32. package/dist/decimate.js +0 -84
  33. package/dist/desktop-i18n/generated/catalogs.js +0 -1230
  34. package/dist/desktop-i18n/messages.js +0 -47
  35. package/dist/errors.js +0 -34
  36. package/dist/exec-tool.js +0 -13
  37. package/dist/exportjob.js +0 -90
  38. package/dist/ffmpeg-tools.js +0 -56
  39. package/dist/ffmpeg.js +0 -98
  40. package/dist/frametime.js +0 -32
  41. package/dist/geo.js +0 -60
  42. package/dist/logging.js +0 -1
  43. package/dist/manual/anchors.js +0 -17
  44. package/dist/manual/build.js +0 -67
  45. package/dist/manual/cliref.js +0 -34
  46. package/dist/manual/links.js +0 -59
  47. package/dist/manual/markdown.js +0 -98
  48. package/dist/manual/model.js +0 -1
  49. package/dist/manual/module.js +0 -5
  50. package/dist/manual/nav.js +0 -11
  51. package/dist/manual/reference.js +0 -18
  52. package/dist/paths.js +0 -16
  53. package/dist/pipeline.js +0 -402
  54. package/dist/plan.js +0 -106
  55. package/dist/png.js +0 -32
  56. package/dist/protobuf-wire.js +0 -102
  57. package/dist/range.js +0 -50
  58. package/dist/recordings.js +0 -55
  59. package/dist/render-page.js +0 -85
  60. package/dist/render.js +0 -268
  61. package/dist/renderer/boot.js +0 -7
  62. package/dist/renderer/dom.js +0 -179
  63. package/dist/renderer/framemath.js +0 -30
  64. package/dist/renderer/scene.js +0 -388
  65. package/dist/renderer/theme.js +0 -82
  66. package/dist/renderer/tilesources.js +0 -38
  67. package/dist/renderer/trail.js +0 -42
  68. package/dist/restyle.js +0 -16
  69. package/dist/serve.js +0 -27
  70. package/dist/srt.js +0 -98
  71. package/dist/telemetry-json-schema.js +0 -18
  72. package/dist/telemetry-json.js +0 -126
  73. package/dist/telemetry-math.js +0 -267
  74. package/dist/telemetry-summary.js +0 -19
  75. package/dist/telemetry.js +0 -95
  76. package/dist/tilecache.js +0 -21
  77. package/dist/tiles.js +0 -155
  78. package/dist/track-format.js +0 -13
  79. package/dist/track-geojson.js +0 -44
  80. package/dist/track-gpx.js +0 -34
  81. package/dist/track-kml.js +0 -47
  82. package/dist/track-kmz.js +0 -68
  83. package/dist/track-write.js +0 -41
  84. package/dist/track.js +0 -79
package/CHANGELOG.md DELETED
@@ -1,349 +0,0 @@
1
- # drone-path
2
-
3
- ## 0.13.0
4
-
5
- - **New:** Choose English, German, Spanish, French or Japanese in desktop
6
- Settings. The app follows the operating system language by default and
7
- remembers a manually selected language between launches.
8
- - **New:** Export dialogs place actions at the bottom and show progress
9
- while restarting or exporting telemetry. Canceled open notices can be
10
- dismissed, and map controls, export settings and menu items use more
11
- consistent names.
12
- - **New:** Workspace headings and Map appearance labels are more consistent.
13
- Video and filmstrip thumbnails show loading text, and zoom limit messages
14
- appear beside the zoom controls.
15
-
16
- ## 0.12.1
17
-
18
- - **Fixed:** The Export video dialog handles every outcome cleanly: a
19
- failed or canceled run returns to the form with the outcome sentence
20
- as a notice, so retry stays one click away, and a canceled run always
21
- reads "Export canceled; its unfinished file was removed." The export
22
- summary now reports the media duration (frames at the frame rate)
23
- instead of the encode wall time, which read as a wrong duration
24
- between the media specs.
25
- - **Fixed:** Exported frames carry the heading pill: the HDG readout
26
- joins ALT and SPD in the top-left HUD column, toggled by the heading
27
- readout setting, exactly as the Map appearance preview shows it. The
28
- preview pills use the export's placement and stacking, and on-video
29
- pills read HDG/ALT/SPD.
30
- - **Fixed:** Selected controls keep their accent selection marker while
31
- hovered: HUD chips, map style tiles, trail swatches and structure bar
32
- segments no longer read unselected under the cursor. Disabled HUD
33
- chips dim to the disabled look instead of the "off" look, and select
34
- and text fields lighten their border on hover like number fields.
35
- - **Fixed:** A failed "Reveal in folder" in the Export telemetry dialog
36
- no longer leaves its error notice behind after a successful retry;
37
- every reveal attempt clears the previous error first.
38
- - **Fixed:** The PiP overlay's map strip shows the zoom level and
39
- announces refused zoom steps, so the `+` and `-` hotkeys give
40
- feedback in every layout instead of silently re-pinning the zoom.
41
-
42
- ## 0.12.0
43
-
44
- - **New:** The flight map zooms in and out with a small `−`/`+` pill
45
- below the map (split view) and the `+` / `-` keys: every step pins the
46
- level as the fixed "Zoom" setting, so the export renders exactly the
47
- zoom the preview shows. Zooming clamps at the map's usable levels with
48
- the matching button disabling at either end, and opening a recording
49
- resets Zoom to auto-fit.
50
- - **New:** The map card's Speed, Altitude and Zoom readouts now sit in
51
- one compact strip below the map — labeled columns with a bare `−`
52
- level `+` stepper instead of separate chip pills and a zoom row — and
53
- the map reclaims the freed height. A turned-off HUD chip keeps its
54
- column and shows a dimmed `--`.
55
- - **New:** Map appearance is now a modal dialog with a live preview of
56
- the export frame — the loaded recording or a bundled example flight —
57
- and grouped settings: map style as thumbnail tiles, a trail color
58
- swatch row with an explicit Style default, an Auto-fit zoom toggle
59
- with a zoom level slider and Frame padding, clickable HUD chips, and
60
- an opening & ending strip. The entry moved from File to View, and the
61
- player shortcuts pause while the dialog is open.
62
-
63
- ## 0.11.1
64
-
65
- - **Fixed:** Video export in the packaged desktop app ("Export video…")
66
- works again: the app now bundles the renderer's `playwright-core` and
67
- renders with the system browser (Google Chrome or Microsoft Edge), the
68
- same as the CLI.
69
-
70
- ## 0.11.0
71
-
72
- - **New:** Flight track files: `--track-out <file>` writes the decoded
73
- flight track in the format the file extension picks — GPX (`.gpx`),
74
- GeoJSON (`.geojson`), KML/KMZ (`.kml`/`.kmz`) — or the existing
75
- telemetry JSON document (`.json`, unchanged bytes). Vertices sit at
76
- decoded GPS fixes with telemetry gaps breaking the line, altitude is
77
- the absolute/GPS altitude in meters above mean sea level, and times
78
- appear only where a recording carries trustworthy UTC — none does
79
- today (the CAM-meta device timestamp counts since power-up), so KML
80
- exports plain line segments instead of a timed flythrough. The
81
- desktop **Export telemetry…** dialog offers the same five formats and
82
- honors the In–Out range; for the same recording and range the app and
83
- the CLI write byte-identical files. `--telemetry-json <file>` is a
84
- deprecated alias of `--track-out <file>.json` — same output, warns on
85
- use, removed in a future version — and mixing the two spellings in
86
- one run is an error. A frame range of a single frame is now valid
87
- everywhere ranges are accepted.
88
- - **New:** The timeline shows a lone in or out point as a half-open
89
- In–Out segment — the in point runs to the end of the recording, the
90
- out point from its start — and the readout names the same passage.
91
- Playback wrap and both exports honor a lone point, setting a point
92
- past the other replaces it, and the readout announces point changes
93
- to screen readers.
94
- - **New:** The app's copy is unified and the dialogs are polished: the
95
- marked range is the In–Out segment with "Set in point" / "Set out
96
- point" controls and an `in 0:12 · out 0:34` readout, the export flow
97
- says "export" throughout with codec and encode-speed labels, every
98
- failure reads as a sentence with a next step (raw text under
99
- "Technical details"), and a failed update restart is reported. Each
100
- dialog dismisses through its header ✕ alone, the export-done dialog
101
- leads with "Export finished." and one accent primary (**Reveal in
102
- folder**), output paths wrap with a full-path tooltip, and export and
103
- telemetry phase text is announced in a live region and keeps keyboard
104
- focus through phase changes.
105
- - **New:** Accessibility hardening for the menu bar and dialogs: AltGr
106
- characters type normally in every field, Left/Right move between the
107
- menu labels with disabled rows announcing themselves, Tab stays
108
- inside dialogs and the Help overlay, and the timeline scrubber
109
- announces times instead of raw frame numbers.
110
- - **New:** The transport and loop controls are compact and stable: the
111
- Play/Pause button is icon-only with a tooltip and accessible name,
112
- the in/out-point buttons form one group beside a fixed readout slot,
113
- and toggling playback or marking points no longer shifts neighboring
114
- controls. The ALT/SPD readouts sit in a strip along the map card's
115
- bottom edge, the Map appearance popover docks left of the map card
116
- and opens from **File → Map appearance…**, the empty workspace drops
117
- its tooling hint and status footer, the header hides the duration
118
- until a recording loads, and the map card shows "Preparing map…"
119
- while its tiles load.
120
- - **Internal:** Code consolidation and dead-export cleanup from a
121
- refactoring pass; no behavior changes.
122
-
123
- ## 0.10.0
124
-
125
- - **New:** Telemetry now comes from the embedded CAM meta (DVTM) stream
126
- whenever a recording has one; the `.SRT` sidecar is only used when no
127
- CAM meta stream is present. A CAM meta stream without GPS positions
128
- fails the run with a clear error instead of silently falling back to
129
- the sidecar.
130
- - **New:** The opt-in OpenTelemetry trace export is removed along with
131
- its `OTEL_*` environment variables. Stage logs, progress reporting
132
- and rendered output are unchanged.
133
-
134
- ## 0.9.0
135
-
136
- - **New:** The flight trail is now configurable: `--trail-color <hex>`
137
- (RGB or RGBA hex like `#e63946` or `#e63946cc`, `#` optional) and the
138
- `trailColor` setting recolor the flight trail, the drone marker and
139
- the HUD accents. Glow and casing are derived from the chosen color,
140
- so the layered trail stays readable on both map styles; omitting the
141
- option keeps the per-style theme defaults.
142
- - **New:** `--telemetry-json <file>` exports per-frame telemetry —
143
- time, position, altitude, body and gimbal attitude, heading and
144
- camera exposure — as one versioned JSON document with a record per
145
- source frame; the schema is checked in as
146
- `docs/telemetry-json.schema.json`. The desktop workspace writes the
147
- same document through Export telemetry…, straight from the loaded
148
- recording (the In–Out segment or the full recording) and
149
- byte-identical to the CLI output.
150
- - **New:** The desktop workspace has a top menu bar with the workspace
151
- actions moved into it: **File** holds Open… (Ctrl+O), Export video…,
152
- Export telemetry…, Settings and Exit, **View** holds Swap (S), and
153
- right-aligned **Help** holds Documentation and About. It follows
154
- Windows menu conventions (click or Alt opens, hover switches, arrows
155
- navigate, Enter/Space activate, Esc closes, Alt+F/V/H mnemonics) with
156
- the accent-forward menu state styling. "Export…" is now "Export
157
- video…" on every surface, the header and status footer keep only
158
- their informational content, the auto-hidden native Electron menu is
159
- gone, and Exit still guards against closing during a running export.
160
- - **New:** **Help → About** shows the drone / path lockup, the running
161
- build's version — `MAJOR.MINOR.PATCH` for releases,
162
- `MAJOR.MINOR.PATCH+<short commit>` for every other build, injected at
163
- build time — an MIT license line, and a link that opens the
164
- `MrManny/drone-path` repository in the default browser.
165
-
166
- ## 0.8.1
167
-
168
- - **Fixed:** The GitHub repository moved to `MrManny/drone-path`:
169
- `npx github:` commands, links and the desktop app's update feed point
170
- at the new home, and old URLs redirect.
171
- - **Internal:** Routine dependency updates.
172
-
173
- ## 0.8.0
174
-
175
- - **New:** The tool is now called **Drone Path**. The rename is a clean
176
- break with no compatibility aliases — on upgrade, use the `drone-path`
177
- command (previously `neo2-flightpath`), move the config file to
178
- `.dronepath.json` (from `.neo2flightpath.json`), and rename the tile-cache
179
- environment variable to `DRONEPATH_TILE_CACHE` (from
180
- `NEO2_FLIGHTPATH_TILE_CACHE`). The per-user data directory moves to
181
- `drone-path`, leaving the old one behind.
182
- - **New:** The desktop app ships as "Drone Path" under a new app identity.
183
- Installed apps do not auto-update in place — uninstall the old version
184
- and install the new one.
185
-
186
- ## 0.7.0
187
-
188
- - **New:** The desktop player is now a synchronized video-and-map review
189
- workspace: dedicated footage and flight-map panes with a swappable overlay
190
- layout, a bare map sidebar with a map appearance popover, and a timeline of
191
- square preview stills spread from the first frame to the last with a
192
- draggable loop band and icon-only loop controls. The transport controls sit
193
- centered under the footage.
194
- - **New:** The app opens straight into the review workspace — the landing
195
- screen is gone and no tile warm-up stands between the user and the footage.
196
- Before a recording is loaded the workspace shows its disabled controls with
197
- an accent **Open…** call to action in the footage pane, a quiet "No
198
- telemetry yet" map pane and a "No recording loaded" status bar. A picked
199
- recording loads right into the player, with map tiles streaming on demand
200
- (rendering and exporting still prefetch their tiles beforehand).
201
- - **New:** The export dialog is wider and shows a map-only output preview at
202
- the export's exact size, with range, output-size and encoding choices
203
- clearly separated and the familiar destination, progress, cancel, done and
204
- error states beside the preview.
205
- - **New:** New color scheme: dark neutral surfaces with a warm coral accent,
206
- sand loop state and warmer semantic tones, plus one shared accent-colored
207
- flight trail in the map island and in rendered frames.
208
- - **New:** The app icon is the final branded artwork: a circular drone badge
209
- rasterized to a metadata-free 512x512 master and re-derived for every
210
- platform format (Windows ICO, Linux icon set).
211
- - **Fixed:** Loading a second recording now switches the footage and the
212
- filmstrip to the new recording instead of replaying the previous one's bytes
213
- from a URL-keyed cache.
214
-
215
- ## 0.6.1
216
-
217
- - **Fixed:** Maintenance release with updated dependencies that contain
218
- security fixes.
219
-
220
- ## 0.6.0
221
-
222
- - **New:** Renders and exports no longer need a local ffmpeg install:
223
- static ffmpeg and ffprobe 7.1.0 binaries ship with the desktop app and
224
- the npm package. `--ffmpeg <path>` and `--ffprobe <path>` override
225
- them, PATH remains a fallback, and installing downloads both tools in
226
- a postinstall step (~250 MB).
227
- - **New:** The export dialog and the CLI now configure the encoder:
228
- video codec (H.264 or H.265), quality (near-lossless down to low) and
229
- encoding speed. The defaults reproduce the previous output exactly.
230
- - **New:** The export dialog opens on the In–Out segment when a loop is
231
- set and keeps the output size for the session.
232
- - **Fixed:** Dialogs now manage keyboard focus: opening a dialog moves
233
- focus onto it, closing hands it back to the control that opened it.
234
-
235
- ## 0.5.0
236
-
237
- - **New:** The player opens as soon as the map tiles around the drone at
238
- the first frame are warm; the remaining tiles the map can show keep
239
- loading into the cache behind a small "Warming tiles…" hint, and
240
- changing the map style, zoom or view moves the loading onto the new
241
- plan.
242
- - **New:** The settings panel's look — map style, view, zoom, intro/outro
243
- and HUD chips — is remembered between launches, and the Open dialog
244
- starts in the folder the last recording was opened from. A fresh
245
- install, or a state file the app cannot read, starts at the documented
246
- defaults.
247
- - **New:** Help now opens a full offline user manual inside the app —
248
- how playback, settings and export fit together, keyboard shortcuts and
249
- a CLI/config reference — from the landing card and the control bar.
250
- - **Fixed:** All tile downloads share one polite queue, so the combined
251
- request rate stays inside the 2-per-second tile budget even when
252
- several loading lanes run at once.
253
- - **Fixed:** Tile cache write failures (a full disk, an unwritable
254
- cache, a cache path that is not a directory) now fail the affected
255
- tile with an error naming the cache instead of silently degrading to a
256
- placeholder.
257
-
258
- ## 0.4.0
259
-
260
- - **New:** The desktop app now updates itself from GitHub Releases:
261
- packaged builds download a newer version in the background and ask
262
- once whether to restart into it. Windows releases gain a self-updating
263
- NSIS installer next to the portable exe (which never self-updates).
264
- - **Fixed:** Escape now closes the Settings and Export dialogs even
265
- while a select field is focused: the first Escape is still reserved
266
- for the select's own dropdown, and the second one closes the dialog.
267
- - **Fixed:** The export dialog's Width and Height fields now show
268
- exactly what the export renders: typing an odd size and leaving the
269
- field commits the even size (rounded down, at least 64 px), so the
270
- fields, the export and the done summary always agree.
271
- - **Fixed:** The preparation progress bar no longer shrinks mid-load:
272
- its percent now grows monotonically to 100 across probing, telemetry,
273
- view planning and the tile pre-warm.
274
- - **Fixed:** The map trail now grows with playback and ends at the
275
- drone: the flown path is drawn up to the current frame's position
276
- instead of stalling on the decimated points, so the trail appears and
277
- grows on every recording (including hovering and straight flights) in
278
- the app and exported overlays alike.
279
- - **Internal:** The test tree is type-checked before the unit tests
280
- run, and the OpenTelemetry packages are up to date.
281
-
282
- ## 0.3.0
283
-
284
- - **New:** The desktop app — pick a recording and watch its flight path on a
285
- map in sync with the footage, one shared timeline scrubber and a swappable
286
- picture-in-picture layout. It ships as a Windows portable executable and a
287
- Linux AppImage, with its own application icon and the window title
288
- "Neo2 Flightpath".
289
- - **New:** Export the look you see: a modal renders the preview as a video,
290
- the full recording or the In–Out loop segment at a chosen size, written
291
- through a native save dialog. Exports run as one cancelable job and are
292
- verified before they replace the chosen file, so a failed or canceled
293
- export never touches an existing file; "Reveal in folder" and "Open video"
294
- act on the exported file, and a refused cancel explains itself.
295
- - **New:** Playback and review: speed 1x–4x, a loop region with I/O points
296
- that auto-engage and wrap on repeat (Esc or Clear to remove), and keyboard
297
- shortcuts for play/pause, speed, frame stepping, one-second jumps and
298
- swapping the views. Seeking is frame-exact: End reaches the last frame and
299
- every step lands exactly where requested.
300
- - **New:** A settings panel (cog button): map style, view, zoom/zoom-out,
301
- intro/outro seconds and HUD chips mirror the CLI options and restyle the
302
- preview instantly, fetching any missing map tiles on demand. The alt chip
303
- hides itself when the telemetry has no altitude.
304
- - **New:** Preparation progress on the landing card: a bar that advances one
305
- step per preparation stage and per warmed map tile, and the status notice
306
- names the running stage.
307
- - **New:** Errors and progress read as plain sentences with the original
308
- system text under "Technical details", and the control bar fits the
309
- 1024×600 minimum window.
310
- - **New:** The map trail is drawn with one incremental update in the app and
311
- the CLI alike; the `--trail` option is removed — drop the `trail` key from
312
- config files.
313
- - **Fixed:** One rule now counts GPS fixes in every telemetry source: exactly
314
- (0, 0) is the no-lock placeholder, so near-equator and near-prime-meridian
315
- coordinates count as fixes again, and fix counts agree between the SRT
316
- sidecar and camera metadata. Frames after the last GPS fix hold that fix
317
- instead of jumping back to the flight's start.
318
- - **Fixed:** ffmpeg/ffprobe failures surface their real cause instead of a
319
- false "no telemetry found", mistyped numbers in config files fail fast
320
- naming the option instead of being silently coerced, and odd canvas
321
- dimensions normalize to even.
322
- - **Fixed:** On Windows, output names differing only in case are one file —
323
- collision suffixing and the overwrite guard agree on it (on Linux and macOS
324
- they stay two distinct names).
325
- - **Internal:** The app and the headless CLI share one map renderer, and CLI
326
- output stays frame-exact. Option defaults live in one table, the
327
- `--out-dir` default is documented as the `out` folder, CLI help names the
328
- offending flag, and the agent helpers move project statuses past the first
329
- result page.
330
-
331
- ## 0.2.0
332
-
333
- - **New:** See where render time goes — opt-in OpenTelemetry traces for the
334
- render pipeline via `OTEL_EXPORTER_OTLP_ENDPOINT` (OTLP/HTTP protobuf);
335
- nothing is loaded or sent without it.
336
- - **Internal:** Release notes are now curated for users; Dependabot keeps
337
- `@types/node` on the Node 24 line.
338
-
339
- ## 0.1.1
340
-
341
- - **Internal:** Code base restructuring and README improvements.
342
-
343
- ## 0.1.0
344
-
345
- - **New:** First release — flight-path map overlay videos from DJI drone
346
- recordings at exactly the source frame rate and frame count, with telemetry
347
- from the `.SRT` sidecar or the embedded CAM-meta (DVTM) stream; `satellite`
348
- and `topo` map styles, batch processing, config file support, `--json`
349
- summaries and `out` as the default output directory.
package/app/ipc.d.mts DELETED
@@ -1,44 +0,0 @@
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
- systemLanguages: readonly string[];
16
- win: IpcWindow | null;
17
- exportRunner: {
18
- start(videoPath: string, request: ExportRequest): void;
19
- cancel(): void;
20
- };
21
- updates: UpdateController | null;
22
- updateReady: boolean;
23
- lastExportOut: string | null;
24
- lastTrackOut: string | null;
25
- }
26
-
27
- export interface IpcHandlersOptions {
28
- devUrl: string | null;
29
- log: (message: string) => void;
30
- sendToWindow(state: IpcState, channel: string, payload: unknown): void;
31
- }
32
-
33
- export function registerIpcHandlers(state: IpcState, options: IpcHandlersOptions): void;
34
-
35
- /**
36
- * Resolves the final save path: the typed name stands as typed when it already
37
- * ends in one of the accepted extensions (any case); otherwise the default
38
- * extension is appended to it.
39
- */
40
- export function resolveSavePath(
41
- typedPath: string,
42
- extensions: readonly string[],
43
- defaultExtension: string,
44
- ): string;
package/app/ipc.mjs DELETED
@@ -1,237 +0,0 @@
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, parseTrackSaveRequest } 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 { isLocale, resolveLocale, translator } from '../dist/desktop-i18n/messages.js';
14
- import { ERR_NO_RECORDING, errorMessage } from '../dist/errors.js';
15
- import { videoBaseName } from '../dist/recordings.js';
16
- import { outputPathFor } from '../dist/pipeline.js';
17
- import { TRACK_FORMAT_VALUES } from '../dist/track-format.js';
18
-
19
- // Only this app's window may drive the session state machine.
20
- function assertTrusted(event, devUrl) {
21
- const url = (event.senderFrame && event.senderFrame.url) || '';
22
- const devOk = devUrl !== null && url.startsWith(devUrl);
23
- if (!url.startsWith(APP_ORIGIN + '/') && !devOk) {
24
- throw new Error('untrusted ipc sender');
25
- }
26
- }
27
-
28
- function handle(devUrl, channel, fn) {
29
- ipcMain.handle(channel, async (event, ...args) => {
30
- // Outside the envelope: an untrusted sender must see a rejected promise,
31
- // never a well-formed reply.
32
- assertTrusted(event, devUrl);
33
- try {
34
- return await fn(...args);
35
- } catch (e) {
36
- return { ok: false, error: errorMessage(e) };
37
- }
38
- });
39
- }
40
-
41
- function requireVideo(state) {
42
- const video = state.session ? state.session.videoPath() : null;
43
- if (!video) throw new Error(ERR_NO_RECORDING);
44
- return video;
45
- }
46
-
47
- // The reveal/open guard: the renderer may only name a file this shell wrote
48
- // (the last export or the last track file, both set only by trusted
49
- // handlers), never an arbitrary path.
50
- function knownOutputOf(state, payload) {
51
- const out = payload && typeof payload === 'object' ? payload.out : null;
52
- if (typeof out !== 'string' || (out !== state.lastExportOut && out !== state.lastTrackOut)) {
53
- throw new Error('unknown output');
54
- }
55
- return out;
56
- }
57
-
58
- // The native dialog confirmed the name as typed, but the extension may have
59
- // been appended after it: re-check the final path on every platform so an
60
- // existing file is never replaced without a confirmation.
61
- async function confirmReplace(state, chosen) {
62
- if (!fs.existsSync(chosen)) return true;
63
- const t = translator(languageSettings(state).locale);
64
- const box = {
65
- type: 'warning',
66
- buttons: [t('native.replace'), t('native.cancel')],
67
- defaultId: 1,
68
- cancelId: 1,
69
- message: t('native.replaceFile', { name: path.basename(chosen) }),
70
- detail: chosen,
71
- };
72
- const confirm = state.win
73
- ? await dialog.showMessageBox(state.win, box)
74
- : await dialog.showMessageBox(box);
75
- return confirm.response === 0;
76
- }
77
-
78
- // The CLI's default naming, with a relative out dir anchored at the
79
- // recording: the app process has no meaningful working directory.
80
- function exportDefaultFor(state, video) {
81
- const outDir = state.config.outDir
82
- ? path.resolve(path.dirname(video), state.config.outDir)
83
- : null;
84
- return outputPathFor(video, { ...state.config, outDir });
85
- }
86
-
87
- // Pure name rule for save dialogs: the typed name stands as typed when it
88
- // already ends in one of the accepted extensions (any case); otherwise the
89
- // default extension is appended to it as typed, so "notes.csv" becomes
90
- // "notes.csv.json". The dialogs that report the result show this final name,
91
- // so the append is never silent.
92
- export function resolveSavePath(typedPath, extensions, defaultExtension) {
93
- const lower = typedPath.toLowerCase();
94
- return extensions.some((extension) => lower.endsWith(`.${extension}`))
95
- ? typedPath
96
- : `${typedPath}.${defaultExtension}`;
97
- }
98
-
99
- async function pickSavePath(state, { title, defaultPath, filters, extensions, defaultExtension }) {
100
- const options = { title, defaultPath, filters };
101
- const result = state.win
102
- ? await dialog.showSaveDialog(state.win, options)
103
- : await dialog.showSaveDialog(options);
104
- if (result.canceled || !result.filePath) return { ok: false, canceled: true };
105
- const chosen = resolveSavePath(result.filePath, extensions, defaultExtension);
106
- if (!(await confirmReplace(state, chosen))) return { ok: false, canceled: true };
107
- return { ok: true, path: chosen };
108
- }
109
-
110
- function registerSessionHandlers(state, devUrl) {
111
- handle(devUrl, 'dronepath:pick', (raw) => state.session.pick(parsePickRequest(raw)));
112
- handle(devUrl, 'dronepath:session', () => state.session.getSession());
113
- }
114
-
115
- function registerSettingsHandlers(state, devUrl, log) {
116
- handle(devUrl, 'dronepath:settings', () => state.config);
117
- handle(devUrl, 'dronepath:settings:save', (raw) => {
118
- const settings = parseSettingsPatch(raw, 'settings');
119
- state.appState = { ...state.appState, settings };
120
- state.config = applyAppState(state.config, state.appState);
121
- try {
122
- writeAppState(appStateFile(), state.appState);
123
- } catch (e) {
124
- // The look still applies when the state file cannot be written.
125
- log(`app state not saved: ${errorMessage(e)}`);
126
- }
127
- return { ok: true };
128
- });
129
- }
130
-
131
- function languageSettings(state) {
132
- const preference = isLocale(state.appState.language) ? state.appState.language : null;
133
- return { preference, locale: resolveLocale(preference, state.systemLanguages) };
134
- }
135
-
136
- function registerLanguageHandlers(state, devUrl) {
137
- handle(devUrl, 'dronepath:language', () => languageSettings(state));
138
- handle(devUrl, 'dronepath:language:save', (preference) => {
139
- if (preference !== null && !isLocale(preference)) throw new Error('invalid app language');
140
- const appState = { ...state.appState, language: preference };
141
- writeAppState(appStateFile(), appState);
142
- state.appState = appState;
143
- return { ok: true, ...languageSettings(state) };
144
- });
145
- }
146
-
147
- function registerExportHandlers(state, devUrl) {
148
- handle(devUrl, 'dronepath:export:pick-output', async () => {
149
- const video = requireVideo(state);
150
- const t = translator(languageSettings(state).locale);
151
- return pickSavePath(state, {
152
- title: t('native.exportVideo'),
153
- defaultPath: exportDefaultFor(state, video),
154
- filters: [{ name: t('native.mp4Video'), extensions: ['mp4'] }],
155
- extensions: ['mp4'],
156
- defaultExtension: 'mp4',
157
- });
158
- });
159
- handle(devUrl, 'dronepath:export:start', (raw) => {
160
- const video = requireVideo(state);
161
- state.exportRunner.start(video, parseExportRequest(raw, state.config));
162
- return { ok: true };
163
- });
164
- handle(devUrl, 'dronepath:export:cancel', () => {
165
- state.exportRunner.cancel();
166
- return { ok: true };
167
- });
168
- handle(devUrl, 'dronepath:export:reveal', (payload) => {
169
- shell.showItemInFolder(knownOutputOf(state, payload));
170
- return { ok: true };
171
- });
172
- handle(devUrl, 'dronepath:export:open', async (payload) => {
173
- const error = await shell.openPath(knownOutputOf(state, payload));
174
- return error ? { ok: false, error } : { ok: true };
175
- });
176
- }
177
-
178
- function registerTrackHandlers(state, devUrl, log) {
179
- handle(devUrl, 'dronepath:track:pick-output', async () => {
180
- const video = requireVideo(state);
181
- // The export dialog's default folder, named after the recording
182
- // (<basename>.telemetry.json); the typed name selects the format by its
183
- // extension, with the telemetry document as the bare-name default.
184
- const exportDefault = exportDefaultFor(state, video);
185
- const t = translator(languageSettings(state).locale);
186
- return pickSavePath(state, {
187
- title: t('native.exportTelemetry'),
188
- defaultPath: path.join(path.dirname(exportDefault), `${videoBaseName(video)}.telemetry.json`),
189
- filters: [
190
- { name: t('native.telemetryJson'), extensions: ['json'] },
191
- { name: t('native.gpx'), extensions: ['gpx'] },
192
- { name: t('native.geojson'), extensions: ['geojson'] },
193
- { name: t('native.kml'), extensions: ['kml'] },
194
- { name: t('native.kmz'), extensions: ['kmz'] },
195
- ],
196
- extensions: [...TRACK_FORMAT_VALUES],
197
- defaultExtension: 'json',
198
- });
199
- });
200
- handle(devUrl, 'dronepath:track:save', (raw) => {
201
- requireVideo(state);
202
- const request = parseTrackSaveRequest(raw);
203
- state.session.saveTrack(request.outPath, request.range);
204
- state.lastTrackOut = request.outPath;
205
- log(`track: wrote ${request.outPath}`);
206
- return { ok: true };
207
- });
208
- }
209
-
210
- function registerUpdateHandlers(state, devUrl, sendToWindow) {
211
- handle(devUrl, 'dronepath:update:restart', () => {
212
- if (!state.updates) return { ok: false, error: 'this build does not self-update' };
213
- // No pendingClose here: the prompt never opens over a running export, and
214
- // a failed restart must not poison the export close guard.
215
- return state.updates.restart({
216
- onError: (message) => sendToWindow(state, 'dronepath:update:restart-failed', message),
217
- });
218
- });
219
- handle(devUrl, 'dronepath:update:state', () => ({ ready: state.updateReady }));
220
- }
221
-
222
- function registerWindowHandlers(state, devUrl) {
223
- handle(devUrl, 'dronepath:window:close', () => {
224
- // The window's close handler runs the running-export guard.
225
- if (state.win && !state.win.isDestroyed()) state.win.close();
226
- });
227
- }
228
-
229
- export function registerIpcHandlers(state, { devUrl, log, sendToWindow }) {
230
- registerSessionHandlers(state, devUrl);
231
- registerSettingsHandlers(state, devUrl, log);
232
- registerLanguageHandlers(state, devUrl);
233
- registerExportHandlers(state, devUrl);
234
- registerTrackHandlers(state, devUrl, log);
235
- registerUpdateHandlers(state, devUrl, sendToWindow);
236
- registerWindowHandlers(state, devUrl);
237
- }