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/decimate.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
// Up-front trail simplification: Douglas-Peucker in Web Mercator pixel space
|
|
2
|
-
// at the working zoom, so the drawn trail deviates from the flown track by
|
|
3
|
-
// less than about one pixel while its point count stays bounded regardless
|
|
4
|
-
// of flight length. Input arrays are index-aligned to video frames.
|
|
5
1
|
import { project } from './geo.js';
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const DEFAULT_EPSILON_PX = 1;
|
|
3
|
+
const DEFAULT_MAX_POINTS = 3000;
|
|
8
4
|
export function decimateTrack(lat, lon, zoom, options = {}) {
|
|
9
5
|
const epsilonPx = options.epsilonPx ?? DEFAULT_EPSILON_PX;
|
|
10
6
|
const maxPoints = options.maxPoints ?? DEFAULT_MAX_POINTS;
|
|
@@ -26,9 +22,6 @@ export function decimateTrack(lat, lon, zoom, options = {}) {
|
|
|
26
22
|
px[i] = project(lon[i], lat[i], zoom);
|
|
27
23
|
let keep = douglasPeucker(px, epsilonPx);
|
|
28
24
|
if (keep.length > maxPoints) {
|
|
29
|
-
// The cap is a promise (<=3k visible points on a 20 min flight), so the
|
|
30
|
-
// epsilon doubles until it holds; geometric growth keeps that
|
|
31
|
-
// deterministic and cheap (one or two extra passes in practice).
|
|
32
25
|
let hi = epsilonPx > 0 ? epsilonPx * 2 : 1;
|
|
33
26
|
let hiKeep = douglasPeucker(px, hi);
|
|
34
27
|
while (hiKeep.length > maxPoints) {
|
|
@@ -45,7 +38,6 @@ export function decimateTrack(lat, lon, zoom, options = {}) {
|
|
|
45
38
|
}
|
|
46
39
|
return track;
|
|
47
40
|
}
|
|
48
|
-
// Iterative (stack-based) so adversarial tracks cannot blow the call stack.
|
|
49
41
|
function douglasPeucker(px, epsilon) {
|
|
50
42
|
const n = px.length;
|
|
51
43
|
const keep = new Uint8Array(n);
|
|
@@ -64,8 +56,6 @@ function douglasPeucker(px, epsilon) {
|
|
|
64
56
|
let maxIdx = -1;
|
|
65
57
|
for (let i = start + 1; i < end; i++) {
|
|
66
58
|
const d = distanceToSegment(px[i], a, b);
|
|
67
|
-
// Ties go to the middle-most point so regular patterns (hover
|
|
68
|
-
// jitter, zigzags) split evenly instead of degenerating to O(n^2).
|
|
69
59
|
if (d > maxDist ||
|
|
70
60
|
(d === maxDist && Math.abs(i - mid) < Math.abs(maxIdx - mid))) {
|
|
71
61
|
maxDist = d;
|
package/dist/exportjob.js
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
// The desktop app's export job runner, free of Electron APIs like
|
|
2
|
-
// src/appsession.ts: one blocking job at a time that renders to a working
|
|
3
|
-
// file and replaces the destination only after the output is verified, so a
|
|
4
|
-
// failed export never destroys a pre-existing file.
|
|
5
1
|
import fs from 'node:fs';
|
|
6
2
|
import path from 'node:path';
|
|
7
3
|
import { errorMessage } from './errors.js';
|
|
8
4
|
import { samePath, uniquePath } from './paths.js';
|
|
9
5
|
import { processRecording } from './run.js';
|
|
10
|
-
// The pipeline is called exactly like the CLI calls it: one job, the
|
|
11
|
-
// snapshot's config, the frozen range. The deps let an in-app export warm
|
|
12
|
-
// through the app's shared tile queue instead of a budget of its own.
|
|
13
6
|
const runViaPipeline = (deps) => (videoPath, request, log, workingPath, signal, onCapture) => processRecording(videoPath, request.config, log, workingPath, {
|
|
14
7
|
range: request.range ?? undefined,
|
|
15
8
|
signal,
|
|
16
9
|
onCapture,
|
|
17
10
|
deps,
|
|
18
11
|
});
|
|
19
|
-
// The working file
|
|
20
|
-
// from it) and share the destination's directory so the final rename stays
|
|
21
|
-
// on one volume. Existing names are never reused or deleted: a stray file
|
|
22
|
-
// there may belong to someone else.
|
|
12
|
+
// The working file keeps the .mp4 suffix: ffmpeg infers the container from it.
|
|
23
13
|
function workingPathFor(outPath) {
|
|
24
14
|
const dir = path.dirname(outPath);
|
|
25
15
|
const stem = `${path.basename(outPath, path.extname(outPath))}.partial`;
|
|
26
16
|
return uniquePath(dir, stem, '.mp4', (candidate) => fs.existsSync(candidate));
|
|
27
17
|
}
|
|
28
|
-
// Best-effort removal of our own working file; a cleanup failure must never
|
|
29
|
-
// mask the job's real error.
|
|
30
18
|
function removeQuietly(working) {
|
|
31
19
|
try {
|
|
32
20
|
fs.rmSync(working, { force: true });
|
|
33
21
|
}
|
|
34
22
|
catch {
|
|
35
|
-
//
|
|
23
|
+
// best-effort removal; a cleanup failure must never throw from here
|
|
36
24
|
}
|
|
37
25
|
}
|
|
38
|
-
// The module's core invariant: the destination is replaced only after the
|
|
39
|
-
// render is complete and verified. A failed swap must keep the finished
|
|
40
|
-
// render at the working path (e.g. when a player holds the destination open).
|
|
41
26
|
function swapIntoPlace(working, outPath) {
|
|
42
27
|
try {
|
|
43
28
|
fs.renameSync(working, outPath);
|
|
@@ -84,8 +69,7 @@ export function createExportRunner(options) {
|
|
|
84
69
|
const controller = new AbortController();
|
|
85
70
|
job = { abort: () => controller.abort() };
|
|
86
71
|
const working = workingPathFor(request.outPath);
|
|
87
|
-
// The catch
|
|
88
|
-
// broken chain): an unhandled rejection here would kill the process.
|
|
72
|
+
// The catch guards a consumer's throwing onDone: an unhandled rejection here would kill the process.
|
|
89
73
|
void execute(videoPath, request, working, controller)
|
|
90
74
|
.then((outcome) => {
|
|
91
75
|
job = null;
|
package/dist/ff.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// ffmpeg and ffprobe invocation: the resolved tool paths come from
|
|
2
|
-
// src/fftools.ts (override, embedded binary, then PATH).
|
|
3
1
|
import { execFile } from 'node:child_process';
|
|
4
2
|
import { promisify } from 'node:util';
|
|
3
|
+
import { framesForSeconds, parseFpsRate, parseRate } from './frametime.js';
|
|
5
4
|
const execFileAsync = promisify(execFile);
|
|
6
5
|
const INSTALL_HINT = 'point --ffmpeg/--ffprobe at your executables, or install ffmpeg (includes ' +
|
|
7
6
|
'ffprobe) and make sure both are on PATH, e.g. "winget install Gyan.FFmpeg" ' +
|
|
@@ -22,27 +21,6 @@ export async function ffprobeJson(tools, videoPath, args) {
|
|
|
22
21
|
const { stdout } = await execFileAsync(tools.ffprobe, ['-v', 'error', ...args, videoPath], { maxBuffer: FFPROBE_MAX_BUFFER });
|
|
23
22
|
return JSON.parse(stdout || '{}');
|
|
24
23
|
}
|
|
25
|
-
// One split of ffprobe's rate wire format ("30" or "30000/1001"), with each
|
|
26
|
-
// consumer's own policy on top: the probe needs a usable rate, the output
|
|
27
|
-
// verification only reads a value.
|
|
28
|
-
function parseRate(str) {
|
|
29
|
-
const [num, den] = str.split('/').map(Number);
|
|
30
|
-
return Number.isFinite(num) ? { num, den } : null;
|
|
31
|
-
}
|
|
32
|
-
function parseFpsRate(str) {
|
|
33
|
-
const rate = str ? parseRate(str) : null;
|
|
34
|
-
if (!rate || !Number.isFinite(rate.den) || rate.den === 0 || rate.num === 0) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const { num } = rate;
|
|
38
|
-
const den = rate.den;
|
|
39
|
-
return {
|
|
40
|
-
num,
|
|
41
|
-
den,
|
|
42
|
-
value: num / den,
|
|
43
|
-
str: den === 1 ? String(num) : `${num}/${den}`,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
24
|
function parseCount(text) {
|
|
47
25
|
return Number.parseInt(text ?? '', 10);
|
|
48
26
|
}
|
|
@@ -65,11 +43,9 @@ export async function probeVideo(tools, videoPath, log = () => { }) {
|
|
|
65
43
|
const durationSec = Number.parseFloat(format.duration ?? '');
|
|
66
44
|
let frames = parseCount(stream.nb_frames);
|
|
67
45
|
if (!Number.isFinite(frames) || frames <= 0) {
|
|
68
|
-
frames =
|
|
46
|
+
frames = framesForSeconds(fps.value, durationSec);
|
|
69
47
|
log('warning: nb_frames missing, using duration x fps');
|
|
70
48
|
}
|
|
71
|
-
// A NaN frame count would flow into renderVideo (zero workers, empty
|
|
72
|
-
// ffmpeg input) and fail much later with a confusing message.
|
|
73
49
|
if (!Number.isFinite(frames) || frames <= 0) {
|
|
74
50
|
throw new Error(`could not determine the frame count of ${videoPath} ` +
|
|
75
51
|
'(nb_frames missing and duration unusable)');
|
|
@@ -108,7 +84,6 @@ async function probeRateFrames(ffprobe, file) {
|
|
|
108
84
|
], { maxBuffer: 1 << 20 });
|
|
109
85
|
return stdout.trim();
|
|
110
86
|
}
|
|
111
|
-
// Missing or unreadable outputs count as a mismatch, not an error.
|
|
112
87
|
export async function outputMatchesSource(tools, src, out) {
|
|
113
88
|
try {
|
|
114
89
|
const [srcRate, srcFrames] = (await probeRateFrames(tools.ffprobe, src)).split(',');
|
package/dist/fftools.js
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
// Where the ffmpeg and ffprobe executables come from at runtime: an explicit
|
|
2
|
-
// override, then the embedded binaries (the packaged app's extraResources, or
|
|
3
|
-
// the optional ffmpeg-ffprobe-static package in dev/CLI installs), then PATH.
|
|
4
|
-
// Pure decision core with an injectable environment so the resolution order is
|
|
5
|
-
// testable without touching the filesystem or spawning anything.
|
|
6
1
|
import fs from 'node:fs';
|
|
7
2
|
import { createRequire } from 'node:module';
|
|
8
3
|
import path from 'node:path';
|
|
9
|
-
// A bare command name defers to spawn's PATH lookup; anything that looks like
|
|
10
|
-
// a path is the documented `<path>` override and must name a real file.
|
|
11
4
|
function isPathLike(value) {
|
|
12
5
|
return value.includes('/') || value.includes('\\') || path.isAbsolute(value);
|
|
13
6
|
}
|
|
@@ -31,9 +24,6 @@ function packagedCandidate(tool) {
|
|
|
31
24
|
const resourcesPath = process.resourcesPath;
|
|
32
25
|
return resourcesPath ? path.join(resourcesPath, 'ff', exeName(tool)) : null;
|
|
33
26
|
}
|
|
34
|
-
// The optional ffmpeg-ffprobe-static package may be absent (unsupported
|
|
35
|
-
// platform, --omit=optional, a failed install download) and must never crash
|
|
36
|
-
// module loading: resolve it lazily.
|
|
37
27
|
function devCandidate(tool) {
|
|
38
28
|
try {
|
|
39
29
|
const mod = createRequire(import.meta.url)('ffmpeg-ffprobe-static');
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function parseRate(str) {
|
|
2
|
+
const [num, den] = str.split('/').map(Number);
|
|
3
|
+
return Number.isFinite(num) ? { num, den } : null;
|
|
4
|
+
}
|
|
5
|
+
export function parseFpsRate(str) {
|
|
6
|
+
const rate = str ? parseRate(str) : null;
|
|
7
|
+
if (!rate || !Number.isFinite(rate.den) || rate.den === 0 || rate.num === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
const { num } = rate;
|
|
11
|
+
const den = rate.den;
|
|
12
|
+
return {
|
|
13
|
+
num,
|
|
14
|
+
den,
|
|
15
|
+
value: num / den,
|
|
16
|
+
str: den === 1 ? String(num) : `${num}/${den}`,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function formatFps(rate) {
|
|
20
|
+
const ratio = /^(\d+)\/(\d+)$/.exec(rate);
|
|
21
|
+
const num = ratio ? Number(ratio[1]) : Number(rate);
|
|
22
|
+
const den = ratio ? Number(ratio[2]) : 1;
|
|
23
|
+
if (!(num > 0) || !(den > 0))
|
|
24
|
+
return rate;
|
|
25
|
+
return `${Math.round((num / den) * 100) / 100} fps`;
|
|
26
|
+
}
|
|
27
|
+
export function timeAt(frame, fps) {
|
|
28
|
+
return fps > 0 ? frame / fps : 0;
|
|
29
|
+
}
|
|
30
|
+
export function framesForSeconds(fps, seconds) {
|
|
31
|
+
return Math.round(fps * seconds);
|
|
32
|
+
}
|
package/dist/geo.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const EARTH_RADIUS_M = 6371008.8; // mean Earth radius
|
|
1
|
+
const EARTH_RADIUS_M = 6371008.8;
|
|
3
2
|
const DEG_TO_RAD = Math.PI / 180;
|
|
4
3
|
const RAD_TO_DEG = 180 / Math.PI;
|
|
5
|
-
//
|
|
6
|
-
// sidecar and CAM meta alike): a finite WGS84 pair in range that is not
|
|
7
|
-
// exactly the (0, 0) "no GPS lock" placeholder DJI writes before the first
|
|
8
|
-
// fix. Near-equator and near-prime-meridian coordinates are real fixes;
|
|
9
|
-
// out-of-range values never are.
|
|
4
|
+
// (0, 0) is DJI's "no GPS lock" placeholder before the first fix, not a real fix.
|
|
10
5
|
export function isGpsFix(lat, lon) {
|
|
11
6
|
return (Number.isFinite(lat) &&
|
|
12
7
|
Number.isFinite(lon) &&
|
|
@@ -16,9 +11,6 @@ export function isGpsFix(lat, lon) {
|
|
|
16
11
|
lon < 180 &&
|
|
17
12
|
!(lat === 0 && lon === 0));
|
|
18
13
|
}
|
|
19
|
-
// The fix/no-lock decision as a value: a real fix or null. Parsers decide
|
|
20
|
-
// once at this point and carry `fix: LatLon | null` from there on, so no
|
|
21
|
-
// downstream code re-litigates coordinates or defends half-set pairs.
|
|
22
14
|
export function gpsFix(lat, lon) {
|
|
23
15
|
return lat !== null && lon !== null && isGpsFix(lat, lon) ? { lat, lon } : null;
|
|
24
16
|
}
|
|
@@ -31,7 +23,6 @@ export function haversineM(a, b) {
|
|
|
31
23
|
Math.cos(latARad) * Math.cos(latBRad) * Math.sin(deltaLonRad / 2) ** 2;
|
|
32
24
|
return 2 * EARTH_RADIUS_M * Math.asin(Math.min(1, Math.sqrt(haversine)));
|
|
33
25
|
}
|
|
34
|
-
// Initial bearing, degrees clockwise from north, range [0, 360).
|
|
35
26
|
export function bearingDeg(a, b) {
|
|
36
27
|
const latARad = a.lat * DEG_TO_RAD;
|
|
37
28
|
const latBRad = b.lat * DEG_TO_RAD;
|
|
@@ -52,8 +43,7 @@ export function circularMeanDeg(degList) {
|
|
|
52
43
|
return degList[0] ?? 0;
|
|
53
44
|
return (Math.atan2(sumSin, sumCos) * RAD_TO_DEG + 360) % 360;
|
|
54
45
|
}
|
|
55
|
-
// Web Mercator (EPSG:3857) global
|
|
56
|
-
// origin at the north-west corner (Leaflet convention).
|
|
46
|
+
// Web Mercator (EPSG:3857) global pixels, 256 px tiles, NW origin (Leaflet convention).
|
|
57
47
|
export function project(lon, lat, zoom) {
|
|
58
48
|
const scale = 256 * 2 ** zoom;
|
|
59
49
|
const x = ((lon + 180) / 360) * scale;
|
package/dist/inputs.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
// The one recording-extension rule: the CLI input scan and the app's pick
|
|
4
|
-
// check share it, so accepting another container (e.g. .MOV) is one edit.
|
|
5
3
|
export function isRecordingName(name) {
|
|
6
4
|
return name.toLowerCase().endsWith('.mp4');
|
|
7
5
|
}
|
|
8
|
-
// The recording's stem: sidecar lookup and output naming both key on it.
|
|
9
6
|
export function videoBaseName(filePath) {
|
|
10
7
|
return path.basename(filePath).replace(/\.[^.]+$/, '');
|
|
11
8
|
}
|
|
12
|
-
// Sidecar lookup matches the video basename, case-insensitively (.SRT vs .srt).
|
|
13
9
|
export function findSrtSidecar(videoPath) {
|
|
14
10
|
const dir = path.dirname(videoPath);
|
|
15
11
|
const base = videoBaseName(videoPath);
|
package/dist/manual/anchors.js
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
// GitHub-compatible heading anchors: the same slug GitHub derives for a
|
|
2
|
-
// heading so in-repo links and in-app links resolve to the same anchor.
|
|
3
1
|
const SLUG_STRIP = /[^\p{L}\p{N}\s_-]/gu;
|
|
4
|
-
/** The anchor GitHub gives a heading of plain `text`. */
|
|
5
2
|
export function githubSlug(text) {
|
|
6
3
|
return text
|
|
7
4
|
.toLowerCase()
|
|
8
5
|
.replace(SLUG_STRIP, '')
|
|
9
6
|
.replace(/ /g, '-');
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
* Slugs one document's headings with GitHub's duplicate rule: the first
|
|
13
|
-
* "Foo" stays "foo", later ones become "foo-1", "foo-2", ...
|
|
14
|
-
*/
|
|
8
|
+
// GitHub's duplicate rule: the first "Foo" stays "foo", later ones become "foo-1", "foo-2", ...
|
|
15
9
|
export function createSlugger() {
|
|
16
10
|
const seen = new Map();
|
|
17
11
|
return (text) => {
|
package/dist/manual/build.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// The manual build: reads docs/user/*.md and docs/images, validates the
|
|
2
|
-
// corpus, then emits the typed UI module and the bundled images. Imperative
|
|
3
|
-
// shell over the pure compiler; paths are injectable so tests run it against
|
|
4
|
-
// a temporary corpus.
|
|
5
1
|
import fs from 'node:fs';
|
|
6
2
|
import path from 'node:path';
|
|
7
3
|
import { fileURLToPath } from 'node:url';
|
|
@@ -9,7 +5,6 @@ import { compileMarkdown } from './markdown.js';
|
|
|
9
5
|
import { bundleModuleSource } from './module.js';
|
|
10
6
|
import { navFromIndex } from './nav.js';
|
|
11
7
|
import { pageSlugOf, sourceNameOf, validateCorpus } from './links.js';
|
|
12
|
-
/** The repository's real paths, resolved from a built or source tree. */
|
|
13
8
|
export function defaultManualPaths(root) {
|
|
14
9
|
return {
|
|
15
10
|
userDir: path.join(root, 'docs', 'user'),
|
|
@@ -43,7 +38,6 @@ export function buildManual(paths) {
|
|
|
43
38
|
if (issues.length > 0) {
|
|
44
39
|
throw new Error(`manual corpus has ${issues.length} issue(s):\n${issues.map((i) => ` - ${i}`).join('\n')}`);
|
|
45
40
|
}
|
|
46
|
-
// The nav comes from the index; pages sort by slug so the bundle is stable.
|
|
47
41
|
const bundle = {
|
|
48
42
|
nav: index ? navFromIndex(index) : [],
|
|
49
43
|
pages: {},
|
package/dist/manual/cliref.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// The generated CLI/config reference: one table over the option vocabulary in
|
|
2
|
-
// src/config.ts, plus the config-file flag. The result is checked in as
|
|
3
|
-
// docs/user/cli-reference.md so GitHub renders it; a unit test compares the
|
|
4
|
-
// checked-in file against this generator so the two cannot drift.
|
|
5
1
|
import { CONFIG_FILE_OPTION, CONFIG_OPTIONS, cliDefaultOf } from '../config.js';
|
|
6
2
|
function defaultCell(key) {
|
|
7
3
|
const value = cliDefaultOf(key);
|
|
@@ -10,8 +6,6 @@ function defaultCell(key) {
|
|
|
10
6
|
return value === '' ? '—' : `\`${value}\``;
|
|
11
7
|
}
|
|
12
8
|
function describe(row) {
|
|
13
|
-
// Angle brackets in help text would read as HTML on GitHub; the entity form
|
|
14
|
-
// renders back to "<" and ">" everywhere.
|
|
15
9
|
const help = row.cli.help.replace(/</g, '<').replace(/>/g, '>');
|
|
16
10
|
return row.cli.choices ? `${help} (choices: ${row.cli.choices.join(', ')})` : help;
|
|
17
11
|
}
|
package/dist/manual/links.js
CHANGED
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
// Manual reference rules: what an internal link or image may point at, and
|
|
2
|
-
// the pure validation that keeps the checked-in corpus consistent. The
|
|
3
|
-
// compiler rewrites what parses here; validation then proves every reference
|
|
4
|
-
// resolves inside the corpus.
|
|
5
1
|
const SCHEME_RX = /^[a-z][a-z0-9+.-]*:/i;
|
|
6
|
-
/** README.md is the index page "index"; foo.md is "foo". */
|
|
7
2
|
export function pageSlugOf(file) {
|
|
8
3
|
const base = file.split('/').pop() ?? file;
|
|
9
4
|
return base === 'README.md' ? 'index' : base.replace(/\.md$/, '');
|
|
10
5
|
}
|
|
11
|
-
/** True for links that leave the manual (web, mail). */
|
|
12
6
|
export function isExternalTarget(raw) {
|
|
13
7
|
return SCHEME_RX.test(raw);
|
|
14
8
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Parses an internal Markdown link target: "foo.md", "foo.md#bar", "#bar"
|
|
17
|
-
* (same page). Anything else returns null and counts as unknown.
|
|
18
|
-
*/
|
|
19
9
|
export function parsePageLink(raw, currentSlug) {
|
|
20
10
|
const [path, hash, ...rest] = raw.split('#');
|
|
21
11
|
if (rest.length > 0)
|
|
@@ -28,16 +18,10 @@ export function parsePageLink(raw, currentSlug) {
|
|
|
28
18
|
return null;
|
|
29
19
|
return { slug: pageSlugOf(clean), anchor };
|
|
30
20
|
}
|
|
31
|
-
/** Parses an image target: "../images/foo.jpg" becomes "foo.jpg". */
|
|
32
21
|
export function parseImageRef(raw) {
|
|
33
22
|
const match = /^\.\.\/images\/([^/?#]+)$/.exec(raw);
|
|
34
23
|
return match ? (match[1] ?? null) : null;
|
|
35
24
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Validates every reference of every compiled page against the corpus:
|
|
38
|
-
* internal links resolve to a page, anchors to a heading in that page, images
|
|
39
|
-
* to a file in `imageFiles`. Unknown targets are rejected outright.
|
|
40
|
-
*/
|
|
41
25
|
export function validateCorpus(pages, imageFiles) {
|
|
42
26
|
const bySlug = new Map(pages.map((p) => [p.slug, p]));
|
|
43
27
|
const issues = [];
|
|
@@ -70,7 +54,6 @@ export function validateCorpus(pages, imageFiles) {
|
|
|
70
54
|
}
|
|
71
55
|
return issues;
|
|
72
56
|
}
|
|
73
|
-
/** The Markdown file name a slug was compiled from. */
|
|
74
57
|
export function sourceNameOf(slug) {
|
|
75
58
|
return slug === 'index' ? 'README.md' : `${slug}.md`;
|
|
76
59
|
}
|
package/dist/manual/markdown.js
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// The one Markdown adapter: GFM in, sanitized HTML plus structured references
|
|
2
|
-
// out. Raw HTML is escaped so the manual stays plain GitHub Flavored Markdown,
|
|
3
|
-
// internal links become data-attribute navigations the help overlay routes,
|
|
4
|
-
// and images point at bundled assets. Everything here is pure: one source
|
|
5
|
-
// string in, one page model out.
|
|
6
1
|
import { Marked } from 'marked';
|
|
7
2
|
import { createSlugger } from './anchors.js';
|
|
8
3
|
import { isExternalTarget, parseImageRef, parsePageLink } from './links.js';
|
|
@@ -12,7 +7,6 @@ function escapeHtml(value) {
|
|
|
12
7
|
function escapeAttr(value) {
|
|
13
8
|
return escapeHtml(value).replace(/"/g, '"');
|
|
14
9
|
}
|
|
15
|
-
/** The readable text of inline tokens, for titles, slugs and link labels. */
|
|
16
10
|
function inlineText(tokens) {
|
|
17
11
|
if (!tokens)
|
|
18
12
|
return '';
|
|
@@ -83,14 +77,12 @@ export function compileMarkdown(source, slug) {
|
|
|
83
77
|
return `<img src="/manual/images/${escapeAttr(file)}" alt="${escapeAttr(text)}"${titleAttr(title)}>`;
|
|
84
78
|
},
|
|
85
79
|
html({ text }) {
|
|
86
|
-
// Comments disappear like on GitHub; any other raw HTML is escaped
|
|
87
|
-
// it shows as text instead of markup.
|
|
80
|
+
// Comments disappear like on GitHub; any other raw HTML is escaped.
|
|
88
81
|
return /^<!--[\s\S]*-->$/.test(text) ? '' : escapeHtml(text);
|
|
89
82
|
},
|
|
90
83
|
},
|
|
91
84
|
});
|
|
92
|
-
//
|
|
93
|
-
// only the two-step form types the output as a plain string.
|
|
85
|
+
// Two-step form instead of parse(): only parser(lexer(...)) types the output as a plain string.
|
|
94
86
|
const html = md.parser(md.lexer(source));
|
|
95
87
|
const title = headings.find((h) => h.level === 1)?.text ?? '';
|
|
96
88
|
return {
|
package/dist/manual/model.js
CHANGED
package/dist/manual/module.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// Serialization of the manual bundle into the typed module the UI bundles.
|
|
2
|
-
// The output is deterministic (stable JSON, fixed header) so regeneration is
|
|
3
|
-
// idempotent and a drift check can byte-compare.
|
|
4
1
|
export function bundleModuleSource(bundle) {
|
|
5
2
|
const header = '// Generated by src/manual/build.ts from docs/user/*.md. Do not edit.\n' +
|
|
6
3
|
"import type { ManualBundle } from '../../../../src/manual/model.js';\n\n";
|
package/dist/manual/nav.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Navigation derivation: the manual's nav is the ordered link list of the
|
|
2
|
-
// index page (docs/user/README.md), with the index itself as the first entry.
|
|
3
1
|
export function navFromIndex(index) {
|
|
4
2
|
const nav = [{ slug: index.slug, label: index.page.title }];
|
|
5
3
|
const seen = new Set([index.slug]);
|
package/dist/manual/reference.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
// Writes the checked-in CLI/config reference from the option vocabulary.
|
|
2
|
-
// Run "npm run docs:reference" after changing src/config.ts; a unit test
|
|
3
|
-
// fails when the checked-in file no longer matches the generator.
|
|
4
1
|
import fs from 'node:fs';
|
|
5
2
|
import path from 'node:path';
|
|
6
3
|
import { fileURLToPath } from 'node:url';
|
|
7
4
|
import { generateCliReference } from './cliref.js';
|
|
8
|
-
|
|
5
|
+
function writeReference(file) {
|
|
9
6
|
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
10
7
|
fs.writeFileSync(file, generateCliReference());
|
|
11
8
|
}
|
package/dist/page.js
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
// The generated headless page receives all telemetry inline (no fetch) and
|
|
2
|
-
// exposes window.__setFrame(i) for per-frame marker/trail updates; it resolves
|
|
3
|
-
// after the canvas has painted so screenshots are frame-exact. The map scene
|
|
4
|
-
// itself lives in src/renderer/ - one shared implementation with the app's
|
|
5
|
-
// React map island.
|
|
6
|
-
//
|
|
7
|
-
// Views:
|
|
8
|
-
// overview - static map fitted to the whole track (trail grows with time)
|
|
9
|
-
// follow - drone marker stays in the frame center and the map slides under
|
|
10
|
-
// it (all tiles are loaded once up-front; the per-frame move is a
|
|
11
|
-
// pure CSS transform, so no tile loads happen mid-render)
|
|
12
1
|
import { hasAltitude, resolveHudSpec } from './config.js';
|
|
13
2
|
import { decimateTrack } from './decimate.js';
|
|
14
3
|
import { unproject } from './geo.js';
|
|
15
4
|
import { planIntroOutroFrames, planView } from './plan.js';
|
|
16
5
|
import { TILE_SOURCES } from './renderer/tilesources.js';
|
|
17
|
-
// The one settings + telemetry -> page mapping. The pipeline's recording
|
|
18
|
-
// mapping and the app's live restyle both plan through here, so a preview and
|
|
19
|
-
// an export from the same settings agree frame for frame. The bbox must be
|
|
20
|
-
// the telemetry's fix bbox (what the tile prefetch warms), never the smaller
|
|
21
|
-
// frame-sample bbox.
|
|
22
6
|
export function planPageOpts(opts) {
|
|
23
7
|
const { bbox, width, height, config, source, frames, planned, previous } = opts;
|
|
24
8
|
const overview = planned?.overview ?? planView(bbox, width, height, config);
|
|
25
9
|
const introOutro = planned?.introOutro ?? planIntroOutroFrames(config, source);
|
|
26
10
|
const hud = planned?.hud ?? resolveHudSpec(config.hud, hasAltitude(frames.alt));
|
|
27
|
-
// Decimation depends only on the track and the working zoom, so an
|
|
28
|
-
// unchanged zoom keeps the identical arrays and consumers can tell that no
|
|
29
|
-
// trail work is needed.
|
|
30
11
|
const decimated = previous && previous.zoom === overview.zoom
|
|
31
12
|
? previous.decimated
|
|
32
13
|
: decimateTrack(frames.lat, frames.lon, overview.zoom);
|
|
@@ -34,6 +15,7 @@ export function planPageOpts(opts) {
|
|
|
34
15
|
width,
|
|
35
16
|
height,
|
|
36
17
|
style: config.style,
|
|
18
|
+
trailColor: config.trailColor,
|
|
37
19
|
view: config.view,
|
|
38
20
|
center: unproject(overview.centerPx.x, overview.centerPx.y, overview.zoom),
|
|
39
21
|
zoom: overview.zoom,
|
|
@@ -49,13 +31,11 @@ export function planPageOpts(opts) {
|
|
|
49
31
|
decimated,
|
|
50
32
|
};
|
|
51
33
|
}
|
|
52
|
-
// The scene data both consumers drive: the generated page inlines it as
|
|
53
|
-
// window.__DATA, the app delivers it as the session payload. Tile URLs are
|
|
54
|
-
// rooted at the consumer's serving base ("/tiles" or "app://bundle/tiles").
|
|
55
34
|
export function buildSceneData(opts, tileBase) {
|
|
56
|
-
const { width, height, style, view, center, zoom, attribution, lat, lon, alt, speed, headingDeg, hud, decimated, introN = 0, outroN = 0, } = opts;
|
|
35
|
+
const { width, height, style, trailColor, view, center, zoom, attribution, lat, lon, alt, speed, headingDeg, hud, decimated, introN = 0, outroN = 0, } = opts;
|
|
57
36
|
return {
|
|
58
37
|
style,
|
|
38
|
+
trailColor,
|
|
59
39
|
tileUrl: tileBase + '/' + style + '/{z}/{x}/{y}.png',
|
|
60
40
|
view,
|
|
61
41
|
width,
|
|
@@ -72,9 +52,6 @@ export function buildSceneData(opts, tileBase) {
|
|
|
72
52
|
trailFrame: decimated.frame,
|
|
73
53
|
};
|
|
74
54
|
}
|
|
75
|
-
// The module boot: boots the shared scene and bridges the globals the
|
|
76
|
-
// headless capture uses. Runs after the DOM is parsed (module semantics), so
|
|
77
|
-
// the scene always finds its host element.
|
|
78
55
|
function bootScript(dataJson) {
|
|
79
56
|
return `import { bootScene } from '/renderer/boot.js';
|
|
80
57
|
var D = window.__DATA = ${dataJson};
|
package/dist/paths.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
// Path identity and collision-free output naming have exactly one home.
|
|
2
|
-
// Identity follows the platform's own file-name rules: Windows file names
|
|
3
|
-
// are case-insensitive, POSIX file names are case-sensitive. The same
|
|
4
|
-
// inputs can therefore plan different names per platform, deterministic
|
|
5
|
-
// and idempotent on each. Case-insensitive macOS volumes are treated like
|
|
6
|
-
// POSIX: folding darwin too would merge two genuinely distinct files on
|
|
7
|
-
// case-sensitive volumes, and the desktop matrix is Windows + Linux.
|
|
8
1
|
import path from 'node:path';
|
|
9
|
-
// Resolved so separator and `..` spellings of one file share a key;
|
|
10
|
-
// toLowerCase is locale-independent, so the key stays deterministic.
|
|
11
2
|
export function pathKey(p, platform = process.platform) {
|
|
12
3
|
const resolved = platform === 'win32' ? path.win32.resolve(p) : path.posix.resolve(p);
|
|
13
4
|
return platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
@@ -15,9 +6,6 @@ export function pathKey(p, platform = process.platform) {
|
|
|
15
6
|
export function samePath(a, b, platform = process.platform) {
|
|
16
7
|
return pathKey(a, platform) === pathKey(b, platform);
|
|
17
8
|
}
|
|
18
|
-
// First free name `stem.ext`, `stem-2.ext`, `stem-3.ext`, ... in dir. The
|
|
19
|
-
// caller says what "taken" means (names planned in this run, or files on
|
|
20
|
-
// disk); existing names are never reused or deleted.
|
|
21
9
|
export function uniquePath(dir, stem, ext, isTaken) {
|
|
22
10
|
for (let n = 1;; n++) {
|
|
23
11
|
const name = n === 1 ? `${stem}${ext}` : `${stem}-${n}${ext}`;
|
package/dist/plan.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
// Pure planning shared by the headless pipeline and the app UI: which zoom,
|
|
2
|
-
// center and tiles cover a track at a given frame size, and how intro/outro
|
|
3
|
-
// timing maps to frames. No I/O lives here, so the browser bundle can import
|
|
4
|
-
// it; the preview and an export therefore always plan identically.
|
|
5
1
|
import { project } from './geo.js';
|
|
6
2
|
import { TILE_SOURCES } from './renderer/tilesources.js';
|
|
7
3
|
const MIN_ZOOM = 2;
|
|
8
4
|
const HOVER_ZOOM_FLOOR = 16;
|
|
9
|
-
const MIN_TRACK_SPAN_PX = 80;
|
|
5
|
+
const MIN_TRACK_SPAN_PX = 80;
|
|
10
6
|
const TILE_SIZE_PX = 256;
|
|
11
7
|
function fitZoomToTrack(bbox, availW, availH, maxZoom) {
|
|
12
8
|
for (let zoom = maxZoom; zoom >= MIN_ZOOM; zoom--) {
|
|
@@ -19,7 +15,6 @@ function fitZoomToTrack(bbox, availW, availH, maxZoom) {
|
|
|
19
15
|
}
|
|
20
16
|
return MIN_ZOOM;
|
|
21
17
|
}
|
|
22
|
-
// Never zoom a tiny (hovering) track past a useful overview.
|
|
23
18
|
function pullBackTinyTracks(zoom, bbox) {
|
|
24
19
|
while (zoom > HOVER_ZOOM_FLOOR) {
|
|
25
20
|
const northWest = project(bbox.minLon, bbox.maxLat, zoom);
|
|
@@ -32,9 +27,6 @@ function pullBackTinyTracks(zoom, bbox) {
|
|
|
32
27
|
}
|
|
33
28
|
return zoom;
|
|
34
29
|
}
|
|
35
|
-
// The map element is 2x the frame (intro/outro zoom-out shows up to 2x the
|
|
36
|
-
// area) and in follow mode it also slides across the track extent. With a
|
|
37
|
-
// native-zoom limit the tiles live one or more levels below the view zoom.
|
|
38
30
|
function tilesCovering(centerPx, trackSpanPx, zoom, width, height, follow, maxNativeZoom) {
|
|
39
31
|
const tileZoom = maxNativeZoom
|
|
40
32
|
? Math.min(zoom, maxNativeZoom)
|
|
@@ -54,9 +46,6 @@ function tilesCovering(centerPx, trackSpanPx, zoom, width, height, follow, maxNa
|
|
|
54
46
|
}
|
|
55
47
|
return tiles;
|
|
56
48
|
}
|
|
57
|
-
// zoomOut adds surroundings context; follow mode slides the map under a
|
|
58
|
-
// centered marker. When the source has a maxNativeZoom below the view zoom,
|
|
59
|
-
// tiles are fetched at the native level (Leaflet scales them).
|
|
60
49
|
export function computeOverview({ bbox, width, height, maxZoom = 19, zoomOut = 0, follow = false, maxNativeZoom = null, zoomOverride = 0, }) {
|
|
61
50
|
const padX = Math.round(width * 0.08);
|
|
62
51
|
const padY = Math.round(height * 0.08);
|
|
@@ -70,7 +59,6 @@ export function computeOverview({ bbox, width, height, maxZoom = 19, zoomOut = 0
|
|
|
70
59
|
zoom = pullBackTinyTracks(fitZoomToTrack(bbox, availW, availH, maxZoom), bbox);
|
|
71
60
|
zoom = Math.max(MIN_ZOOM, zoom - Math.max(0, Math.floor(zoomOut)));
|
|
72
61
|
}
|
|
73
|
-
// Degenerate (hovering) track: show a close-up around the single point.
|
|
74
62
|
const northWest = project(bbox.minLon, bbox.maxLat, zoom);
|
|
75
63
|
const southEast = project(bbox.maxLon, bbox.minLat, zoom);
|
|
76
64
|
const centerPx = {
|
|
@@ -87,9 +75,6 @@ export function computeOverview({ bbox, width, height, maxZoom = 19, zoomOut = 0
|
|
|
87
75
|
tiles: tilesCovering(centerPx, trackSpanPx, zoom, width, height, follow, maxNativeZoom),
|
|
88
76
|
};
|
|
89
77
|
}
|
|
90
|
-
// The one place that turns look settings into view planning: the tile-source
|
|
91
|
-
// constraints (maxZoom, native zoom) are part of the rule, so callers never
|
|
92
|
-
// hand-roll the computeOverview inputs.
|
|
93
78
|
export function planView(bbox, width, height, config) {
|
|
94
79
|
const src = TILE_SOURCES[config.style];
|
|
95
80
|
return computeOverview({
|
|
@@ -103,8 +88,6 @@ export function planView(bbox, width, height, config) {
|
|
|
103
88
|
follow: config.view === 'follow',
|
|
104
89
|
});
|
|
105
90
|
}
|
|
106
|
-
// Intro/outro zoom timing (frames); clamp for very short clips. The clamp is
|
|
107
|
-
// returned as data so the owning caller can report it.
|
|
108
91
|
export function planIntroOutroFrames(config, source) {
|
|
109
92
|
let introN = Math.max(0, Math.round(config.introSec * source.fps));
|
|
110
93
|
let outroN = Math.max(0, Math.round(config.outroSec * source.fps));
|
package/dist/png.js
CHANGED
|
@@ -1,30 +1,10 @@
|
|
|
1
|
-
// A minimal PNG encoder: just enough (IHDR/IDAT/IEND, 8-bit RGB rows) to
|
|
2
|
-
// emit valid solid-color tiles for the placeholder fallback, with no
|
|
3
|
-
// dependencies beyond zlib.
|
|
4
1
|
import zlib from 'node:zlib';
|
|
5
|
-
const CRC_TABLE = (() => {
|
|
6
|
-
const table = new Int32Array(256);
|
|
7
|
-
for (let n = 0; n < 256; n++) {
|
|
8
|
-
let c = n;
|
|
9
|
-
for (let k = 0; k < 8; k++)
|
|
10
|
-
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
11
|
-
table[n] = c;
|
|
12
|
-
}
|
|
13
|
-
return table;
|
|
14
|
-
})();
|
|
15
|
-
function crc32(buf) {
|
|
16
|
-
let crc = 0xffffffff;
|
|
17
|
-
for (let i = 0; i < buf.length; i++) {
|
|
18
|
-
crc = CRC_TABLE[(crc ^ buf[i]) & 0xff] ^ (crc >>> 8);
|
|
19
|
-
}
|
|
20
|
-
return (crc ^ 0xffffffff) >>> 0;
|
|
21
|
-
}
|
|
22
2
|
function pngChunk(type, data) {
|
|
23
3
|
const len = Buffer.alloc(4);
|
|
24
4
|
len.writeUInt32BE(data.length);
|
|
25
5
|
const body = Buffer.concat([Buffer.from(type, 'ascii'), data]);
|
|
26
6
|
const crc = Buffer.alloc(4);
|
|
27
|
-
crc.writeUInt32BE(crc32(body));
|
|
7
|
+
crc.writeUInt32BE(zlib.crc32(body));
|
|
28
8
|
return Buffer.concat([len, body, crc]);
|
|
29
9
|
}
|
|
30
10
|
export function solidPng(hexColor, size = 256) {
|