@gehdoc/svg-to-video 0.31.0 → 0.32.1

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,83 @@
1
+ export const FORMAT_CAPABILITIES = {
2
+ mp4: {
3
+ id: 'mp4',
4
+ label: 'MP4',
5
+ extension: '.mp4',
6
+ extensions: ['.mp4'],
7
+ mimeType: 'video/mp4',
8
+ supportsAlpha: false,
9
+ supportsMetadata: true,
10
+ needsColorKeying: false,
11
+ },
12
+ webm: {
13
+ id: 'webm',
14
+ label: 'WebM',
15
+ extension: '.webm',
16
+ extensions: ['.webm'],
17
+ mimeType: 'video/webm',
18
+ supportsAlpha: true,
19
+ supportsMetadata: true,
20
+ needsColorKeying: false,
21
+ },
22
+ gif: {
23
+ id: 'gif',
24
+ label: 'GIF',
25
+ extension: '.gif',
26
+ extensions: ['.gif'],
27
+ mimeType: 'image/gif',
28
+ supportsAlpha: true,
29
+ supportsMetadata: true,
30
+ needsColorKeying: true,
31
+ },
32
+ apng: {
33
+ id: 'apng',
34
+ label: 'aPNG',
35
+ extension: '.png',
36
+ extensions: ['.apng', '.png'],
37
+ mimeType: 'image/png',
38
+ supportsAlpha: true,
39
+ supportsMetadata: true,
40
+ needsColorKeying: false,
41
+ },
42
+ mkv: {
43
+ id: 'mkv',
44
+ label: 'MKV',
45
+ extension: '.mkv',
46
+ extensions: ['.mkv'],
47
+ mimeType: 'video/x-matroska',
48
+ supportsAlpha: true,
49
+ supportsMetadata: true,
50
+ needsColorKeying: false,
51
+ },
52
+ mov: {
53
+ id: 'mov',
54
+ label: 'MOV',
55
+ extension: '.mov',
56
+ extensions: ['.mov'],
57
+ mimeType: 'video/quicktime',
58
+ supportsAlpha: true,
59
+ supportsMetadata: true,
60
+ needsColorKeying: false,
61
+ },
62
+ };
63
+ export function getFormatCapability(formatOrExtension) {
64
+ if (!formatOrExtension)
65
+ return undefined;
66
+ const rawKey = formatOrExtension.toLowerCase().trim();
67
+ if (FORMAT_CAPABILITIES[rawKey]) {
68
+ return FORMAT_CAPABILITIES[rawKey];
69
+ }
70
+ const cleanKey = rawKey.startsWith('.') ? rawKey.slice(1) : rawKey;
71
+ const extKey = rawKey.startsWith('.') ? rawKey : `.${rawKey}`;
72
+ for (const cap of Object.values(FORMAT_CAPABILITIES)) {
73
+ if (cap.id === cleanKey ||
74
+ cap.extensions.includes(extKey) ||
75
+ cap.extensions.includes(rawKey)) {
76
+ return cap;
77
+ }
78
+ }
79
+ return undefined;
80
+ }
81
+ export function getAllFormatCapabilities() {
82
+ return Object.values(FORMAT_CAPABILITIES);
83
+ }
@@ -0,0 +1,19 @@
1
+ import { getFormatCapability } from '#shared/formatCapabilities.js';
2
+ export class BaseCLIFormatGenerator {
3
+ id;
4
+ extensions;
5
+ mimeType;
6
+ supportsAlpha;
7
+ needsColorKeying;
8
+ constructor(formatId) {
9
+ const cap = getFormatCapability(formatId);
10
+ if (!cap) {
11
+ throw new Error(`Unknown format capability for ID: ${formatId}`);
12
+ }
13
+ this.id = cap.id;
14
+ this.extensions = [...cap.extensions];
15
+ this.mimeType = cap.mimeType;
16
+ this.supportsAlpha = cap.supportsAlpha;
17
+ this.needsColorKeying = cap.needsColorKeying;
18
+ }
19
+ }
@@ -1,13 +1,12 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
+ import { BaseCLIFormatGenerator } from '../BaseCLIFormatGenerator.js';
3
4
  import { mergeMetadataComments } from '#shared/metadata.js';
4
5
  import { injectApngMetadata } from '#shared/apngMetadataInjector.js';
5
- export class ApngFormatGenerator {
6
- id = 'apng';
7
- extensions = ['.apng', '.png'];
8
- mimeType = 'image/png';
9
- supportsAlpha = true;
10
- needsColorKeying = false;
6
+ export class ApngFormatGenerator extends BaseCLIFormatGenerator {
7
+ constructor() {
8
+ super('apng');
9
+ }
11
10
  buildFfmpegArgs(options) {
12
11
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
13
12
  const args = [
@@ -1,13 +1,12 @@
1
1
  import path from 'path';
2
2
  import fs from 'fs';
3
+ import { BaseCLIFormatGenerator } from '../BaseCLIFormatGenerator.js';
3
4
  import { mergeMetadataComments } from '#shared/metadata.js';
4
5
  import { injectGifMetadata } from '#shared/gifMetadataInjector.js';
5
- export class GifFormatGenerator {
6
- id = 'gif';
7
- extensions = ['.gif'];
8
- mimeType = 'image/gif';
9
- supportsAlpha = true;
10
- needsColorKeying = true;
6
+ export class GifFormatGenerator extends BaseCLIFormatGenerator {
7
+ constructor() {
8
+ super('gif');
9
+ }
11
10
  buildFfmpegArgs(options) {
12
11
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
13
12
  const args = [
@@ -1,11 +1,10 @@
1
1
  import path from 'path';
2
+ import { BaseCLIFormatGenerator } from '../BaseCLIFormatGenerator.js';
2
3
  import { mergeMetadataComments } from '#shared/metadata.js';
3
- export class MkvFormatGenerator {
4
- id = 'mkv';
5
- extensions = ['.mkv'];
6
- mimeType = 'video/x-matroska';
7
- supportsAlpha = true;
8
- needsColorKeying = false;
4
+ export class MkvFormatGenerator extends BaseCLIFormatGenerator {
5
+ constructor() {
6
+ super('mkv');
7
+ }
9
8
  buildFfmpegArgs(options) {
10
9
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
11
10
  const args = [
@@ -1,11 +1,10 @@
1
1
  import path from 'path';
2
+ import { BaseCLIFormatGenerator } from '../BaseCLIFormatGenerator.js';
2
3
  import { mergeMetadataComments } from '#shared/metadata.js';
3
- export class MovFormatGenerator {
4
- id = 'mov';
5
- extensions = ['.mov'];
6
- mimeType = 'video/quicktime';
7
- supportsAlpha = true;
8
- needsColorKeying = false;
4
+ export class MovFormatGenerator extends BaseCLIFormatGenerator {
5
+ constructor() {
6
+ super('mov');
7
+ }
9
8
  buildFfmpegArgs(options) {
10
9
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
11
10
  const args = [
@@ -1,11 +1,10 @@
1
1
  import path from 'path';
2
+ import { BaseCLIFormatGenerator } from '../BaseCLIFormatGenerator.js';
2
3
  import { mergeMetadataComments } from '#shared/metadata.js';
3
- export class Mp4FormatGenerator {
4
- id = 'mp4';
5
- extensions = ['.mp4'];
6
- mimeType = 'video/mp4';
7
- supportsAlpha = false;
8
- needsColorKeying = false;
4
+ export class Mp4FormatGenerator extends BaseCLIFormatGenerator {
5
+ constructor() {
6
+ super('mp4');
7
+ }
9
8
  buildFfmpegArgs(options) {
10
9
  const { fps, hold, outDir, metadata, inputPattern, pkgVersion, outputFileName, } = options;
11
10
  const args = [
@@ -1,11 +1,10 @@
1
1
  import path from 'path';
2
+ import { BaseCLIFormatGenerator } from '../BaseCLIFormatGenerator.js';
2
3
  import { mergeMetadataComments } from '#shared/metadata.js';
3
- export class WebmFormatGenerator {
4
- id = 'webm';
5
- extensions = ['.webm'];
6
- mimeType = 'video/webm';
7
- supportsAlpha = true;
8
- needsColorKeying = false;
4
+ export class WebmFormatGenerator extends BaseCLIFormatGenerator {
5
+ constructor() {
6
+ super('webm');
7
+ }
9
8
  buildFfmpegArgs(options) {
10
9
  const { fps, hold, outDir, transparent, metadata, inputPattern, pkgVersion, outputFileName, } = options;
11
10
  const args = [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gehdoc/svg-to-video",
3
3
  "mcpName": "io.github.GehDoc/svg-to-video",
4
- "version": "0.31.0",
4
+ "version": "0.32.1",
5
5
  "type": "module",
6
6
  "description": "Professional animated SVG to Video (MP4/WebM/MKV/MOV) and Animated Image (aPNG/GIF) converter featuring frame-accurate rendering, CLI automation, Model Context Protocol (MCP) server integration, and a serverless Web Studio.",
7
7
  "imports": {