Skip to content

Commit

Permalink
feat(parser): Add LiveChatBannerChatSummary node, update TextRun
Browse files Browse the repository at this point in the history
…node (#809)

* feat(parser): add `LiveChatBannerChatSummary` node

* feat(TextRun): add `deemphasize` property

* chore: npm run build:parser-map
  • Loading branch information
jonz94 authored Nov 18, 2024
1 parent 53d1c75 commit 7fb00fa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/parser/classes/livechat/items/LiveChatBannerChatSummary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { YTNode } from '../../../helpers.js';
import { Parser, type RawNode } from '../../../index.js';
import Text from '../../misc/Text.js';
import ToggleButtonView from '../../ToggleButtonView.js';

export default class LiveChatBannerChatSummary extends YTNode {
static type = 'LiveChatBannerChatSummary';

id: string;
chat_summary: Text;
icon_type: string;
like_feedback_button: ToggleButtonView | null;
dislike_feedback_button: ToggleButtonView | null;

constructor(data: RawNode) {
super();
this.id = data.liveChatSummaryId;
this.chat_summary = new Text(data.chatSummary);
this.icon_type = data.icon.iconType;
this.like_feedback_button = Parser.parseItem(data.likeFeedbackButton, ToggleButtonView);
this.dislike_feedback_button = Parser.parseItem(data.dislikeFeedbackButton, ToggleButtonView);
}
}
3 changes: 3 additions & 0 deletions src/parser/classes/misc/TextRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export default class TextRun implements Run {
bold: boolean;
italics: boolean;
strikethrough: boolean;
deemphasize: boolean;
attachment;

constructor(data: RawNode) {
this.text = data.text;
this.bold = Boolean(data.bold);
this.italics = Boolean(data.italics);
this.strikethrough = Boolean(data.strikethrough);
this.deemphasize = Boolean(data.deemphasize);

if (Reflect.has(data, 'navigationEndpoint')) {
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
Expand All @@ -33,6 +35,7 @@ export default class TextRun implements Run {
if (this.bold) tags.push('b');
if (this.italics) tags.push('i');
if (this.strikethrough) tags.push('s');
if (this.deemphasize) tags.push('small');

const escaped_text = escape(this.text);
const styled_text = tags.map((tag) => `<${tag}>`).join('') + escaped_text + tags.map((tag) => `</${tag}>`).join('');
Expand Down
1 change: 1 addition & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export { default as AddLiveChatTickerItemAction } from './classes/livechat/AddLi
export { default as DimChatItemAction } from './classes/livechat/DimChatItemAction.js';
export { default as LiveChatAutoModMessage } from './classes/livechat/items/LiveChatAutoModMessage.js';
export { default as LiveChatBanner } from './classes/livechat/items/LiveChatBanner.js';
export { default as LiveChatBannerChatSummary } from './classes/livechat/items/LiveChatBannerChatSummary.js';
export { default as LiveChatBannerHeader } from './classes/livechat/items/LiveChatBannerHeader.js';
export { default as LiveChatBannerPoll } from './classes/livechat/items/LiveChatBannerPoll.js';
export { default as LiveChatBannerRedirect } from './classes/livechat/items/LiveChatBannerRedirect.js';
Expand Down

0 comments on commit 7fb00fa

Please sign in to comment.