drone-path 0.8.0 → 0.9.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 +39 -0
- package/README.md +19 -26
- package/THIRD-PARTY-NOTICES.md +7 -0
- package/app/main.mjs +82 -28
- package/app/preload.cjs +3 -0
- package/dist/appassets.js +2 -11
- package/dist/apppaths.js +2 -10
- package/dist/appsession.js +59 -25
- package/dist/appstate.js +0 -18
- package/dist/assets.js +0 -7
- package/dist/buildinfo.js +71 -0
- package/dist/cammeta.js +123 -84
- package/dist/changeset-gate.js +0 -7
- package/dist/cli.js +0 -15
- package/dist/config.js +40 -52
- package/dist/configfile.js +0 -8
- package/dist/decimate.js +2 -12
- package/dist/exportjob.js +3 -19
- package/dist/ff.js +0 -8
- package/dist/fftools.js +0 -10
- 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 +0 -3
- package/dist/proto.js +4 -4
- package/dist/range.js +0 -8
- package/dist/render.js +3 -53
- package/dist/renderer/dom.js +0 -6
- package/dist/renderer/framemath.js +0 -4
- package/dist/renderer/leaflet.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 +45 -46
- 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 +107 -0
- package/dist/telemetry-math.js +9 -45
- package/dist/telemetry.js +52 -9
- package/dist/tilecache.js +0 -5
- package/dist/tiles.js +2 -32
- package/dist/tracing.js +3 -27
- package/package.json +15 -12
package/dist/telemetry-math.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
// Pure telemetry math: turns time-stamped samples into per-frame values
|
|
2
|
-
// (position, speed, heading) plus the track statistics. No I/O lives here,
|
|
3
|
-
// so the loader shell and the unit tests drive it directly with in-memory
|
|
4
|
-
// samples.
|
|
5
1
|
import { bearingDeg, circularMeanDeg, haversineM } from './geo.js';
|
|
6
|
-
const MAX_INTERPOLATION_GAP_S = 3;
|
|
7
|
-
const SPEED_SMOOTHING_SPAN = 5;
|
|
8
|
-
const HEADING_MIN_MOVE_M = 1.5;
|
|
9
|
-
const HEADING_HALF_WINDOW_S = 0.35;
|
|
10
|
-
const HEADING_MAX_BASELINE_S = 3;
|
|
11
|
-
const HEADING_MIN_SPEED_MPS = 0.5;
|
|
12
|
-
const HEADING_SMOOTHING_SPAN = 4;
|
|
2
|
+
const MAX_INTERPOLATION_GAP_S = 3;
|
|
3
|
+
const SPEED_SMOOTHING_SPAN = 5;
|
|
4
|
+
const HEADING_MIN_MOVE_M = 1.5;
|
|
5
|
+
const HEADING_HALF_WINDOW_S = 0.35;
|
|
6
|
+
const HEADING_MAX_BASELINE_S = 3;
|
|
7
|
+
const HEADING_MIN_SPEED_MPS = 0.5;
|
|
8
|
+
const HEADING_SMOOTHING_SPAN = 4;
|
|
13
9
|
function isFixSample(sample) {
|
|
14
10
|
return sample.fix !== null;
|
|
15
11
|
}
|
|
16
|
-
// The fix-bearing samples in order, with their indices; the pipeline works
|
|
17
|
-
// from these instead of re-deriving who carries a fix.
|
|
18
12
|
function fixRefs(samples) {
|
|
19
13
|
const refs = [];
|
|
20
14
|
samples.forEach((sample, index) => {
|
|
@@ -38,7 +32,6 @@ function interpolateAltitude(a, b, fraction) {
|
|
|
38
32
|
return altA;
|
|
39
33
|
return altA + (altB - altA) * fraction;
|
|
40
34
|
}
|
|
41
|
-
// Nearest sample with a GPS fix at or beyond idx in the given direction.
|
|
42
35
|
function nearestFix(samples, idx, direction) {
|
|
43
36
|
let i = idx;
|
|
44
37
|
while (i >= 0 && i < samples.length) {
|
|
@@ -49,8 +42,6 @@ function nearestFix(samples, idx, direction) {
|
|
|
49
42
|
}
|
|
50
43
|
return null;
|
|
51
44
|
}
|
|
52
|
-
// Position at time t (seconds). Gaps of missing fixes longer than maxGapSec
|
|
53
|
-
// are bridged by holding the earlier fix instead of interpolating across them.
|
|
54
45
|
function positionAt(samples, t, maxGapSec = MAX_INTERPOLATION_GAP_S) {
|
|
55
46
|
const n = samples.length;
|
|
56
47
|
if (n === 0)
|
|
@@ -80,7 +71,6 @@ function positionAt(samples, t, maxGapSec = MAX_INTERPOLATION_GAP_S) {
|
|
|
80
71
|
alt: interpolateAltitude(a, b, fraction),
|
|
81
72
|
};
|
|
82
73
|
}
|
|
83
|
-
// t before the first sample yields index 0.
|
|
84
74
|
function sampleIndexBefore(samples, t) {
|
|
85
75
|
let lo = 0;
|
|
86
76
|
let hi = samples.length - 1;
|
|
@@ -119,9 +109,6 @@ function computeTrackStats(fixes) {
|
|
|
119
109
|
}
|
|
120
110
|
return { bbox, trackDistanceM };
|
|
121
111
|
}
|
|
122
|
-
// Centered difference over neighboring fixes (m/s), smoothed with a moving
|
|
123
|
-
// average to tame GPS jitter for the HUD. Values live on the sample indexes
|
|
124
|
-
// so any sample can answer a frame's nearest-sample lookup.
|
|
125
112
|
function computeSpeedBySample(sampleCount, fixes) {
|
|
126
113
|
const rawSpeed = new Array(fixes.length).fill(null);
|
|
127
114
|
for (let k = 1; k < fixes.length - 1; k++) {
|
|
@@ -130,7 +117,6 @@ function computeSpeedBySample(sampleCount, fixes) {
|
|
|
130
117
|
rawSpeed[k] = haversineM(fixes[k - 1].fix, fixes[k + 1].fix) / dt;
|
|
131
118
|
}
|
|
132
119
|
}
|
|
133
|
-
// Endpoints reuse the adjacent centered value.
|
|
134
120
|
rawSpeed[0] = rawSpeed[1] ?? 0;
|
|
135
121
|
rawSpeed[fixes.length - 1] = rawSpeed[fixes.length - 2] ?? 0;
|
|
136
122
|
const speedBySample = new Array(sampleCount).fill(0);
|
|
@@ -150,10 +136,6 @@ function computeSpeedBySample(sampleCount, fixes) {
|
|
|
150
136
|
}
|
|
151
137
|
return speedBySample;
|
|
152
138
|
}
|
|
153
|
-
// Preferred source: drone body yaw (DVTM EulerAngle, deci-degrees) - valid
|
|
154
|
-
// even while hovering. Fallback: course over ground measured across a moving
|
|
155
|
-
// baseline (consecutive fixes are only centimeters apart at 60 fps, so
|
|
156
|
-
// neighbor bearings are pure GPS jitter). Held while truly stationary.
|
|
157
139
|
function computeHeadingBySample(samples, fixes, speedBySample) {
|
|
158
140
|
const hasYaw = samples.some((sample) => sample.yawDeg !== null);
|
|
159
141
|
const headingMode = hasYaw ? 'yaw' : 'cog';
|
|
@@ -165,7 +147,6 @@ function computeHeadingBySample(samples, fixes, speedBySample) {
|
|
|
165
147
|
fillCourseOverGroundHeadings(fixes, speedBySample, rawHeading);
|
|
166
148
|
}
|
|
167
149
|
fillHeadingGaps(rawHeading);
|
|
168
|
-
// Samples without a fix carry the default so the array is fully populated.
|
|
169
150
|
const defaultHeading = rawHeading[0] ?? firstKnownHeading(rawHeading) ?? 0;
|
|
170
151
|
const headingBySample = new Array(samples.length).fill(defaultHeading);
|
|
171
152
|
for (let k = 0; k < fixes.length; k++) {
|
|
@@ -191,8 +172,6 @@ function fillCourseOverGroundHeadings(fixes, speedBySample, rawHeading) {
|
|
|
191
172
|
const tk = fixes[k].tSec;
|
|
192
173
|
if ((speedBySample[fixes[k].index] ?? 0) < HEADING_MIN_SPEED_MPS)
|
|
193
174
|
continue;
|
|
194
|
-
// Grow the baseline until the pair clears the GPS jitter floor: slow
|
|
195
|
-
// flights get a wider window instead of losing their heading to holds.
|
|
196
175
|
let ka = k;
|
|
197
176
|
let kb = k;
|
|
198
177
|
let displacement = 0;
|
|
@@ -212,9 +191,6 @@ function fillCourseOverGroundHeadings(fixes, speedBySample, rawHeading) {
|
|
|
212
191
|
}
|
|
213
192
|
}
|
|
214
193
|
}
|
|
215
|
-
// The leading unknowns are back-filled from the FIRST known heading, never
|
|
216
|
-
// the flight's final heading, which would point the arrow the wrong way on
|
|
217
|
-
// clips that start hovering and turn later.
|
|
218
194
|
function fillHeadingGaps(rawHeading) {
|
|
219
195
|
let last = null;
|
|
220
196
|
for (let k = 0; k < rawHeading.length; k++) {
|
|
@@ -223,17 +199,9 @@ function fillHeadingGaps(rawHeading) {
|
|
|
223
199
|
else
|
|
224
200
|
rawHeading[k] = last;
|
|
225
201
|
}
|
|
226
|
-
const
|
|
227
|
-
if (firstKnown !== null) {
|
|
228
|
-
for (let k = 0; k < rawHeading.length; k++) {
|
|
229
|
-
if (rawHeading[k] === null)
|
|
230
|
-
rawHeading[k] = firstKnown;
|
|
231
|
-
else
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
202
|
+
const fallback = firstKnownHeading(rawHeading) ?? 0;
|
|
235
203
|
for (let k = 0; k < rawHeading.length; k++) {
|
|
236
|
-
rawHeading[k] ??=
|
|
204
|
+
rawHeading[k] ??= fallback;
|
|
237
205
|
}
|
|
238
206
|
}
|
|
239
207
|
function firstKnownHeading(rawHeading) {
|
|
@@ -258,9 +226,6 @@ function buildFrameData(samples, frames, fpsValue, speedBySample, headingBySampl
|
|
|
258
226
|
}
|
|
259
227
|
return frameData;
|
|
260
228
|
}
|
|
261
|
-
// Bridge fully-missing frame positions at the very ends: frames before the
|
|
262
|
-
// first fix hold the first fix, frames after the last fix hold the last fix
|
|
263
|
-
// (the hold-earlier policy from positionAt, applied past its ends).
|
|
264
229
|
function bridgeMissingFramePositions(frameData) {
|
|
265
230
|
const first = frameData.find((d) => d.fix !== null);
|
|
266
231
|
const last = [...frameData].reverse().find((d) => d.fix !== null);
|
|
@@ -277,7 +242,6 @@ function bridgeMissingFramePositions(frameData) {
|
|
|
277
242
|
trail--;
|
|
278
243
|
}
|
|
279
244
|
}
|
|
280
|
-
// The pure pipeline: samples in, per-frame telemetry and track stats out.
|
|
281
245
|
export function buildTelemetry(loaded, timing) {
|
|
282
246
|
const { samples, source, method, noLock } = loaded;
|
|
283
247
|
const fixes = fixRefs(samples);
|
package/dist/telemetry.js
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
// The telemetry I/O shell: discovers and parses a recording's telemetry
|
|
2
|
-
// sources (.SRT sidecar, embedded CAM meta) and hands the samples to the pure
|
|
3
|
-
// pipeline in src/telemetry-math.ts. The math is reachable without files so
|
|
4
|
-
// unit tests can drive it with in-memory samples.
|
|
5
1
|
import { parseSrt } from './srt.js';
|
|
6
2
|
import { parseCamMeta } from './cammeta.js';
|
|
7
3
|
import { findSrtSidecar } from './inputs.js';
|
|
8
4
|
import { buildTelemetry } from './telemetry-math.js';
|
|
9
|
-
|
|
5
|
+
function srtCueToFrameValues(cue) {
|
|
6
|
+
return {
|
|
7
|
+
lat: cue.fix?.lat ?? null,
|
|
8
|
+
lng: cue.fix?.lon ?? null,
|
|
9
|
+
altAbs: cue.absAlt,
|
|
10
|
+
altRel: cue.relAlt,
|
|
11
|
+
iso: cue.iso,
|
|
12
|
+
shutterTime: cue.shutterTime,
|
|
13
|
+
whiteBalanceCctK: cue.whiteBalanceCctK,
|
|
14
|
+
fNumber: cue.fNumber,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function camSampleToFrameValues(sample) {
|
|
18
|
+
return {
|
|
19
|
+
gimbalDeviceTimestampMs: sample.gimbalDeviceTimestampMs,
|
|
20
|
+
lat: sample.fix?.lat ?? null,
|
|
21
|
+
lng: sample.fix?.lon ?? null,
|
|
22
|
+
altAbs: sample.absAlt,
|
|
23
|
+
altRel: sample.relAlt,
|
|
24
|
+
gpsAltMm: sample.gpsAltMm,
|
|
25
|
+
pitchDeg: sample.pitchDeg,
|
|
26
|
+
rollDeg: sample.rollDeg,
|
|
27
|
+
yawDeg: sample.yawDeg,
|
|
28
|
+
gimbalPitchDeg: sample.gimbalPitchDeg,
|
|
29
|
+
gimbalRollDeg: sample.gimbalRollDeg,
|
|
30
|
+
gimbalYawDeg: sample.gimbalYawDeg,
|
|
31
|
+
iso: sample.iso,
|
|
32
|
+
whiteBalanceCctK: sample.whiteBalanceCctK,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
10
35
|
async function loadSamples(tools, videoPath, durationSec) {
|
|
11
36
|
const srtPath = findSrtSidecar(videoPath);
|
|
12
37
|
if (srtPath) {
|
|
@@ -24,15 +49,33 @@ async function loadSamples(tools, videoPath, durationSec) {
|
|
|
24
49
|
source: 'srt',
|
|
25
50
|
method: 'srt-cues',
|
|
26
51
|
noLock: parsed.noLock,
|
|
52
|
+
frameValues: parsed.cues.map(srtCueToFrameValues),
|
|
53
|
+
protoFile: null,
|
|
54
|
+
gimbalDevice: null,
|
|
27
55
|
};
|
|
28
56
|
}
|
|
29
|
-
const cam = await parseCamMeta(tools, videoPath, durationSec);
|
|
30
|
-
|
|
57
|
+
const cam = await parseCamMeta(tools, videoPath, durationSec, { keepAll: true });
|
|
58
|
+
const fixSamples = cam ? cam.samples.filter((sample) => sample.fix !== null) : [];
|
|
59
|
+
if (!cam || fixSamples.length === 0) {
|
|
31
60
|
throw new Error('no telemetry found: no .SRT sidecar and no GPS pairs in the CAM meta stream');
|
|
32
61
|
}
|
|
33
|
-
return {
|
|
62
|
+
return {
|
|
63
|
+
samples: fixSamples,
|
|
64
|
+
source: 'cammeta',
|
|
65
|
+
method: cam.method,
|
|
66
|
+
noLock: cam.noLock,
|
|
67
|
+
frameValues: cam.method === 'dvtm-packets' ? cam.samples.map(camSampleToFrameValues) : [],
|
|
68
|
+
protoFile: cam.protoFile,
|
|
69
|
+
gimbalDevice: cam.gimbalDevice,
|
|
70
|
+
};
|
|
34
71
|
}
|
|
35
72
|
export async function loadTelemetry(videoPath, { frames, fpsValue, durationSec, tools, }) {
|
|
36
73
|
const loaded = await loadSamples(tools, videoPath, durationSec);
|
|
37
|
-
|
|
74
|
+
const { frameValues, protoFile, gimbalDevice, ...samples } = loaded;
|
|
75
|
+
return {
|
|
76
|
+
telemetry: buildTelemetry(samples, { frames, fpsValue }),
|
|
77
|
+
frameValues,
|
|
78
|
+
protoFile,
|
|
79
|
+
gimbalDevice,
|
|
80
|
+
};
|
|
38
81
|
}
|
package/dist/tilecache.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// The one tile cache layout and tile URL parsing, shared by the prefetcher,
|
|
2
|
-
// the render server and the app server so they can never disagree about
|
|
3
|
-
// where a tile lives or which URLs are tiles at all.
|
|
4
1
|
import path from 'node:path';
|
|
5
2
|
import { TILE_SOURCES } from './renderer/tilesources.js';
|
|
6
3
|
function cacheKeyFor(style) {
|
|
@@ -10,8 +7,6 @@ export function parseTilePathname(pathname) {
|
|
|
10
7
|
const m = /^\/tiles\/([a-z0-9_-]+)\/(\d+)\/(\d+)\/(\d+)\.png$/.exec(pathname);
|
|
11
8
|
if (!m)
|
|
12
9
|
return null;
|
|
13
|
-
// The URL regex admits any slug; only vocabulary styles are tiles, so the
|
|
14
|
-
// returned style is never a cast lie the callers must re-check.
|
|
15
10
|
const style = Object.hasOwn(TILE_SOURCES, m[1]) ? m[1] : null;
|
|
16
11
|
return style === null
|
|
17
12
|
? null
|
package/dist/tiles.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// The polite tile download policy in one home: every request start - retries
|
|
2
|
-
// included - is spaced REQUEST_INTERVAL_MS apart (2.0 req/s) and at most
|
|
3
|
-
// DOWNLOAD_WORKERS downloads run at once, whichever entry point drives them.
|
|
4
|
-
// createTileTraffic (the app: on-demand tiles and exports on one queue) and
|
|
5
|
-
// prefetchTiles (the CLI's bulk prefetch, its own queue as it runs alone) are
|
|
6
|
-
// thin wrappers whose priorities decide ordering and sharing.
|
|
7
1
|
import fs from 'node:fs';
|
|
8
2
|
import path from 'node:path';
|
|
9
3
|
import { errorMessage } from './errors.js';
|
|
@@ -12,17 +6,13 @@ import { tilePaths } from './tilecache.js';
|
|
|
12
6
|
import { TILE_SOURCES } from './renderer/tilesources.js';
|
|
13
7
|
import { VERSION } from './version.js';
|
|
14
8
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
|
-
const USER_AGENT = `drone-path/${VERSION} (flight-path map renderer; https://github.com/MrManny/
|
|
9
|
+
const USER_AGENT = `drone-path/${VERSION} (flight-path map renderer; https://github.com/MrManny/drone-path)`;
|
|
16
10
|
const DOWNLOAD_ATTEMPTS = 2;
|
|
17
11
|
const DOWNLOAD_WORKERS = 2;
|
|
18
12
|
const REQUEST_INTERVAL_MS = 500;
|
|
19
13
|
const RETRY_DELAY_MS = 500;
|
|
20
14
|
const FETCH_TIMEOUT_MS = 20000;
|
|
21
15
|
function createRequestGate() {
|
|
22
|
-
// Waiters release in arrival order - the queue's priorities decide who
|
|
23
|
-
// acquires first - and the stamp lands at the actual release with every
|
|
24
|
-
// turn re-checking after sleeping: a late event-loop wake can never
|
|
25
|
-
// squeeze the next start inside the previous release's interval.
|
|
26
16
|
let nextFreeAt = 0;
|
|
27
17
|
let tail = Promise.resolve();
|
|
28
18
|
return () => {
|
|
@@ -51,14 +41,9 @@ function tileUrl(style, tile) {
|
|
|
51
41
|
.replace('{x}', String(tile.x))
|
|
52
42
|
.replace('{y}', String(tile.y));
|
|
53
43
|
}
|
|
54
|
-
// A canceled download is not a failed one: no placeholder is written and the
|
|
55
|
-
// tile stays uncached, so a later request may fetch the real tile.
|
|
56
44
|
function canceledError(signal) {
|
|
57
45
|
return new Error('tile download canceled', { cause: signal.reason });
|
|
58
46
|
}
|
|
59
|
-
// The network half of one tile: its body after a successful attempt, null
|
|
60
|
-
// when the attempts run out. The download retry is for network problems
|
|
61
|
-
// only; cache writes live in writeCacheFile and fail fast.
|
|
62
47
|
async function downloadTile(url, acquire, signal) {
|
|
63
48
|
for (let attempt = 0; attempt < DOWNLOAD_ATTEMPTS; attempt++) {
|
|
64
49
|
await acquire();
|
|
@@ -80,9 +65,6 @@ async function downloadTile(url, acquire, signal) {
|
|
|
80
65
|
}
|
|
81
66
|
return null;
|
|
82
67
|
}
|
|
83
|
-
// An fs failure while writing the cache is the cache's fault, not the
|
|
84
|
-
// network's: it fails the tile's job instead of being retried as a download,
|
|
85
|
-
// and names the cache so the log and Open errors read it as a cache failure.
|
|
86
68
|
function writeCacheFile(cachePath, data) {
|
|
87
69
|
try {
|
|
88
70
|
fs.mkdirSync(path.dirname(cachePath), { recursive: true });
|
|
@@ -92,9 +74,6 @@ function writeCacheFile(cachePath, data) {
|
|
|
92
74
|
throw new Error(`cache write failed: ${cachePath}: ${errorMessage(e)}`, { cause: e });
|
|
93
75
|
}
|
|
94
76
|
}
|
|
95
|
-
// Placeholder PNGs are pure derivations of the tile source's background
|
|
96
|
-
// color; memoizing per downloader keeps repeat failures cheap without any
|
|
97
|
-
// module-level mutable state.
|
|
98
77
|
function createPlaceholderSource() {
|
|
99
78
|
const cache = new Map();
|
|
100
79
|
return (style) => {
|
|
@@ -106,9 +85,6 @@ function createPlaceholderSource() {
|
|
|
106
85
|
return png;
|
|
107
86
|
};
|
|
108
87
|
}
|
|
109
|
-
// The full cache dance for one tile: hit, download, or placeholder. The
|
|
110
|
-
// placeholder is served as a fallback so a missing tile is retried on a later
|
|
111
|
-
// run instead of being cached as missing.
|
|
112
88
|
async function fetchTileToCache(ctx, style, tile, signal) {
|
|
113
89
|
const paths = tilePaths(ctx.cacheDir, style, tile);
|
|
114
90
|
if (fs.existsSync(paths.file))
|
|
@@ -156,8 +132,7 @@ function createDownloader(cacheDir, placeholderPng) {
|
|
|
156
132
|
enqueue(style, tile, options = {}) {
|
|
157
133
|
const priority = options.priority ?? 'background';
|
|
158
134
|
const key = `${priority}:${tilePaths(cacheDir, style, tile).file}`;
|
|
159
|
-
//
|
|
160
|
-
// sharing follows the abort signal of the download it joins.
|
|
135
|
+
// Share only within one stream: a canceled stream's downloads must never be handed to the next one.
|
|
161
136
|
const shared = inFlight.get(key);
|
|
162
137
|
if (shared && shared.signal === options.signal)
|
|
163
138
|
return shared.promise;
|
|
@@ -200,8 +175,6 @@ function createDownloader(cacheDir, placeholderPng) {
|
|
|
200
175
|
},
|
|
201
176
|
};
|
|
202
177
|
}
|
|
203
|
-
// The app's tile traffic on one polite queue: on-demand tiles jump ahead of
|
|
204
|
-
// the queued prefetch, and both stay inside the same 2.0 req/s budget.
|
|
205
178
|
export function createTileTraffic(cacheDir) {
|
|
206
179
|
const downloader = createDownloader(cacheDir, createPlaceholderSource());
|
|
207
180
|
return {
|
|
@@ -233,9 +206,6 @@ export function createTileTraffic(cacheDir) {
|
|
|
233
206
|
},
|
|
234
207
|
};
|
|
235
208
|
}
|
|
236
|
-
// Polite bulk fetching for the pipeline: 2 concurrent workers, 2.0 req/s. It
|
|
237
|
-
// settles once per tile (cached, downloaded or failed) through onTile and
|
|
238
|
-
// rejects with 'tile download canceled' when a signal aborts it.
|
|
239
209
|
export function prefetchTiles(options) {
|
|
240
210
|
return createTileTraffic(options.cacheDir).stream(options);
|
|
241
211
|
}
|
package/dist/tracing.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Without an endpoint no OpenTelemetry package is ever imported, so untraced
|
|
2
|
-
// runs keep their exact output and pay no overhead.
|
|
3
1
|
import { errorMessage } from './errors.js';
|
|
4
2
|
import { VERSION } from './version.js';
|
|
5
3
|
const SERVICE_NAME = 'drone-path';
|
|
@@ -17,8 +15,6 @@ function envFlag(value) {
|
|
|
17
15
|
return value?.trim().toLowerCase() === 'true';
|
|
18
16
|
}
|
|
19
17
|
function envText(value) {
|
|
20
|
-
// A blank value means "unset": the OTLP lookups fall through on undefined,
|
|
21
|
-
// so an empty string must not count as configured (which ?? would allow).
|
|
22
18
|
const trimmed = value?.trim();
|
|
23
19
|
return trimmed === '' ? undefined : trimmed;
|
|
24
20
|
}
|
|
@@ -27,8 +23,7 @@ export function isTracingEnabled(env = process.env) {
|
|
|
27
23
|
envText(env['OTEL_EXPORTER_OTLP_ENDPOINT']);
|
|
28
24
|
return endpoint !== undefined && !envFlag(env['OTEL_SDK_DISABLED']);
|
|
29
25
|
}
|
|
30
|
-
//
|
|
31
|
-
// the signal path is appended to (OTLP spec).
|
|
26
|
+
// Per OTLP spec the specific endpoint is used as-is; the generic one is a base URL that gets /v1/traces.
|
|
32
27
|
export function otlpTracesUrl(env) {
|
|
33
28
|
const specific = envText(env['OTEL_EXPORTER_OTLP_TRACES_ENDPOINT']);
|
|
34
29
|
if (specific)
|
|
@@ -36,8 +31,6 @@ export function otlpTracesUrl(env) {
|
|
|
36
31
|
const base = envText(env['OTEL_EXPORTER_OTLP_ENDPOINT']);
|
|
37
32
|
return base ? `${base.replace(/\/+$/, '')}/v1/traces` : undefined;
|
|
38
33
|
}
|
|
39
|
-
// `k1=v1,k2=v2` lists with URL-encoded values, as the OTEL header and
|
|
40
|
-
// resource-attribute variables use.
|
|
41
34
|
function parseKeyValueList(value) {
|
|
42
35
|
const out = {};
|
|
43
36
|
for (const pair of (value ?? '').split(',')) {
|
|
@@ -57,15 +50,12 @@ function parseKeyValueList(value) {
|
|
|
57
50
|
}
|
|
58
51
|
return out;
|
|
59
52
|
}
|
|
60
|
-
// Signal-specific headers win per key over the generic ones (OTLP spec).
|
|
61
53
|
export function otlpHeaders(env) {
|
|
62
54
|
return {
|
|
63
55
|
...parseKeyValueList(envText(env['OTEL_EXPORTER_OTLP_HEADERS'])),
|
|
64
56
|
...parseKeyValueList(envText(env['OTEL_EXPORTER_OTLP_TRACES_HEADERS'])),
|
|
65
57
|
};
|
|
66
58
|
}
|
|
67
|
-
// Parsed here instead of via envDetector because that reads process.env
|
|
68
|
-
// directly, which would leave the env seam half-applied.
|
|
69
59
|
export function resourceAttributesFromEnv(env) {
|
|
70
60
|
const attrs = parseKeyValueList(envText(env['OTEL_RESOURCE_ATTRIBUTES']));
|
|
71
61
|
const serviceName = envText(env['OTEL_SERVICE_NAME']);
|
|
@@ -73,10 +63,6 @@ export function resourceAttributesFromEnv(env) {
|
|
|
73
63
|
attrs['service.name'] = serviceName;
|
|
74
64
|
return attrs;
|
|
75
65
|
}
|
|
76
|
-
// Exporting is fixed to OTLP/HTTP protobuf; a protocol variable promising
|
|
77
|
-
// anything else would silently push into the wrong port of the collector.
|
|
78
|
-
// Per the OTel spec the signal-specific variable wins over the generic one,
|
|
79
|
-
// so only the effective value is judged.
|
|
80
66
|
function assertSupportedProtocol(env) {
|
|
81
67
|
const specific = envText(env['OTEL_EXPORTER_OTLP_TRACES_PROTOCOL']);
|
|
82
68
|
const generic = envText(env['OTEL_EXPORTER_OTLP_PROTOCOL']);
|
|
@@ -88,8 +74,6 @@ function assertSupportedProtocol(env) {
|
|
|
88
74
|
throw new Error(`unsupported ${name}: ${value} (only ${OTLP_PROTOCOL} is supported)`);
|
|
89
75
|
}
|
|
90
76
|
}
|
|
91
|
-
// The span ends with the body (or earlier, if the body ends it), and a thrown
|
|
92
|
-
// error is recorded on it before it propagates.
|
|
93
77
|
export async function withSpan(tracer, name, options, body) {
|
|
94
78
|
const span = tracer.startSpan(name, options);
|
|
95
79
|
try {
|
|
@@ -103,8 +87,6 @@ export async function withSpan(tracer, name, options, body) {
|
|
|
103
87
|
throw e;
|
|
104
88
|
}
|
|
105
89
|
}
|
|
106
|
-
// Parent and initial attributes are exactly what every stage site would
|
|
107
|
-
// otherwise spell out again.
|
|
108
90
|
export function stage(tracer, name, parent, attributes, body) {
|
|
109
91
|
return withSpan(tracer, name, { parent, attributes }, body);
|
|
110
92
|
}
|
|
@@ -148,9 +130,7 @@ class OtelTracer {
|
|
|
148
130
|
}
|
|
149
131
|
startSpan(name, options) {
|
|
150
132
|
const parent = options?.parent;
|
|
151
|
-
// Unwrap through
|
|
152
|
-
// OpenTelemetry handle (a no-op or foreign span) would silently detach the
|
|
153
|
-
// new span and quietly break the trace topology - refuse it instead.
|
|
133
|
+
// Unwrap through Span.raw, not instanceof: a parent without an OpenTelemetry handle would silently detach the new span.
|
|
154
134
|
const parentRaw = parent?.raw;
|
|
155
135
|
if (parent && !parentRaw) {
|
|
156
136
|
throw new Error('parent span carries no OpenTelemetry handle');
|
|
@@ -161,8 +141,6 @@ class OtelTracer {
|
|
|
161
141
|
return new OtelSpan(this.api, this.raw.startSpan(name, { attributes: options?.attributes }, context));
|
|
162
142
|
}
|
|
163
143
|
}
|
|
164
|
-
// The OpenTelemetry packages are imported here and nowhere else, so a disabled
|
|
165
|
-
// run never loads them.
|
|
166
144
|
export async function createTracing(options = {}) {
|
|
167
145
|
const env = options.env ?? process.env;
|
|
168
146
|
if (!isTracingEnabled(env)) {
|
|
@@ -192,9 +170,7 @@ export async function createTracing(options = {}) {
|
|
|
192
170
|
spanProcessors: [
|
|
193
171
|
new BatchSpanProcessor({
|
|
194
172
|
exporter,
|
|
195
|
-
// The default queue (2048) drops spans silently
|
|
196
|
-
// slow or unreachable; long batches make thousands of batch spans that
|
|
197
|
-
// must survive to keep the trace complete.
|
|
173
|
+
// The default queue (2048) drops spans silently; long batches need thousands to survive.
|
|
198
174
|
maxQueueSize: 8192,
|
|
199
175
|
}),
|
|
200
176
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drone-path",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Render flight-path map overlay videos (exactly the source frame rate and frame count) from DJI drone recordings - telemetry from the .SRT sidecar or the embedded CAM-meta (DVTM) stream.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "app/main.mjs",
|
|
@@ -21,16 +21,18 @@
|
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"app": "electron app/main.mjs",
|
|
24
|
-
"app:dev": "npm run build:manual && concurrently -k \"next dev ui --webpack -p 3210\" \"wait-on http://127.0.0.1:3210 && electron app/main.mjs --dev-url http://localhost:3210\"",
|
|
24
|
+
"app:dev": "npm run build:manual && npm run build:info && concurrently -k \"next dev ui --webpack -p 3210\" \"wait-on http://127.0.0.1:3210 && electron app/main.mjs --dev-url http://localhost:3210\"",
|
|
25
25
|
"app:pack": "electron-builder --publish never",
|
|
26
|
-
"build": "npm run build:manual && npm run build:ui",
|
|
26
|
+
"build": "npm run build:manual && npm run build:info && npm run build:ui",
|
|
27
27
|
"build:cli": "tsc -p tsconfig.json",
|
|
28
|
+
"build:info": "npm run build:cli && node dist/buildinfo.js",
|
|
28
29
|
"build:manual": "npm run build:cli && node dist/manual/build.js",
|
|
29
30
|
"build:ui": "next build ui --webpack",
|
|
30
31
|
"docs:reference": "npm run build:cli && node dist/manual/reference.js",
|
|
32
|
+
"docs:schema": "npm run build:cli && node dist/telemetry-json-schema.js",
|
|
31
33
|
"changeset": "changeset",
|
|
32
34
|
"changeset:version": "changeset version && npm install --package-lock-only",
|
|
33
|
-
"test": "npm run build:manual && npm run typecheck:test && vitest run",
|
|
35
|
+
"test": "npm run build:manual && npm run build:info && npm run typecheck:test && vitest run",
|
|
34
36
|
"typecheck:test": "tsc --noEmit -p test/tsconfig.json",
|
|
35
37
|
"lint": "eslint .",
|
|
36
38
|
"prepare": "npm run build"
|
|
@@ -52,21 +54,22 @@
|
|
|
52
54
|
"license": "MIT",
|
|
53
55
|
"repository": {
|
|
54
56
|
"type": "git",
|
|
55
|
-
"url": "git+https://github.com/MrManny/
|
|
57
|
+
"url": "git+https://github.com/MrManny/drone-path.git"
|
|
56
58
|
},
|
|
57
59
|
"bugs": {
|
|
58
|
-
"url": "https://github.com/MrManny/
|
|
60
|
+
"url": "https://github.com/MrManny/drone-path/issues"
|
|
59
61
|
},
|
|
60
|
-
"homepage": "https://github.com/MrManny/
|
|
62
|
+
"homepage": "https://github.com/MrManny/drone-path#readme",
|
|
61
63
|
"dependencies": {
|
|
62
64
|
"@opentelemetry/api": "~1.10.0",
|
|
63
|
-
"@opentelemetry/exporter-trace-otlp-proto": "~0.
|
|
64
|
-
"@opentelemetry/resources": "~3.
|
|
65
|
-
"@opentelemetry/sdk-trace": "~3.
|
|
65
|
+
"@opentelemetry/exporter-trace-otlp-proto": "~0.301.0",
|
|
66
|
+
"@opentelemetry/resources": "~3.1.0",
|
|
67
|
+
"@opentelemetry/sdk-trace": "~3.1.0",
|
|
66
68
|
"commander": "~15.0.0",
|
|
67
69
|
"electron-updater": "~6.8.11",
|
|
68
70
|
"leaflet": "~1.9.4",
|
|
69
|
-
"playwright-core": "~1.
|
|
71
|
+
"playwright-core": "~1.65.0",
|
|
72
|
+
"zod": "~4.6.7"
|
|
70
73
|
},
|
|
71
74
|
"optionalDependencies": {
|
|
72
75
|
"ffmpeg-ffprobe-static": "~7.1.0-rc.1"
|
|
@@ -85,7 +88,7 @@
|
|
|
85
88
|
"electron-builder": "~26.18.0",
|
|
86
89
|
"eslint": "~10.14.0",
|
|
87
90
|
"eslint-plugin-react-hooks": "~7.1.1",
|
|
88
|
-
"jsdom": "~
|
|
91
|
+
"jsdom": "~31.0.0",
|
|
89
92
|
"marked": "~18.1.3",
|
|
90
93
|
"next": "~16.4.3",
|
|
91
94
|
"react": "~19.3.1",
|