drone-path 0.12.1 → 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.
- package/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/app/ipc.d.mts +1 -0
- package/app/ipc.mjs +31 -10
- package/app/main.mjs +23 -10
- package/app/preload.cjs +2 -0
- package/dist/appstate.js +9 -2
- package/dist/desktop-i18n/generated/catalogs.js +1230 -0
- package/dist/desktop-i18n/messages.js +47 -0
- package/dist/renderer/dom.js +15 -13
- package/dist/renderer/scene.js +5 -2
- package/package.json +2 -2
|
@@ -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);
|
package/dist/renderer/dom.js
CHANGED
|
@@ -112,33 +112,35 @@ export function sceneCss(src, theme, width, height, scale, scope) {
|
|
|
112
112
|
attrCss(at, scale) +
|
|
113
113
|
scaleBarCss(at, scale));
|
|
114
114
|
}
|
|
115
|
+
export const EXPORT_HUD_LABELS = {
|
|
116
|
+
heading: 'HDG',
|
|
117
|
+
alt: 'ALT',
|
|
118
|
+
speed: 'SPD',
|
|
119
|
+
};
|
|
115
120
|
export function hudMarkup(hud) {
|
|
116
121
|
const chips = [];
|
|
117
122
|
if (hud.heading) {
|
|
118
|
-
chips.push(
|
|
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>`);
|
|
119
124
|
}
|
|
120
125
|
if (hud.alt) {
|
|
121
|
-
chips.push(
|
|
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>`);
|
|
122
127
|
}
|
|
123
128
|
if (hud.speed) {
|
|
124
|
-
chips.push(
|
|
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>`);
|
|
125
130
|
}
|
|
126
131
|
return chips.map((chip) => ` ${chip}`).join('\n');
|
|
127
132
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
* match the export HUD contract, so the scene's value queries work for both.
|
|
133
|
-
*/
|
|
134
|
-
export function stripReadoutMarkup(hud) {
|
|
133
|
+
function escapeText(value) {
|
|
134
|
+
return value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('>', '>');
|
|
135
|
+
}
|
|
136
|
+
export function stripReadoutMarkup(hud, labels) {
|
|
135
137
|
const column = (id, label, unit, live) => `<div class="map-readout${live ? '' : ' map-readout-off'}" id="chip-${id}">` +
|
|
136
|
-
`<span class="label">${label}</span>` +
|
|
138
|
+
`<span class="label">${escapeText(label)}</span>` +
|
|
137
139
|
`<span class="value"><span class="num">--</span><span class="unit">${unit}</span></span>` +
|
|
138
140
|
`</div>`;
|
|
139
141
|
return [
|
|
140
|
-
column('speed', 'Speed', 'm/s', hud.speed),
|
|
141
|
-
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),
|
|
142
144
|
]
|
|
143
145
|
.map((col) => ` ${col}`)
|
|
144
146
|
.join('\n');
|
package/dist/renderer/scene.js
CHANGED
|
@@ -257,7 +257,7 @@ class SceneState {
|
|
|
257
257
|
// (the export preview) can never cross-write. A scene whose caller
|
|
258
258
|
// overlays its own pills draws none of its own (#283).
|
|
259
259
|
this.hudRoot.innerHTML = this.externalHud
|
|
260
|
-
? stripReadoutMarkup(this.data.hud)
|
|
260
|
+
? stripReadoutMarkup(this.data.hud, this.data.stripLabels)
|
|
261
261
|
: this.data.hudPills === false
|
|
262
262
|
? ''
|
|
263
263
|
: hudMarkup(this.data.hud);
|
|
@@ -367,7 +367,10 @@ class SceneState {
|
|
|
367
367
|
next.height !== prev.height;
|
|
368
368
|
if (decorInvalidated)
|
|
369
369
|
this.rebuildDecor();
|
|
370
|
-
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)
|
|
371
374
|
this.rebuildHud();
|
|
372
375
|
this.layoutMap();
|
|
373
376
|
return this.setFrame(this.curIdx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drone-path",
|
|
3
|
-
"version": "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",
|