drone-path 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/README.md +17 -24
- package/THIRD-PARTY-NOTICES.md +7 -0
- package/app/main.mjs +82 -28
- package/app/preload.cjs +3 -0
- package/dist/appassets.js +2 -11
- package/dist/apppaths.js +2 -10
- package/dist/appsession.js +59 -25
- package/dist/appstate.js +0 -18
- package/dist/assets.js +0 -7
- package/dist/buildinfo.js +71 -0
- package/dist/cammeta.js +123 -84
- package/dist/changeset-gate.js +0 -7
- package/dist/cli.js +0 -15
- package/dist/config.js +40 -52
- package/dist/configfile.js +0 -8
- package/dist/decimate.js +2 -12
- package/dist/exportjob.js +3 -19
- package/dist/ff.js +0 -8
- package/dist/fftools.js +0 -10
- package/dist/geo.js +3 -13
- package/dist/inputs.js +0 -4
- package/dist/manual/anchors.js +1 -7
- package/dist/manual/build.js +0 -6
- package/dist/manual/cliref.js +0 -6
- package/dist/manual/links.js +0 -17
- package/dist/manual/markdown.js +2 -10
- package/dist/manual/model.js +0 -3
- package/dist/manual/module.js +0 -3
- package/dist/manual/nav.js +0 -2
- package/dist/manual/reference.js +1 -4
- package/dist/page.js +3 -26
- package/dist/paths.js +0 -12
- package/dist/plan.js +1 -18
- package/dist/png.js +0 -3
- package/dist/proto.js +4 -4
- package/dist/range.js +0 -8
- package/dist/render.js +3 -53
- package/dist/renderer/dom.js +0 -6
- package/dist/renderer/framemath.js +0 -4
- package/dist/renderer/leaflet.js +0 -4
- package/dist/renderer/scene.js +10 -34
- package/dist/renderer/theme.js +58 -10
- package/dist/renderer/tilesources.js +0 -10
- package/dist/renderer/trail.js +1 -12
- package/dist/restyle.js +1 -9
- package/dist/run.js +45 -46
- package/dist/serve.js +0 -13
- package/dist/srt.js +30 -8
- package/dist/summary.js +0 -3
- package/dist/telemetry-json-schema.js +23 -0
- package/dist/telemetry-json.js +107 -0
- package/dist/telemetry-math.js +9 -45
- package/dist/telemetry.js +52 -9
- package/dist/tilecache.js +0 -5
- package/dist/tiles.js +1 -31
- package/dist/tracing.js +3 -27
- package/package.json +9 -6
package/dist/config.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
// The option vocabulary: the option types (Style, View, Capture, Codec,
|
|
2
|
-
// Quality, Preset, HudSpec), their defaults and the parsing/normalizing rules.
|
|
3
|
-
// Feature modules import them from here, and this module stays free of I/O so
|
|
4
|
-
// the app UI can share the vocabulary in its browser bundle. File discovery
|
|
5
|
-
// and the precedence of the config layers live in src/configfile.ts.
|
|
6
1
|
export const CONFIG_FILE_NAME = '.dronepath.json';
|
|
7
|
-
// The config-file selection flag: vocabulary outside the config keys,
|
|
8
|
-
// shared by the CLI and the generated reference so they cannot drift.
|
|
9
2
|
export const CONFIG_FILE_OPTION = {
|
|
10
3
|
flags: '--config <path>',
|
|
11
4
|
help: 'config file (default: .dronepath.json discovered upward from the working directory)',
|
|
@@ -35,17 +28,12 @@ export function parseHud(list) {
|
|
|
35
28
|
}
|
|
36
29
|
return hud;
|
|
37
30
|
}
|
|
38
|
-
// The "alt hides when unavailable" rule, one home for the pipeline and the UI.
|
|
39
31
|
export function resolveHudSpec(hud, hasAlt) {
|
|
40
32
|
return hud.alt && !hasAlt ? { ...hud, alt: false } : hud;
|
|
41
33
|
}
|
|
42
|
-
// What "unavailable" means for the rule above: no altitude sample at all in
|
|
43
|
-
// the telemetry.
|
|
44
34
|
export function hasAltitude(alt) {
|
|
45
35
|
return alt.some((a) => a !== null);
|
|
46
36
|
}
|
|
47
|
-
// The CLI-string form of a HUD spec ("none" when no chip is on), the inverse
|
|
48
|
-
// of parseHud.
|
|
49
37
|
export function formatHud(hud) {
|
|
50
38
|
const parts = [];
|
|
51
39
|
if (hud.heading)
|
|
@@ -56,17 +44,12 @@ export function formatHud(hud) {
|
|
|
56
44
|
parts.push('speed');
|
|
57
45
|
return parts.length ? parts.join(',') : 'none';
|
|
58
46
|
}
|
|
59
|
-
// Typed layers (config files, export requests) carry exact JSON types, so a
|
|
60
|
-
// mistyped value must fail instead of being silently converted.
|
|
61
47
|
export function asNumber(value, name) {
|
|
62
48
|
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
63
49
|
throw new Error(`invalid number for ${name}: ${String(value)}`);
|
|
64
50
|
}
|
|
65
51
|
return value;
|
|
66
52
|
}
|
|
67
|
-
// Commander hands every option value as a string; numeric flags are converted
|
|
68
|
-
// at the CLI boundary only. Anything that is not a plain decimal literal
|
|
69
|
-
// passes through so asNumber rejects it naming the offending input verbatim.
|
|
70
53
|
const CLI_NUMBER_RX = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
71
54
|
function cliNumber(raw) {
|
|
72
55
|
if (typeof raw !== 'string' || !CLI_NUMBER_RX.test(raw.trim()))
|
|
@@ -96,6 +79,21 @@ function asNullableString(value, name) {
|
|
|
96
79
|
return null;
|
|
97
80
|
return asString(value, name);
|
|
98
81
|
}
|
|
82
|
+
const TRAIL_COLOR_RX = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
83
|
+
export function asTrailColor(value, name) {
|
|
84
|
+
const bad = () => new Error(`invalid value for ${name}: ${String(value)} (use hex like #e63946 or #e63946cc)`);
|
|
85
|
+
if (value === null || value === '')
|
|
86
|
+
return null;
|
|
87
|
+
if (typeof value !== 'string')
|
|
88
|
+
throw bad();
|
|
89
|
+
const match = TRAIL_COLOR_RX.exec(value.trim());
|
|
90
|
+
if (!match)
|
|
91
|
+
throw bad();
|
|
92
|
+
let hex = match[1].toLowerCase();
|
|
93
|
+
if (hex.length <= 4)
|
|
94
|
+
hex = [...hex].map((c) => c + c).join('');
|
|
95
|
+
return `#${hex}`;
|
|
96
|
+
}
|
|
99
97
|
export const CONFIG_OPTIONS = [
|
|
100
98
|
{
|
|
101
99
|
key: 'outDir',
|
|
@@ -161,6 +159,15 @@ export const CONFIG_OPTIONS = [
|
|
|
161
159
|
default: 2,
|
|
162
160
|
normalize: (v, name) => ({ outroSec: asNumber(v, name) }),
|
|
163
161
|
},
|
|
162
|
+
{
|
|
163
|
+
key: 'trailColor',
|
|
164
|
+
cli: {
|
|
165
|
+
flags: '--trail-color <hex>',
|
|
166
|
+
help: 'trail color as hex, RGB or RGBA (e.g. e63946 or #e63946cc; default: the map style\'s color)',
|
|
167
|
+
},
|
|
168
|
+
default: null,
|
|
169
|
+
normalize: (v, name) => ({ trailColor: asTrailColor(v, name) }),
|
|
170
|
+
},
|
|
164
171
|
{
|
|
165
172
|
key: 'hud',
|
|
166
173
|
cli: {
|
|
@@ -239,6 +246,15 @@ export const CONFIG_OPTIONS = [
|
|
|
239
246
|
default: false,
|
|
240
247
|
normalize: (v, name) => ({ recurse: asBool(v, name) }),
|
|
241
248
|
},
|
|
249
|
+
{
|
|
250
|
+
key: 'telemetryJson',
|
|
251
|
+
cli: {
|
|
252
|
+
flags: '--telemetry-json <file>',
|
|
253
|
+
help: 'write one JSON document with per-frame telemetry to <file> (one recording per run)',
|
|
254
|
+
},
|
|
255
|
+
default: null,
|
|
256
|
+
normalize: (v, name) => ({ telemetryJson: asNullableString(v, name) }),
|
|
257
|
+
},
|
|
242
258
|
{
|
|
243
259
|
key: 'json',
|
|
244
260
|
cli: { flags: '--json', help: 'print one NDJSON summary line per recording on stdout' },
|
|
@@ -252,12 +268,6 @@ export const CONFIG_OPTIONS = [
|
|
|
252
268
|
normalize: (v, name) => ({ quiet: asBool(v, name) }),
|
|
253
269
|
},
|
|
254
270
|
];
|
|
255
|
-
// The CLI spells a default the way commander expects it. The config-native
|
|
256
|
-
// default stays in the table's `default` column so DEFAULT_CONFIG is a straight
|
|
257
|
-
// copy. Three kinds differ from their config form: a boolean default stays a
|
|
258
|
-
// boolean (commander's presence flags), a null default becomes the empty string
|
|
259
|
-
// ("not set") - "null" would read as a literal path - and the HUD spec becomes
|
|
260
|
-
// its comma string.
|
|
261
271
|
export function cliDefaultOf(key) {
|
|
262
272
|
const row = CONFIG_OPTIONS.find((r) => r.key === key);
|
|
263
273
|
if (!row)
|
|
@@ -269,12 +279,8 @@ export function cliDefaultOf(key) {
|
|
|
269
279
|
return '';
|
|
270
280
|
return key === 'hud' ? formatHud(value) : String(value);
|
|
271
281
|
}
|
|
272
|
-
// Frozen so no resolved config can corrupt the shared defaults; merges copy
|
|
273
|
-
// the hud spec so every resolved config owns its own mutable copy.
|
|
274
282
|
export const DEFAULT_CONFIG = Object.freeze(Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.default])));
|
|
275
283
|
Object.freeze(DEFAULT_CONFIG.hud);
|
|
276
|
-
// Keyed lookup built from the option table; a key's normalizer is found by its
|
|
277
|
-
// name, and an unknown key is a usage error naming the origin.
|
|
278
284
|
const OVERRIDE_NORMALIZERS = Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.normalize]));
|
|
279
285
|
export function normalizeOverrides(raw, origin) {
|
|
280
286
|
const out = {};
|
|
@@ -285,7 +291,9 @@ export function normalizeOverrides(raw, origin) {
|
|
|
285
291
|
if (!normalize)
|
|
286
292
|
throw new Error(`unknown config key ${key} in ${origin}`);
|
|
287
293
|
const value = raw[key];
|
|
288
|
-
if (value === undefined
|
|
294
|
+
if (value === undefined)
|
|
295
|
+
continue;
|
|
296
|
+
if (value === null && DEFAULT_CONFIG[key] !== null)
|
|
289
297
|
continue;
|
|
290
298
|
Object.assign(out, normalize(value, `${origin}: ${key}`));
|
|
291
299
|
}
|
|
@@ -303,13 +311,12 @@ export function settingsPatchOf(config) {
|
|
|
303
311
|
hud: config.hud,
|
|
304
312
|
introSec: config.introSec,
|
|
305
313
|
outroSec: config.outroSec,
|
|
314
|
+
trailColor: config.trailColor,
|
|
306
315
|
codec: config.codec,
|
|
307
316
|
quality: config.quality,
|
|
308
317
|
preset: config.preset,
|
|
309
318
|
};
|
|
310
319
|
}
|
|
311
|
-
// The persisted keys in the vocabulary's table order: the persisted state's
|
|
312
|
-
// shape and its serialization order in one home.
|
|
313
320
|
export const SETTINGS_KEYS = [
|
|
314
321
|
'style',
|
|
315
322
|
'view',
|
|
@@ -318,22 +325,16 @@ export const SETTINGS_KEYS = [
|
|
|
318
325
|
'hud',
|
|
319
326
|
'introSec',
|
|
320
327
|
'outroSec',
|
|
328
|
+
'trailColor',
|
|
321
329
|
'codec',
|
|
322
330
|
'quality',
|
|
323
331
|
'preset',
|
|
324
332
|
];
|
|
325
|
-
// The settings-values boundary (the settings save IPC, the persisted state
|
|
326
|
-
// file): the keys arrive complete and vocabulary-valid, so no layer
|
|
327
|
-
// downstream can hold a value the pipeline would reject. The HUD spec travels
|
|
328
|
-
// as its object form over IPC and as its CLI string in JSON files; both run
|
|
329
|
-
// through the vocabulary's own normalizers.
|
|
330
333
|
export function parseSettingsPatch(raw, origin) {
|
|
331
334
|
if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
|
|
332
335
|
throw new Error(`invalid settings in ${origin}`);
|
|
333
336
|
}
|
|
334
337
|
const flat = { ...raw };
|
|
335
|
-
// A known config key outside the persisted set (a machine-owned value) must
|
|
336
|
-
// never ride along; the vocabulary's normalizers only reject unknown keys.
|
|
337
338
|
for (const key of Object.keys(flat)) {
|
|
338
339
|
if (!SETTINGS_KEYS.includes(key)) {
|
|
339
340
|
throw new Error(`unknown settings key ${key} in ${origin}`);
|
|
@@ -352,18 +353,13 @@ export function parseSettingsPatch(raw, origin) {
|
|
|
352
353
|
validateRenderConfig({ ...DEFAULT_CONFIG, ...settings, hud: { ...settings.hud } });
|
|
353
354
|
return settings;
|
|
354
355
|
}
|
|
355
|
-
// The smallest canvas the renderer and the app's dimension fields accept, in
|
|
356
|
-
// one home so the CLI, the pipeline and the export modal cannot disagree.
|
|
357
356
|
export const MIN_DIMENSION = 64;
|
|
358
|
-
//
|
|
357
|
+
// Negated comparisons are NaN-safe (NaN would slip through <).
|
|
359
358
|
export function validateDimensions(width, height) {
|
|
360
359
|
if (!(width >= MIN_DIMENSION) || !(height >= MIN_DIMENSION)) {
|
|
361
360
|
throw new Error(`width and height must be at least ${MIN_DIMENSION}`);
|
|
362
361
|
}
|
|
363
362
|
}
|
|
364
|
-
// The documented "rounded down to even" rule (keeping the MIN_DIMENSION
|
|
365
|
-
// floor), in one home: every config producer applies it so a RenderConfig
|
|
366
|
-
// always holds the effective canvas the renderer gets.
|
|
367
363
|
export function normalizeDimensions(width, height) {
|
|
368
364
|
return {
|
|
369
365
|
width: Math.max(MIN_DIMENSION, 2 * Math.floor(width / 2)),
|
|
@@ -385,8 +381,6 @@ export function validateRenderConfig(config) {
|
|
|
385
381
|
if (!config.outSuffix)
|
|
386
382
|
throw new Error('out-suffix must not be empty');
|
|
387
383
|
}
|
|
388
|
-
// One rule for a usable frame range, shared by the request parser and the
|
|
389
|
-
// pipeline's range guard so they cannot drift.
|
|
390
384
|
export function assertValidFrameRange(range, name = 'frame range') {
|
|
391
385
|
if (!Number.isInteger(range.start) || !Number.isInteger(range.end)) {
|
|
392
386
|
throw new Error(`invalid ${name}: start and end must be integer frame indices`);
|
|
@@ -426,16 +420,10 @@ function parseHudObject(value, name) {
|
|
|
426
420
|
speed: asBool(h.speed, `${name}: speed`),
|
|
427
421
|
};
|
|
428
422
|
}
|
|
429
|
-
// Machine-owned settings the renderer never chooses: the main process's
|
|
430
|
-
// resolved values stay authoritative, so a snapshot cannot redirect the tile
|
|
431
|
-
// cache, the browser, the worker count or the CLI-only switches.
|
|
432
423
|
const MAIN_OWNED_KEYS = [
|
|
433
424
|
'outDir', 'outSuffix', 'tileCache', 'browser', 'ffmpeg', 'ffprobe', 'workers', 'capture',
|
|
434
|
-
'skipExisting', 'recurse', 'json', 'quiet',
|
|
425
|
+
'skipExisting', 'recurse', 'telemetryJson', 'json', 'quiet',
|
|
435
426
|
];
|
|
436
|
-
// The renderer sends the look and the export dimensions; everything else comes
|
|
437
|
-
// from the main process. The HUD spec travels in its CLI string form so the
|
|
438
|
-
// vocabulary's own normalizers stay the single validation home.
|
|
439
427
|
function parseRequestConfig(raw, base) {
|
|
440
428
|
if (typeof raw !== 'object' || raw === null) {
|
|
441
429
|
throw new Error('invalid export request: config');
|
package/dist/configfile.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
// Config file discovery and layer resolution: the imperative side of the
|
|
2
|
-
// option precedence (CLI flags > config file > built-in defaults). The config
|
|
3
|
-
// file is discovered upward from the working directory unless --config names
|
|
4
|
-
// one. The vocabulary itself stays pure in src/config.ts.
|
|
5
1
|
import fs from 'node:fs';
|
|
6
2
|
import path from 'node:path';
|
|
7
3
|
import { userDataDir } from './apppaths.js';
|
|
8
4
|
import { CONFIG_FILE_NAME, DEFAULT_CONFIG, normalizeDimensions, normalizeOverrides, validateRenderConfig, } from './config.js';
|
|
9
|
-
// DRONEPATH_TILE_CACHE overrides the per-user cache directory.
|
|
10
5
|
export function defaultTileCache() {
|
|
11
6
|
const override = process.env['DRONEPATH_TILE_CACHE'];
|
|
12
7
|
if (override)
|
|
@@ -52,9 +47,6 @@ function mergeConfigLayers(fileCfg, cli) {
|
|
|
52
47
|
...DEFAULT_CONFIG,
|
|
53
48
|
...fileCfg,
|
|
54
49
|
...cli,
|
|
55
|
-
// hud is an object; Partial spread replaces it wholesale, which is what
|
|
56
|
-
// we want. The winner is copied so no resolved config shares mutable
|
|
57
|
-
// state with DEFAULT_CONFIG or another layer.
|
|
58
50
|
hud: { ...(cli.hud ?? fileCfg.hud ?? DEFAULT_CONFIG.hud) },
|
|
59
51
|
};
|
|
60
52
|
}
|
package/dist/decimate.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// Up-front trail simplification: Douglas-Peucker in Web Mercator pixel space
|
|
2
|
-
// at the working zoom, so the drawn trail deviates from the flown track by
|
|
3
|
-
// less than about one pixel while its point count stays bounded regardless
|
|
4
|
-
// of flight length. Input arrays are index-aligned to video frames.
|
|
5
1
|
import { project } from './geo.js';
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const DEFAULT_EPSILON_PX = 1;
|
|
3
|
+
const DEFAULT_MAX_POINTS = 3000;
|
|
8
4
|
export function decimateTrack(lat, lon, zoom, options = {}) {
|
|
9
5
|
const epsilonPx = options.epsilonPx ?? DEFAULT_EPSILON_PX;
|
|
10
6
|
const maxPoints = options.maxPoints ?? DEFAULT_MAX_POINTS;
|
|
@@ -26,9 +22,6 @@ export function decimateTrack(lat, lon, zoom, options = {}) {
|
|
|
26
22
|
px[i] = project(lon[i], lat[i], zoom);
|
|
27
23
|
let keep = douglasPeucker(px, epsilonPx);
|
|
28
24
|
if (keep.length > maxPoints) {
|
|
29
|
-
// The cap is a promise (<=3k visible points on a 20 min flight), so the
|
|
30
|
-
// epsilon doubles until it holds; geometric growth keeps that
|
|
31
|
-
// deterministic and cheap (one or two extra passes in practice).
|
|
32
25
|
let hi = epsilonPx > 0 ? epsilonPx * 2 : 1;
|
|
33
26
|
let hiKeep = douglasPeucker(px, hi);
|
|
34
27
|
while (hiKeep.length > maxPoints) {
|
|
@@ -45,7 +38,6 @@ export function decimateTrack(lat, lon, zoom, options = {}) {
|
|
|
45
38
|
}
|
|
46
39
|
return track;
|
|
47
40
|
}
|
|
48
|
-
// Iterative (stack-based) so adversarial tracks cannot blow the call stack.
|
|
49
41
|
function douglasPeucker(px, epsilon) {
|
|
50
42
|
const n = px.length;
|
|
51
43
|
const keep = new Uint8Array(n);
|
|
@@ -64,8 +56,6 @@ function douglasPeucker(px, epsilon) {
|
|
|
64
56
|
let maxIdx = -1;
|
|
65
57
|
for (let i = start + 1; i < end; i++) {
|
|
66
58
|
const d = distanceToSegment(px[i], a, b);
|
|
67
|
-
// Ties go to the middle-most point so regular patterns (hover
|
|
68
|
-
// jitter, zigzags) split evenly instead of degenerating to O(n^2).
|
|
69
59
|
if (d > maxDist ||
|
|
70
60
|
(d === maxDist && Math.abs(i - mid) < Math.abs(maxIdx - mid))) {
|
|
71
61
|
maxDist = d;
|
package/dist/exportjob.js
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
// The desktop app's export job runner, free of Electron APIs like
|
|
2
|
-
// src/appsession.ts: one blocking job at a time that renders to a working
|
|
3
|
-
// file and replaces the destination only after the output is verified, so a
|
|
4
|
-
// failed export never destroys a pre-existing file.
|
|
5
1
|
import fs from 'node:fs';
|
|
6
2
|
import path from 'node:path';
|
|
7
3
|
import { errorMessage } from './errors.js';
|
|
8
4
|
import { samePath, uniquePath } from './paths.js';
|
|
9
5
|
import { processRecording } from './run.js';
|
|
10
|
-
// The pipeline is called exactly like the CLI calls it: one job, the
|
|
11
|
-
// snapshot's config, the frozen range. The deps let an in-app export warm
|
|
12
|
-
// through the app's shared tile queue instead of a budget of its own.
|
|
13
6
|
const runViaPipeline = (deps) => (videoPath, request, log, workingPath, signal, onCapture) => processRecording(videoPath, request.config, log, workingPath, {
|
|
14
7
|
range: request.range ?? undefined,
|
|
15
8
|
signal,
|
|
16
9
|
onCapture,
|
|
17
10
|
deps,
|
|
18
11
|
});
|
|
19
|
-
// The working file
|
|
20
|
-
// from it) and share the destination's directory so the final rename stays
|
|
21
|
-
// on one volume. Existing names are never reused or deleted: a stray file
|
|
22
|
-
// there may belong to someone else.
|
|
12
|
+
// The working file keeps the .mp4 suffix: ffmpeg infers the container from it.
|
|
23
13
|
function workingPathFor(outPath) {
|
|
24
14
|
const dir = path.dirname(outPath);
|
|
25
15
|
const stem = `${path.basename(outPath, path.extname(outPath))}.partial`;
|
|
26
16
|
return uniquePath(dir, stem, '.mp4', (candidate) => fs.existsSync(candidate));
|
|
27
17
|
}
|
|
28
|
-
// Best-effort removal of our own working file; a cleanup failure must never
|
|
29
|
-
// mask the job's real error.
|
|
30
18
|
function removeQuietly(working) {
|
|
31
19
|
try {
|
|
32
20
|
fs.rmSync(working, { force: true });
|
|
33
21
|
}
|
|
34
22
|
catch {
|
|
35
|
-
//
|
|
23
|
+
// best-effort removal; a cleanup failure must never throw from here
|
|
36
24
|
}
|
|
37
25
|
}
|
|
38
|
-
// The module's core invariant: the destination is replaced only after the
|
|
39
|
-
// render is complete and verified. A failed swap must keep the finished
|
|
40
|
-
// render at the working path (e.g. when a player holds the destination open).
|
|
41
26
|
function swapIntoPlace(working, outPath) {
|
|
42
27
|
try {
|
|
43
28
|
fs.renameSync(working, outPath);
|
|
@@ -84,8 +69,7 @@ export function createExportRunner(options) {
|
|
|
84
69
|
const controller = new AbortController();
|
|
85
70
|
job = { abort: () => controller.abort() };
|
|
86
71
|
const working = workingPathFor(request.outPath);
|
|
87
|
-
// The catch
|
|
88
|
-
// broken chain): an unhandled rejection here would kill the process.
|
|
72
|
+
// The catch guards a consumer's throwing onDone: an unhandled rejection here would kill the process.
|
|
89
73
|
void execute(videoPath, request, working, controller)
|
|
90
74
|
.then((outcome) => {
|
|
91
75
|
job = null;
|
package/dist/ff.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// ffmpeg and ffprobe invocation: the resolved tool paths come from
|
|
2
|
-
// src/fftools.ts (override, embedded binary, then PATH).
|
|
3
1
|
import { execFile } from 'node:child_process';
|
|
4
2
|
import { promisify } from 'node:util';
|
|
5
3
|
const execFileAsync = promisify(execFile);
|
|
@@ -22,9 +20,6 @@ export async function ffprobeJson(tools, videoPath, args) {
|
|
|
22
20
|
const { stdout } = await execFileAsync(tools.ffprobe, ['-v', 'error', ...args, videoPath], { maxBuffer: FFPROBE_MAX_BUFFER });
|
|
23
21
|
return JSON.parse(stdout || '{}');
|
|
24
22
|
}
|
|
25
|
-
// One split of ffprobe's rate wire format ("30" or "30000/1001"), with each
|
|
26
|
-
// consumer's own policy on top: the probe needs a usable rate, the output
|
|
27
|
-
// verification only reads a value.
|
|
28
23
|
function parseRate(str) {
|
|
29
24
|
const [num, den] = str.split('/').map(Number);
|
|
30
25
|
return Number.isFinite(num) ? { num, den } : null;
|
|
@@ -68,8 +63,6 @@ export async function probeVideo(tools, videoPath, log = () => { }) {
|
|
|
68
63
|
frames = Math.round(durationSec * fps.value);
|
|
69
64
|
log('warning: nb_frames missing, using duration x fps');
|
|
70
65
|
}
|
|
71
|
-
// A NaN frame count would flow into renderVideo (zero workers, empty
|
|
72
|
-
// ffmpeg input) and fail much later with a confusing message.
|
|
73
66
|
if (!Number.isFinite(frames) || frames <= 0) {
|
|
74
67
|
throw new Error(`could not determine the frame count of ${videoPath} ` +
|
|
75
68
|
'(nb_frames missing and duration unusable)');
|
|
@@ -108,7 +101,6 @@ async function probeRateFrames(ffprobe, file) {
|
|
|
108
101
|
], { maxBuffer: 1 << 20 });
|
|
109
102
|
return stdout.trim();
|
|
110
103
|
}
|
|
111
|
-
// Missing or unreadable outputs count as a mismatch, not an error.
|
|
112
104
|
export async function outputMatchesSource(tools, src, out) {
|
|
113
105
|
try {
|
|
114
106
|
const [srcRate, srcFrames] = (await probeRateFrames(tools.ffprobe, src)).split(',');
|
package/dist/fftools.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
// Where the ffmpeg and ffprobe executables come from at runtime: an explicit
|
|
2
|
-
// override, then the embedded binaries (the packaged app's extraResources, or
|
|
3
|
-
// the optional ffmpeg-ffprobe-static package in dev/CLI installs), then PATH.
|
|
4
|
-
// Pure decision core with an injectable environment so the resolution order is
|
|
5
|
-
// testable without touching the filesystem or spawning anything.
|
|
6
1
|
import fs from 'node:fs';
|
|
7
2
|
import { createRequire } from 'node:module';
|
|
8
3
|
import path from 'node:path';
|
|
9
|
-
// A bare command name defers to spawn's PATH lookup; anything that looks like
|
|
10
|
-
// a path is the documented `<path>` override and must name a real file.
|
|
11
4
|
function isPathLike(value) {
|
|
12
5
|
return value.includes('/') || value.includes('\\') || path.isAbsolute(value);
|
|
13
6
|
}
|
|
@@ -31,9 +24,6 @@ function packagedCandidate(tool) {
|
|
|
31
24
|
const resourcesPath = process.resourcesPath;
|
|
32
25
|
return resourcesPath ? path.join(resourcesPath, 'ff', exeName(tool)) : null;
|
|
33
26
|
}
|
|
34
|
-
// The optional ffmpeg-ffprobe-static package may be absent (unsupported
|
|
35
|
-
// platform, --omit=optional, a failed install download) and must never crash
|
|
36
|
-
// module loading: resolve it lazily.
|
|
37
27
|
function devCandidate(tool) {
|
|
38
28
|
try {
|
|
39
29
|
const mod = createRequire(import.meta.url)('ffmpeg-ffprobe-static');
|
package/dist/geo.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const EARTH_RADIUS_M = 6371008.8; // mean Earth radius
|
|
1
|
+
const EARTH_RADIUS_M = 6371008.8;
|
|
3
2
|
const DEG_TO_RAD = Math.PI / 180;
|
|
4
3
|
const RAD_TO_DEG = 180 / Math.PI;
|
|
5
|
-
//
|
|
6
|
-
// sidecar and CAM meta alike): a finite WGS84 pair in range that is not
|
|
7
|
-
// exactly the (0, 0) "no GPS lock" placeholder DJI writes before the first
|
|
8
|
-
// fix. Near-equator and near-prime-meridian coordinates are real fixes;
|
|
9
|
-
// out-of-range values never are.
|
|
4
|
+
// (0, 0) is DJI's "no GPS lock" placeholder before the first fix, not a real fix.
|
|
10
5
|
export function isGpsFix(lat, lon) {
|
|
11
6
|
return (Number.isFinite(lat) &&
|
|
12
7
|
Number.isFinite(lon) &&
|
|
@@ -16,9 +11,6 @@ export function isGpsFix(lat, lon) {
|
|
|
16
11
|
lon < 180 &&
|
|
17
12
|
!(lat === 0 && lon === 0));
|
|
18
13
|
}
|
|
19
|
-
// The fix/no-lock decision as a value: a real fix or null. Parsers decide
|
|
20
|
-
// once at this point and carry `fix: LatLon | null` from there on, so no
|
|
21
|
-
// downstream code re-litigates coordinates or defends half-set pairs.
|
|
22
14
|
export function gpsFix(lat, lon) {
|
|
23
15
|
return lat !== null && lon !== null && isGpsFix(lat, lon) ? { lat, lon } : null;
|
|
24
16
|
}
|
|
@@ -31,7 +23,6 @@ export function haversineM(a, b) {
|
|
|
31
23
|
Math.cos(latARad) * Math.cos(latBRad) * Math.sin(deltaLonRad / 2) ** 2;
|
|
32
24
|
return 2 * EARTH_RADIUS_M * Math.asin(Math.min(1, Math.sqrt(haversine)));
|
|
33
25
|
}
|
|
34
|
-
// Initial bearing, degrees clockwise from north, range [0, 360).
|
|
35
26
|
export function bearingDeg(a, b) {
|
|
36
27
|
const latARad = a.lat * DEG_TO_RAD;
|
|
37
28
|
const latBRad = b.lat * DEG_TO_RAD;
|
|
@@ -52,8 +43,7 @@ export function circularMeanDeg(degList) {
|
|
|
52
43
|
return degList[0] ?? 0;
|
|
53
44
|
return (Math.atan2(sumSin, sumCos) * RAD_TO_DEG + 360) % 360;
|
|
54
45
|
}
|
|
55
|
-
// Web Mercator (EPSG:3857) global
|
|
56
|
-
// origin at the north-west corner (Leaflet convention).
|
|
46
|
+
// Web Mercator (EPSG:3857) global pixels, 256 px tiles, NW origin (Leaflet convention).
|
|
57
47
|
export function project(lon, lat, zoom) {
|
|
58
48
|
const scale = 256 * 2 ** zoom;
|
|
59
49
|
const x = ((lon + 180) / 360) * scale;
|
package/dist/inputs.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
// The one recording-extension rule: the CLI input scan and the app's pick
|
|
4
|
-
// check share it, so accepting another container (e.g. .MOV) is one edit.
|
|
5
3
|
export function isRecordingName(name) {
|
|
6
4
|
return name.toLowerCase().endsWith('.mp4');
|
|
7
5
|
}
|
|
8
|
-
// The recording's stem: sidecar lookup and output naming both key on it.
|
|
9
6
|
export function videoBaseName(filePath) {
|
|
10
7
|
return path.basename(filePath).replace(/\.[^.]+$/, '');
|
|
11
8
|
}
|
|
12
|
-
// Sidecar lookup matches the video basename, case-insensitively (.SRT vs .srt).
|
|
13
9
|
export function findSrtSidecar(videoPath) {
|
|
14
10
|
const dir = path.dirname(videoPath);
|
|
15
11
|
const base = videoBaseName(videoPath);
|
package/dist/manual/anchors.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
// GitHub-compatible heading anchors: the same slug GitHub derives for a
|
|
2
|
-
// heading so in-repo links and in-app links resolve to the same anchor.
|
|
3
1
|
const SLUG_STRIP = /[^\p{L}\p{N}\s_-]/gu;
|
|
4
|
-
/** The anchor GitHub gives a heading of plain `text`. */
|
|
5
2
|
export function githubSlug(text) {
|
|
6
3
|
return text
|
|
7
4
|
.toLowerCase()
|
|
8
5
|
.replace(SLUG_STRIP, '')
|
|
9
6
|
.replace(/ /g, '-');
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
* Slugs one document's headings with GitHub's duplicate rule: the first
|
|
13
|
-
* "Foo" stays "foo", later ones become "foo-1", "foo-2", ...
|
|
14
|
-
*/
|
|
8
|
+
// GitHub's duplicate rule: the first "Foo" stays "foo", later ones become "foo-1", "foo-2", ...
|
|
15
9
|
export function createSlugger() {
|
|
16
10
|
const seen = new Map();
|
|
17
11
|
return (text) => {
|
package/dist/manual/build.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// The manual build: reads docs/user/*.md and docs/images, validates the
|
|
2
|
-
// corpus, then emits the typed UI module and the bundled images. Imperative
|
|
3
|
-
// shell over the pure compiler; paths are injectable so tests run it against
|
|
4
|
-
// a temporary corpus.
|
|
5
1
|
import fs from 'node:fs';
|
|
6
2
|
import path from 'node:path';
|
|
7
3
|
import { fileURLToPath } from 'node:url';
|
|
@@ -9,7 +5,6 @@ import { compileMarkdown } from './markdown.js';
|
|
|
9
5
|
import { bundleModuleSource } from './module.js';
|
|
10
6
|
import { navFromIndex } from './nav.js';
|
|
11
7
|
import { pageSlugOf, sourceNameOf, validateCorpus } from './links.js';
|
|
12
|
-
/** The repository's real paths, resolved from a built or source tree. */
|
|
13
8
|
export function defaultManualPaths(root) {
|
|
14
9
|
return {
|
|
15
10
|
userDir: path.join(root, 'docs', 'user'),
|
|
@@ -43,7 +38,6 @@ export function buildManual(paths) {
|
|
|
43
38
|
if (issues.length > 0) {
|
|
44
39
|
throw new Error(`manual corpus has ${issues.length} issue(s):\n${issues.map((i) => ` - ${i}`).join('\n')}`);
|
|
45
40
|
}
|
|
46
|
-
// The nav comes from the index; pages sort by slug so the bundle is stable.
|
|
47
41
|
const bundle = {
|
|
48
42
|
nav: index ? navFromIndex(index) : [],
|
|
49
43
|
pages: {},
|
package/dist/manual/cliref.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// The generated CLI/config reference: one table over the option vocabulary in
|
|
2
|
-
// src/config.ts, plus the config-file flag. The result is checked in as
|
|
3
|
-
// docs/user/cli-reference.md so GitHub renders it; a unit test compares the
|
|
4
|
-
// checked-in file against this generator so the two cannot drift.
|
|
5
1
|
import { CONFIG_FILE_OPTION, CONFIG_OPTIONS, cliDefaultOf } from '../config.js';
|
|
6
2
|
function defaultCell(key) {
|
|
7
3
|
const value = cliDefaultOf(key);
|
|
@@ -10,8 +6,6 @@ function defaultCell(key) {
|
|
|
10
6
|
return value === '' ? '—' : `\`${value}\``;
|
|
11
7
|
}
|
|
12
8
|
function describe(row) {
|
|
13
|
-
// Angle brackets in help text would read as HTML on GitHub; the entity form
|
|
14
|
-
// renders back to "<" and ">" everywhere.
|
|
15
9
|
const help = row.cli.help.replace(/</g, '<').replace(/>/g, '>');
|
|
16
10
|
return row.cli.choices ? `${help} (choices: ${row.cli.choices.join(', ')})` : help;
|
|
17
11
|
}
|
package/dist/manual/links.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
// Manual reference rules: what an internal link or image may point at, and
|
|
2
|
-
// the pure validation that keeps the checked-in corpus consistent. The
|
|
3
|
-
// compiler rewrites what parses here; validation then proves every reference
|
|
4
|
-
// resolves inside the corpus.
|
|
5
1
|
const SCHEME_RX = /^[a-z][a-z0-9+.-]*:/i;
|
|
6
|
-
/** README.md is the index page "index"; foo.md is "foo". */
|
|
7
2
|
export function pageSlugOf(file) {
|
|
8
3
|
const base = file.split('/').pop() ?? file;
|
|
9
4
|
return base === 'README.md' ? 'index' : base.replace(/\.md$/, '');
|
|
10
5
|
}
|
|
11
|
-
/** True for links that leave the manual (web, mail). */
|
|
12
6
|
export function isExternalTarget(raw) {
|
|
13
7
|
return SCHEME_RX.test(raw);
|
|
14
8
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Parses an internal Markdown link target: "foo.md", "foo.md#bar", "#bar"
|
|
17
|
-
* (same page). Anything else returns null and counts as unknown.
|
|
18
|
-
*/
|
|
19
9
|
export function parsePageLink(raw, currentSlug) {
|
|
20
10
|
const [path, hash, ...rest] = raw.split('#');
|
|
21
11
|
if (rest.length > 0)
|
|
@@ -28,16 +18,10 @@ export function parsePageLink(raw, currentSlug) {
|
|
|
28
18
|
return null;
|
|
29
19
|
return { slug: pageSlugOf(clean), anchor };
|
|
30
20
|
}
|
|
31
|
-
/** Parses an image target: "../images/foo.jpg" becomes "foo.jpg". */
|
|
32
21
|
export function parseImageRef(raw) {
|
|
33
22
|
const match = /^\.\.\/images\/([^/?#]+)$/.exec(raw);
|
|
34
23
|
return match ? (match[1] ?? null) : null;
|
|
35
24
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Validates every reference of every compiled page against the corpus:
|
|
38
|
-
* internal links resolve to a page, anchors to a heading in that page, images
|
|
39
|
-
* to a file in `imageFiles`. Unknown targets are rejected outright.
|
|
40
|
-
*/
|
|
41
25
|
export function validateCorpus(pages, imageFiles) {
|
|
42
26
|
const bySlug = new Map(pages.map((p) => [p.slug, p]));
|
|
43
27
|
const issues = [];
|
|
@@ -70,7 +54,6 @@ export function validateCorpus(pages, imageFiles) {
|
|
|
70
54
|
}
|
|
71
55
|
return issues;
|
|
72
56
|
}
|
|
73
|
-
/** The Markdown file name a slug was compiled from. */
|
|
74
57
|
export function sourceNameOf(slug) {
|
|
75
58
|
return slug === 'index' ? 'README.md' : `${slug}.md`;
|
|
76
59
|
}
|
package/dist/manual/markdown.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// The one Markdown adapter: GFM in, sanitized HTML plus structured references
|
|
2
|
-
// out. Raw HTML is escaped so the manual stays plain GitHub Flavored Markdown,
|
|
3
|
-
// internal links become data-attribute navigations the help overlay routes,
|
|
4
|
-
// and images point at bundled assets. Everything here is pure: one source
|
|
5
|
-
// string in, one page model out.
|
|
6
1
|
import { Marked } from 'marked';
|
|
7
2
|
import { createSlugger } from './anchors.js';
|
|
8
3
|
import { isExternalTarget, parseImageRef, parsePageLink } from './links.js';
|
|
@@ -12,7 +7,6 @@ function escapeHtml(value) {
|
|
|
12
7
|
function escapeAttr(value) {
|
|
13
8
|
return escapeHtml(value).replace(/"/g, '"');
|
|
14
9
|
}
|
|
15
|
-
/** The readable text of inline tokens, for titles, slugs and link labels. */
|
|
16
10
|
function inlineText(tokens) {
|
|
17
11
|
if (!tokens)
|
|
18
12
|
return '';
|
|
@@ -83,14 +77,12 @@ export function compileMarkdown(source, slug) {
|
|
|
83
77
|
return `<img src="/manual/images/${escapeAttr(file)}" alt="${escapeAttr(text)}"${titleAttr(title)}>`;
|
|
84
78
|
},
|
|
85
79
|
html({ text }) {
|
|
86
|
-
// Comments disappear like on GitHub; any other raw HTML is escaped
|
|
87
|
-
// it shows as text instead of markup.
|
|
80
|
+
// Comments disappear like on GitHub; any other raw HTML is escaped.
|
|
88
81
|
return /^<!--[\s\S]*-->$/.test(text) ? '' : escapeHtml(text);
|
|
89
82
|
},
|
|
90
83
|
},
|
|
91
84
|
});
|
|
92
|
-
//
|
|
93
|
-
// only the two-step form types the output as a plain string.
|
|
85
|
+
// Two-step form instead of parse(): only parser(lexer(...)) types the output as a plain string.
|
|
94
86
|
const html = md.parser(md.lexer(source));
|
|
95
87
|
const title = headings.find((h) => h.level === 1)?.text ?? '';
|
|
96
88
|
return {
|
package/dist/manual/model.js
CHANGED
package/dist/manual/module.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Serialization of the manual bundle into the typed module the UI bundles.
|
|
2
|
-
// The output is deterministic (stable JSON, fixed header) so regeneration is
|
|
3
|
-
// idempotent and a drift check can byte-compare.
|
|
4
1
|
export function bundleModuleSource(bundle) {
|
|
5
2
|
const header = '// Generated by src/manual/build.ts from docs/user/*.md. Do not edit.\n' +
|
|
6
3
|
"import type { ManualBundle } from '../../../../src/manual/model.js';\n\n";
|
package/dist/manual/nav.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Navigation derivation: the manual's nav is the ordered link list of the
|
|
2
|
-
// index page (docs/user/README.md), with the index itself as the first entry.
|
|
3
1
|
export function navFromIndex(index) {
|
|
4
2
|
const nav = [{ slug: index.slug, label: index.page.title }];
|
|
5
3
|
const seen = new Set([index.slug]);
|
package/dist/manual/reference.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
// Writes the checked-in CLI/config reference from the option vocabulary.
|
|
2
|
-
// Run "npm run docs:reference" after changing src/config.ts; a unit test
|
|
3
|
-
// fails when the checked-in file no longer matches the generator.
|
|
4
1
|
import fs from 'node:fs';
|
|
5
2
|
import path from 'node:path';
|
|
6
3
|
import { fileURLToPath } from 'node:url';
|
|
7
4
|
import { generateCliReference } from './cliref.js';
|
|
8
|
-
|
|
5
|
+
function writeReference(file) {
|
|
9
6
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
10
7
|
fs.writeFileSync(file, generateCliReference());
|
|
11
8
|
}
|