@effing/ffs 0.1.1 → 0.2.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.
@@ -1,5 +1,5 @@
1
- import { C as CacheStorage } from '../cache-BUVFfGZF.js';
2
- import { EffieData, EffieSources } from '@effing/effie';
1
+ import { C as CacheStorage, H as HttpProxy } from '../proxy-BI8OMQl0.js';
2
+ import { EffieSourceWithType, EffieData, EffieSources } from '@effing/effie';
3
3
  import express from 'express';
4
4
  import 'stream';
5
5
 
@@ -8,7 +8,7 @@ type UploadOptions = {
8
8
  coverUrl?: string;
9
9
  };
10
10
  type WarmupJob = {
11
- sources: string[];
11
+ sources: EffieSourceWithType[];
12
12
  };
13
13
  type RenderJob = {
14
14
  effie: EffieData<EffieSources>;
@@ -18,6 +18,7 @@ type RenderJob = {
18
18
  };
19
19
  type ServerContext = {
20
20
  cacheStorage: CacheStorage;
21
+ httpProxy: HttpProxy;
21
22
  baseUrl: string;
22
23
  skipValidation: boolean;
23
24
  cacheConcurrency: number;
@@ -26,7 +27,7 @@ type SSEEventSender = (event: string, data: object) => void;
26
27
  /**
27
28
  * Create the server context with configuration from environment variables
28
29
  */
29
- declare function createServerContext(): ServerContext;
30
+ declare function createServerContext(): Promise<ServerContext>;
30
31
 
31
32
  /**
32
33
  * POST /warmup - Create a warmup job
@@ -5,8 +5,8 @@ import {
5
5
  purgeCache,
6
6
  streamRenderJob,
7
7
  streamWarmupJob
8
- } from "../chunk-LK5K4SQV.js";
9
- import "../chunk-RNE6TKMF.js";
8
+ } from "../chunk-6YHSYHDY.js";
9
+ import "../chunk-A7BAW24L.js";
10
10
  export {
11
11
  createRenderJob,
12
12
  createServerContext,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Readable } from 'stream';
2
- import { EffieWebUrl, EffieData, EffieSources, EffieMotion, EffieEffect, EffieTransition } from '@effing/effie';
3
- import { C as CacheStorage } from './cache-BUVFfGZF.js';
2
+ import { EffieWebUrl, EffieData, EffieSources } from '@effing/effie';
3
+ import { C as CacheStorage, H as HttpProxy } from './proxy-BI8OMQl0.js';
4
4
 
5
5
  type EffieRendererOptions = {
6
6
  /**
@@ -15,12 +15,20 @@ type EffieRendererOptions = {
15
15
  * If not provided, a shared lazy-initialized cache will be used.
16
16
  */
17
17
  cacheStorage?: CacheStorage;
18
+ /**
19
+ * HTTP proxy for video/audio URLs.
20
+ * When provided, HTTP(S) URLs for video/audio inputs will be routed
21
+ * through this proxy, allowing Node.js to handle DNS resolution
22
+ * instead of FFmpeg (useful for Alpine Linux with musl libc).
23
+ */
24
+ httpProxy?: HttpProxy;
18
25
  };
19
26
  declare class EffieRenderer<U extends string = EffieWebUrl> {
20
27
  private effieData;
21
28
  private ffmpegRunner?;
22
29
  private allowLocalFiles;
23
30
  private cacheStorage?;
31
+ private httpProxy?;
24
32
  constructor(effieData: EffieData<EffieSources<U>, U>, options?: EffieRendererOptions);
25
33
  private fetchSource;
26
34
  private buildAudioFilter;
@@ -60,6 +68,12 @@ declare class EffieRenderer<U extends string = EffieWebUrl> {
60
68
  private applyGeneralAudio;
61
69
  private buildFFmpegCommand;
62
70
  private createImageTransformer;
71
+ /**
72
+ * Resolves a source reference to its actual URL.
73
+ * If the source is a #reference, returns the resolved URL.
74
+ * Otherwise, returns the source as-is.
75
+ */
76
+ private resolveReference;
63
77
  /**
64
78
  * Renders the effie data to a video stream.
65
79
  * @param scaleFactor - Scale factor for output dimensions
@@ -90,17 +104,11 @@ declare class FFmpegRunner {
90
104
  private command;
91
105
  private ffmpegProc?;
92
106
  constructor(command: FFmpegCommand);
93
- run(sourceResolver: (input: {
107
+ run(sourceFetcher: (input: {
94
108
  type: FFmpegInput["type"];
95
109
  src: string;
96
- }) => Promise<Readable>, imageTransformer?: (imageStream: Readable) => Promise<Readable>): Promise<Readable>;
110
+ }) => Promise<Readable>, imageTransformer?: (imageStream: Readable) => Promise<Readable>, referenceResolver?: (src: string) => string, urlTransformer?: (url: string) => string): Promise<Readable>;
97
111
  close(): void;
98
112
  }
99
113
 
100
- declare function processMotion(delay: number, motion?: EffieMotion): string;
101
-
102
- declare function processEffects(effects: EffieEffect[] | undefined, frameRate: number, frameWidth: number, frameHeight: number): string;
103
-
104
- declare function processTransition(transition: EffieTransition): string;
105
-
106
- export { EffieRenderer, type EffieRendererOptions, FFmpegCommand, type FFmpegInput, FFmpegRunner, processEffects, processMotion, processTransition };
114
+ export { EffieRenderer, type EffieRendererOptions, FFmpegCommand, type FFmpegInput, FFmpegRunner };
package/dist/index.js CHANGED
@@ -1,17 +1,11 @@
1
1
  import {
2
2
  EffieRenderer,
3
3
  FFmpegCommand,
4
- FFmpegRunner,
5
- processEffects,
6
- processMotion,
7
- processTransition
8
- } from "./chunk-RNE6TKMF.js";
4
+ FFmpegRunner
5
+ } from "./chunk-A7BAW24L.js";
9
6
  export {
10
7
  EffieRenderer,
11
8
  FFmpegCommand,
12
- FFmpegRunner,
13
- processEffects,
14
- processMotion,
15
- processTransition
9
+ FFmpegRunner
16
10
  };
17
11
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,68 @@
1
+ import { Readable } from 'stream';
2
+
3
+ /**
4
+ * Cache storage interface
5
+ */
6
+ interface CacheStorage {
7
+ /** Store a stream with the given key */
8
+ put(key: string, stream: Readable): Promise<void>;
9
+ /** Get a stream for the given key, or null if not found */
10
+ getStream(key: string): Promise<Readable | null>;
11
+ /** Check if a key exists */
12
+ exists(key: string): Promise<boolean>;
13
+ /** Check if multiple keys exist (batch operation) */
14
+ existsMany(keys: string[]): Promise<Map<string, boolean>>;
15
+ /** Delete a key */
16
+ delete(key: string): Promise<void>;
17
+ /** Store JSON data */
18
+ putJson(key: string, data: object): Promise<void>;
19
+ /** Get JSON data, or null if not found */
20
+ getJson<T>(key: string): Promise<T | null>;
21
+ /** Close and cleanup resources */
22
+ close(): void;
23
+ }
24
+
25
+ /**
26
+ * HTTP proxy for FFmpeg URL handling.
27
+ *
28
+ * Static FFmpeg binaries can have DNS resolution issues on Alpine Linux (musl libc).
29
+ * This proxy lets Node.js handle DNS lookups instead of FFmpeg by proxying HTTP
30
+ * requests through localhost.
31
+ *
32
+ * URL scheme (M3U8-compatible):
33
+ * - Original: https://cdn.example.com/path/to/stream.m3u8
34
+ * - Proxy: http://127.0.0.1:{port}/https://cdn.example.com/path/to/stream.m3u8
35
+ * - Relative: segment-0.ts → http://127.0.0.1:{port}/https://cdn.example.com/path/to/segment-0.ts
36
+ */
37
+ declare class HttpProxy {
38
+ private server;
39
+ private _port;
40
+ private startPromise;
41
+ get port(): number | null;
42
+ /**
43
+ * Transform a URL to go through the proxy.
44
+ * @throws Error if proxy not started
45
+ */
46
+ transformUrl(url: string): string;
47
+ /**
48
+ * Start the proxy server. Safe to call multiple times.
49
+ */
50
+ start(): Promise<void>;
51
+ private doStart;
52
+ /**
53
+ * Parse the proxy path to extract the original URL.
54
+ * Path format: /{originalUrl}
55
+ */
56
+ private parseProxyPath;
57
+ /**
58
+ * Filter headers to forward to the upstream server.
59
+ * Removes hop-by-hop headers that shouldn't be forwarded.
60
+ */
61
+ private filterHeaders;
62
+ /**
63
+ * Close the proxy server and reset state.
64
+ */
65
+ close(): void;
66
+ }
67
+
68
+ export { type CacheStorage as C, HttpProxy as H };