import { devtoolsInjects } from '../global'; function getGlobal(this: any) { return this; } const global = getGlobal(); // console.info(typeof global); export default function injectDevtools() { // console.info('inject devtools'); if (typeof global.__REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined') { global.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = new Proxy( global.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject, { apply: (target, thisArgument, argumentsList) => { try { // console.info('call inject'); Object.assign(devtoolsInjects, argumentsList[0]); } catch (e: any) { console.warn(e.message); } return Reflect.apply(target, thisArgument, argumentsList); }, } ); } else { global.__REACT_DEVTOOLS_GLOBAL_HOOK__ = { isDisabled: false, supportsFiber: true, inject(injects: any) { try { // console.info('call inject'); Object.assign(devtoolsInjects, injects); } catch (e: any) { console.warn(e.message); } return undefined; }, }; } }