@mux/ai 0.17.0 → 0.17.1

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.
@@ -30,6 +30,10 @@ var EnvSchema = z.object({
30
30
  "Override for Mux image base URL (defaults to https://image.mux.com).",
31
31
  "Mux image URL override"
32
32
  ),
33
+ MUX_STREAM_URL_OVERRIDE: optionalString(
34
+ "Override for Mux stream base URL (defaults to https://stream.mux.com).",
35
+ "Mux stream URL override"
36
+ ),
33
37
  // Test-only helpers (used by this repo's integration tests)
34
38
  MUX_TEST_ASSET_ID: optionalString("Mux asset ID used by integration tests.", "Mux test asset id"),
35
39
  MUX_TEST_ASSET_ID_CHAPTERS: optionalString("Mux asset ID used by integration tests for chapters.", "Mux test asset id for chapters"),
@@ -749,22 +753,24 @@ async function waitForShotsForAsset(assetId, options = {}) {
749
753
  );
750
754
  }
751
755
 
752
- // src/lib/mux-image-url.ts
756
+ // src/lib/mux-url.ts
753
757
  var DEFAULT_MUX_IMAGE_ORIGIN = "https://image.mux.com";
754
- function normalizeMuxImageOrigin(value) {
758
+ var DEFAULT_MUX_STREAM_ORIGIN = "https://stream.mux.com";
759
+ function normalizeOrigin(value, envVarName) {
755
760
  const trimmed = value.trim();
756
761
  const candidate = trimmed.includes("://") ? trimmed : `https://${trimmed}`;
762
+ const exampleHostname = envVarName === "MUX_IMAGE_URL_OVERRIDE" ? "image.example.mux.com" : "stream.example.mux.com";
757
763
  let parsed;
758
764
  try {
759
765
  parsed = new URL(candidate);
760
766
  } catch {
761
767
  throw new Error(
762
- `Invalid MUX_IMAGE_URL_OVERRIDE. Provide a hostname like "image.example.mux.com" (or a URL origin such as "https://image.example.mux.com").`
768
+ `Invalid ${envVarName}. Provide a hostname (e.g. "${exampleHostname}") or a URL origin (e.g. "https://${exampleHostname}").`
763
769
  );
764
770
  }
765
771
  if (parsed.username || parsed.password || parsed.search || parsed.hash || parsed.pathname && parsed.pathname !== "/") {
766
772
  throw new Error(
767
- "Invalid MUX_IMAGE_URL_OVERRIDE. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path)."
773
+ `Invalid ${envVarName}. Only a hostname/origin is allowed (no credentials, query params, hash fragments, or path).`
768
774
  );
769
775
  }
770
776
  return parsed.origin;
@@ -774,7 +780,14 @@ function getMuxImageOrigin() {
774
780
  if (!override) {
775
781
  return DEFAULT_MUX_IMAGE_ORIGIN;
776
782
  }
777
- return normalizeMuxImageOrigin(override);
783
+ return normalizeOrigin(override, "MUX_IMAGE_URL_OVERRIDE");
784
+ }
785
+ function getMuxStreamOrigin() {
786
+ const override = env_default.MUX_STREAM_URL_OVERRIDE;
787
+ if (!override) {
788
+ return DEFAULT_MUX_STREAM_ORIGIN;
789
+ }
790
+ return normalizeOrigin(override, "MUX_STREAM_URL_OVERRIDE");
778
791
  }
779
792
  function getMuxImageBaseUrl(playbackId, assetType) {
780
793
  const origin = getMuxImageOrigin();
@@ -1540,7 +1553,7 @@ function concatenateVttSegments(segments, preamble = "WEBVTT") {
1540
1553
  }
1541
1554
  async function buildTranscriptUrl(playbackId, trackId, shouldSign = false, credentials) {
1542
1555
  "use step";
1543
- const baseUrl = `https://stream.mux.com/${playbackId}/text/${trackId}.vtt`;
1556
+ const baseUrl = `${getMuxStreamOrigin()}/${playbackId}/text/${trackId}.vtt`;
1544
1557
  if (shouldSign) {
1545
1558
  return signUrl(baseUrl, playbackId, "video", void 0, credentials);
1546
1559
  }