dasha 4.4.4 → 4.4.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.mts +8 -2
- package/dist/index.mjs +30 -0
- package/package.json +11 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioCodec as AudioCodec$1, DurationMetadataRequestOptions, EncodedPacket, FilePathSource, HLS, HLS_FORMATS, Input as Input$1, InputAudioTrack as InputAudioTrack$1, InputFormat, InputOptions, InputTrack as InputTrack$2, InputTrackQuery, InputTrackQuery as InputTrackQuery$1, InputVideoTrack as InputVideoTrack$1, MP3, MP4, MaybePromise, MediaCodec as MediaCodec$1, MetadataTags, PacketRetrievalOptions, PathedSource, Source, SourceRef, SubtitleCodec as SubtitleCodec$1, TrackDisposition, UrlSource, VideoCodec as VideoCodec$1, asc, desc, prefer } from "mediabunny";
|
|
1
|
+
import { AudioCodec as AudioCodec$1, DurationMetadataRequestOptions, EncodedPacket, FilePathSource, HLS, HLS_FORMATS, Input as Input$1, InputAudioTrack as InputAudioTrack$1, InputFormat, InputOptions, InputTrack as InputTrack$2, InputTrackQuery, InputTrackQuery as InputTrackQuery$1, InputVideoTrack as InputVideoTrack$1, MP3, MP4, MaybePromise, MaybePromise as MaybePromise$1, MediaCodec as MediaCodec$1, MetadataTags, PacketRetrievalOptions, PathedSource, Source, SourceRef, SubtitleCodec as SubtitleCodec$1, TrackDisposition, UrlSource, VideoCodec as VideoCodec$1, asc, desc, prefer } from "mediabunny";
|
|
2
2
|
|
|
3
3
|
//#region src/mediabunny.d.ts
|
|
4
4
|
type Segment$1 = {
|
|
@@ -439,12 +439,18 @@ declare const DASH: DashInputFormat;
|
|
|
439
439
|
declare const DASH_FORMATS: InputFormat[];
|
|
440
440
|
//#endregion
|
|
441
441
|
//#region src/hls/hls-subtitles.d.ts
|
|
442
|
-
type
|
|
442
|
+
type ReadResult = {
|
|
443
|
+
bytes: Uint8Array;
|
|
444
|
+
view: DataView; /** The offset of the bytes in the file. */
|
|
445
|
+
offset: number;
|
|
446
|
+
};
|
|
447
|
+
type SourceWithRootPath = Source & {
|
|
443
448
|
rootPath: string;
|
|
444
449
|
_options?: {
|
|
445
450
|
requestInit?: RequestInit;
|
|
446
451
|
};
|
|
447
452
|
_url?: string | URL | Request;
|
|
453
|
+
_read(start: number, end: number, minReadPosition: number, maxReadPosition: number): MaybePromise$1<ReadResult | null>;
|
|
448
454
|
};
|
|
449
455
|
type HlsSubtitleMediaTag = {
|
|
450
456
|
autoselect: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -662,6 +662,17 @@ const loadPlaylistText = async (source, path) => {
|
|
|
662
662
|
path,
|
|
663
663
|
text: await readFile(new URL(path), "utf8")
|
|
664
664
|
};
|
|
665
|
+
if (path === source.rootPath && typeof source.getSize === "function" && typeof source._read === "function") {
|
|
666
|
+
const size = await source.getSize();
|
|
667
|
+
const result = await source._read(0, size, 0, Infinity);
|
|
668
|
+
if (result) {
|
|
669
|
+
const data = result.bytes.subarray(result.offset, result.offset + size);
|
|
670
|
+
return {
|
|
671
|
+
path,
|
|
672
|
+
text: new TextDecoder().decode(data)
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
}
|
|
665
676
|
return {
|
|
666
677
|
path,
|
|
667
678
|
text: await readFile(path, "utf8")
|
|
@@ -1416,6 +1427,7 @@ const BACKING_TYPE_AUDIO = "audio";
|
|
|
1416
1427
|
const BACKING_TYPE_VIDEO = "video";
|
|
1417
1428
|
const BASE_INPUT_PATCHED = Symbol.for("dasha.base-mediabunny-input-patched");
|
|
1418
1429
|
const PRESERVE_SUBTITLE_BACKINGS = Symbol.for("dasha.preserve-subtitle-backings");
|
|
1430
|
+
const resolvedHlsSegmentLocations = /* @__PURE__ */ new WeakSet();
|
|
1419
1431
|
const getDefaultAudioTrackFormats = (source) => {
|
|
1420
1432
|
return isLikelyDashPath(source instanceof SourceRef ? source.source : source) ? [DASH, ...ALL_FORMATS$1] : [...ALL_FORMATS$1, DASH];
|
|
1421
1433
|
};
|
|
@@ -1579,6 +1591,22 @@ const getSegmentedInputForTrack = (track) => {
|
|
|
1579
1591
|
const internalTrack = backing.internalTrack;
|
|
1580
1592
|
return internalTrack.demuxer.getSegmentedInputForPath(internalTrack.fullPath);
|
|
1581
1593
|
};
|
|
1594
|
+
const isHlsSegment = (segment) => !("sourcePath" in segment.location);
|
|
1595
|
+
const resolveHlsSegmentLocation = async (source, location) => {
|
|
1596
|
+
if (resolvedHlsSegmentLocations.has(location)) return;
|
|
1597
|
+
location.path = await resolvePathedSourcePath(source, {
|
|
1598
|
+
path: location.path,
|
|
1599
|
+
isRoot: false
|
|
1600
|
+
});
|
|
1601
|
+
resolvedHlsSegmentLocations.add(location);
|
|
1602
|
+
};
|
|
1603
|
+
const resolveHlsSegments = async (source, segments) => {
|
|
1604
|
+
for (const segment of segments) {
|
|
1605
|
+
if (!isHlsSegment(segment)) continue;
|
|
1606
|
+
if (segment.initSegment) await resolveHlsSegmentLocation(source, segment.initSegment.location);
|
|
1607
|
+
await resolveHlsSegmentLocation(source, segment.location);
|
|
1608
|
+
}
|
|
1609
|
+
};
|
|
1582
1610
|
const getTrackBacking = (track) => track._backing;
|
|
1583
1611
|
const getTrackSource = (track) => {
|
|
1584
1612
|
return getTrackBacking(track).getSource?.() ?? track.input.source;
|
|
@@ -1602,11 +1630,13 @@ const addSegmentAccess = (track) => new Proxy(track, { get(target, prop) {
|
|
|
1602
1630
|
if (prop === "getSegments") return async () => {
|
|
1603
1631
|
const segmentedInput = getSegmentedInputForTrack(target);
|
|
1604
1632
|
if (segmentedInput.segments.length === 0) await segmentedInput.runUpdateSegments();
|
|
1633
|
+
await resolveHlsSegments(getTrackSource(target), segmentedInput.segments);
|
|
1605
1634
|
return segmentedInput.segments;
|
|
1606
1635
|
};
|
|
1607
1636
|
if (prop === "refreshSegments") return async () => {
|
|
1608
1637
|
const segmentedInput = getSegmentedInputForTrack(target);
|
|
1609
1638
|
await segmentedInput.runUpdateSegments();
|
|
1639
|
+
await resolveHlsSegments(getTrackSource(target), segmentedInput.segments);
|
|
1610
1640
|
return segmentedInput.segments;
|
|
1611
1641
|
};
|
|
1612
1642
|
const value = Reflect.get(target, prop, target);
|
package/package.json
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dasha",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.6",
|
|
4
4
|
"description": "Streaming manifest parser",
|
|
5
|
+
"packageManager": "pnpm@11.5.0",
|
|
5
6
|
"files": [
|
|
6
7
|
"dist"
|
|
7
8
|
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "vitest",
|
|
11
|
+
"lint": "oxlint . && oxfmt --check .",
|
|
12
|
+
"fix": "oxlint . --fix && oxfmt --write .",
|
|
13
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
14
|
+
"build": "tsdown src/index.ts --format esm",
|
|
15
|
+
"prepublishOnly": "pnpm build"
|
|
16
|
+
},
|
|
8
17
|
"type": "module",
|
|
9
18
|
"main": "./dist/index.mjs",
|
|
10
19
|
"types": "./dist/index.d.mts",
|
|
@@ -61,12 +70,5 @@
|
|
|
61
70
|
"tsdown": "^0.22.1",
|
|
62
71
|
"typescript": "^6.0.3",
|
|
63
72
|
"vitest": "^4.1.7"
|
|
64
|
-
},
|
|
65
|
-
"scripts": {
|
|
66
|
-
"test": "vitest",
|
|
67
|
-
"lint": "oxlint . && oxfmt --check .",
|
|
68
|
-
"fix": "oxlint . --fix && oxfmt --write .",
|
|
69
|
-
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
70
|
-
"build": "tsdown src/index.ts --format esm"
|
|
71
73
|
}
|
|
72
|
-
}
|
|
74
|
+
}
|