@mux/ai 0.43.0 → 0.45.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.
@@ -1,3 +1,3 @@
1
- export { D as DEFAULT_STORYBOARD_WIDTH, H as HeatmapOptions, a as HeatmapResponse, L as LOW_CONFIDENCE_THRESHOLD, M as MAX_CUE_TEXT_CHARS, T as ThumbnailOptions, b as TranscriptFetchOptions, c as TranscriptResult, V as VTTCue, d as VTTCueBudgetChunkingOptions, e as VTTDurationChunk, f as VTTDurationChunkingOptions, g as buildTranscriptUrl, h as buildVttFromCueBlocks, j as buildVttFromTranslatedCueBlocks, k as chunkByTokens, l as chunkText, m as chunkVTTCues, n as chunkVTTCuesByBudget, o as chunkVTTCuesByDuration, p as concatenateVttSegments, q as estimateTokenCount, r as extractTextFromVTT, s as extractTimestampedTranscript, t as fetchTranscriptForAsset, u as filterVttByScope, v as findCaptionTrack, w as getHeatmapForAsset, x as getHeatmapForPlaybackId, y as getHeatmapForVideo, z as getReadyTextTracks, A as getReliableLanguageCode, B as getStoryboardUrl, C as getThumbnailUrls, E as parseVTTCues, F as replaceCueText, G as sanitizeUntrustedText, I as secondsToTimestamp, J as splitVttPreambleAndCueBlocks, K as stripVttMetadataBlocks, N as vttTimestampToSeconds } from '../index-C2Pk7bbF.js';
2
- export { q as CompletedShotsResult, r as ErroredShotsResult, H as Hotspot, s as HotspotOptions, t as HotspotResponse, u as PendingShotsResult, v as Shot, w as ShotRequestOptions, x as ShotsResult, y as WaitForShotsOptions, z as getHotspotsForAsset, B as getHotspotsForPlaybackId, D as getHotspotsForVideo, F as getShotsForAsset, G as requestShotsForAsset, J as waitForShotsForAsset } from '../shots-CUI09Ohe.js';
1
+ export { D as DEFAULT_STORYBOARD_WIDTH, H as HeatmapOptions, a as HeatmapResponse, L as LOW_CONFIDENCE_THRESHOLD, M as MAX_CUE_TEXT_CHARS, T as ThumbnailOptions, b as TranscriptFetchOptions, c as TranscriptResult, V as VTTCue, d as VTTCueBudgetChunkingOptions, e as VTTDurationChunk, f as VTTDurationChunkingOptions, g as buildTranscriptUrl, h as buildVttFromCueBlocks, j as buildVttFromTranslatedCueBlocks, k as chunkByTokens, l as chunkText, m as chunkVTTCues, n as chunkVTTCuesByBudget, o as chunkVTTCuesByDuration, p as concatenateVttSegments, q as estimateTokenCount, r as extractTextFromVTT, s as extractTimestampedTranscript, t as fetchTranscriptForAsset, u as filterVttByScope, v as findCaptionTrack, w as getHeatmapForAsset, x as getHeatmapForPlaybackId, y as getHeatmapForVideo, z as getReadyTextTracks, A as getReliableLanguageCode, B as getStoryboardUrl, C as getThumbnailUrls, E as parseVTTCues, F as replaceCueText, G as sanitizeUntrustedText, I as secondsToTimestamp, J as splitVttPreambleAndCueBlocks, K as stripVttMetadataBlocks, N as vttTimestampToSeconds } from '../index-D6VGaoPm.js';
2
+ export { q as CompletedShotsResult, r as ErroredShotsResult, H as Hotspot, s as HotspotOptions, t as HotspotResponse, u as PendingShotsResult, v as Shot, w as ShotRequestOptions, x as ShotsResult, y as WaitForShotsOptions, z as getHotspotsForAsset, B as getHotspotsForPlaybackId, D as getHotspotsForVideo, F as getShotsForAsset, G as requestShotsForAsset, J as waitForShotsForAsset } from '../shots-B7G0IIF1.js';
3
3
  import '@mux/mux-node';
@@ -27,12 +27,16 @@ var EnvSchema = z.object({
27
27
  ),
28
28
  MUX_SIGNING_KEY: optionalString("Mux signing key ID for signed playback URLs.", "Used to sign playback URLs"),
29
29
  MUX_PRIVATE_KEY: optionalString("Mux signing private key for signed playback URLs.", "Used to sign playback URLs"),
30
+ MUX_CUSTOM_DOMAIN: optionalString(
31
+ "Mux domain for image.* and stream.* playback URLs, e.g. staging.mux.com or a custom domain (defaults to mux.com).",
32
+ "Mux custom domain"
33
+ ),
30
34
  MUX_IMAGE_URL_OVERRIDE: optionalString(
31
- "Override for Mux image base URL (defaults to https://image.mux.com).",
35
+ "Deprecated: use MUX_CUSTOM_DOMAIN. Override for Mux image base URL (defaults to https://image.mux.com).",
32
36
  "Mux image URL override"
33
37
  ),
34
38
  MUX_STREAM_URL_OVERRIDE: optionalString(
35
- "Override for Mux stream base URL (defaults to https://stream.mux.com).",
39
+ "Deprecated: use MUX_CUSTOM_DOMAIN. Override for Mux stream base URL (defaults to https://stream.mux.com).",
36
40
  "Mux stream URL override"
37
41
  ),
38
42
  MUX_BASE_URL: optionalString(
@@ -151,7 +155,18 @@ function parseEnv() {
151
155
  }
152
156
  return parsedEnv.data;
153
157
  }
158
+ var hasWarnedAboutDeprecatedUrlOverrides = false;
159
+ function warnOnDeprecatedUrlOverrides(parsed) {
160
+ if (hasWarnedAboutDeprecatedUrlOverrides || !parsed.MUX_IMAGE_URL_OVERRIDE && !parsed.MUX_STREAM_URL_OVERRIDE) {
161
+ return;
162
+ }
163
+ hasWarnedAboutDeprecatedUrlOverrides = true;
164
+ console.warn(
165
+ "MUX_IMAGE_URL_OVERRIDE and MUX_STREAM_URL_OVERRIDE are deprecated and will be removed in a future release. Set MUX_CUSTOM_DOMAIN instead (e.g. MUX_CUSTOM_DOMAIN=staging.mux.com for image.staging.mux.com and stream.staging.mux.com)."
166
+ );
167
+ }
154
168
  var env = parseEnv();
169
+ warnOnDeprecatedUrlOverrides(env);
155
170
  var env_default = env;
156
171
 
157
172
  // src/lib/workflow-crypto.ts
@@ -1104,8 +1119,7 @@ async function waitForShotsForAsset(assetId, options = {}) {
1104
1119
  }
1105
1120
 
1106
1121
  // src/lib/mux-url.ts
1107
- var DEFAULT_MUX_IMAGE_ORIGIN = "https://image.mux.com";
1108
- var DEFAULT_MUX_STREAM_ORIGIN = "https://stream.mux.com";
1122
+ var DEFAULT_MUX_DOMAIN = "mux.com";
1109
1123
  function normalizeOrigin(value, envVarName) {
1110
1124
  const trimmed = value.trim();
1111
1125
  const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
@@ -1125,29 +1139,56 @@ function normalizeOrigin(value, envVarName) {
1125
1139
  }
1126
1140
  return parsed.origin;
1127
1141
  }
1128
- function getMuxImageOrigin() {
1129
- const override = env_default.MUX_IMAGE_URL_OVERRIDE;
1130
- if (!override) {
1131
- return DEFAULT_MUX_IMAGE_ORIGIN;
1142
+ function buildPlaybackOrigin(service, customDomain, source) {
1143
+ const invalidDomainError = new Error(
1144
+ `Invalid ${source}. Provide a bare hostname (e.g. "media.example.com") with no scheme, port, credentials, query params, hash fragments, or path.`
1145
+ );
1146
+ const trimmed = customDomain.trim();
1147
+ if (!trimmed) {
1148
+ throw invalidDomainError;
1132
1149
  }
1133
- return normalizeOrigin(override, "MUX_IMAGE_URL_OVERRIDE");
1150
+ let parsed;
1151
+ try {
1152
+ parsed = new URL(`https://${service}.${trimmed}`);
1153
+ } catch {
1154
+ throw invalidDomainError;
1155
+ }
1156
+ if (parsed.port || parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname !== "/") {
1157
+ throw invalidDomainError;
1158
+ }
1159
+ return parsed.origin;
1134
1160
  }
1135
- function getMuxStreamOrigin() {
1136
- const override = env_default.MUX_STREAM_URL_OVERRIDE;
1137
- if (!override) {
1138
- return DEFAULT_MUX_STREAM_ORIGIN;
1161
+ async function resolveMuxPlaybackOrigin(service, credentials) {
1162
+ "use step";
1163
+ const { muxCustomDomain } = await resolveWorkflowCredentials(credentials);
1164
+ if (muxCustomDomain) {
1165
+ return buildPlaybackOrigin(service, muxCustomDomain, "muxCustomDomain");
1139
1166
  }
1140
- return normalizeOrigin(override, "MUX_STREAM_URL_OVERRIDE");
1167
+ const legacyOverrideEnvVarName = service === "image" ? "MUX_IMAGE_URL_OVERRIDE" : "MUX_STREAM_URL_OVERRIDE";
1168
+ const legacyOverride = env_default[legacyOverrideEnvVarName];
1169
+ if (legacyOverride) {
1170
+ return normalizeOrigin(legacyOverride, legacyOverrideEnvVarName);
1171
+ }
1172
+ if (env_default.MUX_CUSTOM_DOMAIN) {
1173
+ return buildPlaybackOrigin(service, env_default.MUX_CUSTOM_DOMAIN, "MUX_CUSTOM_DOMAIN");
1174
+ }
1175
+ return buildPlaybackOrigin(service, DEFAULT_MUX_DOMAIN, "custom domain");
1176
+ }
1177
+ async function getMuxImageOrigin(credentials) {
1178
+ return resolveMuxPlaybackOrigin("image", credentials);
1179
+ }
1180
+ async function getMuxStreamOrigin(credentials) {
1181
+ return resolveMuxPlaybackOrigin("stream", credentials);
1141
1182
  }
1142
- function getMuxImageBaseUrl(playbackId, assetType) {
1143
- const origin = getMuxImageOrigin();
1183
+ async function getMuxImageBaseUrl(playbackId, assetType, credentials) {
1184
+ const origin = await getMuxImageOrigin(credentials);
1144
1185
  return `${origin}/${playbackId}/${assetType}.png`;
1145
1186
  }
1146
- function getMuxStoryboardBaseUrl(playbackId) {
1147
- return getMuxImageBaseUrl(playbackId, "storyboard");
1187
+ async function getMuxStoryboardBaseUrl(playbackId, credentials) {
1188
+ return getMuxImageBaseUrl(playbackId, "storyboard", credentials);
1148
1189
  }
1149
- function getMuxThumbnailBaseUrl(playbackId) {
1150
- return getMuxImageBaseUrl(playbackId, "thumbnail");
1190
+ async function getMuxThumbnailBaseUrl(playbackId, credentials) {
1191
+ return getMuxImageBaseUrl(playbackId, "thumbnail", credentials);
1151
1192
  }
1152
1193
 
1153
1194
  // src/lib/url-signing.ts
@@ -1191,7 +1232,7 @@ async function signUrl(url, playbackId, type = "video", params, credentials) {
1191
1232
  var DEFAULT_STORYBOARD_WIDTH = 640;
1192
1233
  async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, shouldSign = false, credentials, scope) {
1193
1234
  "use step";
1194
- const baseUrl = getMuxStoryboardBaseUrl(playbackId);
1235
+ const baseUrl = await getMuxStoryboardBaseUrl(playbackId, credentials);
1195
1236
  const params = { width };
1196
1237
  if (scope?.startTime !== void 0) {
1197
1238
  params.asset_start_time = scope.startTime;
@@ -1520,7 +1561,7 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
1520
1561
  }
1521
1562
  timestamps = newTimestamps;
1522
1563
  }
1523
- const baseUrl = getMuxThumbnailBaseUrl(playbackId);
1564
+ const baseUrl = await getMuxThumbnailBaseUrl(playbackId, credentials);
1524
1565
  const urlPromises = timestamps.map(async (time) => {
1525
1566
  const url = shouldSign ? await signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials) : `${baseUrl}?time=${time}&width=${width}`;
1526
1567
  return { url, time };
@@ -2037,7 +2078,7 @@ function concatenateVttSegments(segments, preamble = "WEBVTT") {
2037
2078
  }
2038
2079
  async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, credentials) {
2039
2080
  "use step";
2040
- const baseUrl = `${getMuxStreamOrigin()}/${playbackId}/text/${trackId}.vtt`;
2081
+ const baseUrl = `${await getMuxStreamOrigin(credentials)}/${playbackId}/text/${trackId}.vtt`;
2041
2082
  if (shouldSign) {
2042
2083
  return signUrl(baseUrl, playbackId, "video", void 0, credentials);
2043
2084
  }