From 919a012121c9487ff552245bb6b47447a9b34305 Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Thu, 28 Nov 2024 10:24:58 +0500 Subject: [PATCH 1/4] fix: remove esm for now --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 52ca234..1b25b41 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "prepublishOnly": "npm run build" }, "main": "./dist/dasha.js", - "module": "./dist/dasha.mjs", "types": "./types/dasha.d.ts", "repository": { "type": "git", From 968167809571fe273865a671bef1d3dc0600ea48 Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Thu, 28 Nov 2024 10:28:41 +0500 Subject: [PATCH 2/4] fix: rollback to cjs --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1b25b41..6e5d946 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,10 @@ { "name": "dasha", - "version": "3.1.3", + "version": "3.1.4", "description": "Streaming manifest parser", "files": [ - "dist", + "dasha.js", + "lib", "types" ], "scripts": { @@ -14,7 +15,7 @@ "build": "tsup dasha.js --format esm,cjs", "prepublishOnly": "npm run build" }, - "main": "./dist/dasha.js", + "main": "dasha.js", "types": "./types/dasha.d.ts", "repository": { "type": "git", From fb3ac36a2c0f573da2ec7f77d4dc3a4c9e60de33 Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Fri, 6 Dec 2024 12:12:07 +0500 Subject: [PATCH 3/4] chore: update deps --- package-lock.json | 30 ++++++++++-------------------- package.json | 10 +++++----- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 15fe5af..df153e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dasha", - "version": "3.1.3", + "version": "3.1.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dasha", - "version": "3.1.3", + "version": "3.1.4", "funding": [ { "type": "individual", @@ -22,13 +22,13 @@ "m3u8-parser": "^7.2.0" }, "devDependencies": { - "@eslint/js": "^9.15.0", - "@types/node": "^22.10.0", - "eslint": "^9.15.0", + "@eslint/js": "^9.16.0", + "@types/node": "^22.10.1", + "eslint": "^9.16.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", - "globals": "^15.12.0", - "prettier": "^3.4.1", + "globals": "^15.13.0", + "prettier": "^3.4.2", "tsup": "^8.3.5", "typescript": "^5.7.2" }, @@ -1498,16 +1498,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/@eslint/js": { - "version": "9.15.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.15.0.tgz", - "integrity": "sha512-tMTqrY+EzbXmKJR5ToI8lxu7jaN5EdmrBFJpQk5JmSlyLsx6o4t27r883K5xsLuCYCpfKBCGswMSWXsM+jB7lg==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - } - }, "node_modules/eslint/node_modules/eslint-visitor-keys": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", @@ -2240,9 +2230,9 @@ } }, "node_modules/prettier": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.1.tgz", - "integrity": "sha512-G+YdqtITVZmOJje6QkXQWzl3fSfMxFwm1tjTyo9exhkmWSqC4Yhd1+lug++IlR2mvRVAxEDDWYkQdeSztajqgg==", + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz", + "integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==", "dev": true, "license": "MIT", "bin": { diff --git a/package.json b/package.json index 6e5d946..ebc414b 100644 --- a/package.json +++ b/package.json @@ -55,13 +55,13 @@ "m3u8-parser": "^7.2.0" }, "devDependencies": { - "@eslint/js": "^9.15.0", - "@types/node": "^22.10.0", - "eslint": "^9.15.0", + "@eslint/js": "^9.16.0", + "@types/node": "^22.10.1", + "eslint": "^9.16.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", - "globals": "^15.12.0", - "prettier": "^3.4.1", + "globals": "^15.13.0", + "prettier": "^3.4.2", "tsup": "^8.3.5", "typescript": "^5.7.2" } From 51f20a55f939d58195823a98e490e9427f34aaa4 Mon Sep 17 00:00:00 2001 From: Vitaly Gashkov Date: Fri, 6 Dec 2024 12:18:26 +0500 Subject: [PATCH 4/4] fix: subtitle codec types --- dasha.js | 2 ++ lib/dash.js | 2 ++ lib/subtitle.js | 1 + types/dasha.d.ts | 15 ++++++++------- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/dasha.js b/dasha.js index b8f1939..e972bb3 100644 --- a/dasha.js +++ b/dasha.js @@ -9,6 +9,7 @@ const { filterByLanguages, filterByChannels, } = require('./lib/track'); +const { SUBTITLE_CODECS } = require('./lib/subtitle'); const parse = (text, url, fallbackLanguage) => { if (text.includes(' { }; const identifierPattern = /\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g; + const identifierReplacement = (values) => (match, identifier, format, width) => { if (match === '$$') return '$'; @@ -147,6 +148,7 @@ const identifierReplacement = if (value.length >= width) return value; return value.padStart(width, '0'); }; + const buildSegmentUrl = (template, fields) => { return template.replace(identifierPattern, identifierReplacement(fields)); }; diff --git a/lib/subtitle.js b/lib/subtitle.js index 04c978a..73fb860 100644 --- a/lib/subtitle.js +++ b/lib/subtitle.js @@ -127,6 +127,7 @@ const createSubtitleTrack = ({ }; module.exports = { + SUBTITLE_CODECS, parseSubtitleCodec, tryParseSubtitleCodec, checkIsClosedCaption, diff --git a/types/dasha.d.ts b/types/dasha.d.ts index daac1c5..8b6b105 100644 --- a/types/dasha.d.ts +++ b/types/dasha.d.ts @@ -139,13 +139,14 @@ export interface AudioTrack extends Track { } export type SubtitleCodec = - | 'SRT' - | 'SSA' - | 'ASS' - | 'TTML' - | 'VTT' - | 'STPP' - | 'WVTT'; + | 'SRT' // https://wikipedia.org/wiki/SubRip + | 'SSA' // https://wikipedia.org/wiki/SubStation_Alpha + | 'ASS' // https://wikipedia.org/wiki/SubStation_Alpha#Advanced_SubStation_Alpha= + | 'TTML' // https://wikipedia.org/wiki/Timed_Text_Markup_Language + | 'VTT' // https://wikipedia.org/wiki/WebVTT + // MPEG-DASH box-encapsulated subtitle formats + | 'STPP' // https://www.w3.org/TR/2018/REC-ttml-imsc1.0.1-20180424 + | 'WVTT'; // https://www.w3.org/TR/webvtt1 export interface SubtitleTrack extends Track { type: 'text';