diff --git a/desktop/app/src/electron/initializeElectron.tsx b/desktop/app/src/electron/initializeElectron.tsx index 493e52750..11a42bb04 100644 --- a/desktop/app/src/electron/initializeElectron.tsx +++ b/desktop/app/src/electron/initializeElectron.tsx @@ -27,6 +27,7 @@ import {setupMenuBar} from './setupMenuBar'; import {FlipperServer, FlipperServerConfig} from 'flipper-common'; import type {Icon, RenderHost} from 'flipper-ui-core'; import {getLocalIconUrl} from '../utils/icons'; +import {getCPUUsage} from 'process'; export function initializeElectron( flipperServer: FlipperServer, @@ -202,6 +203,9 @@ export function initializeElectron( } delete global.electronRequire.cache[resolvedPath]; }, + getPercentCPUUsage() { + return getCPUUsage().percentCPUUsage; + }, } as RenderHost; setupMenuBar(); diff --git a/desktop/flipper-server/src/startWebServerDev.tsx b/desktop/flipper-server/src/startWebServerDev.tsx index 3f6ee7c5e..5f73bd207 100644 --- a/desktop/flipper-server/src/startWebServerDev.tsx +++ b/desktop/flipper-server/src/startWebServerDev.tsx @@ -27,50 +27,50 @@ const uiSourceDirs = [ 'flipper-common', ]; -const stubModules = new Set([ - 'fs', - 'path', - 'crypto', - 'process', - 'os', - 'util', - 'child_process', - 'assert', - 'adbkit', // TODO: factor out! - 'zlib', - 'events', - 'fs-extra', - 'archiver', - 'graceful-fs', - 'stream', - 'url', - 'node-fetch', - 'net', - 'vm', - 'debug', - 'lockfile', - 'constants', - 'https', - 'plugin-lib', // TODO: we only want the types? - 'flipper-plugin-lib', - 'tar', - 'minipass', - 'live-plugin-manager', - 'decompress-tar', - 'readable-stream', - 'archiver-utils', - 'metro', - 'decompress', - 'temp', - 'tmp', - 'promisify-child-process', - 'jsdom', - 'extract-zip', - 'yauzl', - 'fd-slicer', - 'envinfo', - 'bser', - 'fb-watchman', +const stubModules = new Set([ + // 'fs', + // 'path', + // 'crypto', + // 'process', + // 'os', + // 'util', + // 'child_process', + // 'assert', + // 'adbkit', // TODO: factor out! + // 'zlib', + // 'events', + // 'fs-extra', + // 'archiver', + // 'graceful-fs', + // 'stream', + // 'url', + // 'node-fetch', + // 'net', + // 'vm', + // 'debug', + // 'lockfile', + // 'constants', + // 'https', + // 'plugin-lib', // TODO: we only want the types? + // 'flipper-plugin-lib', + // 'tar', + // 'minipass', + // 'live-plugin-manager', + // 'decompress-tar', + // 'readable-stream', + // 'archiver-utils', + // 'metro', + // 'decompress', + // 'temp', + // 'tmp', + // 'promisify-child-process', + // 'jsdom', + // 'extract-zip', + // 'yauzl', + // 'fd-slicer', + // 'envinfo', + // 'bser', + // 'fb-watchman', // TODO fix me ]); diff --git a/desktop/flipper-ui-browser/src/index.tsx b/desktop/flipper-ui-browser/src/index.tsx index acd14bdb7..e5431b215 100644 --- a/desktop/flipper-ui-browser/src/index.tsx +++ b/desktop/flipper-ui-browser/src/index.tsx @@ -18,7 +18,9 @@ async function start() { console.error( `[decapitate] Tried to electronRequire ${path}, this module is not available in the browser and will be stubbed`, ); - return {}; + return { + default: {}, + }; }; const logger = createDelegatedLogger(); diff --git a/desktop/flipper-ui-core/src/RenderHost.tsx b/desktop/flipper-ui-core/src/RenderHost.tsx index 70f2b27fd..c732734c2 100644 --- a/desktop/flipper-ui-core/src/RenderHost.tsx +++ b/desktop/flipper-ui-core/src/RenderHost.tsx @@ -104,6 +104,7 @@ export interface RenderHost { // given the requested icon and proposed public url of the icon, rewrite it to a local icon if needed getLocalIconUrl?(icon: Icon, publicUrl: string): string; unloadModule?(path: string): void; + getPercentCPUUsage?(): number; } export function getRenderHostInstance(): RenderHost { diff --git a/desktop/flipper-ui-core/src/dispatcher/tracking.tsx b/desktop/flipper-ui-core/src/dispatcher/tracking.tsx index 437e06742..26441cf9d 100644 --- a/desktop/flipper-ui-core/src/dispatcher/tracking.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/tracking.tsx @@ -24,7 +24,6 @@ import { import produce from 'immer'; import BaseDevice from '../devices/BaseDevice'; import {deconstructClientId} from 'flipper-common'; -import {getCPUUsage} from 'process'; import {sideEffect} from '../utils/sideEffect'; import {getSelectionInfo} from '../utils/info'; import type {SelectionInfo} from '../utils/info'; @@ -239,7 +238,7 @@ export default (store: Store, logger: Logger) => { sdkVersion, isForeground: state.application.windowIsFocused, usedJSHeapSize: (window.performance as any).memory.usedJSHeapSize, - cpuLoad: getCPUUsage().percentCPUUsage, + cpuLoad: renderHost.getPercentCPUUsage?.() ?? 0, }; // reset dropped frames counter diff --git a/desktop/plugins/public/cpu/index.tsx b/desktop/plugins/public/cpu/index.tsx index 9b8bab519..0404370ce 100644 --- a/desktop/plugins/public/cpu/index.tsx +++ b/desktop/plugins/public/cpu/index.tsx @@ -20,7 +20,6 @@ import { DataTableColumn, Toolbar, } from 'flipper-plugin'; -import adb from 'adbkit'; import TemperatureTable from './TemperatureTable'; import {Button, Typography, Switch} from 'antd'; import {PlayCircleOutlined, PauseCircleOutlined} from '@ant-design/icons'; diff --git a/desktop/plugins/public/kaios-ram/index.tsx b/desktop/plugins/public/kaios-ram/index.tsx index a4c1b4b8c..dc48ace30 100644 --- a/desktop/plugins/public/kaios-ram/index.tsx +++ b/desktop/plugins/public/kaios-ram/index.tsx @@ -9,9 +9,15 @@ import React from 'react'; -import {FlipperDevicePlugin, Device, sleep} from 'flipper'; - -import {FlexColumn, Button, Toolbar, Panel} from 'flipper'; +import { + FlipperDevicePlugin, + Device, + sleep, + FlexColumn, + Button, + Toolbar, + Panel, +} from 'flipper'; import { Legend, @@ -24,7 +30,6 @@ import { Tooltip, } from 'recharts'; -import adb from 'adbkit'; import {getFlipperLib} from 'flipper-plugin'; const PALETTE = [