mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-25 07:42:11 +00:00
feat(parser): Add mobile guide nodes
This commit is contained in:
20
src/parser/classes/mweb/MobileTopbar.ts
Normal file
20
src/parser/classes/mweb/MobileTopbar.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
14
src/parser/classes/mweb/MultiPageMenuSection.ts
Normal file
14
src/parser/classes/mweb/MultiPageMenuSection.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
13
src/parser/classes/mweb/PivotBar.ts
Normal file
13
src/parser/classes/mweb/PivotBar.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
27
src/parser/classes/mweb/PivotBarItem.ts
Normal file
27
src/parser/classes/mweb/PivotBarItem.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
18
src/parser/classes/mweb/TopbarMenuButton.ts
Normal file
18
src/parser/classes/mweb/TopbarMenuButton.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user