@mux/ai 0.7.5 → 0.7.6
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.d.ts +1 -1
- package/dist/index.js +46 -4
- package/dist/index.js.map +1 -1
- package/dist/primitives/index.js +44 -2
- package/dist/primitives/index.js.map +1 -1
- package/dist/workflows/index.js +45 -3
- package/dist/workflows/index.js.map +1 -1
- package/package.json +1 -1
package/dist/workflows/index.js
CHANGED
|
@@ -138,6 +138,10 @@ var EnvSchema = z.object({
|
|
|
138
138
|
),
|
|
139
139
|
MUX_SIGNING_KEY: optionalString("Mux signing key ID for signed playback URLs.", "Used to sign playback URLs"),
|
|
140
140
|
MUX_PRIVATE_KEY: optionalString("Mux signing private key for signed playback URLs.", "Used to sign playback URLs"),
|
|
141
|
+
MUX_IMAGE_URL_OVERRIDE: optionalString(
|
|
142
|
+
"Override for Mux image base URL (defaults to https://image.mux.com).",
|
|
143
|
+
"Mux image URL override"
|
|
144
|
+
),
|
|
141
145
|
// Test-only helpers (used by this repo's integration tests)
|
|
142
146
|
MUX_TEST_ASSET_ID: optionalString("Mux asset ID used by integration tests.", "Mux test asset id"),
|
|
143
147
|
MUX_TEST_ASSET_ID_CHAPTERS: optionalString("Mux asset ID used by integration tests for chapters.", "Mux test asset id for chapters"),
|
|
@@ -835,6 +839,44 @@ async function withRetry(fn, {
|
|
|
835
839
|
throw lastError || new Error("Retry failed with unknown error");
|
|
836
840
|
}
|
|
837
841
|
|
|
842
|
+
// src/lib/mux-image-url.ts
|
|
843
|
+
var DEFAULT_MUX_IMAGE_ORIGIN = "https://image.mux.com";
|
|
844
|
+
function normalizeMuxImageOrigin(value) {
|
|
845
|
+
const trimmed = value.trim();
|
|
846
|
+
const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
|
|
847
|
+
let parsed;
|
|
848
|
+
try {
|
|
849
|
+
parsed = new URL(candidate);
|
|
850
|
+
} catch {
|
|
851
|
+
throw new Error(
|
|
852
|
+
`Invalid MUX_IMAGE_URL_OVERRIDE. Provide a hostname like "image.example.mux.com" (or a URL origin such as "https://image.example.mux.com").`
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
if (parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname && parsed.pathname !== "/") {
|
|
856
|
+
throw new Error(
|
|
857
|
+
"Invalid MUX_IMAGE_URL_OVERRIDE. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path)."
|
|
858
|
+
);
|
|
859
|
+
}
|
|
860
|
+
return parsed.origin;
|
|
861
|
+
}
|
|
862
|
+
function getMuxImageOrigin() {
|
|
863
|
+
const override = env_default.MUX_IMAGE_URL_OVERRIDE;
|
|
864
|
+
if (!override) {
|
|
865
|
+
return DEFAULT_MUX_IMAGE_ORIGIN;
|
|
866
|
+
}
|
|
867
|
+
return normalizeMuxImageOrigin(override);
|
|
868
|
+
}
|
|
869
|
+
function getMuxImageBaseUrl(playbackId, assetType) {
|
|
870
|
+
const origin = getMuxImageOrigin();
|
|
871
|
+
return `${origin}/${playbackId}/${assetType}.png`;
|
|
872
|
+
}
|
|
873
|
+
function getMuxStoryboardBaseUrl(playbackId) {
|
|
874
|
+
return getMuxImageBaseUrl(playbackId, "storyboard");
|
|
875
|
+
}
|
|
876
|
+
function getMuxThumbnailBaseUrl(playbackId) {
|
|
877
|
+
return getMuxImageBaseUrl(playbackId, "thumbnail");
|
|
878
|
+
}
|
|
879
|
+
|
|
838
880
|
// src/lib/url-signing.ts
|
|
839
881
|
async function createSigningClient(context) {
|
|
840
882
|
const { default: MuxClient } = await import("@mux/mux-node");
|
|
@@ -876,7 +918,7 @@ async function signUrl(url, playbackId, type = "video", params, credentials) {
|
|
|
876
918
|
var DEFAULT_STORYBOARD_WIDTH = 640;
|
|
877
919
|
async function getStoryboardUrl(playbackId, width = DEFAULT_STORYBOARD_WIDTH, shouldSign = false, credentials) {
|
|
878
920
|
"use step";
|
|
879
|
-
const baseUrl =
|
|
921
|
+
const baseUrl = getMuxStoryboardBaseUrl(playbackId);
|
|
880
922
|
if (shouldSign) {
|
|
881
923
|
return signUrl(baseUrl, playbackId, "storyboard", { width }, credentials);
|
|
882
924
|
}
|
|
@@ -2085,7 +2127,7 @@ async function getThumbnailUrls(playbackId, duration, options = {}) {
|
|
|
2085
2127
|
}
|
|
2086
2128
|
timestamps = newTimestamps;
|
|
2087
2129
|
}
|
|
2088
|
-
const baseUrl =
|
|
2130
|
+
const baseUrl = getMuxThumbnailBaseUrl(playbackId);
|
|
2089
2131
|
const urlPromises = timestamps.map(async (time) => {
|
|
2090
2132
|
if (shouldSign) {
|
|
2091
2133
|
return signUrl(baseUrl, playbackId, "thumbnail", { time, width }, credentials);
|
|
@@ -2362,7 +2404,7 @@ async function requestHiveModeration(imageUrls, maxConcurrent = 5, submissionMod
|
|
|
2362
2404
|
async function getThumbnailUrlsFromTimestamps(playbackId, timestampsMs, options) {
|
|
2363
2405
|
"use step";
|
|
2364
2406
|
const { width, shouldSign, credentials } = options;
|
|
2365
|
-
const baseUrl =
|
|
2407
|
+
const baseUrl = getMuxThumbnailBaseUrl(playbackId);
|
|
2366
2408
|
const urlPromises = timestampsMs.map(async (tsMs) => {
|
|
2367
2409
|
const time = Number((tsMs / 1e3).toFixed(2));
|
|
2368
2410
|
if (shouldSign) {
|