Compare commits

...

1 commit

Author SHA1 Message Date
Dzianis Dashkevich
9a7db252df add types 2023-09-03 21:19:05 -04:00
5 changed files with 11943 additions and 33 deletions

2
.nvmrc
View file

@ -1 +1 @@
10
16

11863
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@
"description": "m3u8 parser",
"main": "dist/m3u8-parser.cjs.js",
"module": "dist/m3u8-parser.es.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "git@github.com:videojs/m3u8-parser.git"
@ -27,6 +28,7 @@
"build-prod": "cross-env-shell NO_TEST_BUNDLE=1 'npm run build'",
"build": "npm-run-all -s clean -p build:*",
"build:js": "rollup -c scripts/rollup.config.js",
"build:types": "tsc",
"clean": "shx rm -rf ./dist ./test/dist && shx mkdir -p ./dist ./test/dist",
"lint": "vjsstandard",
"prepublishOnly": "npm-run-all build-prod && vjsverify --verbose --skip-es-check",
@ -75,6 +77,7 @@
"rollup": "^2.38.0",
"rollup-plugin-data-files": "^0.1.0",
"sinon": "^9.2.3",
"typescript": "^5.2.2",
"videojs-generate-karma-config": "^8.0.1",
"videojs-generate-rollup-config": "~7.0.0",
"videojs-generator-verify": "~3.0.1",

View file

@ -6,6 +6,92 @@ import decodeB64ToUint8Array from '@videojs/vhs-utils/es/decode-b64-to-uint8-arr
import LineStream from './line-stream';
import ParseStream from './parse-stream';
/**
* @typedef {Object} DateRange
* @property {string} [id] - A quoted-string that uniquely identifies a Date Range in the Playlist.
* @property {string} [class] - A client-defined quoted-string that specifies some set of attributes and their associated value semantics.
* @property {Date} [startDate] - date/time at which the Date Range begins.
* @property {Date} [endDate] - date/time at which the Date Range ends.
* @property {number} [duration] - The duration of the Date Range.
* @property {number} [plannedDuration] - The expected duration of the Date Range.
* @property {boolean} [endOnNext] - This attribute indicates that the end of the range containing it is equal to the START-DATE of its Following Range.
* @property {string} [scte35Cmd] - SCTE-35 splice_info_section()
* @property {string} [scte35Out] - SCTE-35 splice-in
* @property {string} [scte35In] - SCTE-35 splice-out
*/
/**
* @typedef {Object} Playlist
*/
/**
* @typedef {Object} ByteRange
* @property {number} [length] - byte range length
* @property {number} [offset] - byte range offset
*/
/**
* @typdef {Object} Segment
* @property {number} [programDateTime] - associated program date time.
* @property {ByteRange} [byterange] - associated byte range
*/
/**
*
*
*
*
* @typedef {{
* allowCache: boolean;
* discontinuityStarts: Array<number>;
* dateRanges: Array<DateRange>;
* segments: Array<Segment>;
* playlists?: Array<Playlist>;
* mediaGroups?: {
* AUDIO?: Record<string, unknown>;
* VIDEO?: Record<string, unknown>;
* 'CLOSED-CAPTIONS'?: Record<string, unknown>;
* SUBTITLES?: Record<string, unknown>;
* };
* preloadSegment?: string;
* version?: string;
* endList?: boolean;
* mediaSequence?: number;
* discontinuitySequence?: number;
* contentProtection?: {
* 'com.apple.fps.1_0'?: {
* attributes: Record<string, unknown>
* },
* 'com.microsoft.playready'?: {
* uri: string
* },
* 'com.widevine.alpha'?: {
* attributes: {
* schemeIdUri: string;
* keyId: string;
* },
* pssh: Uint8Array
* }
* },
* playlistType?: 'VOD' | 'EVENT';
* dateTimeString?: string;
* dateTimeObject?: Date;
* targetDuration?: number;
* start?: {
* timeOffset: number;
* precise: boolean;
* };
* skip: Record<string, unknown>;
* renditionReports?: Array<RenditionReport>;
* serverControl?: Record<string, unknown>;
* partInf?: Record<string, unknown>;
* partTargetDuration?: number;
* independentSegments?: boolean;
* contentSteering?: Record<string, unknown>;
* custom?: Record<string, unknown>;
* }} Manifest
*/
const camelCase = (str) => str
.toLowerCase()
.replace(/-(\w)/g, (a) => a[1].toUpperCase());

22
tsconfig.json Normal file
View file

@ -0,0 +1,22 @@
{
// Change this to match your project
"include": ["src/**/*"],
"compilerOptions": {
// Tells TypeScript to read JS files, as
// normally they are ignored as source files
"allowJs": true,
// Generate d.ts files
"declaration": true,
// This compiler run should
// only output d.ts files
"emitDeclarationOnly": true,
// Types should go into this directory.
// Removing this would place the .d.ts files
// next to the .js files
"outDir": "dist/types",
// go to js file when using IDE functions like
// "Go to Definition" in VSCode
"declarationMap": true,
"skipLibCheck":true
}
}