mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-25 07:42:11 +00:00
refactor!: migrate core renderers to TypeScript
This commit is contained in:
@@ -4,9 +4,11 @@ import { YTNode } from '../helpers';
|
||||
class BrowseFeedActions extends YTNode {
|
||||
static type = 'BrowseFeedActions';
|
||||
|
||||
constructor(data) {
|
||||
contents;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.contents = Parser.parse(data.contents);
|
||||
this.contents = Parser.parseArray(data.contents);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import Parser from '../index';
|
||||
import ItemSectionHeader from './ItemSectionHeader';
|
||||
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class ItemSection extends YTNode {
|
||||
static type = 'ItemSection';
|
||||
|
||||
constructor(data) {
|
||||
header: ItemSectionHeader | null;
|
||||
contents;
|
||||
target_id;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.header = Parser.parse(data.header);
|
||||
this.header = Parser.parseItem<ItemSectionHeader>(data.header, ItemSectionHeader);
|
||||
this.contents = Parser.parse(data.contents, true);
|
||||
|
||||
if (data.targetId || data.sectionIdentifier) {
|
||||
@@ -4,7 +4,9 @@ import { YTNode } from '../helpers';
|
||||
class ItemSectionHeader extends YTNode {
|
||||
static type = 'ItemSectionHeader';
|
||||
|
||||
constructor(data) {
|
||||
title: Text;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
}
|
||||
@@ -1,15 +1,21 @@
|
||||
import Text from './misc/Text';
|
||||
import Parser from '../index';
|
||||
import MusicThumbnail from './MusicThumbnail';
|
||||
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class MusicImmersiveHeader extends YTNode {
|
||||
static type = 'MusicImmersiveHeader';
|
||||
|
||||
constructor(data) {
|
||||
title: Text;
|
||||
description: Text;
|
||||
thumbnail: MusicThumbnail | null;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.description = new Text(data.description);
|
||||
this.thumbnails = Parser.parse(data.thumbnail);
|
||||
this.thumbnail = Parser.parseItem<MusicThumbnail>(data.thumbnail, MusicThumbnail);
|
||||
/**
|
||||
Not useful for now.
|
||||
this.menu = Parser.parse(data.menu);
|
||||
28
src/parser/classes/MusicShelf.ts
Normal file
28
src/parser/classes/MusicShelf.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import Parser from '../index';
|
||||
import Text from './misc/Text';
|
||||
import NavigationEndpoint from './NavigationEndpoint';
|
||||
import MusicResponsiveListItem from './MusicResponsiveListItem';
|
||||
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class MusicShelf extends YTNode {
|
||||
static type = 'MusicShelf';
|
||||
|
||||
title: Text;
|
||||
contents;
|
||||
endpoint: NavigationEndpoint | null;
|
||||
continuation: string | null;
|
||||
bottom_text: Text | null;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
|
||||
this.title = new Text(data.title);
|
||||
this.contents = Parser.parseArray<MusicResponsiveListItem>(data.contents, MusicResponsiveListItem);
|
||||
this.endpoint = Reflect.has(data, 'bottomEndpoint') ? new NavigationEndpoint(data.bottomEndpoint) : null;
|
||||
this.continuation = data.continuations?.[0]?.nextContinuationData?.continuation || null;
|
||||
this.bottom_text = Reflect.has(data, 'bottomText') ? new Text(data.bottomText) : null;
|
||||
}
|
||||
}
|
||||
|
||||
export default MusicShelf;
|
||||
@@ -4,9 +4,11 @@ import { YTNode } from '../helpers';
|
||||
class MusicThumbnail extends YTNode {
|
||||
static type = 'MusicThumbnail';
|
||||
|
||||
constructor(data) {
|
||||
contents;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
return Thumbnail.fromResponse(data.thumbnail);
|
||||
this.contents = Thumbnail.fromResponse(data.thumbnail);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import Parser from '../index';
|
||||
import Tab from './Tab';
|
||||
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class SingleColumnBrowseResults extends YTNode {
|
||||
static type = 'SingleColumnBrowseResults';
|
||||
|
||||
constructor(data) {
|
||||
tabs;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.tabs = Parser.parse(data.tabs);
|
||||
this.tabs = Parser.parseArray<Tab>(data.tabs, Tab);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import Parser from '../index';
|
||||
import { YTNode } from '../helpers';
|
||||
import Tab from './Tab';
|
||||
|
||||
class TabbedSearchResults extends YTNode {
|
||||
static type = 'TabbedSearchResults';
|
||||
|
||||
constructor(data) {
|
||||
tabs;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.tabs = Parser.parse(data.tabs);
|
||||
this.tabs = Parser.parseArray<Tab>(data.tabs, Tab);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user