From 261162c8bceecc50afad07d57a78b85b98936fe1 Mon Sep 17 00:00:00 2001 From: AAGaming Date: Fri, 20 Mar 2026 20:27:59 -0400 Subject: [PATCH] fix(components): update for latest beta --- .husky/commit-msg | 3 --- src/components/Dialog.ts | 13 +++++++++++-- src/components/ProgressBar.ts | 3 ++- src/components/Scroll.ts | 3 ++- src/components/Spinner.ts | 4 ++-- src/utils/react/fc.ts | 19 +++++++++++++++++++ src/webpack.ts | 2 +- 7 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index e998e31..7b554ec 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - npx --no -- commitlint --edit "${1}" diff --git a/src/components/Dialog.ts b/src/components/Dialog.ts index c60a64b..bfc21cf 100644 --- a/src/components/Dialog.ts +++ b/src/components/Dialog.ts @@ -52,8 +52,17 @@ export interface DialogButtonProps extends DialogCommonProps, FooterLegendProps } const CommonDialogDivs = Object.values(CommonUIModule).filter( - (m: any) => typeof m === 'object' && m?.render?.toString().includes('createElement("div",{...') || - m?.render?.toString().includes('createElement("div",Object.assign({},'), + (m: any) => typeof m === 'object' && + // New + ( + m?.render?.toString().includes('jsx)("div",{...') || + m?.render?.toString().includes('jsx)("div",Object.assign({},') + ) || + // Old + ( + m?.render?.toString().includes('createElement("div",{...') || + m?.render?.toString().includes('createElement("div",Object.assign({},') + ) ); const MappedDialogDivs = new Map( Object.values(CommonDialogDivs).map((m: any) => { diff --git a/src/components/ProgressBar.ts b/src/components/ProgressBar.ts index 8ebeea5..7d83fae 100644 --- a/src/components/ProgressBar.ts +++ b/src/components/ProgressBar.ts @@ -28,7 +28,8 @@ export const ProgressBar = findModuleExport((e: Export) => ) as FC; export const ProgressBarWithInfo = findModuleExport((e: Export) => - e?.toString?.()?.includes('.ProgressBarFieldStatus},'), + // new || old + e?.toString?.()?.includes('.ProgressBarFieldStatus,children') || e?.toString?.()?.includes('.ProgressBarFieldStatus},'), ) as FC; const progressBarItemRegex = createPropListRegex(["indeterminate", "nTransitionSec", "nProgress"]); diff --git a/src/components/Scroll.ts b/src/components/Scroll.ts index a0e731c..cd8f0fe 100644 --- a/src/components/Scroll.ts +++ b/src/components/Scroll.ts @@ -11,5 +11,6 @@ export const ScrollPanel = ScrollingModuleProps.find((prop: any) => ) as FC<{ children?: ReactNode }>; export const ScrollPanelGroup: FC<{ children?: ReactNode }> = findModuleExport((e: Export) => - e?.render?.toString().includes('.FocusVisibleChild()),[])'), + // new || old + e?.render?.toString().includes('.FocusVisibleChild(),[])') || e?.render?.toString().includes('.FocusVisibleChild()),[])'), ); diff --git a/src/components/Spinner.ts b/src/components/Spinner.ts index 7108374..26a5f7c 100755 --- a/src/components/Spinner.ts +++ b/src/components/Spinner.ts @@ -3,6 +3,6 @@ import { FC, SVGAttributes } from 'react'; import { IconsModule } from '../webpack'; // TODO type this and other icons? -export const Spinner = Object.values(IconsModule)?.find( - (mod: any) => mod?.toString && /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(mod.toString()), +export const Spinner = IconsModule && Object.values(IconsModule)?.find( + (mod: any) => mod?.toString && /Spinner\),children:\[\(0,\w+\.jsx\)\("path",\{d:"M18 /.test(mod.toString()) || /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(mod.toString()), ) as FC>; diff --git a/src/utils/react/fc.ts b/src/utils/react/fc.ts index 6de16a1..b5036f8 100644 --- a/src/utils/react/fc.ts +++ b/src/utils/react/fc.ts @@ -42,6 +42,9 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli }; component.prototype.isReactComponent = true; let stubsApplied = false; + const patchJsx = window.SP_REACTDOM.version.startsWith("19."); + let oldJsx = window.SP_JSX?.jsx; + let oldJsxs = window.SP_JSX?.jsxs; let oldCreateElement = window.SP_REACT.createElement; const applyStubsIfNeeded = () => { @@ -55,6 +58,18 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli loggingEnabled && console.trace("createElement trace"); return Object.create(component.prototype); }; + if (patchJsx) { + window.SP_JSX.jsx = () => { + loggingEnabled && logger.debug("jsx hook called"); + loggingEnabled && console.trace("jsx trace"); + return Object.create(component.prototype); + } + window.SP_JSX.jsxs = () => { + loggingEnabled && logger.debug("jsxs hook called"); + loggingEnabled && console.trace("jsxs trace"); + return Object.create(component.prototype); + } + } } } @@ -64,6 +79,10 @@ export function injectFCTrampoline(component: FC, customHooks?: any): FCTrampoli stubsApplied = false; removeHookStubs(); window.SP_REACT.createElement = oldCreateElement; + if (patchJsx) { + window.SP_JSX.jsx = oldJsx; + window.SP_JSX.jsxs = oldJsxs; + } } } diff --git a/src/webpack.ts b/src/webpack.ts index 68a71e9..d47c943 100644 --- a/src/webpack.ts +++ b/src/webpack.ts @@ -154,7 +154,7 @@ export const CommonUIModule = findModule((m: Module) => { }); export const IconsModule = findModuleByExport( - (e) => e?.toString && /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(e.toString()), + (e) => e?.toString && /Spinner\),children:\[\(0,\w+\.jsx\)\("path",\{d:"M18 /.test(e.toString()) || /Spinner\)}\)?,.\.createElement\(\"path\",{d:\"M18 /.test(e.toString()), ); export const ReactRouter = findModuleByExport((e) => e.computeRootMatch);