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
package/dist/plan.js DELETED
@@ -1,106 +0,0 @@
1
- import { project } from './geo.js';
2
- import { TILE_SOURCES } from './renderer/tilesources.js';
3
- const MIN_ZOOM = 2;
4
- const HOVER_ZOOM_FLOOR = 16;
5
- const MIN_TRACK_SPAN_PX = 80;
6
- const TILE_SIZE_PX = 256;
7
- /** The zoom levels the planner renders: the floor and the map style's tile maximum. */
8
- export function zoomLimits(style) {
9
- return { min: MIN_ZOOM, max: TILE_SOURCES[style].maxZoom || 19 };
10
- }
11
- function fitZoomToTrack(bbox, availW, availH, maxZoom) {
12
- for (let zoom = maxZoom; zoom >= MIN_ZOOM; zoom--) {
13
- const northWest = project(bbox.minLon, bbox.maxLat, zoom);
14
- const southEast = project(bbox.maxLon, bbox.minLat, zoom);
15
- const fits = southEast.x - northWest.x <= availW &&
16
- southEast.y - northWest.y <= availH;
17
- if (fits)
18
- return zoom;
19
- }
20
- return MIN_ZOOM;
21
- }
22
- function pullBackTinyTracks(zoom, bbox) {
23
- while (zoom > HOVER_ZOOM_FLOOR) {
24
- const northWest = project(bbox.minLon, bbox.maxLat, zoom);
25
- const southEast = project(bbox.maxLon, bbox.minLat, zoom);
26
- const spansEnough = southEast.x - northWest.x >= MIN_TRACK_SPAN_PX ||
27
- southEast.y - northWest.y >= MIN_TRACK_SPAN_PX;
28
- if (spansEnough)
29
- break;
30
- zoom--;
31
- }
32
- return zoom;
33
- }
34
- function tilesCovering(centerPx, trackSpanPx, zoom, width, height, follow, maxNativeZoom) {
35
- const tileZoom = maxNativeZoom
36
- ? Math.min(zoom, maxNativeZoom)
37
- : zoom;
38
- const scale = 2 ** (tileZoom - zoom);
39
- const halfW = (width + TILE_SIZE_PX + (follow ? trackSpanPx.x / 2 : 0)) * scale;
40
- const halfH = (height + TILE_SIZE_PX + (follow ? trackSpanPx.y / 2 : 0)) * scale;
41
- const maxTileIndex = 2 ** tileZoom - 1;
42
- const xMin = Math.max(0, Math.floor((centerPx.x * scale - halfW) / TILE_SIZE_PX));
43
- const xMax = Math.min(maxTileIndex, Math.floor((centerPx.x * scale + halfW) / TILE_SIZE_PX));
44
- const yMin = Math.max(0, Math.floor((centerPx.y * scale - halfH) / TILE_SIZE_PX));
45
- const yMax = Math.min(maxTileIndex, Math.floor((centerPx.y * scale + halfH) / TILE_SIZE_PX));
46
- const tiles = [];
47
- for (let x = xMin; x <= xMax; x++) {
48
- for (let y = yMin; y <= yMax; y++)
49
- tiles.push({ z: tileZoom, x, y });
50
- }
51
- return tiles;
52
- }
53
- export function computeOverview({ bbox, width, height, maxZoom = 19, zoomOut = 0, follow = false, maxNativeZoom = null, zoomOverride = 0, }) {
54
- const padX = Math.round(width * 0.08);
55
- const padY = Math.round(height * 0.08);
56
- const availW = Math.max(64, width - 2 * padX);
57
- const availH = Math.max(64, height - 2 * padY);
58
- let zoom;
59
- if (zoomOverride > 0) {
60
- zoom = Math.max(MIN_ZOOM, Math.min(maxZoom, Math.round(zoomOverride)));
61
- }
62
- else {
63
- zoom = pullBackTinyTracks(fitZoomToTrack(bbox, availW, availH, maxZoom), bbox);
64
- zoom = Math.max(MIN_ZOOM, zoom - Math.max(0, Math.floor(zoomOut)));
65
- }
66
- const northWest = project(bbox.minLon, bbox.maxLat, zoom);
67
- const southEast = project(bbox.maxLon, bbox.minLat, zoom);
68
- const centerPx = {
69
- x: (northWest.x + southEast.x) / 2,
70
- y: (northWest.y + southEast.y) / 2,
71
- };
72
- const trackSpanPx = {
73
- x: southEast.x - northWest.x,
74
- y: southEast.y - northWest.y,
75
- };
76
- return {
77
- centerPx,
78
- zoom,
79
- tiles: tilesCovering(centerPx, trackSpanPx, zoom, width, height, follow, maxNativeZoom),
80
- };
81
- }
82
- export function planView(bbox, width, height, config) {
83
- const src = TILE_SOURCES[config.style];
84
- return computeOverview({
85
- bbox,
86
- width,
87
- height,
88
- maxZoom: zoomLimits(config.style).max,
89
- maxNativeZoom: src.maxNativeZoom ?? null,
90
- zoomOut: config.zoomOut,
91
- zoomOverride: config.zoom,
92
- follow: config.view === 'follow',
93
- });
94
- }
95
- export function planIntroOutroFrames(config, source) {
96
- let introN = Math.max(0, Math.round(config.introSec * source.fps));
97
- let outroN = Math.max(0, Math.round(config.outroSec * source.fps));
98
- const budget = Math.max(2, Math.floor(source.frames / 2));
99
- const clamped = introN + outroN > budget;
100
- if (clamped) {
101
- const scale = budget / (introN + outroN);
102
- introN = Math.floor(introN * scale);
103
- outroN = Math.floor(outroN * scale);
104
- }
105
- return { introN, outroN, clamped };
106
- }
package/dist/png.js DELETED
@@ -1,32 +0,0 @@
1
- import zlib from 'node:zlib';
2
- function pngChunk(type, data) {
3
- const len = Buffer.alloc(4);
4
- len.writeUInt32BE(data.length);
5
- const body = Buffer.concat([Buffer.from(type, 'ascii'), data]);
6
- const crc = Buffer.alloc(4);
7
- crc.writeUInt32BE(zlib.crc32(body));
8
- return Buffer.concat([len, body, crc]);
9
- }
10
- export function solidPng(hexColor, size = 256) {
11
- const r = Number.parseInt(hexColor.slice(1, 3), 16);
12
- const g = Number.parseInt(hexColor.slice(3, 5), 16);
13
- const b = Number.parseInt(hexColor.slice(5, 7), 16);
14
- const row = Buffer.alloc(1 + size * 3);
15
- for (let x = 0; x < size; x++) {
16
- row[1 + x * 3] = r;
17
- row[2 + x * 3] = g;
18
- row[3 + x * 3] = b;
19
- }
20
- const raw = Buffer.concat(Array.from({ length: size }, () => row));
21
- const ihdr = Buffer.alloc(13);
22
- ihdr.writeUInt32BE(size, 0);
23
- ihdr.writeUInt32BE(size, 4);
24
- ihdr[8] = 8; // bit depth
25
- ihdr[9] = 2; // color type RGB
26
- return Buffer.concat([
27
- Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
28
- pngChunk('IHDR', ihdr),
29
- pngChunk('IDAT', zlib.deflateSync(raw)),
30
- pngChunk('IEND', Buffer.alloc(0)),
31
- ]);
32
- }
@@ -1,102 +0,0 @@
1
- const MAX_VARINT_BYTES = 10;
2
- function readVarint(buf, pos, end) {
3
- let value = 0n;
4
- let shift = 0n;
5
- let i = pos;
6
- while (i < end && i - pos < MAX_VARINT_BYTES) {
7
- const byte = buf[i++];
8
- value |= BigInt(byte & 0x7f) << shift;
9
- if ((byte & 0x80) === 0)
10
- return { value, next: i };
11
- shift += 7n;
12
- }
13
- return null;
14
- }
15
- function signedVarint(value) {
16
- return Number(BigInt.asIntN(64, value));
17
- }
18
- export function parseProtoFields(buf, start, end) {
19
- const fields = new Map();
20
- let pos = start;
21
- while (pos < end) {
22
- const key = readVarint(buf, pos, end);
23
- if (!key)
24
- break;
25
- const fieldNumber = Number(key.value >> 3n);
26
- const wireType = Number(key.value & 7n);
27
- pos = key.next;
28
- const field = readValue(buf, pos, end, wireType, fieldNumber);
29
- if (!field)
30
- break; // groups / unknown wire types / truncation: stop this level
31
- pos = field.next;
32
- pushField(fields, fieldNumber, field.protoField);
33
- }
34
- return fields;
35
- }
36
- function readValue(buf, pos, end, wireType, fieldNumber) {
37
- const base = { wireType, fieldNumber };
38
- if (wireType === 0) {
39
- const v = readVarint(buf, pos, end);
40
- return v && { protoField: { ...base, varintValue: v.value }, next: v.next };
41
- }
42
- if (wireType === 1) {
43
- if (pos + 8 > end)
44
- return null;
45
- return {
46
- protoField: { ...base, doubleValue: buf.readDoubleLE(pos) },
47
- next: pos + 8,
48
- };
49
- }
50
- if (wireType === 2) {
51
- const len = readVarint(buf, pos, end);
52
- if (!len)
53
- return null;
54
- const payloadStart = len.next;
55
- const n = Number(len.value);
56
- if (payloadStart + n > end)
57
- return null;
58
- return {
59
- protoField: { ...base, bytesSpan: [payloadStart, payloadStart + n] },
60
- next: payloadStart + n,
61
- };
62
- }
63
- if (wireType === 5) {
64
- if (pos + 4 > end)
65
- return null;
66
- return {
67
- protoField: { ...base, floatValue: buf.readFloatLE(pos) },
68
- next: pos + 4,
69
- };
70
- }
71
- return null;
72
- }
73
- function pushField(fields, fieldNumber, field) {
74
- const existing = fields.get(fieldNumber);
75
- if (existing)
76
- existing.push(field);
77
- else
78
- fields.set(fieldNumber, [field]);
79
- }
80
- export function firstSubMessage(buf, fields, fieldNumber) {
81
- const field = fields.get(fieldNumber)?.[0];
82
- if (!field?.bytesSpan)
83
- return null;
84
- const [start, end] = field.bytesSpan;
85
- return parseProtoFields(buf, start, end);
86
- }
87
- export function firstVarintField(fields, fieldNumber) {
88
- const value = fields.get(fieldNumber)?.[0]?.varintValue;
89
- return value !== undefined ? signedVarint(value) : null;
90
- }
91
- export function firstFloatField(fields, fieldNumber) {
92
- const value = fields.get(fieldNumber)?.[0]?.floatValue;
93
- return value ?? null;
94
- }
95
- export function firstDoubleField(fields, fieldNumber) {
96
- const value = fields.get(fieldNumber)?.[0]?.doubleValue;
97
- return value ?? null;
98
- }
99
- export function firstStringField(buf, fields, fieldNumber) {
100
- const span = fields.get(fieldNumber)?.[0]?.bytesSpan;
101
- return span ? buf.toString('utf8', span[0], span[1]) : null;
102
- }
package/dist/range.js DELETED
@@ -1,50 +0,0 @@
1
- export function parseByteRange(header, size) {
2
- if (header === undefined)
3
- return null;
4
- const text = Array.isArray(header) ? header[0] : header;
5
- const m = /^bytes=(\d*)-(\d*)$/.exec(text.trim());
6
- if (!m)
7
- return null;
8
- const from = m[1];
9
- const to = m[2];
10
- if (from === '' && to === '')
11
- return null;
12
- let start;
13
- let end;
14
- if (from === '') {
15
- const suffix = Number(to);
16
- if (!Number.isFinite(suffix) || suffix <= 0)
17
- return 'unsatisfiable';
18
- start = Math.max(0, size - suffix);
19
- end = size - 1;
20
- }
21
- else {
22
- start = Number(from);
23
- end = to === '' ? size - 1 : Number(to);
24
- if (!Number.isFinite(start) || !Number.isFinite(end))
25
- return null;
26
- }
27
- if (start > end || start >= size)
28
- return 'unsatisfiable';
29
- return { start, end: Math.min(end, size - 1) };
30
- }
31
- export function planByteRange(header, size, mime) {
32
- const range = parseByteRange(header, size);
33
- if (range === 'unsatisfiable') {
34
- return {
35
- status: 416,
36
- headers: { 'Content-Range': `bytes */${size}`, 'Content-Type': 'text/plain' },
37
- body: 'range not satisfiable',
38
- };
39
- }
40
- const headers = {
41
- 'Content-Type': mime,
42
- 'Accept-Ranges': 'bytes',
43
- 'Cache-Control': 'no-store',
44
- 'Content-Length': String(range === null ? size : range.end - range.start + 1),
45
- };
46
- if (range === null)
47
- return { status: 200, headers };
48
- headers['Content-Range'] = `bytes ${range.start}-${range.end}/${size}`;
49
- return { status: 206, headers, span: range };
50
- }
@@ -1,55 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- export function isRecordingName(name) {
4
- return name.toLowerCase().endsWith('.mp4');
5
- }
6
- export function videoBaseName(filePath) {
7
- return path.basename(filePath).replace(/\.[^.]+$/, '');
8
- }
9
- export function findSrtSidecar(videoPath) {
10
- const dir = path.dirname(videoPath);
11
- const base = videoBaseName(videoPath);
12
- for (const f of fs.readdirSync(dir)) {
13
- if (f.toLowerCase() === `${base.toLowerCase()}.srt`) {
14
- return path.join(dir, f);
15
- }
16
- }
17
- return null;
18
- }
19
- function listMp4(dir, recurse) {
20
- const found = [];
21
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
22
- const full = path.join(dir, entry.name);
23
- if (entry.isDirectory()) {
24
- if (recurse)
25
- found.push(...listMp4(full, recurse));
26
- }
27
- else if (entry.isFile() && isRecordingName(entry.name)) {
28
- found.push(full);
29
- }
30
- }
31
- return found;
32
- }
33
- export function collectRecordings(inputs, opts) {
34
- const files = [];
35
- for (const item of inputs) {
36
- const full = path.resolve(item);
37
- if (!fs.existsSync(full))
38
- throw new Error(`input not found: ${item}`);
39
- const st = fs.statSync(full);
40
- if (st.isDirectory()) {
41
- files.push(...listMp4(full, opts.recurse));
42
- }
43
- else if (isRecordingName(full)) {
44
- files.push(full);
45
- }
46
- else {
47
- throw new Error(`not an .mp4 recording: ${full}`);
48
- }
49
- }
50
- const unique = [...new Set(files.map((f) => path.resolve(f)))].sort((a, b) => a.localeCompare(b, 'en'));
51
- if (unique.length === 0) {
52
- throw new Error('no .mp4 recordings found in the given input');
53
- }
54
- return unique;
55
- }
@@ -1,85 +0,0 @@
1
- import { hasAltitude, resolveHudLayout } from './config.js';
2
- import { decimateTrack } from './decimate.js';
3
- import { unproject } from './geo.js';
4
- import { planIntroOutroFrames, planView } from './plan.js';
5
- import { TILE_SOURCES } from './renderer/tilesources.js';
6
- export function planPageOpts(opts) {
7
- const { bbox, width, height, config, source, frames, planned, previous } = opts;
8
- const overview = planned?.overview ?? planView(bbox, width, height, config);
9
- const introOutro = planned?.introOutro ?? planIntroOutroFrames(config, source);
10
- const hud = planned?.hud ?? resolveHudLayout(config.hud, hasAltitude(frames.alt));
11
- const decimated = previous && previous.zoom === overview.zoom
12
- ? previous.decimated
13
- : decimateTrack(frames.lat, frames.lon, overview.zoom);
14
- return {
15
- width,
16
- height,
17
- style: config.style,
18
- trailColor: config.trailColor,
19
- view: config.view,
20
- center: unproject(overview.centerPx.x, overview.centerPx.y, overview.zoom),
21
- zoom: overview.zoom,
22
- attribution: TILE_SOURCES[config.style].attribution,
23
- introN: introOutro.introN,
24
- outroN: introOutro.outroN,
25
- lat: frames.lat,
26
- lon: frames.lon,
27
- alt: frames.alt,
28
- speed: frames.speed,
29
- headingDeg: frames.headingDeg,
30
- hud,
31
- decimated,
32
- };
33
- }
34
- export function buildSceneData(opts, tileBase) {
35
- const { width, height, style, trailColor, view, center, zoom, attribution, lat, lon, alt, speed, headingDeg, hud, decimated, introN = 0, outroN = 0, } = opts;
36
- return {
37
- style,
38
- trailColor,
39
- tileUrl: tileBase + '/' + style + '/{z}/{x}/{y}.png',
40
- view,
41
- width,
42
- height,
43
- zoom,
44
- center: { lat: center.lat, lon: center.lon },
45
- attribution,
46
- introN,
47
- outroN,
48
- lat, lon, alt, speed, headingDeg,
49
- hud,
50
- trailLat: decimated.lat,
51
- trailLon: decimated.lon,
52
- trailFrame: decimated.frame,
53
- };
54
- }
55
- function bootScript(dataJson) {
56
- return `import { bootScene } from '/renderer/boot.js';
57
- var D = window.__DATA = ${dataJson};
58
- var scene = bootScene(document.getElementById('scene-host'), D, window.L);
59
- window.__setFrame = function (i) { return scene.setFrame(i); };
60
- window.__relayout = function () { scene.relayout(); };
61
- scene.ready.then(function () { window.__READY = true; });`;
62
- }
63
- export function buildPageHtml(opts) {
64
- const data = buildSceneData(opts, '/tiles');
65
- // "</" must not appear verbatim: the JSON is inlined into a <script> tag.
66
- const json = JSON.stringify(data).replace(/</g, '\\u003c');
67
- return `<!DOCTYPE html>
68
- <html>
69
- <head>
70
- <meta charset="utf-8">
71
- <title>flight map</title>
72
- <link rel="stylesheet" href="/leaflet/leaflet.css">
73
- <style>
74
- html, body { margin: 0; padding: 0; overflow: hidden; background: ${TILE_SOURCES[opts.style].bg}; }
75
- </style>
76
- </head>
77
- <body>
78
- <div id="scene-host"></div>
79
- <script src="/leaflet/leaflet.js"></script>
80
- <script type="module">
81
- ${bootScript(json)}
82
- </script>
83
- </body>
84
- </html>`;
85
- }