@editframe/vite-plugin 0.47.1 → 0.47.2
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/LICENSE-FULL.md +148 -0
- package/LICENSE.md +58 -0
- package/dist/jitTranscodeMiddleware.js +3 -2
- package/dist/jitTranscodeMiddleware.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +3 -3
package/LICENSE-FULL.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Editframe SDK License Agreement
|
|
2
|
+
|
|
3
|
+
**Effective Date:** January 12, 2026 **Version:** 2.0
|
|
4
|
+
|
|
5
|
+
This License Agreement ("License") governs your use of the Editframe SDK. By downloading, accessing, or using the SDK, you agree to these terms.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Definitions
|
|
10
|
+
|
|
11
|
+
**"Total Employees"** — All full-time employees, part-time employees, and contractor equivalents across your Organization and all affiliated entities under common control. Contractors are counted proportionally by time worked.
|
|
12
|
+
|
|
13
|
+
**"Organization"** — You, your company, and all affiliates, subsidiaries, or related entities under common control.
|
|
14
|
+
|
|
15
|
+
**"Client-Side SDK"** — The source-available browser-based video rendering components, including the custom video tag for local file playback.
|
|
16
|
+
|
|
17
|
+
**"Server-Side Rendering"** — Hosted cloud service for parallel rendering at scale, supporting simultaneous rendering of large volumes of videos including longer and more complex ones.
|
|
18
|
+
|
|
19
|
+
**"Premium Player"** — Cloud-based CDN streaming service with API-authenticated streaming capabilities, optimized for editing workflows.
|
|
20
|
+
|
|
21
|
+
**"Cloud Services"** — Server-Side Rendering and Premium Player collectively.
|
|
22
|
+
|
|
23
|
+
**"Commercial Use"** — Any use in connection with business operations, revenue-generating activities, or professional services, including internal tools, production environments, and client deliverables.
|
|
24
|
+
|
|
25
|
+
**"Evaluation Use"** — Good-faith testing and proof-of-concept development, limited to 30 days. Excludes production deployment and ongoing business use.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## 2. License Grant
|
|
30
|
+
|
|
31
|
+
### 2.1 Free Tier (≤3 Employees)
|
|
32
|
+
|
|
33
|
+
A limited, non-exclusive, non-transferable, revocable license to use the Client-Side SDK.
|
|
34
|
+
|
|
35
|
+
**Eligible:**
|
|
36
|
+
|
|
37
|
+
- Organizations with ≤3 total employees (Commercial Use permitted)
|
|
38
|
+
- Evaluation Use (any size, 30 days, non-production)
|
|
39
|
+
- Registered non-profits (any size)
|
|
40
|
+
- Accredited educational institutions
|
|
41
|
+
- Personal non-commercial projects
|
|
42
|
+
|
|
43
|
+
**Permitted:**
|
|
44
|
+
|
|
45
|
+
- Install and use the Client-Side SDK
|
|
46
|
+
- Use the custom video tag for local file playback (no API key required)
|
|
47
|
+
- Create and distribute video outputs for personal or Commercial Use
|
|
48
|
+
|
|
49
|
+
**Not included:** Cloud Services. Cloud Services require a Cloud Tier subscription regardless of company size.
|
|
50
|
+
|
|
51
|
+
### 2.2 Team Tier (4–10 Employees)
|
|
52
|
+
|
|
53
|
+
Includes all Free Tier rights. Full Client-Side SDK use for any business purpose including production. Does not include Cloud Services. See [editframe.com/pricing](https://editframe.com/pricing) for pricing.
|
|
54
|
+
|
|
55
|
+
### 2.3 Cloud Tier (11–20 Employees, or Any Size Requiring Cloud)
|
|
56
|
+
|
|
57
|
+
Required for organizations with 11–20 employees, or any organization using Cloud Services.
|
|
58
|
+
|
|
59
|
+
Includes all Team Tier rights, plus Server-Side Rendering and Premium Player via API. Usage-based billing applies in addition to base subscription. See [editframe.com/pricing](https://editframe.com/pricing) for pricing.
|
|
60
|
+
|
|
61
|
+
### 2.4 Enterprise (21+ Employees)
|
|
62
|
+
|
|
63
|
+
Contact [hello@editframe.com](mailto:hello@editframe.com). Includes all Cloud Tier features plus priority support and custom SLAs.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## 3. Restrictions
|
|
68
|
+
|
|
69
|
+
### 3.1 Prohibited
|
|
70
|
+
|
|
71
|
+
- Do not offer the Client-Side SDK or CLI itself as a managed rendering API or infrastructure product to third parties
|
|
72
|
+
- Do not fork, redistribute, or sublicense the Client-Side SDK or CLI under different terms
|
|
73
|
+
- Do not use the SDK above your tier threshold without upgrading
|
|
74
|
+
- Do not share credentials or API keys across separate organizations
|
|
75
|
+
- Do not implement workarounds to avoid usage-based billing
|
|
76
|
+
- Do not reverse engineer, decompile, or extract proprietary algorithms from Server-Side Rendering or Premium Player
|
|
77
|
+
- Do not access Cloud Service APIs other than through official client libraries
|
|
78
|
+
- Do not disable, circumvent, or tamper with telemetry
|
|
79
|
+
- Do not remove or alter copyright notices or attribution
|
|
80
|
+
- Do not use the SDK for unlawful purposes or in violation of export control regulations
|
|
81
|
+
|
|
82
|
+
### 3.2 Permitted
|
|
83
|
+
|
|
84
|
+
- Build any product that creates, processes, or delivers video — editors, workflows, motion design tools, content automation, and more
|
|
85
|
+
- Integrate the Client-Side SDK into platforms, coding environments, vibe coding tools, and AI agents (end users are individually responsible for compliance)
|
|
86
|
+
- Use the Client-Side SDK in CI/CD pipelines and development environments, provided you are not using it to render production video at scale
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 4. Intellectual Property
|
|
91
|
+
|
|
92
|
+
Editframe, Inc. retains all rights to the SDK. This License does not transfer ownership. You retain all rights to video outputs you create ("Your Content"). Feedback may be used by us without obligation.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 5. Telemetry
|
|
97
|
+
|
|
98
|
+
The SDK includes always-on telemetry collecting render counts, durations, IP addresses, domains, and feature usage. Telemetry cannot be disabled. Required for usage-based billing and license compliance. No video content is collected. See [editframe.com/privacy](https://editframe.com/privacy).
|
|
99
|
+
|
|
100
|
+
High Client-Side rendering volume does not trigger payment requirements — eligibility is determined by company size only.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## 6. Support
|
|
105
|
+
|
|
106
|
+
- **Free:** Community support
|
|
107
|
+
- **Team/Cloud:** Email and Slack, 48-hour response
|
|
108
|
+
- **Enterprise:** Dedicated support, custom SLAs
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 7. Warranties
|
|
113
|
+
|
|
114
|
+
THE SDK IS PROVIDED "AS IS" WITHOUT WARRANTIES OF ANY KIND. WE DO NOT WARRANT THAT THE SDK WILL BE ERROR-FREE, SECURE, OR UNINTERRUPTED. YOU ASSUME ALL RISKS.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 8. Limitation of Liability
|
|
119
|
+
|
|
120
|
+
WE SHALL NOT BE LIABLE FOR INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES. TOTAL LIABILITY SHALL NOT EXCEED AMOUNTS PAID IN THE 12 MONTHS PRECEDING THE CLAIM, OR $100 USD, WHICHEVER IS GREATER.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 9. Termination
|
|
125
|
+
|
|
126
|
+
This License is effective upon first use. We may terminate immediately for breach, failure to maintain required subscription tier, or fraudulent conduct (10 days' notice where feasible). Upon termination, all rights cease and you must delete all SDK copies.
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## 10. Compliance
|
|
131
|
+
|
|
132
|
+
Self-report your employee count accurately. Violations may result in termination, back-payment of owed fees, liquidated damages (3× unpaid fees), and legal action. Voluntary disclosure may result in waived penalties.
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 11. General
|
|
137
|
+
|
|
138
|
+
- **Governing Law:** Delaware
|
|
139
|
+
- **Jurisdiction:** New York County, NY
|
|
140
|
+
- **Export Controls:** You must comply with U.S. Export Administration Regulations
|
|
141
|
+
- **Assignment:** You may not assign this License without written consent
|
|
142
|
+
- **Entire Agreement:** This License, Terms of Service, and Privacy Policy constitute the full agreement
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
[hello@editframe.com](mailto:hello@editframe.com) · editframe.com
|
|
147
|
+
|
|
148
|
+
**By using the SDK, you agree to these terms.**
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Editframe SDK License
|
|
2
|
+
|
|
3
|
+
The Editframe SDK is source-available and free for individuals and small teams, including for commercial use. We've kept the bar low intentionally — if you're building something, you should be able to just use it.
|
|
4
|
+
|
|
5
|
+
- [Free Tier](#free-tier)
|
|
6
|
+
- [Paid Tiers](#paid-tiers)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Free Tier
|
|
11
|
+
|
|
12
|
+
Copyright © 2026 [Editframe](https://editframe.com)
|
|
13
|
+
|
|
14
|
+
### Who Qualifies
|
|
15
|
+
|
|
16
|
+
- Individuals and freelancers
|
|
17
|
+
- Organizations with 3 or fewer total employees
|
|
18
|
+
- Non-profits and not-for-profit organizations (any size)
|
|
19
|
+
- Accredited educational institutions
|
|
20
|
+
- Organizations evaluating Editframe in good faith, prior to commercial deployment (30 days)
|
|
21
|
+
|
|
22
|
+
### What You Can Build
|
|
23
|
+
|
|
24
|
+
Use and modify the SDK to build any product that creates, processes, or delivers video — editors, workflows, motion design tools, content automation, and more. Platforms, coding environments, vibe coding tools, and AI agents may freely integrate the SDK. End users are each responsible for their own license compliance.
|
|
25
|
+
|
|
26
|
+
### What Is Not Permitted
|
|
27
|
+
|
|
28
|
+
You may not offer the Client-Side SDK or CLI itself as a managed rendering API or infrastructure product to third parties. You may not sell, sublicense, or redistribute the SDK or modifications to it as a standalone product.
|
|
29
|
+
|
|
30
|
+
### Warranty
|
|
31
|
+
|
|
32
|
+
The SDK is provided as-is without warranty of any kind. See the [Full License Agreement](./LICENSE-FULL.md) for complete terms.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Paid Tiers
|
|
37
|
+
|
|
38
|
+
Organizations outside the Free Tier must subscribe to a paid plan.
|
|
39
|
+
|
|
40
|
+
| Tier | Employees |
|
|
41
|
+
| :---- | :---- |
|
|
42
|
+
| Team | 4–10 |
|
|
43
|
+
| Cloud | 11–20, or any size needing Cloud Rendering & Player |
|
|
44
|
+
| Enterprise | 21+ |
|
|
45
|
+
|
|
46
|
+
All paid tiers include full SDK rights.
|
|
47
|
+
|
|
48
|
+
Cloud Rendering & Player — parallel rendering and CDN streaming optimized for editing workflows — requires a Cloud Tier subscription regardless of company size.
|
|
49
|
+
|
|
50
|
+
[View pricing →](https://editframe.com/pricing) · Enterprise: [hello@editframe.com](mailto:hello@editframe.com)
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
Unsure which tier applies? See the [FAQ](https://editframe.com/faq) or reach out at [hello@editframe.com](mailto:hello@editframe.com).
|
|
55
|
+
|
|
56
|
+
[Full License Agreement](./LICENSE-FULL.md) · [Terms of Service](https://editframe.com/terms)
|
|
57
|
+
|
|
58
|
+
*© 2026 Editframe, Inc.*
|
|
@@ -302,9 +302,10 @@ function createJitTranscodeMiddleware(options, assetFunctions) {
|
|
|
302
302
|
res.end(JSON.stringify({ error: `Track ${trackId} not found (valid tracks: ${validTracks})` }));
|
|
303
303
|
return;
|
|
304
304
|
}
|
|
305
|
+
const resolvedInitContentType = trackTaskResult.cachePath.endsWith(".webm") ? "video/webm" : contentType;
|
|
305
306
|
const { offset, size } = track.initSegment;
|
|
306
307
|
log(`Init segment: offset=${offset}, size=${size}`);
|
|
307
|
-
sendByteRange(res, trackTaskResult.cachePath, offset, size,
|
|
308
|
+
sendByteRange(res, trackTaskResult.cachePath, offset, size, resolvedInitContentType);
|
|
308
309
|
} catch (error) {
|
|
309
310
|
log(`Error serving init segment: ${error}`);
|
|
310
311
|
if (error.code === "ENOENT") {
|
|
@@ -351,7 +352,7 @@ function createJitTranscodeMiddleware(options, assetFunctions) {
|
|
|
351
352
|
}));
|
|
352
353
|
return;
|
|
353
354
|
}
|
|
354
|
-
const contentType = extension === "m4s" ? "video/iso.segment" : "video/mp4";
|
|
355
|
+
const contentType = trackTaskResult.cachePath.endsWith(".webm") ? "video/webm" : extension === "m4s" ? "video/iso.segment" : "video/mp4";
|
|
355
356
|
if (includeInit) {
|
|
356
357
|
const initSegment = track.initSegment;
|
|
357
358
|
log(`Media segment ${segmentId}.mp4: init(offset=${initSegment.offset}, size=${initSegment.size}) + segment(offset=${segment.offset}, size=${segment.size})`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jitTranscodeMiddleware.js","names":["fragmentIndex: Record<number, TrackFragmentIndex>"],"sources":["../src/jitTranscodeMiddleware.ts"],"sourcesContent":["import { createReadStream, statSync } from \"node:fs\";\nimport type { ServerResponse } from \"node:http\";\nimport path from \"node:path\";\n\nimport type { IncomingMessage, NextFunction } from \"connect\";\nimport debug from \"debug\";\nimport mime from \"mime\";\nimport type { TrackFragmentIndex } from \"@editframe/assets\";\n\nimport { forbidRelativePaths } from \"./forbidRelativePaths.js\";\n\nexport type { TrackFragmentIndex };\n\n/**\n * Asset functions required by the JIT middleware.\n * These are injected to support both package imports and direct imports.\n */\nexport interface AssetFunctions {\n generateTrack: (\n cacheRoot: string,\n absolutePath: string,\n trackUrl: string,\n ) => Promise<{ cachePath: string }>;\n generateScrubTrack: (cacheRoot: string, absolutePath: string) => Promise<{ cachePath: string }>;\n generateTrackFragmentIndex: (\n cacheRoot: string,\n absolutePath: string,\n ) => Promise<{ cachePath: string }>;\n}\n\nexport interface JitMiddlewareOptions {\n root: string;\n cacheRoot: string;\n /**\n * When true, remote URLs (http/https) are handled locally via ffprobe/ffmpeg\n * rather than passed to a downstream proxy (e.g. recordReplayProxyPlugin).\n * Set to true in dev-projects; leave false (default) in test environments\n * that use recordReplayProxyPlugin to proxy remote URLs to the cloud API.\n */\n handleRemoteUrls?: boolean;\n}\n\n/**\n * Stream a specific byte range from a file.\n * This is used for JIT segment serving where the server extracts the correct bytes.\n */\nexport function sendByteRange(\n res: ServerResponse,\n filePath: string,\n offset: number,\n size: number,\n contentType?: string,\n) {\n const log = debug(\"ef:sendByteRange\");\n const stats = statSync(filePath);\n const end = offset + size - 1;\n\n if (end >= stats.size) {\n log(`Requested range ${offset}-${end} exceeds file size ${stats.size}`);\n res.writeHead(416, { \"Content-Range\": `bytes */${stats.size}` });\n res.end();\n return;\n }\n\n log(`Streaming bytes ${offset}-${end} (${size} bytes) from ${filePath}`);\n\n res.writeHead(200, {\n \"Content-Type\": contentType || mime.getType(filePath) || \"video/mp4\",\n \"Content-Length\": size,\n \"Cache-Control\": \"public, max-age=3600\",\n });\n\n const readStream = createReadStream(filePath, { start: offset, end });\n readStream.pipe(res);\n}\n\n/**\n * Stream multiple byte ranges from a file concatenated together.\n * Used for creating playable .mp4 files by combining init segment + media segment.\n */\nexport function sendMultipleByteRanges(\n res: ServerResponse,\n filePath: string,\n ranges: Array<{ offset: number; size: number }>,\n contentType?: string,\n) {\n const log = debug(\"ef:sendMultipleByteRanges\");\n const stats = statSync(filePath);\n\n // Validate all ranges\n for (const range of ranges) {\n const end = range.offset + range.size - 1;\n if (end >= stats.size) {\n log(`Requested range ${range.offset}-${end} exceeds file size ${stats.size}`);\n res.writeHead(416, { \"Content-Range\": `bytes */${stats.size}` });\n res.end();\n return;\n }\n }\n\n const totalSize = ranges.reduce((sum, r) => sum + r.size, 0);\n log(`Streaming ${ranges.length} ranges (${totalSize} total bytes) from ${filePath}`);\n\n res.writeHead(200, {\n \"Content-Type\": contentType || \"video/mp4\",\n \"Content-Length\": totalSize,\n \"Cache-Control\": \"public, max-age=3600\",\n });\n\n // Stream ranges sequentially\n let rangeIndex = 0;\n\n const streamNextRange = () => {\n if (rangeIndex >= ranges.length) {\n res.end();\n return;\n }\n\n const range = ranges[rangeIndex]!;\n const end = range.offset + range.size - 1;\n const readStream = createReadStream(filePath, { start: range.offset, end });\n\n readStream.on(\"end\", () => {\n rangeIndex++;\n streamNextRange();\n });\n\n readStream.on(\"error\", (err) => {\n log(`Error streaming range ${rangeIndex}: ${err}`);\n res.destroy();\n });\n\n readStream.pipe(res, { end: false });\n };\n\n streamNextRange();\n}\n\n/**\n * Check if a hostname refers to the local vite server.\n * Handles various local hostname patterns including worktree domains.\n */\nexport function isLocalHost(hostname: string): boolean {\n const localPatterns = [\n \"localhost\",\n \"127.0.0.1\",\n \"0.0.0.0\",\n \".localhost\", // Matches *.localhost (worktree domains like main.localhost)\n ];\n\n const lowerHost = hostname.toLowerCase();\n return localPatterns.some((pattern) =>\n pattern.startsWith(\".\")\n ? lowerHost.endsWith(pattern) || lowerHost === pattern.slice(1)\n : lowerHost === pattern || lowerHost.startsWith(pattern + \":\"),\n );\n}\n\n/**\n * Resolve a URL to either a remote URL (for ffprobe) or a local file path.\n *\n * - Remote URLs (different host): passed directly to ffprobe (it supports http/https)\n * - Local URLs (localhost, *.localhost): resolved to local file path\n *\n * @param urlParam - The URL from the query parameter\n * @param root - The vite plugin root directory\n * @returns The path/URL to pass to ffprobe\n */\nexport function resolveMediaPath(urlParam: string, root: string): string {\n try {\n const url = new URL(urlParam);\n const hostname = url.hostname;\n\n // If NOT a local URL, pass directly to ffprobe - it supports http/https URLs\n if (!isLocalHost(hostname)) {\n return urlParam;\n }\n\n // Local URL - resolve to file path\n let filePath = decodeURIComponent(url.pathname);\n\n // Remove leading slash for path.join\n if (filePath.startsWith(\"/\")) {\n filePath = filePath.slice(1);\n }\n\n // The root is already dev-projects/src, so if the URL path starts with \"src/\",\n // we should remove it to avoid duplication (src/src/assets -> src/assets)\n if (filePath.startsWith(\"src/\")) {\n filePath = filePath.slice(4); // Remove \"src/\"\n }\n\n return path.join(root, filePath);\n } catch {\n // If not a valid URL, treat as relative path\n let filePath = urlParam;\n if (filePath.startsWith(\"src/\")) {\n filePath = filePath.slice(4);\n }\n return path.join(root, filePath);\n }\n}\n\n/**\n * Convert fragment index segments to millisecond durations array.\n */\nexport function getSegmentDurationsMs(track: TrackFragmentIndex): number[] {\n return track.segments.map((segment) => (segment.duration / track.timescale) * 1000);\n}\n\n/**\n * Generate a JIT manifest for a local file.\n * Uses actual fragment index data for accurate segment information.\n */\nexport async function generateLocalJitManifest(\n absolutePath: string,\n sourceUrl: string,\n baseUrl: string,\n cacheRoot: string,\n assetFunctions: AssetFunctions,\n) {\n const log = debug(\"ef:generateLocalJitManifest\");\n\n // Generate the fragment index (this also ensures tracks are generated)\n log(`Generating fragment index for ${absolutePath}`);\n const fragmentIndexResult = await assetFunctions.generateTrackFragmentIndex(\n cacheRoot,\n absolutePath,\n );\n const fragmentIndex: Record<number, TrackFragmentIndex> = JSON.parse(\n await import(\"node:fs/promises\").then((fs) =>\n fs.readFile(fragmentIndexResult.cachePath, \"utf-8\"),\n ),\n );\n\n // Find tracks by type rather than by hardcoded index (audio-only files have audio at index 1)\n const videoTrack = Object.values(fragmentIndex).find((t) => t.type === \"video\");\n const audioTrack = Object.values(fragmentIndex).find((t) => t.type === \"audio\");\n const scrubTrack = fragmentIndex[-1];\n\n const hasVideo = videoTrack?.type === \"video\";\n const hasAudio = audioTrack?.type === \"audio\";\n\n // Get duration from the longest track\n let durationMs = 0;\n if (hasVideo && videoTrack) {\n durationMs = Math.max(durationMs, (videoTrack.duration / videoTrack.timescale) * 1000);\n }\n if (hasAudio && audioTrack) {\n durationMs = Math.max(durationMs, (audioTrack.duration / audioTrack.timescale) * 1000);\n }\n const durationSeconds = durationMs / 1000;\n\n // Get video dimensions from track\n const width = hasVideo && videoTrack && \"width\" in videoTrack ? videoTrack.width : 1920;\n const height = hasVideo && videoTrack && \"height\" in videoTrack ? videoTrack.height : 1080;\n const codec = hasVideo && videoTrack ? videoTrack.codec : \"avc1.640029\";\n\n // Get actual segment durations from fragment index\n const videoSegmentDurationsMs = hasVideo && videoTrack ? getSegmentDurationsMs(videoTrack) : [];\n const scrubSegmentDurationsMs = scrubTrack ? getSegmentDurationsMs(scrubTrack) : [];\n const audioSegmentDurationsMs = hasAudio && audioTrack ? getSegmentDurationsMs(audioTrack) : [];\n\n // Average segment duration for backward compatibility\n const avgVideoSegmentDurationMs =\n videoSegmentDurationsMs.length > 0\n ? videoSegmentDurationsMs.reduce((a, b) => a + b, 0) / videoSegmentDurationsMs.length\n : 2000;\n const avgScrubSegmentDurationMs =\n scrubSegmentDurationsMs.length > 0\n ? scrubSegmentDurationsMs.reduce((a, b) => a + b, 0) / scrubSegmentDurationsMs.length\n : 30000;\n const avgAudioSegmentDurationMs =\n audioSegmentDurationsMs.length > 0\n ? audioSegmentDurationsMs.reduce((a, b) => a + b, 0) / audioSegmentDurationsMs.length\n : 2000;\n\n log(\n `Video: ${videoSegmentDurationsMs.length} segments, Audio: ${audioSegmentDurationsMs.length} segments, Scrub: ${scrubSegmentDurationsMs.length} segments`,\n );\n\n // Construct manifest matching ManifestResponse format\n const manifest = {\n version: \"1.0\",\n type: \"com.editframe/local-jit-manifest\",\n sourceUrl: sourceUrl,\n duration: durationSeconds,\n durationMs: durationMs,\n baseUrl: baseUrl,\n\n videoRenditions: hasVideo\n ? [\n {\n id: \"high\",\n width: width,\n height: height,\n bitrate: 5000000,\n codec: codec,\n container: \"video/mp4\",\n mimeType: `video/mp4; codecs=\"${codec}\"`,\n segmentDuration: avgVideoSegmentDurationMs / 1000,\n segmentDurationMs: avgVideoSegmentDurationMs,\n segmentDurationsMs: videoSegmentDurationsMs,\n startTimeOffsetMs: videoTrack!.startTimeOffsetMs,\n frameRate: 30,\n profile: \"High\",\n level: \"4.1\",\n },\n ...(scrubTrack\n ? [\n {\n id: \"scrub\",\n width: 320,\n height: Math.round((320 * (height ?? 1080)) / (width ?? 1920)),\n bitrate: 100000,\n codec: scrubTrack.codec,\n container: \"video/mp4\",\n mimeType: `video/mp4; codecs=\"${scrubTrack.codec}\"`,\n segmentDuration: avgScrubSegmentDurationMs / 1000,\n segmentDurationMs: avgScrubSegmentDurationMs,\n segmentDurationsMs: scrubSegmentDurationsMs,\n startTimeOffsetMs: scrubTrack.startTimeOffsetMs,\n frameRate: 15,\n profile: \"High\",\n level: \"4.1\",\n },\n ]\n : []),\n ]\n : [],\n\n audioRenditions:\n hasAudio && audioTrack\n ? [\n {\n id: \"audio\",\n channels: \"channel_count\" in audioTrack ? audioTrack.channel_count : 2,\n sampleRate: \"sample_rate\" in audioTrack ? audioTrack.sample_rate : 48000,\n bitrate: 128000,\n codec: audioTrack.codec,\n container: \"audio/mp4\",\n mimeType: `audio/mp4; codecs=\"${audioTrack.codec}\"`,\n segmentDuration: avgAudioSegmentDurationMs / 1000,\n segmentDurationMs: avgAudioSegmentDurationMs,\n segmentDurationsMs: audioSegmentDurationsMs,\n language: \"en\",\n },\n ]\n : [],\n\n endpoints: {\n initSegment: `${baseUrl}/api/v1/transcode/{rendition}/init.m4s?url=${encodeURIComponent(sourceUrl)}`,\n mediaSegment: `${baseUrl}/api/v1/transcode/{rendition}/{segmentId}.m4s?url=${encodeURIComponent(sourceUrl)}`,\n },\n\n jitInfo: {\n parallelTranscodingSupported: true,\n expectedTranscodeLatency: 100, // Local is fast\n segmentCount: videoSegmentDurationsMs.length,\n scrubSegmentCount: scrubSegmentDurationsMs.length,\n },\n };\n\n return manifest;\n}\n\n/**\n * Create the JIT transcode middleware for /api/v1/transcode/* routes.\n *\n * @param options - The middleware options (root, cacheRoot)\n * @param assetFunctions - The asset functions to use (allows dependency injection)\n * @returns Express-compatible middleware function\n */\nexport function createJitTranscodeMiddleware(\n options: JitMiddlewareOptions,\n assetFunctions: AssetFunctions,\n) {\n return async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => {\n const log = debug(\"ef:vite-plugin:jit\");\n\n if (!req.url?.startsWith(\"/api/v1/transcode/\")) {\n return next();\n }\n\n forbidRelativePaths(req);\n log(`Handling JIT transcode request: ${req.url}`);\n\n const url = new URL(req.url, `http://${req.headers.host}`);\n const sourceUrl = url.searchParams.get(\"url\");\n\n if (!sourceUrl) {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"url parameter is required\" }));\n return;\n }\n\n // Resolve URL to either local file path or keep as remote URL (ffprobe supports both)\n const mediaPath = resolveMediaPath(sourceUrl, options.root);\n\n // If the source is a remote URL and handleRemoteUrls is not enabled, let the\n // next middleware handle it (e.g. recordReplayProxyPlugin in test environments).\n if (\n !options.handleRemoteUrls &&\n (mediaPath.startsWith(\"http://\") || mediaPath.startsWith(\"https://\"))\n ) {\n return next();\n }\n\n // Handle CORS\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\"Access-Control-Allow-Methods\", \"GET, OPTIONS\");\n res.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type, Authorization\");\n\n if (req.method === \"OPTIONS\") {\n res.writeHead(204);\n res.end();\n return;\n }\n\n try {\n // Parse the path to determine which endpoint\n const pathMatch = url.pathname.match(/^\\/api\\/v1\\/transcode\\/(?:([^/]+)\\/)?(.+)$/);\n\n if (!pathMatch) {\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Invalid transcode endpoint\" }));\n return;\n }\n\n const [, rendition, endpoint] = pathMatch;\n\n // Handle manifest.json endpoint\n if (endpoint === \"manifest.json\") {\n log(`Generating manifest for ${mediaPath}`);\n const proto =\n (req.headers[\"x-forwarded-proto\"] as string | undefined) || url.protocol.replace(\":\", \"\");\n const baseUrl = `${proto}://${url.host}`;\n\n try {\n const manifest = await generateLocalJitManifest(\n mediaPath,\n sourceUrl,\n baseUrl,\n options.cacheRoot,\n assetFunctions,\n );\n\n res.writeHead(200, {\n \"Content-Type\": \"application/json\",\n \"Cache-Control\": \"public, max-age=300\",\n });\n res.end(JSON.stringify(manifest, null, 2));\n } catch (error) {\n log(`Error generating manifest: ${error}`);\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Failed to generate manifest\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n return;\n }\n\n // Get fragment index first - we need it to determine track IDs\n const fragmentIndexResult = await assetFunctions.generateTrackFragmentIndex(\n options.cacheRoot,\n mediaPath,\n );\n const fragmentIndex: Record<number, TrackFragmentIndex> = JSON.parse(\n await import(\"node:fs/promises\").then((fs) =>\n fs.readFile(fragmentIndexResult.cachePath, \"utf-8\"),\n ),\n );\n\n // Helper: Map rendition ID to track ID, using fragment index to find correct track\n // For video files: track 1 = video, track 2 = audio\n // For audio-only files: track 1 = audio (no track 2)\n const getTrackId = (renditionId: string): number => {\n if (renditionId === \"scrub\") return -1;\n\n if (renditionId === \"audio\") {\n // Find the audio track - could be track 1 (audio-only) or track 2 (video+audio)\n for (const [trackIdStr, trackInfo] of Object.entries(fragmentIndex)) {\n if (trackInfo.type === \"audio\") {\n return Number.parseInt(trackIdStr, 10);\n }\n }\n // Fallback to track 2 if no audio track found by type\n return 2;\n }\n\n // For video renditions (high, medium, low), find the video track\n for (const [trackIdStr, trackInfo] of Object.entries(fragmentIndex)) {\n if (trackInfo.type === \"video\") {\n return Number.parseInt(trackIdStr, 10);\n }\n }\n // Fallback to track 1\n return 1;\n };\n\n // Handle init segment endpoint (e.g., /api/v1/transcode/high/init.mp4 or init.m4s)\n const initMatch = endpoint?.match(/^init\\.(mp4|m4s)$/);\n if (initMatch && rendition) {\n const extension = initMatch[1];\n const contentType = extension === \"m4s\" ? \"video/iso.segment\" : \"video/mp4\";\n log(`Serving init segment (${extension}) for ${mediaPath}, rendition: ${rendition}`);\n\n try {\n const trackId = getTrackId(rendition);\n\n // Generate/get the track file\n let trackTaskResult;\n if (trackId === -1) {\n trackTaskResult = await assetFunctions.generateScrubTrack(options.cacheRoot, mediaPath);\n } else {\n const trackUrl = `/@ef-track/${mediaPath}?trackId=${trackId}`;\n trackTaskResult = await assetFunctions.generateTrack(\n options.cacheRoot,\n mediaPath,\n trackUrl,\n );\n }\n\n const track = fragmentIndex[trackId];\n if (!track) {\n const validTracks = Object.keys(fragmentIndex).join(\", \");\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: `Track ${trackId} not found (valid tracks: ${validTracks})`,\n }),\n );\n return;\n }\n\n // Stream only the init segment bytes\n const { offset, size } = track.initSegment;\n log(`Init segment: offset=${offset}, size=${size}`);\n sendByteRange(res, trackTaskResult.cachePath, offset, size, contentType);\n } catch (error) {\n log(`Error serving init segment: ${error}`);\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n res.writeHead(404, { \"Content-Type\": \"text/plain\" });\n res.end(\"File not found\");\n } else {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Failed to generate init segment\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n }\n return;\n }\n\n // Handle media segment endpoint\n // - .m4s: moof+mdat only (fragment for streaming)\n // - .mp4: init+moof+mdat (playable standalone file for testing)\n const segmentMatch = endpoint?.match(/^(\\d+)\\.(mp4|m4s)$/);\n if (segmentMatch?.[1] && segmentMatch?.[2] && rendition) {\n const segmentId = Number.parseInt(segmentMatch[1], 10);\n const extension = segmentMatch[2];\n const includeInit = extension === \"mp4\";\n log(\n `Serving media segment ${segmentId}.${extension} for ${mediaPath}, rendition: ${rendition}, includeInit: ${includeInit}`,\n );\n\n try {\n const trackId = getTrackId(rendition);\n\n // Generate/get the track file\n let trackTaskResult;\n if (trackId === -1) {\n trackTaskResult = await assetFunctions.generateScrubTrack(options.cacheRoot, mediaPath);\n } else {\n const trackUrl = `/@ef-track/${mediaPath}?trackId=${trackId}`;\n trackTaskResult = await assetFunctions.generateTrack(\n options.cacheRoot,\n mediaPath,\n trackUrl,\n );\n }\n\n const track = fragmentIndex[trackId];\n if (!track) {\n const validTracks = Object.keys(fragmentIndex).join(\", \");\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: `Track ${trackId} not found (valid tracks: ${validTracks})`,\n }),\n );\n return;\n }\n\n // JIT uses 1-based segment IDs, fragment index uses 0-based\n const segmentIndex = segmentId - 1;\n const segment = track.segments[segmentIndex];\n if (!segment) {\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: `Segment ${segmentId} not found`,\n availableSegments: track.segments.length,\n }),\n );\n return;\n }\n\n const contentType = extension === \"m4s\" ? \"video/iso.segment\" : \"video/mp4\";\n\n if (includeInit) {\n // .mp4: Stream init segment + media segment (playable file)\n const initSegment = track.initSegment;\n log(\n `Media segment ${segmentId}.mp4: init(offset=${initSegment.offset}, size=${initSegment.size}) + segment(offset=${segment.offset}, size=${segment.size})`,\n );\n sendMultipleByteRanges(\n res,\n trackTaskResult.cachePath,\n [\n { offset: initSegment.offset, size: initSegment.size },\n { offset: segment.offset, size: segment.size },\n ],\n contentType,\n );\n } else {\n // .m4s: Stream only this segment's bytes (moof+mdat)\n const { offset, size } = segment;\n log(`Media segment ${segmentId}.m4s: offset=${offset}, size=${size}`);\n sendByteRange(res, trackTaskResult.cachePath, offset, size, contentType);\n }\n } catch (error) {\n log(`Error serving media segment: ${error}`);\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n res.writeHead(404, { \"Content-Type\": \"text/plain\" });\n res.end(\"File not found\");\n } else {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Failed to generate media segment\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n }\n return;\n }\n\n // Unknown endpoint\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Unknown transcode endpoint\" }));\n } catch (error) {\n log(`Unexpected error: ${error}`);\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Internal server error\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n };\n}\n"],"mappings":";;;;;;;;;;;AA8CA,SAAgB,cACd,KACA,UACA,QACA,MACA,aACA;CACA,MAAM,MAAM,MAAM,mBAAmB;CACrC,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,MAAM,SAAS,OAAO;AAE5B,KAAI,OAAO,MAAM,MAAM;AACrB,MAAI,mBAAmB,OAAO,GAAG,IAA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CAAC;WACzD,OAAO;AACd,OAAI,qBAAqB,QAAQ;AACjC,OAAI,UAAU,KAAK,EAAE,gBAAgB,oBAAoB,CAAC;AAC1D,OAAI,IACF,KAAK,UAAU;IACb,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAChE,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"jitTranscodeMiddleware.js","names":["fragmentIndex: Record<number, TrackFragmentIndex>"],"sources":["../src/jitTranscodeMiddleware.ts"],"sourcesContent":["import { createReadStream, statSync } from \"node:fs\";\nimport type { ServerResponse } from \"node:http\";\nimport path from \"node:path\";\n\nimport type { IncomingMessage, NextFunction } from \"connect\";\nimport debug from \"debug\";\nimport mime from \"mime\";\nimport type { TrackFragmentIndex } from \"@editframe/assets\";\n\nimport { forbidRelativePaths } from \"./forbidRelativePaths.js\";\n\nexport type { TrackFragmentIndex };\n\n/**\n * Asset functions required by the JIT middleware.\n * These are injected to support both package imports and direct imports.\n */\nexport interface AssetFunctions {\n generateTrack: (\n cacheRoot: string,\n absolutePath: string,\n trackUrl: string,\n ) => Promise<{ cachePath: string }>;\n generateScrubTrack: (cacheRoot: string, absolutePath: string) => Promise<{ cachePath: string }>;\n generateTrackFragmentIndex: (\n cacheRoot: string,\n absolutePath: string,\n ) => Promise<{ cachePath: string }>;\n}\n\nexport interface JitMiddlewareOptions {\n root: string;\n cacheRoot: string;\n /**\n * When true, remote URLs (http/https) are handled locally via ffprobe/ffmpeg\n * rather than passed to a downstream proxy (e.g. recordReplayProxyPlugin).\n * Set to true in dev-projects; leave false (default) in test environments\n * that use recordReplayProxyPlugin to proxy remote URLs to the cloud API.\n */\n handleRemoteUrls?: boolean;\n}\n\n/**\n * Stream a specific byte range from a file.\n * This is used for JIT segment serving where the server extracts the correct bytes.\n */\nexport function sendByteRange(\n res: ServerResponse,\n filePath: string,\n offset: number,\n size: number,\n contentType?: string,\n) {\n const log = debug(\"ef:sendByteRange\");\n const stats = statSync(filePath);\n const end = offset + size - 1;\n\n if (end >= stats.size) {\n log(`Requested range ${offset}-${end} exceeds file size ${stats.size}`);\n res.writeHead(416, { \"Content-Range\": `bytes */${stats.size}` });\n res.end();\n return;\n }\n\n log(`Streaming bytes ${offset}-${end} (${size} bytes) from ${filePath}`);\n\n res.writeHead(200, {\n \"Content-Type\": contentType || mime.getType(filePath) || \"video/mp4\",\n \"Content-Length\": size,\n \"Cache-Control\": \"public, max-age=3600\",\n });\n\n const readStream = createReadStream(filePath, { start: offset, end });\n readStream.pipe(res);\n}\n\n/**\n * Stream multiple byte ranges from a file concatenated together.\n * Used for creating playable .mp4 files by combining init segment + media segment.\n */\nexport function sendMultipleByteRanges(\n res: ServerResponse,\n filePath: string,\n ranges: Array<{ offset: number; size: number }>,\n contentType?: string,\n) {\n const log = debug(\"ef:sendMultipleByteRanges\");\n const stats = statSync(filePath);\n\n // Validate all ranges\n for (const range of ranges) {\n const end = range.offset + range.size - 1;\n if (end >= stats.size) {\n log(`Requested range ${range.offset}-${end} exceeds file size ${stats.size}`);\n res.writeHead(416, { \"Content-Range\": `bytes */${stats.size}` });\n res.end();\n return;\n }\n }\n\n const totalSize = ranges.reduce((sum, r) => sum + r.size, 0);\n log(`Streaming ${ranges.length} ranges (${totalSize} total bytes) from ${filePath}`);\n\n res.writeHead(200, {\n \"Content-Type\": contentType || \"video/mp4\",\n \"Content-Length\": totalSize,\n \"Cache-Control\": \"public, max-age=3600\",\n });\n\n // Stream ranges sequentially\n let rangeIndex = 0;\n\n const streamNextRange = () => {\n if (rangeIndex >= ranges.length) {\n res.end();\n return;\n }\n\n const range = ranges[rangeIndex]!;\n const end = range.offset + range.size - 1;\n const readStream = createReadStream(filePath, { start: range.offset, end });\n\n readStream.on(\"end\", () => {\n rangeIndex++;\n streamNextRange();\n });\n\n readStream.on(\"error\", (err) => {\n log(`Error streaming range ${rangeIndex}: ${err}`);\n res.destroy();\n });\n\n readStream.pipe(res, { end: false });\n };\n\n streamNextRange();\n}\n\n/**\n * Check if a hostname refers to the local vite server.\n * Handles various local hostname patterns including worktree domains.\n */\nexport function isLocalHost(hostname: string): boolean {\n const localPatterns = [\n \"localhost\",\n \"127.0.0.1\",\n \"0.0.0.0\",\n \".localhost\", // Matches *.localhost (worktree domains like main.localhost)\n ];\n\n const lowerHost = hostname.toLowerCase();\n return localPatterns.some((pattern) =>\n pattern.startsWith(\".\")\n ? lowerHost.endsWith(pattern) || lowerHost === pattern.slice(1)\n : lowerHost === pattern || lowerHost.startsWith(pattern + \":\"),\n );\n}\n\n/**\n * Resolve a URL to either a remote URL (for ffprobe) or a local file path.\n *\n * - Remote URLs (different host): passed directly to ffprobe (it supports http/https)\n * - Local URLs (localhost, *.localhost): resolved to local file path\n *\n * @param urlParam - The URL from the query parameter\n * @param root - The vite plugin root directory\n * @returns The path/URL to pass to ffprobe\n */\nexport function resolveMediaPath(urlParam: string, root: string): string {\n try {\n const url = new URL(urlParam);\n const hostname = url.hostname;\n\n // If NOT a local URL, pass directly to ffprobe - it supports http/https URLs\n if (!isLocalHost(hostname)) {\n return urlParam;\n }\n\n // Local URL - resolve to file path\n let filePath = decodeURIComponent(url.pathname);\n\n // Remove leading slash for path.join\n if (filePath.startsWith(\"/\")) {\n filePath = filePath.slice(1);\n }\n\n // The root is already dev-projects/src, so if the URL path starts with \"src/\",\n // we should remove it to avoid duplication (src/src/assets -> src/assets)\n if (filePath.startsWith(\"src/\")) {\n filePath = filePath.slice(4); // Remove \"src/\"\n }\n\n return path.join(root, filePath);\n } catch {\n // If not a valid URL, treat as relative path\n let filePath = urlParam;\n if (filePath.startsWith(\"src/\")) {\n filePath = filePath.slice(4);\n }\n return path.join(root, filePath);\n }\n}\n\n/**\n * Convert fragment index segments to millisecond durations array.\n */\nexport function getSegmentDurationsMs(track: TrackFragmentIndex): number[] {\n return track.segments.map((segment) => (segment.duration / track.timescale) * 1000);\n}\n\n/**\n * Generate a JIT manifest for a local file.\n * Uses actual fragment index data for accurate segment information.\n */\nexport async function generateLocalJitManifest(\n absolutePath: string,\n sourceUrl: string,\n baseUrl: string,\n cacheRoot: string,\n assetFunctions: AssetFunctions,\n) {\n const log = debug(\"ef:generateLocalJitManifest\");\n\n // Generate the fragment index (this also ensures tracks are generated)\n log(`Generating fragment index for ${absolutePath}`);\n const fragmentIndexResult = await assetFunctions.generateTrackFragmentIndex(\n cacheRoot,\n absolutePath,\n );\n const fragmentIndex: Record<number, TrackFragmentIndex> = JSON.parse(\n await import(\"node:fs/promises\").then((fs) =>\n fs.readFile(fragmentIndexResult.cachePath, \"utf-8\"),\n ),\n );\n\n // Find tracks by type rather than by hardcoded index (audio-only files have audio at index 1)\n const videoTrack = Object.values(fragmentIndex).find((t) => t.type === \"video\");\n const audioTrack = Object.values(fragmentIndex).find((t) => t.type === \"audio\");\n const scrubTrack = fragmentIndex[-1];\n\n const hasVideo = videoTrack?.type === \"video\";\n const hasAudio = audioTrack?.type === \"audio\";\n\n // Get duration from the longest track\n let durationMs = 0;\n if (hasVideo && videoTrack) {\n durationMs = Math.max(durationMs, (videoTrack.duration / videoTrack.timescale) * 1000);\n }\n if (hasAudio && audioTrack) {\n durationMs = Math.max(durationMs, (audioTrack.duration / audioTrack.timescale) * 1000);\n }\n const durationSeconds = durationMs / 1000;\n\n // Get video dimensions from track\n const width = hasVideo && videoTrack && \"width\" in videoTrack ? videoTrack.width : 1920;\n const height = hasVideo && videoTrack && \"height\" in videoTrack ? videoTrack.height : 1080;\n const codec = hasVideo && videoTrack ? videoTrack.codec : \"avc1.640029\";\n\n // Get actual segment durations from fragment index\n const videoSegmentDurationsMs = hasVideo && videoTrack ? getSegmentDurationsMs(videoTrack) : [];\n const scrubSegmentDurationsMs = scrubTrack ? getSegmentDurationsMs(scrubTrack) : [];\n const audioSegmentDurationsMs = hasAudio && audioTrack ? getSegmentDurationsMs(audioTrack) : [];\n\n // Average segment duration for backward compatibility\n const avgVideoSegmentDurationMs =\n videoSegmentDurationsMs.length > 0\n ? videoSegmentDurationsMs.reduce((a, b) => a + b, 0) / videoSegmentDurationsMs.length\n : 2000;\n const avgScrubSegmentDurationMs =\n scrubSegmentDurationsMs.length > 0\n ? scrubSegmentDurationsMs.reduce((a, b) => a + b, 0) / scrubSegmentDurationsMs.length\n : 30000;\n const avgAudioSegmentDurationMs =\n audioSegmentDurationsMs.length > 0\n ? audioSegmentDurationsMs.reduce((a, b) => a + b, 0) / audioSegmentDurationsMs.length\n : 2000;\n\n log(\n `Video: ${videoSegmentDurationsMs.length} segments, Audio: ${audioSegmentDurationsMs.length} segments, Scrub: ${scrubSegmentDurationsMs.length} segments`,\n );\n\n // Construct manifest matching ManifestResponse format\n const manifest = {\n version: \"1.0\",\n type: \"com.editframe/local-jit-manifest\",\n sourceUrl: sourceUrl,\n duration: durationSeconds,\n durationMs: durationMs,\n baseUrl: baseUrl,\n\n videoRenditions: hasVideo\n ? [\n {\n id: \"high\",\n width: width,\n height: height,\n bitrate: 5000000,\n codec: codec,\n container: \"video/mp4\",\n mimeType: `video/mp4; codecs=\"${codec}\"`,\n segmentDuration: avgVideoSegmentDurationMs / 1000,\n segmentDurationMs: avgVideoSegmentDurationMs,\n segmentDurationsMs: videoSegmentDurationsMs,\n startTimeOffsetMs: videoTrack!.startTimeOffsetMs,\n frameRate: 30,\n profile: \"High\",\n level: \"4.1\",\n },\n ...(scrubTrack\n ? [\n {\n id: \"scrub\",\n width: 320,\n height: Math.round((320 * (height ?? 1080)) / (width ?? 1920)),\n bitrate: 100000,\n codec: scrubTrack.codec,\n container: \"video/mp4\",\n mimeType: `video/mp4; codecs=\"${scrubTrack.codec}\"`,\n segmentDuration: avgScrubSegmentDurationMs / 1000,\n segmentDurationMs: avgScrubSegmentDurationMs,\n segmentDurationsMs: scrubSegmentDurationsMs,\n startTimeOffsetMs: scrubTrack.startTimeOffsetMs,\n frameRate: 15,\n profile: \"High\",\n level: \"4.1\",\n },\n ]\n : []),\n ]\n : [],\n\n audioRenditions:\n hasAudio && audioTrack\n ? [\n {\n id: \"audio\",\n channels: \"channel_count\" in audioTrack ? audioTrack.channel_count : 2,\n sampleRate: \"sample_rate\" in audioTrack ? audioTrack.sample_rate : 48000,\n bitrate: 128000,\n codec: audioTrack.codec,\n container: \"audio/mp4\",\n mimeType: `audio/mp4; codecs=\"${audioTrack.codec}\"`,\n segmentDuration: avgAudioSegmentDurationMs / 1000,\n segmentDurationMs: avgAudioSegmentDurationMs,\n segmentDurationsMs: audioSegmentDurationsMs,\n language: \"en\",\n },\n ]\n : [],\n\n endpoints: {\n initSegment: `${baseUrl}/api/v1/transcode/{rendition}/init.m4s?url=${encodeURIComponent(sourceUrl)}`,\n mediaSegment: `${baseUrl}/api/v1/transcode/{rendition}/{segmentId}.m4s?url=${encodeURIComponent(sourceUrl)}`,\n },\n\n jitInfo: {\n parallelTranscodingSupported: true,\n expectedTranscodeLatency: 100, // Local is fast\n segmentCount: videoSegmentDurationsMs.length,\n scrubSegmentCount: scrubSegmentDurationsMs.length,\n },\n };\n\n return manifest;\n}\n\n/**\n * Create the JIT transcode middleware for /api/v1/transcode/* routes.\n *\n * @param options - The middleware options (root, cacheRoot)\n * @param assetFunctions - The asset functions to use (allows dependency injection)\n * @returns Express-compatible middleware function\n */\nexport function createJitTranscodeMiddleware(\n options: JitMiddlewareOptions,\n assetFunctions: AssetFunctions,\n) {\n return async (req: IncomingMessage, res: ServerResponse, next: NextFunction) => {\n const log = debug(\"ef:vite-plugin:jit\");\n\n if (!req.url?.startsWith(\"/api/v1/transcode/\")) {\n return next();\n }\n\n forbidRelativePaths(req);\n log(`Handling JIT transcode request: ${req.url}`);\n\n const url = new URL(req.url, `http://${req.headers.host}`);\n const sourceUrl = url.searchParams.get(\"url\");\n\n if (!sourceUrl) {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"url parameter is required\" }));\n return;\n }\n\n // Resolve URL to either local file path or keep as remote URL (ffprobe supports both)\n const mediaPath = resolveMediaPath(sourceUrl, options.root);\n\n // If the source is a remote URL and handleRemoteUrls is not enabled, let the\n // next middleware handle it (e.g. recordReplayProxyPlugin in test environments).\n if (\n !options.handleRemoteUrls &&\n (mediaPath.startsWith(\"http://\") || mediaPath.startsWith(\"https://\"))\n ) {\n return next();\n }\n\n // Handle CORS\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.setHeader(\"Access-Control-Allow-Methods\", \"GET, OPTIONS\");\n res.setHeader(\"Access-Control-Allow-Headers\", \"Content-Type, Authorization\");\n\n if (req.method === \"OPTIONS\") {\n res.writeHead(204);\n res.end();\n return;\n }\n\n try {\n // Parse the path to determine which endpoint\n const pathMatch = url.pathname.match(/^\\/api\\/v1\\/transcode\\/(?:([^/]+)\\/)?(.+)$/);\n\n if (!pathMatch) {\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Invalid transcode endpoint\" }));\n return;\n }\n\n const [, rendition, endpoint] = pathMatch;\n\n // Handle manifest.json endpoint\n if (endpoint === \"manifest.json\") {\n log(`Generating manifest for ${mediaPath}`);\n const proto =\n (req.headers[\"x-forwarded-proto\"] as string | undefined) || url.protocol.replace(\":\", \"\");\n const baseUrl = `${proto}://${url.host}`;\n\n try {\n const manifest = await generateLocalJitManifest(\n mediaPath,\n sourceUrl,\n baseUrl,\n options.cacheRoot,\n assetFunctions,\n );\n\n res.writeHead(200, {\n \"Content-Type\": \"application/json\",\n \"Cache-Control\": \"public, max-age=300\",\n });\n res.end(JSON.stringify(manifest, null, 2));\n } catch (error) {\n log(`Error generating manifest: ${error}`);\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Failed to generate manifest\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n return;\n }\n\n // Get fragment index first - we need it to determine track IDs\n const fragmentIndexResult = await assetFunctions.generateTrackFragmentIndex(\n options.cacheRoot,\n mediaPath,\n );\n const fragmentIndex: Record<number, TrackFragmentIndex> = JSON.parse(\n await import(\"node:fs/promises\").then((fs) =>\n fs.readFile(fragmentIndexResult.cachePath, \"utf-8\"),\n ),\n );\n\n // Helper: Map rendition ID to track ID, using fragment index to find correct track\n // For video files: track 1 = video, track 2 = audio\n // For audio-only files: track 1 = audio (no track 2)\n const getTrackId = (renditionId: string): number => {\n if (renditionId === \"scrub\") return -1;\n\n if (renditionId === \"audio\") {\n // Find the audio track - could be track 1 (audio-only) or track 2 (video+audio)\n for (const [trackIdStr, trackInfo] of Object.entries(fragmentIndex)) {\n if (trackInfo.type === \"audio\") {\n return Number.parseInt(trackIdStr, 10);\n }\n }\n // Fallback to track 2 if no audio track found by type\n return 2;\n }\n\n // For video renditions (high, medium, low), find the video track\n for (const [trackIdStr, trackInfo] of Object.entries(fragmentIndex)) {\n if (trackInfo.type === \"video\") {\n return Number.parseInt(trackIdStr, 10);\n }\n }\n // Fallback to track 1\n return 1;\n };\n\n // Handle init segment endpoint (e.g., /api/v1/transcode/high/init.mp4 or init.m4s)\n const initMatch = endpoint?.match(/^init\\.(mp4|m4s)$/);\n if (initMatch && rendition) {\n const extension = initMatch[1];\n const contentType = extension === \"m4s\" ? \"video/iso.segment\" : \"video/mp4\";\n log(`Serving init segment (${extension}) for ${mediaPath}, rendition: ${rendition}`);\n\n try {\n const trackId = getTrackId(rendition);\n\n // Generate/get the track file\n let trackTaskResult;\n if (trackId === -1) {\n trackTaskResult = await assetFunctions.generateScrubTrack(options.cacheRoot, mediaPath);\n } else {\n const trackUrl = `/@ef-track/${mediaPath}?trackId=${trackId}`;\n trackTaskResult = await assetFunctions.generateTrack(\n options.cacheRoot,\n mediaPath,\n trackUrl,\n );\n }\n\n const track = fragmentIndex[trackId];\n if (!track) {\n const validTracks = Object.keys(fragmentIndex).join(\", \");\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: `Track ${trackId} not found (valid tracks: ${validTracks})`,\n }),\n );\n return;\n }\n\n // Stream only the init segment bytes\n // For VP9-alpha WebM tracks the cache file is .webm; use the correct MIME type.\n const resolvedInitContentType = trackTaskResult.cachePath.endsWith(\".webm\")\n ? \"video/webm\"\n : contentType;\n const { offset, size } = track.initSegment;\n log(`Init segment: offset=${offset}, size=${size}`);\n sendByteRange(res, trackTaskResult.cachePath, offset, size, resolvedInitContentType);\n } catch (error) {\n log(`Error serving init segment: ${error}`);\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n res.writeHead(404, { \"Content-Type\": \"text/plain\" });\n res.end(\"File not found\");\n } else {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Failed to generate init segment\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n }\n return;\n }\n\n // Handle media segment endpoint\n // - .m4s: moof+mdat only (fragment for streaming)\n // - .mp4: init+moof+mdat (playable standalone file for testing)\n const segmentMatch = endpoint?.match(/^(\\d+)\\.(mp4|m4s)$/);\n if (segmentMatch?.[1] && segmentMatch?.[2] && rendition) {\n const segmentId = Number.parseInt(segmentMatch[1], 10);\n const extension = segmentMatch[2];\n const includeInit = extension === \"mp4\";\n log(\n `Serving media segment ${segmentId}.${extension} for ${mediaPath}, rendition: ${rendition}, includeInit: ${includeInit}`,\n );\n\n try {\n const trackId = getTrackId(rendition);\n\n // Generate/get the track file\n let trackTaskResult;\n if (trackId === -1) {\n trackTaskResult = await assetFunctions.generateScrubTrack(options.cacheRoot, mediaPath);\n } else {\n const trackUrl = `/@ef-track/${mediaPath}?trackId=${trackId}`;\n trackTaskResult = await assetFunctions.generateTrack(\n options.cacheRoot,\n mediaPath,\n trackUrl,\n );\n }\n\n const track = fragmentIndex[trackId];\n if (!track) {\n const validTracks = Object.keys(fragmentIndex).join(\", \");\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: `Track ${trackId} not found (valid tracks: ${validTracks})`,\n }),\n );\n return;\n }\n\n // JIT uses 1-based segment IDs, fragment index uses 0-based\n const segmentIndex = segmentId - 1;\n const segment = track.segments[segmentIndex];\n if (!segment) {\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: `Segment ${segmentId} not found`,\n availableSegments: track.segments.length,\n }),\n );\n return;\n }\n\n // For VP9-alpha WebM tracks the cache file is .webm; use the correct MIME type\n // regardless of the .mp4 / .m4s URL extension (those are just request conventions).\n const isWebmTrack = trackTaskResult.cachePath.endsWith(\".webm\");\n const contentType = isWebmTrack\n ? \"video/webm\"\n : extension === \"m4s\"\n ? \"video/iso.segment\"\n : \"video/mp4\";\n\n if (includeInit) {\n // .mp4 (or .webm): Stream init segment + media segment (playable file / WebM)\n const initSegment = track.initSegment;\n log(\n `Media segment ${segmentId}.mp4: init(offset=${initSegment.offset}, size=${initSegment.size}) + segment(offset=${segment.offset}, size=${segment.size})`,\n );\n sendMultipleByteRanges(\n res,\n trackTaskResult.cachePath,\n [\n { offset: initSegment.offset, size: initSegment.size },\n { offset: segment.offset, size: segment.size },\n ],\n contentType,\n );\n } else {\n // .m4s: Stream only this segment's bytes (moof+mdat, or WebM clusters)\n const { offset, size } = segment;\n log(`Media segment ${segmentId}.m4s: offset=${offset}, size=${size}`);\n sendByteRange(res, trackTaskResult.cachePath, offset, size, contentType);\n }\n } catch (error) {\n log(`Error serving media segment: ${error}`);\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") {\n res.writeHead(404, { \"Content-Type\": \"text/plain\" });\n res.end(\"File not found\");\n } else {\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Failed to generate media segment\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n }\n return;\n }\n\n // Unknown endpoint\n res.writeHead(404, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"Unknown transcode endpoint\" }));\n } catch (error) {\n log(`Unexpected error: ${error}`);\n res.writeHead(500, { \"Content-Type\": \"application/json\" });\n res.end(\n JSON.stringify({\n error: \"Internal server error\",\n details: error instanceof Error ? error.message : String(error),\n }),\n );\n }\n };\n}\n"],"mappings":";;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pD,UAAI,IAAI,iBAAiB;YACpB;AACL,UAAI,UAAU,KAAK,EAAE,gBAAgB,oBAAoB,CAAC;AAC1D,UAAI,IACF,KAAK,UAAU;OACb,OAAO;OACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;OAChE,CAAC,CACH;;;AAGL;;AAIF,OAAI,UAAU,KAAK,EAAE,gBAAgB,oBAAoB,CAAC;AAC1D,OAAI,IAAI,KAAK,UAAU,EAAE,OAAO,8BAA8B,CAAC,CAAC;WACzD,OAAO;AACd,OAAI,qBAAqB,QAAQ;AACjC,OAAI,UAAU,KAAK,EAAE,gBAAgB,oBAAoB,CAAC;AAC1D,OAAI,IACF,KAAK,UAAU;IACb,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAChE,CAAC,CACH"}
|
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const version = \"0.47.
|
|
1
|
+
{"version":3,"file":"version.js","names":[],"sources":["../src/version.ts"],"sourcesContent":["export const version = \"0.47.2\";\n"],"mappings":";AAAA,MAAa,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/vite-plugin",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.2",
|
|
4
4
|
"description": "Editframe vite plugin",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"author": "",
|
|
21
21
|
"license": "SEE LICENSE IN LICENSE-FULL.md",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@editframe/api": "0.47.
|
|
24
|
-
"@editframe/assets": "0.47.
|
|
23
|
+
"@editframe/api": "0.47.2",
|
|
24
|
+
"@editframe/assets": "0.47.2",
|
|
25
25
|
"connect": "^3.7.0",
|
|
26
26
|
"debug": "^4.3.5",
|
|
27
27
|
"mime": "^4.0.3",
|