feat: integrate authored nightdrive soundtrack
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export const PERFORMANCE_BUDGETS: Readonly<Record<string, number>>;
|
||||
export function normalizeDetectedMediaType(mediaType: string | null | undefined): string | null;
|
||||
export function resolveBudgetGateMode(options: {
|
||||
transferOnly: boolean;
|
||||
runtimeTracePath: string | null;
|
||||
@@ -11,7 +12,7 @@ export function evaluateMediaAssetBudget(
|
||||
asset: Readonly<Record<string, unknown>>,
|
||||
probe: Readonly<Record<string, unknown>> | null,
|
||||
transferBytes: number,
|
||||
assetClass?: 'chart' | 'project-still',
|
||||
assetClass?: 'chart' | 'project-still' | 'soundtrack-audio',
|
||||
): { violations: Array<{ budget: string; actual: number; threshold: number; id?: string }> };
|
||||
export function evaluateRuntimeBudgetEvidence(evidence: Readonly<Record<string, unknown>>): {
|
||||
tiers: Array<{ tier: string; textureBytes: number; geometryBytes: number; renderTargetBytes: number; runtimeAllowanceBytes: number; totalBytes: number }>;
|
||||
|
||||
@@ -13,6 +13,7 @@ export const PERFORMANCE_BUDGETS = Object.freeze({
|
||||
deferredProjectVisuals: 2.5 * 1024 * 1024,
|
||||
highTierExtras: 750 * 1024,
|
||||
deferredNonVideo: 3.5 * 1024 * 1024,
|
||||
deferredAudio: 13 * 1024 * 1024,
|
||||
imageSceneConcurrency: 2,
|
||||
videoConcurrency: 1,
|
||||
mobileTextureDimension: 2048,
|
||||
@@ -20,6 +21,10 @@ export const PERFORMANCE_BUDGETS = Object.freeze({
|
||||
highTierGpuEstimate: 192 * 1024 * 1024,
|
||||
});
|
||||
|
||||
export const normalizeDetectedMediaType = (mediaType) => (
|
||||
typeof mediaType === 'string' ? mediaType.split(';', 1)[0].trim() : null
|
||||
);
|
||||
|
||||
export const resolveBudgetGateMode = ({ transferOnly, runtimeTracePath }) => {
|
||||
if (transferOnly && runtimeTracePath !== null) throw new Error('Transfer-only mode cannot be combined with runtime evidence.');
|
||||
if (transferOnly) return { kind: 'transfer-only' };
|
||||
@@ -39,6 +44,7 @@ export const classifyArtifact = (path, source = '') => {
|
||||
if (/^assets\/project-[^/]+\.(?:webm|mp4)$/u.test(path)) return 'project-video';
|
||||
if (/^assets\/project-[^/]*chart[^/]*\.(?:avif|webp|png|jpe?g)$/u.test(path)) return 'chart';
|
||||
if (/^assets\/project-[^/]+\.(?:avif|webp|png|jpe?g|svg)$/u.test(path)) return 'project-still';
|
||||
if (/^assets\/nightdrive-(?:intro|main)\.(?:opus|mp3)$/u.test(path)) return 'soundtrack-audio';
|
||||
if (/^(?:robots\.txt|sitemap\.xml|_headers\.example|_redirects\.example)$/u.test(path)) return 'release-metadata';
|
||||
throw new Error(`Artifact is unclassified: ${path}`);
|
||||
};
|
||||
@@ -51,6 +57,7 @@ const thresholdByTotal = Object.freeze({
|
||||
firstLiveScene: PERFORMANCE_BUDGETS.firstLiveScene,
|
||||
deferredProjectVisuals: PERFORMANCE_BUDGETS.deferredProjectVisuals,
|
||||
deferredNonVideo: PERFORMANCE_BUDGETS.deferredNonVideo,
|
||||
deferredAudio: PERFORMANCE_BUDGETS.deferredAudio,
|
||||
highTierExtras: PERFORMANCE_BUDGETS.highTierExtras,
|
||||
});
|
||||
|
||||
@@ -63,13 +70,34 @@ export const evaluateBudgetTotals = (totals) => ({
|
||||
const violation = (budget, actual, threshold, id) => ({ budget, actual, threshold, ...(id === undefined ? {} : { id }) });
|
||||
const finitePositiveInteger = (value) => Number.isInteger(value) && value > 0;
|
||||
|
||||
export const evaluateMediaAssetBudget = (asset, probe, transferBytes, assetClass = undefined) => {
|
||||
export const evaluateMediaAssetBudget = (
|
||||
asset,
|
||||
probe,
|
||||
transferBytes,
|
||||
assetClass = /** @type {'chart' | 'project-still' | 'soundtrack-audio' | undefined} */ (undefined),
|
||||
) => {
|
||||
if (probe === null || typeof probe !== 'object') throw new Error(`Media probe evidence is required for ${asset?.id ?? 'unknown asset'}.`);
|
||||
if (assetClass === 'soundtrack-audio' && !asset?.mediaType?.startsWith('audio/')) {
|
||||
throw new Error(`Soundtrack classification requires audio media for ${asset?.id ?? 'unknown asset'}.`);
|
||||
}
|
||||
if (asset?.mediaType !== probe.mediaType) {
|
||||
throw new Error(`Manifest and probe evidence disagree for ${asset?.id ?? 'unknown asset'}.`);
|
||||
}
|
||||
if (asset.mediaType.startsWith('audio/')) {
|
||||
if (asset.width !== null || asset.height !== null || probe.width !== null || probe.height !== null) {
|
||||
throw new Error(`Audio dimensions must be null for ${asset.id}.`);
|
||||
}
|
||||
if (!finitePositiveInteger(asset.durationMs) || !finitePositiveInteger(probe.durationMs)
|
||||
|| Math.abs(asset.durationMs - probe.durationMs) > 100) {
|
||||
throw new Error(`Verified duration is required for ${asset.id}.`);
|
||||
}
|
||||
return { violations: [] };
|
||||
}
|
||||
if (!finitePositiveInteger(asset?.width) || !finitePositiveInteger(asset?.height)
|
||||
|| !finitePositiveInteger(probe.width) || !finitePositiveInteger(probe.height)) {
|
||||
throw new Error(`Verified dimensions are required for ${asset?.id ?? 'unknown asset'}.`);
|
||||
}
|
||||
if (asset.width !== probe.width || asset.height !== probe.height || asset.mediaType !== probe.mediaType) {
|
||||
if (asset.width !== probe.width || asset.height !== probe.height) {
|
||||
throw new Error(`Manifest and probe evidence disagree for ${asset.id}.`);
|
||||
}
|
||||
const violations = [];
|
||||
|
||||
Reference in New Issue
Block a user