drone-path 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +16 -11
  3. package/app/ipc.d.mts +43 -0
  4. package/app/ipc.mjs +92 -54
  5. package/app/main.mjs +6 -6
  6. package/dist/appsession.js +17 -24
  7. package/dist/appstate.js +2 -1
  8. package/dist/buildinfo.js +9 -16
  9. package/dist/cammeta-decode.js +237 -0
  10. package/dist/cammeta.js +4 -242
  11. package/dist/cli.js +37 -11
  12. package/dist/config.js +181 -82
  13. package/dist/configfile.js +20 -7
  14. package/dist/errors.js +30 -0
  15. package/dist/exec-tool.js +13 -0
  16. package/dist/exportjob.js +7 -7
  17. package/dist/{fftools.js → ffmpeg-tools.js} +5 -4
  18. package/dist/{ff.js → ffmpeg.js} +12 -10
  19. package/dist/geo.js +1 -1
  20. package/dist/logging.js +1 -0
  21. package/dist/manual/build.js +5 -10
  22. package/dist/manual/cliref.js +4 -1
  23. package/dist/manual/reference.js +6 -11
  24. package/dist/{run.js → pipeline.js} +59 -39
  25. package/dist/{proto.js → protobuf-wire.js} +5 -5
  26. package/dist/range.js +3 -3
  27. package/dist/{page.js → render-page.js} +2 -2
  28. package/dist/render.js +5 -18
  29. package/dist/renderer/boot.js +2 -2
  30. package/dist/renderer/dom.js +32 -10
  31. package/dist/renderer/scene.js +14 -6
  32. package/dist/restyle.js +1 -1
  33. package/dist/serve.js +1 -31
  34. package/dist/srt.js +2 -2
  35. package/dist/telemetry-json-schema.js +6 -11
  36. package/dist/telemetry-json.js +13 -0
  37. package/dist/telemetry-math.js +1 -1
  38. package/dist/{summary.js → telemetry-summary.js} +4 -4
  39. package/dist/telemetry.js +16 -6
  40. package/dist/track-format.js +13 -0
  41. package/dist/track-geojson.js +44 -0
  42. package/dist/track-gpx.js +34 -0
  43. package/dist/track-kml.js +47 -0
  44. package/dist/track-kmz.js +68 -0
  45. package/dist/track-write.js +41 -0
  46. package/dist/track.js +79 -0
  47. package/package.json +8 -8
  48. /package/dist/{inputs.js → recordings.js} +0 -0
package/dist/config.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { z } from 'zod';
2
+ export const MAP_STYLE_VALUES = ['satellite', 'topo'];
3
+ const VIEW_MODE_VALUES = ['follow', 'overview'];
4
+ const CAPTURE_FORMAT_VALUES = ['jpeg', 'png'];
5
+ export const CODEC_VALUES = ['h264', 'h265'];
6
+ export const QUALITY_VALUES = ['near-lossless', 'high', 'medium', 'low'];
7
+ export const ENCODER_PRESET_VALUES = ['medium', 'veryfast'];
2
8
  export const CONFIG_FILE_NAME = '.dronepath.json';
3
9
  export const CONFIG_FILE_OPTION = {
4
10
  flags: '--config <path>',
5
11
  help: 'config file (default: .dronepath.json discovered upward from the working directory)',
6
12
  };
7
- export const STYLE_VALUES = ['satellite', 'topo'];
8
- export const VIEW_VALUES = ['follow', 'overview'];
9
- const CAPTURE_VALUES = ['jpeg', 'png'];
10
- export const CODEC_VALUES = ['h264', 'h265'];
11
- export const QUALITY_VALUES = ['near-lossless', 'high', 'medium', 'low'];
12
- export const PRESET_VALUES = ['medium', 'veryfast'];
13
13
  export function parseHud(list) {
14
14
  const hud = { heading: false, alt: false, speed: false };
15
15
  if (!list || list.toLowerCase() === 'none')
@@ -29,7 +29,7 @@ export function parseHud(list) {
29
29
  }
30
30
  return hud;
31
31
  }
32
- export function resolveHudSpec(hud, hasAlt) {
32
+ export function resolveHudLayout(hud, hasAlt) {
33
33
  return hud.alt && !hasAlt ? { ...hud, alt: false } : hud;
34
34
  }
35
35
  export function hasAltitude(alt) {
@@ -64,7 +64,7 @@ export function strictShape(shape, wording) {
64
64
  : wording.invalid,
65
65
  });
66
66
  }
67
- export function numberValue(name) {
67
+ function numberValue(name) {
68
68
  return z.number({ error: invalidNumber(name) });
69
69
  }
70
70
  function stringValue(name) {
@@ -121,70 +121,100 @@ function patchHud(value, name) {
121
121
  ? parseHud(parseValue(stringValue(name), value))
122
122
  : parseValue(hudSpecSchema(name), value);
123
123
  }
124
+ // Literal-first on purpose: the mapped satisfies turns a missing or extra key
125
+ // into a compile error, so every RenderConfig key keeps exactly one normalizer.
126
+ export const OVERRIDE_NORMALIZERS = {
127
+ outDir: (v, name) => ({ outDir: parseValue(nullableStringValue(name), v) }),
128
+ outSuffix: (v, name) => ({ outSuffix: parseValue(stringValue(name), v) }),
129
+ width: (v, name) => ({ width: parseValue(numberValue(name), v) }),
130
+ height: (v, name) => ({ height: parseValue(numberValue(name), v) }),
131
+ style: (v, name) => ({ style: parseValue(enumValue(name, MAP_STYLE_VALUES), v) }),
132
+ view: (v, name) => ({ view: parseValue(enumValue(name, VIEW_MODE_VALUES), v) }),
133
+ zoom: (v, name) => ({ zoom: parseValue(numberValue(name), v) }),
134
+ zoomOut: (v, name) => ({ zoomOut: parseValue(numberValue(name), v) }),
135
+ introSec: (v, name) => ({ introSec: parseValue(numberValue(name), v) }),
136
+ outroSec: (v, name) => ({ outroSec: parseValue(numberValue(name), v) }),
137
+ trailColor: (v, name) => ({ trailColor: asTrailColor(v, name) }),
138
+ hud: (v, name) => ({ hud: parseHud(parseValue(stringValue(name), v)) }),
139
+ workers: (v, name) => ({ workers: parseValue(numberValue(name), v) }),
140
+ capture: (v, name) => ({ capture: parseValue(enumValue(name, CAPTURE_FORMAT_VALUES), v) }),
141
+ codec: (v, name) => ({ codec: parseValue(enumValue(name, CODEC_VALUES), v) }),
142
+ quality: (v, name) => ({ quality: parseValue(enumValue(name, QUALITY_VALUES), v) }),
143
+ preset: (v, name) => ({ preset: parseValue(enumValue(name, ENCODER_PRESET_VALUES), v) }),
144
+ tileCache: (v, name) => ({ tileCache: parseValue(stringValue(name), v) }),
145
+ browser: (v, name) => ({ browser: parseValue(nullableStringValue(name), v) }),
146
+ ffmpeg: (v, name) => ({ ffmpeg: parseValue(nullableStringValue(name), v) }),
147
+ ffprobe: (v, name) => ({ ffprobe: parseValue(nullableStringValue(name), v) }),
148
+ skipExisting: (v, name) => ({ skipExisting: parseValue(boolValue(name), v) }),
149
+ recurse: (v, name) => ({ recurse: parseValue(boolValue(name), v) }),
150
+ trackOut: (v, name) => ({ trackOut: parseValue(nullableStringValue(name), v) }),
151
+ json: (v, name) => ({ json: parseValue(boolValue(name), v) }),
152
+ quiet: (v, name) => ({ quiet: parseValue(boolValue(name), v) }),
153
+ };
124
154
  export const CONFIG_OPTIONS = [
125
155
  {
126
156
  key: 'outDir',
127
157
  cli: { flags: '--out-dir <dir>', help: 'output folder' },
128
158
  default: 'out',
129
- normalize: (v, name) => ({ outDir: parseValue(nullableStringValue(name), v) }),
159
+ normalize: OVERRIDE_NORMALIZERS.outDir,
130
160
  },
131
161
  {
132
162
  key: 'outSuffix',
133
163
  cli: { flags: '--out-suffix <suffix>', help: 'output name = <basename><suffix>.mp4' },
134
164
  default: '_map',
135
- normalize: (v, name) => ({ outSuffix: parseValue(stringValue(name), v) }),
165
+ normalize: OVERRIDE_NORMALIZERS.outSuffix,
136
166
  },
137
167
  {
138
168
  key: 'width',
139
169
  cli: { flags: '--width <px>', help: 'canvas width in pixels (rounded down to even)', parse: cliNumber },
140
170
  default: 768,
141
- normalize: (v, name) => ({ width: parseValue(numberValue(name), v) }),
171
+ normalize: OVERRIDE_NORMALIZERS.width,
142
172
  },
143
173
  {
144
174
  key: 'height',
145
175
  cli: { flags: '--height <px>', help: 'canvas height in pixels (rounded down to even)', parse: cliNumber },
146
176
  default: 768,
147
- normalize: (v, name) => ({ height: parseValue(numberValue(name), v) }),
177
+ normalize: OVERRIDE_NORMALIZERS.height,
148
178
  },
149
179
  {
150
180
  key: 'style',
151
- cli: { flags: '--style <name>', help: 'map look', choices: STYLE_VALUES },
181
+ cli: { flags: '--style <name>', help: 'map look', choices: MAP_STYLE_VALUES },
152
182
  default: 'satellite',
153
- normalize: (v, name) => ({ style: parseValue(enumValue(name, STYLE_VALUES), v) }),
183
+ normalize: OVERRIDE_NORMALIZERS.style,
154
184
  },
155
185
  {
156
186
  key: 'view',
157
187
  cli: {
158
188
  flags: '--view <mode>',
159
189
  help: 'follow: drone stays centered and the map slides under it; overview: static whole-track map',
160
- choices: VIEW_VALUES,
190
+ choices: VIEW_MODE_VALUES,
161
191
  },
162
192
  default: 'follow',
163
- normalize: (v, name) => ({ view: parseValue(enumValue(name, VIEW_VALUES), v) }),
193
+ normalize: OVERRIDE_NORMALIZERS.view,
164
194
  },
165
195
  {
166
196
  key: 'zoom',
167
197
  cli: { flags: '--zoom <n>', help: 'fixed view zoom level (0 = auto-fit to the track)', parse: cliNumber },
168
198
  default: 0,
169
- normalize: (v, name) => ({ zoom: parseValue(numberValue(name), v) }),
199
+ normalize: OVERRIDE_NORMALIZERS.zoom,
170
200
  },
171
201
  {
172
202
  key: 'zoomOut',
173
203
  cli: { flags: '--zoom-out <n>', help: 'auto-fit only: pull back n zoom levels', parse: cliNumber },
174
204
  default: 1,
175
- normalize: (v, name) => ({ zoomOut: parseValue(numberValue(name), v) }),
205
+ normalize: OVERRIDE_NORMALIZERS.zoomOut,
176
206
  },
177
207
  {
178
208
  key: 'introSec',
179
209
  cli: { flags: '--intro-sec <s>', help: 'intro: zoom in from one level out over s seconds', parse: cliNumber },
180
210
  default: 2,
181
- normalize: (v, name) => ({ introSec: parseValue(numberValue(name), v) }),
211
+ normalize: OVERRIDE_NORMALIZERS.introSec,
182
212
  },
183
213
  {
184
214
  key: 'outroSec',
185
215
  cli: { flags: '--outro-sec <s>', help: 'outro: zoom back out over s seconds', parse: cliNumber },
186
216
  default: 2,
187
- normalize: (v, name) => ({ outroSec: parseValue(numberValue(name), v) }),
217
+ normalize: OVERRIDE_NORMALIZERS.outroSec,
188
218
  },
189
219
  {
190
220
  key: 'trailColor',
@@ -193,7 +223,7 @@ export const CONFIG_OPTIONS = [
193
223
  help: 'trail color as hex, RGB or RGBA (e.g. e63946 or #e63946cc; default: the map style\'s color)',
194
224
  },
195
225
  default: null,
196
- normalize: (v, name) => ({ trailColor: asTrailColor(v, name) }),
226
+ normalize: OVERRIDE_NORMALIZERS.trailColor,
197
227
  },
198
228
  {
199
229
  key: 'hud',
@@ -202,61 +232,61 @@ export const CONFIG_OPTIONS = [
202
232
  help: 'comma list of heading,alt,speed - or none (alt hides when unavailable)',
203
233
  },
204
234
  default: { heading: true, alt: false, speed: false },
205
- normalize: (v, name) => ({ hud: parseHud(parseValue(stringValue(name), v)) }),
235
+ normalize: OVERRIDE_NORMALIZERS.hud,
206
236
  },
207
237
  {
208
238
  key: 'workers',
209
239
  cli: { flags: '--workers <n>', help: 'parallel browser pages', parse: cliNumber },
210
240
  default: 4,
211
- normalize: (v, name) => ({ workers: parseValue(numberValue(name), v) }),
241
+ normalize: OVERRIDE_NORMALIZERS.workers,
212
242
  },
213
243
  {
214
244
  key: 'capture',
215
- cli: { flags: '--capture <mode>', help: 'frame capture mode (canvas is parked)', choices: CAPTURE_VALUES },
245
+ cli: { flags: '--capture <mode>', help: 'frame capture mode (canvas is parked)', choices: CAPTURE_FORMAT_VALUES },
216
246
  default: 'jpeg',
217
- normalize: (v, name) => ({ capture: parseValue(enumValue(name, CAPTURE_VALUES), v) }),
247
+ normalize: OVERRIDE_NORMALIZERS.capture,
218
248
  },
219
249
  {
220
250
  key: 'codec',
221
251
  cli: { flags: '--codec <name>', help: 'video codec (mp4 container)', choices: CODEC_VALUES },
222
252
  default: 'h264',
223
- normalize: (v, name) => ({ codec: parseValue(enumValue(name, CODEC_VALUES), v) }),
253
+ normalize: OVERRIDE_NORMALIZERS.codec,
224
254
  },
225
255
  {
226
256
  key: 'quality',
227
257
  cli: { flags: '--quality <level>', help: 'encoding quality', choices: QUALITY_VALUES },
228
258
  default: 'high',
229
- normalize: (v, name) => ({ quality: parseValue(enumValue(name, QUALITY_VALUES), v) }),
259
+ normalize: OVERRIDE_NORMALIZERS.quality,
230
260
  },
231
261
  {
232
262
  key: 'preset',
233
- cli: { flags: '--preset <name>', help: 'encoding speed', choices: PRESET_VALUES },
263
+ cli: { flags: '--preset <name>', help: 'encoding speed', choices: ENCODER_PRESET_VALUES },
234
264
  default: 'medium',
235
- normalize: (v, name) => ({ preset: parseValue(enumValue(name, PRESET_VALUES), v) }),
265
+ normalize: OVERRIDE_NORMALIZERS.preset,
236
266
  },
237
267
  {
238
268
  key: 'tileCache',
239
269
  cli: { flags: '--tile-cache <dir>', help: 'tile cache directory (default: per-user cache dir)' },
240
270
  default: '',
241
- normalize: (v, name) => ({ tileCache: parseValue(stringValue(name), v) }),
271
+ normalize: OVERRIDE_NORMALIZERS.tileCache,
242
272
  },
243
273
  {
244
274
  key: 'browser',
245
275
  cli: { flags: '--browser <path>', help: 'Chromium/Chrome/Edge executable (default: system Chrome/Edge)' },
246
276
  default: null,
247
- normalize: (v, name) => ({ browser: parseValue(nullableStringValue(name), v) }),
277
+ normalize: OVERRIDE_NORMALIZERS.browser,
248
278
  },
249
279
  {
250
280
  key: 'ffmpeg',
251
281
  cli: { flags: '--ffmpeg <path>', help: 'ffmpeg executable (default: embedded binary, then PATH)' },
252
282
  default: null,
253
- normalize: (v, name) => ({ ffmpeg: parseValue(nullableStringValue(name), v) }),
283
+ normalize: OVERRIDE_NORMALIZERS.ffmpeg,
254
284
  },
255
285
  {
256
286
  key: 'ffprobe',
257
287
  cli: { flags: '--ffprobe <path>', help: 'ffprobe executable (default: embedded binary, then PATH)' },
258
288
  default: null,
259
- normalize: (v, name) => ({ ffprobe: parseValue(nullableStringValue(name), v) }),
289
+ normalize: OVERRIDE_NORMALIZERS.ffprobe,
260
290
  },
261
291
  {
262
292
  key: 'skipExisting',
@@ -265,37 +295,73 @@ export const CONFIG_OPTIONS = [
265
295
  help: 'skip recordings whose output already exists and matches the source',
266
296
  },
267
297
  default: false,
268
- normalize: (v, name) => ({ skipExisting: parseValue(boolValue(name), v) }),
298
+ normalize: OVERRIDE_NORMALIZERS.skipExisting,
269
299
  },
270
300
  {
271
301
  key: 'recurse',
272
302
  cli: { flags: '--recurse', help: 'scan input folders recursively' },
273
303
  default: false,
274
- normalize: (v, name) => ({ recurse: parseValue(boolValue(name), v) }),
304
+ normalize: OVERRIDE_NORMALIZERS.recurse,
275
305
  },
276
306
  {
277
- key: 'telemetryJson',
307
+ key: 'trackOut',
278
308
  cli: {
279
- flags: '--telemetry-json <file>',
280
- help: 'write one JSON document with per-frame telemetry to <file> (one recording per run)',
309
+ flags: '--track-out <file>',
310
+ help: 'write one flight track file to <file>, format from the extension: ' +
311
+ '.gpx, .geojson, .kml, .kmz or .json (the telemetry document; one recording per run)',
281
312
  },
282
313
  default: null,
283
- normalize: (v, name) => ({ telemetryJson: parseValue(nullableStringValue(name), v) }),
314
+ normalize: OVERRIDE_NORMALIZERS.trackOut,
284
315
  },
285
316
  {
286
317
  key: 'json',
287
318
  cli: { flags: '--json', help: 'print one NDJSON summary line per recording on stdout' },
288
319
  default: false,
289
- normalize: (v, name) => ({ json: parseValue(boolValue(name), v) }),
320
+ normalize: OVERRIDE_NORMALIZERS.json,
290
321
  },
291
322
  {
292
323
  key: 'quiet',
293
324
  cli: { flags: '-q, --quiet', help: 'suppress progress output' },
294
325
  default: false,
295
- normalize: (v, name) => ({ quiet: parseValue(boolValue(name), v) }),
326
+ normalize: OVERRIDE_NORMALIZERS.quiet,
296
327
  },
297
328
  ];
298
329
  const CLI_NUMBER_RX = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
330
+ // The deprecated spelling keeps working through the deprecation window: both
331
+ // spellings normalize into the one `trackOut` override key, use warns, and the
332
+ // spelling stays rejected once removed (the `trail`-key precedent).
333
+ export const TELEMETRY_JSON_ALIAS = {
334
+ inputKey: 'telemetryJson',
335
+ key: 'trackOut',
336
+ flags: '--telemetry-json <file>',
337
+ help: 'deprecated alias of --track-out <file>.json',
338
+ cliWarning: 'warning: --telemetry-json is deprecated; use --track-out <file>.json (the alias will be removed in a future version)',
339
+ fileWarning: 'warning: the telemetryJson key is deprecated; use trackOut (the key will be removed in a future version)',
340
+ };
341
+ /**
342
+ * Which spelling of the one trackOut key a raw override object uses. Both
343
+ * spellings within one origin are ambiguous and rejected.
344
+ */
345
+ export function trackOutSpellingOf(raw, origin) {
346
+ const alias = raw[TELEMETRY_JSON_ALIAS.inputKey] !== undefined;
347
+ const canonical = raw[TELEMETRY_JSON_ALIAS.key] !== undefined;
348
+ if (alias && canonical) {
349
+ throw new Error(`${TELEMETRY_JSON_ALIAS.inputKey} and ${TELEMETRY_JSON_ALIAS.key} cannot be combined in ${origin} (use ${TELEMETRY_JSON_ALIAS.key})`);
350
+ }
351
+ return alias ? 'telemetry-json' : canonical ? 'track-out' : null;
352
+ }
353
+ /**
354
+ * The merged effective config may use only one spelling of the one trackOut
355
+ * key - across the command line and the config file, not just within one of
356
+ * them.
357
+ */
358
+ export function assertOneTrackOutSpelling(entries) {
359
+ const used = new Set(entries.map((entry) => entry.spelling).filter(Boolean));
360
+ if (used.size > 1) {
361
+ throw new Error(`${TELEMETRY_JSON_ALIAS.flags.split(' ')[0]} and --track-out cannot be combined ` +
362
+ 'across the command line and the config file (use --track-out)');
363
+ }
364
+ }
299
365
  function cliNumber(raw) {
300
366
  if (typeof raw !== 'string' || !CLI_NUMBER_RX.test(raw.trim()))
301
367
  return raw;
@@ -314,15 +380,21 @@ export function cliDefaultOf(key) {
314
380
  }
315
381
  export const DEFAULT_CONFIG = Object.freeze(Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.default])));
316
382
  Object.freeze(DEFAULT_CONFIG.hud);
317
- const OVERRIDE_NORMALIZERS = Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.normalize]));
318
- const OVERRIDE_SHAPE = Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, z.unknown().optional()]));
319
- export function normalizeOverrides(raw, origin) {
383
+ const OVERRIDE_SHAPE = {
384
+ ...Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, z.unknown().optional()])),
385
+ // The deprecated alias is accepted as an input spelling only; it never
386
+ // becomes its own config key.
387
+ [TELEMETRY_JSON_ALIAS.inputKey]: z.unknown().optional(),
388
+ };
389
+ export function normalizeOverrides(raw, origin, onDeprecated) {
320
390
  parseValue(strictShape(OVERRIDE_SHAPE, {
321
391
  invalid: `invalid config overrides in ${origin}`,
322
392
  unknownKey: (key) => `unknown config key ${key} in ${origin}`,
323
393
  }), raw);
324
394
  const out = {};
325
395
  for (const key of Object.keys(raw)) {
396
+ if (key === TELEMETRY_JSON_ALIAS.inputKey)
397
+ continue;
326
398
  const normalize = OVERRIDE_NORMALIZERS[key];
327
399
  const value = raw[key];
328
400
  if (value === undefined)
@@ -331,11 +403,30 @@ export function normalizeOverrides(raw, origin) {
331
403
  continue;
332
404
  Object.assign(out, normalize(value, `${origin}: ${key}`));
333
405
  }
406
+ // Both spellings at once is ambiguous and rejected; the alias alone warns
407
+ // and lands on the canonical key.
408
+ const spelling = trackOutSpellingOf(raw, origin);
409
+ if (spelling === 'telemetry-json') {
410
+ onDeprecated?.(TELEMETRY_JSON_ALIAS.fileWarning);
411
+ Object.assign(out, OVERRIDE_NORMALIZERS.trackOut(raw[TELEMETRY_JSON_ALIAS.inputKey], `${origin}: ${TELEMETRY_JSON_ALIAS.inputKey}`));
412
+ }
334
413
  return out;
335
414
  }
336
415
  export function effectiveZoomOut(config) {
337
416
  return config.zoom > 0 ? 0 : config.zoomOut;
338
417
  }
418
+ const LOOK_SETTINGS_KEYS = [
419
+ 'style',
420
+ 'view',
421
+ 'zoom',
422
+ 'zoomOut',
423
+ 'hud',
424
+ 'introSec',
425
+ 'outroSec',
426
+ 'trailColor',
427
+ ];
428
+ const ENCODE_SETTINGS_KEYS = ['codec', 'quality', 'preset'];
429
+ export const SETTINGS_KEYS = [...LOOK_SETTINGS_KEYS, ...ENCODE_SETTINGS_KEYS];
339
430
  export function settingsPatchOf(config) {
340
431
  return {
341
432
  style: config.style,
@@ -351,19 +442,6 @@ export function settingsPatchOf(config) {
351
442
  preset: config.preset,
352
443
  };
353
444
  }
354
- export const SETTINGS_KEYS = [
355
- 'style',
356
- 'view',
357
- 'zoom',
358
- 'zoomOut',
359
- 'hud',
360
- 'introSec',
361
- 'outroSec',
362
- 'trailColor',
363
- 'codec',
364
- 'quality',
365
- 'preset',
366
- ];
367
445
  const SETTINGS_SHAPE = Object.fromEntries(SETTINGS_KEYS.map((key) => [key, z.unknown().optional()]));
368
446
  export function parseSettingsPatch(raw, origin) {
369
447
  parseValue(strictShape(SETTINGS_SHAPE, {
@@ -387,27 +465,23 @@ export function parseSettingsPatch(raw, origin) {
387
465
  }
388
466
  // The pick-request flavor of look settings: its error wording is the legacy
389
467
  // IPC wording, deliberately distinct from validateRenderConfig's CLI wording.
390
- export function parseLookSettings(raw) {
468
+ export function parseAppearanceSettings(raw) {
391
469
  const look = typeof raw === 'object' && raw !== null ? raw : {};
392
470
  const { style, view, hud } = look;
393
- const mapStyle = parseValue(z.enum(STYLE_VALUES, {
471
+ const mapStyle = parseValue(z.enum(MAP_STYLE_VALUES, {
394
472
  error: (issue) => `unknown map style: ${String(issue.input)}`,
395
473
  }), style);
396
- const viewMode = parseValue(z.enum(VIEW_VALUES, {
474
+ const viewMode = parseValue(z.enum(VIEW_MODE_VALUES, {
397
475
  error: (issue) => `unknown view: ${String(issue.input)}`,
398
476
  }), view);
399
477
  const zoom = parseValue(numberValue('zoom'), look.zoom);
400
478
  const zoomOut = parseValue(numberValue('zoom-out'), look.zoomOut);
401
- if (!(zoom >= 0))
402
- throw new Error('zoom must be >= 0 (0 = auto-fit)');
403
- if (!(zoomOut >= 0))
404
- throw new Error('zoom-out must be >= 0');
479
+ requireNonNegative(zoom, 'zoom must be >= 0 (0 = auto-fit)');
480
+ requireNonNegative(zoomOut, 'zoom-out must be >= 0');
405
481
  const introSec = parseValue(numberValue('intro'), look.introSec);
406
482
  const outroSec = parseValue(numberValue('outro'), look.outroSec);
407
- if (!(introSec >= 0))
408
- throw new Error('intro must be 0 or more');
409
- if (!(outroSec >= 0))
410
- throw new Error('outro must be 0 or more');
483
+ requireNonNegative(introSec, 'intro must be 0 or more');
484
+ requireNonNegative(outroSec, 'outro must be 0 or more');
411
485
  const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
412
486
  const chips = typeof hud === 'object' && hud !== null ? hud : {};
413
487
  return {
@@ -422,9 +496,12 @@ export function parseLookSettings(raw) {
422
496
  };
423
497
  }
424
498
  export const MIN_DIMENSION = 64;
425
- // Negated comparisons are NaN-safe (NaN would slip through <).
426
- export function validateDimensions(width, height) {
427
- if (!(width >= MIN_DIMENSION) || !(height >= MIN_DIMENSION)) {
499
+ export function isValidDimensions(width, height) {
500
+ // NaN-safe: the >= form fails for NaN, where a plain < would let it pass.
501
+ return width >= MIN_DIMENSION && height >= MIN_DIMENSION;
502
+ }
503
+ function validateDimensions(width, height) {
504
+ if (!isValidDimensions(width, height)) {
428
505
  throw new Error(`width and height must be at least ${MIN_DIMENSION}`);
429
506
  }
430
507
  }
@@ -434,27 +511,47 @@ export function normalizeDimensions(width, height) {
434
511
  height: Math.max(MIN_DIMENSION, 2 * Math.floor(height / 2)),
435
512
  };
436
513
  }
514
+ // One bounds rule for both validator wordings; the message travels with the
515
+ // call so the CLI and IPC surfaces keep their deliberately distinct text.
516
+ function isNonNegative(value) {
517
+ return value >= 0;
518
+ }
519
+ function requireNonNegative(value, message) {
520
+ if (!isNonNegative(value))
521
+ throw new Error(message);
522
+ }
523
+ function isValidWorkerCount(workers) {
524
+ return Number.isInteger(workers) && workers >= 1;
525
+ }
526
+ export function isValidRenderConfig(config) {
527
+ return (isValidDimensions(config.width, config.height) &&
528
+ isValidWorkerCount(config.workers) &&
529
+ isNonNegative(config.zoom) &&
530
+ isNonNegative(config.zoomOut) &&
531
+ isNonNegative(config.introSec) &&
532
+ isNonNegative(config.outroSec) &&
533
+ config.outSuffix !== '');
534
+ }
437
535
  export function validateRenderConfig(config) {
438
536
  validateDimensions(config.width, config.height);
439
- if (!Number.isInteger(config.workers) || config.workers < 1) {
537
+ if (!isValidWorkerCount(config.workers)) {
440
538
  throw new Error('workers must be a positive integer');
441
539
  }
442
- if (!(config.zoom >= 0))
443
- throw new Error('zoom must be >= 0 (0 = auto-fit)');
444
- if (!(config.zoomOut >= 0))
445
- throw new Error('zoom-out must be >= 0');
446
- if (!(config.introSec >= 0) || !(config.outroSec >= 0)) {
540
+ requireNonNegative(config.zoom, 'zoom must be >= 0 (0 = auto-fit)');
541
+ requireNonNegative(config.zoomOut, 'zoom-out must be >= 0');
542
+ if (!isNonNegative(config.introSec) || !isNonNegative(config.outroSec)) {
447
543
  throw new Error('intro-sec and outro-sec must be >= 0');
448
544
  }
449
545
  if (!config.outSuffix)
450
546
  throw new Error('out-suffix must not be empty');
451
547
  }
452
- export function assertValidFrameRange(range, name = 'frame range') {
548
+ function assertValidFrameRange(range, name = 'frame range') {
453
549
  if (!Number.isInteger(range.start) || !Number.isInteger(range.end)) {
454
550
  throw new Error(`invalid ${name}: start and end must be integer frame indices`);
455
551
  }
456
- if (range.start < 0 || range.start >= range.end) {
457
- throw new Error(`invalid ${name}: expected 0 <= start < end, got ${range.start}-${range.end}`);
552
+ // A single-frame span (start === end) is a valid export range.
553
+ if (range.start < 0 || range.start > range.end) {
554
+ throw new Error(`invalid ${name}: expected 0 <= start <= end, got ${range.start}-${range.end}`);
458
555
  }
459
556
  }
460
557
  export function parseFrameRange(raw, name = 'frame range') {
@@ -468,7 +565,7 @@ export function parseFrameRange(raw, name = 'frame range') {
468
565
  assertValidFrameRange(range, name);
469
566
  return range;
470
567
  }
471
- export function resolveRange(range, frames) {
568
+ export function resolveFrameRange(range, frames) {
472
569
  if (!range)
473
570
  return null;
474
571
  assertValidFrameRange(range);
@@ -478,8 +575,10 @@ export function resolveRange(range, frames) {
478
575
  return range;
479
576
  }
480
577
  const MAIN_OWNED_KEYS = [
578
+ // TELEMETRY_JSON_ALIAS.inputKey stays stripped as a legacy spelling of
579
+ // trackOut, so neither spelling can leak into an export request's config.
481
580
  'outDir', 'outSuffix', 'tileCache', 'browser', 'ffmpeg', 'ffprobe', 'workers', 'capture',
482
- 'skipExisting', 'recurse', 'telemetryJson', 'json', 'quiet',
581
+ 'skipExisting', 'recurse', 'trackOut', TELEMETRY_JSON_ALIAS.inputKey, 'json', 'quiet',
483
582
  ];
484
583
  function parseRequestConfig(raw, base) {
485
584
  if (typeof raw !== 'object' || raw === null) {
@@ -1,7 +1,8 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { userDataDir } from './apppaths.js';
4
- import { CONFIG_FILE_NAME, DEFAULT_CONFIG, normalizeDimensions, normalizeOverrides, validateRenderConfig, } from './config.js';
4
+ import { CONFIG_FILE_NAME, DEFAULT_CONFIG, assertOneTrackOutSpelling, normalizeDimensions, normalizeOverrides, trackOutSpellingOf, validateRenderConfig, } from './config.js';
5
+ import { errorMessage } from './errors.js';
5
6
  export function defaultTileCache() {
6
7
  const override = process.env['DRONEPATH_TILE_CACHE'];
7
8
  if (override)
@@ -20,13 +21,13 @@ export function discoverConfigFile(startDir) {
20
21
  dir = parent;
21
22
  }
22
23
  }
23
- export function loadConfigFile(file) {
24
+ export function loadConfigFile(file, onDeprecated) {
24
25
  let text;
25
26
  try {
26
27
  text = fs.readFileSync(file, 'utf8');
27
28
  }
28
29
  catch (e) {
29
- throw new Error(`cannot read config file ${file}: ${e.message}`, {
30
+ throw new Error(`cannot read config file ${file}: ${errorMessage(e)}`, {
30
31
  cause: e,
31
32
  });
32
33
  }
@@ -35,12 +36,16 @@ export function loadConfigFile(file) {
35
36
  raw = JSON.parse(text);
36
37
  }
37
38
  catch (e) {
38
- throw new Error(`config file is not valid JSON: ${file}: ${e.message}`, { cause: e });
39
+ throw new Error(`config file is not valid JSON: ${file}: ${errorMessage(e)}`, { cause: e });
39
40
  }
40
41
  if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
41
42
  throw new Error(`config file must contain a JSON object: ${file}`);
42
43
  }
43
- return normalizeOverrides(raw, file);
44
+ const input = raw;
45
+ return {
46
+ overrides: normalizeOverrides(input, file, onDeprecated),
47
+ trackOutSpelling: trackOutSpellingOf(input, file),
48
+ };
44
49
  }
45
50
  function mergeConfigLayers(fileCfg, cli) {
46
51
  return {
@@ -62,8 +67,16 @@ export function resolveConfig(opts) {
62
67
  const configPath = opts.configPath !== undefined && opts.configPath !== null
63
68
  ? path.resolve(cwd, opts.configPath)
64
69
  : discoverConfigFile(cwd);
65
- const fileCfg = configPath ? loadConfigFile(configPath) : {};
66
- const merged = mergeConfigLayers(fileCfg, opts.cli ?? {});
70
+ const fileLayer = configPath
71
+ ? loadConfigFile(configPath, opts.onDeprecated)
72
+ : { overrides: {}, trackOutSpelling: null };
73
+ // The merged effective config may use only one spelling of the trackOut
74
+ // key - across origins, not just within one of them.
75
+ assertOneTrackOutSpelling([
76
+ { origin: 'the config file', spelling: fileLayer.trackOutSpelling },
77
+ { origin: 'the command line', spelling: opts.cliTrackOutSpelling ?? null },
78
+ ]);
79
+ const merged = mergeConfigLayers(fileLayer.overrides, opts.cli ?? {});
67
80
  validateRenderConfig(merged);
68
81
  const normalized = {
69
82
  ...merged,
package/dist/errors.js CHANGED
@@ -2,3 +2,33 @@ export const ERROR_PREFIX = '[drone-path] ERROR: ';
2
2
  export function errorMessage(error) {
3
3
  return error instanceof Error ? error.message : String(error);
4
4
  }
5
+ // The backend-to-UI error protocol: ui/lib/errortext.ts builds its sentence
6
+ // patterns from these exact strings, so every producer spells its message
7
+ // through here — rewording one is greppable and cannot silently downgrade
8
+ // its UI sentence.
9
+ export const ERR_NO_RECORDING = 'no recording loaded';
10
+ export const ERR_EXPORT_ALREADY_RUNNING = 'an export is already running';
11
+ export const ERR_EXPORT_COULD_NOT_START = 'export could not start';
12
+ export const ERR_EXPORT_COULD_NOT_BE_CANCELED = 'export could not be canceled';
13
+ export const ERR_OUTPUT_OVERWRITES_SOURCE = 'the output must not overwrite the source recording';
14
+ export const ERR_OUTPUT_PATH_ABSOLUTE = 'output path must be absolute: ';
15
+ export const ERR_APP_BRIDGE_UNAVAILABLE = 'app bridge unavailable';
16
+ export const ERR_RENDER_CANCELED = 'render canceled';
17
+ export const ERR_NOT_READABLE_MP4 = 'not a readable .mp4 file: ';
18
+ export const ERR_NO_TELEMETRY = 'no telemetry found: ';
19
+ export const ERR_OUTPUT_VERIFICATION = 'output verification failed: ';
20
+ export const ERR_COULD_NOT_REPLACE = 'could not replace ';
21
+ export const ERR_RENDER_KEPT_AT = 'the finished render is at ';
22
+ export const ERR_NO_FRAME_RATE = 'could not determine the frame rate of the video';
23
+ export const ERR_UNKNOWN = 'unknown error';
24
+ // The mandated failure shell for generated-art tool entries (AGENTS.md): one
25
+ // ERROR line on stderr and process.exitCode = 1, never a mid-flow exit.
26
+ export async function runToolMain(fn) {
27
+ try {
28
+ await fn();
29
+ }
30
+ catch (e) {
31
+ process.stderr.write(`${ERROR_PREFIX}${errorMessage(e)}\n`);
32
+ process.exitCode = 1;
33
+ }
34
+ }
@@ -0,0 +1,13 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { promisify } from 'node:util';
3
+ const execFileAsync = promisify(execFile);
4
+ // One child-process seam for src/: command, argv and buffer budget pass
5
+ // through untouched, and the spawned error propagates unwrapped so each
6
+ // caller keeps its own { cause } wording. Tool output is text (utf8).
7
+ export async function runTool(command, args, opts) {
8
+ const result = await execFileAsync(command, args, opts);
9
+ return {
10
+ stdout: String(result?.stdout ?? ''),
11
+ stderr: String(result?.stderr ?? ''),
12
+ };
13
+ }