@mux/ai 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-0a27mjs2.d.ts → index-C5zhbQHK.d.ts} +15 -15
- package/dist/index.d.ts +2 -2
- package/dist/index.js +62 -12
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.js +5 -4
- package/dist/primitives/index.js.map +1 -1
- package/dist/workflows/index.d.ts +1 -1
- package/dist/workflows/index.js +61 -11
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -592,11 +592,11 @@ declare const chapterSchema: z.ZodObject<{
|
|
|
592
592
|
startTime: z.ZodNumber;
|
|
593
593
|
title: z.ZodString;
|
|
594
594
|
}, "strip", z.ZodTypeAny, {
|
|
595
|
-
startTime: number;
|
|
596
595
|
title: string;
|
|
597
|
-
}, {
|
|
598
596
|
startTime: number;
|
|
597
|
+
}, {
|
|
599
598
|
title: string;
|
|
599
|
+
startTime: number;
|
|
600
600
|
}>;
|
|
601
601
|
type Chapter = z.infer<typeof chapterSchema>;
|
|
602
602
|
declare const chaptersSchema: z.ZodObject<{
|
|
@@ -604,21 +604,21 @@ declare const chaptersSchema: z.ZodObject<{
|
|
|
604
604
|
startTime: z.ZodNumber;
|
|
605
605
|
title: z.ZodString;
|
|
606
606
|
}, "strip", z.ZodTypeAny, {
|
|
607
|
-
startTime: number;
|
|
608
607
|
title: string;
|
|
609
|
-
}, {
|
|
610
608
|
startTime: number;
|
|
609
|
+
}, {
|
|
611
610
|
title: string;
|
|
611
|
+
startTime: number;
|
|
612
612
|
}>, "many">;
|
|
613
613
|
}, "strip", z.ZodTypeAny, {
|
|
614
614
|
chapters: {
|
|
615
|
-
startTime: number;
|
|
616
615
|
title: string;
|
|
616
|
+
startTime: number;
|
|
617
617
|
}[];
|
|
618
618
|
}, {
|
|
619
619
|
chapters: {
|
|
620
|
-
startTime: number;
|
|
621
620
|
title: string;
|
|
621
|
+
startTime: number;
|
|
622
622
|
}[];
|
|
623
623
|
}>;
|
|
624
624
|
type ChaptersType = z.infer<typeof chaptersSchema>;
|
|
@@ -834,12 +834,14 @@ declare function censorVttContent(rawVtt: string, profanity: string[], mode: Cen
|
|
|
834
834
|
*/
|
|
835
835
|
declare function applyOverrideLists(detected: string[], alwaysCensor: string[], neverCensor: string[]): string[];
|
|
836
836
|
/**
|
|
837
|
-
* Applies static find/replace pairs to cue text
|
|
838
|
-
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
841
|
-
*
|
|
842
|
-
*
|
|
837
|
+
* Applies static find/replace pairs to cue text blocks in raw VTT content.
|
|
838
|
+
* Whitespace in the find string can match VTT line wrapping, and word-character
|
|
839
|
+
* edges are constrained to avoid replacing substrings inside words.
|
|
840
|
+
* Defaults to case-sensitive matching since static replacements typically
|
|
841
|
+
* target specific known strings; each entry may opt into case-insensitive
|
|
842
|
+
* matching via `caseSensitive: false`. Headers, timestamps, and cue
|
|
843
|
+
* identifiers are untouched. Returns the edited VTT and the total number of
|
|
844
|
+
* replacements.
|
|
843
845
|
*/
|
|
844
846
|
declare function applyReplacements(rawVtt: string, replacements: CaptionReplacement[]): {
|
|
845
847
|
editedVtt: string;
|
|
@@ -896,8 +898,6 @@ interface MomentInsight {
|
|
|
896
898
|
startMs: number;
|
|
897
899
|
/** End time in milliseconds */
|
|
898
900
|
endMs: number;
|
|
899
|
-
/** Human-readable timestamp (e.g., "2:15") */
|
|
900
|
-
timestamp: string;
|
|
901
901
|
/** Normalized engagement score (0-1) */
|
|
902
902
|
engagementScore: number;
|
|
903
903
|
/** Primary insight explaining the engagement pattern */
|
|
@@ -968,7 +968,7 @@ declare function mapShotsToHotspots(shots: Shot[], hotspots: Hotspot[]): string[
|
|
|
968
968
|
* });
|
|
969
969
|
*
|
|
970
970
|
* result.momentInsights.forEach(m => {
|
|
971
|
-
* console.log(`${m.
|
|
971
|
+
* console.log(`${m.startMs}ms: ${m.insight}`);
|
|
972
972
|
* });
|
|
973
973
|
* ```
|
|
974
974
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-
|
|
1
|
+
export { I as ISO639_1, a as ISO639_3, L as LanguageCodePair, S as SupportedISO639_1, b as SupportedISO639_3, g as getLanguageCodePair, c as getLanguageName, i as isUndeterminedLanguageCode, d as isValidISO639_1, e as isValidISO639_3, t as toISO639_1, f as toISO639_3, h as workflows } from './index-C5zhbQHK.js';
|
|
2
2
|
import { W as WorkflowCredentials, S as StoragePutObjectInput, a as StoragePresignGetObjectInput } from './shots-mGJfYGiO.js';
|
|
3
3
|
export { A as AssetTextTrack, C as ChunkEmbedding, b as ChunkingStrategy, E as Encrypted, c as EncryptedPayload, I as ImageSubmissionMode, M as MuxAIOptions, d as MuxAsset, P as PlaybackAsset, e as PlaybackPolicy, f as StorageAdapter, T as TextChunk, g as TokenChunkingConfig, h as TokenUsage, i as ToneType, U as UsageMetadata, V as VTTChunkingConfig, j as VideoEmbeddingsResult, k as WorkflowCredentialsInput, l as WorkflowMuxClient, m as decryptFromWorkflow, n as encryptForWorkflow } from './shots-mGJfYGiO.js';
|
|
4
4
|
import { WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE } from '@workflow/serde';
|
|
@@ -9,7 +9,7 @@ import '@ai-sdk/google';
|
|
|
9
9
|
import '@ai-sdk/openai';
|
|
10
10
|
import '@mux/mux-node';
|
|
11
11
|
|
|
12
|
-
var version = "0.
|
|
12
|
+
var version = "0.24.0";
|
|
13
13
|
|
|
14
14
|
type MuxAiErrorType = "validation_error" | "processing_error" | "timeout_error";
|
|
15
15
|
/**
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.
|
|
8
|
+
var version = "0.24.0";
|
|
9
9
|
|
|
10
10
|
// src/lib/language-codes.ts
|
|
11
11
|
var ISO639_1_TO_3 = {
|
|
@@ -1602,12 +1602,12 @@ function getShotsPath(assetId) {
|
|
|
1602
1602
|
}
|
|
1603
1603
|
function mapManifestShots(shots) {
|
|
1604
1604
|
return shots.map((shot, index) => {
|
|
1605
|
-
const { startTime, imageUrl } = shot;
|
|
1605
|
+
const { start_time: startTime, image_url: imageUrl } = shot;
|
|
1606
1606
|
if (typeof startTime !== "number" || !Number.isFinite(startTime)) {
|
|
1607
|
-
throw new TypeError(`Invalid shot
|
|
1607
|
+
throw new TypeError(`Invalid shot start_time in shots manifest at index ${index}`);
|
|
1608
1608
|
}
|
|
1609
1609
|
if (typeof imageUrl !== "string" || imageUrl.length === 0) {
|
|
1610
|
-
throw new TypeError(`Invalid shot
|
|
1610
|
+
throw new TypeError(`Invalid shot image_url in shots manifest at index ${index}`);
|
|
1611
1611
|
}
|
|
1612
1612
|
return {
|
|
1613
1613
|
startTime,
|
|
@@ -2180,7 +2180,8 @@ function getReliableLanguageCode(track, confidenceThreshold = LOW_CONFIDENCE_THR
|
|
|
2180
2180
|
return void 0;
|
|
2181
2181
|
if (isUndeterminedLanguageCode(track.language_code))
|
|
2182
2182
|
return void 0;
|
|
2183
|
-
|
|
2183
|
+
const { auto_language_confidence: autoLanguageConfidence } = track;
|
|
2184
|
+
if (autoLanguageConfidence !== void 0 && autoLanguageConfidence < confidenceThreshold) {
|
|
2184
2185
|
return void 0;
|
|
2185
2186
|
}
|
|
2186
2187
|
return track.language_code;
|
|
@@ -4128,12 +4129,64 @@ function transformCueText(rawVtt, transform) {
|
|
|
4128
4129
|
});
|
|
4129
4130
|
return transformed.join("\n");
|
|
4130
4131
|
}
|
|
4132
|
+
function transformCueTextBlocks(rawVtt, transform) {
|
|
4133
|
+
const lines = rawVtt.split("\n");
|
|
4134
|
+
const transformed = [];
|
|
4135
|
+
let cueTextLines;
|
|
4136
|
+
let currentCueStartTime = 0;
|
|
4137
|
+
const flushCueText = () => {
|
|
4138
|
+
if (!cueTextLines)
|
|
4139
|
+
return;
|
|
4140
|
+
if (cueTextLines.length > 0) {
|
|
4141
|
+
transformed.push(...transform(cueTextLines.join("\n"), currentCueStartTime).split("\n"));
|
|
4142
|
+
}
|
|
4143
|
+
cueTextLines = void 0;
|
|
4144
|
+
};
|
|
4145
|
+
for (const line of lines) {
|
|
4146
|
+
if (line.includes("-->")) {
|
|
4147
|
+
flushCueText();
|
|
4148
|
+
const startTimestamp = line.split("-->")[0].trim();
|
|
4149
|
+
currentCueStartTime = vttTimestampToSeconds(startTimestamp);
|
|
4150
|
+
transformed.push(line);
|
|
4151
|
+
cueTextLines = [];
|
|
4152
|
+
continue;
|
|
4153
|
+
}
|
|
4154
|
+
if (cueTextLines) {
|
|
4155
|
+
if (line.trim() === "") {
|
|
4156
|
+
flushCueText();
|
|
4157
|
+
transformed.push(line);
|
|
4158
|
+
} else {
|
|
4159
|
+
cueTextLines.push(line);
|
|
4160
|
+
}
|
|
4161
|
+
continue;
|
|
4162
|
+
}
|
|
4163
|
+
transformed.push(line);
|
|
4164
|
+
}
|
|
4165
|
+
flushCueText();
|
|
4166
|
+
return transformed.join("\n");
|
|
4167
|
+
}
|
|
4168
|
+
function escapeRegex(text) {
|
|
4169
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
4170
|
+
}
|
|
4171
|
+
function buildStaticReplacementRegex(find, caseSensitive) {
|
|
4172
|
+
const pattern = find.split(/(\s+)/).map((part) => /\s+/.test(part) ? "\\s+" : escapeRegex(part)).join("");
|
|
4173
|
+
const firstNonWhitespaceIndex = find.search(/\S/);
|
|
4174
|
+
const firstNonWhitespace = firstNonWhitespaceIndex >= 0 ? find[firstNonWhitespaceIndex] : void 0;
|
|
4175
|
+
const lastNonWhitespaceMatch = /\S(?=\s*$)/.exec(find);
|
|
4176
|
+
const lastNonWhitespace = lastNonWhitespaceMatch?.[0];
|
|
4177
|
+
const startsAtTextBoundary = firstNonWhitespaceIndex === 0 && !!firstNonWhitespace && /\w/.test(firstNonWhitespace);
|
|
4178
|
+
const endsAtTextBoundary = !!lastNonWhitespace && find.trimEnd().length === find.length && /\w/.test(lastNonWhitespace);
|
|
4179
|
+
const prefix = startsAtTextBoundary ? "(?<!\\w)" : "";
|
|
4180
|
+
const suffix = endsAtTextBoundary ? "(?!\\w)" : "";
|
|
4181
|
+
const flags = caseSensitive === false ? "gi" : "g";
|
|
4182
|
+
return new RegExp(`${prefix}${pattern}${suffix}`, flags);
|
|
4183
|
+
}
|
|
4131
4184
|
function buildReplacementRegex(words) {
|
|
4132
4185
|
const filtered = words.filter((w) => w.length > 0);
|
|
4133
4186
|
if (filtered.length === 0)
|
|
4134
4187
|
return null;
|
|
4135
4188
|
filtered.sort((a, b) => b.length - a.length);
|
|
4136
|
-
const escaped = filtered.map(
|
|
4189
|
+
const escaped = filtered.map(escapeRegex);
|
|
4137
4190
|
const pattern = escaped.join("|");
|
|
4138
4191
|
return new RegExp(`\\b(?:${pattern})\\b`, "gi");
|
|
4139
4192
|
}
|
|
@@ -4185,12 +4238,10 @@ function applyReplacements(rawVtt, replacements) {
|
|
|
4185
4238
|
return { editedVtt: rawVtt, replacements: [] };
|
|
4186
4239
|
}
|
|
4187
4240
|
const records = [];
|
|
4188
|
-
const editedVtt =
|
|
4189
|
-
let result =
|
|
4241
|
+
const editedVtt = transformCueTextBlocks(rawVtt, (cueText, cueStartTime) => {
|
|
4242
|
+
let result = cueText;
|
|
4190
4243
|
for (const { find, replace, caseSensitive } of filtered) {
|
|
4191
|
-
const
|
|
4192
|
-
const flags = caseSensitive === false ? "gi" : "g";
|
|
4193
|
-
const regex = new RegExp(`\\b${escaped}\\b`, flags);
|
|
4244
|
+
const regex = buildStaticReplacementRegex(find, caseSensitive);
|
|
4194
4245
|
result = result.replace(regex, (match) => {
|
|
4195
4246
|
records.push({ cueStartTime, before: match, after: replace });
|
|
4196
4247
|
return replace;
|
|
@@ -5091,7 +5142,6 @@ async function generateEngagementInsights(assetId, options = {}) {
|
|
|
5091
5142
|
momentInsights.push({
|
|
5092
5143
|
startMs: hotspot.startMs,
|
|
5093
5144
|
endMs: hotspot.endMs,
|
|
5094
|
-
timestamp: secondsToTimestamp(hotspot.startMs / 1e3),
|
|
5095
5145
|
engagementScore: hotspot.score,
|
|
5096
5146
|
insight: insightScrub.leaked ? "Insight suppressed by safety filter." : insightScrub.text
|
|
5097
5147
|
});
|