drone-path 0.9.0 → 0.11.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 +64 -0
- package/README.md +16 -14
- package/THIRD-PARTY-NOTICES.md +7 -7
- package/app/ipc.d.mts +43 -0
- package/app/ipc.mjs +216 -0
- package/app/main.mjs +10 -204
- package/dist/appsession.js +34 -75
- package/dist/appstate.js +24 -21
- package/dist/buildinfo.js +9 -16
- package/dist/cammeta-decode.js +237 -0
- package/dist/cammeta.js +8 -247
- package/dist/cli.js +40 -32
- package/dist/config.js +333 -173
- package/dist/configfile.js +20 -7
- package/dist/errors.js +30 -0
- package/dist/exec-tool.js +13 -0
- package/dist/exportjob.js +7 -7
- package/dist/{fftools.js → ffmpeg-tools.js} +5 -4
- package/dist/{ff.js → ffmpeg.js} +14 -29
- package/dist/frametime.js +32 -0
- package/dist/geo.js +1 -1
- package/dist/manual/build.js +5 -10
- package/dist/manual/cliref.js +4 -1
- package/dist/manual/reference.js +6 -11
- package/dist/{run.js → pipeline.js} +100 -143
- package/dist/png.js +1 -18
- package/dist/{proto.js → protobuf-wire.js} +5 -5
- package/dist/range.js +3 -3
- package/dist/{page.js → render-page.js} +2 -2
- package/dist/render.js +25 -115
- package/dist/renderer/boot.js +2 -2
- package/dist/renderer/dom.js +32 -10
- package/dist/renderer/scene.js +14 -6
- package/dist/restyle.js +1 -1
- package/dist/serve.js +1 -31
- package/dist/srt.js +2 -2
- package/dist/telemetry-json-schema.js +6 -11
- package/dist/telemetry-json.js +46 -27
- package/dist/telemetry-math.js +3 -2
- package/dist/{summary.js → telemetry-summary.js} +4 -4
- package/dist/telemetry.js +32 -18
- package/dist/tiles.js +30 -86
- package/dist/track-format.js +13 -0
- package/dist/track-geojson.js +44 -0
- package/dist/track-gpx.js +34 -0
- package/dist/track-kml.js +47 -0
- package/dist/track-kmz.js +68 -0
- package/dist/track-write.js +41 -0
- package/dist/track.js +79 -0
- package/package.json +13 -14
- package/dist/tracing.js +0 -184
- /package/dist/{renderer/leaflet.js → logging.js} +0 -0
- /package/dist/{inputs.js → recordings.js} +0 -0
package/dist/config.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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'];
|
|
1
8
|
export const CONFIG_FILE_NAME = '.dronepath.json';
|
|
2
9
|
export const CONFIG_FILE_OPTION = {
|
|
3
10
|
flags: '--config <path>',
|
|
4
11
|
help: 'config file (default: .dronepath.json discovered upward from the working directory)',
|
|
5
12
|
};
|
|
6
|
-
export const STYLE_VALUES = ['satellite', 'topo'];
|
|
7
|
-
export const VIEW_VALUES = ['follow', 'overview'];
|
|
8
|
-
const CAPTURE_VALUES = ['jpeg', 'png'];
|
|
9
|
-
export const CODEC_VALUES = ['h264', 'h265'];
|
|
10
|
-
export const QUALITY_VALUES = ['near-lossless', 'high', 'medium', 'low'];
|
|
11
|
-
export const PRESET_VALUES = ['medium', 'veryfast'];
|
|
12
13
|
export function parseHud(list) {
|
|
13
14
|
const hud = { heading: false, alt: false, speed: false };
|
|
14
15
|
if (!list || list.toLowerCase() === 'none')
|
|
@@ -28,7 +29,7 @@ export function parseHud(list) {
|
|
|
28
29
|
}
|
|
29
30
|
return hud;
|
|
30
31
|
}
|
|
31
|
-
export function
|
|
32
|
+
export function resolveHudLayout(hud, hasAlt) {
|
|
32
33
|
return hud.alt && !hasAlt ? { ...hud, alt: false } : hud;
|
|
33
34
|
}
|
|
34
35
|
export function hasAltitude(alt) {
|
|
@@ -44,120 +45,176 @@ export function formatHud(hud) {
|
|
|
44
45
|
parts.push('speed');
|
|
45
46
|
return parts.length ? parts.join(',') : 'none';
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const invalidValue = (name) => (issue) => `invalid value for ${name}: ${String(issue.input)}`;
|
|
49
|
+
const invalidNumber = (name) => (issue) => `invalid number for ${name}: ${String(issue.input)}`;
|
|
50
|
+
export function parseValue(schema, value) {
|
|
51
|
+
const result = schema.safeParse(value);
|
|
52
|
+
if (result.success)
|
|
53
|
+
return result.data;
|
|
54
|
+
// The legacy key loops ran before the value checks; surface an unknown-key
|
|
55
|
+
// issue first so multi-error input keeps reporting in that order.
|
|
56
|
+
const issue = result.error.issues.find((i) => i.code === 'unrecognized_keys') ??
|
|
57
|
+
result.error.issues[0];
|
|
58
|
+
throw new Error(issue.message, { cause: result.error });
|
|
52
59
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
export function strictShape(shape, wording) {
|
|
61
|
+
return z.strictObject(shape, {
|
|
62
|
+
error: (issue) => issue.code === 'unrecognized_keys'
|
|
63
|
+
? wording.unknownKey(issue.keys[0])
|
|
64
|
+
: wording.invalid,
|
|
65
|
+
});
|
|
58
66
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
throw new Error(`invalid value for ${name}: ${String(value)}`);
|
|
62
|
-
}
|
|
63
|
-
return value;
|
|
67
|
+
function numberValue(name) {
|
|
68
|
+
return z.number({ error: invalidNumber(name) });
|
|
64
69
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return value;
|
|
70
|
+
function stringValue(name) {
|
|
71
|
+
return z
|
|
72
|
+
.string({ error: invalidValue(name) })
|
|
73
|
+
.min(1, { error: invalidValue(name) });
|
|
70
74
|
}
|
|
71
|
-
function
|
|
72
|
-
|
|
73
|
-
throw new Error(`invalid value for ${name}: ${String(value)} (use ${allowed.join(' | ')})`);
|
|
74
|
-
}
|
|
75
|
-
return value;
|
|
75
|
+
function boolValue(name) {
|
|
76
|
+
return z.boolean({ error: invalidValue(name) });
|
|
76
77
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
function enumValue(name, values) {
|
|
79
|
+
return z.enum(values, {
|
|
80
|
+
error: (issue) => `invalid value for ${name}: ${String(issue.input)} (use ${values.join(' | ')})`,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function nullableStringValue(name) {
|
|
84
|
+
return z
|
|
85
|
+
.nullable(z.string({ error: invalidValue(name) }))
|
|
86
|
+
.transform((value) => (value === '' ? null : value));
|
|
87
|
+
}
|
|
88
|
+
// The legacy key loops ran Object.keys on any object, arrays included;
|
|
89
|
+
// spreading keeps exactly those keys visible to the strict shapes below.
|
|
90
|
+
const keyedObjectInput = (value) => typeof value === 'object' && value !== null ? { ...value } : value;
|
|
91
|
+
// The whitespace tolerance matches the legacy trim-before-match so the error
|
|
92
|
+
// can echo the raw untrimmed input.
|
|
93
|
+
const TRAIL_COLOR_RX = /^\s*#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})\s*$/i;
|
|
94
|
+
function canonicalTrailColor(value) {
|
|
95
|
+
const hex = value.trim().replace(/^#/, '').toLowerCase();
|
|
96
|
+
return `#${hex.length <= 4 ? [...hex].map((c) => c + c).join('') : hex}`;
|
|
97
|
+
}
|
|
98
|
+
function trailColorValue(name) {
|
|
99
|
+
const bad = (issue) => `invalid value for ${name}: ${String(issue.input)} (use hex like #e63946 or #e63946cc)`;
|
|
100
|
+
return z
|
|
101
|
+
.union([z.null(), z.literal(''), z.string().regex(TRAIL_COLOR_RX, { error: bad })], { error: bad })
|
|
102
|
+
.transform((value) => value === null || value === '' ? null : canonicalTrailColor(value));
|
|
81
103
|
}
|
|
82
|
-
const TRAIL_COLOR_RX = /^#?([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
83
104
|
export function asTrailColor(value, name) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
return parseValue(trailColorValue(name), value);
|
|
106
|
+
}
|
|
107
|
+
function hudSpecSchema(name) {
|
|
108
|
+
return z.preprocess(keyedObjectInput, strictShape({
|
|
109
|
+
heading: boolValue(`${name}: heading`),
|
|
110
|
+
alt: boolValue(`${name}: alt`),
|
|
111
|
+
speed: boolValue(`${name}: speed`),
|
|
112
|
+
}, {
|
|
113
|
+
invalid: `invalid value for ${name}`,
|
|
114
|
+
unknownKey: (key) => `unknown key ${key} in ${name}`,
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
function patchHud(value, name) {
|
|
118
|
+
if (value === undefined || value === null)
|
|
119
|
+
return undefined;
|
|
120
|
+
return typeof value === 'string'
|
|
121
|
+
? parseHud(parseValue(stringValue(name), value))
|
|
122
|
+
: parseValue(hudSpecSchema(name), value);
|
|
96
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
|
+
};
|
|
97
154
|
export const CONFIG_OPTIONS = [
|
|
98
155
|
{
|
|
99
156
|
key: 'outDir',
|
|
100
157
|
cli: { flags: '--out-dir <dir>', help: 'output folder' },
|
|
101
158
|
default: 'out',
|
|
102
|
-
normalize:
|
|
159
|
+
normalize: OVERRIDE_NORMALIZERS.outDir,
|
|
103
160
|
},
|
|
104
161
|
{
|
|
105
162
|
key: 'outSuffix',
|
|
106
163
|
cli: { flags: '--out-suffix <suffix>', help: 'output name = <basename><suffix>.mp4' },
|
|
107
164
|
default: '_map',
|
|
108
|
-
normalize:
|
|
165
|
+
normalize: OVERRIDE_NORMALIZERS.outSuffix,
|
|
109
166
|
},
|
|
110
167
|
{
|
|
111
168
|
key: 'width',
|
|
112
169
|
cli: { flags: '--width <px>', help: 'canvas width in pixels (rounded down to even)', parse: cliNumber },
|
|
113
170
|
default: 768,
|
|
114
|
-
normalize:
|
|
171
|
+
normalize: OVERRIDE_NORMALIZERS.width,
|
|
115
172
|
},
|
|
116
173
|
{
|
|
117
174
|
key: 'height',
|
|
118
175
|
cli: { flags: '--height <px>', help: 'canvas height in pixels (rounded down to even)', parse: cliNumber },
|
|
119
176
|
default: 768,
|
|
120
|
-
normalize:
|
|
177
|
+
normalize: OVERRIDE_NORMALIZERS.height,
|
|
121
178
|
},
|
|
122
179
|
{
|
|
123
180
|
key: 'style',
|
|
124
|
-
cli: { flags: '--style <name>', help: 'map look', choices:
|
|
181
|
+
cli: { flags: '--style <name>', help: 'map look', choices: MAP_STYLE_VALUES },
|
|
125
182
|
default: 'satellite',
|
|
126
|
-
normalize:
|
|
183
|
+
normalize: OVERRIDE_NORMALIZERS.style,
|
|
127
184
|
},
|
|
128
185
|
{
|
|
129
186
|
key: 'view',
|
|
130
187
|
cli: {
|
|
131
188
|
flags: '--view <mode>',
|
|
132
189
|
help: 'follow: drone stays centered and the map slides under it; overview: static whole-track map',
|
|
133
|
-
choices:
|
|
190
|
+
choices: VIEW_MODE_VALUES,
|
|
134
191
|
},
|
|
135
192
|
default: 'follow',
|
|
136
|
-
normalize:
|
|
193
|
+
normalize: OVERRIDE_NORMALIZERS.view,
|
|
137
194
|
},
|
|
138
195
|
{
|
|
139
196
|
key: 'zoom',
|
|
140
197
|
cli: { flags: '--zoom <n>', help: 'fixed view zoom level (0 = auto-fit to the track)', parse: cliNumber },
|
|
141
198
|
default: 0,
|
|
142
|
-
normalize:
|
|
199
|
+
normalize: OVERRIDE_NORMALIZERS.zoom,
|
|
143
200
|
},
|
|
144
201
|
{
|
|
145
202
|
key: 'zoomOut',
|
|
146
203
|
cli: { flags: '--zoom-out <n>', help: 'auto-fit only: pull back n zoom levels', parse: cliNumber },
|
|
147
204
|
default: 1,
|
|
148
|
-
normalize:
|
|
205
|
+
normalize: OVERRIDE_NORMALIZERS.zoomOut,
|
|
149
206
|
},
|
|
150
207
|
{
|
|
151
208
|
key: 'introSec',
|
|
152
209
|
cli: { flags: '--intro-sec <s>', help: 'intro: zoom in from one level out over s seconds', parse: cliNumber },
|
|
153
210
|
default: 2,
|
|
154
|
-
normalize:
|
|
211
|
+
normalize: OVERRIDE_NORMALIZERS.introSec,
|
|
155
212
|
},
|
|
156
213
|
{
|
|
157
214
|
key: 'outroSec',
|
|
158
215
|
cli: { flags: '--outro-sec <s>', help: 'outro: zoom back out over s seconds', parse: cliNumber },
|
|
159
216
|
default: 2,
|
|
160
|
-
normalize:
|
|
217
|
+
normalize: OVERRIDE_NORMALIZERS.outroSec,
|
|
161
218
|
},
|
|
162
219
|
{
|
|
163
220
|
key: 'trailColor',
|
|
@@ -166,7 +223,7 @@ export const CONFIG_OPTIONS = [
|
|
|
166
223
|
help: 'trail color as hex, RGB or RGBA (e.g. e63946 or #e63946cc; default: the map style\'s color)',
|
|
167
224
|
},
|
|
168
225
|
default: null,
|
|
169
|
-
normalize:
|
|
226
|
+
normalize: OVERRIDE_NORMALIZERS.trailColor,
|
|
170
227
|
},
|
|
171
228
|
{
|
|
172
229
|
key: 'hud',
|
|
@@ -175,61 +232,61 @@ export const CONFIG_OPTIONS = [
|
|
|
175
232
|
help: 'comma list of heading,alt,speed - or none (alt hides when unavailable)',
|
|
176
233
|
},
|
|
177
234
|
default: { heading: true, alt: false, speed: false },
|
|
178
|
-
normalize:
|
|
235
|
+
normalize: OVERRIDE_NORMALIZERS.hud,
|
|
179
236
|
},
|
|
180
237
|
{
|
|
181
238
|
key: 'workers',
|
|
182
239
|
cli: { flags: '--workers <n>', help: 'parallel browser pages', parse: cliNumber },
|
|
183
240
|
default: 4,
|
|
184
|
-
normalize:
|
|
241
|
+
normalize: OVERRIDE_NORMALIZERS.workers,
|
|
185
242
|
},
|
|
186
243
|
{
|
|
187
244
|
key: 'capture',
|
|
188
|
-
cli: { flags: '--capture <mode>', help: 'frame capture mode (canvas is parked)', choices:
|
|
245
|
+
cli: { flags: '--capture <mode>', help: 'frame capture mode (canvas is parked)', choices: CAPTURE_FORMAT_VALUES },
|
|
189
246
|
default: 'jpeg',
|
|
190
|
-
normalize:
|
|
247
|
+
normalize: OVERRIDE_NORMALIZERS.capture,
|
|
191
248
|
},
|
|
192
249
|
{
|
|
193
250
|
key: 'codec',
|
|
194
251
|
cli: { flags: '--codec <name>', help: 'video codec (mp4 container)', choices: CODEC_VALUES },
|
|
195
252
|
default: 'h264',
|
|
196
|
-
normalize:
|
|
253
|
+
normalize: OVERRIDE_NORMALIZERS.codec,
|
|
197
254
|
},
|
|
198
255
|
{
|
|
199
256
|
key: 'quality',
|
|
200
257
|
cli: { flags: '--quality <level>', help: 'encoding quality', choices: QUALITY_VALUES },
|
|
201
258
|
default: 'high',
|
|
202
|
-
normalize:
|
|
259
|
+
normalize: OVERRIDE_NORMALIZERS.quality,
|
|
203
260
|
},
|
|
204
261
|
{
|
|
205
262
|
key: 'preset',
|
|
206
|
-
cli: { flags: '--preset <name>', help: 'encoding speed', choices:
|
|
263
|
+
cli: { flags: '--preset <name>', help: 'encoding speed', choices: ENCODER_PRESET_VALUES },
|
|
207
264
|
default: 'medium',
|
|
208
|
-
normalize:
|
|
265
|
+
normalize: OVERRIDE_NORMALIZERS.preset,
|
|
209
266
|
},
|
|
210
267
|
{
|
|
211
268
|
key: 'tileCache',
|
|
212
269
|
cli: { flags: '--tile-cache <dir>', help: 'tile cache directory (default: per-user cache dir)' },
|
|
213
270
|
default: '',
|
|
214
|
-
normalize:
|
|
271
|
+
normalize: OVERRIDE_NORMALIZERS.tileCache,
|
|
215
272
|
},
|
|
216
273
|
{
|
|
217
274
|
key: 'browser',
|
|
218
275
|
cli: { flags: '--browser <path>', help: 'Chromium/Chrome/Edge executable (default: system Chrome/Edge)' },
|
|
219
276
|
default: null,
|
|
220
|
-
normalize:
|
|
277
|
+
normalize: OVERRIDE_NORMALIZERS.browser,
|
|
221
278
|
},
|
|
222
279
|
{
|
|
223
280
|
key: 'ffmpeg',
|
|
224
281
|
cli: { flags: '--ffmpeg <path>', help: 'ffmpeg executable (default: embedded binary, then PATH)' },
|
|
225
282
|
default: null,
|
|
226
|
-
normalize:
|
|
283
|
+
normalize: OVERRIDE_NORMALIZERS.ffmpeg,
|
|
227
284
|
},
|
|
228
285
|
{
|
|
229
286
|
key: 'ffprobe',
|
|
230
287
|
cli: { flags: '--ffprobe <path>', help: 'ffprobe executable (default: embedded binary, then PATH)' },
|
|
231
288
|
default: null,
|
|
232
|
-
normalize:
|
|
289
|
+
normalize: OVERRIDE_NORMALIZERS.ffprobe,
|
|
233
290
|
},
|
|
234
291
|
{
|
|
235
292
|
key: 'skipExisting',
|
|
@@ -238,36 +295,78 @@ export const CONFIG_OPTIONS = [
|
|
|
238
295
|
help: 'skip recordings whose output already exists and matches the source',
|
|
239
296
|
},
|
|
240
297
|
default: false,
|
|
241
|
-
normalize:
|
|
298
|
+
normalize: OVERRIDE_NORMALIZERS.skipExisting,
|
|
242
299
|
},
|
|
243
300
|
{
|
|
244
301
|
key: 'recurse',
|
|
245
302
|
cli: { flags: '--recurse', help: 'scan input folders recursively' },
|
|
246
303
|
default: false,
|
|
247
|
-
normalize:
|
|
304
|
+
normalize: OVERRIDE_NORMALIZERS.recurse,
|
|
248
305
|
},
|
|
249
306
|
{
|
|
250
|
-
key: '
|
|
307
|
+
key: 'trackOut',
|
|
251
308
|
cli: {
|
|
252
|
-
flags: '--
|
|
253
|
-
help: 'write one
|
|
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)',
|
|
254
312
|
},
|
|
255
313
|
default: null,
|
|
256
|
-
normalize:
|
|
314
|
+
normalize: OVERRIDE_NORMALIZERS.trackOut,
|
|
257
315
|
},
|
|
258
316
|
{
|
|
259
317
|
key: 'json',
|
|
260
318
|
cli: { flags: '--json', help: 'print one NDJSON summary line per recording on stdout' },
|
|
261
319
|
default: false,
|
|
262
|
-
normalize:
|
|
320
|
+
normalize: OVERRIDE_NORMALIZERS.json,
|
|
263
321
|
},
|
|
264
322
|
{
|
|
265
323
|
key: 'quiet',
|
|
266
324
|
cli: { flags: '-q, --quiet', help: 'suppress progress output' },
|
|
267
325
|
default: false,
|
|
268
|
-
normalize:
|
|
326
|
+
normalize: OVERRIDE_NORMALIZERS.quiet,
|
|
269
327
|
},
|
|
270
328
|
];
|
|
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
|
+
}
|
|
365
|
+
function cliNumber(raw) {
|
|
366
|
+
if (typeof raw !== 'string' || !CLI_NUMBER_RX.test(raw.trim()))
|
|
367
|
+
return raw;
|
|
368
|
+
return Number(raw);
|
|
369
|
+
}
|
|
271
370
|
export function cliDefaultOf(key) {
|
|
272
371
|
const row = CONFIG_OPTIONS.find((r) => r.key === key);
|
|
273
372
|
if (!row)
|
|
@@ -281,15 +380,22 @@ export function cliDefaultOf(key) {
|
|
|
281
380
|
}
|
|
282
381
|
export const DEFAULT_CONFIG = Object.freeze(Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.default])));
|
|
283
382
|
Object.freeze(DEFAULT_CONFIG.hud);
|
|
284
|
-
const
|
|
285
|
-
|
|
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) {
|
|
390
|
+
parseValue(strictShape(OVERRIDE_SHAPE, {
|
|
391
|
+
invalid: `invalid config overrides in ${origin}`,
|
|
392
|
+
unknownKey: (key) => `unknown config key ${key} in ${origin}`,
|
|
393
|
+
}), raw);
|
|
286
394
|
const out = {};
|
|
287
395
|
for (const key of Object.keys(raw)) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (!normalize)
|
|
292
|
-
throw new Error(`unknown config key ${key} in ${origin}`);
|
|
396
|
+
if (key === TELEMETRY_JSON_ALIAS.inputKey)
|
|
397
|
+
continue;
|
|
398
|
+
const normalize = OVERRIDE_NORMALIZERS[key];
|
|
293
399
|
const value = raw[key];
|
|
294
400
|
if (value === undefined)
|
|
295
401
|
continue;
|
|
@@ -297,11 +403,30 @@ export function normalizeOverrides(raw, origin) {
|
|
|
297
403
|
continue;
|
|
298
404
|
Object.assign(out, normalize(value, `${origin}: ${key}`));
|
|
299
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
|
+
}
|
|
300
413
|
return out;
|
|
301
414
|
}
|
|
302
415
|
export function effectiveZoomOut(config) {
|
|
303
416
|
return config.zoom > 0 ? 0 : config.zoomOut;
|
|
304
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];
|
|
305
430
|
export function settingsPatchOf(config) {
|
|
306
431
|
return {
|
|
307
432
|
style: config.style,
|
|
@@ -317,33 +442,18 @@ export function settingsPatchOf(config) {
|
|
|
317
442
|
preset: config.preset,
|
|
318
443
|
};
|
|
319
444
|
}
|
|
320
|
-
|
|
321
|
-
'style',
|
|
322
|
-
'view',
|
|
323
|
-
'zoom',
|
|
324
|
-
'zoomOut',
|
|
325
|
-
'hud',
|
|
326
|
-
'introSec',
|
|
327
|
-
'outroSec',
|
|
328
|
-
'trailColor',
|
|
329
|
-
'codec',
|
|
330
|
-
'quality',
|
|
331
|
-
'preset',
|
|
332
|
-
];
|
|
445
|
+
const SETTINGS_SHAPE = Object.fromEntries(SETTINGS_KEYS.map((key) => [key, z.unknown().optional()]));
|
|
333
446
|
export function parseSettingsPatch(raw, origin) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
447
|
+
parseValue(strictShape(SETTINGS_SHAPE, {
|
|
448
|
+
invalid: `invalid settings in ${origin}`,
|
|
449
|
+
unknownKey: (key) => `unknown settings key ${key} in ${origin}`,
|
|
450
|
+
}), raw);
|
|
337
451
|
const flat = { ...raw };
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
if (flat.hud !== undefined && flat.hud !== null && typeof flat.hud !== 'string') {
|
|
344
|
-
flat.hud = formatHud(parseHudObject(flat.hud, `${origin}: hud`));
|
|
345
|
-
}
|
|
346
|
-
const patch = normalizeOverrides(flat, origin);
|
|
452
|
+
const hud = patchHud(flat.hud, `${origin}: hud`);
|
|
453
|
+
delete flat.hud;
|
|
454
|
+
const patch = { ...normalizeOverrides(flat, origin) };
|
|
455
|
+
if (hud !== undefined)
|
|
456
|
+
patch.hud = hud;
|
|
347
457
|
for (const key of SETTINGS_KEYS) {
|
|
348
458
|
if (patch[key] === undefined) {
|
|
349
459
|
throw new Error(`missing settings key ${key} in ${origin}`);
|
|
@@ -353,10 +463,45 @@ export function parseSettingsPatch(raw, origin) {
|
|
|
353
463
|
validateRenderConfig({ ...DEFAULT_CONFIG, ...settings, hud: { ...settings.hud } });
|
|
354
464
|
return settings;
|
|
355
465
|
}
|
|
466
|
+
// The pick-request flavor of look settings: its error wording is the legacy
|
|
467
|
+
// IPC wording, deliberately distinct from validateRenderConfig's CLI wording.
|
|
468
|
+
export function parseAppearanceSettings(raw) {
|
|
469
|
+
const look = typeof raw === 'object' && raw !== null ? raw : {};
|
|
470
|
+
const { style, view, hud } = look;
|
|
471
|
+
const mapStyle = parseValue(z.enum(MAP_STYLE_VALUES, {
|
|
472
|
+
error: (issue) => `unknown map style: ${String(issue.input)}`,
|
|
473
|
+
}), style);
|
|
474
|
+
const viewMode = parseValue(z.enum(VIEW_MODE_VALUES, {
|
|
475
|
+
error: (issue) => `unknown view: ${String(issue.input)}`,
|
|
476
|
+
}), view);
|
|
477
|
+
const zoom = parseValue(numberValue('zoom'), look.zoom);
|
|
478
|
+
const zoomOut = parseValue(numberValue('zoom-out'), look.zoomOut);
|
|
479
|
+
requireNonNegative(zoom, 'zoom must be >= 0 (0 = auto-fit)');
|
|
480
|
+
requireNonNegative(zoomOut, 'zoom-out must be >= 0');
|
|
481
|
+
const introSec = parseValue(numberValue('intro'), look.introSec);
|
|
482
|
+
const outroSec = parseValue(numberValue('outro'), look.outroSec);
|
|
483
|
+
requireNonNegative(introSec, 'intro must be 0 or more');
|
|
484
|
+
requireNonNegative(outroSec, 'outro must be 0 or more');
|
|
485
|
+
const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
|
|
486
|
+
const chips = typeof hud === 'object' && hud !== null ? hud : {};
|
|
487
|
+
return {
|
|
488
|
+
style: mapStyle,
|
|
489
|
+
view: viewMode,
|
|
490
|
+
zoom,
|
|
491
|
+
zoomOut,
|
|
492
|
+
hud: { heading: !!chips.heading, alt: !!chips.alt, speed: !!chips.speed },
|
|
493
|
+
introSec,
|
|
494
|
+
outroSec,
|
|
495
|
+
trailColor,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
356
498
|
export const MIN_DIMENSION = 64;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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)) {
|
|
360
505
|
throw new Error(`width and height must be at least ${MIN_DIMENSION}`);
|
|
361
506
|
}
|
|
362
507
|
}
|
|
@@ -366,63 +511,74 @@ export function normalizeDimensions(width, height) {
|
|
|
366
511
|
height: Math.max(MIN_DIMENSION, 2 * Math.floor(height / 2)),
|
|
367
512
|
};
|
|
368
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
|
+
}
|
|
369
535
|
export function validateRenderConfig(config) {
|
|
370
536
|
validateDimensions(config.width, config.height);
|
|
371
|
-
if (!
|
|
537
|
+
if (!isValidWorkerCount(config.workers)) {
|
|
372
538
|
throw new Error('workers must be a positive integer');
|
|
373
539
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
if (!(config.
|
|
377
|
-
throw new Error('zoom-out must be >= 0');
|
|
378
|
-
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)) {
|
|
379
543
|
throw new Error('intro-sec and outro-sec must be >= 0');
|
|
380
544
|
}
|
|
381
545
|
if (!config.outSuffix)
|
|
382
546
|
throw new Error('out-suffix must not be empty');
|
|
383
547
|
}
|
|
384
|
-
|
|
548
|
+
function assertValidFrameRange(range, name = 'frame range') {
|
|
385
549
|
if (!Number.isInteger(range.start) || !Number.isInteger(range.end)) {
|
|
386
550
|
throw new Error(`invalid ${name}: start and end must be integer frame indices`);
|
|
387
551
|
}
|
|
388
|
-
|
|
389
|
-
|
|
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}`);
|
|
390
555
|
}
|
|
391
556
|
}
|
|
392
557
|
export function parseFrameRange(raw, name = 'frame range') {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
throw new Error(`invalid value for ${name}`);
|
|
410
|
-
}
|
|
411
|
-
const h = value;
|
|
412
|
-
for (const key of Object.keys(h)) {
|
|
413
|
-
if (key !== 'heading' && key !== 'alt' && key !== 'speed') {
|
|
414
|
-
throw new Error(`unknown key ${key} in ${name}`);
|
|
415
|
-
}
|
|
558
|
+
const range = parseValue(strictShape({
|
|
559
|
+
start: numberValue(`${name}: start`),
|
|
560
|
+
end: numberValue(`${name}: end`),
|
|
561
|
+
}, {
|
|
562
|
+
invalid: `invalid ${name}`,
|
|
563
|
+
unknownKey: (key) => `unknown ${name} key ${key}`,
|
|
564
|
+
}), raw);
|
|
565
|
+
assertValidFrameRange(range, name);
|
|
566
|
+
return range;
|
|
567
|
+
}
|
|
568
|
+
export function resolveFrameRange(range, frames) {
|
|
569
|
+
if (!range)
|
|
570
|
+
return null;
|
|
571
|
+
assertValidFrameRange(range);
|
|
572
|
+
if (range.end >= frames) {
|
|
573
|
+
throw new Error(`frame range ${range.start}-${range.end} is beyond the recording (${frames} frames)`);
|
|
416
574
|
}
|
|
417
|
-
return
|
|
418
|
-
heading: asBool(h.heading, `${name}: heading`),
|
|
419
|
-
alt: asBool(h.alt, `${name}: alt`),
|
|
420
|
-
speed: asBool(h.speed, `${name}: speed`),
|
|
421
|
-
};
|
|
575
|
+
return range;
|
|
422
576
|
}
|
|
423
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.
|
|
424
580
|
'outDir', 'outSuffix', 'tileCache', 'browser', 'ffmpeg', 'ffprobe', 'workers', 'capture',
|
|
425
|
-
'skipExisting', 'recurse', '
|
|
581
|
+
'skipExisting', 'recurse', 'trackOut', TELEMETRY_JSON_ALIAS.inputKey, 'json', 'quiet',
|
|
426
582
|
];
|
|
427
583
|
function parseRequestConfig(raw, base) {
|
|
428
584
|
if (typeof raw !== 'object' || raw === null) {
|
|
@@ -431,27 +587,31 @@ function parseRequestConfig(raw, base) {
|
|
|
431
587
|
const flat = { ...raw };
|
|
432
588
|
for (const key of MAIN_OWNED_KEYS)
|
|
433
589
|
delete flat[key];
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
590
|
+
const { hud, ...rest } = flat;
|
|
591
|
+
const hudSpec = hud === undefined || hud === null
|
|
592
|
+
? undefined
|
|
593
|
+
: parseValue(hudSpecSchema('export request: config: hud'), hud);
|
|
594
|
+
const config = { ...base, ...normalizeOverrides(rest, 'export request: config') };
|
|
595
|
+
const merged = hudSpec === undefined ? config : { ...config, hud: hudSpec };
|
|
596
|
+
validateRenderConfig(merged);
|
|
597
|
+
return { ...merged, ...normalizeDimensions(merged.width, merged.height) };
|
|
440
598
|
}
|
|
599
|
+
const EXPORT_REQUEST_SCHEMA = z.preprocess(keyedObjectInput, strictShape({
|
|
600
|
+
outPath: z.unknown().optional(),
|
|
601
|
+
config: z.unknown().optional(),
|
|
602
|
+
range: z.unknown().optional(),
|
|
603
|
+
}, {
|
|
604
|
+
invalid: 'invalid export request',
|
|
605
|
+
unknownKey: (key) => `unknown export request key ${key}`,
|
|
606
|
+
}));
|
|
441
607
|
export function parseExportRequest(raw, base) {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
const r = raw;
|
|
446
|
-
for (const key of Object.keys(r)) {
|
|
447
|
-
if (key !== 'outPath' && key !== 'config' && key !== 'range') {
|
|
448
|
-
throw new Error(`unknown export request key ${key}`);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
const outPath = asString(r.outPath, 'export request: outPath');
|
|
608
|
+
const request = parseValue(EXPORT_REQUEST_SCHEMA, raw);
|
|
609
|
+
const outPath = parseValue(stringValue('export request: outPath'), request.outPath);
|
|
452
610
|
if (!outPath.toLowerCase().endsWith('.mp4')) {
|
|
453
611
|
throw new Error(`export request: outPath must be an .mp4 file: ${outPath}`);
|
|
454
612
|
}
|
|
455
|
-
const range =
|
|
456
|
-
|
|
613
|
+
const range = request.range === undefined || request.range === null
|
|
614
|
+
? null
|
|
615
|
+
: parseFrameRange(request.range);
|
|
616
|
+
return { outPath, config: parseRequestConfig(request.config, base), range };
|
|
457
617
|
}
|