drone-path 0.13.0 → 1.0.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/README.md +20 -74
- package/THIRD-PARTY-NOTICES.md +3 -82
- package/bin/drone-path.mjs +0 -0
- package/dist/archive-cli.d.ts +1 -0
- package/dist/archive-cli.js +50 -0
- package/dist/archive-query-cli.d.ts +3 -0
- package/dist/archive-query-cli.js +128 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +19 -12
- package/dist/version.d.ts +1 -0
- package/package.json +22 -68
- package/CHANGELOG.md +0 -349
- package/app/ipc.d.mts +0 -44
- package/app/ipc.mjs +0 -237
- package/app/main.mjs +0 -369
- package/app/preload.cjs +0 -36
- package/app/update-policy.d.mts +0 -6
- package/app/update-policy.mjs +0 -6
- package/app/update.d.mts +0 -10
- package/app/update.mjs +0 -54
- package/dist/appassets.js +0 -35
- package/dist/apppaths.js +0 -20
- package/dist/appsession.js +0 -121
- package/dist/appstate.js +0 -101
- package/dist/assets.js +0 -60
- package/dist/buildinfo.js +0 -64
- package/dist/cammeta-decode.js +0 -237
- package/dist/cammeta.js +0 -92
- package/dist/changeset-gate.js +0 -39
- package/dist/config.js +0 -631
- package/dist/configfile.js +0 -86
- package/dist/decimate.js +0 -84
- package/dist/desktop-i18n/generated/catalogs.js +0 -1230
- package/dist/desktop-i18n/messages.js +0 -47
- package/dist/errors.js +0 -34
- package/dist/exec-tool.js +0 -13
- package/dist/exportjob.js +0 -90
- package/dist/ffmpeg-tools.js +0 -56
- package/dist/ffmpeg.js +0 -98
- package/dist/frametime.js +0 -32
- package/dist/geo.js +0 -60
- package/dist/logging.js +0 -1
- package/dist/manual/anchors.js +0 -17
- package/dist/manual/build.js +0 -67
- package/dist/manual/cliref.js +0 -34
- package/dist/manual/links.js +0 -59
- package/dist/manual/markdown.js +0 -98
- package/dist/manual/model.js +0 -1
- package/dist/manual/module.js +0 -5
- package/dist/manual/nav.js +0 -11
- package/dist/manual/reference.js +0 -18
- package/dist/paths.js +0 -16
- package/dist/pipeline.js +0 -402
- package/dist/plan.js +0 -106
- package/dist/png.js +0 -32
- package/dist/protobuf-wire.js +0 -102
- package/dist/range.js +0 -50
- package/dist/recordings.js +0 -55
- package/dist/render-page.js +0 -85
- package/dist/render.js +0 -268
- package/dist/renderer/boot.js +0 -7
- package/dist/renderer/dom.js +0 -179
- package/dist/renderer/framemath.js +0 -30
- package/dist/renderer/scene.js +0 -388
- package/dist/renderer/theme.js +0 -82
- package/dist/renderer/tilesources.js +0 -38
- package/dist/renderer/trail.js +0 -42
- package/dist/restyle.js +0 -16
- package/dist/serve.js +0 -27
- package/dist/srt.js +0 -98
- package/dist/telemetry-json-schema.js +0 -18
- package/dist/telemetry-json.js +0 -126
- package/dist/telemetry-math.js +0 -267
- package/dist/telemetry-summary.js +0 -19
- package/dist/telemetry.js +0 -95
- package/dist/tilecache.js +0 -21
- package/dist/tiles.js +0 -155
- package/dist/track-format.js +0 -13
- package/dist/track-geojson.js +0 -44
- package/dist/track-gpx.js +0 -34
- package/dist/track-kml.js +0 -47
- package/dist/track-kmz.js +0 -68
- package/dist/track-write.js +0 -41
- package/dist/track.js +0 -79
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { catalogs } from './generated/catalogs.js';
|
|
2
|
-
export const DEFAULT_LOCALE = 'en';
|
|
3
|
-
const messages = catalogs;
|
|
4
|
-
export const locales = Object.keys(catalogs);
|
|
5
|
-
export function isLocale(value) {
|
|
6
|
-
return typeof value === 'string' && Object.hasOwn(catalogs, value);
|
|
7
|
-
}
|
|
8
|
-
export function resolveLocale(preference, systemLanguages) {
|
|
9
|
-
if (preference !== null && isLocale(preference))
|
|
10
|
-
return preference;
|
|
11
|
-
for (const language of systemLanguages) {
|
|
12
|
-
try {
|
|
13
|
-
const locale = new Intl.Locale(language);
|
|
14
|
-
const parts = locale.baseName.split('-');
|
|
15
|
-
while (parts.length > 0) {
|
|
16
|
-
const candidate = parts.join('-');
|
|
17
|
-
if (isLocale(candidate))
|
|
18
|
-
return candidate;
|
|
19
|
-
parts.pop();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
// Ignore malformed tags and continue through the OS preference list.
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return DEFAULT_LOCALE;
|
|
27
|
-
}
|
|
28
|
-
export function languageName(locale) {
|
|
29
|
-
return new Intl.DisplayNames(locale, { type: 'language' }).of(locale) ?? locale;
|
|
30
|
-
}
|
|
31
|
-
export function translator(locale) {
|
|
32
|
-
const entries = messages[locale];
|
|
33
|
-
const pluralRules = new Intl.PluralRules(locale);
|
|
34
|
-
const englishRules = new Intl.PluralRules(DEFAULT_LOCALE);
|
|
35
|
-
return (key, values = {}) => {
|
|
36
|
-
const local = Object.hasOwn(entries, key) ? entries[key] : undefined;
|
|
37
|
-
const message = local ?? (Object.hasOwn(messages.en, key) ? messages.en[key] : undefined);
|
|
38
|
-
if (message === undefined)
|
|
39
|
-
return '';
|
|
40
|
-
const rules = local === undefined ? englishRules : pluralRules;
|
|
41
|
-
const template = typeof message === 'string'
|
|
42
|
-
? message
|
|
43
|
-
: message[rules.select(Number(values.count))] ?? message.other;
|
|
44
|
-
return template.replace(/\{([a-zA-Z][a-zA-Z0-9]*)\}/g, (_, name) => Object.hasOwn(values, name) ? String(values[name]) : '');
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export const tEnglish = translator(DEFAULT_LOCALE);
|
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
|
-
}
|
package/dist/ffmpeg-tools.js
DELETED
|
@@ -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 {};
|
package/dist/manual/anchors.js
DELETED
|
@@ -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
|
-
}
|
package/dist/manual/build.js
DELETED
|
@@ -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
|
-
}
|
package/dist/manual/cliref.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { CONFIG_FILE_OPTION, CONFIG_OPTIONS, TELEMETRY_JSON_ALIAS, cliDefaultOf, } from '../config.js';
|
|
2
|
-
import { escapeAngleBrackets } from './markdown.js';
|
|
3
|
-
function defaultCell(key) {
|
|
4
|
-
const value = cliDefaultOf(key);
|
|
5
|
-
if (typeof value === 'boolean')
|
|
6
|
-
return value ? 'on' : 'off';
|
|
7
|
-
return value === '' ? '—' : `\`${value}\``;
|
|
8
|
-
}
|
|
9
|
-
function describe(row) {
|
|
10
|
-
const help = escapeAngleBrackets(row.cli.help);
|
|
11
|
-
return row.cli.choices ? `${help} (choices: ${row.cli.choices.join(', ')})` : help;
|
|
12
|
-
}
|
|
13
|
-
export function generateCliReference() {
|
|
14
|
-
const rows = CONFIG_OPTIONS.map((row) => `| \`${row.key}\` | \`${row.cli.flags}\` | ${defaultCell(row.key)} | ${describe(row)} |`);
|
|
15
|
-
rows.push(`| — | \`${CONFIG_FILE_OPTION.flags}\` | — | ${CONFIG_FILE_OPTION.help} |`);
|
|
16
|
-
rows.push(`| \`${TELEMETRY_JSON_ALIAS.inputKey}\` | \`${TELEMETRY_JSON_ALIAS.flags}\` | — | ` +
|
|
17
|
-
`deprecated alias of --track-out <file>.json: same output, warns on use, ` +
|
|
18
|
-
`removed in a future version |`);
|
|
19
|
-
return [
|
|
20
|
-
'<!-- Generated from the option vocabulary in src/config.ts by "npm run docs:reference". Do not edit by hand. -->',
|
|
21
|
-
'',
|
|
22
|
-
'# CLI and config reference',
|
|
23
|
-
'',
|
|
24
|
-
'Every `drone-path` option with its config-file key and built-in default.',
|
|
25
|
-
'In a [config file](config-file.md) every key is optional: anything omitted',
|
|
26
|
-
'falls back to the default below. Run `npx drone-path --help` for the same',
|
|
27
|
-
'table in the terminal.',
|
|
28
|
-
'',
|
|
29
|
-
'| Config key | CLI flag | Default | Description |',
|
|
30
|
-
'|---|---|---|---|',
|
|
31
|
-
...rows,
|
|
32
|
-
'',
|
|
33
|
-
].join('\n');
|
|
34
|
-
}
|
package/dist/manual/links.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const SCHEME_RX = /^[a-z][a-z0-9+.-]*:/i;
|
|
2
|
-
export function pageSlugOf(file) {
|
|
3
|
-
const base = file.split('/').pop() ?? file;
|
|
4
|
-
return base === 'README.md' ? 'index' : base.replace(/\.md$/, '');
|
|
5
|
-
}
|
|
6
|
-
export function isExternalTarget(raw) {
|
|
7
|
-
return SCHEME_RX.test(raw);
|
|
8
|
-
}
|
|
9
|
-
export function parsePageLink(raw, currentSlug) {
|
|
10
|
-
const [path, hash, ...rest] = raw.split('#');
|
|
11
|
-
if (rest.length > 0)
|
|
12
|
-
return null;
|
|
13
|
-
const anchor = hash === undefined || hash === '' ? null : hash;
|
|
14
|
-
if (path === '')
|
|
15
|
-
return anchor === null ? null : { slug: currentSlug, anchor };
|
|
16
|
-
const clean = path.startsWith('./') ? path.slice(2) : path;
|
|
17
|
-
if (!clean.endsWith('.md') || clean.includes('/'))
|
|
18
|
-
return null;
|
|
19
|
-
return { slug: pageSlugOf(clean), anchor };
|
|
20
|
-
}
|
|
21
|
-
export function parseImageRef(raw) {
|
|
22
|
-
const match = /^\.\.\/images\/([^/?#]+)$/.exec(raw);
|
|
23
|
-
return match ? (match[1] ?? null) : null;
|
|
24
|
-
}
|
|
25
|
-
export function validateCorpus(pages, imageFiles) {
|
|
26
|
-
const bySlug = new Map(pages.map((p) => [p.slug, p]));
|
|
27
|
-
const issues = [];
|
|
28
|
-
for (const { slug, refs } of pages) {
|
|
29
|
-
const file = `docs/user/${sourceNameOf(slug)}`;
|
|
30
|
-
for (const raw of refs.unknown) {
|
|
31
|
-
issues.push({
|
|
32
|
-
file,
|
|
33
|
-
message: `link "${raw}" is neither a .md page link nor a web link; link pages as "other.md" or "other.md#anchor", and mention plain file paths in backticks`,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
for (const link of refs.links) {
|
|
37
|
-
const target = bySlug.get(link.slug);
|
|
38
|
-
if (!target) {
|
|
39
|
-
issues.push({ file, message: `link "${link.raw}" points at missing page "${link.slug}.md"` });
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
if (link.anchor !== null && !target.page.headings.some((h) => h.id === link.anchor)) {
|
|
43
|
-
issues.push({
|
|
44
|
-
file,
|
|
45
|
-
message: `link "${link.raw}" points at missing anchor "#${link.anchor}" in "${sourceNameOf(link.slug)}"`,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
for (const image of refs.images) {
|
|
50
|
-
if (!imageFiles.has(image.file)) {
|
|
51
|
-
issues.push({ file, message: `image "${image.raw}" points at missing file "docs/images/${image.file}"` });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return issues;
|
|
56
|
-
}
|
|
57
|
-
export function sourceNameOf(slug) {
|
|
58
|
-
return slug === 'index' ? 'README.md' : `${slug}.md`;
|
|
59
|
-
}
|