diff --git a/packages/hyperion-react-native-testapp/src/hyperion/AutoLoggingWrapper.ts b/packages/hyperion-react-native-testapp/src/hyperion/AutoLoggingWrapper.ts index c5b7fdec..3d041e5c 100644 --- a/packages/hyperion-react-native-testapp/src/hyperion/AutoLoggingWrapper.ts +++ b/packages/hyperion-react-native-testapp/src/hyperion/AutoLoggingWrapper.ts @@ -10,6 +10,7 @@ import * as IPromise from "hyperion-core/src/IPromise"; import {interceptFunction} from "hyperion-core/src/FunctionInterceptor"; import TestAndSet from 'hyperion-test-and-set/src/TestAndSet'; import interceptReactProps from "./interceptReactProps"; +import { useALSurfaceContext } from "hyperion-autologging/src/ALSurfaceContext"; globalThis.__DEV__ = true; @@ -18,6 +19,8 @@ export let interceptionStatus = "disabled"; const initialized = new TestAndSet(); export function init() { + const RENDER_FUNCTION_INTERCEPTED = '__IS_RENDER_INTERCEPTED__TODO_LIST'; + if (initialized.testAndSet()) { return; } @@ -30,6 +33,12 @@ export function init() { } } + function observer1(name: string) { + return function (this: T) { + console.log(name, this); + } + } + // ReactModule/JSX const IReactModule = IReact.intercept("react", React as any, []); const IJsxRuntimeModule = IReact.interceptRuntime("react/jsx-runtime", ReactDev as any, []); @@ -75,6 +84,21 @@ export function init() { } }); + IReactComponent.onReactClassComponentIntercept.add(shadow => { + const render = shadow.render; + if (!render.testAndSet(RENDER_FUNCTION_INTERCEPTED)) { + const name = render.getOriginal().name ?? shadow.name + render.onBeforeCallObserverAdd(observer1(`[${name}][Class][render]`)); + } + }) + + IReactComponent.onReactFunctionComponentIntercept.add(render => { + const name: string = render.getOriginal().displayName ?? render.name; + if (!render.testAndSet(RENDER_FUNCTION_INTERCEPTED) && name != null) { + render.onBeforeCallObserverAdd(observer1(`[${name}][Func][render]`)); + } + }); + /** * ***************************** * IReactComponent / JSX - END