@hyperframes/studio-server 0.8.142 → 0.8.143

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,3 +1,7 @@
1
+ import {
2
+ resolveWithinProject
3
+ } from "./chunk-DTKK7TKL.js";
4
+
1
5
  // src/helpers/loudness.ts
2
6
  import { execFile } from "child_process";
3
7
  import { isAbsolute, relative, resolve } from "path";
@@ -5,6 +9,25 @@ import { promisify } from "util";
5
9
  import { isAudibleVideoElement } from "@hyperframes/core/audible-video";
6
10
  import { formatAudioGain, MAX_AUDIO_GAIN_DB } from "@hyperframes/core/audio-gain";
7
11
  import { findFfBinary } from "@hyperframes/parsers/ff-binaries";
12
+ import { readMediaOffsetSeconds } from "@hyperframes/parsers/media-duration";
13
+
14
+ // src/helpers/requestSubPath.ts
15
+ import { existsSync } from "fs";
16
+ import { decodedUrlPath, decodeWellFormedEscapes } from "@hyperframes/parsers/asset-paths";
17
+ import { decodeWellFormedEscapes as decodeWellFormedEscapes2 } from "@hyperframes/parsers/asset-paths";
18
+ function requestSubPath(url, route) {
19
+ const routeSegments = route.split("/");
20
+ const segments = new URL(url).pathname.split("/");
21
+ const start = segments.indexOf(routeSegments[0] ?? "");
22
+ return decodeWellFormedEscapes(segments.slice(start + routeSegments.length).join("/"));
23
+ }
24
+ function requestedProjectPath(projectDir, field) {
25
+ const trimmed = field.trim().replace(/^[.]\//, "");
26
+ const named = resolveWithinProject(projectDir, trimmed);
27
+ return named && existsSync(named) ? trimmed : decodedUrlPath(trimmed);
28
+ }
29
+
30
+ // src/helpers/loudness.ts
8
31
  var execFileAsync = promisify(execFile);
9
32
  var FFMPEG_TIMEOUT_MS = 12e4;
10
33
  function authoredNumber(raw, fallback, attribute, id, strictlyPositive = false) {
@@ -149,6 +172,13 @@ function requiredAudioIdentity(attributes) {
149
172
  if (!src) throw new Error(`Audio #${id} has no src`);
150
173
  return { id, src };
151
174
  }
175
+ function authoredMediaStart(attributes, id) {
176
+ return readMediaOffsetSeconds((name) => {
177
+ const raw = attributes.get(name)?.value;
178
+ if (name === "data-media-start") authoredNumber(raw, 0, name, id);
179
+ return raw;
180
+ });
181
+ }
152
182
  function hasBareAttribute(html, range, name) {
153
183
  const unquoted = html.slice(range.start, range.end).replace(/"[^"]*"|'[^']*'/g, '""');
154
184
  return new RegExp(`\\s${name}(?=[\\s/>=])`, "i").test(unquoted);
@@ -173,12 +203,7 @@ function mediaTagFromRange(html, range) {
173
203
  id,
174
204
  src,
175
205
  volume: authoredNumber(volumeAttribute?.value, 1, "data-volume", id),
176
- mediaStart: authoredNumber(
177
- attributes.get("data-media-start")?.value,
178
- 0,
179
- "data-media-start",
180
- id
181
- ),
206
+ mediaStart: authoredMediaStart(attributes, id),
182
207
  duration: authoredDuration(attributes, id),
183
208
  playbackRate: authoredNumber(
184
209
  attributes.get("data-playback-rate")?.value,
@@ -205,13 +230,7 @@ function audioTags(html) {
205
230
  return tags;
206
231
  }
207
232
  function resolveLocalAudioPath(projectDir, src) {
208
- const withoutSuffix = src.split(/[?#]/, 1)[0] ?? "";
209
- let decoded = "";
210
- try {
211
- decoded = decodeURIComponent(withoutSuffix);
212
- } catch {
213
- throw new Error(`Audio source must be a local project file: ${src}`);
214
- }
233
+ const decoded = requestedProjectPath(projectDir, src);
215
234
  if (!decoded || isAbsolute(decoded) || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(decoded)) {
216
235
  throw new Error(`Audio source must be a local project file: ${src}`);
217
236
  }
@@ -346,6 +365,9 @@ function absoluteLoudnessPlan(track, targetLufs = DEFAULT_TARGET_LUFS) {
346
365
  }
347
366
 
348
367
  export {
368
+ requestSubPath,
369
+ requestedProjectPath,
370
+ decodeWellFormedEscapes2 as decodeWellFormedEscapes,
349
371
  audioTags,
350
372
  resolveLocalAudioPath,
351
373
  parseEbur128Summary,
@@ -359,4 +381,4 @@ export {
359
381
  NORMALIZE_TRUE_PEAK_CEILING_DBFS,
360
382
  absoluteLoudnessPlan
361
383
  };
362
- //# sourceMappingURL=chunk-DSVQ2U7J.js.map
384
+ //# sourceMappingURL=chunk-32IH7WBY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/loudness.ts","../src/helpers/requestSubPath.ts"],"sourcesContent":["import { execFile } from \"node:child_process\";\nimport { isAbsolute, relative, resolve } from \"node:path\";\nimport { promisify } from \"node:util\";\nimport { isAudibleVideoElement } from \"@hyperframes/core/audible-video\";\nimport { formatAudioGain, MAX_AUDIO_GAIN_DB } from \"@hyperframes/core/audio-gain\";\nimport { findFfBinary } from \"@hyperframes/parsers/ff-binaries\";\nimport { readMediaOffsetSeconds } from \"@hyperframes/parsers/media-duration\";\nimport { requestedProjectPath } from \"./requestSubPath.js\";\n\nconst execFileAsync = promisify(execFile);\n\nconst FFMPEG_TIMEOUT_MS = 120_000;\n\ninterface AttributeSpan {\n value: string;\n valueStart: number;\n valueEnd: number;\n}\n\ninterface TagRange {\n start: number;\n end: number;\n}\n\ntype MediaTagName = \"audio\" | \"video\";\n\ninterface MediaTagRange extends TagRange {\n name: MediaTagName;\n}\n\ninterface ParsedStartTag extends TagRange {\n closing: boolean;\n name: string;\n}\n\ninterface ScanResult {\n cursor: number;\n mediaRange: MediaTagRange | null;\n}\n\nexport interface AudioTag {\n tag: MediaTagName;\n id: string;\n src: string;\n volume: number;\n mediaStart: number;\n duration: number | null;\n playbackRate: number;\n start: number;\n end: number;\n volumeAttribute: AttributeSpan | null;\n}\n\nexport interface LoudnessMeasurement {\n integratedLufs: number;\n truePeakDbfs: number;\n}\n\nexport interface NormalizationTrack extends LoudnessMeasurement {\n id: string;\n volume: number;\n}\n\nexport interface AudioNormalizationPlan {\n referenceId: string;\n targetId: string;\n referenceLufs: number;\n targetLufs: number;\n previousVolume: number;\n volume: number;\n gainDb: number;\n changeDb: number;\n projectedLufs: number;\n projectedTruePeakDbfs: number;\n}\n\nfunction authoredNumber(\n raw: string | undefined,\n fallback: number,\n attribute: string,\n id: string,\n strictlyPositive = false,\n): number {\n if (raw === undefined) return fallback;\n const value = Number(raw);\n if (!Number.isFinite(value) || (strictlyPositive ? value <= 0 : value < 0)) {\n throw new Error(`Audio #${id} has an invalid ${attribute}: ${raw}`);\n }\n return value;\n}\n\nfunction attributeFromMatch(\n match: RegExpMatchArray,\n absoluteOffset: number,\n): [string, AttributeSpan] | null {\n if (match.index === undefined) return null;\n const name = match[1]?.toLowerCase();\n const value = matchedAttributeValue(match);\n if (!name || value === undefined) return null;\n\n const whole = match[0];\n const localValueStart = attributeValueStart(whole);\n const valueStart = absoluteOffset + match.index + localValueStart;\n return [name, { value, valueStart, valueEnd: valueStart + value.length }];\n}\n\nfunction matchedAttributeValue(match: RegExpMatchArray): string | undefined {\n return match[2] ?? match[3] ?? match[4];\n}\n\nfunction attributeValueStart(attribute: string): number {\n let cursor = attribute.indexOf(\"=\") + 1;\n while (/\\s/.test(attribute[cursor] ?? \"\")) cursor += 1;\n const quote = attribute[cursor];\n return quote === '\"' || quote === \"'\" ? cursor + 1 : cursor;\n}\n\nfunction attributesInTag(html: string, from: number, to: number): Map<string, AttributeSpan> {\n const tag = html.slice(from, to);\n const nameEnd = tag.search(/\\s|\\/?\\s*>/);\n const attributes = new Map<string, AttributeSpan>();\n if (nameEnd < 0) return attributes;\n\n const pattern = /([^\\s=/>]+)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+))/g;\n for (const match of tag.slice(nameEnd).matchAll(pattern)) {\n const attribute = attributeFromMatch(match, from + nameEnd);\n if (attribute) attributes.set(...attribute);\n }\n return attributes;\n}\n\nfunction startTagEnd(html: string, start: number): number {\n let quote = \"\";\n let end = start + 1;\n for (; end < html.length; end += 1) {\n const char = html[end];\n if (quote) {\n if (char === quote) quote = \"\";\n } else if (char === '\"' || char === \"'\") {\n quote = char;\n } else if (char === \">\") {\n return end + 1;\n }\n }\n throw new Error(\"Unterminated HTML start tag\");\n}\n\nfunction commentEnd(html: string, start: number): number {\n const end = html.indexOf(\"-->\", start + 4);\n if (end < 0) throw new Error(\"Unterminated HTML comment\");\n return end + 3;\n}\n\nconst isSpaceAt = (html: string, index: number) => /\\s/.test(html.charAt(index));\nconst isWordAt = (html: string, index: number) => /\\w/.test(html.charAt(index));\n\nfunction skipSpaces(html: string, index: number): number {\n let cursor = index;\n while (cursor < html.length && isSpaceAt(html, cursor)) cursor++;\n return cursor;\n}\n\nfunction parsedStartTag(html: string, start: number): ParsedStartTag | null {\n let cursor = skipSpaces(html, start + 1);\n const closing = html.charAt(cursor) === \"/\";\n if (closing) cursor = skipSpaces(html, cursor + 1);\n const nameStart = cursor;\n if (!/[a-z]/i.test(html.charAt(cursor))) return null;\n while (/[a-z\\d:-]/i.test(html.charAt(cursor + 1))) cursor++;\n let nameEnd = cursor + 1;\n while (nameEnd > nameStart && isWordAt(html, nameEnd - 1) === isWordAt(html, nameEnd)) nameEnd--;\n if (nameEnd === nameStart) return null;\n return {\n start,\n end: startTagEnd(html, start),\n closing,\n name: html.slice(nameStart, nameEnd).toLowerCase(),\n };\n}\n\nfunction rawTextElementEnd(html: string, lower: string, tag: ParsedStartTag): number | null {\n if (tag.closing || (tag.name !== \"script\" && tag.name !== \"style\")) return null;\n const closeStart = lower.indexOf(`</${tag.name}`, tag.end);\n if (closeStart < 0) throw new Error(`Unterminated <${tag.name}> element`);\n return startTagEnd(html, closeStart);\n}\n\nfunction scanMarkup(html: string, lower: string, start: number): ScanResult {\n if (html.startsWith(\"<!--\", start)) {\n return { cursor: commentEnd(html, start), mediaRange: null };\n }\n const tag = parsedStartTag(html, start);\n if (!tag) {\n const marker = html[start + 1];\n const cursor = marker === \"!\" || marker === \"?\" ? startTagEnd(html, start) : start + 1;\n return { cursor, mediaRange: null };\n }\n const rawTextEnd = rawTextElementEnd(html, lower, tag);\n if (rawTextEnd !== null) return { cursor: rawTextEnd, mediaRange: null };\n return { cursor: tag.end, mediaRange: mediaRangeOf(tag) };\n}\n\nfunction mediaRangeOf(tag: ParsedStartTag): MediaTagRange | null {\n if (tag.closing) return null;\n if (tag.name === \"audio\" || tag.name === \"video\") {\n return { start: tag.start, end: tag.end, name: tag.name };\n }\n return null;\n}\n\nfunction mediaTagRanges(html: string): MediaTagRange[] {\n const lower = html.toLowerCase();\n const ranges: MediaTagRange[] = [];\n let cursor = 0;\n while (cursor < html.length) {\n const start = html.indexOf(\"<\", cursor);\n if (start < 0) break;\n const scanned = scanMarkup(html, lower, start);\n if (scanned.mediaRange) ranges.push(scanned.mediaRange);\n cursor = scanned.cursor;\n }\n return ranges;\n}\n\nfunction trimmedAttribute(attributes: Map<string, AttributeSpan>, name: string): string {\n return attributes.get(name)?.value.trim() ?? \"\";\n}\n\n/**\n * How much of the source the composition actually plays.\n *\n * `data-duration` is the explicit trim; absent, `data-end` still bounds the\n * clip's timeline window, and the parser, the runtime and the render mixer all\n * honour it. Measuring the whole file for a `data-end`-trimmed clip reads a\n * loudness the composition never plays — and `--write` then \"corrects\" an\n * already-matched clip by tens of dB.\n */\nfunction authoredDuration(attributes: Map<string, AttributeSpan>, id: string): number | null {\n const raw = attributes.get(\"data-duration\")?.value;\n if (raw !== undefined) return authoredNumber(raw, 0, \"data-duration\", id, true);\n\n const rawEnd = attributes.get(\"data-end\")?.value;\n if (rawEnd === undefined) return null;\n const end = authoredNumber(rawEnd, 0, \"data-end\", id, true);\n const start = authoredNumber(attributes.get(\"data-start\")?.value, 0, \"data-start\", id);\n return end > start ? end - start : null;\n}\n\nfunction requiredAudioIdentity(attributes: Map<string, AttributeSpan>) {\n const id = trimmedAttribute(attributes, \"id\");\n const src = trimmedAttribute(attributes, \"src\");\n if (!id) throw new Error(\"Every normalized <audio> element needs an id\");\n if (!src) throw new Error(`Audio #${id} has no src`);\n return { id, src };\n}\n\nfunction authoredMediaStart(attributes: Map<string, AttributeSpan>, id: string): number {\n return readMediaOffsetSeconds((name) => {\n const raw = attributes.get(name)?.value;\n if (name === \"data-media-start\") authoredNumber(raw, 0, name, id);\n return raw;\n });\n}\n\n/** Boolean attributes carry no `=`, so the value map cannot see them. */\nfunction hasBareAttribute(html: string, range: TagRange, name: string): boolean {\n const unquoted = html.slice(range.start, range.end).replace(/\"[^\"]*\"|'[^']*'/g, '\"\"');\n return new RegExp(`\\\\s${name}(?=[\\\\s/>=])`, \"i\").test(unquoted);\n}\n\nfunction isAudibleVideoTag(\n html: string,\n range: TagRange,\n attributes: Map<string, AttributeSpan>,\n): boolean {\n return isAudibleVideoElement({\n tagName: \"video\",\n hasAttribute: (name) => attributes.has(name) || hasBareAttribute(html, range, name),\n getAttribute: (name) => attributes.get(name)?.value ?? null,\n });\n}\n\n/**\n * A video joins the scan only when it carries sound and can be addressed.\n * Silent footage, and a video no command could name, are skipped rather than\n * failing a run that is about some other clip.\n */\nfunction inScopeVideo(\n html: string,\n range: TagRange,\n attributes: Map<string, AttributeSpan>,\n): boolean {\n return (\n isAudibleVideoTag(html, range, attributes) &&\n trimmedAttribute(attributes, \"id\") !== \"\" &&\n trimmedAttribute(attributes, \"src\") !== \"\"\n );\n}\n\nfunction mediaTagFromRange(html: string, range: MediaTagRange): AudioTag | null {\n const attributes = attributesInTag(html, range.start, range.end);\n if (range.name === \"video\" && !inScopeVideo(html, range, attributes)) return null;\n const { id, src } = requiredAudioIdentity(attributes);\n const volumeAttribute = attributes.get(\"data-volume\") ?? null;\n return {\n tag: range.name,\n id,\n src,\n volume: authoredNumber(volumeAttribute?.value, 1, \"data-volume\", id),\n mediaStart: authoredMediaStart(attributes, id),\n duration: authoredDuration(attributes, id),\n playbackRate: authoredNumber(\n attributes.get(\"data-playback-rate\")?.value,\n 1,\n \"data-playback-rate\",\n id,\n true,\n ),\n start: range.start,\n end: range.end,\n volumeAttribute,\n };\n}\n\n/** Read the authored clips with sound — `<audio>` and audible `<video>` — without reserializing. */\nexport function audioTags(html: string): AudioTag[] {\n const seen = new Set<string>();\n const tags: AudioTag[] = [];\n for (const range of mediaTagRanges(html)) {\n const tag = mediaTagFromRange(html, range);\n if (!tag) continue;\n if (seen.has(tag.id)) throw new Error(`Duplicate audio id \"${tag.id}\"`);\n seen.add(tag.id);\n tags.push(tag);\n }\n return tags;\n}\n\n/** Resolve only a file contained by the project. Remote and traversal sources are not measured. */\nexport function resolveLocalAudioPath(projectDir: string, src: string): string {\n const decoded = requestedProjectPath(projectDir, src);\n if (!decoded || isAbsolute(decoded) || /^(?:[a-z][a-z\\d+.-]*:|\\/\\/)/i.test(decoded)) {\n throw new Error(`Audio source must be a local project file: ${src}`);\n }\n const root = resolve(projectDir);\n const file = resolve(root, decoded);\n const rel = relative(root, file);\n if (!rel || rel === \"..\" || rel.startsWith(`..${process.platform === \"win32\" ? \"\\\\\" : \"/\"}`)) {\n throw new Error(`Audio source must be a local project file: ${src}`);\n }\n return file;\n}\n\n/** Parse FFmpeg's final EBU R128 summary, not its per-window log lines. */\nexport function parseEbur128Summary(stderr: string): LoudnessMeasurement {\n const summaryAt = stderr.lastIndexOf(\"Summary:\");\n const summary = summaryAt >= 0 ? stderr.slice(summaryAt) : \"\";\n const integrated = summary.match(/\\bI:\\s*(-?\\d+(?:\\.\\d+)?)\\s+LUFS\\b/);\n const peak = summary.match(/\\bPeak:\\s*(-?\\d+(?:\\.\\d+)?)\\s+dBFS\\b/);\n const integratedLufs = Number(integrated?.[1]);\n const truePeakDbfs = Number(peak?.[1]);\n if (!Number.isFinite(integratedLufs)) {\n throw new Error(\"FFmpeg did not report integrated loudness for this audio stream\");\n }\n if (!Number.isFinite(truePeakDbfs)) {\n throw new Error(\"FFmpeg did not report true peak for this audio stream\");\n }\n return { integratedLufs, truePeakDbfs };\n}\n\nexport function gainDb(volume: number): number {\n return volume > 0 ? 20 * Math.log10(volume) : Number.NEGATIVE_INFINITY;\n}\n\n/** Calculate the target's absolute authored gain while keeping the reference unchanged. */\nexport function audioNormalizationPlan(\n referenceTrack: NormalizationTrack,\n targetTrack: NormalizationTrack,\n): AudioNormalizationPlan {\n if (!(referenceTrack.volume > 0) || !(targetTrack.volume > 0)) {\n throw new Error(\"Muted audio cannot be used for loudness matching\");\n }\n const referenceLufs = referenceTrack.integratedLufs + gainDb(referenceTrack.volume);\n const targetLufs = targetTrack.integratedLufs + gainDb(targetTrack.volume);\n const wantedGainDb = referenceLufs - targetTrack.integratedLufs;\n if (wantedGainDb > MAX_AUDIO_GAIN_DB + 1e-9) {\n throw new Error(\n `Matching #${targetTrack.id} needs ${wantedGainDb.toFixed(1)} dB, beyond the +${MAX_AUDIO_GAIN_DB} dB authoring ceiling. ` +\n `A gap this large belongs in the source file, not the mixer — mixer gain raises the noise floor with the signal. ` +\n `Normalize ${targetTrack.id}'s asset offline (e.g. ffmpeg loudnorm), or lower #${referenceTrack.id} instead.`,\n );\n }\n const volume = 10 ** (wantedGainDb / 20);\n const projectedTruePeakDbfs = targetTrack.truePeakDbfs + wantedGainDb;\n if (projectedTruePeakDbfs > 0) {\n throw new Error(\n `Matching #${targetTrack.id} would clip at +${projectedTruePeakDbfs.toFixed(1)} dBFS; limit or preprocess the source first`,\n );\n }\n return {\n referenceId: referenceTrack.id,\n targetId: targetTrack.id,\n referenceLufs,\n targetLufs,\n previousVolume: targetTrack.volume,\n volume,\n gainDb: wantedGainDb,\n changeDb: wantedGainDb - gainDb(targetTrack.volume),\n projectedLufs: targetTrack.integratedLufs + wantedGainDb,\n projectedTruePeakDbfs,\n };\n}\n\n/** Patch one authored attribute in place so scripts/styles/comments remain byte-stable. */\nexport function updateAudioVolume(html: string, id: string, volume: number): string {\n const tag = audioTags(html).find((candidate) => candidate.id === id);\n if (!tag) throw new Error(`Audio #${id} was not found`);\n const value = formatAudioGain(volume);\n if (tag.volumeAttribute) {\n return (\n html.slice(0, tag.volumeAttribute.valueStart) +\n value +\n html.slice(tag.volumeAttribute.valueEnd)\n );\n }\n\n let insertion = tag.end - 1;\n let tail = insertion - 1;\n while (tail >= tag.start && /\\s/.test(html[tail] ?? \"\")) tail -= 1;\n if (html[tail] === \"/\") {\n insertion = tail;\n while (insertion > tag.start && /\\s/.test(html[insertion - 1] ?? \"\")) insertion -= 1;\n } else {\n while (insertion > tag.start && /\\s/.test(html[insertion - 1] ?? \"\")) insertion -= 1;\n }\n return html.slice(0, insertion) + ` data-volume=\"${value}\"` + html.slice(insertion);\n}\n\n/**\n * FFmpeg arguments that measure exactly the window the composition plays.\n *\n * `-ss` / `-t` go BEFORE `-i`, as INPUT options. After `-i` they bound the\n * output, and with `-f null` there is no real output to bound: ffmpeg keeps\n * feeding the filter graph past the limit, so ebur128 integrates audio the clip\n * never plays. Measured on a 12 s file whose first 4 s — the played window — is\n * -61.8 LUFS: output-side `-t 4` reported -33.8 LUFS, input-side reports -61.8,\n * the same as physically cutting the file first.\n */\nexport function loudnessMeasureArgs(file: string, tag: MeasuredWindow): string[] {\n const args = [\"-hide_banner\", \"-nostats\"];\n if (tag.mediaStart > 0) args.push(\"-ss\", String(tag.mediaStart));\n const sourceSpan = tag.duration === null ? null : tag.duration * (tag.playbackRate ?? 1);\n if (sourceSpan !== null && sourceSpan > 0) args.push(\"-t\", String(sourceSpan));\n args.push(\"-i\", file, \"-map\", \"0:a:0\", \"-vn\", \"-af\", \"ebur128=peak=true\", \"-f\", \"null\", \"-\");\n return args;\n}\n\nexport type MeasuredWindow = Pick<AudioTag, \"mediaStart\" | \"duration\"> &\n Partial<Pick<AudioTag, \"playbackRate\">>;\n\nexport async function measureAudio(\n ffmpegPath: string,\n file: string,\n tag: MeasuredWindow,\n): Promise<LoudnessMeasurement> {\n const result = await execFileAsync(ffmpegPath, loudnessMeasureArgs(file, tag), {\n encoding: \"utf8\",\n maxBuffer: 16 * 1024 * 1024,\n timeout: FFMPEG_TIMEOUT_MS,\n windowsHide: true,\n });\n return parseEbur128Summary(result.stderr);\n}\n\nexport function requiredFfmpeg(): string {\n const ffmpegPath = findFfBinary(\"ffmpeg\", { configuredMustExist: true });\n if (!ffmpegPath) throw new Error(\"FFmpeg is required to measure integrated loudness\");\n return ffmpegPath;\n}\n\nexport const DEFAULT_TARGET_LUFS = -16;\nexport const NORMALIZE_TRUE_PEAK_CEILING_DBFS = -1.5;\n/** EBU R128's absolute gate: a window this quiet has no integrated loudness to match. */\nconst SILENCE_LUFS = -70;\n\nexport type LoudnessLimit = \"gain-ceiling\" | \"true-peak\";\n\nexport interface AbsoluteLoudnessPlan {\n targetId: string;\n targetLufs: number;\n sourceLufs: number;\n previousVolume: number;\n volume: number;\n gainDb: number;\n changeDb: number;\n projectedLufs: number;\n projectedTruePeakDbfs: number;\n limitedBy: LoudnessLimit | null;\n}\n\n/**\n * The authored gain that brings one clip's played window to an absolute\n * loudness. Unlike reference matching it never refuses: past the +12 dB\n * authoring ceiling or the true-peak ceiling it applies the most that fits and\n * names which limit stopped it.\n */\nexport function absoluteLoudnessPlan(\n track: NormalizationTrack,\n targetLufs: number = DEFAULT_TARGET_LUFS,\n): AbsoluteLoudnessPlan {\n if (track.integratedLufs <= SILENCE_LUFS) {\n throw new Error(`#${track.id} is silent in the played window; there is nothing to normalize`);\n }\n const wantedGainDb = targetLufs - track.integratedLufs;\n const peakRoomDb = NORMALIZE_TRUE_PEAK_CEILING_DBFS - track.truePeakDbfs;\n const limits: Array<[LoudnessLimit | null, number]> = [\n [null, wantedGainDb],\n [\"gain-ceiling\", MAX_AUDIO_GAIN_DB],\n [\"true-peak\", peakRoomDb],\n ];\n const [limitedBy, appliedGainDb] = limits.reduce((lowest, candidate) =>\n candidate[1] < lowest[1] - 1e-9 ? candidate : lowest,\n );\n const previousGainDb = track.volume > 0 ? gainDb(track.volume) : 0;\n return {\n targetId: track.id,\n targetLufs,\n sourceLufs: track.integratedLufs,\n previousVolume: track.volume,\n volume: 10 ** (appliedGainDb / 20),\n gainDb: appliedGainDb,\n changeDb: appliedGainDb - previousGainDb,\n projectedLufs: track.integratedLufs + appliedGainDb,\n projectedTruePeakDbfs: track.truePeakDbfs + appliedGainDb,\n limitedBy,\n };\n}\n","import { existsSync } from \"node:fs\";\nimport { decodedUrlPath, decodeWellFormedEscapes } from \"@hyperframes/parsers/asset-paths\";\nimport { resolveWithinProject } from \"./safePath.js\";\nexport { decodeWellFormedEscapes } from \"@hyperframes/parsers/asset-paths\";\n\n// The decoded path after `route` (\"projects/:id/preview\", \"composition\"), cut by segment from the raw URL:\n// Hono's c.req.path leaves %40 %25 %23 %26 %3F encoded, so cutting a decoded prefix out of it misses.\nexport function requestSubPath(url: string, route: string): string {\n const routeSegments = route.split(\"/\");\n const segments = new URL(url).pathname.split(\"/\");\n const start = segments.indexOf(routeSegments[0] ?? \"\");\n return decodeWellFormedEscapes(segments.slice(start + routeSegments.length).join(\"/\"));\n}\n\n// A project file a request names: the literal name when that file exists, otherwise the field read as a URL.\nexport function requestedProjectPath(projectDir: string, field: string): string {\n const trimmed = field.trim().replace(/^[.]\\//, \"\");\n const named = resolveWithinProject(projectDir, trimmed);\n return named && existsSync(named) ? trimmed : decodedUrlPath(trimmed);\n}\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY,UAAU,eAAe;AAC9C,SAAS,iBAAiB;AAC1B,SAAS,6BAA6B;AACtC,SAAS,iBAAiB,yBAAyB;AACnD,SAAS,oBAAoB;AAC7B,SAAS,8BAA8B;;;ACNvC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB,+BAA+B;AAExD,SAAS,2BAAAA,gCAA+B;AAIjC,SAAS,eAAe,KAAa,OAAuB;AACjE,QAAM,gBAAgB,MAAM,MAAM,GAAG;AACrC,QAAM,WAAW,IAAI,IAAI,GAAG,EAAE,SAAS,MAAM,GAAG;AAChD,QAAM,QAAQ,SAAS,QAAQ,cAAc,CAAC,KAAK,EAAE;AACrD,SAAO,wBAAwB,SAAS,MAAM,QAAQ,cAAc,MAAM,EAAE,KAAK,GAAG,CAAC;AACvF;AAGO,SAAS,qBAAqB,YAAoB,OAAuB;AAC9E,QAAM,UAAU,MAAM,KAAK,EAAE,QAAQ,UAAU,EAAE;AACjD,QAAM,QAAQ,qBAAqB,YAAY,OAAO;AACtD,SAAO,SAAS,WAAW,KAAK,IAAI,UAAU,eA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scapes"]}
@@ -2,7 +2,7 @@ import {
2
2
  PROXY_VARIANT_CONFIG,
3
3
  probeFirstFrameColour,
4
4
  probeMediaMetadata
5
- } from "./chunk-74JVVCWL.js";
5
+ } from "./chunk-RN33UALN.js";
6
6
  import {
7
7
  mkdirWithinProject,
8
8
  realProjectRoot,
@@ -491,4 +491,4 @@ export {
491
491
  proxyActivityMark,
492
492
  resolveProxy
493
493
  };
494
- //# sourceMappingURL=chunk-QP7LKFU2.js.map
494
+ //# sourceMappingURL=chunk-6EFY2WPN.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  PROXY_PARAMS_VERSION,
3
3
  resolveProxy
4
- } from "./chunk-QP7LKFU2.js";
4
+ } from "./chunk-6EFY2WPN.js";
5
5
  import {
6
6
  createMediaCodecProbeCache,
7
7
  proxyVariantFor,
8
8
  recordProxyPrewarm,
9
9
  scanProjectMediaCodecMap,
10
10
  shouldPrewarmProxy
11
- } from "./chunk-74JVVCWL.js";
11
+ } from "./chunk-RN33UALN.js";
12
12
 
13
13
  // src/helpers/mediaProxyPreview.ts
14
14
  import { resolve } from "path";
@@ -64,4 +64,4 @@ export {
64
64
  injectMediaCodecMapIntoHtml,
65
65
  injectMediaCodecMap
66
66
  };
67
- //# sourceMappingURL=chunk-5VCIZYUE.js.map
67
+ //# sourceMappingURL=chunk-AYKLBPP2.js.map
@@ -3,15 +3,15 @@ import {
3
3
  } from "./chunk-DTKK7TKL.js";
4
4
 
5
5
  // src/helpers/mediaCodecMap.ts
6
- import { existsSync, statSync } from "fs";
7
- import { relative, resolve, sep } from "path";
6
+ import { scanHtmlOpeningTags, decodeAuthoredAttribute } from "@hyperframes/parsers";
7
+ import { statSync } from "fs";
8
+ import { sep } from "path";
8
9
  import { rewriteAssetPath } from "@hyperframes/parsers/asset-paths";
9
10
  import {
10
11
  cleanAssetUrl,
11
12
  isRemoteOrInlineUrl,
12
13
  isUnresolvedAssetPlaceholder,
13
- maskNonScannableRanges,
14
- resolveLocalAssetCandidates
14
+ resolveExistingLocalAsset as resolveAsset
15
15
  } from "@hyperframes/parsers/asset-resolution";
16
16
 
17
17
  // src/helpers/mediaMetadata.ts
@@ -272,24 +272,22 @@ async function probeAssetCodec(filePath, runner, cache = defaultProbeCache) {
272
272
  rememberProbeResult(cache, filePath, { target, mtimeMs: stat.mtimeMs, size: stat.size, facts });
273
273
  return facts;
274
274
  }
275
- var VIDEO_SRC_RE = /<video\b[^>]*\bsrc\s*=\s*["']([^"']+)["'][^>]*>/gi;
276
275
  function resolveExistingLocalAsset(projectDir, url) {
277
- const projectRoot = resolve(projectDir);
278
- const resolvedPath = resolveLocalAssetCandidates(projectRoot, url).find(
279
- (candidate) => existsSync(candidate)
280
- );
281
- if (!resolvedPath) return null;
282
- const rootRelative = relative(projectRoot, resolvedPath).split(sep).join("/");
283
- return { resolvedPath, rootRelativePathname: `/${rootRelative}` };
276
+ const asset = resolveAsset(projectDir, url);
277
+ if (!asset) return null;
278
+ return {
279
+ resolvedPath: asset.resolved,
280
+ rootRelativePathname: `/${asset.rootRelativePath.split(sep).join("/")}`
281
+ };
284
282
  }
285
283
  function collectLocalVideoAssets(projectDir, htmlSources) {
286
284
  const candidates = /* @__PURE__ */ new Map();
287
285
  for (const { html, compSrcPath } of htmlSources) {
288
- const scannable = maskNonScannableRanges(html);
289
- const re = new RegExp(VIDEO_SRC_RE.source, VIDEO_SRC_RE.flags);
290
- let match;
291
- while ((match = re.exec(scannable)) !== null) {
292
- const rawSrc = match[1] ?? "";
286
+ for (const tag of scanHtmlOpeningTags(html)) {
287
+ if (tag.name !== "video" || !tag.closed) continue;
288
+ const attribute = tag.attributes.find((attr) => attr.name === "src");
289
+ if (attribute?.kind !== "value") continue;
290
+ const rawSrc = decodeAuthoredAttribute(attribute.value);
293
291
  if (isUnresolvedAssetPlaceholder(rawSrc)) continue;
294
292
  const src = cleanAssetUrl(rawSrc);
295
293
  if (!src || isRemoteOrInlineUrl(src)) continue;
@@ -346,4 +344,4 @@ export {
346
344
  probeAssetCodec,
347
345
  scanProjectMediaCodecMap
348
346
  };
349
- //# sourceMappingURL=chunk-74JVVCWL.js.map
347
+ //# sourceMappingURL=chunk-RN33UALN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/helpers/mediaCodecMap.ts","../src/helpers/mediaMetadata.ts"],"sourcesContent":["import { scanHtmlOpeningTags, decodeAuthoredAttribute } from \"@hyperframes/parsers\";\nimport { statSync } from \"node:fs\";\nimport { realpath } from \"./safePath.js\";\nimport { sep } from \"node:path\";\nimport { rewriteAssetPath } from \"@hyperframes/parsers/asset-paths\";\nimport {\n cleanAssetUrl,\n isRemoteOrInlineUrl,\n isUnresolvedAssetPlaceholder,\n resolveExistingLocalAsset as resolveAsset,\n} from \"@hyperframes/parsers/asset-resolution\";\nimport { pixelFormatHasAlpha, probeMediaMetadata, type FfprobeRunner } from \"./mediaMetadata.js\";\n\n/**\n * One reusable answer to \"what codec is this asset, and is it browser-hostile?\",\n * built on top of `mediaMetadata.ts`'s ffprobe-backed prober so studio-server\n * probes each asset once instead of running a second prober.\n */\n\nexport interface AssetCodecFacts {\n codecName: string;\n browserHostile: boolean;\n /** Coarse `canPlayType()` input; `null` when not applicable (safe codec) or\n * when no representative mime exists (ProRes: browsers never decode it, so\n * the runtime always proxies rather than probing `canPlayType`). */\n representativeMime: string | null;\n /** Source carries an alpha channel (ffprobe pix_fmt). Alpha sources use a\n * VP8/WebM proxy so their transparency is preserved across Chromium builds. */\n hasAlpha: boolean;\n}\n\n/** Server-root-relative URL pathname -> that asset's codec facts. */\nexport type MediaCodecMap = Record<string, AssetCodecFacts>;\n\nexport interface BrowserHostileCodec {\n /** Coarse `canPlayType()` input; `null` when no representative mime exists\n * (ProRes: browsers never decode it, so the runtime always proxies rather\n * than probing `canPlayType`). */\n representativeMime: string | null;\n /**\n * Whether the server may transcode before any browser asks. True only where\n * no cross-platform decode exists, so some client is sure to need the\n * substitute; false where the first `?hf-proxy=` request can do it lazily.\n */\n prewarm: boolean;\n}\n\n/**\n * Browser-hostile codec table v1. One exported constant so extending it is a\n * one-line change. `ffprobe` cannot emit exact RFC 6381 codec strings, so\n * these `representativeMime` values are deliberately coarse (a false\n * positive costs one proxy transcode, never correctness; a false negative is\n * rescued by the runtime's reactive zero-videoWidth swap).\n */\nexport const BROWSER_HOSTILE_CODECS: Record<string, BrowserHostileCodec> = {\n // HEVC decode is platform-bound, not absent: macOS Chrome answers\n // canPlayType with \"probably\" and keeps the source, while Chrome on\n // Windows/Linux and Firefox everywhere need the substitute.\n hevc: { representativeMime: 'video/mp4; codecs=\"hvc1.1.6.L120.B0\"', prewarm: true },\n prores: { representativeMime: null, prewarm: true },\n // Every mainstream engine decodes AV1 and VP9, so canPlayType keeps the\n // original and only the rare browser that cannot pays for a transcode.\n av1: { representativeMime: 'video/mp4; codecs=\"av01.0.08M.08\"', prewarm: false },\n vp9: { representativeMime: 'video/webm; codecs=\"vp09.00.10.08\"', prewarm: false },\n};\n\n/** `Object.hasOwn` rather than a bare index: a codec named `constructor` or\n * `toString` would otherwise resolve against `Object.prototype`. */\nfunction hostileCodecEntry(codecName: string): BrowserHostileCodec | undefined {\n return Object.hasOwn(BROWSER_HOSTILE_CODECS, codecName)\n ? BROWSER_HOSTILE_CODECS[codecName]\n : undefined;\n}\n\n/** The pre-warm gate: true only for codecs with no cross-platform browser\n * decode, so some client will ask. See `BrowserHostileCodec.prewarm`. */\nexport function shouldPrewarmProxy(facts: AssetCodecFacts): boolean {\n return hostileCodecEntry(facts.codecName)?.prewarm === true;\n}\n\n// Per process, and deliberately in one unit — a call to `resolveProxy` — so\n// the pair reads as a ratio. Summarised at exit on stderr, in the same\n// `[hyperframes:<area>] {json}` shape as `writeUrlDownloadTelemetry`.\nconst proxyDemand = { prewarmsRequested: 0, proxyRequests: 0 };\n\n/** Snapshot of this process's pre-warm demand counters. */\nexport function mediaProxyDemand(): { prewarmsRequested: number; proxyRequests: number } {\n return { ...proxyDemand };\n}\n\nfunction writeDemandLine(event: \"prewarm_requested\" | \"summary\"): void {\n try {\n process.stderr.write(\n `[hyperframes:media-proxy] ${JSON.stringify({ event, ...proxyDemand })}\\n`,\n );\n } catch {\n // Observability must never change proxy correctness.\n }\n}\n\n/** Mirrors `isGpuProbeDebugEnabled` in packages/engine/src/utils/gpuEncoder.ts. */\nfunction isMediaProxyDebugEnabled(): boolean {\n const value = process.env.HYPERFRAMES_DEBUG_MEDIA_PROXY;\n return value === \"1\" || value === \"true\";\n}\n\n// Registered on the first pre-warm rather than at import, so a process that\n// never pre-warms adds no handler and prints nothing. Sync-only, mirroring the\n// `process.on(\"exit\")` shutdown hooks in packages/cli/src/cli.ts:331 and\n// packages/cli/src/commands/preview.ts:1329.\nlet summaryHookInstalled = false;\n\n/**\n * One proxy asked for before any browser wanted it. \"Requested\", not\n * \"started\": a warm cache makes `resolveProxy` a no-op and this counter cannot\n * see that, so it is an upper bound on transcodes, not a measure of CPU. The\n * number it does answer exactly is the one that decides policy — a nonzero\n * count beside `proxyRequests: 0` means nothing ever redeemed the pre-warm.\n *\n * The per-asset line is debug-only: a composition with fifty hostile clips\n * would otherwise print fifty JSON lines into a clack-formatted terminal on\n * every re-render. The exit summary carries the same numbers unconditionally.\n */\nexport function recordProxyPrewarm(): void {\n proxyDemand.prewarmsRequested++;\n if (!summaryHookInstalled) {\n summaryHookInstalled = true;\n process.once(\"exit\", () => writeDemandLine(\"summary\"));\n }\n if (isMediaProxyDebugEnabled()) writeDemandLine(\"prewarm_requested\");\n}\n\n/** One proxy resolved for a browser that asked, counted on the path that calls\n * `resolveProxy` so it shares a unit with `prewarmsRequested`. A 304 does not\n * count; an unconditional Range refill still does, so read it as zero versus\n * nonzero. Never logged per event, only in the exit summary. */\nexport function recordProxyRequest(): void {\n proxyDemand.proxyRequests++;\n}\n\nexport type ProxyVariant = \"h264\" | \"vp8\";\nexport type ProxyVariantRequest = ProxyVariant | \"auto\";\n\nexport const PROXY_VARIANT_CONFIG: Record<\n ProxyVariant,\n { extension: \".mp4\" | \".webm\"; contentType: \"video/mp4\" | \"video/webm\" }\n> = {\n h264: { extension: \".mp4\", contentType: \"video/mp4\" },\n vp8: { extension: \".webm\", contentType: \"video/webm\" },\n};\n\nexport function isProxyVariant(value: string): value is ProxyVariant {\n return Object.hasOwn(PROXY_VARIANT_CONFIG, value);\n}\n\nexport function isProxyVariantRequest(value: string): value is ProxyVariantRequest {\n return value === \"auto\" || isProxyVariant(value);\n}\n\nexport function proxyVariantFor(facts: AssetCodecFacts): ProxyVariant {\n return facts.hasAlpha ? \"vp8\" : \"h264\";\n}\n\nexport function resolveProxyVariantRequest(\n request: ProxyVariantRequest,\n facts: AssetCodecFacts,\n): ProxyVariant | null {\n const expected = proxyVariantFor(facts);\n return request === \"auto\" || request === expected ? expected : null;\n}\n\nexport type MediaProxyIneligibilityReason = \"browser_safe_codec\" | \"unknown_codec\";\n\nexport type MediaProxyEligibility =\n | { eligible: true }\n | { eligible: false; reason: MediaProxyIneligibilityReason };\n\n/** Single policy gate shared by proactive scans and on-demand proxy routes. */\nexport function decideMediaProxyEligibility(facts: AssetCodecFacts | null): MediaProxyEligibility {\n if (!facts) return { eligible: false, reason: \"unknown_codec\" };\n if (!facts.browserHostile) return { eligible: false, reason: \"browser_safe_codec\" };\n return { eligible: true };\n}\n\nfunction codecFactsFor(codecName: string, hasAlpha: boolean): AssetCodecFacts {\n const hostile = hostileCodecEntry(codecName);\n return {\n codecName,\n browserHostile: hostile !== undefined,\n representativeMime: hostile?.representativeMime ?? null,\n hasAlpha,\n };\n}\n\n/** `undefined` when ffprobe itself failed: no answer about the file, so nothing to cache. */\nasync function probeCodecFacts(\n filePath: string,\n runner?: FfprobeRunner,\n): Promise<AssetCodecFacts | null | undefined> {\n const metadata = runner\n ? await probeMediaMetadata(filePath, runner)\n : await probeMediaMetadata(filePath);\n if (metadata.probeError) return undefined;\n if (metadata.kind !== \"video\") return null;\n const codecName = metadata.color.codecName;\n if (!codecName) return null;\n return codecFactsFor(codecName, pixelFormatHasAlpha(metadata.color.pixelFormat));\n}\n\ninterface CachedAssetProbe {\n /** The file a symlinked path pointed at, so retargeting the link is a miss. */\n target: string;\n mtimeMs: number;\n size: number;\n facts: AssetCodecFacts | null;\n}\n\n/** Per (path, mtime) probe cache. Construct one per project/server lifetime\n * and reuse it across scans; a fresh instance defeats the caching benefit. */\nexport type MediaCodecProbeCache = Map<string, CachedAssetProbe>;\n\nexport function createMediaCodecProbeCache(): MediaCodecProbeCache {\n return new Map();\n}\n\n// Shared by every route and scan in this process that does not pass its own cache.\nconst defaultProbeCache: MediaCodecProbeCache = new Map();\nconst MAX_PROBE_CACHE_ENTRIES = 512;\n\nfunction rememberProbeResult(\n cache: MediaCodecProbeCache,\n filePath: string,\n result: CachedAssetProbe,\n): void {\n if (!cache.has(filePath) && cache.size >= MAX_PROBE_CACHE_ENTRIES) {\n const oldest = cache.keys().next().value;\n if (oldest) cache.delete(oldest);\n }\n // Refresh insertion order so frequently used assets remain resident.\n cache.delete(filePath);\n cache.set(filePath, result);\n}\n\n/**\n * Codec facts for one video, cached per path until its target, mtime or size changes; a hit skips\n * `runner`. Never throws: no video stream or a failed probe gives `null`, and a failed probe is not cached.\n */\nexport async function probeAssetCodec(\n filePath: string,\n runner?: FfprobeRunner,\n cache: MediaCodecProbeCache = defaultProbeCache,\n): Promise<AssetCodecFacts | null> {\n let stat: ReturnType<typeof statSync>;\n let target: string;\n try {\n stat = statSync(filePath);\n target = realpath(filePath);\n } catch {\n return null;\n }\n const cached = cache.get(filePath);\n if (\n cached &&\n cached.target === target &&\n cached.mtimeMs === stat.mtimeMs &&\n cached.size === stat.size\n ) {\n rememberProbeResult(cache, filePath, cached);\n return cached.facts;\n }\n const facts = await probeCodecFacts(filePath, runner);\n if (facts === undefined) return null;\n rememberProbeResult(cache, filePath, { target, mtimeMs: stat.mtimeMs, size: stat.size, facts });\n return facts;\n}\n\n/** Structurally compatible with `packages/lint/src/hevcPreviewLint.ts`'s\n * (unexported) `HtmlSourceLike`. */\nexport interface HtmlSourceLike {\n html: string;\n compSrcPath?: string;\n}\n\n/**\n * Resolve a `<video src>` reference to an existing local file.\n *\n * `rootRelativePathname` is the map key format PINNED by this plan's Key\n * Technical Decisions: project-root-relative URL pathname, percent-decoded,\n * query-string-stripped, forward-slash separated, leading-slash prefixed\n * (e.g. \"/assets/videos/clip.mp4\"). This must match what the runtime derives\n * via `new URL(el.currentSrc || el.src, document.baseURI).pathname`, because\n * server-side scanning resolves filesystem paths while the DOM sees served\n * URLs — a documented prior source of this exact class of bug.\n */\nfunction resolveExistingLocalAsset(\n projectDir: string,\n url: string,\n): { resolvedPath: string; rootRelativePathname: string } | null {\n const asset = resolveAsset(projectDir, url);\n if (!asset) return null;\n return {\n resolvedPath: asset.resolved,\n rootRelativePathname: `/${asset.rootRelativePath.split(sep).join(\"/\")}`,\n };\n}\n\n/**\n * Collects local `<video src>` references, resolved to their absolute path\n * and deduped by that path, keyed by the pinned root-relative URL pathname.\n */\n// fallow-ignore-next-line complexity\nfunction collectLocalVideoAssets(\n projectDir: string,\n htmlSources: HtmlSourceLike[],\n): Map<string, string> {\n const candidates = new Map<string, string>();\n\n for (const { html, compSrcPath } of htmlSources) {\n for (const tag of scanHtmlOpeningTags(html)) {\n if (tag.name !== \"video\" || !tag.closed) continue;\n const attribute = tag.attributes.find((attr) => attr.name === \"src\");\n if (attribute?.kind !== \"value\") continue;\n const rawSrc = decodeAuthoredAttribute(attribute.value);\n // Placeholder check runs on the RAW value: cleanAssetUrl() splits on ?/# and would chop inside a ${...} token.\n if (isUnresolvedAssetPlaceholder(rawSrc)) continue;\n const src = cleanAssetUrl(rawSrc);\n if (!src || isRemoteOrInlineUrl(src)) continue;\n const rootRelativeSrc = compSrcPath ? rewriteAssetPath(compSrcPath, src) : src;\n const resolved = resolveExistingLocalAsset(projectDir, rootRelativeSrc);\n if (!resolved) continue;\n candidates.set(resolved.resolvedPath, resolved.rootRelativePathname);\n }\n }\n\n return candidates;\n}\n\n// Bounds concurrent ffprobe child processes for projects referencing many\n// videos, mirroring `PROBE_CONCURRENCY` in `hevcPreviewLint.ts`.\nconst PROBE_CONCURRENCY = 8;\n\nexport interface ScanProjectMediaCodecMapOptions {\n /** Persisted across calls by the caller for the mtime-cache benefit;\n * defaults to a shared module-level cache when omitted. */\n cache?: MediaCodecProbeCache;\n runner?: FfprobeRunner;\n}\n\n/**\n * Scans a project's composition HTML for local `<video src>` references and\n * returns the injection map: root-relative URL pathname -> codec facts.\n * Best-effort throughout — a video whose codec can't be determined (missing\n * ffprobe, probe error, no video stream) is simply omitted, never thrown.\n */\nexport async function scanProjectMediaCodecMap(\n projectDir: string,\n htmlSources: HtmlSourceLike[],\n options: ScanProjectMediaCodecMapOptions = {},\n): Promise<MediaCodecMap> {\n const candidates = collectLocalVideoAssets(projectDir, htmlSources);\n if (candidates.size === 0) return {};\n\n const cache = options.cache ?? defaultProbeCache;\n const entries = [...candidates.entries()]; // [resolvedPath, rootRelativePathname]\n const facts = new Array<AssetCodecFacts | null>(entries.length).fill(null);\n let nextIndex = 0;\n const workerCount = Math.min(PROBE_CONCURRENCY, entries.length);\n await Promise.all(\n Array.from({ length: workerCount }, async () => {\n while (nextIndex < entries.length) {\n const index = nextIndex++;\n const entry = entries[index];\n if (!entry) break;\n facts[index] = await probeAssetCodec(entry[0], options.runner, cache);\n }\n }),\n );\n\n const map: MediaCodecMap = {};\n entries.forEach(([, pathname], index) => {\n const entryFacts = facts[index];\n if (entryFacts?.browserHostile) map[pathname] = entryFacts;\n });\n return map;\n}\n","import { execFile } from \"node:child_process\";\nimport { extname } from \"node:path\";\nimport {\n firstFrameColourArgs,\n parseFirstFrameColour,\n type ToneMapSourceColour,\n} from \"@hyperframes/core\";\nimport { findFfBinary } from \"@hyperframes/parsers/ff-binaries\";\n\nexport interface FfprobeRunResult {\n status: number | null;\n stdout: string | Buffer;\n stderr: string | Buffer;\n /** Spawn-level failure (covers both `NodeJS.ErrnoException` and\n * `ExecFileException`); only `code === \"ENOENT\"` is ever inspected. */\n error?: { code?: string | number | null | undefined };\n}\n\n/** Injectable ffprobe runner. May be synchronous (tests) or async (the\n * default `execFile`-based runner below), so cold scans can run many probes\n * concurrently off the event loop. */\nexport type FfprobeRunner = (\n command: string,\n args: string[],\n options?: { timeout?: number; maxBuffer?: number },\n) => FfprobeRunResult | Promise<FfprobeRunResult>;\n\n/** Default runner: genuinely async (`execFile`), unlike the previous\n * `spawnSync`-based one — a pool of concurrent probes actually parallelizes\n * (mirrors `execFileAsync` in packages/lint/src/hevcPreviewLint.ts). */\nconst execFileRunner: FfprobeRunner = (command, args, options) =>\n new Promise<FfprobeRunResult>((resolvePromise) => {\n execFile(\n command,\n args,\n { timeout: options?.timeout, maxBuffer: options?.maxBuffer, windowsHide: true },\n (error, stdout, stderr) => {\n if (error && error.code === \"ENOENT\") {\n resolvePromise({ status: null, stdout: \"\", stderr: \"\", error });\n return;\n }\n if (error) {\n // Nonzero exit / timeout / kill: report a nonzero status; callers\n // only distinguish \"ok\" (0) from \"failed\" from \"ENOENT\".\n const status = typeof error.code === \"number\" ? error.code : 1;\n resolvePromise({ status, stdout: stdout ?? \"\", stderr: stderr ?? \"\" });\n return;\n }\n resolvePromise({ status: 0, stdout: stdout ?? \"\", stderr: stderr ?? \"\" });\n },\n );\n });\n\nexport type MediaDynamicRange = \"hdr\" | \"sdr\" | \"unknown\";\nexport type MediaHdrTransfer = \"pq\" | \"hlg\" | \"unknown\";\n\nexport interface MediaColorMetadata {\n dynamicRange: MediaDynamicRange;\n hdrTransfer: MediaHdrTransfer | null;\n label: string;\n isHdr: boolean;\n codecName?: string;\n profile?: string;\n pixelFormat?: string;\n colorSpace?: string;\n colorTransfer?: string;\n colorPrimaries?: string;\n bitsPerRawSample?: string;\n}\n\nexport interface MediaMetadata {\n kind: \"video\" | \"image\" | \"audio\" | \"unknown\";\n color: MediaColorMetadata;\n /** Video audio stream, when probed. Absent means the drop path stays muted. */\n hasAudio?: boolean;\n probeError?: string;\n}\n\ninterface FfprobeStream {\n codec_type?: string;\n codec_name?: string;\n profile?: string;\n pix_fmt?: string;\n color_space?: string;\n color_transfer?: string;\n color_primaries?: string;\n bits_per_raw_sample?: string;\n disposition?: { attached_pic?: number };\n}\n\nconst VIDEO_EXT = new Set([\n \".mp4\",\n \".mov\",\n \".webm\",\n \".mkv\",\n \".avi\",\n \".m4v\",\n \".mxf\",\n \".mts\",\n \".m2ts\",\n \".ts\",\n]);\nconst IMAGE_EXT = new Set([\".jpg\", \".jpeg\", \".png\", \".webp\", \".avif\"]);\nconst AUDIO_EXT = new Set([\".mp3\", \".wav\", \".ogg\", \".m4a\", \".aac\", \".flac\"]);\n\nfunction lower(value: string | undefined): string {\n return value?.toLowerCase() ?? \"\";\n}\n\nfunction inferKindFromPath(path: string): MediaMetadata[\"kind\"] {\n const ext = extname(path).toLowerCase();\n if (VIDEO_EXT.has(ext)) return \"video\";\n if (IMAGE_EXT.has(ext)) return \"image\";\n if (AUDIO_EXT.has(ext)) return \"audio\";\n return \"unknown\";\n}\n\nfunction colorLabel(input: {\n isHdr: boolean;\n hdrTransfer: MediaHdrTransfer | null;\n colorPrimaries: string;\n colorSpace: string;\n colorTransfer: string;\n}): string {\n if (input.isHdr) {\n if (input.hdrTransfer === \"pq\") return \"HDR PQ\";\n if (input.hdrTransfer === \"hlg\") return \"HDR HLG\";\n return \"HDR\";\n }\n if (\n input.colorPrimaries.includes(\"bt709\") ||\n input.colorSpace.includes(\"bt709\") ||\n input.colorTransfer.includes(\"bt709\")\n ) {\n return \"SDR Rec.709\";\n }\n return \"SDR/unknown\";\n}\n\n// Conservative alpha-bearing pix_fmt list: yuva* (yuva420p, yuva444p10le...),\n// rgba/argb/bgra/abgr (packed RGB+alpha), gbrap* (planar GBR+alpha, ProRes\n// 4444 decodes to these), ya* (gray+alpha). Prefix match keeps bit-depth /\n// endianness suffixes covered.\nconst ALPHA_PIX_FMT_RE = /^(?:yuva|rgba|argb|bgra|abgr|gbrap|ya)/;\n\n/** True when an ffprobe `pix_fmt` carries an alpha component. */\nexport function pixelFormatHasAlpha(pixFmt: string | undefined): boolean {\n return pixFmt !== undefined && ALPHA_PIX_FMT_RE.test(pixFmt.toLowerCase());\n}\n\nexport function classifyMediaColor(stream: FfprobeStream | null | undefined): MediaColorMetadata {\n const colorPrimaries = lower(stream?.color_primaries);\n const colorSpace = lower(stream?.color_space);\n const colorTransfer = lower(stream?.color_transfer);\n const isHdr =\n colorPrimaries.includes(\"bt2020\") ||\n colorSpace.includes(\"bt2020\") ||\n colorTransfer === \"smpte2084\" ||\n colorTransfer === \"arib-std-b67\";\n const hdrTransfer: MediaHdrTransfer | null = isHdr\n ? colorTransfer === \"smpte2084\"\n ? \"pq\"\n : colorTransfer === \"arib-std-b67\"\n ? \"hlg\"\n : \"unknown\"\n : null;\n\n return {\n dynamicRange: stream ? (isHdr ? \"hdr\" : \"sdr\") : \"unknown\",\n hdrTransfer,\n label: stream\n ? colorLabel({ isHdr, hdrTransfer, colorPrimaries, colorSpace, colorTransfer })\n : \"Unknown\",\n isHdr,\n codecName: stream?.codec_name,\n profile: stream?.profile,\n pixelFormat: stream?.pix_fmt,\n colorSpace: stream?.color_space,\n colorTransfer: stream?.color_transfer,\n colorPrimaries: stream?.color_primaries,\n bitsPerRawSample: stream?.bits_per_raw_sample,\n };\n}\n\n/** The first shown frame's colour tags, which zscale reads per frame. Empty when unread. */\nexport async function probeFirstFrameColour(\n filePath: string,\n runner: FfprobeRunner = execFileRunner,\n): Promise<ToneMapSourceColour> {\n const ffmpegPath =\n findFfBinary(\"ffmpeg\", { configuredMustExist: true }) ??\n (runner === execFileRunner ? undefined : \"ffmpeg\");\n if (!ffmpegPath) return {};\n const result = await runner(ffmpegPath, firstFrameColourArgs(filePath), {\n timeout: 15_000,\n maxBuffer: 1024 * 1024,\n });\n return result.status === 0 ? parseFirstFrameColour(String(result.stderr)) : {};\n}\n\nexport async function probeMediaMetadata(\n filePath: string,\n runner: FfprobeRunner = execFileRunner,\n): Promise<MediaMetadata> {\n const kind = inferKindFromPath(filePath);\n if (kind === \"audio\" || kind === \"unknown\") {\n return { kind, color: classifyMediaColor(null) };\n }\n\n // The default runner degrades a missing ffprobe to \"unavailable\" without\n // spawning; injected runners own execution and receive the normal command.\n const ffprobePath =\n findFfBinary(\"ffprobe\", { configuredMustExist: true }) ??\n (runner === execFileRunner ? undefined : \"ffprobe\");\n if (!ffprobePath) {\n return { kind, color: classifyMediaColor(null), probeError: \"ffprobe unavailable\" };\n }\n\n const result = await runner(\n ffprobePath,\n [\n \"-v\",\n \"error\",\n \"-show_entries\",\n \"stream=codec_type,codec_name,profile,pix_fmt,color_space,color_transfer,color_primaries,bits_per_raw_sample:stream_disposition=attached_pic\",\n \"-of\",\n \"json\",\n \"--\",\n filePath,\n ],\n { timeout: 15_000, maxBuffer: 1024 * 1024 },\n );\n\n if (result.error?.code === \"ENOENT\") {\n return { kind, color: classifyMediaColor(null), probeError: \"ffprobe unavailable\" };\n }\n if (result.status !== 0) {\n return { kind, color: classifyMediaColor(null), probeError: \"ffprobe failed\" };\n }\n\n try {\n const parsed = JSON.parse(String(result.stdout || \"{}\")) as { streams?: FfprobeStream[] };\n const stream = parsed.streams?.find((item) => {\n if (kind === \"image\") return item.codec_type === \"video\";\n return item.codec_type === kind && item.disposition?.attached_pic !== 1;\n });\n const metadata: MediaMetadata = { kind, color: classifyMediaColor(stream) };\n if (kind === \"video\") {\n metadata.hasAudio = (parsed.streams ?? []).some((item) => item.codec_type === \"audio\");\n }\n return metadata;\n } catch {\n return { kind, color: classifyMediaColor(null), probeError: \"ffprobe returned invalid json\" };\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,qBAAqB,+BAA+B;AAC7D,SAAS,gBAAgB;AAEzB,SAAS,WAAW;AACpB,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,6BAA6B;AAAA,OACxB;;;ACVP,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,oBAA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;AACvC,UAAM,aAAa,MAAM,KAAK;AAC9B,QAAI,YAAY,eAAgB,KAAI,QAAQ,IAAI;AAAA,EAClD,CAAC;AACD,SAAO;AACT;","names":[]}
@@ -11,7 +11,10 @@ import {
11
11
  requiredFfmpeg,
12
12
  resolveLocalAudioPath,
13
13
  updateAudioVolume
14
- } from "../chunk-DSVQ2U7J.js";
14
+ } from "../chunk-32IH7WBY.js";
15
+ import "../chunk-DTKK7TKL.js";
16
+ import "../chunk-6XMC64FJ.js";
17
+ import "../chunk-4ETS2LXI.js";
15
18
  export {
16
19
  DEFAULT_TARGET_LUFS,
17
20
  NORMALIZE_TRUE_PEAK_CEILING_DBFS,
@@ -13,7 +13,7 @@ import {
13
13
  resolveProxyVariantRequest,
14
14
  scanProjectMediaCodecMap,
15
15
  shouldPrewarmProxy
16
- } from "../chunk-74JVVCWL.js";
16
+ } from "../chunk-RN33UALN.js";
17
17
  import "../chunk-DTKK7TKL.js";
18
18
  import "../chunk-6XMC64FJ.js";
19
19
  import "../chunk-4ETS2LXI.js";
@@ -4,9 +4,9 @@ import {
4
4
  isAutoProxyEnabled,
5
5
  proxyEtagSalt,
6
6
  resolvePreviewMediaCodecProbeCache
7
- } from "../chunk-5VCIZYUE.js";
8
- import "../chunk-QP7LKFU2.js";
9
- import "../chunk-74JVVCWL.js";
7
+ } from "../chunk-AYKLBPP2.js";
8
+ import "../chunk-6EFY2WPN.js";
9
+ import "../chunk-RN33UALN.js";
10
10
  import "../chunk-DTKK7TKL.js";
11
11
  import "../chunk-6XMC64FJ.js";
12
12
  import "../chunk-4ETS2LXI.js";
@@ -14,8 +14,8 @@ import {
14
14
  proxyActivityMark,
15
15
  resolveProxy,
16
16
  waitForProxy
17
- } from "../chunk-QP7LKFU2.js";
18
- import "../chunk-74JVVCWL.js";
17
+ } from "../chunk-6EFY2WPN.js";
18
+ import "../chunk-RN33UALN.js";
19
19
  import "../chunk-DTKK7TKL.js";
20
20
  import "../chunk-6XMC64FJ.js";
21
21
  import "../chunk-4ETS2LXI.js";
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export { PatchOperation, dedupeClonedCompositionId, findTargetElement, parseSour
11
11
  export { ScreenshotClip, clearElementScreenshotIsolation, getElementScreenshotClip } from './helpers/screenshotClip.js';
12
12
  export { STUDIO_MANUAL_EDITS_PATH, StudioManualEditsRenderScriptOptions, createStudioManualEditsRenderBodyScript, createStudioPositionSeekReapplyScript } from './helpers/manualEditsRenderScript.js';
13
13
  export { STUDIO_MOTION_PATH, StudioMotionRenderScriptOptions, createStudioMotionRenderBodyScript } from './helpers/studioMotionRenderScript.js';
14
+ export { decodeWellFormedEscapes } from '@hyperframes/parsers/asset-paths';
14
15
  export { isSafePath } from '@hyperframes/core/safe-path';
15
16
  import '@hyperframes/core';
16
17
  import '@hyperframes/parsers';