chore(parser): import YTNodes directly to reduce web bundle size

This commit is contained in:
LuanRT
2023-03-08 07:18:01 -03:00
parent 574b67a1f7
commit c76b24b3f4
5 changed files with 35 additions and 27 deletions

View File

@@ -1,10 +1,12 @@
import { YTNode } from '../helpers.js';
import Author from './misc/Author.js';
import { YTNodes } from '../index.js';
import { Menu } from '../map.js';
import Parser from '../parser.js';
import BackstagePost from './BackstagePost.js';
import Button from './Button.js';
import Author from './misc/Author.js';
import Text from './misc/Text.js';
import Thumbnail from './misc/Thumbnail.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import Text from './misc/Text.js';
class SharedPost extends YTNode {
static type = 'SharedPost';
@@ -12,11 +14,11 @@ class SharedPost extends YTNode {
thumbnail: Thumbnail[];
content: Text;
published: Text;
menu: YTNodes.Menu | null;
original_post: YTNodes.BackstagePost | null;
menu: Menu | null;
original_post: BackstagePost | null;
id: string;
endpoint: NavigationEndpoint;
expand_button: YTNodes.Button | null;
expand_button: Button | null;
author: Author;
constructor(data: any) {
@@ -24,11 +26,11 @@ class SharedPost extends YTNode {
this.thumbnail = Thumbnail.fromResponse(data.thumbnail);
this.content = new Text(data.content);
this.published = new Text(data.publishedTimeText);
this.menu = Parser.parseItem(data.actionMenu, [ YTNodes.Menu ]);
this.original_post = Parser.parseItem(data.originalPost, [ YTNodes.BackstagePost ]);
this.menu = Parser.parseItem(data.actionMenu, Menu);
this.original_post = Parser.parseItem(data.originalPost, BackstagePost);
this.id = data.postId;
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
this.expand_button = Parser.parseItem(data.expandButton, [ YTNodes.Button ]);
this.expand_button = Parser.parseItem(data.expandButton, Button);
this.author = new Author(data.displayName, undefined);
}
}