refactor(Player)!: Use AST-based JS extraction with side-effect safe code emission (#1052)

* chore(deps): Add `meriyah`

* feat(utils): Implement AST-based JS extractors

* chore(utils): Remove old ast walker code

* fix(Player): Migrate js extraction logic

* chore(JsExtractor): Fix typo in tsdoc

* perf(JsAnalyzer): Simplify main AST analysis logic

* fix(JsAnalyzer): Change `break` to `return` in AST matching logic

* chore: Update docs

* chore: Don't export `PlayerInitializationOptions`

* chore(evaluate): Update error message to include doc link

* perf: Use a `for-loop` to find iife
This commit is contained in:
Luan
2025-10-12 09:08:51 -03:00
committed by GitHub
parent bffa92d96e
commit 25d0876b91
873 changed files with 10992 additions and 8345 deletions

View File

@@ -32,7 +32,7 @@
#### Defined in
[src/parser/ytshorts/ShortFormVideoInfo.ts:15](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/ytshorts/ShortFormVideoInfo.ts#L15)
[src/parser/ytshorts/ShortFormVideoInfo.ts:15](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/parser/ytshorts/ShortFormVideoInfo.ts#L15)
## Properties
@@ -46,7 +46,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:40](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L40)
[src/core/mixins/MediaInfo.ts:40](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L40)
***
@@ -192,7 +192,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:39](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L39)
[src/core/mixins/MediaInfo.ts:39](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L39)
***
@@ -206,7 +206,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:43](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L43)
[src/core/mixins/MediaInfo.ts:43](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L43)
***
@@ -220,7 +220,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:44](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L44)
[src/core/mixins/MediaInfo.ts:44](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L44)
***
@@ -230,7 +230,7 @@
#### Defined in
[src/parser/ytshorts/ShortFormVideoInfo.ts:12](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/ytshorts/ShortFormVideoInfo.ts#L12)
[src/parser/ytshorts/ShortFormVideoInfo.ts:12](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/parser/ytshorts/ShortFormVideoInfo.ts#L12)
***
@@ -244,7 +244,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:42](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L42)
[src/core/mixins/MediaInfo.ts:42](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L42)
***
@@ -258,7 +258,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:46](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L46)
[src/core/mixins/MediaInfo.ts:46](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L46)
***
@@ -272,7 +272,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:47](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L47)
[src/core/mixins/MediaInfo.ts:47](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L47)
***
@@ -282,7 +282,7 @@
#### Defined in
[src/parser/ytshorts/ShortFormVideoInfo.ts:13](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/ytshorts/ShortFormVideoInfo.ts#L13)
[src/parser/ytshorts/ShortFormVideoInfo.ts:13](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/parser/ytshorts/ShortFormVideoInfo.ts#L13)
***
@@ -296,7 +296,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:41](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L41)
[src/core/mixins/MediaInfo.ts:41](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L41)
***
@@ -310,7 +310,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:45](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L45)
[src/core/mixins/MediaInfo.ts:45](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L45)
***
@@ -320,7 +320,7 @@
#### Defined in
[src/parser/ytshorts/ShortFormVideoInfo.ts:11](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/ytshorts/ShortFormVideoInfo.ts#L11)
[src/parser/ytshorts/ShortFormVideoInfo.ts:11](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/parser/ytshorts/ShortFormVideoInfo.ts#L11)
## Accessors
@@ -338,7 +338,7 @@
#### Defined in
[src/core/mixins/MediaInfo.ts:247](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L247)
[src/core/mixins/MediaInfo.ts:247](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L247)
***
@@ -358,7 +358,7 @@ Content Playback Nonce.
#### Defined in
[src/core/mixins/MediaInfo.ts:254](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L254)
[src/core/mixins/MediaInfo.ts:254](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L254)
***
@@ -378,7 +378,7 @@ Parsed InnerTube response.
#### Defined in
[src/core/mixins/MediaInfo.ts:261](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L261)
[src/core/mixins/MediaInfo.ts:261](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L261)
***
@@ -394,7 +394,7 @@ Checks if continuation is available for the watch next feed.
#### Defined in
[src/parser/ytshorts/ShortFormVideoInfo.ts:47](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/ytshorts/ShortFormVideoInfo.ts#L47)
[src/parser/ytshorts/ShortFormVideoInfo.ts:47](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/parser/ytshorts/ShortFormVideoInfo.ts#L47)
## Methods
@@ -420,7 +420,7 @@ Checks if continuation is available for the watch next feed.
#### Defined in
[src/core/mixins/MediaInfo.ts:208](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L208)
[src/core/mixins/MediaInfo.ts:208](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L208)
***
@@ -446,7 +446,7 @@ Options
#### Defined in
[src/core/mixins/MediaInfo.ts:161](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L161)
[src/core/mixins/MediaInfo.ts:161](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L161)
***
@@ -472,13 +472,13 @@ Download options.
#### Defined in
[src/core/mixins/MediaInfo.ts:169](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L169)
[src/core/mixins/MediaInfo.ts:169](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L169)
***
### getStreamingInfo()
> **getStreamingInfo**(`url_transformer`?, `format_filter`?): `StreamingInfo`
> **getStreamingInfo**(`url_transformer`?, `format_filter`?): `Promise`\<`StreamingInfo`\>
Get a cleaned up representation of the adaptive_formats
@@ -490,7 +490,7 @@ Get a cleaned up representation of the adaptive_formats
#### Returns
`StreamingInfo`
`Promise`\<`StreamingInfo`\>
#### Inherited from
@@ -498,7 +498,7 @@ Get a cleaned up representation of the adaptive_formats
#### Defined in
[src/core/mixins/MediaInfo.ts:144](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L144)
[src/core/mixins/MediaInfo.ts:144](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L144)
***
@@ -518,7 +518,7 @@ Retrieves the video's transcript.
#### Defined in
[src/core/mixins/MediaInfo.ts:182](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L182)
[src/core/mixins/MediaInfo.ts:182](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L182)
***
@@ -532,7 +532,7 @@ Retrieves the video's transcript.
#### Defined in
[src/parser/ytshorts/ShortFormVideoInfo.ts:27](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/parser/ytshorts/ShortFormVideoInfo.ts#L27)
[src/parser/ytshorts/ShortFormVideoInfo.ts:27](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/parser/ytshorts/ShortFormVideoInfo.ts#L27)
***
@@ -564,7 +564,7 @@ DASH manifest
#### Defined in
[src/core/mixins/MediaInfo.ts:104](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L104)
[src/core/mixins/MediaInfo.ts:104](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L104)
***
@@ -592,4 +592,4 @@ DASH manifest
#### Defined in
[src/core/mixins/MediaInfo.ts:227](https://github.com/LuanRT/YouTube.js/blob/4ae0cc5c523a2080e68d6c0c1437c78fe318ea30/src/core/mixins/MediaInfo.ts#L227)
[src/core/mixins/MediaInfo.ts:227](https://github.com/LuanRT/YouTube.js/blob/af92984523f90200a18314b94478a2697c9deab0/src/core/mixins/MediaInfo.ts#L227)