drone-path 0.8.1 → 0.10.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 +43 -0
- package/README.md +18 -25
- package/THIRD-PARTY-NOTICES.md +14 -7
- package/app/ipc.mjs +178 -0
- package/app/main.mjs +10 -150
- package/app/preload.cjs +3 -0
- package/dist/appassets.js +2 -11
- package/dist/apppaths.js +2 -10
- package/dist/appsession.js +59 -59
- package/dist/appstate.js +22 -38
- package/dist/assets.js +0 -7
- package/dist/buildinfo.js +71 -0
- package/dist/cammeta.js +127 -89
- package/dist/changeset-gate.js +0 -7
- package/dist/cli.js +3 -36
- package/dist/config.js +216 -167
- package/dist/configfile.js +0 -8
- package/dist/decimate.js +2 -12
- package/dist/exportjob.js +3 -19
- package/dist/ff.js +2 -27
- package/dist/fftools.js +0 -10
- package/dist/frametime.js +32 -0
- package/dist/geo.js +3 -13
- package/dist/inputs.js +0 -4
- package/dist/manual/anchors.js +1 -7
- package/dist/manual/build.js +0 -6
- package/dist/manual/cliref.js +0 -6
- package/dist/manual/links.js +0 -17
- package/dist/manual/markdown.js +2 -10
- package/dist/manual/model.js +0 -3
- package/dist/manual/module.js +0 -3
- package/dist/manual/nav.js +0 -2
- package/dist/manual/reference.js +1 -4
- package/dist/page.js +3 -26
- package/dist/paths.js +0 -12
- package/dist/plan.js +1 -18
- package/dist/png.js +1 -21
- package/dist/proto.js +4 -4
- package/dist/range.js +0 -8
- package/dist/render.js +38 -165
- package/dist/renderer/dom.js +0 -6
- package/dist/renderer/framemath.js +0 -4
- package/dist/renderer/scene.js +10 -34
- package/dist/renderer/theme.js +58 -10
- package/dist/renderer/tilesources.js +0 -10
- package/dist/renderer/trail.js +1 -12
- package/dist/restyle.js +1 -9
- package/dist/run.js +79 -143
- package/dist/serve.js +0 -13
- package/dist/srt.js +30 -8
- package/dist/summary.js +0 -3
- package/dist/telemetry-json-schema.js +23 -0
- package/dist/telemetry-json.js +113 -0
- package/dist/telemetry-math.js +11 -46
- package/dist/telemetry.js +58 -11
- package/dist/tilecache.js +0 -5
- package/dist/tiles.js +31 -117
- package/package.json +15 -13
- package/dist/renderer/leaflet.js +0 -5
- package/dist/tracing.js +0 -208
package/dist/config.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
// Quality, Preset, HudSpec), their defaults and the parsing/normalizing rules.
|
|
3
|
-
// Feature modules import them from here, and this module stays free of I/O so
|
|
4
|
-
// the app UI can share the vocabulary in its browser bundle. File discovery
|
|
5
|
-
// and the precedence of the config layers live in src/configfile.ts.
|
|
1
|
+
import { z } from 'zod';
|
|
6
2
|
export const CONFIG_FILE_NAME = '.dronepath.json';
|
|
7
|
-
// The config-file selection flag: vocabulary outside the config keys,
|
|
8
|
-
// shared by the CLI and the generated reference so they cannot drift.
|
|
9
3
|
export const CONFIG_FILE_OPTION = {
|
|
10
4
|
flags: '--config <path>',
|
|
11
5
|
help: 'config file (default: .dronepath.json discovered upward from the working directory)',
|
|
@@ -35,17 +29,12 @@ export function parseHud(list) {
|
|
|
35
29
|
}
|
|
36
30
|
return hud;
|
|
37
31
|
}
|
|
38
|
-
// The "alt hides when unavailable" rule, one home for the pipeline and the UI.
|
|
39
32
|
export function resolveHudSpec(hud, hasAlt) {
|
|
40
33
|
return hud.alt && !hasAlt ? { ...hud, alt: false } : hud;
|
|
41
34
|
}
|
|
42
|
-
// What "unavailable" means for the rule above: no altitude sample at all in
|
|
43
|
-
// the telemetry.
|
|
44
35
|
export function hasAltitude(alt) {
|
|
45
36
|
return alt.some((a) => a !== null);
|
|
46
37
|
}
|
|
47
|
-
// The CLI-string form of a HUD spec ("none" when no chip is on), the inverse
|
|
48
|
-
// of parseHud.
|
|
49
38
|
export function formatHud(hud) {
|
|
50
39
|
const parts = [];
|
|
51
40
|
if (hud.heading)
|
|
@@ -56,76 +45,112 @@ export function formatHud(hud) {
|
|
|
56
45
|
parts.push('speed');
|
|
57
46
|
return parts.length ? parts.join(',') : 'none';
|
|
58
47
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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 });
|
|
66
59
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return raw;
|
|
74
|
-
return Number(raw);
|
|
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
|
+
});
|
|
75
66
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
throw new Error(`invalid value for ${name}: ${String(value)}`);
|
|
79
|
-
}
|
|
80
|
-
return value;
|
|
67
|
+
export function numberValue(name) {
|
|
68
|
+
return z.number({ error: invalidNumber(name) });
|
|
81
69
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return value;
|
|
70
|
+
function stringValue(name) {
|
|
71
|
+
return z
|
|
72
|
+
.string({ error: invalidValue(name) })
|
|
73
|
+
.min(1, { error: invalidValue(name) });
|
|
87
74
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
throw new Error(`invalid value for ${name}: ${String(value)} (use ${allowed.join(' | ')})`);
|
|
91
|
-
}
|
|
92
|
-
return value;
|
|
75
|
+
function boolValue(name) {
|
|
76
|
+
return z.boolean({ error: invalidValue(name) });
|
|
93
77
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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);
|
|
98
123
|
}
|
|
99
124
|
export const CONFIG_OPTIONS = [
|
|
100
125
|
{
|
|
101
126
|
key: 'outDir',
|
|
102
127
|
cli: { flags: '--out-dir <dir>', help: 'output folder' },
|
|
103
128
|
default: 'out',
|
|
104
|
-
normalize: (v, name) => ({ outDir:
|
|
129
|
+
normalize: (v, name) => ({ outDir: parseValue(nullableStringValue(name), v) }),
|
|
105
130
|
},
|
|
106
131
|
{
|
|
107
132
|
key: 'outSuffix',
|
|
108
133
|
cli: { flags: '--out-suffix <suffix>', help: 'output name = <basename><suffix>.mp4' },
|
|
109
134
|
default: '_map',
|
|
110
|
-
normalize: (v, name) => ({ outSuffix:
|
|
135
|
+
normalize: (v, name) => ({ outSuffix: parseValue(stringValue(name), v) }),
|
|
111
136
|
},
|
|
112
137
|
{
|
|
113
138
|
key: 'width',
|
|
114
139
|
cli: { flags: '--width <px>', help: 'canvas width in pixels (rounded down to even)', parse: cliNumber },
|
|
115
140
|
default: 768,
|
|
116
|
-
normalize: (v, name) => ({ width:
|
|
141
|
+
normalize: (v, name) => ({ width: parseValue(numberValue(name), v) }),
|
|
117
142
|
},
|
|
118
143
|
{
|
|
119
144
|
key: 'height',
|
|
120
145
|
cli: { flags: '--height <px>', help: 'canvas height in pixels (rounded down to even)', parse: cliNumber },
|
|
121
146
|
default: 768,
|
|
122
|
-
normalize: (v, name) => ({ height:
|
|
147
|
+
normalize: (v, name) => ({ height: parseValue(numberValue(name), v) }),
|
|
123
148
|
},
|
|
124
149
|
{
|
|
125
150
|
key: 'style',
|
|
126
151
|
cli: { flags: '--style <name>', help: 'map look', choices: STYLE_VALUES },
|
|
127
152
|
default: 'satellite',
|
|
128
|
-
normalize: (v, name) => ({ style:
|
|
153
|
+
normalize: (v, name) => ({ style: parseValue(enumValue(name, STYLE_VALUES), v) }),
|
|
129
154
|
},
|
|
130
155
|
{
|
|
131
156
|
key: 'view',
|
|
@@ -135,31 +160,40 @@ export const CONFIG_OPTIONS = [
|
|
|
135
160
|
choices: VIEW_VALUES,
|
|
136
161
|
},
|
|
137
162
|
default: 'follow',
|
|
138
|
-
normalize: (v, name) => ({ view:
|
|
163
|
+
normalize: (v, name) => ({ view: parseValue(enumValue(name, VIEW_VALUES), v) }),
|
|
139
164
|
},
|
|
140
165
|
{
|
|
141
166
|
key: 'zoom',
|
|
142
167
|
cli: { flags: '--zoom <n>', help: 'fixed view zoom level (0 = auto-fit to the track)', parse: cliNumber },
|
|
143
168
|
default: 0,
|
|
144
|
-
normalize: (v, name) => ({ zoom:
|
|
169
|
+
normalize: (v, name) => ({ zoom: parseValue(numberValue(name), v) }),
|
|
145
170
|
},
|
|
146
171
|
{
|
|
147
172
|
key: 'zoomOut',
|
|
148
173
|
cli: { flags: '--zoom-out <n>', help: 'auto-fit only: pull back n zoom levels', parse: cliNumber },
|
|
149
174
|
default: 1,
|
|
150
|
-
normalize: (v, name) => ({ zoomOut:
|
|
175
|
+
normalize: (v, name) => ({ zoomOut: parseValue(numberValue(name), v) }),
|
|
151
176
|
},
|
|
152
177
|
{
|
|
153
178
|
key: 'introSec',
|
|
154
179
|
cli: { flags: '--intro-sec <s>', help: 'intro: zoom in from one level out over s seconds', parse: cliNumber },
|
|
155
180
|
default: 2,
|
|
156
|
-
normalize: (v, name) => ({ introSec:
|
|
181
|
+
normalize: (v, name) => ({ introSec: parseValue(numberValue(name), v) }),
|
|
157
182
|
},
|
|
158
183
|
{
|
|
159
184
|
key: 'outroSec',
|
|
160
185
|
cli: { flags: '--outro-sec <s>', help: 'outro: zoom back out over s seconds', parse: cliNumber },
|
|
161
186
|
default: 2,
|
|
162
|
-
normalize: (v, name) => ({ outroSec:
|
|
187
|
+
normalize: (v, name) => ({ outroSec: parseValue(numberValue(name), v) }),
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
key: 'trailColor',
|
|
191
|
+
cli: {
|
|
192
|
+
flags: '--trail-color <hex>',
|
|
193
|
+
help: 'trail color as hex, RGB or RGBA (e.g. e63946 or #e63946cc; default: the map style\'s color)',
|
|
194
|
+
},
|
|
195
|
+
default: null,
|
|
196
|
+
normalize: (v, name) => ({ trailColor: asTrailColor(v, name) }),
|
|
163
197
|
},
|
|
164
198
|
{
|
|
165
199
|
key: 'hud',
|
|
@@ -168,61 +202,61 @@ export const CONFIG_OPTIONS = [
|
|
|
168
202
|
help: 'comma list of heading,alt,speed - or none (alt hides when unavailable)',
|
|
169
203
|
},
|
|
170
204
|
default: { heading: true, alt: false, speed: false },
|
|
171
|
-
normalize: (v, name) => ({ hud: parseHud(
|
|
205
|
+
normalize: (v, name) => ({ hud: parseHud(parseValue(stringValue(name), v)) }),
|
|
172
206
|
},
|
|
173
207
|
{
|
|
174
208
|
key: 'workers',
|
|
175
209
|
cli: { flags: '--workers <n>', help: 'parallel browser pages', parse: cliNumber },
|
|
176
210
|
default: 4,
|
|
177
|
-
normalize: (v, name) => ({ workers:
|
|
211
|
+
normalize: (v, name) => ({ workers: parseValue(numberValue(name), v) }),
|
|
178
212
|
},
|
|
179
213
|
{
|
|
180
214
|
key: 'capture',
|
|
181
215
|
cli: { flags: '--capture <mode>', help: 'frame capture mode (canvas is parked)', choices: CAPTURE_VALUES },
|
|
182
216
|
default: 'jpeg',
|
|
183
|
-
normalize: (v, name) => ({ capture:
|
|
217
|
+
normalize: (v, name) => ({ capture: parseValue(enumValue(name, CAPTURE_VALUES), v) }),
|
|
184
218
|
},
|
|
185
219
|
{
|
|
186
220
|
key: 'codec',
|
|
187
221
|
cli: { flags: '--codec <name>', help: 'video codec (mp4 container)', choices: CODEC_VALUES },
|
|
188
222
|
default: 'h264',
|
|
189
|
-
normalize: (v, name) => ({ codec:
|
|
223
|
+
normalize: (v, name) => ({ codec: parseValue(enumValue(name, CODEC_VALUES), v) }),
|
|
190
224
|
},
|
|
191
225
|
{
|
|
192
226
|
key: 'quality',
|
|
193
227
|
cli: { flags: '--quality <level>', help: 'encoding quality', choices: QUALITY_VALUES },
|
|
194
228
|
default: 'high',
|
|
195
|
-
normalize: (v, name) => ({ quality:
|
|
229
|
+
normalize: (v, name) => ({ quality: parseValue(enumValue(name, QUALITY_VALUES), v) }),
|
|
196
230
|
},
|
|
197
231
|
{
|
|
198
232
|
key: 'preset',
|
|
199
233
|
cli: { flags: '--preset <name>', help: 'encoding speed', choices: PRESET_VALUES },
|
|
200
234
|
default: 'medium',
|
|
201
|
-
normalize: (v, name) => ({ preset:
|
|
235
|
+
normalize: (v, name) => ({ preset: parseValue(enumValue(name, PRESET_VALUES), v) }),
|
|
202
236
|
},
|
|
203
237
|
{
|
|
204
238
|
key: 'tileCache',
|
|
205
239
|
cli: { flags: '--tile-cache <dir>', help: 'tile cache directory (default: per-user cache dir)' },
|
|
206
240
|
default: '',
|
|
207
|
-
normalize: (v, name) => ({ tileCache:
|
|
241
|
+
normalize: (v, name) => ({ tileCache: parseValue(stringValue(name), v) }),
|
|
208
242
|
},
|
|
209
243
|
{
|
|
210
244
|
key: 'browser',
|
|
211
245
|
cli: { flags: '--browser <path>', help: 'Chromium/Chrome/Edge executable (default: system Chrome/Edge)' },
|
|
212
246
|
default: null,
|
|
213
|
-
normalize: (v, name) => ({ browser:
|
|
247
|
+
normalize: (v, name) => ({ browser: parseValue(nullableStringValue(name), v) }),
|
|
214
248
|
},
|
|
215
249
|
{
|
|
216
250
|
key: 'ffmpeg',
|
|
217
251
|
cli: { flags: '--ffmpeg <path>', help: 'ffmpeg executable (default: embedded binary, then PATH)' },
|
|
218
252
|
default: null,
|
|
219
|
-
normalize: (v, name) => ({ ffmpeg:
|
|
253
|
+
normalize: (v, name) => ({ ffmpeg: parseValue(nullableStringValue(name), v) }),
|
|
220
254
|
},
|
|
221
255
|
{
|
|
222
256
|
key: 'ffprobe',
|
|
223
257
|
cli: { flags: '--ffprobe <path>', help: 'ffprobe executable (default: embedded binary, then PATH)' },
|
|
224
258
|
default: null,
|
|
225
|
-
normalize: (v, name) => ({ ffprobe:
|
|
259
|
+
normalize: (v, name) => ({ ffprobe: parseValue(nullableStringValue(name), v) }),
|
|
226
260
|
},
|
|
227
261
|
{
|
|
228
262
|
key: 'skipExisting',
|
|
@@ -231,33 +265,42 @@ export const CONFIG_OPTIONS = [
|
|
|
231
265
|
help: 'skip recordings whose output already exists and matches the source',
|
|
232
266
|
},
|
|
233
267
|
default: false,
|
|
234
|
-
normalize: (v, name) => ({ skipExisting:
|
|
268
|
+
normalize: (v, name) => ({ skipExisting: parseValue(boolValue(name), v) }),
|
|
235
269
|
},
|
|
236
270
|
{
|
|
237
271
|
key: 'recurse',
|
|
238
272
|
cli: { flags: '--recurse', help: 'scan input folders recursively' },
|
|
239
273
|
default: false,
|
|
240
|
-
normalize: (v, name) => ({ recurse:
|
|
274
|
+
normalize: (v, name) => ({ recurse: parseValue(boolValue(name), v) }),
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
key: 'telemetryJson',
|
|
278
|
+
cli: {
|
|
279
|
+
flags: '--telemetry-json <file>',
|
|
280
|
+
help: 'write one JSON document with per-frame telemetry to <file> (one recording per run)',
|
|
281
|
+
},
|
|
282
|
+
default: null,
|
|
283
|
+
normalize: (v, name) => ({ telemetryJson: parseValue(nullableStringValue(name), v) }),
|
|
241
284
|
},
|
|
242
285
|
{
|
|
243
286
|
key: 'json',
|
|
244
287
|
cli: { flags: '--json', help: 'print one NDJSON summary line per recording on stdout' },
|
|
245
288
|
default: false,
|
|
246
|
-
normalize: (v, name) => ({ json:
|
|
289
|
+
normalize: (v, name) => ({ json: parseValue(boolValue(name), v) }),
|
|
247
290
|
},
|
|
248
291
|
{
|
|
249
292
|
key: 'quiet',
|
|
250
293
|
cli: { flags: '-q, --quiet', help: 'suppress progress output' },
|
|
251
294
|
default: false,
|
|
252
|
-
normalize: (v, name) => ({ quiet:
|
|
295
|
+
normalize: (v, name) => ({ quiet: parseValue(boolValue(name), v) }),
|
|
253
296
|
},
|
|
254
297
|
];
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
298
|
+
const CLI_NUMBER_RX = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
299
|
+
function cliNumber(raw) {
|
|
300
|
+
if (typeof raw !== 'string' || !CLI_NUMBER_RX.test(raw.trim()))
|
|
301
|
+
return raw;
|
|
302
|
+
return Number(raw);
|
|
303
|
+
}
|
|
261
304
|
export function cliDefaultOf(key) {
|
|
262
305
|
const row = CONFIG_OPTIONS.find((r) => r.key === key);
|
|
263
306
|
if (!row)
|
|
@@ -269,23 +312,22 @@ export function cliDefaultOf(key) {
|
|
|
269
312
|
return '';
|
|
270
313
|
return key === 'hud' ? formatHud(value) : String(value);
|
|
271
314
|
}
|
|
272
|
-
// Frozen so no resolved config can corrupt the shared defaults; merges copy
|
|
273
|
-
// the hud spec so every resolved config owns its own mutable copy.
|
|
274
315
|
export const DEFAULT_CONFIG = Object.freeze(Object.fromEntries(CONFIG_OPTIONS.map((row) => [row.key, row.default])));
|
|
275
316
|
Object.freeze(DEFAULT_CONFIG.hud);
|
|
276
|
-
// Keyed lookup built from the option table; a key's normalizer is found by its
|
|
277
|
-
// name, and an unknown key is a usage error naming the origin.
|
|
278
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()]));
|
|
279
319
|
export function normalizeOverrides(raw, origin) {
|
|
320
|
+
parseValue(strictShape(OVERRIDE_SHAPE, {
|
|
321
|
+
invalid: `invalid config overrides in ${origin}`,
|
|
322
|
+
unknownKey: (key) => `unknown config key ${key} in ${origin}`,
|
|
323
|
+
}), raw);
|
|
280
324
|
const out = {};
|
|
281
325
|
for (const key of Object.keys(raw)) {
|
|
282
|
-
const normalize =
|
|
283
|
-
? OVERRIDE_NORMALIZERS[key]
|
|
284
|
-
: null;
|
|
285
|
-
if (!normalize)
|
|
286
|
-
throw new Error(`unknown config key ${key} in ${origin}`);
|
|
326
|
+
const normalize = OVERRIDE_NORMALIZERS[key];
|
|
287
327
|
const value = raw[key];
|
|
288
|
-
if (value === undefined
|
|
328
|
+
if (value === undefined)
|
|
329
|
+
continue;
|
|
330
|
+
if (value === null && DEFAULT_CONFIG[key] !== null)
|
|
289
331
|
continue;
|
|
290
332
|
Object.assign(out, normalize(value, `${origin}: ${key}`));
|
|
291
333
|
}
|
|
@@ -303,13 +345,12 @@ export function settingsPatchOf(config) {
|
|
|
303
345
|
hud: config.hud,
|
|
304
346
|
introSec: config.introSec,
|
|
305
347
|
outroSec: config.outroSec,
|
|
348
|
+
trailColor: config.trailColor,
|
|
306
349
|
codec: config.codec,
|
|
307
350
|
quality: config.quality,
|
|
308
351
|
preset: config.preset,
|
|
309
352
|
};
|
|
310
353
|
}
|
|
311
|
-
// The persisted keys in the vocabulary's table order: the persisted state's
|
|
312
|
-
// shape and its serialization order in one home.
|
|
313
354
|
export const SETTINGS_KEYS = [
|
|
314
355
|
'style',
|
|
315
356
|
'view',
|
|
@@ -318,31 +359,23 @@ export const SETTINGS_KEYS = [
|
|
|
318
359
|
'hud',
|
|
319
360
|
'introSec',
|
|
320
361
|
'outroSec',
|
|
362
|
+
'trailColor',
|
|
321
363
|
'codec',
|
|
322
364
|
'quality',
|
|
323
365
|
'preset',
|
|
324
366
|
];
|
|
325
|
-
|
|
326
|
-
// file): the keys arrive complete and vocabulary-valid, so no layer
|
|
327
|
-
// downstream can hold a value the pipeline would reject. The HUD spec travels
|
|
328
|
-
// as its object form over IPC and as its CLI string in JSON files; both run
|
|
329
|
-
// through the vocabulary's own normalizers.
|
|
367
|
+
const SETTINGS_SHAPE = Object.fromEntries(SETTINGS_KEYS.map((key) => [key, z.unknown().optional()]));
|
|
330
368
|
export function parseSettingsPatch(raw, origin) {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
369
|
+
parseValue(strictShape(SETTINGS_SHAPE, {
|
|
370
|
+
invalid: `invalid settings in ${origin}`,
|
|
371
|
+
unknownKey: (key) => `unknown settings key ${key} in ${origin}`,
|
|
372
|
+
}), raw);
|
|
334
373
|
const flat = { ...raw };
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
if (flat.hud !== undefined && flat.hud !== null && typeof flat.hud !== 'string') {
|
|
343
|
-
flat.hud = formatHud(parseHudObject(flat.hud, `${origin}: hud`));
|
|
344
|
-
}
|
|
345
|
-
const patch = normalizeOverrides(flat, origin);
|
|
374
|
+
const hud = patchHud(flat.hud, `${origin}: hud`);
|
|
375
|
+
delete flat.hud;
|
|
376
|
+
const patch = { ...normalizeOverrides(flat, origin) };
|
|
377
|
+
if (hud !== undefined)
|
|
378
|
+
patch.hud = hud;
|
|
346
379
|
for (const key of SETTINGS_KEYS) {
|
|
347
380
|
if (patch[key] === undefined) {
|
|
348
381
|
throw new Error(`missing settings key ${key} in ${origin}`);
|
|
@@ -352,18 +385,49 @@ export function parseSettingsPatch(raw, origin) {
|
|
|
352
385
|
validateRenderConfig({ ...DEFAULT_CONFIG, ...settings, hud: { ...settings.hud } });
|
|
353
386
|
return settings;
|
|
354
387
|
}
|
|
355
|
-
// The
|
|
356
|
-
//
|
|
388
|
+
// The pick-request flavor of look settings: its error wording is the legacy
|
|
389
|
+
// IPC wording, deliberately distinct from validateRenderConfig's CLI wording.
|
|
390
|
+
export function parseLookSettings(raw) {
|
|
391
|
+
const look = typeof raw === 'object' && raw !== null ? raw : {};
|
|
392
|
+
const { style, view, hud } = look;
|
|
393
|
+
const mapStyle = parseValue(z.enum(STYLE_VALUES, {
|
|
394
|
+
error: (issue) => `unknown map style: ${String(issue.input)}`,
|
|
395
|
+
}), style);
|
|
396
|
+
const viewMode = parseValue(z.enum(VIEW_VALUES, {
|
|
397
|
+
error: (issue) => `unknown view: ${String(issue.input)}`,
|
|
398
|
+
}), view);
|
|
399
|
+
const zoom = parseValue(numberValue('zoom'), look.zoom);
|
|
400
|
+
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');
|
|
405
|
+
const introSec = parseValue(numberValue('intro'), look.introSec);
|
|
406
|
+
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');
|
|
411
|
+
const trailColor = asTrailColor(look.trailColor ?? null, 'trail color');
|
|
412
|
+
const chips = typeof hud === 'object' && hud !== null ? hud : {};
|
|
413
|
+
return {
|
|
414
|
+
style: mapStyle,
|
|
415
|
+
view: viewMode,
|
|
416
|
+
zoom,
|
|
417
|
+
zoomOut,
|
|
418
|
+
hud: { heading: !!chips.heading, alt: !!chips.alt, speed: !!chips.speed },
|
|
419
|
+
introSec,
|
|
420
|
+
outroSec,
|
|
421
|
+
trailColor,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
357
424
|
export const MIN_DIMENSION = 64;
|
|
358
|
-
//
|
|
425
|
+
// Negated comparisons are NaN-safe (NaN would slip through <).
|
|
359
426
|
export function validateDimensions(width, height) {
|
|
360
427
|
if (!(width >= MIN_DIMENSION) || !(height >= MIN_DIMENSION)) {
|
|
361
428
|
throw new Error(`width and height must be at least ${MIN_DIMENSION}`);
|
|
362
429
|
}
|
|
363
430
|
}
|
|
364
|
-
// The documented "rounded down to even" rule (keeping the MIN_DIMENSION
|
|
365
|
-
// floor), in one home: every config producer applies it so a RenderConfig
|
|
366
|
-
// always holds the effective canvas the renderer gets.
|
|
367
431
|
export function normalizeDimensions(width, height) {
|
|
368
432
|
return {
|
|
369
433
|
width: Math.max(MIN_DIMENSION, 2 * Math.floor(width / 2)),
|
|
@@ -385,8 +449,6 @@ export function validateRenderConfig(config) {
|
|
|
385
449
|
if (!config.outSuffix)
|
|
386
450
|
throw new Error('out-suffix must not be empty');
|
|
387
451
|
}
|
|
388
|
-
// One rule for a usable frame range, shared by the request parser and the
|
|
389
|
-
// pipeline's range guard so they cannot drift.
|
|
390
452
|
export function assertValidFrameRange(range, name = 'frame range') {
|
|
391
453
|
if (!Number.isInteger(range.start) || !Number.isInteger(range.end)) {
|
|
392
454
|
throw new Error(`invalid ${name}: start and end must be integer frame indices`);
|
|
@@ -396,46 +458,29 @@ export function assertValidFrameRange(range, name = 'frame range') {
|
|
|
396
458
|
}
|
|
397
459
|
}
|
|
398
460
|
export function parseFrameRange(raw, name = 'frame range') {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const start = asNumber(r.start, `${name}: start`);
|
|
409
|
-
const end = asNumber(r.end, `${name}: end`);
|
|
410
|
-
assertValidFrameRange({ start, end }, name);
|
|
411
|
-
return { start, end };
|
|
461
|
+
const range = parseValue(strictShape({
|
|
462
|
+
start: numberValue(`${name}: start`),
|
|
463
|
+
end: numberValue(`${name}: end`),
|
|
464
|
+
}, {
|
|
465
|
+
invalid: `invalid ${name}`,
|
|
466
|
+
unknownKey: (key) => `unknown ${name} key ${key}`,
|
|
467
|
+
}), raw);
|
|
468
|
+
assertValidFrameRange(range, name);
|
|
469
|
+
return range;
|
|
412
470
|
}
|
|
413
|
-
function
|
|
414
|
-
if (
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
if (key !== 'heading' && key !== 'alt' && key !== 'speed') {
|
|
420
|
-
throw new Error(`unknown key ${key} in ${name}`);
|
|
421
|
-
}
|
|
471
|
+
export function resolveRange(range, frames) {
|
|
472
|
+
if (!range)
|
|
473
|
+
return null;
|
|
474
|
+
assertValidFrameRange(range);
|
|
475
|
+
if (range.end >= frames) {
|
|
476
|
+
throw new Error(`frame range ${range.start}-${range.end} is beyond the recording (${frames} frames)`);
|
|
422
477
|
}
|
|
423
|
-
return
|
|
424
|
-
heading: asBool(h.heading, `${name}: heading`),
|
|
425
|
-
alt: asBool(h.alt, `${name}: alt`),
|
|
426
|
-
speed: asBool(h.speed, `${name}: speed`),
|
|
427
|
-
};
|
|
478
|
+
return range;
|
|
428
479
|
}
|
|
429
|
-
// Machine-owned settings the renderer never chooses: the main process's
|
|
430
|
-
// resolved values stay authoritative, so a snapshot cannot redirect the tile
|
|
431
|
-
// cache, the browser, the worker count or the CLI-only switches.
|
|
432
480
|
const MAIN_OWNED_KEYS = [
|
|
433
481
|
'outDir', 'outSuffix', 'tileCache', 'browser', 'ffmpeg', 'ffprobe', 'workers', 'capture',
|
|
434
|
-
'skipExisting', 'recurse', 'json', 'quiet',
|
|
482
|
+
'skipExisting', 'recurse', 'telemetryJson', 'json', 'quiet',
|
|
435
483
|
];
|
|
436
|
-
// The renderer sends the look and the export dimensions; everything else comes
|
|
437
|
-
// from the main process. The HUD spec travels in its CLI string form so the
|
|
438
|
-
// vocabulary's own normalizers stay the single validation home.
|
|
439
484
|
function parseRequestConfig(raw, base) {
|
|
440
485
|
if (typeof raw !== 'object' || raw === null) {
|
|
441
486
|
throw new Error('invalid export request: config');
|
|
@@ -443,27 +488,31 @@ function parseRequestConfig(raw, base) {
|
|
|
443
488
|
const flat = { ...raw };
|
|
444
489
|
for (const key of MAIN_OWNED_KEYS)
|
|
445
490
|
delete flat[key];
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
491
|
+
const { hud, ...rest } = flat;
|
|
492
|
+
const hudSpec = hud === undefined || hud === null
|
|
493
|
+
? undefined
|
|
494
|
+
: parseValue(hudSpecSchema('export request: config: hud'), hud);
|
|
495
|
+
const config = { ...base, ...normalizeOverrides(rest, 'export request: config') };
|
|
496
|
+
const merged = hudSpec === undefined ? config : { ...config, hud: hudSpec };
|
|
497
|
+
validateRenderConfig(merged);
|
|
498
|
+
return { ...merged, ...normalizeDimensions(merged.width, merged.height) };
|
|
452
499
|
}
|
|
500
|
+
const EXPORT_REQUEST_SCHEMA = z.preprocess(keyedObjectInput, strictShape({
|
|
501
|
+
outPath: z.unknown().optional(),
|
|
502
|
+
config: z.unknown().optional(),
|
|
503
|
+
range: z.unknown().optional(),
|
|
504
|
+
}, {
|
|
505
|
+
invalid: 'invalid export request',
|
|
506
|
+
unknownKey: (key) => `unknown export request key ${key}`,
|
|
507
|
+
}));
|
|
453
508
|
export function parseExportRequest(raw, base) {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
const r = raw;
|
|
458
|
-
for (const key of Object.keys(r)) {
|
|
459
|
-
if (key !== 'outPath' && key !== 'config' && key !== 'range') {
|
|
460
|
-
throw new Error(`unknown export request key ${key}`);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
const outPath = asString(r.outPath, 'export request: outPath');
|
|
509
|
+
const request = parseValue(EXPORT_REQUEST_SCHEMA, raw);
|
|
510
|
+
const outPath = parseValue(stringValue('export request: outPath'), request.outPath);
|
|
464
511
|
if (!outPath.toLowerCase().endsWith('.mp4')) {
|
|
465
512
|
throw new Error(`export request: outPath must be an .mp4 file: ${outPath}`);
|
|
466
513
|
}
|
|
467
|
-
const range =
|
|
468
|
-
|
|
514
|
+
const range = request.range === undefined || request.range === null
|
|
515
|
+
? null
|
|
516
|
+
: parseFrameRange(request.range);
|
|
517
|
+
return { outPath, config: parseRequestConfig(request.config, base), range };
|
|
469
518
|
}
|
package/dist/configfile.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
// Config file discovery and layer resolution: the imperative side of the
|
|
2
|
-
// option precedence (CLI flags > config file > built-in defaults). The config
|
|
3
|
-
// file is discovered upward from the working directory unless --config names
|
|
4
|
-
// one. The vocabulary itself stays pure in src/config.ts.
|
|
5
1
|
import fs from 'node:fs';
|
|
6
2
|
import path from 'node:path';
|
|
7
3
|
import { userDataDir } from './apppaths.js';
|
|
8
4
|
import { CONFIG_FILE_NAME, DEFAULT_CONFIG, normalizeDimensions, normalizeOverrides, validateRenderConfig, } from './config.js';
|
|
9
|
-
// DRONEPATH_TILE_CACHE overrides the per-user cache directory.
|
|
10
5
|
export function defaultTileCache() {
|
|
11
6
|
const override = process.env['DRONEPATH_TILE_CACHE'];
|
|
12
7
|
if (override)
|
|
@@ -52,9 +47,6 @@ function mergeConfigLayers(fileCfg, cli) {
|
|
|
52
47
|
...DEFAULT_CONFIG,
|
|
53
48
|
...fileCfg,
|
|
54
49
|
...cli,
|
|
55
|
-
// hud is an object; Partial spread replaces it wholesale, which is what
|
|
56
|
-
// we want. The winner is copied so no resolved config shares mutable
|
|
57
|
-
// state with DEFAULT_CONFIG or another layer.
|
|
58
50
|
hud: { ...(cli.hud ?? fileCfg.hud ?? DEFAULT_CONFIG.hud) },
|
|
59
51
|
};
|
|
60
52
|
}
|