@remotion/media-parser 4.0.269 → 4.0.271
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/aac-codecprivate.js +6 -13
- package/dist/add-avc-profile-to-track.js +5 -9
- package/dist/buffer-iterator.js +8 -13
- package/dist/combine-uint8-arrays.js +1 -5
- package/dist/containers/aac/parse-aac.js +9 -13
- package/dist/containers/aac/types.js +1 -2
- package/dist/containers/avc/codec-string.js +1 -5
- package/dist/containers/avc/color.js +3 -9
- package/dist/containers/avc/create-sps-pps-data.js +5 -9
- package/dist/containers/avc/interpret-sps.js +7 -13
- package/dist/containers/avc/key.js +1 -5
- package/dist/containers/avc/parse-avc.js +3 -7
- package/dist/containers/avc/sps-and-pps.js +1 -5
- package/dist/containers/flac/get-block-size.js +1 -5
- package/dist/containers/flac/get-channel-count.d.ts +1 -1
- package/dist/containers/flac/get-channel-count.js +1 -5
- package/dist/containers/flac/get-duration-from-flac.js +1 -5
- package/dist/containers/flac/get-metadata-from-flac.js +1 -5
- package/dist/containers/flac/get-sample-rate.js +1 -5
- package/dist/containers/flac/parse-flac-frame.js +14 -19
- package/dist/containers/flac/parse-flac.js +15 -19
- package/dist/containers/flac/parse-header.js +1 -5
- package/dist/containers/flac/parse-metadata.js +1 -5
- package/dist/containers/flac/parse-streaminfo.js +3 -7
- package/dist/containers/flac/parse-unknown-block.js +1 -5
- package/dist/containers/flac/types.d.ts +2 -2
- package/dist/containers/flac/types.js +1 -2
- package/dist/containers/iso-base-media/base-media-box.js +1 -2
- package/dist/containers/iso-base-media/base-type.js +1 -2
- package/dist/containers/iso-base-media/esds/decoder-specific-config.js +1 -5
- package/dist/containers/iso-base-media/esds/esds-descriptors.js +5 -10
- package/dist/containers/iso-base-media/esds/esds.js +3 -7
- package/dist/containers/iso-base-media/ftyp.js +1 -5
- package/dist/containers/iso-base-media/get-actual-number-of-channels.js +4 -8
- package/dist/containers/iso-base-media/get-children.js +3 -7
- package/dist/containers/iso-base-media/get-keyframes.js +7 -11
- package/dist/containers/iso-base-media/get-moov-atom.js +22 -15
- package/dist/containers/iso-base-media/get-sample-positions-from-track.js +20 -24
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.d.ts +1 -1
- package/dist/containers/iso-base-media/get-video-codec-from-iso-track.js +3 -7
- package/dist/containers/iso-base-media/make-track.js +30 -34
- package/dist/containers/iso-base-media/mdat/mdat.js +16 -20
- package/dist/containers/iso-base-media/mdhd.js +1 -5
- package/dist/containers/iso-base-media/meta/hdlr.js +1 -5
- package/dist/containers/iso-base-media/meta/ilst.js +1 -5
- package/dist/containers/iso-base-media/moov/moov.js +3 -7
- package/dist/containers/iso-base-media/mvhd.js +7 -11
- package/dist/containers/iso-base-media/parse-boxes.js +5 -9
- package/dist/containers/iso-base-media/parse-icc-profile.js +4 -8
- package/dist/containers/iso-base-media/process-box.js +63 -67
- package/dist/containers/iso-base-media/stsd/av1c.js +1 -5
- package/dist/containers/iso-base-media/stsd/avcc.js +1 -5
- package/dist/containers/iso-base-media/stsd/colr.js +3 -7
- package/dist/containers/iso-base-media/stsd/ctts.js +1 -5
- package/dist/containers/iso-base-media/stsd/hvcc.js +3 -7
- package/dist/containers/iso-base-media/stsd/keys.js +1 -5
- package/dist/containers/iso-base-media/stsd/mebx.js +3 -7
- package/dist/containers/iso-base-media/stsd/pasp.js +1 -5
- package/dist/containers/iso-base-media/stsd/samples.js +8 -13
- package/dist/containers/iso-base-media/stsd/stco.js +1 -5
- package/dist/containers/iso-base-media/stsd/stsc.js +1 -5
- package/dist/containers/iso-base-media/stsd/stsd.js +3 -7
- package/dist/containers/iso-base-media/stsd/stss.js +1 -5
- package/dist/containers/iso-base-media/stsd/stsz.js +1 -5
- package/dist/containers/iso-base-media/stsd/stts.js +1 -5
- package/dist/containers/iso-base-media/tfdt.js +1 -5
- package/dist/containers/iso-base-media/tfhd.js +1 -5
- package/dist/containers/iso-base-media/tkhd.js +4 -8
- package/dist/containers/iso-base-media/to-date.js +1 -5
- package/dist/containers/iso-base-media/trak/trak.js +3 -7
- package/dist/containers/iso-base-media/traversal.d.ts +3 -2
- package/dist/containers/iso-base-media/traversal.js +42 -57
- package/dist/containers/iso-base-media/trun.js +2 -6
- package/dist/containers/iso-base-media/void-box.js +1 -2
- package/dist/containers/m3u/after-manifest-fetch.d.ts +8 -8
- package/dist/containers/m3u/after-manifest-fetch.js +33 -51
- package/dist/containers/m3u/fetch-m3u8-stream.d.ts +5 -2
- package/dist/containers/m3u/fetch-m3u8-stream.js +4 -12
- package/dist/containers/m3u/get-chunks.d.ts +1 -0
- package/dist/containers/m3u/get-chunks.js +6 -6
- package/dist/containers/m3u/get-duration-from-m3u.d.ts +2 -2
- package/dist/containers/m3u/get-duration-from-m3u.js +9 -8
- package/dist/containers/m3u/get-playlist.d.ts +6 -1
- package/dist/containers/m3u/get-playlist.js +19 -16
- package/dist/containers/m3u/get-streams.d.ts +14 -7
- package/dist/containers/m3u/get-streams.js +15 -18
- package/dist/containers/m3u/iterate-over-segment-files.d.ts +19 -0
- package/dist/containers/m3u/iterate-over-segment-files.js +106 -0
- package/dist/containers/m3u/m3u-child-stream.d.ts +0 -0
- package/dist/containers/m3u/m3u-child-stream.js +1 -0
- package/dist/containers/m3u/parse-directive.js +37 -10
- package/dist/containers/m3u/parse-m3u-manifest.js +3 -7
- package/dist/containers/m3u/parse-m3u-media-directive.d.ts +1 -0
- package/dist/containers/m3u/parse-m3u-media-directive.js +7 -7
- package/dist/containers/m3u/parse-m3u.js +18 -11
- package/dist/containers/m3u/parse-m3u8-text.js +3 -7
- package/dist/containers/m3u/parse-stream-inf.js +2 -7
- package/dist/containers/m3u/return-packets.d.ts +3 -2
- package/dist/containers/m3u/return-packets.js +92 -54
- package/dist/containers/m3u/run-over-m3u.d.ts +9 -0
- package/dist/containers/m3u/run-over-m3u.js +85 -0
- package/dist/containers/m3u/sample-sorter.d.ts +13 -0
- package/dist/containers/m3u/sample-sorter.js +60 -0
- package/dist/containers/m3u/select-stream.d.ts +10 -1
- package/dist/containers/m3u/select-stream.js +23 -7
- package/dist/containers/m3u/types.d.ts +15 -1
- package/dist/containers/m3u/types.js +1 -2
- package/dist/containers/mp3/get-duration.js +5 -9
- package/dist/containers/mp3/get-frame-length.js +2 -7
- package/dist/containers/mp3/get-metadata-from-mp3.d.ts +2 -2
- package/dist/containers/mp3/get-metadata-from-mp3.js +1 -5
- package/dist/containers/mp3/id3-v1.js +1 -5
- package/dist/containers/mp3/id3.js +1 -5
- package/dist/containers/mp3/parse-mp3.js +7 -11
- package/dist/containers/mp3/parse-mpeg-header.js +10 -14
- package/dist/containers/mp3/samples-per-mpeg-file.js +1 -5
- package/dist/containers/riff/expect-riff-box.js +11 -15
- package/dist/containers/riff/get-duration.js +7 -12
- package/dist/containers/riff/get-tracks-from-avi.js +20 -28
- package/dist/containers/riff/is-movi.js +1 -5
- package/dist/containers/riff/parse-avih.js +1 -5
- package/dist/containers/riff/parse-isft.js +1 -5
- package/dist/containers/riff/parse-list-box.js +3 -7
- package/dist/containers/riff/parse-movi.js +13 -18
- package/dist/containers/riff/parse-riff-body.js +9 -13
- package/dist/containers/riff/parse-riff-box.js +9 -13
- package/dist/containers/riff/parse-riff-header.js +1 -5
- package/dist/containers/riff/parse-riff.js +5 -9
- package/dist/containers/riff/parse-strf.js +1 -5
- package/dist/containers/riff/parse-strh.js +3 -7
- package/dist/containers/riff/parse-video-section.js +7 -11
- package/dist/containers/riff/riff-box.js +1 -2
- package/dist/containers/riff/timescale.js +1 -4
- package/dist/containers/riff/traversal.js +7 -15
- package/dist/containers/transport-stream/adts-header.js +6 -10
- package/dist/containers/transport-stream/boxes.js +1 -2
- package/dist/containers/transport-stream/discard-rest-of-packet.js +2 -7
- package/dist/containers/transport-stream/find-separator.js +1 -4
- package/dist/containers/transport-stream/get-tracks.js +7 -12
- package/dist/containers/transport-stream/handle-aac-packet.js +12 -16
- package/dist/containers/transport-stream/handle-avc-packet.js +22 -26
- package/dist/containers/transport-stream/next-pes-header-store.js +1 -5
- package/dist/containers/transport-stream/parse-packet.js +13 -17
- package/dist/containers/transport-stream/parse-pat.js +5 -10
- package/dist/containers/transport-stream/parse-pes.js +1 -5
- package/dist/containers/transport-stream/parse-pmt.js +3 -7
- package/dist/containers/transport-stream/parse-stream-packet.js +13 -17
- package/dist/containers/transport-stream/parse-transport-stream.js +5 -9
- package/dist/containers/transport-stream/process-stream-buffers.js +10 -15
- package/dist/containers/transport-stream/traversal.js +4 -10
- package/dist/containers/wav/get-duration-from-wav.js +3 -8
- package/dist/containers/wav/get-metadata-from-wav.d.ts +2 -2
- package/dist/containers/wav/get-metadata-from-wav.js +1 -5
- package/dist/containers/wav/parse-data.js +5 -9
- package/dist/containers/wav/parse-fmt.js +3 -7
- package/dist/containers/wav/parse-header.js +1 -5
- package/dist/containers/wav/parse-id3.js +1 -5
- package/dist/containers/wav/parse-list.js +10 -6
- package/dist/containers/wav/parse-video-section.js +3 -7
- package/dist/containers/wav/parse-wav.js +15 -19
- package/dist/containers/wav/types.d.ts +2 -2
- package/dist/containers/wav/types.js +1 -2
- package/dist/containers/webm/allowed-partial-segments.js +1 -4
- package/dist/containers/webm/av1-codec-private.js +3 -7
- package/dist/containers/webm/color.js +6 -10
- package/dist/containers/webm/description.js +6 -10
- package/dist/containers/webm/get-ready-tracks.js +13 -18
- package/dist/containers/webm/get-sample-from-block.js +12 -16
- package/dist/containers/webm/make-track.js +43 -48
- package/dist/containers/webm/parse-ebml.js +14 -19
- package/dist/containers/webm/parse-webm-header.js +3 -7
- package/dist/containers/webm/segments/all-segments.js +168 -173
- package/dist/containers/webm/segments/block-simple-block-flags.js +4 -8
- package/dist/containers/webm/segments/track-entry.js +1 -5
- package/dist/containers/webm/segments.js +9 -13
- package/dist/containers/webm/traversal.js +37 -67
- package/dist/convert-audio-or-video-sample.js +1 -5
- package/dist/download-and-parse-media.js +44 -46
- package/dist/emit-available-info.js +38 -38
- package/dist/emitter.js +1 -5
- package/dist/errors.d.ts +2 -17
- package/dist/errors.js +10 -30
- package/dist/esm/fetch.mjs +93 -67
- package/dist/esm/index.mjs +1189 -355
- package/dist/esm/node.mjs +59 -36
- package/dist/esm/universal.mjs +323 -0
- package/dist/esm/web-file.mjs +55 -43
- package/dist/esm/web.mjs +257 -0
- package/dist/esm/worker-server-entry.mjs +13056 -0
- package/dist/esm/worker-server.mjs +12914 -0
- package/dist/esm/worker-web-entry.mjs +12969 -0
- package/dist/esm/worker.mjs +439 -0
- package/dist/fetch.js +1 -17
- package/dist/file-types/bmp.js +3 -7
- package/dist/file-types/detect-file-type.js +24 -38
- package/dist/file-types/index.js +22 -26
- package/dist/file-types/jpeg.js +4 -9
- package/dist/file-types/pdf.js +3 -7
- package/dist/file-types/png.js +4 -9
- package/dist/file-types/webp.js +3 -7
- package/dist/forward-controller.js +1 -5
- package/dist/get-audio-codec.js +25 -38
- package/dist/get-container.d.ts +3 -3
- package/dist/get-container.js +5 -10
- package/dist/get-dimensions.js +8 -13
- package/dist/get-duration.js +27 -34
- package/dist/get-fields-from-callbacks.js +1 -5
- package/dist/get-fps.js +24 -34
- package/dist/get-is-hdr.js +5 -10
- package/dist/get-keyframes.js +6 -11
- package/dist/get-location.js +4 -9
- package/dist/get-number-of-audio-channels.js +2 -7
- package/dist/get-sample-aspect-ratio.js +17 -30
- package/dist/get-sample-positions-from-lpcm.js +5 -9
- package/dist/get-sample-positions.js +1 -5
- package/dist/get-sample-rate.js +2 -7
- package/dist/get-tracks.d.ts +5 -0
- package/dist/get-tracks.js +37 -44
- package/dist/get-video-codec.js +26 -34
- package/dist/has-all-info.js +33 -38
- package/dist/index.d.ts +44 -36
- package/dist/index.js +34 -47
- package/dist/init-video.d.ts +1 -1
- package/dist/init-video.js +47 -20
- package/dist/internal-parse-media.js +39 -41
- package/dist/is-audio-structure.d.ts +2 -2
- package/dist/is-audio-structure.js +1 -5
- package/dist/log.js +8 -12
- package/dist/make-hvc1-codec-strings.js +1 -5
- package/dist/media-parser-controller.js +7 -11
- package/dist/metadata/get-metadata.d.ts +4 -4
- package/dist/metadata/get-metadata.js +17 -22
- package/dist/metadata/metadata-from-iso.d.ts +3 -3
- package/dist/metadata/metadata-from-iso.js +12 -17
- package/dist/metadata/metadata-from-matroska.d.ts +2 -2
- package/dist/metadata/metadata-from-matroska.js +3 -7
- package/dist/metadata/metadata-from-riff.d.ts +2 -2
- package/dist/metadata/metadata-from-riff.js +3 -7
- package/dist/node-writer.js +1 -17
- package/dist/node.js +1 -17
- package/dist/options.d.ts +32 -25
- package/dist/options.js +1 -2
- package/dist/parse-media-on-browser-worker.d.ts +2 -0
- package/dist/parse-media-on-browser-worker.js +4 -0
- package/dist/parse-media-on-server-worker.d.ts +2 -0
- package/dist/parse-media-on-server-worker.js +4 -0
- package/dist/parse-media-on-web-worker.d.ts +2 -0
- package/dist/parse-media-on-web-worker.js +4 -0
- package/dist/parse-media-on-worker-entry.d.ts +2 -0
- package/dist/parse-media-on-worker-entry.js +269 -0
- package/dist/parse-media-on-worker.d.ts +2 -0
- package/dist/parse-media-on-worker.js +4 -0
- package/dist/parse-media.js +10 -12
- package/dist/parse-result.d.ts +3 -3
- package/dist/parse-result.js +1 -2
- package/dist/pause-signal.js +1 -5
- package/dist/perform-seek.js +6 -10
- package/dist/readers/fetch/get-body-and-reader.js +1 -5
- package/dist/readers/fetch/resolve-url.d.ts +1 -1
- package/dist/readers/fetch/resolve-url.js +1 -5
- package/dist/readers/from-fetch.d.ts +4 -1
- package/dist/readers/from-fetch.js +109 -94
- package/dist/readers/from-node.d.ts +4 -1
- package/dist/readers/from-node.js +58 -41
- package/dist/readers/from-web-file.d.ts +4 -1
- package/dist/readers/from-web-file.js +55 -49
- package/dist/readers/reader.d.ts +5 -1
- package/dist/readers/reader.js +1 -2
- package/dist/readers/universal.d.ts +2 -0
- package/dist/readers/universal.js +35 -0
- package/dist/readers/web.d.ts +2 -0
- package/dist/readers/web.js +22 -0
- package/dist/register-track.js +9 -15
- package/dist/remotion-license-acknowledge.js +4 -8
- package/dist/run-parse-iteration.js +26 -25
- package/dist/samples-from-moof.js +8 -12
- package/dist/skip.js +1 -5
- package/dist/state/aac-state.js +1 -5
- package/dist/state/can-skip-tracks.d.ts +2 -2
- package/dist/state/can-skip-tracks.js +3 -8
- package/dist/state/emitted-fields.js +1 -5
- package/dist/state/flac-state.js +1 -5
- package/dist/state/has-tracks-section.js +3 -7
- package/dist/state/images.js +1 -5
- package/dist/state/iso-base-media/cached-sample-positions.js +8 -13
- package/dist/state/iso-base-media/iso-state.js +5 -9
- package/dist/state/iso-base-media/moov-box.js +1 -5
- package/dist/state/keyframes.js +1 -5
- package/dist/state/last-eventloop-break.js +3 -7
- package/dist/state/m3u-state.d.ts +37 -16
- package/dist/state/m3u-state.js +98 -29
- package/dist/state/may-skip-video-data.js +3 -7
- package/dist/state/mp3.js +1 -5
- package/dist/state/need-samples-for-fields.js +1 -5
- package/dist/state/parser-state.d.ts +39 -33
- package/dist/state/parser-state.js +37 -41
- package/dist/state/riff.js +1 -5
- package/dist/state/sample-callbacks.js +8 -12
- package/dist/state/slow-duration-fps.js +1 -5
- package/dist/state/structure.d.ts +4 -4
- package/dist/state/structure.js +1 -5
- package/dist/state/transport-stream.js +3 -7
- package/dist/state/video-section.js +1 -5
- package/dist/state/webm.js +5 -9
- package/dist/throttled-progress.js +21 -14
- package/dist/truthy.js +1 -4
- package/dist/universal.d.ts +1 -0
- package/dist/universal.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -4
- package/dist/web-file.js +1 -17
- package/dist/web.d.ts +1 -0
- package/dist/web.js +1 -0
- package/dist/webcodec-sample-types.d.ts +6 -4
- package/dist/webcodec-sample-types.js +1 -2
- package/dist/worker/forward-controller.d.ts +3 -0
- package/dist/worker/forward-controller.js +20 -0
- package/dist/worker/serialize-error.d.ts +4 -0
- package/dist/worker/serialize-error.js +95 -0
- package/dist/worker/worker-types.d.ts +243 -0
- package/dist/worker/worker-types.js +1 -0
- package/dist/worker-bun-entry.d.ts +1 -0
- package/dist/worker-bun-entry.js +5 -0
- package/dist/worker-entry.d.ts +1 -0
- package/dist/worker-entry.js +5 -0
- package/dist/worker-server-entry.d.ts +1 -0
- package/dist/worker-server-entry.js +5 -0
- package/dist/worker-server.d.ts +2 -0
- package/dist/worker-server.js +381 -0
- package/dist/worker-web-entry.d.ts +1 -0
- package/dist/worker-web-entry.js +5 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +267 -0
- package/dist/writers/node.js +16 -23
- package/dist/writers/writer.js +1 -2
- package/package.json +40 -21
- package/fetch.js +0 -2
- package/test.json +0 -663
- package/web-file.js +0 -2
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const get_video_codec_1 = require("./get-video-codec");
|
|
17
|
-
const get_metadata_1 = require("./metadata/get-metadata");
|
|
18
|
-
const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name, mimeType, fieldsInReturnValue, }) => {
|
|
1
|
+
import { getM3uStreams } from './containers/m3u/get-streams';
|
|
2
|
+
import { getAudioCodec } from './get-audio-codec';
|
|
3
|
+
import { getContainer } from './get-container';
|
|
4
|
+
import { getDimensions } from './get-dimensions';
|
|
5
|
+
import { getDuration } from './get-duration';
|
|
6
|
+
import { getFps } from './get-fps';
|
|
7
|
+
import { getIsHdr } from './get-is-hdr';
|
|
8
|
+
import { getKeyframes } from './get-keyframes';
|
|
9
|
+
import { getLocation } from './get-location';
|
|
10
|
+
import { getNumberOfAudioChannels } from './get-number-of-audio-channels';
|
|
11
|
+
import { getSampleRate } from './get-sample-rate';
|
|
12
|
+
import { getTracks } from './get-tracks';
|
|
13
|
+
import { getVideoCodec } from './get-video-codec';
|
|
14
|
+
import { getMetadata } from './metadata/get-metadata';
|
|
15
|
+
export const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name, mimeType, fieldsInReturnValue, }) => {
|
|
19
16
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
20
17
|
const keys = Object.keys(hasInfo);
|
|
21
18
|
const { emittedFields } = state;
|
|
@@ -33,7 +30,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
33
30
|
if (key === 'durationInSeconds') {
|
|
34
31
|
if (hasInfo.durationInSeconds) {
|
|
35
32
|
if (!emittedFields.durationInSeconds) {
|
|
36
|
-
const durationInSeconds =
|
|
33
|
+
const durationInSeconds = getDuration(state);
|
|
37
34
|
await ((_b = callbacks.onDurationInSeconds) === null || _b === void 0 ? void 0 : _b.call(callbacks, durationInSeconds));
|
|
38
35
|
if (fieldsInReturnValue.durationInSeconds) {
|
|
39
36
|
returnValue.durationInSeconds = durationInSeconds;
|
|
@@ -46,7 +43,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
46
43
|
if (key === 'slowDurationInSeconds') {
|
|
47
44
|
if (hasInfo.slowDurationInSeconds &&
|
|
48
45
|
!emittedFields.slowDurationInSeconds) {
|
|
49
|
-
const slowDurationInSeconds = (_c =
|
|
46
|
+
const slowDurationInSeconds = (_c = getDuration(state)) !== null && _c !== void 0 ? _c : state.slowDurationAndFps.getSlowDurationInSeconds();
|
|
50
47
|
await ((_d = callbacks.onSlowDurationInSeconds) === null || _d === void 0 ? void 0 : _d.call(callbacks, slowDurationInSeconds));
|
|
51
48
|
if (fieldsInReturnValue.slowDurationInSeconds) {
|
|
52
49
|
returnValue.slowDurationInSeconds = slowDurationInSeconds;
|
|
@@ -58,7 +55,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
58
55
|
if (key === 'fps') {
|
|
59
56
|
if (hasInfo.fps) {
|
|
60
57
|
if (!emittedFields.fps) {
|
|
61
|
-
const fps =
|
|
58
|
+
const fps = getFps(state);
|
|
62
59
|
await ((_e = callbacks.onFps) === null || _e === void 0 ? void 0 : _e.call(callbacks, fps));
|
|
63
60
|
if (fieldsInReturnValue.fps) {
|
|
64
61
|
returnValue.fps = fps;
|
|
@@ -66,7 +63,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
66
63
|
emittedFields.fps = true;
|
|
67
64
|
}
|
|
68
65
|
if (!emittedFields.slowFps) {
|
|
69
|
-
const fps =
|
|
66
|
+
const fps = getFps(state);
|
|
70
67
|
if (fps) {
|
|
71
68
|
await ((_f = callbacks.onSlowFps) === null || _f === void 0 ? void 0 : _f.call(callbacks, fps));
|
|
72
69
|
if (fieldsInReturnValue.slowFps) {
|
|
@@ -92,7 +89,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
92
89
|
}
|
|
93
90
|
if (key === 'dimensions') {
|
|
94
91
|
if (hasInfo.dimensions && !emittedFields.dimensions) {
|
|
95
|
-
const dimensionsQueried =
|
|
92
|
+
const dimensionsQueried = getDimensions(state);
|
|
96
93
|
const dimensions = dimensionsQueried === null
|
|
97
94
|
? null
|
|
98
95
|
: {
|
|
@@ -109,7 +106,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
109
106
|
}
|
|
110
107
|
if (key === 'unrotatedDimensions') {
|
|
111
108
|
if (hasInfo.unrotatedDimensions && !emittedFields.unrotatedDimensions) {
|
|
112
|
-
const dimensionsQueried =
|
|
109
|
+
const dimensionsQueried = getDimensions(state);
|
|
113
110
|
const unrotatedDimensions = dimensionsQueried === null
|
|
114
111
|
? null
|
|
115
112
|
: {
|
|
@@ -126,7 +123,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
126
123
|
}
|
|
127
124
|
if (key === 'rotation') {
|
|
128
125
|
if (hasInfo.rotation && !emittedFields.rotation) {
|
|
129
|
-
const dimensionsQueried =
|
|
126
|
+
const dimensionsQueried = getDimensions(state);
|
|
130
127
|
const rotation = (_k = dimensionsQueried === null || dimensionsQueried === void 0 ? void 0 : dimensionsQueried.rotation) !== null && _k !== void 0 ? _k : 0;
|
|
131
128
|
await ((_l = callbacks.onRotation) === null || _l === void 0 ? void 0 : _l.call(callbacks, rotation));
|
|
132
129
|
if (fieldsInReturnValue.rotation) {
|
|
@@ -138,7 +135,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
138
135
|
}
|
|
139
136
|
if (key === 'videoCodec') {
|
|
140
137
|
if (!emittedFields.videoCodec && hasInfo.videoCodec) {
|
|
141
|
-
const videoCodec =
|
|
138
|
+
const videoCodec = getVideoCodec(state);
|
|
142
139
|
await ((_m = callbacks.onVideoCodec) === null || _m === void 0 ? void 0 : _m.call(callbacks, videoCodec));
|
|
143
140
|
if (fieldsInReturnValue.videoCodec) {
|
|
144
141
|
returnValue.videoCodec = videoCodec;
|
|
@@ -149,7 +146,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
149
146
|
}
|
|
150
147
|
if (key === 'audioCodec') {
|
|
151
148
|
if (!emittedFields.audioCodec && hasInfo.audioCodec) {
|
|
152
|
-
const audioCodec =
|
|
149
|
+
const audioCodec = getAudioCodec(state);
|
|
153
150
|
await ((_o = callbacks.onAudioCodec) === null || _o === void 0 ? void 0 : _o.call(callbacks, audioCodec));
|
|
154
151
|
if (fieldsInReturnValue.audioCodec) {
|
|
155
152
|
returnValue.audioCodec = audioCodec;
|
|
@@ -160,7 +157,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
160
157
|
}
|
|
161
158
|
if (key === 'tracks') {
|
|
162
159
|
if (!emittedFields.tracks && hasInfo.tracks) {
|
|
163
|
-
const { videoTracks, audioTracks } =
|
|
160
|
+
const { videoTracks, audioTracks } = getTracks(state);
|
|
164
161
|
await ((_p = callbacks.onTracks) === null || _p === void 0 ? void 0 : _p.call(callbacks, { videoTracks, audioTracks }));
|
|
165
162
|
if (fieldsInReturnValue.tracks) {
|
|
166
163
|
returnValue.tracks = { videoTracks, audioTracks };
|
|
@@ -212,7 +209,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
212
209
|
}
|
|
213
210
|
if (key === 'isHdr') {
|
|
214
211
|
if (!returnValue.isHdr && hasInfo.isHdr) {
|
|
215
|
-
const isHdr =
|
|
212
|
+
const isHdr = getIsHdr(state);
|
|
216
213
|
await ((_t = callbacks.onIsHdr) === null || _t === void 0 ? void 0 : _t.call(callbacks, isHdr));
|
|
217
214
|
if (fieldsInReturnValue.isHdr) {
|
|
218
215
|
returnValue.isHdr = isHdr;
|
|
@@ -223,7 +220,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
223
220
|
}
|
|
224
221
|
if (key === 'container') {
|
|
225
222
|
if (!returnValue.container && hasInfo.container) {
|
|
226
|
-
const container =
|
|
223
|
+
const container = getContainer(state.getStructure());
|
|
227
224
|
await ((_u = callbacks.onContainer) === null || _u === void 0 ? void 0 : _u.call(callbacks, container));
|
|
228
225
|
if (fieldsInReturnValue.container) {
|
|
229
226
|
returnValue.container = container;
|
|
@@ -234,7 +231,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
234
231
|
}
|
|
235
232
|
if (key === 'metadata') {
|
|
236
233
|
if (!emittedFields.metadata && hasInfo.metadata) {
|
|
237
|
-
const metadata =
|
|
234
|
+
const metadata = getMetadata(state);
|
|
238
235
|
await ((_v = callbacks.onMetadata) === null || _v === void 0 ? void 0 : _v.call(callbacks, metadata));
|
|
239
236
|
if (fieldsInReturnValue.metadata) {
|
|
240
237
|
returnValue.metadata = metadata;
|
|
@@ -245,7 +242,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
245
242
|
}
|
|
246
243
|
if (key === 'location') {
|
|
247
244
|
if (!emittedFields.location && hasInfo.location) {
|
|
248
|
-
const location =
|
|
245
|
+
const location = getLocation(state);
|
|
249
246
|
await ((_w = callbacks.onLocation) === null || _w === void 0 ? void 0 : _w.call(callbacks, location));
|
|
250
247
|
if (fieldsInReturnValue.location) {
|
|
251
248
|
returnValue.location = location;
|
|
@@ -299,9 +296,9 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
299
296
|
}
|
|
300
297
|
if (key === 'keyframes') {
|
|
301
298
|
if (!emittedFields.keyframes && hasInfo.keyframes) {
|
|
302
|
-
await ((_1 = callbacks.onKeyframes) === null || _1 === void 0 ? void 0 : _1.call(callbacks,
|
|
299
|
+
await ((_1 = callbacks.onKeyframes) === null || _1 === void 0 ? void 0 : _1.call(callbacks, getKeyframes(state)));
|
|
303
300
|
if (fieldsInReturnValue.keyframes) {
|
|
304
|
-
returnValue.keyframes =
|
|
301
|
+
returnValue.keyframes = getKeyframes(state);
|
|
305
302
|
}
|
|
306
303
|
emittedFields.keyframes = true;
|
|
307
304
|
}
|
|
@@ -319,7 +316,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
319
316
|
}
|
|
320
317
|
if (key === 'sampleRate') {
|
|
321
318
|
if (!emittedFields.sampleRate && hasInfo.sampleRate) {
|
|
322
|
-
const sampleRate =
|
|
319
|
+
const sampleRate = getSampleRate(state);
|
|
323
320
|
await ((_3 = callbacks.onSampleRate) === null || _3 === void 0 ? void 0 : _3.call(callbacks, sampleRate));
|
|
324
321
|
if (fieldsInReturnValue.sampleRate) {
|
|
325
322
|
returnValue.sampleRate = sampleRate;
|
|
@@ -331,7 +328,7 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
331
328
|
if (key === 'numberOfAudioChannels') {
|
|
332
329
|
if (!emittedFields.numberOfAudioChannels &&
|
|
333
330
|
hasInfo.numberOfAudioChannels) {
|
|
334
|
-
const numberOfAudioChannels =
|
|
331
|
+
const numberOfAudioChannels = getNumberOfAudioChannels(state);
|
|
335
332
|
await ((_4 = callbacks.onNumberOfAudioChannels) === null || _4 === void 0 ? void 0 : _4.call(callbacks, numberOfAudioChannels));
|
|
336
333
|
if (fieldsInReturnValue.numberOfAudioChannels) {
|
|
337
334
|
returnValue.numberOfAudioChannels = numberOfAudioChannels;
|
|
@@ -342,7 +339,11 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
342
339
|
}
|
|
343
340
|
if (key === 'm3uStreams') {
|
|
344
341
|
if (!emittedFields.m3uStreams && hasInfo.m3uStreams) {
|
|
345
|
-
const streams =
|
|
342
|
+
const streams = getM3uStreams({
|
|
343
|
+
structure: state.getStructureOrNull(),
|
|
344
|
+
originalSrc: state.src,
|
|
345
|
+
readerInterface: state.readerInterface,
|
|
346
|
+
});
|
|
346
347
|
await ((_5 = callbacks.onM3uStreams) === null || _5 === void 0 ? void 0 : _5.call(callbacks, streams));
|
|
347
348
|
if (fieldsInReturnValue.m3uStreams) {
|
|
348
349
|
returnValue.m3uStreams = streams;
|
|
@@ -354,4 +355,3 @@ const emitAvailableInfo = async ({ hasInfo, callbacks, state, returnValue, name,
|
|
|
354
355
|
throw new Error(`Unhandled key: ${key}`);
|
|
355
356
|
}
|
|
356
357
|
};
|
|
357
|
-
exports.emitAvailableInfo = emitAvailableInfo;
|
package/dist/emitter.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MediaParserEmitter = void 0;
|
|
4
|
-
class MediaParserEmitter {
|
|
1
|
+
export class MediaParserEmitter {
|
|
5
2
|
constructor() {
|
|
6
3
|
this.listeners = {
|
|
7
4
|
pause: [],
|
|
@@ -30,4 +27,3 @@ class MediaParserEmitter {
|
|
|
30
27
|
});
|
|
31
28
|
}
|
|
32
29
|
}
|
|
33
|
-
exports.MediaParserEmitter = MediaParserEmitter;
|
package/dist/errors.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ export declare class IsAGifError extends Error {
|
|
|
9
9
|
fileName: string | null;
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
type ImageType = 'png' | 'jpeg' | 'bmp' | 'webp';
|
|
13
|
-
type Dimensions = {
|
|
12
|
+
export type ImageType = 'png' | 'jpeg' | 'bmp' | 'webp';
|
|
13
|
+
export type Dimensions = {
|
|
14
14
|
width: number;
|
|
15
15
|
height: number;
|
|
16
16
|
};
|
|
@@ -51,22 +51,7 @@ export declare class IsAnUnsupportedFileTypeError extends Error {
|
|
|
51
51
|
fileName: string | null;
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
type UnsupportedAudioType = never;
|
|
55
|
-
export declare class IsAnUnsupportedAudioTypeError extends Error {
|
|
56
|
-
mimeType: string | null;
|
|
57
|
-
sizeInBytes: number | null;
|
|
58
|
-
fileName: string | null;
|
|
59
|
-
audioType: UnsupportedAudioType | null;
|
|
60
|
-
constructor({ message, mimeType, sizeInBytes, fileName, audioType, }: {
|
|
61
|
-
message: string;
|
|
62
|
-
mimeType: string | null;
|
|
63
|
-
sizeInBytes: number | null;
|
|
64
|
-
fileName: string | null;
|
|
65
|
-
audioType: UnsupportedAudioType | null;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
54
|
export declare class MediaParserAbortError extends Error {
|
|
69
55
|
constructor(message: string);
|
|
70
56
|
}
|
|
71
57
|
export declare const hasBeenAborted: (error: unknown) => error is MediaParserAbortError;
|
|
72
|
-
export {};
|
package/dist/errors.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasBeenAborted = exports.MediaParserAbortError = exports.IsAnUnsupportedAudioTypeError = exports.IsAnUnsupportedFileTypeError = exports.IsAPdfError = exports.IsAnImageError = exports.IsAGifError = void 0;
|
|
4
|
-
class IsAGifError extends Error {
|
|
1
|
+
export class IsAGifError extends Error {
|
|
5
2
|
constructor({ message, mimeType, sizeInBytes, fileName, }) {
|
|
6
3
|
super(message);
|
|
4
|
+
this.name = 'IsAGifError';
|
|
7
5
|
this.fileName = 'IsAGifError';
|
|
8
6
|
this.mimeType = mimeType;
|
|
9
7
|
this.sizeInBytes = sizeInBytes;
|
|
@@ -13,8 +11,7 @@ class IsAGifError extends Error {
|
|
|
13
11
|
}
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
class IsAnImageError extends Error {
|
|
14
|
+
export class IsAnImageError extends Error {
|
|
18
15
|
constructor({ dimensions, imageType, message, mimeType, sizeInBytes, fileName, }) {
|
|
19
16
|
super(message);
|
|
20
17
|
this.name = 'IsAnImageError';
|
|
@@ -28,8 +25,7 @@ class IsAnImageError extends Error {
|
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
|
-
|
|
32
|
-
class IsAPdfError extends Error {
|
|
28
|
+
export class IsAPdfError extends Error {
|
|
33
29
|
constructor({ message, mimeType, sizeInBytes, fileName, }) {
|
|
34
30
|
super(message);
|
|
35
31
|
this.name = 'IsAPdfError';
|
|
@@ -41,8 +37,7 @@ class IsAPdfError extends Error {
|
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
class IsAnUnsupportedFileTypeError extends Error {
|
|
40
|
+
export class IsAnUnsupportedFileTypeError extends Error {
|
|
46
41
|
constructor({ message, mimeType, sizeInBytes, fileName, }) {
|
|
47
42
|
super(message);
|
|
48
43
|
this.name = 'IsAnUnsupportedFileTypeError';
|
|
@@ -54,30 +49,15 @@ class IsAnUnsupportedFileTypeError extends Error {
|
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
|
-
|
|
58
|
-
class IsAnUnsupportedAudioTypeError extends Error {
|
|
59
|
-
constructor({ message, mimeType, sizeInBytes, fileName, audioType, }) {
|
|
60
|
-
super(message);
|
|
61
|
-
this.name = 'IsAnUnsupportedAudioTypeError';
|
|
62
|
-
this.mimeType = mimeType;
|
|
63
|
-
this.sizeInBytes = sizeInBytes;
|
|
64
|
-
this.fileName = fileName;
|
|
65
|
-
this.audioType = audioType;
|
|
66
|
-
if (Error.captureStackTrace) {
|
|
67
|
-
Error.captureStackTrace(this, IsAnUnsupportedAudioTypeError);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.IsAnUnsupportedAudioTypeError = IsAnUnsupportedAudioTypeError;
|
|
72
|
-
class MediaParserAbortError extends Error {
|
|
52
|
+
export class MediaParserAbortError extends Error {
|
|
73
53
|
constructor(message) {
|
|
74
54
|
super(message);
|
|
75
55
|
this.name = 'MediaParserAbortError';
|
|
76
56
|
this.cause = undefined;
|
|
77
57
|
}
|
|
78
58
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
export const hasBeenAborted = (error) => {
|
|
60
|
+
return (error instanceof MediaParserAbortError ||
|
|
61
|
+
// On worker it is not the same instance, but same name
|
|
62
|
+
error.name === 'MediaParserAbortError');
|
|
82
63
|
};
|
|
83
|
-
exports.hasBeenAborted = hasBeenAborted;
|
package/dist/esm/fetch.mjs
CHANGED
|
@@ -80,89 +80,115 @@ function parseContentRange(input) {
|
|
|
80
80
|
return range;
|
|
81
81
|
}
|
|
82
82
|
var validateContentRangeAndDetectIfSupported = ({
|
|
83
|
-
|
|
83
|
+
requestedRange,
|
|
84
84
|
parsedContentRange,
|
|
85
85
|
statusCode
|
|
86
86
|
}) => {
|
|
87
87
|
if (statusCode === 206) {
|
|
88
88
|
return { supportsContentRange: true };
|
|
89
89
|
}
|
|
90
|
-
if (typeof
|
|
91
|
-
if (
|
|
90
|
+
if (typeof requestedRange === "number" && parsedContentRange?.start !== requestedRange) {
|
|
91
|
+
if (requestedRange === 0) {
|
|
92
92
|
return { supportsContentRange: false };
|
|
93
93
|
}
|
|
94
|
-
throw new Error(`Range header (${
|
|
94
|
+
throw new Error(`Range header (${requestedRange}) does not match content-range header (${parsedContentRange?.start})`);
|
|
95
95
|
}
|
|
96
|
-
if (
|
|
97
|
-
throw new Error(`Range header (${
|
|
96
|
+
if (requestedRange !== null && typeof requestedRange !== "number" && (parsedContentRange?.start !== requestedRange[0] || parsedContentRange?.end !== requestedRange[1])) {
|
|
97
|
+
throw new Error(`Range header (${requestedRange}) does not match content-range header (${parsedContentRange?.start})`);
|
|
98
98
|
}
|
|
99
99
|
return { supportsContentRange: true };
|
|
100
100
|
};
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
101
|
+
var fetchReadContent = async ({
|
|
102
|
+
src,
|
|
103
|
+
range,
|
|
104
|
+
controller
|
|
105
|
+
}) => {
|
|
106
|
+
if (typeof src !== "string" && src instanceof URL === false) {
|
|
107
|
+
throw new Error("src must be a string when using `fetchReader`");
|
|
108
|
+
}
|
|
109
|
+
const resolvedUrl = resolveUrl(src);
|
|
110
|
+
const resolvedUrlString = resolvedUrl.toString();
|
|
111
|
+
if (!resolvedUrlString.startsWith("https://") && !resolvedUrlString.startsWith("blob:") && !resolvedUrlString.startsWith("http://")) {
|
|
112
|
+
return Promise.reject(new Error(`${resolvedUrlString} is not a URL - needs to start with http:// or https:// or blob:. If you want to read a local file, pass \`reader: nodeReader\` to parseMedia().`));
|
|
113
|
+
}
|
|
114
|
+
const ownController = new AbortController;
|
|
115
|
+
const cache = typeof navigator !== "undefined" && navigator.userAgent.includes("Cloudflare-Workers") ? undefined : "no-store";
|
|
116
|
+
const requestedRange = range === null ? 0 : range;
|
|
117
|
+
const asString = typeof resolvedUrl === "string" ? resolvedUrl : resolvedUrl.pathname;
|
|
118
|
+
const requestWithoutRange = asString.endsWith(".m3u8");
|
|
119
|
+
const canLiveWithoutContentLength = asString.endsWith(".m3u8") || asString.endsWith(".ts");
|
|
120
|
+
const headers = requestedRange === 0 && requestWithoutRange ? {} : typeof requestedRange === "number" ? {
|
|
121
|
+
Range: `bytes=${requestedRange}-`
|
|
122
|
+
} : {
|
|
123
|
+
Range: `bytes=${`${requestedRange[0]}-${requestedRange[1]}`}`
|
|
124
|
+
};
|
|
125
|
+
const res = await fetch(resolvedUrl, {
|
|
126
|
+
headers,
|
|
127
|
+
signal: ownController.signal,
|
|
128
|
+
cache
|
|
129
|
+
});
|
|
130
|
+
const contentRange = res.headers.get("content-range");
|
|
131
|
+
const parsedContentRange = contentRange ? parseContentRange(contentRange) : null;
|
|
132
|
+
const { supportsContentRange } = validateContentRangeAndDetectIfSupported({
|
|
133
|
+
requestedRange,
|
|
134
|
+
parsedContentRange,
|
|
135
|
+
statusCode: res.status
|
|
136
|
+
});
|
|
137
|
+
controller._internals.signal.addEventListener("abort", () => {
|
|
138
|
+
ownController.abort(new MediaParserAbortError("Aborted by user"));
|
|
139
|
+
}, { once: true });
|
|
140
|
+
if (res.status.toString().startsWith("4") || res.status.toString().startsWith("5")) {
|
|
141
|
+
throw new Error(`Server returned status code ${res.status} for ${src} and range ${requestedRange}`);
|
|
142
|
+
}
|
|
143
|
+
const contentDisposition = res.headers.get("content-disposition");
|
|
144
|
+
const name = contentDisposition?.match(/filename="([^"]+)"/)?.[1];
|
|
145
|
+
const fallbackName = src.toString().split("/").pop();
|
|
146
|
+
const { contentLength, needsContentRange, reader } = await getLengthAndReader({
|
|
147
|
+
canLiveWithoutContentLength,
|
|
148
|
+
res,
|
|
149
|
+
ownController,
|
|
150
|
+
requestedWithoutRange: requestWithoutRange
|
|
151
|
+
});
|
|
152
|
+
if (controller) {
|
|
134
153
|
controller._internals.signal.addEventListener("abort", () => {
|
|
135
|
-
|
|
154
|
+
reader.reader.cancel().catch(() => {
|
|
155
|
+
});
|
|
136
156
|
}, { once: true });
|
|
137
|
-
if (res.status.toString().startsWith("4") || res.status.toString().startsWith("5")) {
|
|
138
|
-
throw new Error(`Server returned status code ${res.status} for ${src} and range ${actualRange}`);
|
|
139
|
-
}
|
|
140
|
-
const contentDisposition = res.headers.get("content-disposition");
|
|
141
|
-
const name = contentDisposition?.match(/filename="([^"]+)"/)?.[1];
|
|
142
|
-
const fallbackName = src.split("/").pop();
|
|
143
|
-
const { contentLength, needsContentRange, reader } = await getLengthAndReader({
|
|
144
|
-
canLiveWithoutContentLength,
|
|
145
|
-
res,
|
|
146
|
-
ownController,
|
|
147
|
-
requestedWithoutRange: requestWithoutRange
|
|
148
|
-
});
|
|
149
|
-
if (controller) {
|
|
150
|
-
controller._internals.signal.addEventListener("abort", () => {
|
|
151
|
-
reader.reader.cancel().catch(() => {
|
|
152
|
-
});
|
|
153
|
-
}, { once: true });
|
|
154
|
-
}
|
|
155
|
-
return {
|
|
156
|
-
reader,
|
|
157
|
-
contentLength,
|
|
158
|
-
contentType: res.headers.get("content-type"),
|
|
159
|
-
name: name ?? fallbackName,
|
|
160
|
-
supportsContentRange,
|
|
161
|
-
needsContentRange
|
|
162
|
-
};
|
|
163
157
|
}
|
|
158
|
+
return {
|
|
159
|
+
reader,
|
|
160
|
+
contentLength,
|
|
161
|
+
contentType: res.headers.get("content-type"),
|
|
162
|
+
name: name ?? fallbackName,
|
|
163
|
+
supportsContentRange,
|
|
164
|
+
needsContentRange
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
var fetchReadWholeAsText = async (src) => {
|
|
168
|
+
if (typeof src !== "string" && src instanceof URL === false) {
|
|
169
|
+
throw new Error("src must be a string when using `fetchReader`");
|
|
170
|
+
}
|
|
171
|
+
const res = await fetch(src);
|
|
172
|
+
if (!res.ok) {
|
|
173
|
+
throw new Error(`Failed to fetch ${src} (HTTP code: ${res.status})`);
|
|
174
|
+
}
|
|
175
|
+
return res.text();
|
|
176
|
+
};
|
|
177
|
+
var fetchCreateAdjacentFileSource = (relativePath, src) => {
|
|
178
|
+
if (typeof src !== "string" && src instanceof URL === false) {
|
|
179
|
+
throw new Error("src must be a string or URL when using `fetchReader`");
|
|
180
|
+
}
|
|
181
|
+
return new URL(relativePath, src).toString();
|
|
182
|
+
};
|
|
183
|
+
var fetchReader = {
|
|
184
|
+
read: fetchReadContent,
|
|
185
|
+
readWholeAsText: fetchReadWholeAsText,
|
|
186
|
+
createAdjacentFileSource: fetchCreateAdjacentFileSource
|
|
164
187
|
};
|
|
165
188
|
export {
|
|
166
189
|
parseContentRange,
|
|
167
|
-
fetchReader
|
|
190
|
+
fetchReader,
|
|
191
|
+
fetchReadWholeAsText,
|
|
192
|
+
fetchReadContent,
|
|
193
|
+
fetchCreateAdjacentFileSource
|
|
168
194
|
};
|