mediabunny 1.3.0 → 1.3.2
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/README.md +2 -0
- package/dist/bundles/mediabunny.cjs +22 -3
- package/dist/bundles/mediabunny.min.cjs +4 -4
- package/dist/bundles/mediabunny.min.mjs +4 -4
- package/dist/bundles/mediabunny.mjs +22 -3
- package/dist/modules/misc.js +1 -1
- package/dist/modules/source.d.ts.map +1 -1
- package/dist/modules/source.js +23 -2
- package/package.json +2 -2
- package/src/misc.ts +3 -3
- package/src/source.ts +27 -2
package/README.md
CHANGED
|
@@ -49,6 +49,8 @@ Core features include:
|
|
|
49
49
|
npm install mediabunny
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
Requires any JavaScript environment that can run ECMAScript 2021 or later. Mediabunny is expected to be run in modern browsers. For types, TypeScript 5.7 or later is required.
|
|
53
|
+
|
|
52
54
|
### Read file metadata
|
|
53
55
|
|
|
54
56
|
```js
|
|
@@ -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 (
|
|
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]
|
|
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;
|