Skip to content

Commit

Permalink
feat(parser): Add mobile guide nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
LuanRT committed Dec 8, 2024
1 parent 4bf125b commit ad2ae51
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/parser/classes/mweb/MobileTopbar.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
14 changes: 14 additions & 0 deletions src/parser/classes/mweb/MultiPageMenuSection.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
13 changes: 13 additions & 0 deletions src/parser/classes/mweb/PivotBar.ts
Original file line number Diff line number Diff line change
@@ -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);
}
}
27 changes: 27 additions & 0 deletions src/parser/classes/mweb/PivotBarItem.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
18 changes: 18 additions & 0 deletions src/parser/classes/mweb/TopbarMenuButton.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}
5 changes: 5 additions & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit ad2ae51

Please sign in to comment.