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/app/main.mjs DELETED
@@ -1,369 +0,0 @@
1
- #!/usr/bin/env node
2
- // Electron shell for the Drone Path desktop app: window, native file
3
- // dialog, the app:// scheme and process lifecycle only. All behavior lives in
4
- // dist/ (compiled from src/), so the app and the CLI stay one code base.
5
-
6
- import fs from 'node:fs';
7
- import path from 'node:path';
8
- import process from 'node:process';
9
- import { Readable } from 'node:stream';
10
- import { pathToFileURL } from 'node:url';
11
-
12
- import { app, BrowserWindow, dialog, Menu, net, protocol, shell } from 'electron';
13
-
14
- import { resolveAppAsset } from '../dist/appassets.js';
15
- import { APP_ORIGIN, appStateFile, uiExportRoot } from '../dist/apppaths.js';
16
- import {
17
- applyAppState,
18
- emptyAppState,
19
- readAppState,
20
- rememberOpenedFile,
21
- writeAppState,
22
- } from '../dist/appstate.js';
23
- import { createAppSession } from '../dist/appsession.js';
24
- import { resolveConfig } from '../dist/configfile.js';
25
- import { DEFAULT_LOCALE, resolveLocale, translator } from '../dist/desktop-i18n/messages.js';
26
- import { ERROR_PREFIX, errorMessage } from '../dist/errors.js';
27
- import { createExportRunner } from '../dist/exportjob.js';
28
- import { requireFfmpegTools } from '../dist/ffmpeg.js';
29
- import { resolveFfmpegTools } from '../dist/ffmpeg-tools.js';
30
- import { planByteRange } from '../dist/range.js';
31
- import { createTileTraffic } from '../dist/tiles.js';
32
- import { registerIpcHandlers } from './ipc.mjs';
33
- import { initUpdates } from './update.mjs';
34
-
35
- const SCHEME = 'app';
36
- // --dev-url points the window at `next dev` (hot reload) instead of the
37
- // built export; kept an argv flag so no cross-platform env helper is needed.
38
- const devUrlIndex = process.argv.indexOf('--dev-url');
39
- const DEV_URL = devUrlIndex >= 0 ? process.argv[devUrlIndex + 1] : null;
40
- const DEV_MODE = DEV_URL !== null;
41
- const log = (msg) => process.stderr.write(`[drone-path] ${msg}\n`);
42
-
43
- // Must run before app ready so the scheme gets standard/secure semantics.
44
- protocol.registerSchemesAsPrivileged([
45
- {
46
- scheme: SCHEME,
47
- privileges: { standard: true, secure: true, supportFetchAPI: true, stream: true },
48
- },
49
- ]);
50
-
51
- // Resolved against this script's directory (works in a checkout and in
52
- // app.asar); app.getAppPath() does not point at the repo root when Electron
53
- // is started with a script path.
54
- const exportRoot = uiExportRoot(import.meta.dirname);
55
-
56
- // The one window's mutable state, created in startup() and handed to every
57
- // stage as one object: the IPC handlers, the export runner callbacks and the
58
- // window lifecycle handlers share it, so each writer (export completion, the
59
- // close guard, window-all-closed) is a named handler instead of a nested
60
- // closure over scattered module globals.
61
- function createShellState() {
62
- return {
63
- win: null,
64
- session: null,
65
- config: null,
66
- appState: emptyAppState(),
67
- systemLanguages: app.getPreferredSystemLanguages(),
68
- tileTraffic: null,
69
- // The one tile prefetch entry point every in-process lane drives.
70
- tilePrefetch: null,
71
- exportRunner: null,
72
- // The update controller, or null when this build cannot self-update.
73
- updates: null,
74
- // A downloaded update waits even if its announcement raced the renderer.
75
- updateReady: false,
76
- // The destinations of the last successful export and the last track
77
- // save: the only paths the renderer may reveal or open.
78
- lastExportOut: null,
79
- lastTrackOut: null,
80
- closePromptOpen: false,
81
- pendingClose: false,
82
- };
83
- }
84
-
85
- function translationFor(state) {
86
- return translator(resolveLocale(state.appState.language, state.systemLanguages));
87
- }
88
-
89
- async function pickRecording(state) {
90
- const t = translationFor(state);
91
- const options = {
92
- title: t('native.chooseRecording'),
93
- filters: [{ name: t('native.djiRecordings'), extensions: ['mp4'] }],
94
- properties: ['openFile'],
95
- // Back where the last recording came from, when that folder still exists.
96
- defaultPath: rememberedOpenDir(state) ?? undefined,
97
- };
98
- const result = state.win
99
- ? await dialog.showOpenDialog(state.win, options)
100
- : await dialog.showOpenDialog(options);
101
- const picked = result.canceled ? null : result.filePaths[0];
102
- if (picked) rememberPicked(state, picked);
103
- return picked;
104
- }
105
-
106
- function rememberedOpenDir(state) {
107
- const dir = state.appState.lastOpenDir;
108
- return dir && fs.existsSync(dir) ? dir : undefined;
109
- }
110
-
111
- function rememberPicked(state, filePath) {
112
- state.appState = rememberOpenedFile(state.appState, filePath);
113
- try {
114
- writeAppState(appStateFile(), state.appState);
115
- } catch (e) {
116
- // The pick and the look still apply when the state file cannot be written.
117
- log(`app state not saved: ${errorMessage(e)}`);
118
- }
119
- }
120
-
121
- function fail(state, error) {
122
- const message = errorMessage(error);
123
- process.stderr.write(`${ERROR_PREFIX}${message}\n`);
124
- const locale = resolveLocale(state.appState.language, state.systemLanguages);
125
- const t = translator(locale);
126
- dialog.showErrorBox(t('app.title'), locale === DEFAULT_LOCALE
127
- ? message
128
- : t('native.startupFailure', { details: message }));
129
- app.quit();
130
- }
131
-
132
- function sendToWindow(state, channel, payload) {
133
- if (state.win && !state.win.isDestroyed()) state.win.webContents.send(channel, payload);
134
- }
135
-
136
- function handleExportDone(state, outcome) {
137
- if (outcome.status === 'ok') state.lastExportOut = outcome.summary.out;
138
- sendToWindow(state, 'dronepath:export:done', outcome);
139
- if (state.pendingClose) {
140
- state.pendingClose = false;
141
- if (state.win && !state.win.isDestroyed()) state.win.close();
142
- else app.quit();
143
- }
144
- }
145
-
146
- function videoResponse(request, filePath) {
147
- const size = fs.statSync(filePath).size;
148
- const plan = planByteRange(request.headers.get('range') ?? undefined, size, 'video/mp4');
149
- if (plan.status === 416) {
150
- return new Response(plan.body, { status: 416, headers: plan.headers });
151
- }
152
- const stream =
153
- plan.status === 206
154
- ? fs.createReadStream(filePath, { start: plan.span.start, end: plan.span.end })
155
- : fs.createReadStream(filePath);
156
- return new Response(Readable.toWeb(stream), { status: plan.status, headers: plan.headers });
157
- }
158
-
159
- // net.fetch only sets request headers; wrapping the body gives the client
160
- // the intended MIME and status.
161
- async function fileResponse(filePath, mime, status = 200) {
162
- const fetched = await net.fetch(pathToFileURL(filePath).toString());
163
- return new Response(fetched.body, { status, headers: { 'Content-Type': mime } });
164
- }
165
-
166
- function notFound() {
167
- const fallback = path.join(exportRoot, '404.html');
168
- return fs.existsSync(fallback)
169
- ? fileResponse(fallback, 'text/html; charset=utf-8', 404)
170
- : new Response('not found', { status: 404 });
171
- }
172
-
173
- async function handleRequest(state, request) {
174
- let pathname;
175
- try {
176
- pathname = decodeURIComponent(new URL(request.url).pathname);
177
- } catch {
178
- return new Response('bad request', { status: 400 });
179
- }
180
- const plan = resolveAppAsset(pathname, {
181
- exportRoot,
182
- tileCache: state.config.tileCache,
183
- videoPath: state.session ? state.session.videoPath() : null,
184
- });
185
- switch (plan.kind) {
186
- case 'video':
187
- return videoResponse(request, plan.filePath);
188
- case 'tile': {
189
- // Always through the tile traffic: it serves cached tiles immediately,
190
- // retries tiles whose earlier download failed (so they recover once
191
- // connectivity returns) and falls back to the placeholder.
192
- const file = await state.tileTraffic.ensure(plan.style, plan.tile);
193
- return fileResponse(file, 'image/png');
194
- }
195
- case 'export':
196
- if (fs.existsSync(plan.filePath)) return fileResponse(plan.filePath, plan.mime);
197
- return notFound();
198
- case 'not-found':
199
- return notFound();
200
- }
201
- }
202
-
203
- // The backing services behind the window: tool check, config, tile cache and
204
- // the recording session.
205
- async function initServices(state) {
206
- state.appState = readAppState(appStateFile());
207
- const resolved = resolveConfig({});
208
- state.config = applyAppState(resolved.config, state.appState);
209
- await requireFfmpegTools(resolveFfmpegTools(state.config));
210
- // One polite tile queue for the whole app: on-demand tiles and the export
211
- // prefetch share its request budget, and on-demand tiles the player needs
212
- // right now jump the queue.
213
- state.tileTraffic = createTileTraffic(state.config.tileCache);
214
- state.tilePrefetch = (options) => state.tileTraffic.stream(options);
215
- state.session = createAppSession({
216
- config: state.config,
217
- pickFile: () => pickRecording(state),
218
- log,
219
- onPreparing: () => sendToWindow(state, 'dronepath:preparing'),
220
- onPrepareProgress: (progress) =>
221
- sendToWindow(state, 'dronepath:preparing:progress', progress),
222
- });
223
- }
224
-
225
- function initExportRunner(state) {
226
- state.exportRunner = createExportRunner({
227
- log: (msg) => {
228
- log(msg);
229
- sendToWindow(state, 'dronepath:export:progress', msg);
230
- },
231
- onCapture: (progress) =>
232
- sendToWindow(state, 'dronepath:export:capture', progress),
233
- onDone: (outcome) => handleExportDone(state, outcome),
234
- // An export warms tiles next to the live app: same queue, same budget.
235
- deps: { prefetchTiles: state.tilePrefetch },
236
- });
237
- }
238
-
239
- function installProtocolHandler(state) {
240
- protocol.handle(SCHEME, (request) =>
241
- handleRequest(state, request).catch((e) => {
242
- log(`scheme error: ${errorMessage(e)}`);
243
- return new Response('internal error', { status: 500 });
244
- }),
245
- );
246
- }
247
-
248
- function ensureUiExport() {
249
- if (!DEV_MODE && !fs.existsSync(path.join(exportRoot, 'index.html'))) {
250
- throw new Error('ui export missing; run "npm run build" first');
251
- }
252
- }
253
-
254
- function createWindow(state) {
255
- // The in-app menu bar owns all workspace commands; a native Alt/F10 menu
256
- // would compete with it, so none is installed (Windows and Linux).
257
- Menu.setApplicationMenu(null);
258
- const t = translationFor(state);
259
- state.win = new BrowserWindow({
260
- width: 1600,
261
- height: 950,
262
- // The control bar needs ~1000px of min-content width; below this the
263
- // right-hand buttons would become unreachable.
264
- minWidth: 1024,
265
- minHeight: 600,
266
- // Match --page in ui/app/globals.css so startup shows one background.
267
- backgroundColor: '#232323',
268
- // The loaded page's <title> takes over after load (ui/app/layout.tsx).
269
- title: t('app.title'),
270
- // Windows renders an ICO best, Linux a PNG (Electron docs); both are
271
- // derived from build/icon-master.png (see build/README.md).
272
- icon:
273
- process.platform === 'win32'
274
- ? path.join(import.meta.dirname, '..', 'build', 'icon.ico')
275
- : path.join(import.meta.dirname, '..', 'build', 'icons', '256x256.png'),
276
- webPreferences: {
277
- preload: path.join(import.meta.dirname, 'preload.cjs'),
278
- contextIsolation: true,
279
- sandbox: true,
280
- nodeIntegration: false,
281
- },
282
- });
283
- state.win.on('closed', () => {
284
- state.win = null;
285
- });
286
- // Web links (e.g. in the user manual) open in the system browser, never in
287
- // a second app window.
288
- state.win.webContents.setWindowOpenHandler(({ url }) => {
289
- if (/^(https?|mailto):/i.test(url)) void shell.openExternal(url);
290
- return { action: 'deny' };
291
- });
292
- }
293
-
294
- // Closing the window must not silently kill a running export and strand
295
- // minutes of work; the user chooses between stopping and keeping it.
296
- function installCloseGuard(state) {
297
- state.win.on('close', (e) => {
298
- // A close already confirmed by the user, or with nothing running, passes.
299
- if (state.pendingClose || !state.exportRunner || !state.exportRunner.running()) return;
300
- if (state.closePromptOpen) {
301
- e.preventDefault();
302
- return;
303
- }
304
- e.preventDefault();
305
- state.closePromptOpen = true;
306
- const t = translationFor(state);
307
- const box = {
308
- type: 'warning',
309
- buttons: [t('native.stopExport'), t('native.keepExporting')],
310
- defaultId: 1,
311
- cancelId: 1,
312
- message: t('native.exportInProgress'),
313
- detail: t('native.closeExportDetail'),
314
- };
315
- void (state.win ? dialog.showMessageBox(state.win, box) : dialog.showMessageBox(box)).then(
316
- ({ response }) => {
317
- state.closePromptOpen = false;
318
- if (response !== 0) return;
319
- // Cancellation settles asynchronously: the close completes from the
320
- // job's onDone, never from a synchronous running() check.
321
- state.pendingClose = true;
322
- state.exportRunner.cancel();
323
- },
324
- );
325
- });
326
- }
327
-
328
- async function loadUi(state) {
329
- await state.win.loadURL(DEV_MODE ? DEV_URL : `${APP_ORIGIN}/`);
330
- }
331
-
332
- // The window is the app: closing it quits. A still-running export delays the
333
- // quit until its job has settled and cleaned up after itself.
334
- function handleWindowAllClosed(state) {
335
- if (state.exportRunner && state.exportRunner.running()) {
336
- state.pendingClose = true;
337
- state.exportRunner.cancel();
338
- return;
339
- }
340
- app.quit();
341
- }
342
-
343
- async function startup() {
344
- const state = createShellState();
345
- app.on('window-all-closed', () => handleWindowAllClosed(state));
346
- try {
347
- await initServices(state);
348
- initExportRunner(state);
349
- state.updates = initUpdates({
350
- log,
351
- onReady: () => {
352
- // Buffered: the cache fast path can announce before the renderer
353
- // subscribes, and the state handler replays it on mount.
354
- state.updateReady = true;
355
- sendToWindow(state, 'dronepath:update:ready');
356
- },
357
- });
358
- registerIpcHandlers(state, { devUrl: DEV_URL, log, sendToWindow });
359
- installProtocolHandler(state);
360
- ensureUiExport();
361
- createWindow(state);
362
- installCloseGuard(state);
363
- await loadUi(state);
364
- } catch (e) {
365
- fail(state, e);
366
- }
367
- }
368
-
369
- app.whenReady().then(startup);
package/app/preload.cjs DELETED
@@ -1,36 +0,0 @@
1
- // Preload bridge for the UI: the only surface the renderer sees. CommonJS
2
- // (.cjs) because sandboxed preload scripts cannot use ESM.
3
- const { contextBridge, ipcRenderer } = require('electron');
4
-
5
- function subscribe(channel, adapt) {
6
- const handler = (_event, payload) => adapt(payload);
7
- ipcRenderer.on(channel, handler);
8
- return () => ipcRenderer.removeListener(channel, handler);
9
- }
10
-
11
- contextBridge.exposeInMainWorld('dronepath', {
12
- pickRecording: (request) => ipcRenderer.invoke('dronepath:pick', request),
13
- getSession: () => ipcRenderer.invoke('dronepath:session'),
14
- getLanguage: () => ipcRenderer.invoke('dronepath:language'),
15
- saveLanguage: (preference) => ipcRenderer.invoke('dronepath:language:save', preference),
16
- getSettings: () => ipcRenderer.invoke('dronepath:settings'),
17
- saveSettings: (patch) => ipcRenderer.invoke('dronepath:settings:save', patch),
18
- pickExportOutput: () => ipcRenderer.invoke('dronepath:export:pick-output'),
19
- pickTrackOutput: () => ipcRenderer.invoke('dronepath:track:pick-output'),
20
- saveTrack: (request) => ipcRenderer.invoke('dronepath:track:save', request),
21
- startExport: (request) => ipcRenderer.invoke('dronepath:export:start', request),
22
- cancelExport: () => ipcRenderer.invoke('dronepath:export:cancel'),
23
- revealExportOutput: (payload) => ipcRenderer.invoke('dronepath:export:reveal', payload),
24
- openExportOutput: (payload) => ipcRenderer.invoke('dronepath:export:open', payload),
25
- onExportProgress: (cb) => subscribe('dronepath:export:progress', cb),
26
- onExportCapture: (cb) => subscribe('dronepath:export:capture', cb),
27
- onExportDone: (cb) => subscribe('dronepath:export:done', cb),
28
- onPreparing: (cb) => subscribe('dronepath:preparing', () => cb()),
29
- onPrepareProgress: (cb) => subscribe('dronepath:preparing:progress', cb),
30
- onUpdateReady: (cb) => subscribe('dronepath:update:ready', () => cb()),
31
- onUpdateRestartFailed: (cb) =>
32
- subscribe('dronepath:update:restart-failed', (message) => cb(message)),
33
- getUpdateState: () => ipcRenderer.invoke('dronepath:update:state'),
34
- restartToUpdate: () => ipcRenderer.invoke('dronepath:update:restart'),
35
- closeWindow: () => ipcRenderer.invoke('dronepath:window:close'),
36
- });
@@ -1,6 +0,0 @@
1
- export interface UpdateGateInput {
2
- packaged: boolean;
3
- hasUpdateMetadata: boolean;
4
- }
5
-
6
- export declare function shouldCheckForUpdates(input: UpdateGateInput): boolean;
@@ -1,6 +0,0 @@
1
- // Whether this install can ever self-update. Only packaged builds that carry
2
- // electron-builder's update metadata talk to the feed: NSIS and AppImage
3
- // builds ship app-update.yml, portable installs and dev runs never do.
4
- export function shouldCheckForUpdates({ packaged, hasUpdateMetadata }) {
5
- return packaged && hasUpdateMetadata;
6
- }
package/app/update.d.mts DELETED
@@ -1,10 +0,0 @@
1
- export interface UpdateController {
2
- restart(deps: { onError: (message: string) => void }): { ok: true } | { ok: false; error: string };
3
- }
4
-
5
- export interface InitUpdatesOptions {
6
- log: (message: string) => void;
7
- onReady: () => void;
8
- }
9
-
10
- export function initUpdates(options: InitUpdatesOptions): UpdateController | null;
package/app/update.mjs DELETED
@@ -1,54 +0,0 @@
1
- // Auto-update for the packaged desktop app: check the GitHub release feed,
2
- // download in the background and let the UI prompt before the restart. Every
3
- // failure stays a stderr line and never touches startup.
4
- import fs from 'node:fs';
5
- import path from 'node:path';
6
- import process from 'node:process';
7
-
8
- import { app } from 'electron';
9
- // The default import then destructuring keeps ESM consumers off the CJS named
10
- // export interop (electron-builder issue #7976).
11
- import electronUpdater from 'electron-updater';
12
-
13
- import { errorMessage } from '../dist/errors.js';
14
- import { shouldCheckForUpdates } from './update-policy.mjs';
15
-
16
- const { autoUpdater } = electronUpdater;
17
-
18
- export function initUpdates({ log, onReady }) {
19
- const hasUpdateMetadata = fs.existsSync(path.join(process.resourcesPath, 'app-update.yml'));
20
- if (!shouldCheckForUpdates({ packaged: app.isPackaged, hasUpdateMetadata })) return null;
21
-
22
- autoUpdater.autoDownload = true;
23
- // A postponed prompt must still install the update on the next regular quit.
24
- autoUpdater.autoInstallOnAppQuit = true;
25
- autoUpdater.logger = {
26
- info: (message) => log(`update: ${message}`),
27
- warn: (message) => log(`update: ${message}`),
28
- error: (message) => log(`update: ${message}`),
29
- };
30
- // Feed and download failures are background noise: report and continue.
31
- autoUpdater.on('error', (e) => log(`update failed: ${errorMessage(e)}`));
32
- autoUpdater.on('update-downloaded', () => onReady());
33
- autoUpdater.checkForUpdates().catch((e) => log(`update check failed: ${errorMessage(e)}`));
34
-
35
- return {
36
- // electron-updater swallows install failures onto its 'error' event and
37
- // keeps running: both the thrown and the emitted failure must surface or
38
- // the restart prompt would wait forever.
39
- restart({ onError }) {
40
- const fail = (e) => {
41
- autoUpdater.removeListener('error', fail);
42
- onError(errorMessage(e));
43
- };
44
- autoUpdater.once('error', fail);
45
- try {
46
- autoUpdater.quitAndInstall(true, true);
47
- } catch (e) {
48
- fail(e);
49
- return { ok: false, error: errorMessage(e) };
50
- }
51
- return { ok: true };
52
- },
53
- };
54
- }
package/dist/appassets.js DELETED
@@ -1,35 +0,0 @@
1
- import path from 'node:path';
2
- import { mimeFor, resolveTileRoute } from './assets.js';
3
- import { MEDIA_PATH } from './apppaths.js';
4
- export function resolveAppAsset(pathname, routes) {
5
- if (pathname === MEDIA_PATH) {
6
- return routes.videoPath
7
- ? { kind: 'video', filePath: routes.videoPath }
8
- : { kind: 'not-found' };
9
- }
10
- const tile = resolveTileRoute(pathname, routes.tileCache, { anyStyle: true });
11
- if (tile) {
12
- return { kind: 'tile', ...tile };
13
- }
14
- return exportFile(pathname, routes.exportRoot);
15
- }
16
- function exportFile(pathname, exportRoot) {
17
- let rel = pathname.replace(/^\/+/, '');
18
- if (rel === '' || rel.endsWith('/'))
19
- rel += 'index.html';
20
- // Windows drive prefixes or backslashes would be a plain file name to POSIX
21
- // resolution; refuse them so the guard works the same on every OS.
22
- if (rel.split('/').some((s) => s.includes('\\') || /^[a-zA-Z]:/.test(s))) {
23
- return { kind: 'not-found' };
24
- }
25
- const filePath = path.resolve(exportRoot, rel);
26
- const relCheck = path.relative(exportRoot, filePath);
27
- if (relCheck === '' || relCheck.startsWith('..') || path.isAbsolute(relCheck)) {
28
- return { kind: 'not-found' };
29
- }
30
- return {
31
- kind: 'export',
32
- filePath,
33
- mime: mimeFor(filePath),
34
- };
35
- }
package/dist/apppaths.js DELETED
@@ -1,20 +0,0 @@
1
- import os from 'node:os';
2
- import path from 'node:path';
3
- export const APP_ORIGIN = 'app://bundle';
4
- export const MEDIA_PATH = '/media/video';
5
- const MEDIA_URL = APP_ORIGIN + MEDIA_PATH;
6
- export const TILE_BASE = APP_ORIGIN + '/tiles';
7
- // The ?v= query names the file so a reload can never replay another recording's bytes from a URL-keyed cache.
8
- export function mediaUrlFor(videoPath) {
9
- return `${MEDIA_URL}?v=${encodeURIComponent(videoPath)}`;
10
- }
11
- export function uiExportRoot(shellDir) {
12
- return path.join(shellDir, '..', 'ui', 'out');
13
- }
14
- export function userDataDir() {
15
- const base = process.env['LOCALAPPDATA'] ?? path.join(os.homedir(), '.cache');
16
- return path.join(base, 'drone-path');
17
- }
18
- export function appStateFile() {
19
- return path.join(userDataDir(), 'state.json');
20
- }
@@ -1,121 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { z } from 'zod';
4
- import { TILE_BASE, mediaUrlFor } from './apppaths.js';
5
- import { parseFrameRange, parseAppearanceSettings, parseValue, strictShape, } from './config.js';
6
- import { ERR_NO_RECORDING, ERR_NOT_READABLE_MP4, errorMessage } from './errors.js';
7
- import { timeAt } from './frametime.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';
13
- export function frameExactDuration(probe) {
14
- return timeAt(probe.frames, probe.fps.value);
15
- }
16
- export function parsePickRequest(raw) {
17
- const input = typeof raw === 'object' && raw !== null ? raw : {};
18
- return { settings: parseAppearanceSettings(input.settings) };
19
- }
20
- const TRACK_SAVE_SHAPE = {
21
- outPath: z.unknown().optional(),
22
- range: z.unknown().optional(),
23
- };
24
- export function parseTrackSaveRequest(raw) {
25
- const request = parseValue(strictShape(TRACK_SAVE_SHAPE, {
26
- invalid: 'invalid track save request',
27
- unknownKey: (key) => `unknown track save request key ${key}`,
28
- }), raw);
29
- const outPath = parseValue(z
30
- .string({ error: () => 'invalid track save request: outPath' })
31
- .min(1, { error: () => 'invalid track save request: outPath' }), request.outPath);
32
- try {
33
- trackFormatOf(outPath);
34
- }
35
- catch (e) {
36
- throw new Error(`invalid track save request: outPath must be a .gpx, .geojson, .kml, .kmz or .json file: ${outPath}`, { cause: e });
37
- }
38
- const range = request.range === undefined || request.range === null
39
- ? null
40
- : parseFrameRange(request.range);
41
- return { outPath, range };
42
- }
43
- export const prepareUiSession = async (videoPath, config, log, onProgress, deps) => {
44
- const prep = await prepareSession(videoPath, config, log, {
45
- onProgress,
46
- deps,
47
- });
48
- return {
49
- session: {
50
- scene: buildSceneData(recordingPageOpts(prep, config), TILE_BASE),
51
- video: {
52
- src: mediaUrlFor(videoPath),
53
- fps: prep.probe.fps.value,
54
- frames: prep.probe.frames,
55
- width: prep.probe.width,
56
- height: prep.probe.height,
57
- },
58
- tileBase: TILE_BASE,
59
- bbox: prep.tel.bbox,
60
- durationSec: frameExactDuration(prep.probe),
61
- },
62
- telemetry: telemetryExportInput(prep),
63
- track: trackExportStream(prep),
64
- };
65
- };
66
- function isReadableVideo(filePath) {
67
- if (!isRecordingName(filePath))
68
- return false;
69
- try {
70
- return fs.statSync(filePath).isFile();
71
- }
72
- catch {
73
- return false;
74
- }
75
- }
76
- export function createAppSession(options) {
77
- const { config, pickFile } = options;
78
- const prepare = options.prepare ?? prepareUiSession;
79
- const log = options.log ?? (() => { });
80
- const onPreparing = options.onPreparing ?? (() => { });
81
- const onPrepareProgress = options.onPrepareProgress ?? (() => { });
82
- let prepared = null;
83
- let videoPath = null;
84
- let picking = false;
85
- return {
86
- async pick(request) {
87
- if (picking)
88
- return { ok: false, error: 'a pick is already in progress' };
89
- picking = true;
90
- try {
91
- const picked = await pickFile();
92
- if (picked === null)
93
- return { ok: false, canceled: true };
94
- const resolved = path.resolve(picked);
95
- if (!isReadableVideo(resolved)) {
96
- log(`rejected: ${resolved}`);
97
- return { ok: false, error: `${ERR_NOT_READABLE_MP4}${resolved}` };
98
- }
99
- onPreparing(resolved);
100
- prepared = await prepare(resolved, { ...config, ...request.settings }, log, onPrepareProgress);
101
- videoPath = resolved;
102
- log(`loaded: ${resolved}`);
103
- return { ok: true };
104
- }
105
- catch (e) {
106
- log(`error: ${errorMessage(e)}`);
107
- return { ok: false, error: errorMessage(e) };
108
- }
109
- finally {
110
- picking = false;
111
- }
112
- },
113
- getSession: () => prepared?.session ?? null,
114
- videoPath: () => videoPath,
115
- saveTrack(file, range) {
116
- if (!prepared)
117
- throw new Error(ERR_NO_RECORDING);
118
- writeTrackFile(file, { document: prepared.telemetry, track: prepared.track }, range);
119
- },
120
- };
121
- }