From e96581614471524cbf91bf962742df867ba3c3e9 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Fri, 11 Oct 2024 14:47:27 -0400 Subject: [PATCH] fix(*): prevent issues where toString may not be a function (what) --- src/components/Dialog.ts | 4 ++-- src/components/FocusRing.ts | 2 +- src/components/Menu.ts | 4 ++-- src/components/Modal.ts | 2 +- src/components/Panel.ts | 2 +- src/components/ProgressBar.ts | 4 ++-- src/components/SliderField.ts | 2 +- src/components/Tabs.tsx | 4 ++-- src/components/Toggle.ts | 2 +- src/components/ToggleField.ts | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/components/Dialog.ts b/src/components/Dialog.ts index c5a6b29..3895ab3 100644 --- a/src/components/Dialog.ts +++ b/src/components/Dialog.ts @@ -78,11 +78,11 @@ export const DialogControlsSection = MappedDialogDivs.get('DialogControlsSection export const DialogControlsSectionHeader = MappedDialogDivs.get('DialogControlsSectionHeader') as FC; export const DialogButtonPrimary = Object.values(CommonUIModule).find( - (mod: any) => mod?.render?.toString()?.includes('"DialogButton","_DialogLayout","Primary"'), + (mod: any) => mod?.render?.toString?.()?.includes('"DialogButton","_DialogLayout","Primary"'), ) as FC; export const DialogButtonSecondary = Object.values(CommonUIModule).find( - (mod: any) => mod?.render?.toString()?.includes('"DialogButton","_DialogLayout","Secondary"') + (mod: any) => mod?.render?.toString?.()?.includes('"DialogButton","_DialogLayout","Secondary"') ) as FC; // This is the "main" button. The Primary can act as a submit button, diff --git a/src/components/FocusRing.ts b/src/components/FocusRing.ts index 20f1ba5..97e08e1 100644 --- a/src/components/FocusRing.ts +++ b/src/components/FocusRing.ts @@ -11,5 +11,5 @@ export interface FocusRingProps { } export const FocusRing = findModuleExport((e: Export) => - e?.toString()?.includes('.GetShowDebugFocusRing())'), + e?.toString?.()?.includes('.GetShowDebugFocusRing())'), ) as FC; diff --git a/src/components/Menu.ts b/src/components/Menu.ts index 08d4c1c..2fe30dd 100755 --- a/src/components/Menu.ts +++ b/src/components/Menu.ts @@ -26,7 +26,7 @@ export interface MenuGroupProps { } const MenuGoupModule = findModuleByExport(e => e?.prototype?.Focus && e?.prototype?.OnOKButton && e?.prototype?.render?.toString().includes?.(`"emphasis"==this.props.tone`)); -export const MenuGroup: FC = MenuGoupModule && Object.values(MenuGoupModule).find((e: Export) => typeof e == "function" && e?.toString()?.includes("bInGamepadUI:")); +export const MenuGroup: FC = MenuGoupModule && Object.values(MenuGoupModule).find((e: Export) => typeof e == "function" && e?.toString?.()?.includes("bInGamepadUI:")); export interface MenuItemProps extends FooterLegendProps { bInteractableItem?: boolean; onClick?(evt: Event): void; @@ -42,7 +42,7 @@ export interface MenuItemProps extends FooterLegendProps { export const MenuItem: FC = findModuleExport( (e: Export) => - e?.render?.toString()?.includes('bPlayAudio:') || (e?.prototype?.OnOKButton && e?.prototype?.OnMouseEnter), + e?.render?.toString?.()?.includes('bPlayAudio:') || (e?.prototype?.OnOKButton && e?.prototype?.OnMouseEnter), ); /* diff --git a/src/components/Modal.ts b/src/components/Modal.ts index 9f98e12..69b131f 100755 --- a/src/components/Modal.ts +++ b/src/components/Modal.ts @@ -98,7 +98,7 @@ export const ModalRoot = Object.values( return false; }) || {}, -)?.find((x: any) => x?.type?.toString()?.includes('((function(){')) as FC; +)?.find((x: any) => x?.type?.toString?.()?.includes('((function(){')) as FC; interface SimpleModalProps { active?: boolean; diff --git a/src/components/Panel.ts b/src/components/Panel.ts index cbddb0f..c51b873 100644 --- a/src/components/Panel.ts +++ b/src/components/Panel.ts @@ -22,5 +22,5 @@ export interface PanelSectionRowProps { children?: ReactNode; } export const PanelSectionRow = Object.values(mod).filter( - (exp: any) => !exp?.toString()?.includes('.PanelSection'), + (exp: any) => !exp?.toString?.()?.includes('.PanelSection'), )[0] as FC; diff --git a/src/components/ProgressBar.ts b/src/components/ProgressBar.ts index 4f02e38..8ebeea5 100644 --- a/src/components/ProgressBar.ts +++ b/src/components/ProgressBar.ts @@ -24,11 +24,11 @@ export interface ProgressBarWithInfoProps extends ProgressBarItemProps { } export const ProgressBar = findModuleExport((e: Export) => - e?.toString()?.includes('.ProgressBar,"standard"=='), + e?.toString?.()?.includes('.ProgressBar,"standard"=='), ) as FC; export const ProgressBarWithInfo = findModuleExport((e: Export) => - e?.toString()?.includes('.ProgressBarFieldStatus},'), + e?.toString?.()?.includes('.ProgressBarFieldStatus},'), ) as FC; const progressBarItemRegex = createPropListRegex(["indeterminate", "nTransitionSec", "nProgress"]); diff --git a/src/components/SliderField.ts b/src/components/SliderField.ts index a494ff7..963a2d3 100644 --- a/src/components/SliderField.ts +++ b/src/components/SliderField.ts @@ -30,5 +30,5 @@ export interface SliderFieldProps extends ItemProps { export const SliderField = Object.values(CommonUIModule).find((mod: any) => // stable || beta as of oct 2 2024 - mod?.toString()?.includes('SliderField,fallback') || mod?.toString()?.includes("SliderField\",") + mod?.toString?.()?.includes('SliderField,fallback') || mod?.toString?.()?.includes("SliderField\",") ) as FC; diff --git a/src/components/Tabs.tsx b/src/components/Tabs.tsx index e592568..24e7610 100644 --- a/src/components/Tabs.tsx +++ b/src/components/Tabs.tsx @@ -62,9 +62,9 @@ export interface TabsProps { autoFocusContents?: boolean; } -const tabsModule = findModuleByExport(e => e?.toString()?.includes(".TabRowTabs") && e?.toString()?.includes("activeTab:")); +const tabsModule = findModuleByExport(e => e?.toString?.()?.includes(".TabRowTabs") && e?.toString?.()?.includes("activeTab:")); /** * Tabs component as used in the library and media tabs. See {@link TabsProps}. */ -export const Tabs = tabsModule && Object.values(tabsModule).find((e: any) => e?.type?.toString()?.includes("((function()")) as FC; +export const Tabs = tabsModule && Object.values(tabsModule).find((e: any) => e?.type?.toString?.()?.includes("((function()")) as FC; diff --git a/src/components/Toggle.ts b/src/components/Toggle.ts index 0836eb3..6f4da0d 100644 --- a/src/components/Toggle.ts +++ b/src/components/Toggle.ts @@ -10,5 +10,5 @@ export interface ToggleProps { } export const Toggle = Object.values(CommonUIModule).find((mod: any) => - mod?.render?.toString()?.includes('.ToggleOff)'), + mod?.render?.toString?.()?.includes('.ToggleOff)'), ) as FC; diff --git a/src/components/ToggleField.ts b/src/components/ToggleField.ts index ffb06ba..182eb4d 100644 --- a/src/components/ToggleField.ts +++ b/src/components/ToggleField.ts @@ -12,5 +12,5 @@ export interface ToggleFieldProps extends ItemProps { export const ToggleField = Object.values(CommonUIModule).find((mod: any) => // stable || beta as of oct 2 2024 - mod?.render?.toString()?.includes('ToggleField,fallback') || mod?.render?.toString()?.includes("ToggleField\",") + mod?.render?.toString?.()?.includes('ToggleField,fallback') || mod?.render?.toString?.()?.includes("ToggleField\",") ) as FC;