@amazon/vinyl-hls-parser 1.1.1 → 2.0.0

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.
Files changed (84) hide show
  1. package/dist/hlsTestAssets/types/current/tsconfig.tsbuildinfo +1 -1
  2. package/dist/index.cjs +140 -58
  3. package/dist/index.cjs.map +4 -4
  4. package/dist/index.js +139 -57
  5. package/dist/index.js.map +4 -4
  6. package/dist/test/benchmark.es5.js +79 -255
  7. package/dist/test/benchmark.js +584 -1224
  8. package/dist/test/benchmark.js.map +4 -4
  9. package/dist/types/current/index.d.ts +11 -10
  10. package/dist/types/current/index.d.ts.map +1 -1
  11. package/dist/types/current/index.js +11 -10
  12. package/dist/types/current/parse/parseMainPlaylist.d.ts +8 -3
  13. package/dist/types/current/parse/parseMainPlaylist.d.ts.map +1 -1
  14. package/dist/types/current/parse/parseMainPlaylist.js +43 -5
  15. package/dist/types/current/parse/parseMediaPlaylist.d.ts +11 -4
  16. package/dist/types/current/parse/parseMediaPlaylist.d.ts.map +1 -1
  17. package/dist/types/current/parse/parseMediaPlaylist.js +111 -7
  18. package/dist/types/current/tsconfig.tsbuildinfo +1 -1
  19. package/dist/types/current/types/AlternativeRendition.d.ts +13 -0
  20. package/dist/types/current/types/AlternativeRendition.d.ts.map +1 -1
  21. package/dist/types/current/types/HlsDateRange.d.ts +51 -0
  22. package/dist/types/current/types/HlsDateRange.d.ts.map +1 -0
  23. package/dist/types/current/types/HlsDateRange.js +11 -0
  24. package/dist/types/{ts4.7/types/MainPlaylist.d.ts → current/types/HlsMainPlaylist.d.ts} +4 -4
  25. package/dist/types/current/types/HlsMainPlaylist.d.ts.map +1 -0
  26. package/dist/types/{ts4.1/types/MediaPlaylist.d.ts → current/types/HlsMediaPlaylist.d.ts} +11 -4
  27. package/dist/types/current/types/HlsMediaPlaylist.d.ts.map +1 -0
  28. package/dist/types/ts3.7/index.d.ts +11 -10
  29. package/dist/types/ts3.7/parse/parseMainPlaylist.d.ts +8 -3
  30. package/dist/types/ts3.7/parse/parseMediaPlaylist.d.ts +11 -4
  31. package/dist/types/ts3.7/types/AlternativeRendition.d.ts +13 -0
  32. package/dist/types/ts3.7/types/HlsDateRange.d.ts +51 -0
  33. package/dist/types/ts3.7/types/{MainPlaylist.d.ts → HlsMainPlaylist.d.ts} +4 -4
  34. package/dist/types/ts3.7/types/{MediaPlaylist.d.ts → HlsMediaPlaylist.d.ts} +11 -4
  35. package/dist/types/ts4.1/index.d.ts +11 -10
  36. package/dist/types/ts4.1/parse/parseMainPlaylist.d.ts +8 -3
  37. package/dist/types/ts4.1/parse/parseMediaPlaylist.d.ts +11 -4
  38. package/dist/types/ts4.1/types/AlternativeRendition.d.ts +13 -0
  39. package/dist/types/ts4.1/types/HlsDateRange.d.ts +51 -0
  40. package/dist/types/{current/types/MainPlaylist.d.ts → ts4.1/types/HlsMainPlaylist.d.ts} +4 -4
  41. package/dist/types/{current/types/MediaPlaylist.d.ts → ts4.1/types/HlsMediaPlaylist.d.ts} +11 -4
  42. package/dist/types/ts4.7/index.d.ts +11 -10
  43. package/dist/types/ts4.7/parse/parseMainPlaylist.d.ts +8 -3
  44. package/dist/types/ts4.7/parse/parseMediaPlaylist.d.ts +11 -4
  45. package/dist/types/ts4.7/types/AlternativeRendition.d.ts +13 -0
  46. package/dist/types/ts4.7/types/HlsDateRange.d.ts +51 -0
  47. package/dist/types/{ts4.1/types/MainPlaylist.d.ts → ts4.7/types/HlsMainPlaylist.d.ts} +4 -4
  48. package/dist/types/ts4.7/types/{MediaPlaylist.d.ts → HlsMediaPlaylist.d.ts} +11 -4
  49. package/package.json +30 -19
  50. package/dist/test/benchmark.css +0 -71
  51. package/dist/test/benchmark.html +0 -67
  52. package/dist/test/favicon.png +0 -0
  53. package/dist/test/index.html +0 -61
  54. package/dist/test/integ.es5.js +0 -410
  55. package/dist/test/integ.js +0 -2127
  56. package/dist/test/integ.js.map +0 -7
  57. package/dist/test/jasmine.css +0 -304
  58. package/dist/test/jasmineHtml.es5.js +0 -670
  59. package/dist/test/jasmineHtml.js +0 -10851
  60. package/dist/test/jasmineHtml.js.map +0 -7
  61. package/dist/test/styles.css +0 -42
  62. package/dist/types/current/types/MainPlaylist.d.ts.map +0 -1
  63. package/dist/types/current/types/MediaPlaylist.d.ts.map +0 -1
  64. package/dist/unit/types/current/index.d.ts +0 -7
  65. package/dist/unit/types/current/index.d.ts.map +0 -1
  66. package/dist/unit/types/current/index.js +0 -6
  67. package/dist/unit/types/current/parse/parseAttributes.test.d.ts +0 -2
  68. package/dist/unit/types/current/parse/parseAttributes.test.d.ts.map +0 -1
  69. package/dist/unit/types/current/parse/parseAttributes.test.js +0 -70
  70. package/dist/unit/types/current/parse/parseMainPlaylist.test.d.ts +0 -2
  71. package/dist/unit/types/current/parse/parseMainPlaylist.test.d.ts.map +0 -1
  72. package/dist/unit/types/current/parse/parseMainPlaylist.test.js +0 -194
  73. package/dist/unit/types/current/parse/parseMediaPlaylist.test.d.ts +0 -2
  74. package/dist/unit/types/current/parse/parseMediaPlaylist.test.d.ts.map +0 -1
  75. package/dist/unit/types/current/parse/parseMediaPlaylist.test.js +0 -401
  76. package/dist/unit/types/current/parse/parseUtil.test.d.ts +0 -2
  77. package/dist/unit/types/current/parse/parseUtil.test.d.ts.map +0 -1
  78. package/dist/unit/types/current/parse/parseUtil.test.js +0 -67
  79. package/dist/unit/types/current/setup.d.ts +0 -2
  80. package/dist/unit/types/current/setup.d.ts.map +0 -1
  81. package/dist/unit/types/current/setup.js +0 -19
  82. package/dist/unit/types/current/tsconfig.tsbuildinfo +0 -1
  83. /package/dist/types/current/types/{MainPlaylist.js → HlsMainPlaylist.js} +0 -0
  84. /package/dist/types/current/types/{MediaPlaylist.js → HlsMediaPlaylist.js} +0 -0
@@ -1,12 +1,19 @@
1
- import { MediaPlaylist } from '../types/MediaPlaylist';
1
+ import { HlsMediaPlaylist } from '../types/HlsMediaPlaylist';
2
2
  export declare const HLS_VARIABLE_PATTERN: RegExp;
3
3
  /**
4
4
  * Parses an HLS media playlist from M3U8 text.
5
5
  *
6
6
  * @param text The raw M3U8 manifest string.
7
- * @param variables Optional variable definitions from the master playlist's #EXT-X-DEFINE tags.
8
- * @returns A readonly MediaPlaylist structure.
7
+ * @param variables Optional variable definitions from the parent multivariant
8
+ * playlist's #EXT-X-DEFINE tags. Media-playlist `#EXT-X-DEFINE:IMPORT="name"`
9
+ * entries resolve against this map. Local `#EXT-X-DEFINE:NAME=,VALUE=`
10
+ * entries are also supported and take precedence.
11
+ * @param queryParams Optional query parameters from the playlist's own URL,
12
+ * used to resolve `#EXT-X-DEFINE:QUERYPARAM="name"` entries (RFC 8216
13
+ * §4.4.5.1). Interstitial ad manifests (e.g. AWS MediaTailor) commonly carry
14
+ * session tokens this way and reference them as `{$name}` in child URIs.
15
+ * @returns A readonly HlsMediaPlaylist structure.
9
16
  * @throws StringParseError if the manifest is malformed.
10
17
  */
11
- export declare function parseMediaPlaylist(text: string, variables?: Readonly<Record<string, string>>): MediaPlaylist;
18
+ export declare function parseMediaPlaylist(text: string, variables?: Readonly<Record<string, string>>, queryParams?: Readonly<Record<string, string>>): HlsMediaPlaylist;
12
19
  //# sourceMappingURL=parseMediaPlaylist.d.ts.map
@@ -23,6 +23,19 @@ export interface AlternativeRendition {
23
23
  readonly default?: boolean;
24
24
  /** Whether the client may choose to play this rendition without explicit user selection (AUTOSELECT). */
25
25
  readonly autoSelect?: boolean;
26
+ /**
27
+ * Whether this is a forced rendition (FORCED=YES): it presents essential
28
+ * text (e.g. translations of foreign dialogue) that should be shown even
29
+ * when the user has not enabled subtitles. Only meaningful for SUBTITLES.
30
+ */
31
+ readonly forced?: boolean;
32
+ /**
33
+ * Media Characteristic Tags (CHARACTERISTICS), a comma-separated list of
34
+ * Uniform Type Identifiers describing the rendition, e.g.
35
+ * `public.accessibility.transcribes-spoken-dialog`. Parsed into individual
36
+ * tags. Absent when the attribute is not present.
37
+ */
38
+ readonly characteristics?: readonly string[];
26
39
  }
27
40
  /**
28
41
  * The media type of an alternative rendition (EXT-X-MEDIA TYPE attribute).
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The CLASS value that identifies an {@link HlsDateRange} as an HLS Interstitial,
3
+ * the server-guided ad insertion (SGAI) primitive defined by Apple.
4
+ *
5
+ * @see https://developer.apple.com/streaming/GettingStartedWithHLSInterstitials.pdf
6
+ */
7
+ export declare const HLS_INTERSTITIAL_CLASS = "com.apple.hls.interstitial";
8
+ /**
9
+ * A parsed EXT-X-DATERANGE tag from an HLS Media Playlist (RFC 8216 §4.3.2.7).
10
+ *
11
+ * A Date Range associates a span of the media timeline, anchored to a wall-clock
12
+ * START-DATE, with a set of application-defined attributes. It is the transport
13
+ * for HLS Interstitials (SGAI): an interstitial is a Date Range whose
14
+ * {@link classId} is {@link HLS_INTERSTITIAL_CLASS} and which carries the
15
+ * `X-ASSET-URI` or `X-ASSET-LIST` client attributes describing the ad content.
16
+ *
17
+ * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.7
18
+ */
19
+ export interface HlsDateRange {
20
+ /** A unique identifier for this Date Range within the playlist (ID). */
21
+ readonly id: string;
22
+ /** The `CLASS` attribute, a client-defined category for the range, if present. */
23
+ readonly classId?: string;
24
+ /** The ISO-8601 wall-clock time at which the range begins (START-DATE). */
25
+ readonly startDate: string;
26
+ /** The ISO-8601 wall-clock time at which the range ends (END-DATE), if present. */
27
+ readonly endDate?: string;
28
+ /** The duration of the range in seconds (DURATION), if present. */
29
+ readonly duration?: number;
30
+ /**
31
+ * The expected duration of the Date Range in seconds.
32
+ * This attribute SHOULD be used to indicate the expected duration of a Date Range whose actual
33
+ * duration is not yet known.
34
+ * It must be positive.
35
+ */
36
+ readonly plannedDuration?: number;
37
+ /**
38
+ * Whether the END-DATE of a live range equals the START-DATE of the
39
+ * range that follows it (END-ON-NEXT=YES). Ranges with this flag must
40
+ * carry a {@link classId} and omit {@link duration} and {@link endDate}.
41
+ */
42
+ readonly endOnNext?: boolean;
43
+ /**
44
+ * The client-defined `X-` attributes of the range, keyed by their full
45
+ * attribute name (e.g. `X-ASSET-URI`). Values are the raw parsed strings
46
+ * with surrounding quotes removed. Numeric and hex `X-` attributes are
47
+ * kept verbatim so callers can interpret them per their own schema.
48
+ */
49
+ readonly clientAttributes: Readonly<Record<string, string>>;
50
+ }
51
+ //# sourceMappingURL=HlsDateRange.d.ts.map
@@ -2,14 +2,14 @@ import { AlternativeRendition } from './AlternativeRendition';
2
2
  import { SessionData } from './SessionData';
3
3
  import { VariantStream } from './VariantStream';
4
4
  /**
5
- * A parsed HLS Master Playlist (also called Multivariant Playlist) as defined by RFC 8216.
5
+ * A parsed HLS Main Playlist (also called Multivariant Playlist) as defined by RFC 8216.
6
6
  *
7
- * A Master Playlist provides a set of variant streams, each representing the same content at
7
+ * A Main Playlist provides a set of variant streams, each representing the same content at
8
8
  * different bitrates or resolutions, along with alternative renditions and session-level metadata.
9
9
  *
10
10
  * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4
11
11
  */
12
- export interface MainPlaylist {
12
+ export interface HlsMainPlaylist {
13
13
  /** The variant streams available in this presentation (EXT-X-STREAM-INF). */
14
14
  readonly variants: readonly VariantStream[];
15
15
  /** Alternative renditions such as additional audio languages or subtitles (EXT-X-MEDIA). */
@@ -19,4 +19,4 @@ export interface MainPlaylist {
19
19
  /** Variables defined via EXT-X-DEFINE. Keys are variable names, values are their resolved values. */
20
20
  readonly defines?: Readonly<Record<string, string>>;
21
21
  }
22
- //# sourceMappingURL=MainPlaylist.d.ts.map
22
+ //# sourceMappingURL=HlsMainPlaylist.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { HlsDateRange } from './HlsDateRange';
1
2
  import { HlsSegment } from './HlsSegment';
2
3
  /**
3
4
  * A parsed HLS Media Playlist as defined by RFC 8216.
@@ -6,7 +7,7 @@ import { HlsSegment } from './HlsSegment';
6
7
  *
7
8
  * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4
8
9
  */
9
- export interface MediaPlaylist {
10
+ export interface HlsMediaPlaylist {
10
11
  /** The HLS protocol version required by this playlist (EXT-X-VERSION). */
11
12
  readonly version: number;
12
13
  /** The upper bound on the duration of any segment in the playlist, in seconds (EXT-X-TARGETDURATION). */
@@ -14,12 +15,18 @@ export interface MediaPlaylist {
14
15
  /** The sequence number of the first segment in the playlist (EXT-X-MEDIA-SEQUENCE). */
15
16
  readonly mediaSequence: number;
16
17
  /** The mutability type of the playlist: VOD (static), EVENT (append-only), or LIVE (sliding window). */
17
- readonly playlistType: MediaPlaylistType;
18
+ readonly playlistType: HlsMediaPlaylistType;
18
19
  /** Whether the playlist is complete, indicated by the presence of EXT-X-ENDLIST. */
19
20
  readonly ended: boolean;
20
21
  /** The ordered list of media segments in this playlist. */
21
22
  readonly segments: readonly HlsSegment[];
23
+ /**
24
+ * The Date Ranges declared in this playlist (EXT-X-DATERANGE), in the order
25
+ * they appear. HLS Interstitials (SGAI ad breaks) are carried as Date Ranges
26
+ * whose classId is `com.apple.hls.interstitial`.
27
+ */
28
+ readonly dateRanges: readonly HlsDateRange[];
22
29
  }
23
30
  /** The mutability type of Media Playlist. */
24
- export type MediaPlaylistType = 'VOD' | 'EVENT' | 'LIVE';
25
- //# sourceMappingURL=MediaPlaylist.d.ts.map
31
+ export type HlsMediaPlaylistType = 'VOD' | 'EVENT' | 'LIVE';
32
+ //# sourceMappingURL=HlsMediaPlaylist.d.ts.map
@@ -1,13 +1,14 @@
1
1
  /** Auto-generated from build scripts */
2
- export * from './types/VariantStream';
3
- export * from './types/SessionData';
4
- export * from './types/MediaPlaylist';
5
- export * from './types/MainPlaylist';
6
- export * from './types/HlsSegment';
7
- export * from './types/EncryptionKey';
8
- export * from './types/AlternativeRendition';
9
- export * from './parse/parseUtil';
10
- export * from './parse/parseMediaPlaylist';
11
- export * from './parse/parseMainPlaylist';
12
2
  export * from './parse/parseAttributes';
3
+ export * from './parse/parseMainPlaylist';
4
+ export * from './parse/parseMediaPlaylist';
5
+ export * from './parse/parseUtil';
6
+ export * from './types/AlternativeRendition';
7
+ export * from './types/EncryptionKey';
8
+ export * from './types/HlsDateRange';
9
+ export * from './types/HlsMainPlaylist';
10
+ export * from './types/HlsMediaPlaylist';
11
+ export * from './types/HlsSegment';
12
+ export * from './types/SessionData';
13
+ export * from './types/VariantStream';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,15 @@
1
- import type { MainPlaylist } from '../types/MainPlaylist';
1
+ import type { HlsMainPlaylist } from '../types/HlsMainPlaylist';
2
2
  /**
3
3
  * Parses an HLS master playlist from M3U8 text.
4
4
  *
5
5
  * @param text The raw M3U8 manifest string.
6
- * @returns A readonly MainPlaylist structure.
6
+ * @param queryParams Optional query parameters from the playlist's own URL,
7
+ * used to resolve `#EXT-X-DEFINE:QUERYPARAM="name"` entries (RFC 8216
8
+ * §4.4.5.1). Resolved values are exposed via {@link HlsMainPlaylist.defines} so
9
+ * child media playlists can `IMPORT` them. Interstitial ad manifests (e.g.
10
+ * AWS MediaTailor) carry session tokens this way.
11
+ * @returns A readonly HlsMainPlaylist structure.
7
12
  * @throws StringParseError if the manifest is malformed.
8
13
  */
9
- export declare function parseMainPlaylist(text: string): MainPlaylist;
14
+ export declare function parseMainPlaylist(text: string, queryParams?: Readonly<Record<string, string>>): HlsMainPlaylist;
10
15
  //# sourceMappingURL=parseMainPlaylist.d.ts.map
@@ -1,12 +1,19 @@
1
- import type { MediaPlaylist } from '../types/MediaPlaylist';
1
+ import type { HlsMediaPlaylist } from '../types/HlsMediaPlaylist';
2
2
  export declare const HLS_VARIABLE_PATTERN: RegExp;
3
3
  /**
4
4
  * Parses an HLS media playlist from M3U8 text.
5
5
  *
6
6
  * @param text The raw M3U8 manifest string.
7
- * @param variables Optional variable definitions from the master playlist's #EXT-X-DEFINE tags.
8
- * @returns A readonly MediaPlaylist structure.
7
+ * @param variables Optional variable definitions from the parent multivariant
8
+ * playlist's #EXT-X-DEFINE tags. Media-playlist `#EXT-X-DEFINE:IMPORT="name"`
9
+ * entries resolve against this map. Local `#EXT-X-DEFINE:NAME=,VALUE=`
10
+ * entries are also supported and take precedence.
11
+ * @param queryParams Optional query parameters from the playlist's own URL,
12
+ * used to resolve `#EXT-X-DEFINE:QUERYPARAM="name"` entries (RFC 8216
13
+ * §4.4.5.1). Interstitial ad manifests (e.g. AWS MediaTailor) commonly carry
14
+ * session tokens this way and reference them as `{$name}` in child URIs.
15
+ * @returns A readonly HlsMediaPlaylist structure.
9
16
  * @throws StringParseError if the manifest is malformed.
10
17
  */
11
- export declare function parseMediaPlaylist(text: string, variables?: Readonly<Record<string, string>>): MediaPlaylist;
18
+ export declare function parseMediaPlaylist(text: string, variables?: Readonly<Record<string, string>>, queryParams?: Readonly<Record<string, string>>): HlsMediaPlaylist;
12
19
  //# sourceMappingURL=parseMediaPlaylist.d.ts.map
@@ -23,6 +23,19 @@ export interface AlternativeRendition {
23
23
  readonly default?: boolean;
24
24
  /** Whether the client may choose to play this rendition without explicit user selection (AUTOSELECT). */
25
25
  readonly autoSelect?: boolean;
26
+ /**
27
+ * Whether this is a forced rendition (FORCED=YES): it presents essential
28
+ * text (e.g. translations of foreign dialogue) that should be shown even
29
+ * when the user has not enabled subtitles. Only meaningful for SUBTITLES.
30
+ */
31
+ readonly forced?: boolean;
32
+ /**
33
+ * Media Characteristic Tags (CHARACTERISTICS), a comma-separated list of
34
+ * Uniform Type Identifiers describing the rendition, e.g.
35
+ * `public.accessibility.transcribes-spoken-dialog`. Parsed into individual
36
+ * tags. Absent when the attribute is not present.
37
+ */
38
+ readonly characteristics?: readonly string[];
26
39
  }
27
40
  /**
28
41
  * The media type of an alternative rendition (EXT-X-MEDIA TYPE attribute).
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The CLASS value that identifies an {@link HlsDateRange} as an HLS Interstitial,
3
+ * the server-guided ad insertion (SGAI) primitive defined by Apple.
4
+ *
5
+ * @see https://developer.apple.com/streaming/GettingStartedWithHLSInterstitials.pdf
6
+ */
7
+ export declare const HLS_INTERSTITIAL_CLASS = "com.apple.hls.interstitial";
8
+ /**
9
+ * A parsed EXT-X-DATERANGE tag from an HLS Media Playlist (RFC 8216 §4.3.2.7).
10
+ *
11
+ * A Date Range associates a span of the media timeline, anchored to a wall-clock
12
+ * START-DATE, with a set of application-defined attributes. It is the transport
13
+ * for HLS Interstitials (SGAI): an interstitial is a Date Range whose
14
+ * {@link classId} is {@link HLS_INTERSTITIAL_CLASS} and which carries the
15
+ * `X-ASSET-URI` or `X-ASSET-LIST` client attributes describing the ad content.
16
+ *
17
+ * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.7
18
+ */
19
+ export interface HlsDateRange {
20
+ /** A unique identifier for this Date Range within the playlist (ID). */
21
+ readonly id: string;
22
+ /** The `CLASS` attribute, a client-defined category for the range, if present. */
23
+ readonly classId?: string;
24
+ /** The ISO-8601 wall-clock time at which the range begins (START-DATE). */
25
+ readonly startDate: string;
26
+ /** The ISO-8601 wall-clock time at which the range ends (END-DATE), if present. */
27
+ readonly endDate?: string;
28
+ /** The duration of the range in seconds (DURATION), if present. */
29
+ readonly duration?: number;
30
+ /**
31
+ * The expected duration of the Date Range in seconds.
32
+ * This attribute SHOULD be used to indicate the expected duration of a Date Range whose actual
33
+ * duration is not yet known.
34
+ * It must be positive.
35
+ */
36
+ readonly plannedDuration?: number;
37
+ /**
38
+ * Whether the END-DATE of a live range equals the START-DATE of the
39
+ * range that follows it (END-ON-NEXT=YES). Ranges with this flag must
40
+ * carry a {@link classId} and omit {@link duration} and {@link endDate}.
41
+ */
42
+ readonly endOnNext?: boolean;
43
+ /**
44
+ * The client-defined `X-` attributes of the range, keyed by their full
45
+ * attribute name (e.g. `X-ASSET-URI`). Values are the raw parsed strings
46
+ * with surrounding quotes removed. Numeric and hex `X-` attributes are
47
+ * kept verbatim so callers can interpret them per their own schema.
48
+ */
49
+ readonly clientAttributes: Readonly<Record<string, string>>;
50
+ }
51
+ //# sourceMappingURL=HlsDateRange.d.ts.map
@@ -2,14 +2,14 @@ import type { AlternativeRendition } from './AlternativeRendition';
2
2
  import type { SessionData } from './SessionData';
3
3
  import type { VariantStream } from './VariantStream';
4
4
  /**
5
- * A parsed HLS Master Playlist (also called Multivariant Playlist) as defined by RFC 8216.
5
+ * A parsed HLS Main Playlist (also called Multivariant Playlist) as defined by RFC 8216.
6
6
  *
7
- * A Master Playlist provides a set of variant streams, each representing the same content at
7
+ * A Main Playlist provides a set of variant streams, each representing the same content at
8
8
  * different bitrates or resolutions, along with alternative renditions and session-level metadata.
9
9
  *
10
10
  * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4
11
11
  */
12
- export interface MainPlaylist {
12
+ export interface HlsMainPlaylist {
13
13
  /** The variant streams available in this presentation (EXT-X-STREAM-INF). */
14
14
  readonly variants: readonly VariantStream[];
15
15
  /** Alternative renditions such as additional audio languages or subtitles (EXT-X-MEDIA). */
@@ -19,4 +19,4 @@ export interface MainPlaylist {
19
19
  /** Variables defined via EXT-X-DEFINE. Keys are variable names, values are their resolved values. */
20
20
  readonly defines?: Readonly<Record<string, string>>;
21
21
  }
22
- //# sourceMappingURL=MainPlaylist.d.ts.map
22
+ //# sourceMappingURL=HlsMainPlaylist.d.ts.map
@@ -1,3 +1,4 @@
1
+ import type { HlsDateRange } from './HlsDateRange';
1
2
  import type { HlsSegment } from './HlsSegment';
2
3
  /**
3
4
  * A parsed HLS Media Playlist as defined by RFC 8216.
@@ -6,7 +7,7 @@ import type { HlsSegment } from './HlsSegment';
6
7
  *
7
8
  * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4
8
9
  */
9
- export interface MediaPlaylist {
10
+ export interface HlsMediaPlaylist {
10
11
  /** The HLS protocol version required by this playlist (EXT-X-VERSION). */
11
12
  readonly version: number;
12
13
  /** The upper bound on the duration of any segment in the playlist, in seconds (EXT-X-TARGETDURATION). */
@@ -14,12 +15,18 @@ export interface MediaPlaylist {
14
15
  /** The sequence number of the first segment in the playlist (EXT-X-MEDIA-SEQUENCE). */
15
16
  readonly mediaSequence: number;
16
17
  /** The mutability type of the playlist: VOD (static), EVENT (append-only), or LIVE (sliding window). */
17
- readonly playlistType: MediaPlaylistType;
18
+ readonly playlistType: HlsMediaPlaylistType;
18
19
  /** Whether the playlist is complete, indicated by the presence of EXT-X-ENDLIST. */
19
20
  readonly ended: boolean;
20
21
  /** The ordered list of media segments in this playlist. */
21
22
  readonly segments: readonly HlsSegment[];
23
+ /**
24
+ * The Date Ranges declared in this playlist (EXT-X-DATERANGE), in the order
25
+ * they appear. HLS Interstitials (SGAI ad breaks) are carried as Date Ranges
26
+ * whose classId is `com.apple.hls.interstitial`.
27
+ */
28
+ readonly dateRanges: readonly HlsDateRange[];
22
29
  }
23
30
  /** The mutability type of Media Playlist. */
24
- export type MediaPlaylistType = 'VOD' | 'EVENT' | 'LIVE';
25
- //# sourceMappingURL=MediaPlaylist.d.ts.map
31
+ export type HlsMediaPlaylistType = 'VOD' | 'EVENT' | 'LIVE';
32
+ //# sourceMappingURL=HlsMediaPlaylist.d.ts.map
@@ -1,13 +1,14 @@
1
1
  /** Auto-generated from build scripts */
2
- export * from './types/VariantStream';
3
- export * from './types/SessionData';
4
- export * from './types/MediaPlaylist';
5
- export * from './types/MainPlaylist';
6
- export * from './types/HlsSegment';
7
- export * from './types/EncryptionKey';
8
- export * from './types/AlternativeRendition';
9
- export * from './parse/parseUtil';
10
- export * from './parse/parseMediaPlaylist';
11
- export * from './parse/parseMainPlaylist';
12
2
  export * from './parse/parseAttributes';
3
+ export * from './parse/parseMainPlaylist';
4
+ export * from './parse/parseMediaPlaylist';
5
+ export * from './parse/parseUtil';
6
+ export * from './types/AlternativeRendition';
7
+ export * from './types/EncryptionKey';
8
+ export * from './types/HlsDateRange';
9
+ export * from './types/HlsMainPlaylist';
10
+ export * from './types/HlsMediaPlaylist';
11
+ export * from './types/HlsSegment';
12
+ export * from './types/SessionData';
13
+ export * from './types/VariantStream';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,15 @@
1
- import type { MainPlaylist } from '../types/MainPlaylist';
1
+ import type { HlsMainPlaylist } from '../types/HlsMainPlaylist';
2
2
  /**
3
3
  * Parses an HLS master playlist from M3U8 text.
4
4
  *
5
5
  * @param text The raw M3U8 manifest string.
6
- * @returns A readonly MainPlaylist structure.
6
+ * @param queryParams Optional query parameters from the playlist's own URL,
7
+ * used to resolve `#EXT-X-DEFINE:QUERYPARAM="name"` entries (RFC 8216
8
+ * §4.4.5.1). Resolved values are exposed via {@link HlsMainPlaylist.defines} so
9
+ * child media playlists can `IMPORT` them. Interstitial ad manifests (e.g.
10
+ * AWS MediaTailor) carry session tokens this way.
11
+ * @returns A readonly HlsMainPlaylist structure.
7
12
  * @throws StringParseError if the manifest is malformed.
8
13
  */
9
- export declare function parseMainPlaylist(text: string): MainPlaylist;
14
+ export declare function parseMainPlaylist(text: string, queryParams?: Readonly<Record<string, string>>): HlsMainPlaylist;
10
15
  //# sourceMappingURL=parseMainPlaylist.d.ts.map
@@ -1,12 +1,19 @@
1
- import type { MediaPlaylist } from '../types/MediaPlaylist';
1
+ import type { HlsMediaPlaylist } from '../types/HlsMediaPlaylist';
2
2
  export declare const HLS_VARIABLE_PATTERN: RegExp;
3
3
  /**
4
4
  * Parses an HLS media playlist from M3U8 text.
5
5
  *
6
6
  * @param text The raw M3U8 manifest string.
7
- * @param variables Optional variable definitions from the master playlist's #EXT-X-DEFINE tags.
8
- * @returns A readonly MediaPlaylist structure.
7
+ * @param variables Optional variable definitions from the parent multivariant
8
+ * playlist's #EXT-X-DEFINE tags. Media-playlist `#EXT-X-DEFINE:IMPORT="name"`
9
+ * entries resolve against this map. Local `#EXT-X-DEFINE:NAME=,VALUE=`
10
+ * entries are also supported and take precedence.
11
+ * @param queryParams Optional query parameters from the playlist's own URL,
12
+ * used to resolve `#EXT-X-DEFINE:QUERYPARAM="name"` entries (RFC 8216
13
+ * §4.4.5.1). Interstitial ad manifests (e.g. AWS MediaTailor) commonly carry
14
+ * session tokens this way and reference them as `{$name}` in child URIs.
15
+ * @returns A readonly HlsMediaPlaylist structure.
9
16
  * @throws StringParseError if the manifest is malformed.
10
17
  */
11
- export declare function parseMediaPlaylist(text: string, variables?: Readonly<Record<string, string>>): MediaPlaylist;
18
+ export declare function parseMediaPlaylist(text: string, variables?: Readonly<Record<string, string>>, queryParams?: Readonly<Record<string, string>>): HlsMediaPlaylist;
12
19
  //# sourceMappingURL=parseMediaPlaylist.d.ts.map
@@ -23,6 +23,19 @@ export interface AlternativeRendition {
23
23
  readonly default?: boolean;
24
24
  /** Whether the client may choose to play this rendition without explicit user selection (AUTOSELECT). */
25
25
  readonly autoSelect?: boolean;
26
+ /**
27
+ * Whether this is a forced rendition (FORCED=YES): it presents essential
28
+ * text (e.g. translations of foreign dialogue) that should be shown even
29
+ * when the user has not enabled subtitles. Only meaningful for SUBTITLES.
30
+ */
31
+ readonly forced?: boolean;
32
+ /**
33
+ * Media Characteristic Tags (CHARACTERISTICS), a comma-separated list of
34
+ * Uniform Type Identifiers describing the rendition, e.g.
35
+ * `public.accessibility.transcribes-spoken-dialog`. Parsed into individual
36
+ * tags. Absent when the attribute is not present.
37
+ */
38
+ readonly characteristics?: readonly string[];
26
39
  }
27
40
  /**
28
41
  * The media type of an alternative rendition (EXT-X-MEDIA TYPE attribute).
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The CLASS value that identifies an {@link HlsDateRange} as an HLS Interstitial,
3
+ * the server-guided ad insertion (SGAI) primitive defined by Apple.
4
+ *
5
+ * @see https://developer.apple.com/streaming/GettingStartedWithHLSInterstitials.pdf
6
+ */
7
+ export declare const HLS_INTERSTITIAL_CLASS = "com.apple.hls.interstitial";
8
+ /**
9
+ * A parsed EXT-X-DATERANGE tag from an HLS Media Playlist (RFC 8216 §4.3.2.7).
10
+ *
11
+ * A Date Range associates a span of the media timeline, anchored to a wall-clock
12
+ * START-DATE, with a set of application-defined attributes. It is the transport
13
+ * for HLS Interstitials (SGAI): an interstitial is a Date Range whose
14
+ * {@link classId} is {@link HLS_INTERSTITIAL_CLASS} and which carries the
15
+ * `X-ASSET-URI` or `X-ASSET-LIST` client attributes describing the ad content.
16
+ *
17
+ * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.2.7
18
+ */
19
+ export interface HlsDateRange {
20
+ /** A unique identifier for this Date Range within the playlist (ID). */
21
+ readonly id: string;
22
+ /** The `CLASS` attribute, a client-defined category for the range, if present. */
23
+ readonly classId?: string;
24
+ /** The ISO-8601 wall-clock time at which the range begins (START-DATE). */
25
+ readonly startDate: string;
26
+ /** The ISO-8601 wall-clock time at which the range ends (END-DATE), if present. */
27
+ readonly endDate?: string;
28
+ /** The duration of the range in seconds (DURATION), if present. */
29
+ readonly duration?: number;
30
+ /**
31
+ * The expected duration of the Date Range in seconds.
32
+ * This attribute SHOULD be used to indicate the expected duration of a Date Range whose actual
33
+ * duration is not yet known.
34
+ * It must be positive.
35
+ */
36
+ readonly plannedDuration?: number;
37
+ /**
38
+ * Whether the END-DATE of a live range equals the START-DATE of the
39
+ * range that follows it (END-ON-NEXT=YES). Ranges with this flag must
40
+ * carry a {@link classId} and omit {@link duration} and {@link endDate}.
41
+ */
42
+ readonly endOnNext?: boolean;
43
+ /**
44
+ * The client-defined `X-` attributes of the range, keyed by their full
45
+ * attribute name (e.g. `X-ASSET-URI`). Values are the raw parsed strings
46
+ * with surrounding quotes removed. Numeric and hex `X-` attributes are
47
+ * kept verbatim so callers can interpret them per their own schema.
48
+ */
49
+ readonly clientAttributes: Readonly<Record<string, string>>;
50
+ }
51
+ //# sourceMappingURL=HlsDateRange.d.ts.map
@@ -2,14 +2,14 @@ import type { AlternativeRendition } from './AlternativeRendition';
2
2
  import type { SessionData } from './SessionData';
3
3
  import type { VariantStream } from './VariantStream';
4
4
  /**
5
- * A parsed HLS Master Playlist (also called Multivariant Playlist) as defined by RFC 8216.
5
+ * A parsed HLS Main Playlist (also called Multivariant Playlist) as defined by RFC 8216.
6
6
  *
7
- * A Master Playlist provides a set of variant streams, each representing the same content at
7
+ * A Main Playlist provides a set of variant streams, each representing the same content at
8
8
  * different bitrates or resolutions, along with alternative renditions and session-level metadata.
9
9
  *
10
10
  * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4.3.4
11
11
  */
12
- export interface MainPlaylist {
12
+ export interface HlsMainPlaylist {
13
13
  /** The variant streams available in this presentation (EXT-X-STREAM-INF). */
14
14
  readonly variants: readonly VariantStream[];
15
15
  /** Alternative renditions such as additional audio languages or subtitles (EXT-X-MEDIA). */
@@ -19,4 +19,4 @@ export interface MainPlaylist {
19
19
  /** Variables defined via EXT-X-DEFINE. Keys are variable names, values are their resolved values. */
20
20
  readonly defines?: Readonly<Record<string, string>>;
21
21
  }
22
- //# sourceMappingURL=MainPlaylist.d.ts.map
22
+ //# sourceMappingURL=HlsMainPlaylist.d.ts.map
@@ -1,3 +1,4 @@
1
+ import type { HlsDateRange } from './HlsDateRange';
1
2
  import type { HlsSegment } from './HlsSegment';
2
3
  /**
3
4
  * A parsed HLS Media Playlist as defined by RFC 8216.
@@ -6,7 +7,7 @@ import type { HlsSegment } from './HlsSegment';
6
7
  *
7
8
  * @see https://datatracker.ietf.org/doc/html/rfc8216#section-4
8
9
  */
9
- export interface MediaPlaylist {
10
+ export interface HlsMediaPlaylist {
10
11
  /** The HLS protocol version required by this playlist (EXT-X-VERSION). */
11
12
  readonly version: number;
12
13
  /** The upper bound on the duration of any segment in the playlist, in seconds (EXT-X-TARGETDURATION). */
@@ -14,12 +15,18 @@ export interface MediaPlaylist {
14
15
  /** The sequence number of the first segment in the playlist (EXT-X-MEDIA-SEQUENCE). */
15
16
  readonly mediaSequence: number;
16
17
  /** The mutability type of the playlist: VOD (static), EVENT (append-only), or LIVE (sliding window). */
17
- readonly playlistType: MediaPlaylistType;
18
+ readonly playlistType: HlsMediaPlaylistType;
18
19
  /** Whether the playlist is complete, indicated by the presence of EXT-X-ENDLIST. */
19
20
  readonly ended: boolean;
20
21
  /** The ordered list of media segments in this playlist. */
21
22
  readonly segments: readonly HlsSegment[];
23
+ /**
24
+ * The Date Ranges declared in this playlist (EXT-X-DATERANGE), in the order
25
+ * they appear. HLS Interstitials (SGAI ad breaks) are carried as Date Ranges
26
+ * whose classId is `com.apple.hls.interstitial`.
27
+ */
28
+ readonly dateRanges: readonly HlsDateRange[];
22
29
  }
23
30
  /** The mutability type of Media Playlist. */
24
- export type MediaPlaylistType = 'VOD' | 'EVENT' | 'LIVE';
25
- //# sourceMappingURL=MediaPlaylist.d.ts.map
31
+ export type HlsMediaPlaylistType = 'VOD' | 'EVENT' | 'LIVE';
32
+ //# sourceMappingURL=HlsMediaPlaylist.d.ts.map