@depths/waves 0.2.0 → 0.3.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/dist/cli.mjs CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  WavesEngine,
4
4
  __wavesVersion,
5
5
  getPromptPayload
6
- } from "./chunk-7QPNRHMW.mjs";
6
+ } from "./chunk-QP54QRAP.mjs";
7
7
  import {
8
8
  VideoIRv2AuthoringSchema,
9
9
  WavesRenderError,
@@ -11,7 +11,7 @@ import {
11
11
  globalRegistry,
12
12
  registerBuiltInComponents,
13
13
  zodSchemaToJsonSchema
14
- } from "./chunk-PKLHVWMD.mjs";
14
+ } from "./chunk-YYS6AVTN.mjs";
15
15
 
16
16
  // src/cli.ts
17
17
  import fs from "fs/promises";
@@ -42,7 +42,7 @@ function parseArgs(argv) {
42
42
  const hasInlineValue = eq >= 0;
43
43
  const inlineValue = hasInlineValue ? arg.slice(eq + 1) : void 0;
44
44
  const next = argv[i + 1];
45
- const isBoolean = key === "help" || key === "pretty" || key === "includeInternal";
45
+ const isBoolean = key === "help" || key === "pretty" || key === "includeInternal" || key === "debugBounds" || key === "debugLabels";
46
46
  if (isBoolean) {
47
47
  flags[key] = true;
48
48
  continue;
@@ -87,6 +87,7 @@ Commands:
87
87
  write-ir Write a starter IR JSON file
88
88
  validate Validate an IR JSON file
89
89
  render Render MP4 from an IR JSON file
90
+ stills Render PNG/JPEG/WebP still frames from an IR JSON file
90
91
 
91
92
  Options:
92
93
  -h, --help Show help
@@ -123,6 +124,10 @@ async function importRegistrationModules(modules) {
123
124
  function stringifyJSON(value, pretty) {
124
125
  return JSON.stringify(value, null, pretty ? 2 : 0) + "\n";
125
126
  }
127
+ function parseImageFormat(raw) {
128
+ if (raw === "png" || raw === "jpeg" || raw === "webp") return raw;
129
+ return null;
130
+ }
126
131
  async function main(argv = process.argv.slice(2)) {
127
132
  const parsed = parseArgs(argv);
128
133
  if (parsed.flags.version) {
@@ -472,15 +477,19 @@ async function main(argv = process.argv.slice(2)) {
472
477
  const crfRaw = getFlagString(parsed.flags, "crf");
473
478
  const concurrencyRaw = getFlagString(parsed.flags, "concurrency");
474
479
  const publicDir = getFlagString(parsed.flags, "publicDir");
480
+ const debugBounds = Boolean(parsed.flags.debugBounds);
481
+ const debugLabels = Boolean(parsed.flags.debugLabels);
475
482
  const crf = crfRaw ? Number(crfRaw) : void 0;
476
483
  const concurrency = concurrencyRaw ? /^[0-9]+$/.test(concurrencyRaw) ? Number(concurrencyRaw) : concurrencyRaw : void 0;
477
484
  const engine = new WavesEngine(globalRegistry, new IRValidator(globalRegistry));
478
485
  try {
486
+ const inputProps = debugBounds || debugLabels ? { __wavesDebugBounds: debugBounds, __wavesDebugLabels: debugLabels } : void 0;
479
487
  const opts = { outputPath, registrationModules };
480
488
  if (publicDir) opts.publicDir = publicDir;
481
489
  if (codec) opts.codec = codec;
482
490
  if (Number.isFinite(crf ?? Number.NaN)) opts.crf = crf;
483
491
  if (concurrency !== void 0) opts.concurrency = concurrency;
492
+ if (inputProps) opts.inputProps = inputProps;
484
493
  await engine.render(json, opts);
485
494
  } catch (err) {
486
495
  const message = err instanceof Error ? err.message : String(err);
@@ -495,6 +504,84 @@ async function main(argv = process.argv.slice(2)) {
495
504
  `);
496
505
  return EXIT_OK;
497
506
  }
507
+ if (parsed.command === "stills") {
508
+ const inputPath = getFlagString(parsed.flags, "in");
509
+ const outDir = getFlagString(parsed.flags, "outDir") ?? getFlagString(parsed.flags, "out");
510
+ if (!inputPath) {
511
+ process.stderr.write("Missing required --in <path>\n");
512
+ return EXIT_USAGE;
513
+ }
514
+ if (!outDir) {
515
+ process.stderr.write("Missing required --outDir <dir>\n");
516
+ return EXIT_USAGE;
517
+ }
518
+ let raw;
519
+ try {
520
+ raw = await fs.readFile(inputPath, "utf-8");
521
+ } catch (err) {
522
+ const message = err instanceof Error ? err.message : String(err);
523
+ process.stderr.write(`Failed to read ${inputPath}: ${message}
524
+ `);
525
+ return EXIT_IO;
526
+ }
527
+ let json;
528
+ try {
529
+ json = JSON.parse(raw);
530
+ } catch (err) {
531
+ const message = err instanceof Error ? err.message : String(err);
532
+ process.stderr.write(`Invalid JSON: ${message}
533
+ `);
534
+ return EXIT_VALIDATE;
535
+ }
536
+ const framesRaw = getFlagString(parsed.flags, "frames") ?? "0";
537
+ const frames = framesRaw.split(/[,\s]+/g).map((v) => v.trim()).filter(Boolean).map((v) => Number(v)).filter((n) => Number.isFinite(n));
538
+ if (frames.length === 0) {
539
+ process.stderr.write('Invalid --frames (expected comma-separated frame numbers, e.g. "0,30,60")\n');
540
+ return EXIT_USAGE;
541
+ }
542
+ const imageFormatRaw = (getFlagString(parsed.flags, "imageFormat") ?? "png").toLowerCase();
543
+ const imageFormat = parseImageFormat(imageFormatRaw);
544
+ if (!imageFormat) {
545
+ process.stderr.write(`Invalid --imageFormat: ${imageFormatRaw} (expected png|jpeg|webp)
546
+ `);
547
+ return EXIT_USAGE;
548
+ }
549
+ const scaleRaw = getFlagString(parsed.flags, "scale");
550
+ const jpegQualityRaw = getFlagString(parsed.flags, "jpegQuality");
551
+ const publicDir = getFlagString(parsed.flags, "publicDir");
552
+ const debugBounds = Boolean(parsed.flags.debugBounds);
553
+ const debugLabels = Boolean(parsed.flags.debugLabels);
554
+ const scale = scaleRaw ? Number(scaleRaw) : void 0;
555
+ const jpegQuality = jpegQualityRaw ? Number(jpegQualityRaw) : void 0;
556
+ const engine = new WavesEngine(globalRegistry, new IRValidator(globalRegistry));
557
+ try {
558
+ const inputProps = debugBounds || debugLabels ? { __wavesDebugBounds: debugBounds, __wavesDebugLabels: debugLabels } : void 0;
559
+ const opts = {
560
+ outputDir: outDir,
561
+ frames,
562
+ imageFormat,
563
+ registrationModules
564
+ };
565
+ if (publicDir) opts.publicDir = publicDir;
566
+ if (Number.isFinite(scale ?? Number.NaN)) opts.scale = scale;
567
+ if (Number.isFinite(jpegQuality ?? Number.NaN)) opts.jpegQuality = jpegQuality;
568
+ if (inputProps) opts.inputProps = inputProps;
569
+ const written = await engine.renderStills(json, opts);
570
+ for (const p of written) {
571
+ process.stderr.write(`Wrote ${p}
572
+ `);
573
+ }
574
+ } catch (err) {
575
+ const message = err instanceof Error ? err.message : String(err);
576
+ const context = err instanceof WavesRenderError ? err.context : void 0;
577
+ const payload = context ? stringifyJSON({ error: message, context }, pretty) : null;
578
+ process.stderr.write(`stills failed: ${message}
579
+ `);
580
+ if (payload) process.stderr.write(payload);
581
+ return EXIT_RENDER;
582
+ }
583
+ return EXIT_OK;
584
+ }
498
585
  process.stderr.write(`Unknown command: ${parsed.command}
499
586
  `);
500
587
  process.stderr.write(`Run: waves --help
package/dist/index.d.mts CHANGED
@@ -46,12 +46,25 @@ interface RenderOptions {
46
46
  publicDir?: string;
47
47
  rootDir?: string;
48
48
  registrationModules?: string[];
49
+ inputProps?: Record<string, unknown>;
50
+ }
51
+ interface RenderStillsOptions {
52
+ outputDir: string;
53
+ frames: number[];
54
+ imageFormat?: 'png' | 'jpeg' | 'webp';
55
+ jpegQuality?: number;
56
+ scale?: number;
57
+ publicDir?: string;
58
+ rootDir?: string;
59
+ registrationModules?: string[];
60
+ inputProps?: Record<string, unknown>;
49
61
  }
50
62
  declare class WavesEngine {
51
63
  private readonly registry;
52
64
  private readonly validator;
53
65
  constructor(registry: ComponentRegistry, validator: IRValidator);
54
66
  render(ir: unknown, options: RenderOptions): Promise<void>;
67
+ renderStills(ir: unknown, options: RenderStillsOptions): Promise<string[]>;
55
68
  }
56
69
 
57
70
  declare class WavesError extends Error {
package/dist/index.d.ts CHANGED
@@ -46,12 +46,25 @@ interface RenderOptions {
46
46
  publicDir?: string;
47
47
  rootDir?: string;
48
48
  registrationModules?: string[];
49
+ inputProps?: Record<string, unknown>;
50
+ }
51
+ interface RenderStillsOptions {
52
+ outputDir: string;
53
+ frames: number[];
54
+ imageFormat?: 'png' | 'jpeg' | 'webp';
55
+ jpegQuality?: number;
56
+ scale?: number;
57
+ publicDir?: string;
58
+ rootDir?: string;
59
+ registrationModules?: string[];
60
+ inputProps?: Record<string, unknown>;
49
61
  }
50
62
  declare class WavesEngine {
51
63
  private readonly registry;
52
64
  private readonly validator;
53
65
  constructor(registry: ComponentRegistry, validator: IRValidator);
54
66
  render(ir: unknown, options: RenderOptions): Promise<void>;
67
+ renderStills(ir: unknown, options: RenderStillsOptions): Promise<string[]>;
55
68
  }
56
69
 
57
70
  declare class WavesError extends Error {