@mux/ai 0.21.2 → 0.23.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.js CHANGED
@@ -5,7 +5,178 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // package.json
8
- var version = "0.21.2";
8
+ var version = "0.23.0";
9
+
10
+ // src/lib/language-codes.ts
11
+ var ISO639_1_TO_3 = {
12
+ // Major world languages
13
+ en: "eng",
14
+ // English
15
+ es: "spa",
16
+ // Spanish
17
+ fr: "fra",
18
+ // French
19
+ de: "deu",
20
+ // German
21
+ it: "ita",
22
+ // Italian
23
+ pt: "por",
24
+ // Portuguese
25
+ ru: "rus",
26
+ // Russian
27
+ zh: "zho",
28
+ // Chinese
29
+ ja: "jpn",
30
+ // Japanese
31
+ ko: "kor",
32
+ // Korean
33
+ ar: "ara",
34
+ // Arabic
35
+ hi: "hin",
36
+ // Hindi
37
+ // European languages
38
+ nl: "nld",
39
+ // Dutch
40
+ pl: "pol",
41
+ // Polish
42
+ sv: "swe",
43
+ // Swedish
44
+ da: "dan",
45
+ // Danish
46
+ no: "nor",
47
+ // Norwegian
48
+ fi: "fin",
49
+ // Finnish
50
+ el: "ell",
51
+ // Greek
52
+ cs: "ces",
53
+ // Czech
54
+ hu: "hun",
55
+ // Hungarian
56
+ ro: "ron",
57
+ // Romanian
58
+ bg: "bul",
59
+ // Bulgarian
60
+ hr: "hrv",
61
+ // Croatian
62
+ sk: "slk",
63
+ // Slovak
64
+ sl: "slv",
65
+ // Slovenian
66
+ uk: "ukr",
67
+ // Ukrainian
68
+ tr: "tur",
69
+ // Turkish
70
+ // Asian languages
71
+ th: "tha",
72
+ // Thai
73
+ vi: "vie",
74
+ // Vietnamese
75
+ id: "ind",
76
+ // Indonesian
77
+ ms: "msa",
78
+ // Malay
79
+ tl: "tgl",
80
+ // Tagalog/Filipino
81
+ // Other languages
82
+ he: "heb",
83
+ // Hebrew
84
+ fa: "fas",
85
+ // Persian/Farsi
86
+ bn: "ben",
87
+ // Bengali
88
+ ta: "tam",
89
+ // Tamil
90
+ te: "tel",
91
+ // Telugu
92
+ mr: "mar",
93
+ // Marathi
94
+ gu: "guj",
95
+ // Gujarati
96
+ kn: "kan",
97
+ // Kannada
98
+ ml: "mal",
99
+ // Malayalam
100
+ pa: "pan",
101
+ // Punjabi
102
+ ur: "urd",
103
+ // Urdu
104
+ sw: "swa",
105
+ // Swahili
106
+ af: "afr",
107
+ // Afrikaans
108
+ ca: "cat",
109
+ // Catalan
110
+ eu: "eus",
111
+ // Basque
112
+ gl: "glg",
113
+ // Galician
114
+ is: "isl",
115
+ // Icelandic
116
+ et: "est",
117
+ // Estonian
118
+ lv: "lav",
119
+ // Latvian
120
+ lt: "lit"
121
+ // Lithuanian
122
+ };
123
+ var ISO639_3_TO_1 = Object.fromEntries(
124
+ Object.entries(ISO639_1_TO_3).map(([iso1, iso3]) => [iso3, iso1])
125
+ );
126
+ function toISO639_3(code) {
127
+ const normalized = code.toLowerCase().trim();
128
+ if (normalized.length === 3) {
129
+ return normalized;
130
+ }
131
+ return ISO639_1_TO_3[normalized] ?? normalized;
132
+ }
133
+ function toISO639_1(code) {
134
+ const normalized = code.toLowerCase().trim();
135
+ if (normalized.length === 2) {
136
+ return normalized;
137
+ }
138
+ return ISO639_3_TO_1[normalized] ?? normalized;
139
+ }
140
+ function getLanguageCodePair(code) {
141
+ const normalized = code.toLowerCase().trim();
142
+ if (normalized.length === 2) {
143
+ return {
144
+ iso639_1: normalized,
145
+ iso639_3: toISO639_3(normalized)
146
+ };
147
+ } else if (normalized.length === 3) {
148
+ return {
149
+ iso639_1: toISO639_1(normalized),
150
+ iso639_3: normalized
151
+ };
152
+ }
153
+ return {
154
+ iso639_1: normalized,
155
+ iso639_3: normalized
156
+ };
157
+ }
158
+ function isValidISO639_1(code) {
159
+ return code.length === 2 && code.toLowerCase() in ISO639_1_TO_3;
160
+ }
161
+ function isValidISO639_3(code) {
162
+ return code.length === 3 && code.toLowerCase() in ISO639_3_TO_1;
163
+ }
164
+ var UNDETERMINED_LANGUAGE_CODES = /* @__PURE__ */ new Set(["und", "mul", "mis", "zxx"]);
165
+ function isUndeterminedLanguageCode(code) {
166
+ return UNDETERMINED_LANGUAGE_CODES.has(code.toLowerCase().trim());
167
+ }
168
+ function getLanguageName(code) {
169
+ if (isUndeterminedLanguageCode(code)) {
170
+ return void 0;
171
+ }
172
+ const iso639_1 = toISO639_1(code);
173
+ try {
174
+ const displayNames = new Intl.DisplayNames(["en"], { type: "language" });
175
+ return displayNames.of(iso639_1) ?? code.toUpperCase();
176
+ } catch {
177
+ return code.toUpperCase();
178
+ }
179
+ }
9
180
 
10
181
  // src/lib/prompt-fragments.ts
11
182
  import dedent from "dedent";
@@ -1431,12 +1602,12 @@ function getShotsPath(assetId) {
1431
1602
  }
1432
1603
  function mapManifestShots(shots) {
1433
1604
  return shots.map((shot, index) => {
1434
- const { startTime, imageUrl } = shot;
1605
+ const { start_time: startTime, image_url: imageUrl } = shot;
1435
1606
  if (typeof startTime !== "number" || !Number.isFinite(startTime)) {
1436
- throw new TypeError(`Invalid shot startTime in shots manifest at index ${index}`);
1607
+ throw new TypeError(`Invalid shot start_time in shots manifest at index ${index}`);
1437
1608
  }
1438
1609
  if (typeof imageUrl !== "string" || imageUrl.length === 0) {
1439
- throw new TypeError(`Invalid shot imageUrl in shots manifest at index ${index}`);
1610
+ throw new TypeError(`Invalid shot image_url in shots manifest at index ${index}`);
1440
1611
  }
1441
1612
  return {
1442
1613
  startTime,
@@ -1926,171 +2097,6 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
1926
2097
  return Promise.all(urlPromises);
1927
2098
  }
1928
2099
 
1929
- // src/lib/language-codes.ts
1930
- var ISO639_1_TO_3 = {
1931
- // Major world languages
1932
- en: "eng",
1933
- // English
1934
- es: "spa",
1935
- // Spanish
1936
- fr: "fra",
1937
- // French
1938
- de: "deu",
1939
- // German
1940
- it: "ita",
1941
- // Italian
1942
- pt: "por",
1943
- // Portuguese
1944
- ru: "rus",
1945
- // Russian
1946
- zh: "zho",
1947
- // Chinese
1948
- ja: "jpn",
1949
- // Japanese
1950
- ko: "kor",
1951
- // Korean
1952
- ar: "ara",
1953
- // Arabic
1954
- hi: "hin",
1955
- // Hindi
1956
- // European languages
1957
- nl: "nld",
1958
- // Dutch
1959
- pl: "pol",
1960
- // Polish
1961
- sv: "swe",
1962
- // Swedish
1963
- da: "dan",
1964
- // Danish
1965
- no: "nor",
1966
- // Norwegian
1967
- fi: "fin",
1968
- // Finnish
1969
- el: "ell",
1970
- // Greek
1971
- cs: "ces",
1972
- // Czech
1973
- hu: "hun",
1974
- // Hungarian
1975
- ro: "ron",
1976
- // Romanian
1977
- bg: "bul",
1978
- // Bulgarian
1979
- hr: "hrv",
1980
- // Croatian
1981
- sk: "slk",
1982
- // Slovak
1983
- sl: "slv",
1984
- // Slovenian
1985
- uk: "ukr",
1986
- // Ukrainian
1987
- tr: "tur",
1988
- // Turkish
1989
- // Asian languages
1990
- th: "tha",
1991
- // Thai
1992
- vi: "vie",
1993
- // Vietnamese
1994
- id: "ind",
1995
- // Indonesian
1996
- ms: "msa",
1997
- // Malay
1998
- tl: "tgl",
1999
- // Tagalog/Filipino
2000
- // Other languages
2001
- he: "heb",
2002
- // Hebrew
2003
- fa: "fas",
2004
- // Persian/Farsi
2005
- bn: "ben",
2006
- // Bengali
2007
- ta: "tam",
2008
- // Tamil
2009
- te: "tel",
2010
- // Telugu
2011
- mr: "mar",
2012
- // Marathi
2013
- gu: "guj",
2014
- // Gujarati
2015
- kn: "kan",
2016
- // Kannada
2017
- ml: "mal",
2018
- // Malayalam
2019
- pa: "pan",
2020
- // Punjabi
2021
- ur: "urd",
2022
- // Urdu
2023
- sw: "swa",
2024
- // Swahili
2025
- af: "afr",
2026
- // Afrikaans
2027
- ca: "cat",
2028
- // Catalan
2029
- eu: "eus",
2030
- // Basque
2031
- gl: "glg",
2032
- // Galician
2033
- is: "isl",
2034
- // Icelandic
2035
- et: "est",
2036
- // Estonian
2037
- lv: "lav",
2038
- // Latvian
2039
- lt: "lit"
2040
- // Lithuanian
2041
- };
2042
- var ISO639_3_TO_1 = Object.fromEntries(
2043
- Object.entries(ISO639_1_TO_3).map(([iso1, iso3]) => [iso3, iso1])
2044
- );
2045
- function toISO639_3(code) {
2046
- const normalized = code.toLowerCase().trim();
2047
- if (normalized.length === 3) {
2048
- return normalized;
2049
- }
2050
- return ISO639_1_TO_3[normalized] ?? normalized;
2051
- }
2052
- function toISO639_1(code) {
2053
- const normalized = code.toLowerCase().trim();
2054
- if (normalized.length === 2) {
2055
- return normalized;
2056
- }
2057
- return ISO639_3_TO_1[normalized] ?? normalized;
2058
- }
2059
- function getLanguageCodePair(code) {
2060
- const normalized = code.toLowerCase().trim();
2061
- if (normalized.length === 2) {
2062
- return {
2063
- iso639_1: normalized,
2064
- iso639_3: toISO639_3(normalized)
2065
- };
2066
- } else if (normalized.length === 3) {
2067
- return {
2068
- iso639_1: toISO639_1(normalized),
2069
- iso639_3: normalized
2070
- };
2071
- }
2072
- return {
2073
- iso639_1: normalized,
2074
- iso639_3: normalized
2075
- };
2076
- }
2077
- var UNDETERMINED_LANGUAGE_CODES = /* @__PURE__ */ new Set(["und", "mul", "mis", "zxx"]);
2078
- function isUndeterminedLanguageCode(code) {
2079
- return UNDETERMINED_LANGUAGE_CODES.has(code.toLowerCase().trim());
2080
- }
2081
- function getLanguageName(code) {
2082
- if (isUndeterminedLanguageCode(code)) {
2083
- return void 0;
2084
- }
2085
- const iso639_1 = toISO639_1(code);
2086
- try {
2087
- const displayNames = new Intl.DisplayNames(["en"], { type: "language" });
2088
- return displayNames.of(iso639_1) ?? code.toUpperCase();
2089
- } catch {
2090
- return code.toUpperCase();
2091
- }
2092
- }
2093
-
2094
2100
  // src/lib/mux-assets.ts
2095
2101
  function getPlaybackId(asset) {
2096
2102
  const playbackIds = asset.playback_ids || [];
@@ -5085,7 +5091,6 @@ async function generateEngagementInsights(assetId, options = {}) {
5085
5091
  momentInsights.push({
5086
5092
  startMs: hotspot.startMs,
5087
5093
  endMs: hotspot.endMs,
5088
- timestamp: secondsToTimestamp(hotspot.startMs / 1e3),
5089
5094
  engagementScore: hotspot.score,
5090
5095
  insight: insightScrub.leaked ? "Insight suppressed by safety filter." : insightScrub.text
5091
5096
  });
@@ -7443,8 +7448,15 @@ export {
7443
7448
  createWorkflowStorageClient,
7444
7449
  decryptFromWorkflow,
7445
7450
  encryptForWorkflow,
7451
+ getLanguageCodePair,
7452
+ getLanguageName,
7453
+ isUndeterminedLanguageCode,
7454
+ isValidISO639_1,
7455
+ isValidISO639_3,
7446
7456
  primitives_exports as primitives,
7447
7457
  setWorkflowCredentialsProvider,
7458
+ toISO639_1,
7459
+ toISO639_3,
7448
7460
  version,
7449
7461
  workflows_exports as workflows,
7450
7462
  wrapError