drone-path-engine 1.0.0 → 1.1.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.
@@ -14,6 +14,8 @@ export declare function resolveConfig(opts: {
14
14
  cli?: ConfigOverrides;
15
15
  configPath?: string | null;
16
16
  cwd?: string;
17
+ discover?: boolean;
18
+ resolveOutDir?: boolean;
17
19
  onDeprecated?: (message: string) => void;
18
20
  cliTrackOutSpelling?: TrackOutSpelling | null;
19
21
  }): ResolvedConfig;
@@ -55,18 +55,25 @@ function mergeConfigLayers(fileCfg, cli) {
55
55
  hud: { ...(cli.hud ?? fileCfg.hud ?? DEFAULT_CONFIG.hud) },
56
56
  };
57
57
  }
58
- function resolveConfigPaths(config, cwd) {
58
+ function resolveConfigPaths(config, cwd, resolveOutDir = true) {
59
59
  return {
60
60
  ...config,
61
61
  tileCache: path.resolve(cwd, config.tileCache || defaultTileCache()),
62
- outDir: config.outDir ? path.resolve(cwd, config.outDir) : null,
62
+ outDir: config.outDir
63
+ ? resolveOutDir
64
+ ? path.resolve(cwd, config.outDir)
65
+ : config.outDir
66
+ : null,
63
67
  };
64
68
  }
65
69
  export function resolveConfig(opts) {
66
70
  const cwd = opts.cwd ?? process.cwd();
71
+ const discover = opts.discover ?? true;
67
72
  const configPath = opts.configPath !== undefined && opts.configPath !== null
68
73
  ? path.resolve(cwd, opts.configPath)
69
- : discoverConfigFile(cwd);
74
+ : discover
75
+ ? discoverConfigFile(cwd)
76
+ : null;
70
77
  const fileLayer = configPath
71
78
  ? loadConfigFile(configPath, opts.onDeprecated)
72
79
  : { overrides: {}, trackOutSpelling: null };
@@ -78,5 +85,8 @@ export function resolveConfig(opts) {
78
85
  ]);
79
86
  const merged = mergeConfigLayers(fileLayer.overrides, opts.cli ?? {});
80
87
  const normalized = finalizeRenderConfig(merged);
81
- return { config: resolveConfigPaths(normalized, cwd), configPath };
88
+ return {
89
+ config: resolveConfigPaths(normalized, cwd, opts.resolveOutDir ?? true),
90
+ configPath,
91
+ };
82
92
  }
package/dist/pipeline.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { ERR_OUTPUT_VERIFICATION, ERR_RENDER_CANCELED, errorMessage } from 'drone-path-core/errors';
3
+ import { ERR_OUTPUT_VERIFICATION, ERR_RENDER_CANCELED, codedError, errorMessage } from 'drone-path-core/errors';
4
4
  import { probeVideo } from 'drone-path-core/ffmpeg';
5
5
  import { outputMatchesSource, verifyOutput } from './ffmpeg-output.js';
6
6
  import { resolveFfmpegTools } from 'drone-path-core/ffmpeg-tools';
@@ -175,9 +175,12 @@ async function viewPlanStage(env, tel) {
175
175
  log(describeView(config, overview, config.style));
176
176
  return overview;
177
177
  }
178
+ function canceledError(cause) {
179
+ return codedError(ERR_RENDER_CANCELED, { code: 'RENDER_CANCELED', cause });
180
+ }
178
181
  async function tileWarmStage(deps, config, overview, log, signal) {
179
182
  if (signal?.aborted)
180
- throw new Error(ERR_RENDER_CANCELED);
183
+ throw canceledError();
181
184
  let tileStats;
182
185
  try {
183
186
  tileStats = await deps.prefetchTiles({
@@ -189,11 +192,11 @@ async function tileWarmStage(deps, config, overview, log, signal) {
189
192
  }
190
193
  catch (err) {
191
194
  if (signal?.aborted)
192
- throw new Error(ERR_RENDER_CANCELED, { cause: err });
195
+ throw canceledError(err);
193
196
  throw err;
194
197
  }
195
198
  if (signal?.aborted)
196
- throw new Error(ERR_RENDER_CANCELED);
199
+ throw canceledError();
197
200
  if (tileStats.downloaded) {
198
201
  log(`tiles: ${tileStats.downloaded} downloaded, ${tileStats.failed} placeholders`);
199
202
  }
@@ -282,8 +285,16 @@ async function verifyRenderedOutput(env) {
282
285
  const { ctx, deps, tools } = env;
283
286
  const verify = await deps.verifyOutput(tools, ctx.outPath, ctx.outFrames, ctx.probe.fps.value);
284
287
  if (!verify.ok) {
285
- throw new Error(`${ERR_OUTPUT_VERIFICATION}got ${verify.frames} frames @ ${verify.fps ?? 'unknown'}, ` +
286
- `expected ${ctx.outFrames} @ ${ctx.probe.fps.str}`);
288
+ throw codedError(`${ERR_OUTPUT_VERIFICATION}got ${verify.frames} frames @ ${verify.fps ?? 'unknown'}, ` +
289
+ `expected ${ctx.outFrames} @ ${ctx.probe.fps.str}`, {
290
+ code: 'OUTPUT_VERIFICATION',
291
+ params: {
292
+ frames: verify.frames,
293
+ fps: verify.fps ?? 'unknown',
294
+ expectedFrames: ctx.outFrames,
295
+ expectedFps: ctx.probe.fps.str,
296
+ },
297
+ });
287
298
  }
288
299
  ctx.log(ctx.frameRange
289
300
  ? 'verified: frame count and frame rate are 1:1 within the exported range'
@@ -350,7 +361,7 @@ export async function processRecording(videoPath, config, log, outPath = outputP
350
361
  const deps = resolveDeps(options.deps, config.tileCache);
351
362
  const tools = options.tools ?? resolveFfmpegTools(config);
352
363
  if (options.signal?.aborted)
353
- throw new Error(ERR_RENDER_CANCELED);
364
+ throw canceledError();
354
365
  const prep = await prepareWithEnv({
355
366
  videoPath,
356
367
  config,
@@ -360,7 +371,7 @@ export async function processRecording(videoPath, config, log, outPath = outputP
360
371
  report: createPrepareReporter(options.onProgress),
361
372
  });
362
373
  if (options.signal?.aborted)
363
- throw new Error(ERR_RENDER_CANCELED);
374
+ throw canceledError();
364
375
  if (config.trackOut) {
365
376
  writeTrackExport(config.trackOut, prep, log);
366
377
  }
package/dist/render.js CHANGED
@@ -2,7 +2,7 @@ import http from 'node:http';
2
2
  import { spawn } from 'node:child_process';
3
3
  import { once } from 'node:events';
4
4
  import { MIME } from './assets.js';
5
- import { ERR_RENDER_CANCELED, errorMessage } from 'drone-path-core/errors';
5
+ import { ERR_RENDER_CANCELED, codedError, errorMessage } from 'drone-path-core/errors';
6
6
  import { RENDERER_DIR, serveAsset } from './serve.js';
7
7
  const PAGE_LOAD_TIMEOUT_MS = 60000;
8
8
  const SCREENSHOT_TIMEOUT_MS = 60000;
@@ -267,6 +267,9 @@ async function captureFrame(run, loop, page, idx) {
267
267
  run.onCapture?.({ done, total: run.frames });
268
268
  }
269
269
  }
270
+ function canceledError(cause) {
271
+ return codedError(ERR_RENDER_CANCELED, { code: 'RENDER_CANCELED', cause });
272
+ }
270
273
  async function workerLoop(run, loop, workerId) {
271
274
  const page = await run.active.newPage({
272
275
  viewport: { width: run.width, height: run.height },
@@ -279,7 +282,7 @@ async function workerLoop(run, loop, workerId) {
279
282
  if (loop.failed)
280
283
  return;
281
284
  if (run.signal?.aborted)
282
- throw new Error(ERR_RENDER_CANCELED);
285
+ throw canceledError();
283
286
  const idx = loop.cursor++;
284
287
  if (idx >= run.frames)
285
288
  break;
@@ -326,13 +329,13 @@ async function captureAndEncode(active, env) {
326
329
  const stream = new OrderedFrameStream(encoder, workerCount);
327
330
  const abortEncode = () => {
328
331
  encoder.kill();
329
- stream.abort(new Error(ERR_RENDER_CANCELED));
332
+ stream.abort(canceledError());
330
333
  };
331
334
  signal?.addEventListener('abort', abortEncode, { once: true });
332
335
  try {
333
336
  await runWorkers({ ...ctx, active, url, stream, timing }, workerCount);
334
337
  if (signal?.aborted)
335
- throw new Error(ERR_RENDER_CANCELED);
338
+ throw canceledError();
336
339
  await finishEncode(encoder, stream, log, outPath);
337
340
  }
338
341
  catch (e) {
@@ -341,7 +344,7 @@ async function captureAndEncode(active, env) {
341
344
  if (signal?.aborted) {
342
345
  throw e instanceof Error && e.message === ERR_RENDER_CANCELED
343
346
  ? e
344
- : new Error(ERR_RENDER_CANCELED, { cause: e });
347
+ : canceledError(e);
345
348
  }
346
349
  throw e;
347
350
  }
@@ -379,7 +382,7 @@ export async function renderVideo(opts) {
379
382
  tools,
380
383
  };
381
384
  if (signal?.aborted)
382
- throw new Error(ERR_RENDER_CANCELED);
385
+ throw canceledError();
383
386
  const timing = { evalMs: 0, captureMs: 0, emitMs: 0 };
384
387
  const { server, url } = await startServer({ html, style, tileCache, log });
385
388
  const env = { ctx, url, timing, workerCount };
@@ -78,7 +78,7 @@ function attrCss(at, scale) {
78
78
  return `
79
79
  ${at} #attr {
80
80
  position: absolute; right: 0; bottom: 0; z-index: 1000; max-width: 72%;
81
- background: rgba(12, 14, 22, 0.62); color: rgba(255,255,255,0.78);
81
+ background: rgba(12, 14, 22, 0.8); color: rgba(255,255,255,0.88);
82
82
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
83
83
  font-size: ${Math.round(11 * scale)}px; line-height: 1.35;
84
84
  padding: ${Math.round(2 * scale)}px ${Math.round(8 * scale)}px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drone-path-engine",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Plan and render flight-path map overlays from drone telemetry.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@types/leaflet": "~1.9.22",
33
- "drone-path-core": "~1.0.0",
33
+ "drone-path-core": "~1.1.0",
34
34
  "leaflet": "~1.9.4",
35
35
  "p-queue": "~10.0.0",
36
36
  "playwright-core": "~1.65.0",