drone-path 0.12.1 → 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.
Files changed (78) hide show
  1. package/README.md +20 -74
  2. package/THIRD-PARTY-NOTICES.md +3 -82
  3. package/bin/drone-path.mjs +0 -0
  4. package/dist/cli.d.ts +14 -0
  5. package/dist/cli.js +7 -7
  6. package/dist/version.d.ts +1 -0
  7. package/package.json +21 -68
  8. package/CHANGELOG.md +0 -336
  9. package/app/ipc.d.mts +0 -43
  10. package/app/ipc.mjs +0 -216
  11. package/app/main.mjs +0 -356
  12. package/app/preload.cjs +0 -34
  13. package/app/update-policy.d.mts +0 -6
  14. package/app/update-policy.mjs +0 -6
  15. package/app/update.d.mts +0 -10
  16. package/app/update.mjs +0 -54
  17. package/dist/appassets.js +0 -35
  18. package/dist/apppaths.js +0 -20
  19. package/dist/appsession.js +0 -121
  20. package/dist/appstate.js +0 -94
  21. package/dist/assets.js +0 -60
  22. package/dist/buildinfo.js +0 -64
  23. package/dist/cammeta-decode.js +0 -237
  24. package/dist/cammeta.js +0 -92
  25. package/dist/changeset-gate.js +0 -39
  26. package/dist/config.js +0 -631
  27. package/dist/configfile.js +0 -86
  28. package/dist/decimate.js +0 -84
  29. package/dist/errors.js +0 -34
  30. package/dist/exec-tool.js +0 -13
  31. package/dist/exportjob.js +0 -90
  32. package/dist/ffmpeg-tools.js +0 -56
  33. package/dist/ffmpeg.js +0 -98
  34. package/dist/frametime.js +0 -32
  35. package/dist/geo.js +0 -60
  36. package/dist/logging.js +0 -1
  37. package/dist/manual/anchors.js +0 -17
  38. package/dist/manual/build.js +0 -67
  39. package/dist/manual/cliref.js +0 -34
  40. package/dist/manual/links.js +0 -59
  41. package/dist/manual/markdown.js +0 -98
  42. package/dist/manual/model.js +0 -1
  43. package/dist/manual/module.js +0 -5
  44. package/dist/manual/nav.js +0 -11
  45. package/dist/manual/reference.js +0 -18
  46. package/dist/paths.js +0 -16
  47. package/dist/pipeline.js +0 -402
  48. package/dist/plan.js +0 -106
  49. package/dist/png.js +0 -32
  50. package/dist/protobuf-wire.js +0 -102
  51. package/dist/range.js +0 -50
  52. package/dist/recordings.js +0 -55
  53. package/dist/render-page.js +0 -85
  54. package/dist/render.js +0 -268
  55. package/dist/renderer/boot.js +0 -7
  56. package/dist/renderer/dom.js +0 -177
  57. package/dist/renderer/framemath.js +0 -30
  58. package/dist/renderer/scene.js +0 -385
  59. package/dist/renderer/theme.js +0 -82
  60. package/dist/renderer/tilesources.js +0 -38
  61. package/dist/renderer/trail.js +0 -42
  62. package/dist/restyle.js +0 -16
  63. package/dist/serve.js +0 -27
  64. package/dist/srt.js +0 -98
  65. package/dist/telemetry-json-schema.js +0 -18
  66. package/dist/telemetry-json.js +0 -126
  67. package/dist/telemetry-math.js +0 -267
  68. package/dist/telemetry-summary.js +0 -19
  69. package/dist/telemetry.js +0 -95
  70. package/dist/tilecache.js +0 -21
  71. package/dist/tiles.js +0 -155
  72. package/dist/track-format.js +0 -13
  73. package/dist/track-geojson.js +0 -44
  74. package/dist/track-gpx.js +0 -34
  75. package/dist/track-kml.js +0 -47
  76. package/dist/track-kmz.js +0 -68
  77. package/dist/track-write.js +0 -41
  78. package/dist/track.js +0 -79
@@ -1,86 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { userDataDir } from './apppaths.js';
4
- import { CONFIG_FILE_NAME, DEFAULT_CONFIG, assertOneTrackOutSpelling, normalizeDimensions, normalizeOverrides, trackOutSpellingOf, validateRenderConfig, } from './config.js';
5
- import { errorMessage } from './errors.js';
6
- export function defaultTileCache() {
7
- const override = process.env['DRONEPATH_TILE_CACHE'];
8
- if (override)
9
- return path.resolve(override);
10
- return path.join(userDataDir(), 'tiles');
11
- }
12
- export function discoverConfigFile(startDir) {
13
- let dir = path.resolve(startDir);
14
- for (;;) {
15
- const candidate = path.join(dir, CONFIG_FILE_NAME);
16
- if (fs.existsSync(candidate))
17
- return candidate;
18
- const parent = path.dirname(dir);
19
- if (parent === dir)
20
- return null;
21
- dir = parent;
22
- }
23
- }
24
- export function loadConfigFile(file, onDeprecated) {
25
- let text;
26
- try {
27
- text = fs.readFileSync(file, 'utf8');
28
- }
29
- catch (e) {
30
- throw new Error(`cannot read config file ${file}: ${errorMessage(e)}`, {
31
- cause: e,
32
- });
33
- }
34
- let raw;
35
- try {
36
- raw = JSON.parse(text);
37
- }
38
- catch (e) {
39
- throw new Error(`config file is not valid JSON: ${file}: ${errorMessage(e)}`, { cause: e });
40
- }
41
- if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
42
- throw new Error(`config file must contain a JSON object: ${file}`);
43
- }
44
- const input = raw;
45
- return {
46
- overrides: normalizeOverrides(input, file, onDeprecated),
47
- trackOutSpelling: trackOutSpellingOf(input, file),
48
- };
49
- }
50
- function mergeConfigLayers(fileCfg, cli) {
51
- return {
52
- ...DEFAULT_CONFIG,
53
- ...fileCfg,
54
- ...cli,
55
- hud: { ...(cli.hud ?? fileCfg.hud ?? DEFAULT_CONFIG.hud) },
56
- };
57
- }
58
- function resolveConfigPaths(config, cwd) {
59
- return {
60
- ...config,
61
- tileCache: path.resolve(cwd, config.tileCache || defaultTileCache()),
62
- outDir: config.outDir ? path.resolve(cwd, config.outDir) : null,
63
- };
64
- }
65
- export function resolveConfig(opts) {
66
- const cwd = opts.cwd ?? process.cwd();
67
- const configPath = opts.configPath !== undefined && opts.configPath !== null
68
- ? path.resolve(cwd, opts.configPath)
69
- : discoverConfigFile(cwd);
70
- const fileLayer = configPath
71
- ? loadConfigFile(configPath, opts.onDeprecated)
72
- : { overrides: {}, trackOutSpelling: null };
73
- // The merged effective config may use only one spelling of the trackOut
74
- // key - across origins, not just within one of them.
75
- assertOneTrackOutSpelling([
76
- { origin: 'the config file', spelling: fileLayer.trackOutSpelling },
77
- { origin: 'the command line', spelling: opts.cliTrackOutSpelling ?? null },
78
- ]);
79
- const merged = mergeConfigLayers(fileLayer.overrides, opts.cli ?? {});
80
- validateRenderConfig(merged);
81
- const normalized = {
82
- ...merged,
83
- ...normalizeDimensions(merged.width, merged.height),
84
- };
85
- return { config: resolveConfigPaths(normalized, cwd), configPath };
86
- }
package/dist/decimate.js DELETED
@@ -1,84 +0,0 @@
1
- import { project } from './geo.js';
2
- const DEFAULT_EPSILON_PX = 1;
3
- const DEFAULT_MAX_POINTS = 3000;
4
- export function decimateTrack(lat, lon, zoom, options = {}) {
5
- const epsilonPx = options.epsilonPx ?? DEFAULT_EPSILON_PX;
6
- const maxPoints = options.maxPoints ?? DEFAULT_MAX_POINTS;
7
- if (!(epsilonPx >= 0))
8
- throw new Error('epsilon must be >= 0');
9
- if (!Number.isInteger(maxPoints) || maxPoints < 2) {
10
- throw new Error('maxPoints must be an integer >= 2');
11
- }
12
- if (lat.length !== lon.length) {
13
- throw new Error('lat and lon must have the same length');
14
- }
15
- const n = lat.length;
16
- if (n === 0)
17
- return { lat: [], lon: [], frame: [] };
18
- if (n === 1)
19
- return { lat: [lat[0]], lon: [lon[0]], frame: [0] };
20
- const px = new Array(n);
21
- for (let i = 0; i < n; i++)
22
- px[i] = project(lon[i], lat[i], zoom);
23
- let keep = douglasPeucker(px, epsilonPx);
24
- if (keep.length > maxPoints) {
25
- let hi = epsilonPx > 0 ? epsilonPx * 2 : 1;
26
- let hiKeep = douglasPeucker(px, hi);
27
- while (hiKeep.length > maxPoints) {
28
- hi *= 2;
29
- hiKeep = douglasPeucker(px, hi);
30
- }
31
- keep = hiKeep;
32
- }
33
- const track = { lat: [], lon: [], frame: [] };
34
- for (const i of keep) {
35
- track.lat.push(lat[i]);
36
- track.lon.push(lon[i]);
37
- track.frame.push(i);
38
- }
39
- return track;
40
- }
41
- function douglasPeucker(px, epsilon) {
42
- const n = px.length;
43
- const keep = new Uint8Array(n);
44
- keep[0] = 1;
45
- keep[n - 1] = 1;
46
- const stack = [0, n - 1];
47
- while (stack.length > 0) {
48
- const end = stack.pop();
49
- const start = stack.pop();
50
- if (end - start < 2)
51
- continue;
52
- const a = px[start];
53
- const b = px[end];
54
- const mid = (start + end) / 2;
55
- let maxDist = -1;
56
- let maxIdx = -1;
57
- for (let i = start + 1; i < end; i++) {
58
- const d = distanceToSegment(px[i], a, b);
59
- if (d > maxDist ||
60
- (d === maxDist && Math.abs(i - mid) < Math.abs(maxIdx - mid))) {
61
- maxDist = d;
62
- maxIdx = i;
63
- }
64
- }
65
- if (maxDist > epsilon) {
66
- keep[maxIdx] = 1;
67
- stack.push(start, maxIdx, maxIdx, end);
68
- }
69
- }
70
- const indices = [];
71
- for (let i = 0; i < n; i++)
72
- if (keep[i])
73
- indices.push(i);
74
- return indices;
75
- }
76
- function distanceToSegment(p, a, b) {
77
- const dx = b.x - a.x;
78
- const dy = b.y - a.y;
79
- const lenSq = dx * dx + dy * dy;
80
- if (lenSq === 0)
81
- return Math.sqrt((p.x - a.x) ** 2 + (p.y - a.y) ** 2);
82
- const t = Math.max(0, Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / lenSq));
83
- return Math.sqrt((p.x - (a.x + t * dx)) ** 2 + (p.y - (a.y + t * dy)) ** 2);
84
- }
package/dist/errors.js DELETED
@@ -1,34 +0,0 @@
1
- export const ERROR_PREFIX = '[drone-path] ERROR: ';
2
- export function errorMessage(error) {
3
- return error instanceof Error ? error.message : String(error);
4
- }
5
- // The backend-to-UI error protocol: ui/lib/errortext.ts builds its sentence
6
- // patterns from these exact strings, so every producer spells its message
7
- // through here — rewording one is greppable and cannot silently downgrade
8
- // its UI sentence.
9
- export const ERR_NO_RECORDING = 'no recording loaded';
10
- export const ERR_EXPORT_ALREADY_RUNNING = 'an export is already running';
11
- export const ERR_EXPORT_COULD_NOT_START = 'export could not start';
12
- export const ERR_EXPORT_COULD_NOT_BE_CANCELED = 'export could not be canceled';
13
- export const ERR_OUTPUT_OVERWRITES_SOURCE = 'the output must not overwrite the source recording';
14
- export const ERR_OUTPUT_PATH_ABSOLUTE = 'output path must be absolute: ';
15
- export const ERR_APP_BRIDGE_UNAVAILABLE = 'app bridge unavailable';
16
- export const ERR_RENDER_CANCELED = 'render canceled';
17
- export const ERR_NOT_READABLE_MP4 = 'not a readable .mp4 file: ';
18
- export const ERR_NO_TELEMETRY = 'no telemetry found: ';
19
- export const ERR_OUTPUT_VERIFICATION = 'output verification failed: ';
20
- export const ERR_COULD_NOT_REPLACE = 'could not replace ';
21
- export const ERR_RENDER_KEPT_AT = 'the finished render is at ';
22
- export const ERR_NO_FRAME_RATE = 'could not determine the frame rate of the video';
23
- export const ERR_UNKNOWN = 'unknown error';
24
- // The mandated failure shell for generated-art tool entries (AGENTS.md): one
25
- // ERROR line on stderr and process.exitCode = 1, never a mid-flow exit.
26
- export async function runToolMain(fn) {
27
- try {
28
- await fn();
29
- }
30
- catch (e) {
31
- process.stderr.write(`${ERROR_PREFIX}${errorMessage(e)}\n`);
32
- process.exitCode = 1;
33
- }
34
- }
package/dist/exec-tool.js DELETED
@@ -1,13 +0,0 @@
1
- import { execFile } from 'node:child_process';
2
- import { promisify } from 'node:util';
3
- const execFileAsync = promisify(execFile);
4
- // One child-process seam for src/: command, argv and buffer budget pass
5
- // through untouched, and the spawned error propagates unwrapped so each
6
- // caller keeps its own { cause } wording. Tool output is text (utf8).
7
- export async function runTool(command, args, opts) {
8
- const result = await execFileAsync(command, args, opts);
9
- return {
10
- stdout: String(result?.stdout ?? ''),
11
- stderr: String(result?.stderr ?? ''),
12
- };
13
- }
package/dist/exportjob.js DELETED
@@ -1,90 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { ERR_COULD_NOT_REPLACE, ERR_EXPORT_ALREADY_RUNNING, ERR_OUTPUT_OVERWRITES_SOURCE, ERR_OUTPUT_PATH_ABSOLUTE, ERR_RENDER_KEPT_AT, errorMessage, } from './errors.js';
4
- import { samePath, uniquePath } from './paths.js';
5
- import { processRecording } from './pipeline.js';
6
- const runViaPipeline = (deps) => (videoPath, request, log, workingPath, signal, onCapture) => processRecording(videoPath, request.config, log, workingPath, {
7
- range: request.range ?? undefined,
8
- signal,
9
- onCapture,
10
- deps,
11
- });
12
- // The working file keeps the .mp4 suffix: ffmpeg infers the container from it.
13
- function workingPathFor(outPath) {
14
- const dir = path.dirname(outPath);
15
- const stem = `${path.basename(outPath, path.extname(outPath))}.partial`;
16
- return uniquePath(dir, stem, '.mp4', (candidate) => fs.existsSync(candidate));
17
- }
18
- function removeQuietly(working) {
19
- try {
20
- fs.rmSync(working, { force: true });
21
- }
22
- catch {
23
- // best-effort removal; a cleanup failure must never throw from here
24
- }
25
- }
26
- function swapIntoPlace(working, outPath) {
27
- try {
28
- fs.renameSync(working, outPath);
29
- }
30
- catch (e) {
31
- throw new Error(`${ERR_COULD_NOT_REPLACE}${outPath}: ${errorMessage(e)} ` +
32
- `(${ERR_RENDER_KEPT_AT}${working})`, { cause: e });
33
- }
34
- }
35
- export function createExportRunner(options) {
36
- const log = options.log ?? (() => { });
37
- const run = options.run ?? runViaPipeline(options.deps);
38
- let job = null;
39
- async function execute(videoPath, request, working, controller) {
40
- let summary;
41
- try {
42
- summary = await run(videoPath, request, log, working, controller.signal, options.onCapture);
43
- }
44
- catch (e) {
45
- removeQuietly(working);
46
- return controller.signal.aborted
47
- ? { status: 'canceled' }
48
- : { status: 'error', error: errorMessage(e) };
49
- }
50
- try {
51
- swapIntoPlace(working, request.outPath);
52
- }
53
- catch (e) {
54
- return { status: 'error', error: errorMessage(e) };
55
- }
56
- log(`exported: ${request.outPath}`);
57
- return { status: 'ok', summary: { ...summary, out: request.outPath } };
58
- }
59
- return {
60
- start(videoPath, request) {
61
- if (job)
62
- throw new Error(ERR_EXPORT_ALREADY_RUNNING);
63
- if (!path.isAbsolute(request.outPath)) {
64
- throw new Error(`${ERR_OUTPUT_PATH_ABSOLUTE}${request.outPath}`);
65
- }
66
- if (samePath(request.outPath, videoPath)) {
67
- throw new Error(ERR_OUTPUT_OVERWRITES_SOURCE);
68
- }
69
- const controller = new AbortController();
70
- job = { abort: () => controller.abort() };
71
- const working = workingPathFor(request.outPath);
72
- // The catch guards a consumer's throwing onDone: an unhandled rejection here would kill the process.
73
- void execute(videoPath, request, working, controller)
74
- .then((outcome) => {
75
- job = null;
76
- options.onDone(outcome);
77
- })
78
- .catch((e) => {
79
- job = null;
80
- log(`export completion failed: ${errorMessage(e)}`);
81
- });
82
- },
83
- cancel() {
84
- job?.abort();
85
- },
86
- running() {
87
- return job !== null;
88
- },
89
- };
90
- }
@@ -1,56 +0,0 @@
1
- import fs from 'node:fs';
2
- import { createRequire } from 'node:module';
3
- import path from 'node:path';
4
- export const FFMPEG_TOOL_NAMES = ['ffmpeg', 'ffprobe'];
5
- function isPathLike(value) {
6
- return value.includes('/') || value.includes('\\') || path.isAbsolute(value);
7
- }
8
- export function pickFfmpegTool(tool, override, candidates, exists) {
9
- if (override) {
10
- if (isPathLike(override) && !exists(override)) {
11
- throw new Error(`invalid ${tool} override (CLI --${tool} or config key \`${tool}\`): no such file: ${override}`);
12
- }
13
- return override;
14
- }
15
- for (const candidate of candidates) {
16
- if (candidate && exists(candidate))
17
- return candidate;
18
- }
19
- return tool;
20
- }
21
- function exeName(tool) {
22
- return process.platform === 'win32' ? `${tool}.exe` : tool;
23
- }
24
- function packagedCandidate(tool) {
25
- const resourcesPath = process.resourcesPath;
26
- return resourcesPath ? path.join(resourcesPath, 'ff', exeName(tool)) : null;
27
- }
28
- function devCandidate(tool) {
29
- try {
30
- const mod = createRequire(import.meta.url)('ffmpeg-ffprobe-static');
31
- const candidate = tool === 'ffmpeg' ? mod.ffmpegPath : mod.ffprobePath;
32
- return typeof candidate === 'string' ? candidate : null;
33
- }
34
- catch {
35
- return null;
36
- }
37
- }
38
- function realEnv() {
39
- return {
40
- exists: (file) => {
41
- try {
42
- return fs.statSync(file).isFile();
43
- }
44
- catch {
45
- return false;
46
- }
47
- },
48
- candidates: (tool) => [packagedCandidate(tool), devCandidate(tool)],
49
- };
50
- }
51
- export function resolveFfmpegTools(overrides, env = realEnv()) {
52
- return {
53
- ffmpeg: pickFfmpegTool('ffmpeg', overrides.ffmpeg, env.candidates('ffmpeg'), env.exists),
54
- ffprobe: pickFfmpegTool('ffprobe', overrides.ffprobe, env.candidates('ffprobe'), env.exists),
55
- };
56
- }
package/dist/ffmpeg.js DELETED
@@ -1,98 +0,0 @@
1
- import { ERR_NO_FRAME_RATE } from './errors.js';
2
- import { runTool } from './exec-tool.js';
3
- import { framesForSeconds, parseFpsRate, parseRate } from './frametime.js';
4
- import { FFMPEG_TOOL_NAMES } from './ffmpeg-tools.js';
5
- const INSTALL_HINT = 'point --ffmpeg/--ffprobe at your executables, or install ffmpeg (includes ' +
6
- 'ffprobe) and make sure both are on PATH, e.g. "winget install Gyan.FFmpeg" ' +
7
- '(Windows), "brew install ffmpeg" (macOS) or "apt install ffmpeg" (Linux)';
8
- const FFPROBE_MAX_BUFFER = 64 * 1024 * 1024;
9
- const TOOL_VERSION_MAX_BUFFER = 1 << 20;
10
- const RATE_PROBE_MAX_BUFFER = 1 << 20;
11
- export async function requireFfmpegTools(tools) {
12
- for (const tool of FFMPEG_TOOL_NAMES) {
13
- const command = tools[tool];
14
- try {
15
- await runTool(command, ['-version'], { maxBuffer: TOOL_VERSION_MAX_BUFFER });
16
- }
17
- catch (e) {
18
- throw new Error(`${tool} is required but could not be run (${command}) - ${INSTALL_HINT}`, { cause: e });
19
- }
20
- }
21
- }
22
- export async function ffprobeJson(tools, videoPath, args) {
23
- const { stdout } = await runTool(tools.ffprobe, ['-v', 'error', ...args, videoPath], { maxBuffer: FFPROBE_MAX_BUFFER });
24
- return JSON.parse(stdout || '{}');
25
- }
26
- function parseCount(text) {
27
- return Number.parseInt(text ?? '', 10);
28
- }
29
- function firstStream(j) {
30
- return (j['streams'] ?? [])[0] ?? {};
31
- }
32
- export async function probeVideo(tools, videoPath, log = () => { }) {
33
- const j = await ffprobeJson(tools, videoPath, [
34
- '-select_streams', 'v:0',
35
- '-show_entries',
36
- 'stream=r_frame_rate,avg_frame_rate,nb_frames,width,height:format=duration',
37
- '-of', 'json',
38
- ]);
39
- const stream = firstStream(j);
40
- const format = j['format'] ?? {};
41
- const fps = parseFpsRate(stream.r_frame_rate) ??
42
- parseFpsRate(stream.avg_frame_rate);
43
- if (!fps)
44
- throw new Error(ERR_NO_FRAME_RATE);
45
- const durationSec = Number.parseFloat(format.duration ?? '');
46
- let frames = parseCount(stream.nb_frames);
47
- if (!Number.isFinite(frames) || frames <= 0) {
48
- frames = framesForSeconds(fps.value, durationSec);
49
- log('warning: nb_frames missing, using duration x fps');
50
- }
51
- if (!Number.isFinite(frames) || frames <= 0) {
52
- throw new Error(`could not determine the frame count of ${videoPath} ` +
53
- '(nb_frames missing and duration unusable)');
54
- }
55
- return {
56
- fps,
57
- frames,
58
- durationSec,
59
- width: stream.width ?? 0,
60
- height: stream.height ?? 0,
61
- };
62
- }
63
- export async function verifyOutput(tools, outPath, frames, fpsValue) {
64
- const j = await ffprobeJson(tools, outPath, [
65
- '-select_streams', 'v:0',
66
- '-show_entries', 'stream=nb_frames,r_frame_rate',
67
- '-of', 'json',
68
- ]);
69
- const stream = firstStream(j);
70
- const gotFrames = parseCount(stream.nb_frames);
71
- const rate = parseRate(stream.r_frame_rate ?? '0/0');
72
- const gotValue = rate ? (rate.den ? rate.num / rate.den : rate.num) : null;
73
- return {
74
- frames: gotFrames,
75
- fps: stream.r_frame_rate ?? null,
76
- ok: gotFrames === frames &&
77
- gotValue !== null &&
78
- Math.abs(gotValue - fpsValue) < 1e-6,
79
- };
80
- }
81
- async function probeRateFrames(ffprobe, file) {
82
- const { stdout } = await runTool(ffprobe, [
83
- '-v', 'error', '-select_streams', 'v:0',
84
- '-show_entries', 'stream=avg_frame_rate,nb_frames',
85
- '-of', 'csv=p=0', '--', file,
86
- ], { maxBuffer: RATE_PROBE_MAX_BUFFER });
87
- return stdout.trim();
88
- }
89
- export async function outputMatchesSource(tools, src, out) {
90
- try {
91
- const [srcRate, srcFrames] = (await probeRateFrames(tools.ffprobe, src)).split(',');
92
- const [outRate, outFrames] = (await probeRateFrames(tools.ffprobe, out)).split(',');
93
- return Number(outFrames) > 0 && srcRate === outRate && srcFrames === outFrames;
94
- }
95
- catch {
96
- return false;
97
- }
98
- }
package/dist/frametime.js DELETED
@@ -1,32 +0,0 @@
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 DELETED
@@ -1,60 +0,0 @@
1
- const EARTH_RADIUS_M = 6371008.8;
2
- const DEG_TO_RAD = Math.PI / 180;
3
- const RAD_TO_DEG = 180 / Math.PI;
4
- // (0, 0) is DJI's "no GPS lock" placeholder before the first fix, not a real fix.
5
- export function isGpsFix(lat, lon) {
6
- return (Number.isFinite(lat) &&
7
- Number.isFinite(lon) &&
8
- lat > -90 &&
9
- lat < 90 &&
10
- lon > -180 &&
11
- lon < 180 &&
12
- !(lat === 0 && lon === 0));
13
- }
14
- export function gpsFixOrNull(lat, lon) {
15
- return lat !== null && lon !== null && isGpsFix(lat, lon) ? { lat, lon } : null;
16
- }
17
- export function haversineM(a, b) {
18
- const deltaLatRad = (b.lat - a.lat) * DEG_TO_RAD;
19
- const deltaLonRad = (b.lon - a.lon) * DEG_TO_RAD;
20
- const latARad = a.lat * DEG_TO_RAD;
21
- const latBRad = b.lat * DEG_TO_RAD;
22
- const haversine = Math.sin(deltaLatRad / 2) ** 2 +
23
- Math.cos(latARad) * Math.cos(latBRad) * Math.sin(deltaLonRad / 2) ** 2;
24
- return 2 * EARTH_RADIUS_M * Math.asin(Math.min(1, Math.sqrt(haversine)));
25
- }
26
- export function bearingDeg(a, b) {
27
- const latARad = a.lat * DEG_TO_RAD;
28
- const latBRad = b.lat * DEG_TO_RAD;
29
- const deltaLonRad = (b.lon - a.lon) * DEG_TO_RAD;
30
- const y = Math.sin(deltaLonRad) * Math.cos(latBRad);
31
- const x = Math.cos(latARad) * Math.sin(latBRad) -
32
- Math.sin(latARad) * Math.cos(latBRad) * Math.cos(deltaLonRad);
33
- return (Math.atan2(y, x) * RAD_TO_DEG + 360) % 360;
34
- }
35
- export function circularMeanDeg(degList) {
36
- let sumCos = 0;
37
- let sumSin = 0;
38
- for (const deg of degList) {
39
- sumCos += Math.cos(deg * DEG_TO_RAD);
40
- sumSin += Math.sin(deg * DEG_TO_RAD);
41
- }
42
- if (sumCos === 0 && sumSin === 0)
43
- return degList[0] ?? 0;
44
- return (Math.atan2(sumSin, sumCos) * RAD_TO_DEG + 360) % 360;
45
- }
46
- // Web Mercator (EPSG:3857) global pixels, 256 px tiles, NW origin (Leaflet convention).
47
- export function project(lon, lat, zoom) {
48
- const scale = 256 * 2 ** zoom;
49
- const x = ((lon + 180) / 360) * scale;
50
- const sinLat = Math.sin(Math.max(-85.05112878, Math.min(85.05112878, lat)) * DEG_TO_RAD);
51
- const y = (0.5 - Math.log((1 + sinLat) / (1 - sinLat)) / (4 * Math.PI)) * scale;
52
- return { x, y };
53
- }
54
- export function unproject(x, y, zoom) {
55
- const scale = 256 * 2 ** zoom;
56
- const lon = (x / scale) * 360 - 180;
57
- const mercatorN = Math.PI - 2 * Math.PI * (y / scale);
58
- const lat = RAD_TO_DEG * Math.atan(Math.sinh(mercatorN));
59
- return { lat, lon };
60
- }
package/dist/logging.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- const SLUG_STRIP = /[^\p{L}\p{N}\s_-]/gu;
2
- export function githubSlug(text) {
3
- return text
4
- .toLowerCase()
5
- .replace(SLUG_STRIP, '')
6
- .replace(/ /g, '-');
7
- }
8
- // GitHub's duplicate rule: the first "Foo" stays "foo", later ones become "foo-1", "foo-2", ...
9
- export function createSlugger() {
10
- const seen = new Map();
11
- return (text) => {
12
- const base = githubSlug(text);
13
- const count = seen.get(base) ?? 0;
14
- seen.set(base, count + 1);
15
- return count === 0 ? base : `${base}-${count}`;
16
- };
17
- }
@@ -1,67 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { runToolMain } from '../errors.js';
5
- import { compileMarkdown } from './markdown.js';
6
- import { bundleModuleSource } from './module.js';
7
- import { navFromIndex } from './nav.js';
8
- import { pageSlugOf, sourceNameOf, validateCorpus } from './links.js';
9
- export function defaultManualPaths(root) {
10
- return {
11
- userDir: path.join(root, 'docs', 'user'),
12
- imagesDir: path.join(root, 'docs', 'images'),
13
- moduleFile: path.join(root, 'ui', 'lib', 'manual', 'generated', 'manual.ts'),
14
- assetDir: path.join(root, 'ui', 'public', 'manual', 'images'),
15
- };
16
- }
17
- export function buildManual(paths) {
18
- const files = fs
19
- .readdirSync(paths.userDir)
20
- .filter((file) => file.endsWith('.md'))
21
- .sort();
22
- const compiled = files.map((file) => {
23
- const source = fs.readFileSync(path.join(paths.userDir, file), 'utf8');
24
- return compileMarkdown(source, pageSlugOf(file));
25
- });
26
- const issues = [];
27
- for (const { slug, page } of compiled) {
28
- if (page.title === '') {
29
- issues.push(`docs/user/${sourceNameOf(slug)} needs a level-1 "# " heading as its title`);
30
- }
31
- }
32
- const index = compiled.find((c) => c.slug === 'index');
33
- if (!index)
34
- issues.push('docs/user/README.md is missing; it is the manual index');
35
- const imageFiles = new Set(fs.existsSync(paths.imagesDir) ? fs.readdirSync(paths.imagesDir) : []);
36
- for (const issue of validateCorpus(compiled, imageFiles)) {
37
- issues.push(`${issue.file}: ${issue.message}`);
38
- }
39
- if (issues.length > 0) {
40
- throw new Error(`manual corpus has ${issues.length} issue(s):\n${issues.map((i) => ` - ${i}`).join('\n')}`);
41
- }
42
- const bundle = {
43
- nav: index ? navFromIndex(index) : [],
44
- pages: {},
45
- };
46
- for (const entry of [...compiled].sort((a, b) => (a.slug < b.slug ? -1 : 1))) {
47
- bundle.pages[entry.slug] = entry.page;
48
- }
49
- fs.mkdirSync(path.dirname(paths.moduleFile), { recursive: true });
50
- fs.writeFileSync(paths.moduleFile, bundleModuleSource(bundle));
51
- const referenced = [
52
- ...new Set(compiled.flatMap((c) => c.refs.images.map((image) => image.file))),
53
- ].sort();
54
- fs.mkdirSync(paths.assetDir, { recursive: true });
55
- for (const file of referenced) {
56
- fs.copyFileSync(path.join(paths.imagesDir, file), path.join(paths.assetDir, file));
57
- }
58
- return { pages: compiled.length, images: referenced };
59
- }
60
- function main() {
61
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..');
62
- const result = buildManual(defaultManualPaths(root));
63
- process.stderr.write(`[drone-path] manual: ${result.pages} page(s), ${result.images.length} image(s)\n`);
64
- }
65
- if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
66
- void runToolMain(main);
67
- }