mediabunny 1.3.0 → 1.3.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.
@@ -497,12 +497,12 @@ var Mediabunny = (() => {
497
497
  try {
498
498
  return await fetch(url2, requestInit);
499
499
  } catch (error) {
500
- console.error("Retrying failed fetch. Error:", error);
501
500
  attempts++;
502
501
  const retryDelayInSeconds = getRetryDelay(attempts);
503
502
  if (retryDelayInSeconds === null) {
504
503
  throw error;
505
504
  }
505
+ console.error("Retrying failed fetch. Error:", error);
506
506
  if (!Number.isFinite(retryDelayInSeconds) || retryDelayInSeconds < 0) {
507
507
  throw new TypeError("Retry delay must be a non-negative finite number.");
508
508
  }
@@ -11695,7 +11695,7 @@ ${cue.notes ?? ""}`;
11695
11695
  throw new Error(`Error fetching ${this._url}: ${response.status} ${response.statusText}`);
11696
11696
  }
11697
11697
  const buffer = await response.arrayBuffer();
11698
- if (!range) {
11698
+ if (response.status === 200) {
11699
11699
  this._fullData = buffer;
11700
11700
  }
11701
11701
  return {
@@ -11720,6 +11720,22 @@ ${cue.notes ?? ""}`;
11720
11720
  if (this._fullData) {
11721
11721
  return this._fullData.byteLength;
11722
11722
  }
11723
+ try {
11724
+ const headResponse = await retriedFetch(
11725
+ this._url,
11726
+ mergeObjectsDeeply(this._options.requestInit ?? {}, {
11727
+ method: "HEAD"
11728
+ }),
11729
+ this._options.getRetryDelay ?? (() => null)
11730
+ );
11731
+ if (headResponse.ok) {
11732
+ const contentLength = headResponse.headers.get("Content-Length");
11733
+ if (contentLength) {
11734
+ return parseInt(contentLength);
11735
+ }
11736
+ }
11737
+ } catch {
11738
+ }
11723
11739
  const rangeResponse = await retriedFetch(
11724
11740
  this._url,
11725
11741
  mergeObjectsDeeply(this._options.requestInit ?? {}, {
@@ -11733,9 +11749,12 @@ ${cue.notes ?? ""}`;
11733
11749
  if (contentRange) {
11734
11750
  const match = contentRange.match(/bytes \d+-\d+\/(\d+)/);
11735
11751
  if (match && match[1]) {
11736
- return parseInt(match[1], 10);
11752
+ return parseInt(match[1]);
11737
11753
  }
11738
11754
  }
11755
+ } else if (rangeResponse.status === 200) {
11756
+ this._fullData = await rangeResponse.arrayBuffer();
11757
+ return this._fullData.byteLength;
11739
11758
  }
11740
11759
  const { response } = await this._makeRequest();
11741
11760
  return response.byteLength;