feat(parser): Add mobile guide nodes

This commit is contained in:
Luan
2024-12-08 17:11:27 -03:00
parent 4bf125b6a5
commit ad2ae51b97
6 changed files with 97 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import { YTNode } from '../../helpers.js';
import Text from '../misc/Text.js';
import { Parser, type RawNode } from '../../index.js';
export default class MobileTopbar extends YTNode {
static type = 'MobileTopbar';
public placeholder_text: Text;
public buttons;
public logo_type?: string;
constructor(data: RawNode) {
super();
this.placeholder_text = new Text(data.placeholderText);
this.buttons = Parser.parseArray(data.buttons);
if (Reflect.has(data, 'logo') && Reflect.has(data.logo, 'iconType'))
this.logo_type = data.logo.iconType;
}
}

View File

@@ -0,0 +1,14 @@
import type { ObservedArray } from '../../helpers.js';
import { YTNode } from '../../helpers.js';
import { Parser, type RawNode } from '../../index.js';
export default class MultiPageMenuSection extends YTNode {
static type = 'MultiPageMenuSection';
public items: ObservedArray<YTNode> | null;
constructor(data: RawNode) {
super();
this.items = Parser.parseArray(data.items);
}
}

View File

@@ -0,0 +1,13 @@
import { YTNode } from '../../helpers.js';
import { Parser, type RawNode } from '../../index.js';
export default class PivotBar extends YTNode {
static type = 'PivotBar';
public items;
constructor(data: RawNode) {
super();
this.items = Parser.parseArray(data.items);
}
}

View File

@@ -0,0 +1,27 @@
import { YTNode } from '../../helpers.js';
import { type RawNode } from '../../index.js';
import Text from '../misc/Text.js';
import NavigationEndpoint from '../NavigationEndpoint.js';
export default class PivotBarItem extends YTNode {
static type = 'PivotBarItem';
public pivot_identifier: string;
public endpoint: NavigationEndpoint;
public title: Text;
public accessibility_label?: string;
public icon_type?: string;
constructor(data: RawNode) {
super();
this.pivot_identifier = data.pivotIdentifier;
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
this.title = new Text(data.title);
if (Reflect.has(data, 'accessibility') && Reflect.has(data.accessibility, 'accessibilityData'))
this.accessibility_label = data.accessibility.accessibilityData.label;
if (Reflect.has(data, 'icon') && Reflect.has(data.icon, 'iconType'))
this.icon_type = data.icon.iconType;
}
}

View File

@@ -0,0 +1,18 @@
import { YTNode } from '../../helpers.js';
import { Parser, type RawNode } from '../../index.js';
export default class TopbarMenuButton extends YTNode {
static type = 'TopbarMenuButton';
public icon_type?: string;
public menu_renderer: YTNode | null;
public target_id: string;
constructor(data: RawNode) {
super();
if (Reflect.has(data, 'icon') && Reflect.has(data.icon, 'iconType'))
this.icon_type = data.icon.iconType;
this.menu_renderer = Parser.parseItem(data.menuRenderer);
this.target_id = data.targetId;
}
}

View File

@@ -323,6 +323,11 @@ export { default as MusicTastebuilderShelfThumbnail } from './classes/MusicTaste
export { default as MusicThumbnail } from './classes/MusicThumbnail.js';
export { default as MusicTwoRowItem } from './classes/MusicTwoRowItem.js';
export { default as MusicVisualHeader } from './classes/MusicVisualHeader.js';
export { default as MobileTopbar } from './classes/mweb/MobileTopbar.js';
export { default as MultiPageMenuSection } from './classes/mweb/MultiPageMenuSection.js';
export { default as PivotBar } from './classes/mweb/PivotBar.js';
export { default as PivotBarItem } from './classes/mweb/PivotBarItem.js';
export { default as TopbarMenuButton } from './classes/mweb/TopbarMenuButton.js';
export { default as NavigationEndpoint } from './classes/NavigationEndpoint.js';
export { default as Notification } from './classes/Notification.js';
export { default as NotificationAction } from './classes/NotificationAction.js';