drone-path 0.13.0 → 1.0.0-rc1
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/README.md +20 -74
- package/THIRD-PARTY-NOTICES.md +3 -82
- package/bin/drone-path.mjs +0 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +7 -7
- package/dist/version.d.ts +1 -0
- package/package.json +21 -68
- package/CHANGELOG.md +0 -349
- package/app/ipc.d.mts +0 -44
- package/app/ipc.mjs +0 -237
- package/app/main.mjs +0 -369
- package/app/preload.cjs +0 -36
- package/app/update-policy.d.mts +0 -6
- package/app/update-policy.mjs +0 -6
- package/app/update.d.mts +0 -10
- package/app/update.mjs +0 -54
- package/dist/appassets.js +0 -35
- package/dist/apppaths.js +0 -20
- package/dist/appsession.js +0 -121
- package/dist/appstate.js +0 -101
- package/dist/assets.js +0 -60
- package/dist/buildinfo.js +0 -64
- package/dist/cammeta-decode.js +0 -237
- package/dist/cammeta.js +0 -92
- package/dist/changeset-gate.js +0 -39
- package/dist/config.js +0 -631
- package/dist/configfile.js +0 -86
- package/dist/decimate.js +0 -84
- package/dist/desktop-i18n/generated/catalogs.js +0 -1230
- package/dist/desktop-i18n/messages.js +0 -47
- package/dist/errors.js +0 -34
- package/dist/exec-tool.js +0 -13
- package/dist/exportjob.js +0 -90
- package/dist/ffmpeg-tools.js +0 -56
- package/dist/ffmpeg.js +0 -98
- package/dist/frametime.js +0 -32
- package/dist/geo.js +0 -60
- package/dist/logging.js +0 -1
- package/dist/manual/anchors.js +0 -17
- package/dist/manual/build.js +0 -67
- package/dist/manual/cliref.js +0 -34
- package/dist/manual/links.js +0 -59
- package/dist/manual/markdown.js +0 -98
- package/dist/manual/model.js +0 -1
- package/dist/manual/module.js +0 -5
- package/dist/manual/nav.js +0 -11
- package/dist/manual/reference.js +0 -18
- package/dist/paths.js +0 -16
- package/dist/pipeline.js +0 -402
- package/dist/plan.js +0 -106
- package/dist/png.js +0 -32
- package/dist/protobuf-wire.js +0 -102
- package/dist/range.js +0 -50
- package/dist/recordings.js +0 -55
- package/dist/render-page.js +0 -85
- package/dist/render.js +0 -268
- package/dist/renderer/boot.js +0 -7
- package/dist/renderer/dom.js +0 -179
- package/dist/renderer/framemath.js +0 -30
- package/dist/renderer/scene.js +0 -388
- package/dist/renderer/theme.js +0 -82
- package/dist/renderer/tilesources.js +0 -38
- package/dist/renderer/trail.js +0 -42
- package/dist/restyle.js +0 -16
- package/dist/serve.js +0 -27
- package/dist/srt.js +0 -98
- package/dist/telemetry-json-schema.js +0 -18
- package/dist/telemetry-json.js +0 -126
- package/dist/telemetry-math.js +0 -267
- package/dist/telemetry-summary.js +0 -19
- package/dist/telemetry.js +0 -95
- package/dist/tilecache.js +0 -21
- package/dist/tiles.js +0 -155
- package/dist/track-format.js +0 -13
- package/dist/track-geojson.js +0 -44
- package/dist/track-gpx.js +0 -34
- package/dist/track-kml.js +0 -47
- package/dist/track-kmz.js +0 -68
- package/dist/track-write.js +0 -41
- package/dist/track.js +0 -79
package/dist/config.js
DELETED
|
@@ -1,631 +0,0 @@
|
|
|
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'];
|
|
8
|
-
export const CONFIG_FILE_NAME = '.dronepath.json';
|
|
9
|
-
export const CONFIG_FILE_OPTION = {
|
|
10
|
-
flags: '--config <path>',
|
|
11
|
-
help: 'config file (default: .dronepath.json discovered upward from the working directory)',
|
|
12
|
-
};
|
|
13
|
-
export function parseHud(list) {
|
|
14
|
-
const hud = { heading: false, alt: false, speed: false };
|
|
15
|
-
if (!list || list.toLowerCase() === 'none')
|
|
16
|
-
return hud;
|
|
17
|
-
for (const part of list
|
|
18
|
-
.split(',')
|
|
19
|
-
.map((s) => s.trim().toLowerCase())
|
|
20
|
-
.filter(Boolean)) {
|
|
21
|
-
if (part === 'heading' || part === 'arrow')
|
|
22
|
-
hud.heading = true;
|
|
23
|
-
else if (part === 'alt' || part === 'altitude')
|
|
24
|
-
hud.alt = true;
|
|
25
|
-
else if (part === 'speed')
|
|
26
|
-
hud.speed = true;
|
|
27
|
-
else
|
|
28
|
-
throw new Error(`unknown --hud component: ${part} (use heading,alt,speed or none)`);
|
|
29
|
-
}
|
|
30
|
-
return hud;
|
|
31
|
-
}
|
|
32
|
-
export function resolveHudLayout(hud, hasAlt) {
|
|
33
|
-
return hud.alt && !hasAlt ? { ...hud, alt: false } : hud;
|
|
34
|
-
}
|
|
35
|
-
export function hasAltitude(alt) {
|
|
36
|
-
return alt.some((a) => a !== null);
|
|
37
|
-
}
|
|
38
|
-
export function formatHud(hud) {
|
|
39
|
-
const parts = [];
|
|
40
|
-
if (hud.heading)
|
|
41
|
-
parts.push('heading');
|
|
42
|
-
if (hud.alt)
|
|
43
|
-
parts.push('alt');
|
|
44
|
-
if (hud.speed)
|
|
45
|
-
parts.push('speed');
|
|
46
|
-
return parts.length ? parts.join(',') : 'none';
|
|
47
|
-
}
|
|
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 });
|
|
59
|
-
}
|
|
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
|
-
});
|
|
66
|
-
}
|
|
67
|
-
function numberValue(name) {
|
|
68
|
-
return z.number({ error: invalidNumber(name) });
|
|
69
|
-
}
|
|
70
|
-
function stringValue(name) {
|
|
71
|
-
return z
|
|
72
|
-
.string({ error: invalidValue(name) })
|
|
73
|
-
.min(1, { error: invalidValue(name) });
|
|
74
|
-
}
|
|
75
|
-
function boolValue(name) {
|
|
76
|
-
return z.boolean({ error: invalidValue(name) });
|
|
77
|
-
}
|
|
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));
|
|
103
|
-
}
|
|
104
|
-
export function asTrailColor(value, name) {
|
|
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);
|
|
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
|
-
};
|
|
154
|
-
export const CONFIG_OPTIONS = [
|
|
155
|
-
{
|
|
156
|
-
key: 'outDir',
|
|
157
|
-
cli: { flags: '--out-dir <dir>', help: 'output folder' },
|
|
158
|
-
default: 'out',
|
|
159
|
-
normalize: OVERRIDE_NORMALIZERS.outDir,
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
key: 'outSuffix',
|
|
163
|
-
cli: { flags: '--out-suffix <suffix>', help: 'output name = <basename><suffix>.mp4' },
|
|
164
|
-
default: '_map',
|
|
165
|
-
normalize: OVERRIDE_NORMALIZERS.outSuffix,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
key: 'width',
|
|
169
|
-
cli: { flags: '--width <px>', help: 'canvas width in pixels (rounded down to even)', parse: cliNumber },
|
|
170
|
-
default: 768,
|
|
171
|
-
normalize: OVERRIDE_NORMALIZERS.width,
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
key: 'height',
|
|
175
|
-
cli: { flags: '--height <px>', help: 'canvas height in pixels (rounded down to even)', parse: cliNumber },
|
|
176
|
-
default: 768,
|
|
177
|
-
normalize: OVERRIDE_NORMALIZERS.height,
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
key: 'style',
|
|
181
|
-
cli: { flags: '--style <name>', help: 'map look', choices: MAP_STYLE_VALUES },
|
|
182
|
-
default: 'satellite',
|
|
183
|
-
normalize: OVERRIDE_NORMALIZERS.style,
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
key: 'view',
|
|
187
|
-
cli: {
|
|
188
|
-
flags: '--view <mode>',
|
|
189
|
-
help: 'follow: drone stays centered and the map slides under it; overview: static whole-track map',
|
|
190
|
-
choices: VIEW_MODE_VALUES,
|
|
191
|
-
},
|
|
192
|
-
default: 'follow',
|
|
193
|
-
normalize: OVERRIDE_NORMALIZERS.view,
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
key: 'zoom',
|
|
197
|
-
cli: { flags: '--zoom <n>', help: 'fixed view zoom level (0 = auto-fit to the track)', parse: cliNumber },
|
|
198
|
-
default: 0,
|
|
199
|
-
normalize: OVERRIDE_NORMALIZERS.zoom,
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
key: 'zoomOut',
|
|
203
|
-
cli: { flags: '--zoom-out <n>', help: 'auto-fit only: pull back n zoom levels', parse: cliNumber },
|
|
204
|
-
default: 1,
|
|
205
|
-
normalize: OVERRIDE_NORMALIZERS.zoomOut,
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
key: 'introSec',
|
|
209
|
-
cli: { flags: '--intro-sec <s>', help: 'intro: zoom in from one level out over s seconds', parse: cliNumber },
|
|
210
|
-
default: 2,
|
|
211
|
-
normalize: OVERRIDE_NORMALIZERS.introSec,
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
key: 'outroSec',
|
|
215
|
-
cli: { flags: '--outro-sec <s>', help: 'outro: zoom back out over s seconds', parse: cliNumber },
|
|
216
|
-
default: 2,
|
|
217
|
-
normalize: OVERRIDE_NORMALIZERS.outroSec,
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
key: 'trailColor',
|
|
221
|
-
cli: {
|
|
222
|
-
flags: '--trail-color <hex>',
|
|
223
|
-
help: 'trail color as hex, RGB or RGBA (e.g. e63946 or #e63946cc; default: the map style\'s color)',
|
|
224
|
-
},
|
|
225
|
-
default: null,
|
|
226
|
-
normalize: OVERRIDE_NORMALIZERS.trailColor,
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
key: 'hud',
|
|
230
|
-
cli: {
|
|
231
|
-
flags: '--hud <list>',
|
|
232
|
-
help: 'comma list of heading,alt,speed - or none (alt hides when unavailable)',
|
|
233
|
-
},
|
|
234
|
-
default: { heading: true, alt: false, speed: false },
|
|
235
|
-
normalize: OVERRIDE_NORMALIZERS.hud,
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
key: 'workers',
|
|
239
|
-
cli: { flags: '--workers <n>', help: 'parallel browser pages', parse: cliNumber },
|
|
240
|
-
default: 4,
|
|
241
|
-
normalize: OVERRIDE_NORMALIZERS.workers,
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
key: 'capture',
|
|
245
|
-
cli: { flags: '--capture <mode>', help: 'frame capture mode (canvas is parked)', choices: CAPTURE_FORMAT_VALUES },
|
|
246
|
-
default: 'jpeg',
|
|
247
|
-
normalize: OVERRIDE_NORMALIZERS.capture,
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
key: 'codec',
|
|
251
|
-
cli: { flags: '--codec <name>', help: 'video codec (mp4 container)', choices: CODEC_VALUES },
|
|
252
|
-
default: 'h264',
|
|
253
|
-
normalize: OVERRIDE_NORMALIZERS.codec,
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
key: 'quality',
|
|
257
|
-
cli: { flags: '--quality <level>', help: 'encoding quality', choices: QUALITY_VALUES },
|
|
258
|
-
default: 'high',
|
|
259
|
-
normalize: OVERRIDE_NORMALIZERS.quality,
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
key: 'preset',
|
|
263
|
-
cli: { flags: '--preset <name>', help: 'encoding speed', choices: ENCODER_PRESET_VALUES },
|
|
264
|
-
default: 'medium',
|
|
265
|
-
normalize: OVERRIDE_NORMALIZERS.preset,
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
key: 'tileCache',
|
|
269
|
-
cli: { flags: '--tile-cache <dir>', help: 'tile cache directory (default: per-user cache dir)' },
|
|
270
|
-
default: '',
|
|
271
|
-
normalize: OVERRIDE_NORMALIZERS.tileCache,
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
key: 'browser',
|
|
275
|
-
cli: { flags: '--browser <path>', help: 'Chromium/Chrome/Edge executable (default: system Chrome/Edge)' },
|
|
276
|
-
default: null,
|
|
277
|
-
normalize: OVERRIDE_NORMALIZERS.browser,
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
key: 'ffmpeg',
|
|
281
|
-
cli: { flags: '--ffmpeg <path>', help: 'ffmpeg executable (default: embedded binary, then PATH)' },
|
|
282
|
-
default: null,
|
|
283
|
-
normalize: OVERRIDE_NORMALIZERS.ffmpeg,
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
key: 'ffprobe',
|
|
287
|
-
cli: { flags: '--ffprobe <path>', help: 'ffprobe executable (default: embedded binary, then PATH)' },
|
|
288
|
-
default: null,
|
|
289
|
-
normalize: OVERRIDE_NORMALIZERS.ffprobe,
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
key: 'skipExisting',
|
|
293
|
-
cli: {
|
|
294
|
-
flags: '--skip-existing',
|
|
295
|
-
help: 'skip recordings whose output already exists and matches the source',
|
|
296
|
-
},
|
|
297
|
-
default: false,
|
|
298
|
-
normalize: OVERRIDE_NORMALIZERS.skipExisting,
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
key: 'recurse',
|
|
302
|
-
cli: { flags: '--recurse', help: 'scan input folders recursively' },
|
|
303
|
-
default: false,
|
|
304
|
-
normalize: OVERRIDE_NORMALIZERS.recurse,
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
key: 'trackOut',
|
|
308
|
-
cli: {
|
|
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)',
|
|
312
|
-
},
|
|
313
|
-
default: null,
|
|
314
|
-
normalize: OVERRIDE_NORMALIZERS.trackOut,
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
key: 'json',
|
|
318
|
-
cli: { flags: '--json', help: 'print one NDJSON summary line per recording on stdout' },
|
|
319
|
-
default: false,
|
|
320
|
-
normalize: OVERRIDE_NORMALIZERS.json,
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
key: 'quiet',
|
|
324
|
-
cli: { flags: '-q, --quiet', help: 'suppress progress output' },
|
|
325
|
-
default: false,
|
|
326
|
-
normalize: OVERRIDE_NORMALIZERS.quiet,
|
|
327
|
-
},
|
|
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
|
-
}
|
|
370
|
-
export function cliDefaultOf(key) {
|
|
371
|
-
const row = CONFIG_OPTIONS.find((r) => r.key === key);
|
|
372
|
-
if (!row)
|
|
373
|
-
throw new Error(`unknown config key ${String(key)}`);
|
|
374
|
-
const value = row.default;
|
|
375
|
-
if (typeof value === 'boolean')
|
|
376
|
-
return value;
|
|
377
|
-
if (value === null || value === undefined)
|
|
378
|
-
return '';
|
|
379
|
-
return key === 'hud' ? formatHud(value) : String(value);
|
|
380
|
-
}
|
|
381
|
-
export const DEFAULT_CONFIG = Object.freeze(Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.default])));
|
|
382
|
-
Object.freeze(DEFAULT_CONFIG.hud);
|
|
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);
|
|
394
|
-
const out = {};
|
|
395
|
-
for (const key of Object.keys(raw)) {
|
|
396
|
-
if (key === TELEMETRY_JSON_ALIAS.inputKey)
|
|
397
|
-
continue;
|
|
398
|
-
const normalize = OVERRIDE_NORMALIZERS[key];
|
|
399
|
-
const value = raw[key];
|
|
400
|
-
if (value === undefined)
|
|
401
|
-
continue;
|
|
402
|
-
if (value === null && DEFAULT_CONFIG[key] !== null)
|
|
403
|
-
continue;
|
|
404
|
-
Object.assign(out, normalize(value, `${origin}: ${key}`));
|
|
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
|
-
}
|
|
413
|
-
return out;
|
|
414
|
-
}
|
|
415
|
-
export function effectiveZoomOut(config) {
|
|
416
|
-
return config.zoom > 0 ? 0 : config.zoomOut;
|
|
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];
|
|
430
|
-
/** The look projection every consumer shares; hud is cloned so no caller can
|
|
431
|
-
leak chip state into another owner. */
|
|
432
|
-
export function appearanceOf(config) {
|
|
433
|
-
return {
|
|
434
|
-
style: config.style,
|
|
435
|
-
view: config.view,
|
|
436
|
-
zoom: config.zoom,
|
|
437
|
-
zoomOut: config.zoomOut,
|
|
438
|
-
hud: { ...config.hud },
|
|
439
|
-
introSec: config.introSec,
|
|
440
|
-
outroSec: config.outroSec,
|
|
441
|
-
trailColor: config.trailColor,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
export function settingsPatchOf(config) {
|
|
445
|
-
return {
|
|
446
|
-
style: config.style,
|
|
447
|
-
view: config.view,
|
|
448
|
-
zoom: config.zoom,
|
|
449
|
-
zoomOut: config.zoomOut,
|
|
450
|
-
hud: config.hud,
|
|
451
|
-
introSec: config.introSec,
|
|
452
|
-
outroSec: config.outroSec,
|
|
453
|
-
trailColor: config.trailColor,
|
|
454
|
-
codec: config.codec,
|
|
455
|
-
quality: config.quality,
|
|
456
|
-
preset: config.preset,
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
const SETTINGS_SHAPE = Object.fromEntries(SETTINGS_KEYS.map((key) => [key, z.unknown().optional()]));
|
|
460
|
-
export function parseSettingsPatch(raw, origin) {
|
|
461
|
-
parseValue(strictShape(SETTINGS_SHAPE, {
|
|
462
|
-
invalid: `invalid settings in ${origin}`,
|
|
463
|
-
unknownKey: (key) => `unknown settings key ${key} in ${origin}`,
|
|
464
|
-
}), raw);
|
|
465
|
-
const flat = { ...raw };
|
|
466
|
-
const hud = patchHud(flat.hud, `${origin}: hud`);
|
|
467
|
-
delete flat.hud;
|
|
468
|
-
const patch = { ...normalizeOverrides(flat, origin) };
|
|
469
|
-
if (hud !== undefined)
|
|
470
|
-
patch.hud = hud;
|
|
471
|
-
for (const key of SETTINGS_KEYS) {
|
|
472
|
-
if (patch[key] === undefined) {
|
|
473
|
-
throw new Error(`missing settings key ${key} in ${origin}`);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
const settings = patch;
|
|
477
|
-
validateRenderConfig({ ...DEFAULT_CONFIG, ...settings, hud: { ...settings.hud } });
|
|
478
|
-
return settings;
|
|
479
|
-
}
|
|
480
|
-
// The pick-request flavor of look settings: its error wording is the legacy
|
|
481
|
-
// IPC wording, deliberately distinct from validateRenderConfig's CLI wording.
|
|
482
|
-
export function parseAppearanceSettings(raw) {
|
|
483
|
-
const look = typeof raw === 'object' && raw !== null ? raw : {};
|
|
484
|
-
const { style, view, hud } = look;
|
|
485
|
-
const mapStyle = parseValue(z.enum(MAP_STYLE_VALUES, {
|
|
486
|
-
error: (issue) => `unknown map style: ${String(issue.input)}`,
|
|
487
|
-
}), style);
|
|
488
|
-
const viewMode = parseValue(z.enum(VIEW_MODE_VALUES, {
|
|
489
|
-
error: (issue) => `unknown view: ${String(issue.input)}`,
|
|
490
|
-
}), view);
|
|
491
|
-
const zoom = parseValue(numberValue('zoom'), look.zoom);
|
|
492
|
-
const zoomOut = parseValue(numberValue('zoom-out'), look.zoomOut);
|
|
493
|
-
requireNonNegative(zoom, 'zoom must be >= 0 (0 = auto-fit)');
|
|
494
|
-
requireNonNegative(zoomOut, 'zoom-out must be >= 0');
|
|
495
|
-
const introSec = parseValue(numberValue('intro'), look.introSec);
|
|
496
|
-
const outroSec = parseValue(numberValue('outro'), look.outroSec);
|
|
497
|
-
requireNonNegative(introSec, 'intro must be 0 or more');
|
|
498
|
-
requireNonNegative(outroSec, 'outro must be 0 or more');
|
|
499
|
-
const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
|
|
500
|
-
const chips = typeof hud === 'object' && hud !== null ? hud : {};
|
|
501
|
-
return {
|
|
502
|
-
style: mapStyle,
|
|
503
|
-
view: viewMode,
|
|
504
|
-
zoom,
|
|
505
|
-
zoomOut,
|
|
506
|
-
hud: { heading: !!chips.heading, alt: !!chips.alt, speed: !!chips.speed },
|
|
507
|
-
introSec,
|
|
508
|
-
outroSec,
|
|
509
|
-
trailColor,
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
export const MIN_DIMENSION = 64;
|
|
513
|
-
export function isValidDimensions(width, height) {
|
|
514
|
-
// NaN-safe: the >= form fails for NaN, where a plain < would let it pass.
|
|
515
|
-
return width >= MIN_DIMENSION && height >= MIN_DIMENSION;
|
|
516
|
-
}
|
|
517
|
-
function validateDimensions(width, height) {
|
|
518
|
-
if (!isValidDimensions(width, height)) {
|
|
519
|
-
throw new Error(`width and height must be at least ${MIN_DIMENSION}`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
export function normalizeDimensions(width, height) {
|
|
523
|
-
return {
|
|
524
|
-
width: Math.max(MIN_DIMENSION, 2 * Math.floor(width / 2)),
|
|
525
|
-
height: Math.max(MIN_DIMENSION, 2 * Math.floor(height / 2)),
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
// One bounds rule for both validator wordings; the message travels with the
|
|
529
|
-
// call so the CLI and IPC surfaces keep their deliberately distinct text.
|
|
530
|
-
function isNonNegative(value) {
|
|
531
|
-
return value >= 0;
|
|
532
|
-
}
|
|
533
|
-
function requireNonNegative(value, message) {
|
|
534
|
-
if (!isNonNegative(value))
|
|
535
|
-
throw new Error(message);
|
|
536
|
-
}
|
|
537
|
-
function isValidWorkerCount(workers) {
|
|
538
|
-
return Number.isInteger(workers) && workers >= 1;
|
|
539
|
-
}
|
|
540
|
-
export function isValidRenderConfig(config) {
|
|
541
|
-
return (isValidDimensions(config.width, config.height) &&
|
|
542
|
-
isValidWorkerCount(config.workers) &&
|
|
543
|
-
isNonNegative(config.zoom) &&
|
|
544
|
-
isNonNegative(config.zoomOut) &&
|
|
545
|
-
isNonNegative(config.introSec) &&
|
|
546
|
-
isNonNegative(config.outroSec) &&
|
|
547
|
-
config.outSuffix !== '');
|
|
548
|
-
}
|
|
549
|
-
export function validateRenderConfig(config) {
|
|
550
|
-
validateDimensions(config.width, config.height);
|
|
551
|
-
if (!isValidWorkerCount(config.workers)) {
|
|
552
|
-
throw new Error('workers must be a positive integer');
|
|
553
|
-
}
|
|
554
|
-
requireNonNegative(config.zoom, 'zoom must be >= 0 (0 = auto-fit)');
|
|
555
|
-
requireNonNegative(config.zoomOut, 'zoom-out must be >= 0');
|
|
556
|
-
if (!isNonNegative(config.introSec) || !isNonNegative(config.outroSec)) {
|
|
557
|
-
throw new Error('intro-sec and outro-sec must be >= 0');
|
|
558
|
-
}
|
|
559
|
-
if (!config.outSuffix)
|
|
560
|
-
throw new Error('out-suffix must not be empty');
|
|
561
|
-
}
|
|
562
|
-
function assertValidFrameRange(range, name = 'frame range') {
|
|
563
|
-
if (!Number.isInteger(range.start) || !Number.isInteger(range.end)) {
|
|
564
|
-
throw new Error(`invalid ${name}: start and end must be integer frame indices`);
|
|
565
|
-
}
|
|
566
|
-
// A single-frame span (start === end) is a valid export range.
|
|
567
|
-
if (range.start < 0 || range.start > range.end) {
|
|
568
|
-
throw new Error(`invalid ${name}: expected 0 <= start <= end, got ${range.start}-${range.end}`);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
export function parseFrameRange(raw, name = 'frame range') {
|
|
572
|
-
const range = parseValue(strictShape({
|
|
573
|
-
start: numberValue(`${name}: start`),
|
|
574
|
-
end: numberValue(`${name}: end`),
|
|
575
|
-
}, {
|
|
576
|
-
invalid: `invalid ${name}`,
|
|
577
|
-
unknownKey: (key) => `unknown ${name} key ${key}`,
|
|
578
|
-
}), raw);
|
|
579
|
-
assertValidFrameRange(range, name);
|
|
580
|
-
return range;
|
|
581
|
-
}
|
|
582
|
-
export function resolveFrameRange(range, frames) {
|
|
583
|
-
if (!range)
|
|
584
|
-
return null;
|
|
585
|
-
assertValidFrameRange(range);
|
|
586
|
-
if (range.end >= frames) {
|
|
587
|
-
throw new Error(`frame range ${range.start}-${range.end} is beyond the recording (${frames} frames)`);
|
|
588
|
-
}
|
|
589
|
-
return range;
|
|
590
|
-
}
|
|
591
|
-
const MAIN_OWNED_KEYS = [
|
|
592
|
-
// TELEMETRY_JSON_ALIAS.inputKey stays stripped as a legacy spelling of
|
|
593
|
-
// trackOut, so neither spelling can leak into an export request's config.
|
|
594
|
-
'outDir', 'outSuffix', 'tileCache', 'browser', 'ffmpeg', 'ffprobe', 'workers', 'capture',
|
|
595
|
-
'skipExisting', 'recurse', 'trackOut', TELEMETRY_JSON_ALIAS.inputKey, 'json', 'quiet',
|
|
596
|
-
];
|
|
597
|
-
function parseRequestConfig(raw, base) {
|
|
598
|
-
if (typeof raw !== 'object' || raw === null) {
|
|
599
|
-
throw new Error('invalid export request: config');
|
|
600
|
-
}
|
|
601
|
-
const flat = { ...raw };
|
|
602
|
-
for (const key of MAIN_OWNED_KEYS)
|
|
603
|
-
delete flat[key];
|
|
604
|
-
const { hud, ...rest } = flat;
|
|
605
|
-
const hudSpec = hud === undefined || hud === null
|
|
606
|
-
? undefined
|
|
607
|
-
: parseValue(hudSpecSchema('export request: config: hud'), hud);
|
|
608
|
-
const config = { ...base, ...normalizeOverrides(rest, 'export request: config') };
|
|
609
|
-
const merged = hudSpec === undefined ? config : { ...config, hud: hudSpec };
|
|
610
|
-
validateRenderConfig(merged);
|
|
611
|
-
return { ...merged, ...normalizeDimensions(merged.width, merged.height) };
|
|
612
|
-
}
|
|
613
|
-
const EXPORT_REQUEST_SCHEMA = z.preprocess(keyedObjectInput, strictShape({
|
|
614
|
-
outPath: z.unknown().optional(),
|
|
615
|
-
config: z.unknown().optional(),
|
|
616
|
-
range: z.unknown().optional(),
|
|
617
|
-
}, {
|
|
618
|
-
invalid: 'invalid export request',
|
|
619
|
-
unknownKey: (key) => `unknown export request key ${key}`,
|
|
620
|
-
}));
|
|
621
|
-
export function parseExportRequest(raw, base) {
|
|
622
|
-
const request = parseValue(EXPORT_REQUEST_SCHEMA, raw);
|
|
623
|
-
const outPath = parseValue(stringValue('export request: outPath'), request.outPath);
|
|
624
|
-
if (!outPath.toLowerCase().endsWith('.mp4')) {
|
|
625
|
-
throw new Error(`export request: outPath must be an .mp4 file: ${outPath}`);
|
|
626
|
-
}
|
|
627
|
-
const range = request.range === undefined || request.range === null
|
|
628
|
-
? null
|
|
629
|
-
: parseFrameRange(request.range);
|
|
630
|
-
return { outPath, config: parseRequestConfig(request.config, base), range };
|
|
631
|
-
}
|