Remove 'process' usage

Summary: Removed process, adbkit and electron usages that were still remaining. Verified changes by disabling the built-in module stubbing (will be cleaned up further later in this stack).

Reviewed By: aigoncharov

Differential Revision: D33019083

fbshipit-source-id: 8bfce31f4b5ed349cb4fd86d34c9b41b9b8b8360
This commit is contained in:
Michel Weststrate
2021-12-13 05:46:42 -08:00
committed by Facebook GitHub Bot
parent 3ef1923b29
commit ac9080abac
7 changed files with 62 additions and 52 deletions

View File

@@ -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();

View File

@@ -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<string>([
// '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
]);

View File

@@ -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();

View File

@@ -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 {

View File

@@ -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

View File

@@ -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';

View File

@@ -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 = [