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.
Files changed (84) 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/archive-cli.d.ts +1 -0
  5. package/dist/archive-cli.js +50 -0
  6. package/dist/archive-query-cli.d.ts +3 -0
  7. package/dist/archive-query-cli.js +128 -0
  8. package/dist/cli.d.ts +14 -0
  9. package/dist/cli.js +19 -12
  10. package/dist/version.d.ts +1 -0
  11. package/package.json +22 -68
  12. package/CHANGELOG.md +0 -349
  13. package/app/ipc.d.mts +0 -44
  14. package/app/ipc.mjs +0 -237
  15. package/app/main.mjs +0 -369
  16. package/app/preload.cjs +0 -36
  17. package/app/update-policy.d.mts +0 -6
  18. package/app/update-policy.mjs +0 -6
  19. package/app/update.d.mts +0 -10
  20. package/app/update.mjs +0 -54
  21. package/dist/appassets.js +0 -35
  22. package/dist/apppaths.js +0 -20
  23. package/dist/appsession.js +0 -121
  24. package/dist/appstate.js +0 -101
  25. package/dist/assets.js +0 -60
  26. package/dist/buildinfo.js +0 -64
  27. package/dist/cammeta-decode.js +0 -237
  28. package/dist/cammeta.js +0 -92
  29. package/dist/changeset-gate.js +0 -39
  30. package/dist/config.js +0 -631
  31. package/dist/configfile.js +0 -86
  32. package/dist/decimate.js +0 -84
  33. package/dist/desktop-i18n/generated/catalogs.js +0 -1230
  34. package/dist/desktop-i18n/messages.js +0 -47
  35. package/dist/errors.js +0 -34
  36. package/dist/exec-tool.js +0 -13
  37. package/dist/exportjob.js +0 -90
  38. package/dist/ffmpeg-tools.js +0 -56
  39. package/dist/ffmpeg.js +0 -98
  40. package/dist/frametime.js +0 -32
  41. package/dist/geo.js +0 -60
  42. package/dist/logging.js +0 -1
  43. package/dist/manual/anchors.js +0 -17
  44. package/dist/manual/build.js +0 -67
  45. package/dist/manual/cliref.js +0 -34
  46. package/dist/manual/links.js +0 -59
  47. package/dist/manual/markdown.js +0 -98
  48. package/dist/manual/model.js +0 -1
  49. package/dist/manual/module.js +0 -5
  50. package/dist/manual/nav.js +0 -11
  51. package/dist/manual/reference.js +0 -18
  52. package/dist/paths.js +0 -16
  53. package/dist/pipeline.js +0 -402
  54. package/dist/plan.js +0 -106
  55. package/dist/png.js +0 -32
  56. package/dist/protobuf-wire.js +0 -102
  57. package/dist/range.js +0 -50
  58. package/dist/recordings.js +0 -55
  59. package/dist/render-page.js +0 -85
  60. package/dist/render.js +0 -268
  61. package/dist/renderer/boot.js +0 -7
  62. package/dist/renderer/dom.js +0 -179
  63. package/dist/renderer/framemath.js +0 -30
  64. package/dist/renderer/scene.js +0 -388
  65. package/dist/renderer/theme.js +0 -82
  66. package/dist/renderer/tilesources.js +0 -38
  67. package/dist/renderer/trail.js +0 -42
  68. package/dist/restyle.js +0 -16
  69. package/dist/serve.js +0 -27
  70. package/dist/srt.js +0 -98
  71. package/dist/telemetry-json-schema.js +0 -18
  72. package/dist/telemetry-json.js +0 -126
  73. package/dist/telemetry-math.js +0 -267
  74. package/dist/telemetry-summary.js +0 -19
  75. package/dist/telemetry.js +0 -95
  76. package/dist/tilecache.js +0 -21
  77. package/dist/tiles.js +0 -155
  78. package/dist/track-format.js +0 -13
  79. package/dist/track-geojson.js +0 -44
  80. package/dist/track-gpx.js +0 -34
  81. package/dist/track-kml.js +0 -47
  82. package/dist/track-kmz.js +0 -68
  83. package/dist/track-write.js +0 -41
  84. package/dist/track.js +0 -79
package/dist/appstate.js DELETED
@@ -1,101 +0,0 @@
1
- import fs from 'node:fs';
2
- import path from 'node:path';
3
- import { z } from 'zod';
4
- import { DEFAULT_CONFIG, SETTINGS_KEYS, formatHud, parseSettingsPatch, parseValue, strictShape, } from './config.js';
5
- import { errorMessage } from './errors.js';
6
- export const APP_STATE_VERSION = 1;
7
- export function emptyAppState() {
8
- return { settings: null, lastOpenDir: null, language: null };
9
- }
10
- function fillMissingSettings(raw) {
11
- if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
12
- return raw;
13
- const filled = { ...raw };
14
- for (const key of SETTINGS_KEYS) {
15
- if (!(key in filled))
16
- filled[key] = DEFAULT_CONFIG[key];
17
- }
18
- return filled;
19
- }
20
- const APP_STATE_SHAPE = {
21
- version: z.unknown().optional(),
22
- settings: z.unknown().optional(),
23
- lastOpenDir: z.unknown().optional(),
24
- language: z.unknown().optional(),
25
- };
26
- const LAST_OPEN_DIR = z
27
- .optional(z.nullable(z.string({
28
- error: (issue) => `invalid app state: lastOpenDir: ${String(issue.input)}`,
29
- })))
30
- .transform((value) => value ?? null);
31
- export function parseAppState(raw) {
32
- const state = parseValue(strictShape(APP_STATE_SHAPE, {
33
- invalid: 'invalid app state',
34
- unknownKey: (key) => `unknown app state key ${key}`,
35
- }), raw);
36
- parseValue(z.literal(APP_STATE_VERSION, {
37
- error: (issue) => `unsupported app state version: ${String(issue.input)}`,
38
- }), state.version);
39
- const settings = state.settings === undefined || state.settings === null
40
- ? null
41
- : parseSettingsPatch(fillMissingSettings(state.settings), 'app state');
42
- return {
43
- settings,
44
- lastOpenDir: parseValue(LAST_OPEN_DIR, state.lastOpenDir),
45
- language: typeof state.language === 'string' ? state.language : null,
46
- };
47
- }
48
- export function serializeAppState(state) {
49
- const out = { version: APP_STATE_VERSION };
50
- if (state.settings) {
51
- const settings = {};
52
- for (const key of SETTINGS_KEYS) {
53
- settings[key] =
54
- key === 'hud' ? formatHud(state.settings.hud) : state.settings[key];
55
- }
56
- out.settings = settings;
57
- }
58
- if (state.lastOpenDir !== null)
59
- out.lastOpenDir = state.lastOpenDir;
60
- if (state.language !== null)
61
- out.language = state.language;
62
- return `${JSON.stringify(out, null, 2)}\n`;
63
- }
64
- export function applyAppState(config, state) {
65
- if (!state.settings)
66
- return config;
67
- return {
68
- ...config,
69
- ...state.settings,
70
- hud: { ...state.settings.hud },
71
- };
72
- }
73
- export function rememberOpenedFile(state, filePath) {
74
- return { ...state, lastOpenDir: path.dirname(filePath) };
75
- }
76
- export function readAppState(file) {
77
- let text;
78
- try {
79
- text = fs.readFileSync(file, 'utf8');
80
- }
81
- catch {
82
- return emptyAppState();
83
- }
84
- try {
85
- return parseAppState(JSON.parse(text));
86
- }
87
- catch {
88
- return emptyAppState();
89
- }
90
- }
91
- export function writeAppState(file, state) {
92
- try {
93
- fs.mkdirSync(path.dirname(file), { recursive: true });
94
- fs.writeFileSync(file, serializeAppState(state));
95
- }
96
- catch (e) {
97
- throw new Error(`cannot write app state ${file}: ${errorMessage(e)}`, {
98
- cause: e,
99
- });
100
- }
101
- }
package/dist/assets.js DELETED
@@ -1,60 +0,0 @@
1
- import path from 'node:path';
2
- import { parseTilePathname, tilePaths } from './tilecache.js';
3
- export const MIME = {
4
- '.html': 'text/html; charset=utf-8',
5
- '.js': 'text/javascript; charset=utf-8',
6
- '.css': 'text/css; charset=utf-8',
7
- '.json': 'application/json; charset=utf-8',
8
- '.txt': 'text/plain; charset=utf-8',
9
- '.svg': 'image/svg+xml',
10
- '.ico': 'image/x-icon',
11
- '.png': 'image/png',
12
- '.mp4': 'video/mp4',
13
- };
14
- export function mimeFor(filePath) {
15
- return MIME[path.extname(filePath).toLowerCase()] ?? 'application/octet-stream';
16
- }
17
- export function resolveTileRoute(pathname, tileCache, policy) {
18
- const parsed = parseTilePathname(pathname);
19
- if (!parsed)
20
- return null;
21
- if (!('anyStyle' in policy) && parsed.style !== policy.style)
22
- return null;
23
- const paths = tilePaths(tileCache, parsed.style, parsed.tile);
24
- return {
25
- style: parsed.style,
26
- tile: parsed.tile,
27
- filePath: paths.file,
28
- placeholderPath: paths.placeholder,
29
- };
30
- }
31
- export function resolveAsset(url, routes) {
32
- if (url.startsWith('/leaflet/')) {
33
- const rel = url.slice('/leaflet/'.length);
34
- if (!/^(leaflet\.(js|css|js\.map|css\.map)|images\/[a-z0-9_-]+\.png)$/.test(rel)) {
35
- return { kind: 'missing' };
36
- }
37
- return fileResolution(path.join(routes.leafletDir, rel));
38
- }
39
- if (url.startsWith('/tiles/')) {
40
- const tile = resolveTileRoute(url, routes.tileCache, { style: routes.style });
41
- return tile
42
- ? {
43
- kind: 'file',
44
- filePath: tile.filePath,
45
- fallbackPath: tile.placeholderPath,
46
- mime: mimeFor(tile.filePath),
47
- }
48
- : { kind: 'missing' };
49
- }
50
- if (url.startsWith('/renderer/')) {
51
- const rel = url.slice('/renderer/'.length);
52
- if (!/^[a-z0-9_-]+\.js$/.test(rel))
53
- return { kind: 'missing' };
54
- return fileResolution(path.join(routes.rendererDir, rel));
55
- }
56
- return { kind: 'unrouted' };
57
- }
58
- function fileResolution(filePath) {
59
- return { kind: 'file', filePath, mime: mimeFor(filePath) };
60
- }
package/dist/buildinfo.js DELETED
@@ -1,64 +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 { runTool } from './exec-tool.js';
6
- import { VERSION } from './version.js';
7
- export function defaultBuildinfoPaths(root) {
8
- return {
9
- moduleFile: path.join(root, 'ui', 'lib', 'buildinfo', 'generated', 'buildinfo.ts'),
10
- };
11
- }
12
- export function resolveBuildGit(version, probe) {
13
- const commit = probe?.headCommit?.trim() ?? '';
14
- if (probe === null || commit === '')
15
- return null;
16
- // Only the matching v<version> tag marks a formal release; any other state
17
- // keeps the commit hash visible.
18
- return { tagged: probe.tagsAtHead.includes(`v${version}`), commit: commit.slice(0, 8) };
19
- }
20
- export function buildinfoModuleSource(version, git) {
21
- return ('// Generated by src/buildinfo.ts at build time. Do not edit.\n' +
22
- "import type { BuildGit } from '../../buildversion.js';\n" +
23
- '\n' +
24
- `export const BUILD_VERSION = ${JSON.stringify(version)};\n` +
25
- `export const BUILD_GIT: BuildGit | null = ${JSON.stringify(git)};\n`);
26
- }
27
- export function buildBuildinfo(paths, version, probe) {
28
- const git = resolveBuildGit(version, probe);
29
- fs.mkdirSync(path.dirname(paths.moduleFile), { recursive: true });
30
- fs.writeFileSync(paths.moduleFile, buildinfoModuleSource(version, git));
31
- return git;
32
- }
33
- async function tryGit(args) {
34
- try {
35
- const { stdout } = await runTool('git', [...args]);
36
- return stdout;
37
- }
38
- catch {
39
- return null;
40
- }
41
- }
42
- async function probeGit() {
43
- const head = await tryGit(['rev-parse', 'HEAD']);
44
- if (head === null)
45
- return null;
46
- // A missing tag list only means HEAD is untagged, not that git is gone.
47
- const tags = await tryGit(['tag', '--points-at', 'HEAD']);
48
- return {
49
- headCommit: head.trim(),
50
- tagsAtHead: (tags ?? '')
51
- .split('\n')
52
- .map((tag) => tag.trim())
53
- .filter((tag) => tag !== ''),
54
- };
55
- }
56
- async function main() {
57
- const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
58
- const git = buildBuildinfo(defaultBuildinfoPaths(root), VERSION, await probeGit());
59
- const detail = git === null ? 'no git' : git.tagged ? 'tagged' : `commit ${git.commit}`;
60
- process.stderr.write(`[drone-path] buildinfo: ${VERSION} (${detail})\n`);
61
- }
62
- if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
63
- void runToolMain(main);
64
- }
@@ -1,237 +0,0 @@
1
- import { gpsFixOrNull } from './geo.js';
2
- import { firstDoubleField, firstFloatField, firstStringField, firstVarintField, parseProtoFields, firstSubMessage, } from './protobuf-wire.js';
3
- // DVTM field numbers; the message layout is documented in docs/telemetry-protobuf.md.
4
- const CLIP_META = 1;
5
- const CLIP_META_HEADER = 1;
6
- const PROTO_FILE_NAME = 1;
7
- const PRODUCT_PROTO_VERSION = 3;
8
- const FRAME_META = 3;
9
- const CAMERA = 2;
10
- const ISO = 3;
11
- const WHITE_BALANCE_CCT = 6;
12
- const ABSOLUTE_ALTITUDE = 11;
13
- const DRONE = 4;
14
- const GPS_BASIC = 4;
15
- const POSITION_COORD = 1;
16
- const GPS_ALTITUDE_MM = 2;
17
- const RELATIVE_ALTITUDE = 5;
18
- const EULER_ANGLE = 3;
19
- const GIMBAL = 5;
20
- const GIMBAL_DEVICE_HEADER = 1;
21
- const GIMBAL_EULER_ANGLE = 2;
22
- const DEVICE_ID = 1;
23
- const DEVICE_TYPE = 2;
24
- const DEVICE_SUB_TYPE = 3;
25
- const DEVICE_NAME = 4;
26
- const DEVICE_FREQUENCY = 5;
27
- const DEVICE_TIMESTAMP = 6;
28
- const VALUE = 1;
29
- const PITCH = 1;
30
- const ROLL = 2;
31
- const YAW = 3;
32
- const LAT = 2;
33
- const LON = 3;
34
- // GPS double-pair wire signature (0x11 lat f64, 0x19 lon f64); see docs/telemetry-protobuf.md.
35
- const GPS_PAIR_SPAN = 18;
36
- function emptyProductMeta() {
37
- return {
38
- fix: null,
39
- noLock: false,
40
- relAlt: null,
41
- absAlt: null,
42
- yawDeg: null,
43
- pitchDeg: null,
44
- rollDeg: null,
45
- gpsAltMm: null,
46
- gimbalPitchDeg: null,
47
- gimbalRollDeg: null,
48
- gimbalYawDeg: null,
49
- gimbalDeviceTimestampMs: null,
50
- iso: null,
51
- whiteBalanceCctK: null,
52
- };
53
- }
54
- export function decodeProductMeta(buf, start = 0, end = buf.length) {
55
- const top = parseProtoFields(buf, start, end);
56
- const frameMeta = firstSubMessage(buf, top, FRAME_META);
57
- const camera = frameMeta ? firstSubMessage(buf, frameMeta, CAMERA) : null;
58
- const drone = frameMeta ? firstSubMessage(buf, frameMeta, DRONE) : null;
59
- const gimbal = frameMeta ? firstSubMessage(buf, frameMeta, GIMBAL) : null;
60
- const absAlt = camera ? decodeAbsoluteAltitude(buf, camera) : null;
61
- const gps = drone ? decodeGps(buf, drone) : null;
62
- const euler = drone ? decodeEulerAngles(buf, drone, EULER_ANGLE) : null;
63
- const gimbalEuler = gimbal
64
- ? decodeEulerAngles(buf, gimbal, GIMBAL_EULER_ANGLE)
65
- : null;
66
- const gimbalHeader = gimbal
67
- ? firstSubMessage(buf, gimbal, GIMBAL_DEVICE_HEADER)
68
- : null;
69
- return {
70
- fix: gps?.fix ?? null,
71
- noLock: gps?.noLock ?? false,
72
- relAlt: drone ? decodeRelativeAltitude(buf, drone) : null,
73
- absAlt: absAlt ?? gpsAltMeters(gps?.gpsAltMm ?? null),
74
- yawDeg: euler?.yawDeg ?? null,
75
- pitchDeg: euler?.pitchDeg ?? null,
76
- rollDeg: euler?.rollDeg ?? null,
77
- gpsAltMm: gps?.gpsAltMm ?? null,
78
- gimbalPitchDeg: gimbalEuler?.pitchDeg ?? null,
79
- gimbalRollDeg: gimbalEuler?.rollDeg ?? null,
80
- gimbalYawDeg: gimbalEuler?.yawDeg ?? null,
81
- gimbalDeviceTimestampMs: gimbalHeader
82
- ? (firstVarintField(gimbalHeader, DEVICE_TIMESTAMP) ?? 0)
83
- : null,
84
- iso: camera ? decodeCameraVarint(buf, camera, ISO) : null,
85
- whiteBalanceCctK: camera ? decodeCameraVarint(buf, camera, WHITE_BALANCE_CCT) : null,
86
- };
87
- }
88
- function decodeCameraVarint(buf, camera, fieldNumber) {
89
- const message = firstSubMessage(buf, camera, fieldNumber);
90
- return message ? (firstVarintField(message, VALUE) ?? 0) : null;
91
- }
92
- function decodeAbsoluteAltitude(buf, camera) {
93
- const absoluteAltitude = firstSubMessage(buf, camera, ABSOLUTE_ALTITUDE);
94
- if (!absoluteAltitude)
95
- return null;
96
- const meters = firstFloatField(absoluteAltitude, VALUE) ?? 0;
97
- return Number.isFinite(meters) ? meters : null;
98
- }
99
- function gpsAltMeters(gpsAltMm) {
100
- return gpsAltMm !== null ? gpsAltMm / 1000 : null;
101
- }
102
- function decodeGps(buf, drone) {
103
- const out = { fix: null, noLock: false, gpsAltMm: null };
104
- const gps = firstSubMessage(buf, drone, GPS_BASIC);
105
- if (!gps)
106
- return out;
107
- const coord = firstSubMessage(buf, gps, POSITION_COORD);
108
- if (coord) {
109
- const lat = firstDoubleField(coord, LAT);
110
- const lon = firstDoubleField(coord, LON);
111
- if (lat !== null && lon !== null) {
112
- const fix = gpsFixOrNull(lat, lon);
113
- if (fix !== null)
114
- out.fix = fix;
115
- else
116
- out.noLock = true;
117
- }
118
- }
119
- out.gpsAltMm = firstVarintField(gps, GPS_ALTITUDE_MM) ?? 0;
120
- return out;
121
- }
122
- function decodeRelativeAltitude(buf, drone) {
123
- const relative = firstSubMessage(buf, drone, RELATIVE_ALTITUDE);
124
- if (!relative)
125
- return null;
126
- const millimeters = firstFloatField(relative, VALUE) ?? 0;
127
- return Number.isFinite(millimeters) ? millimeters / 1000 : null;
128
- }
129
- function decodeEulerAngles(buf, fields, fieldNumber) {
130
- const euler = firstSubMessage(buf, fields, fieldNumber);
131
- if (!euler)
132
- return null;
133
- return {
134
- pitchDeg: (firstVarintField(euler, PITCH) ?? 0) / 10,
135
- rollDeg: (firstVarintField(euler, ROLL) ?? 0) / 10,
136
- yawDeg: (firstVarintField(euler, YAW) ?? 0) / 10,
137
- };
138
- }
139
- export function decodeProvenance(buf, start = 0, end = buf.length) {
140
- const top = parseProtoFields(buf, start, end);
141
- return {
142
- protoFile: decodeProtoFile(buf, top),
143
- gimbalDevice: decodeGimbalDevice(buf, top),
144
- };
145
- }
146
- function decodeProtoFile(buf, top) {
147
- const clipMeta = firstSubMessage(buf, top, CLIP_META);
148
- const header = clipMeta && firstSubMessage(buf, clipMeta, CLIP_META_HEADER);
149
- if (!header)
150
- return null;
151
- const name = nonEmptyString(buf, header, PROTO_FILE_NAME);
152
- const version = nonEmptyString(buf, header, PRODUCT_PROTO_VERSION);
153
- if (!name)
154
- return null;
155
- return version ? `${name} ${version}` : name;
156
- }
157
- function nonEmptyString(buf, fields, fieldNumber) {
158
- const value = firstStringField(buf, fields, fieldNumber)?.trim() ?? '';
159
- return value === '' ? null : value;
160
- }
161
- function decodeGimbalDevice(buf, top) {
162
- const frameMeta = firstSubMessage(buf, top, FRAME_META);
163
- const gimbal = frameMeta && firstSubMessage(buf, frameMeta, GIMBAL);
164
- const header = gimbal && firstSubMessage(buf, gimbal, GIMBAL_DEVICE_HEADER);
165
- if (!header)
166
- return null;
167
- return {
168
- id: firstVarintField(header, DEVICE_ID) ?? 0,
169
- type: firstVarintField(header, DEVICE_TYPE) ?? 0,
170
- subType: firstVarintField(header, DEVICE_SUB_TYPE) ?? 0,
171
- name: firstStringField(buf, header, DEVICE_NAME) ?? '',
172
- frequency: firstFloatField(header, DEVICE_FREQUENCY) ?? 0,
173
- };
174
- }
175
- export function scanGpsPair(buf, offset = 0, end = buf.length) {
176
- for (let i = offset; i <= end - GPS_PAIR_SPAN; i++) {
177
- if (buf[i] === 0x11 && buf[i + 9] === 0x19) {
178
- const fix = gpsFixOrNull(buf.readDoubleLE(i + 1), buf.readDoubleLE(i + 10));
179
- if (fix !== null)
180
- return { fix, at: i };
181
- }
182
- }
183
- return null;
184
- }
185
- function toCamSample(meta, tSec) {
186
- return { tSec, ...meta };
187
- }
188
- export function decodePacketSamples(buf, packets, keepAll) {
189
- const samples = [];
190
- let noLock = 0;
191
- let offset = 0;
192
- let protoFile = null;
193
- let gimbalDevice = null;
194
- for (const packet of packets) {
195
- const end = offset + packet.size;
196
- if (protoFile === null || gimbalDevice === null) {
197
- const declared = decodeProvenance(buf, offset, end);
198
- protoFile ??= declared.protoFile;
199
- gimbalDevice ??= declared.gimbalDevice;
200
- }
201
- let meta = decodeProductMeta(buf, offset, end);
202
- if (meta.fix === null) {
203
- const hit = scanGpsPair(buf, offset, end);
204
- if (hit)
205
- meta = { ...meta, fix: hit.fix, noLock: false };
206
- }
207
- if (meta.noLock)
208
- noLock++;
209
- if (meta.fix !== null || keepAll) {
210
- const tSec = Number.isFinite(packet.tSec) ? packet.tSec : 0;
211
- samples.push(toCamSample(meta, tSec));
212
- }
213
- offset = end;
214
- }
215
- return { samples, noLock, provenance: { protoFile, gimbalDevice } };
216
- }
217
- export function scanBufferForGpsPairs(buf) {
218
- const samples = [];
219
- for (let i = 0; i <= buf.length - GPS_PAIR_SPAN; i++) {
220
- const hit = scanGpsPair(buf, i, i + GPS_PAIR_SPAN);
221
- if (hit) {
222
- const meta = emptyProductMeta();
223
- meta.fix = hit.fix;
224
- samples.push(toCamSample(meta, 0));
225
- i += GPS_PAIR_SPAN - 1;
226
- }
227
- }
228
- return samples;
229
- }
230
- export function spreadSampleTimes(samples, durationSec) {
231
- const span = Number.isFinite(durationSec) && durationSec > 0
232
- ? durationSec
233
- : samples.length;
234
- samples.forEach((sample, k) => {
235
- sample.tSec = (k / Math.max(1, samples.length - 1)) * span;
236
- });
237
- }
package/dist/cammeta.js DELETED
@@ -1,92 +0,0 @@
1
- import fs from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { decodePacketSamples, scanBufferForGpsPairs, spreadSampleTimes, } from './cammeta-decode.js';
5
- import { runTool } from './exec-tool.js';
6
- import { ffprobeJson } from './ffmpeg.js';
7
- const FFMPEG_MAX_BUFFER = 64 * 1024 * 1024;
8
- async function findCamMetaIndex(tools, videoPath) {
9
- let probe;
10
- try {
11
- probe = await ffprobeJson(tools, videoPath, [
12
- '-select_streams',
13
- 'd',
14
- '-show_entries',
15
- 'stream=index:stream_tags=handler_name',
16
- '-of',
17
- 'json',
18
- ]);
19
- }
20
- catch (e) {
21
- throw new Error('ffprobe failed while probing the cam meta stream', { cause: e });
22
- }
23
- const streams = (probe['streams'] ?? []);
24
- for (const stream of streams) {
25
- if (stream.tags && stream.tags.handler_name === 'CAM meta')
26
- return stream.index;
27
- }
28
- return null;
29
- }
30
- async function listCamMetaPackets(tools, videoPath, streamIndex) {
31
- let probe;
32
- try {
33
- probe = await ffprobeJson(tools, videoPath, [
34
- // NOTE: bare stream index - `d:N` would mean the N-th *data* stream.
35
- '-select_streams',
36
- String(streamIndex),
37
- '-show_entries',
38
- 'packet=pts_time,size',
39
- '-of',
40
- 'json',
41
- ]);
42
- }
43
- catch (e) {
44
- throw new Error('ffprobe failed while listing the cam meta packets', { cause: e });
45
- }
46
- return (probe['packets'] ?? []).map((packet) => ({
47
- tSec: Number.parseFloat(packet.pts_time),
48
- size: Number.parseInt(packet.size, 10),
49
- }));
50
- }
51
- async function dumpCamMetaStream(tools, videoPath, streamIndex) {
52
- const tmp = path.join(os.tmpdir(), `cammeta_${process.pid}_${Date.now().toString(36)}.bin`);
53
- try {
54
- try {
55
- await runTool(tools.ffmpeg, [
56
- '-v', 'error', '-y', '-i', videoPath,
57
- '-map', `0:${streamIndex}`, '-c', 'copy', '-f', 'rawvideo', tmp,
58
- ], { maxBuffer: FFMPEG_MAX_BUFFER });
59
- }
60
- catch (e) {
61
- throw new Error('ffmpeg failed while dumping the cam meta stream', { cause: e });
62
- }
63
- return fs.readFileSync(tmp);
64
- }
65
- finally {
66
- fs.rmSync(tmp, { force: true });
67
- }
68
- }
69
- // Resolves to null only when the video carries no CAM meta stream at all; a
70
- // present stream that yields nothing decodable resolves to empty samples so
71
- // callers can tell absence from a stream without GPS fix pairs.
72
- export async function parseCamMeta(tools, videoPath, durationSec, opts = {}) {
73
- const streamIndex = await findCamMetaIndex(tools, videoPath);
74
- if (streamIndex === null)
75
- return null;
76
- const packets = await listCamMetaPackets(tools, videoPath, streamIndex);
77
- const buf = await dumpCamMetaStream(tools, videoPath, streamIndex);
78
- const sizeSum = packets.reduce((sum, packet) => sum + (Number.isFinite(packet.size) ? packet.size : 0), 0);
79
- if (buf.length > 0 && packets.length > 0 && sizeSum === buf.length) {
80
- const { samples, noLock, provenance } = decodePacketSamples(buf, packets, opts.keepAll === true);
81
- return { samples, noLock, method: 'dvtm-packets', ...provenance };
82
- }
83
- const samples = scanBufferForGpsPairs(buf);
84
- spreadSampleTimes(samples, durationSec);
85
- return {
86
- samples,
87
- noLock: 0,
88
- method: 'cammeta-scan',
89
- protoFile: null,
90
- gimbalDevice: null,
91
- };
92
- }
@@ -1,39 +0,0 @@
1
- const PR_TITLE_NEEDS_CHANGESET = /^(feat|fix)(\([^)]+\))?!?:/;
2
- const PR_TITLE_NEEDS_CHANGELOG = /^release(\([^)]+\))?:/;
3
- const CHANGESET_FRAGMENT_PATH = /^\.changeset\/([^/]+)\.md$/;
4
- const CHANGELOG_PATH = /^CHANGELOG\.md$/;
5
- export function prNeedsChangeset(prTitle) {
6
- return PR_TITLE_NEEDS_CHANGESET.test(prTitle.trim());
7
- }
8
- export function prNeedsChangelogUpdate(prTitle) {
9
- return PR_TITLE_NEEDS_CHANGELOG.test(prTitle.trim());
10
- }
11
- export function prNeedsArtifact(prTitle) {
12
- return prNeedsChangeset(prTitle) || prNeedsChangelogUpdate(prTitle);
13
- }
14
- export function hasChangesetFragment(changedPaths) {
15
- return changedPaths.some((path) => {
16
- const match = CHANGESET_FRAGMENT_PATH.exec(path);
17
- return match !== null && match[1].toLowerCase() !== 'readme';
18
- });
19
- }
20
- export function hasChangelogUpdate(changedPaths) {
21
- return changedPaths.some((path) => CHANGELOG_PATH.test(path));
22
- }
23
- export function evaluateGate(prTitle, changedPaths) {
24
- const title = prTitle.trim();
25
- if (prNeedsChangeset(title)) {
26
- return hasChangesetFragment(changedPaths)
27
- ? { ok: true, note: `changeset: fragment found for '${title}'` }
28
- : {
29
- ok: false,
30
- error: `'${title}' must add a .changeset/*.md fragment (see .changeset/README.md)`,
31
- };
32
- }
33
- if (prNeedsChangelogUpdate(title)) {
34
- return hasChangelogUpdate(changedPaths)
35
- ? { ok: true, note: `changeset: CHANGELOG.md updated for '${title}'` }
36
- : { ok: false, error: `'${title}' must change CHANGELOG.md` };
37
- }
38
- return { ok: true, note: `changeset: '${title}' requires no changelog artifact` };
39
- }