feat(Parser): just-in-time YTNode generation (#310)

* refactor: merge NavigatableText into Text

* fix(Text): data might not be object

* refactor: remove GetParserByName from map

* feat(Parser): just-in-time YTNode generation

* refactor: cleanup YTNodeGenerator

* fix: YTNode map imports

* feat(YTNodeGenerator): primative types

Add support for inferring primatives types

* fix(YTNodeGenerator): NavigationEndpoint detection

* fix(YTNodeGenerator): fix generated typescript

Correct types and linting for generated typescript class

* chore: update parsers after merge

* feat: add support for object type inference

* fix: object type def

* docs: basic YTNodeGenerator explanation

* docs: tsdoc for YTNodeGenerator

* docs: update parser updating guide

* fix: apply suggested changes

* docs: accessing generated nodes
This commit is contained in:
Daniel Wykerd
2023-03-15 08:39:36 +02:00
committed by GitHub
parent ffd7d79308
commit 2cee59024c
20 changed files with 1201 additions and 1169 deletions

View File

@@ -1,9 +1,9 @@
import Parser from '../../index.js';
import NavigatableText from './NavigatableText.js';
import NavigationEndpoint from '../NavigationEndpoint.js';
import TextRun from './TextRun.js';
import Thumbnail from './Thumbnail.js';
import Constants from '../../../utils/Constants.js';
import Text from './Text.js';
class Author {
#nav_text;
@@ -11,14 +11,14 @@ class Author {
id: string;
name: string;
thumbnails: Thumbnail[];
endpoint: NavigationEndpoint | null;
endpoint?: NavigationEndpoint;
badges?: any;
is_verified?: boolean | null;
is_verified_artist?: boolean | null;
url: string | null;
constructor(item: any, badges?: any, thumbs?: any) {
this.#nav_text = new NavigatableText(item);
this.#nav_text = new Text(item);
this.id =
(this.#nav_text.runs?.[0] as TextRun)?.endpoint?.payload?.browseId ||