mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-17 19:42:14 +00:00
chore(parser): import YTNodes directly to reduce web bundle size
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
import { ObservedArray, YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import { Parser, YTNodes } from '../index.js';
|
||||
import { Parser } from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
import SearchFilter from './SearchFilter.js';
|
||||
|
||||
class SearchFilterGroup extends YTNode {
|
||||
static type = 'SearchFilterGroup';
|
||||
|
||||
title: Text;
|
||||
filters: ObservedArray<YTNodes.SearchFilter> | null;
|
||||
filters: ObservedArray<SearchFilter> | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
|
||||
this.title = new Text(data.title);
|
||||
this.filters = Parser.parseArray(data.filters, YTNodes.SearchFilter);
|
||||
this.filters = Parser.parseArray(data.filters, SearchFilter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
import { ObservedArray, YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import Parser, { YTNodes } from '../index.js';
|
||||
import Parser from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
import SearchFilterGroup from './SearchFilterGroup.js';
|
||||
import ToggleButton from './ToggleButton.js';
|
||||
|
||||
class SearchSubMenu extends YTNode {
|
||||
static type = 'SearchSubMenu';
|
||||
|
||||
title: Text;
|
||||
groups: ObservedArray<YTNodes.SearchFilterGroup> | null;
|
||||
button: YTNodes.ToggleButton | null;
|
||||
groups: ObservedArray<SearchFilterGroup> | null;
|
||||
button: ToggleButton | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.groups = Parser.parseArray(data.groups, YTNodes.SearchFilterGroup);
|
||||
this.button = Parser.parseItem(data.button, YTNodes.ToggleButton);
|
||||
this.groups = Parser.parseArray(data.groups, SearchFilterGroup);
|
||||
this.button = Parser.parseItem(data.button, ToggleButton);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
import Parser, { YTNodes } from '../index.js';
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import Parser from '../index.js';
|
||||
import Button from './Button.js';
|
||||
import ToggleButton from './ToggleButton.js';
|
||||
|
||||
class SegmentedLikeDislikeButton extends YTNode {
|
||||
static type = 'SegmentedLikeDislikeButton';
|
||||
|
||||
like_button: YTNodes.ToggleButton | YTNodes.Button | null;
|
||||
dislike_button: YTNodes.ToggleButton | YTNodes.Button | null;
|
||||
like_button: ToggleButton | Button | null;
|
||||
dislike_button: ToggleButton | Button | null;
|
||||
|
||||
constructor (data: RawNode) {
|
||||
super();
|
||||
this.like_button = Parser.parseItem<YTNodes.ToggleButton | YTNodes.Button>(data.likeButton, [ YTNodes.ToggleButton, YTNodes.Button ]);
|
||||
this.dislike_button = Parser.parseItem<YTNodes.ToggleButton | YTNodes.Button>(data.dislikeButton, [ YTNodes.ToggleButton, YTNodes.Button ]);
|
||||
this.like_button = Parser.parseItem<ToggleButton | Button>(data.likeButton, [ ToggleButton, Button ]);
|
||||
this.dislike_button = Parser.parseItem<ToggleButton | Button>(data.dislikeButton, [ ToggleButton, Button ]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { YTNode } from '../helpers.js';
|
||||
import type { RawNode } from '../index.js';
|
||||
import type { ObservedArray } from '../helpers.js';
|
||||
import { YTNodes } from '../index.js';
|
||||
import Parser from '../index.js';
|
||||
import Text from './misc/Text.js';
|
||||
import MetadataBadge from './MetadataBadge.js';
|
||||
import Menu from './menus/Menu.js';
|
||||
|
||||
class VideoPrimaryInfo extends YTNode {
|
||||
static type = 'VideoPrimaryInfo';
|
||||
@@ -12,10 +13,10 @@ class VideoPrimaryInfo extends YTNode {
|
||||
super_title_link: Text;
|
||||
view_count: Text;
|
||||
short_view_count: Text;
|
||||
badges: ObservedArray<YTNodes.MetadataBadge>;
|
||||
badges: ObservedArray<MetadataBadge>;
|
||||
published: Text;
|
||||
relative_date: Text;
|
||||
menu: YTNodes.Menu | null;
|
||||
menu: Menu | null;
|
||||
|
||||
constructor(data: RawNode) {
|
||||
super();
|
||||
@@ -23,10 +24,10 @@ class VideoPrimaryInfo extends YTNode {
|
||||
this.super_title_link = new Text(data.superTitleLink);
|
||||
this.view_count = new Text(data.viewCount?.videoViewCountRenderer?.viewCount);
|
||||
this.short_view_count = new Text(data.viewCount?.videoViewCountRenderer?.shortViewCount);
|
||||
this.badges = Parser.parseArray(data.badges, YTNodes.MetadataBadge);
|
||||
this.badges = Parser.parseArray(data.badges, MetadataBadge);
|
||||
this.published = new Text(data.dateText);
|
||||
this.relative_date = new Text(data.relativeDateText);
|
||||
this.menu = Parser.parseItem(data.videoActions, YTNodes.Menu);
|
||||
this.menu = Parser.parseItem(data.videoActions, Menu);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user