From 0379e7b939b4c39deb18c838f8b0e5a288b1b14b Mon Sep 17 00:00:00 2001 From: jonz94 Date: Wed, 11 Dec 2024 16:41:28 +0800 Subject: [PATCH 1/3] feat(parser): Add `ClientSideToggleMenuItem` --- .../classes/ClientSideToggleMenuItem.ts | 22 +++++++++++++++++++ src/parser/nodes.ts | 1 + 2 files changed, 23 insertions(+) create mode 100644 src/parser/classes/ClientSideToggleMenuItem.ts diff --git a/src/parser/classes/ClientSideToggleMenuItem.ts b/src/parser/classes/ClientSideToggleMenuItem.ts new file mode 100644 index 000000000..4c6291dbc --- /dev/null +++ b/src/parser/classes/ClientSideToggleMenuItem.ts @@ -0,0 +1,22 @@ +import { YTNode } from '../helpers.js'; +import type { RawNode } from '../index.js'; +import Text from './misc/Text.js'; + +export default class ClientSideToggleMenuItem extends YTNode { + static type = 'ClientSideToggleMenuItem'; + + text: Text; + icon_type: string; + toggled_text: Text; + toggled_icon_type: string; + menu_item_identifier: string; + + constructor(data: RawNode) { + super(); + this.text = new Text(data.defaultText); + this.icon_type = data.defaultIcon.iconType; + this.toggled_text = new Text(data.toggledText); + this.toggled_icon_type = data.toggledIcon.iconType; + this.menu_item_identifier = data.menuItemIdentifier; + } +} diff --git a/src/parser/nodes.ts b/src/parser/nodes.ts index a23778d1d..f918eced6 100644 --- a/src/parser/nodes.ts +++ b/src/parser/nodes.ts @@ -64,6 +64,7 @@ export { default as ChipBarView } from './classes/ChipBarView.js'; export { default as ChipCloud } from './classes/ChipCloud.js'; export { default as ChipCloudChip } from './classes/ChipCloudChip.js'; export { default as ChipView } from './classes/ChipView.js'; +export { default as ClientSideToggleMenuItem } from './classes/ClientSideToggleMenuItem.js'; export { default as ClipAdState } from './classes/ClipAdState.js'; export { default as ClipCreation } from './classes/ClipCreation.js'; export { default as ClipCreationScrubber } from './classes/ClipCreationScrubber.js'; From f0c5c8067606c7ac61d9b54d20944282ae919c76 Mon Sep 17 00:00:00 2001 From: jonz94 Date: Thu, 12 Dec 2024 06:37:14 +0800 Subject: [PATCH 2/3] feat: parse the command --- src/parser/classes/ClientSideToggleMenuItem.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/parser/classes/ClientSideToggleMenuItem.ts b/src/parser/classes/ClientSideToggleMenuItem.ts index 4c6291dbc..956ee94f1 100644 --- a/src/parser/classes/ClientSideToggleMenuItem.ts +++ b/src/parser/classes/ClientSideToggleMenuItem.ts @@ -1,5 +1,6 @@ import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; import Text from './misc/Text.js'; export default class ClientSideToggleMenuItem extends YTNode { @@ -10,6 +11,7 @@ export default class ClientSideToggleMenuItem extends YTNode { toggled_text: Text; toggled_icon_type: string; menu_item_identifier: string; + endpoint: NavigationEndpoint; constructor(data: RawNode) { super(); @@ -18,5 +20,6 @@ export default class ClientSideToggleMenuItem extends YTNode { this.toggled_text = new Text(data.toggledText); this.toggled_icon_type = data.toggledIcon.iconType; this.menu_item_identifier = data.menuItemIdentifier; + this.endpoint = new NavigationEndpoint(data.command); } } From 8d8ca30b8ad81322d1d812eea6c5ebac78af0c23 Mon Sep 17 00:00:00 2001 From: jonz94 Date: Thu, 12 Dec 2024 07:16:18 +0800 Subject: [PATCH 3/3] feat: handle different type of `ClientSideToggleMenuItem` --- .../classes/ClientSideToggleMenuItem.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/parser/classes/ClientSideToggleMenuItem.ts b/src/parser/classes/ClientSideToggleMenuItem.ts index 956ee94f1..7540df1ba 100644 --- a/src/parser/classes/ClientSideToggleMenuItem.ts +++ b/src/parser/classes/ClientSideToggleMenuItem.ts @@ -10,8 +10,15 @@ export default class ClientSideToggleMenuItem extends YTNode { icon_type: string; toggled_text: Text; toggled_icon_type: string; + is_toggled?: boolean; menu_item_identifier: string; endpoint: NavigationEndpoint; + logging_directives?: { + visibility: { + types: string; + }, + enable_displaylogger_experiment: boolean; + }; constructor(data: RawNode) { super(); @@ -19,7 +26,21 @@ export default class ClientSideToggleMenuItem extends YTNode { this.icon_type = data.defaultIcon.iconType; this.toggled_text = new Text(data.toggledText); this.toggled_icon_type = data.toggledIcon.iconType; + + if (Reflect.has(data, 'isToggled')) { + this.is_toggled = data.isToggled; + } + this.menu_item_identifier = data.menuItemIdentifier; this.endpoint = new NavigationEndpoint(data.command); + + if (Reflect.has(data, 'loggingDirectives')) { + this.logging_directives = { + visibility: { + types: data.loggingDirectives.visibility.types + }, + enable_displaylogger_experiment: data.loggingDirectives.enableDisplayloggerExperiment + }; + } } }