drone-path 0.12.0 → 0.13.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.
@@ -0,0 +1,47 @@
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);
@@ -1,4 +1,5 @@
1
1
  import { CONFIG_FILE_OPTION, CONFIG_OPTIONS, TELEMETRY_JSON_ALIAS, cliDefaultOf, } from '../config.js';
2
+ import { escapeAngleBrackets } from './markdown.js';
2
3
  function defaultCell(key) {
3
4
  const value = cliDefaultOf(key);
4
5
  if (typeof value === 'boolean')
@@ -6,7 +7,7 @@ function defaultCell(key) {
6
7
  return value === '' ? '—' : `\`${value}\``;
7
8
  }
8
9
  function describe(row) {
9
- const help = row.cli.help.replace(/</g, '&lt;').replace(/>/g, '&gt;');
10
+ const help = escapeAngleBrackets(row.cli.help);
10
11
  return row.cli.choices ? `${help} (choices: ${row.cli.choices.join(', ')})` : help;
11
12
  }
12
13
  export function generateCliReference() {
@@ -1,8 +1,13 @@
1
1
  import { Marked } from 'marked';
2
2
  import { createSlugger } from './anchors.js';
3
3
  import { isExternalTarget, parseImageRef, parsePageLink } from './links.js';
4
+ /** Angle brackets only — for help text that carries no entities (the CLI
5
+ reference renders these as literal angle brackets). */
6
+ export function escapeAngleBrackets(value) {
7
+ return value.replace(/</g, '&lt;').replace(/>/g, '&gt;');
8
+ }
4
9
  function escapeHtml(value) {
5
- return value.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
10
+ return escapeAngleBrackets(value.replace(/&/g, '&amp;'));
6
11
  }
7
12
  function escapeAttr(value) {
8
13
  return escapeHtml(value).replace(/"/g, '&quot;');
@@ -64,7 +64,15 @@ function chipCss(at, theme, scale) {
64
64
  font-size: 0.55em; font-weight: 700; letter-spacing: 1.2px;
65
65
  color: ${theme.core}; opacity: 0.95;
66
66
  }
67
- ${at} .chip .unit { font-weight: 500; opacity: 0.72; font-size: 0.68em; }`;
67
+ ${at} .chip .unit { font-weight: 500; opacity: 0.72; font-size: 0.68em; }
68
+ ${at} .chip .chip-arrow {
69
+ /* The heading arrow lives in a fixed square slot like the preview chip's,
70
+ so its ink never crowds the pill padding at any rotation angle. */
71
+ display: inline-flex; align-items: center; justify-content: center;
72
+ width: ${Math.round(24 * scale)}px; height: ${Math.round(24 * scale)}px;
73
+ font-size: ${Math.round(19 * scale)}px; line-height: 1;
74
+ color: ${theme.core};
75
+ }`;
68
76
  }
69
77
  function attrCss(at, scale) {
70
78
  return `
@@ -104,30 +112,35 @@ export function sceneCss(src, theme, width, height, scale, scope) {
104
112
  attrCss(at, scale) +
105
113
  scaleBarCss(at, scale));
106
114
  }
115
+ export const EXPORT_HUD_LABELS = {
116
+ heading: 'HDG',
117
+ alt: 'ALT',
118
+ speed: 'SPD',
119
+ };
107
120
  export function hudMarkup(hud) {
108
121
  const chips = [];
122
+ if (hud.heading) {
123
+ chips.push(`<div class="chip" id="chip-heading"><span class="label">${EXPORT_HUD_LABELS.heading}</span><span class="chip-arrow">▲</span><span class="num">--</span></div>`);
124
+ }
109
125
  if (hud.alt) {
110
- chips.push('<div class="chip" id="chip-alt"><span class="label">ALT</span><span class="num">--</span><span class="unit">m</span></div>');
126
+ chips.push(`<div class="chip" id="chip-alt"><span class="label">${EXPORT_HUD_LABELS.alt}</span><span class="num">--</span><span class="unit">m</span></div>`);
111
127
  }
112
128
  if (hud.speed) {
113
- chips.push('<div class="chip" id="chip-speed"><span class="label">SPD</span><span class="num">--</span><span class="unit">m/s</span></div>');
129
+ chips.push(`<div class="chip" id="chip-speed"><span class="label">${EXPORT_HUD_LABELS.speed}</span><span class="num">--</span><span class="unit">m/s</span></div>`);
114
130
  }
115
131
  return chips.map((chip) => ` ${chip}`).join('\n');
116
132
  }
117
- /**
118
- * The app strip's readout columns (#272): both always render so the strip's
119
- * shape never depends on settings; a disabled chip keeps its column and shows
120
- * the dimmed "--" placeholder instead of a value. The ids and .num/.unit spans
121
- * match the export HUD contract, so the scene's value queries work for both.
122
- */
123
- export function stripReadoutMarkup(hud) {
133
+ function escapeText(value) {
134
+ return value.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
135
+ }
136
+ export function stripReadoutMarkup(hud, labels) {
124
137
  const column = (id, label, unit, live) => `<div class="map-readout${live ? '' : ' map-readout-off'}" id="chip-${id}">` +
125
- `<span class="label">${label}</span>` +
138
+ `<span class="label">${escapeText(label)}</span>` +
126
139
  `<span class="value"><span class="num">--</span><span class="unit">${unit}</span></span>` +
127
140
  `</div>`;
128
141
  return [
129
- column('speed', 'Speed', 'm/s', hud.speed),
130
- column('alt', 'Altitude', 'm', hud.alt),
142
+ column('speed', labels?.speed ?? 'Speed', 'm/s', hud.speed),
143
+ column('alt', labels?.altitude ?? 'Altitude', 'm', hud.alt),
131
144
  ]
132
145
  .map((col) => ` ${col}`)
133
146
  .join('\n');
@@ -36,6 +36,7 @@ class SceneState {
36
36
  bb;
37
37
  layout;
38
38
  decor;
39
+ headingChip = null;
39
40
  altChip = null;
40
41
  speedChip = null;
41
42
  /** Chip container: inside the map frame for exports, or an external strip. */
@@ -253,10 +254,14 @@ class SceneState {
253
254
  }
254
255
  rebuildHud() {
255
256
  // Scoped to the chip container so an external strip and a second scene
256
- // (the export preview) can never cross-write.
257
+ // (the export preview) can never cross-write. A scene whose caller
258
+ // overlays its own pills draws none of its own (#283).
257
259
  this.hudRoot.innerHTML = this.externalHud
258
- ? stripReadoutMarkup(this.data.hud)
259
- : hudMarkup(this.data.hud);
260
+ ? stripReadoutMarkup(this.data.hud, this.data.stripLabels)
261
+ : this.data.hudPills === false
262
+ ? ''
263
+ : hudMarkup(this.data.hud);
264
+ this.headingChip = this.hudRoot.querySelector('#chip-heading');
260
265
  this.altChip = this.hudRoot.querySelector('#chip-alt');
261
266
  this.speedChip = this.hudRoot.querySelector('#chip-speed');
262
267
  if (this.decor.arrowEl) {
@@ -288,6 +293,23 @@ class SceneState {
288
293
  // "--" placeholder instead of a value (#272 review).
289
294
  this.setReadout(this.altChip, this.data.hud.alt ? this.data.alt[i] : null, (a) => String(Math.round(a)));
290
295
  this.setReadout(this.speedChip, this.data.hud.speed ? this.data.speed[i] : null, (s) => s.toFixed(1));
296
+ this.setHeading(this.headingChip, this.data.headingDeg[i]);
297
+ }
298
+ /** The heading pill rotates its arrow like the marker does; a missing
299
+ sample falls back to the dimmed "--", matching the preview chip (#283). */
300
+ setHeading(chip, deg) {
301
+ if (!chip)
302
+ return;
303
+ const missing = deg === null || deg === undefined;
304
+ const arrow = chip.querySelector('.chip-arrow');
305
+ const num = chip.querySelector('.num');
306
+ if (arrow) {
307
+ arrow.style.display = missing ? 'none' : '';
308
+ if (!missing)
309
+ arrow.style.transform = 'rotate(' + deg + 'deg)';
310
+ }
311
+ if (num)
312
+ num.style.display = missing ? '' : 'none';
291
313
  }
292
314
  setReadout(chip, value, format) {
293
315
  if (!chip)
@@ -345,7 +367,10 @@ class SceneState {
345
367
  next.height !== prev.height;
346
368
  if (decorInvalidated)
347
369
  this.rebuildDecor();
348
- if (!hudEq(prev.hud, next.hud))
370
+ if (!hudEq(prev.hud, next.hud) ||
371
+ next.hudPills !== prev.hudPills ||
372
+ next.stripLabels?.speed !== prev.stripLabels?.speed ||
373
+ next.stripLabels?.altitude !== prev.stripLabels?.altitude)
349
374
  this.rebuildHud();
350
375
  this.layoutMap();
351
376
  return this.setFrame(this.curIdx);
@@ -22,3 +22,17 @@ export const TILE_SOURCES = {
22
22
  maxNativeZoom: 17,
23
23
  },
24
24
  };
25
+ /** Leaflet wants HTML and the map style thumbnails plain text; the thumbnail
26
+ credits derive from these attributions so the wording can never drift. */
27
+ function plainCredit(html) {
28
+ return html
29
+ .replaceAll('&copy;', '©')
30
+ .replace(/<a [^>]+>/g, '')
31
+ .replaceAll('</a>', '')
32
+ .split(' | ')
33
+ .map((part) => part.replace('Style: ', 'Style ')); // the thumbnail wording drops the colon
34
+ }
35
+ export const TILE_CREDITS = [
36
+ ...plainCredit(TILE_SOURCES.satellite.attribution),
37
+ ...plainCredit(TILE_SOURCES.topo.attribution),
38
+ ].join(' · ');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drone-path",
3
- "version": "0.12.0",
3
+ "version": "0.13.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 embedded CAM-meta (DVTM) stream or the .SRT sidecar.",
5
5
  "type": "module",
6
6
  "main": "app/main.mjs",
@@ -24,7 +24,7 @@
24
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
26
  "build": "npm run build:manual && npm run build:info && npm run build:ui",
27
- "build:cli": "tsc -p tsconfig.json",
27
+ "build:cli": "node scripts/build-desktop-catalogs.mjs && tsc -p tsconfig.json",
28
28
  "build:info": "npm run build:cli && node dist/buildinfo.js",
29
29
  "build:manual": "npm run build:cli && node dist/manual/build.js",
30
30
  "build:ui": "next build ui --webpack",
@@ -84,10 +84,10 @@
84
84
  "concurrently": "~10.0.7",
85
85
  "electron": "~45.3.1",
86
86
  "electron-builder": "~26.18.0",
87
- "eslint": "~10.14.0",
87
+ "eslint": "~10.15.0",
88
88
  "eslint-plugin-react-hooks": "~7.1.1",
89
89
  "jsdom": "~31.0.1",
90
- "lucide-react": "~1.72.0",
90
+ "lucide-react": "~1.73.0",
91
91
  "marked": "~18.2.0",
92
92
  "next": "~16.4.6",
93
93
  "react": "~19.3.1",