From fd380a4c1e7465ee89e3dc9563f7652d6b15289b Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Mon, 20 Jun 2022 12:18:40 -0700 Subject: [PATCH] Use BaseDevice from flipper-frontend-core in flipper-ui-core Summary: Use BasDevice definition from flipper-frontend-core in flipper-ui-core and remove the redundant definition from flipper-ui-core Reviewed By: lblasa Differential Revision: D37234785 fbshipit-source-id: 6e768090a197c1d2c49cb1cd573acea12fb65d24 --- desktop/flipper-frontend-core/src/index.tsx | 2 +- .../flipper-ui-core/src/PluginContainer.tsx | 2 +- .../src/__tests__/test-utils/MockFlipper.tsx | 4 +- .../createMockFlipperWithPlugin.tsx | 2 +- .../src/chrome/MetroButton.tsx | 2 +- .../src/chrome/VideoRecordingButton.tsx | 2 +- desktop/flipper-ui-core/src/deeplink.tsx | 4 - .../src/deprecated-exports.tsx | 4 +- .../src/devices/ArchivedDevice.tsx | 2 +- .../src/devices/BaseDevice.tsx | 378 ------------------ .../src/devices/TestDevice.tsx | 2 +- .../__tests__/pluginManager.node.tsx | 2 +- .../src/dispatcher/flipperServer.tsx | 4 +- .../dispatcher/handleOpenPluginDeeplink.tsx | 6 +- .../src/dispatcher/tracking.tsx | 2 +- desktop/flipper-ui-core/src/plugin.tsx | 2 +- .../reducers/__tests__/connections.node.tsx | 2 +- .../src/reducers/connections.tsx | 12 +- .../sandy-chrome/appinspect/AppInspect.tsx | 2 +- .../sandy-chrome/appinspect/AppSelector.tsx | 2 +- .../sandy-chrome/appinspect/PluginList.tsx | 2 +- .../appinspect/__tests__/PluginList.spec.tsx | 2 +- .../notification/Notification.tsx | 2 - .../src/utils/__tests__/exportData.node.tsx | 26 -- .../flipper-ui-core/src/utils/clientUtils.tsx | 2 +- .../src/utils/createSandyPluginWrapper.tsx | 2 +- .../flipper-ui-core/src/utils/exportData.tsx | 8 +- .../utils/flipperLibImplementation/index.tsx | 2 +- .../flipper-ui-core/src/utils/pluginUtils.tsx | 2 +- .../src/utils/reduxDevToolsConfig.tsx | 2 +- .../flipper-ui-core/src/utils/screenshot.tsx | 2 +- desktop/plugins/public/layout/index.tsx | 1 - 32 files changed, 29 insertions(+), 462 deletions(-) delete mode 100644 desktop/flipper-ui-core/src/devices/BaseDevice.tsx diff --git a/desktop/flipper-frontend-core/src/index.tsx b/desktop/flipper-frontend-core/src/index.tsx index cd488eafe..9f9de0c67 100644 --- a/desktop/flipper-frontend-core/src/index.tsx +++ b/desktop/flipper-frontend-core/src/index.tsx @@ -15,7 +15,7 @@ export { RequestMetadata, } from './AbstractClient'; export {default as ArchivedDevice} from './devices/ArchivedDevice'; -export {default as BaseDevice} from './devices/BaseDevice'; +export {default as BaseDevice, DeviceExport} from './devices/BaseDevice'; export * from './globalObject'; export * from './plugins'; export {getPluginKey} from './utils/pluginKey'; diff --git a/desktop/flipper-ui-core/src/PluginContainer.tsx b/desktop/flipper-ui-core/src/PluginContainer.tsx index 54e07c3b5..a19d2e659 100644 --- a/desktop/flipper-ui-core/src/PluginContainer.tsx +++ b/desktop/flipper-ui-core/src/PluginContainer.tsx @@ -9,7 +9,7 @@ import {FlipperPlugin, FlipperDevicePlugin} from './plugin'; import {Logger, isTest} from 'flipper-common'; -import BaseDevice from './devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {pluginKey as getPluginKey} from './utils/pluginKey'; import Client from './Client'; import { diff --git a/desktop/flipper-ui-core/src/__tests__/test-utils/MockFlipper.tsx b/desktop/flipper-ui-core/src/__tests__/test-utils/MockFlipper.tsx index 21aed9a47..b844900d5 100644 --- a/desktop/flipper-ui-core/src/__tests__/test-utils/MockFlipper.tsx +++ b/desktop/flipper-ui-core/src/__tests__/test-utils/MockFlipper.tsx @@ -8,7 +8,7 @@ */ import {createStore} from 'redux'; -import BaseDevice from '../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {createRootReducer} from '../../reducers'; import {Store} from '../../reducers/index'; import Client from '../../Client'; @@ -198,8 +198,6 @@ export default class MockFlipper { this._logger, this._store, new Set(supportedPlugins), - // TODO: Remove after migration - // @ts-expect-error device, this.flipperServer, ); diff --git a/desktop/flipper-ui-core/src/__tests__/test-utils/createMockFlipperWithPlugin.tsx b/desktop/flipper-ui-core/src/__tests__/test-utils/createMockFlipperWithPlugin.tsx index 975a4189a..1153252cd 100644 --- a/desktop/flipper-ui-core/src/__tests__/test-utils/createMockFlipperWithPlugin.tsx +++ b/desktop/flipper-ui-core/src/__tests__/test-utils/createMockFlipperWithPlugin.tsx @@ -21,7 +21,7 @@ import { selectDevice, selectClient, } from '../../reducers/connections'; -import BaseDevice from '../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {Store} from '../../reducers/index'; import Client from '../../Client'; diff --git a/desktop/flipper-ui-core/src/chrome/MetroButton.tsx b/desktop/flipper-ui-core/src/chrome/MetroButton.tsx index c5d376d14..54652960a 100644 --- a/desktop/flipper-ui-core/src/chrome/MetroButton.tsx +++ b/desktop/flipper-ui-core/src/chrome/MetroButton.tsx @@ -13,7 +13,7 @@ import {useStore} from '../utils/useStore'; import {Button as AntButton} from 'antd'; import {MenuOutlined, ReloadOutlined} from '@ant-design/icons'; import {theme} from 'flipper-plugin'; -import BaseDevice from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; export default function MetroButton() { const device = useStore((state) => diff --git a/desktop/flipper-ui-core/src/chrome/VideoRecordingButton.tsx b/desktop/flipper-ui-core/src/chrome/VideoRecordingButton.tsx index 9319a5bad..ea4d3b721 100644 --- a/desktop/flipper-ui-core/src/chrome/VideoRecordingButton.tsx +++ b/desktop/flipper-ui-core/src/chrome/VideoRecordingButton.tsx @@ -8,7 +8,7 @@ */ import React, {Component} from 'react'; -import BaseDevice from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {Button, Glyph, colors} from '../ui'; import {getRenderHostInstance} from '../RenderHost'; import {path} from 'flipper-plugin'; diff --git a/desktop/flipper-ui-core/src/deeplink.tsx b/desktop/flipper-ui-core/src/deeplink.tsx index 67d273947..cbe88eedd 100644 --- a/desktop/flipper-ui-core/src/deeplink.tsx +++ b/desktop/flipper-ui-core/src/deeplink.tsx @@ -101,16 +101,12 @@ export async function handleDeeplink( const selectedClient = getAllClients(store.getState().connections).find( (c) => c.query.app === match[0] && - // TODO: Remove at the end of migration - // @ts-expect-error (selectedDevice == null || c.device === selectedDevice), ); store.dispatch( selectPlugin({ selectedAppId: selectedClient?.id, - // TODO: Remove at the end of migration - // @ts-expect-error selectedDevice: selectedClient ? selectedClient.device : selectedDevice, selectedPlugin: match[1], deepLinkPayload, diff --git a/desktop/flipper-ui-core/src/deprecated-exports.tsx b/desktop/flipper-ui-core/src/deprecated-exports.tsx index 45b089709..279ee70f9 100644 --- a/desktop/flipper-ui-core/src/deprecated-exports.tsx +++ b/desktop/flipper-ui-core/src/deprecated-exports.tsx @@ -31,10 +31,10 @@ export {getPluginKey} from './utils/pluginKey'; export {Notification, Idler} from 'flipper-plugin'; export {IdlerImpl} from './utils/Idler'; export {Store, State as ReduxState} from './reducers/index'; -export {default as BaseDevice} from './devices/BaseDevice'; +export {BaseDevice} from 'flipper-frontend-core'; export {default as isProduction} from './utils/isProduction'; export {DetailSidebar} from 'flipper-plugin'; -export {default as Device} from './devices/BaseDevice'; +export {BaseDevice as Device} from 'flipper-frontend-core'; export {default as ArchivedDevice} from './devices/ArchivedDevice'; export {DeviceOS as OS} from 'flipper-plugin'; export {default as Button} from './ui/components/Button'; diff --git a/desktop/flipper-ui-core/src/devices/ArchivedDevice.tsx b/desktop/flipper-ui-core/src/devices/ArchivedDevice.tsx index 821d9973d..023900424 100644 --- a/desktop/flipper-ui-core/src/devices/ArchivedDevice.tsx +++ b/desktop/flipper-ui-core/src/devices/ArchivedDevice.tsx @@ -7,7 +7,7 @@ * @format */ -import BaseDevice from './BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import type {DeviceOS, DeviceType} from 'flipper-plugin'; export default class ArchivedDevice extends BaseDevice { diff --git a/desktop/flipper-ui-core/src/devices/BaseDevice.tsx b/desktop/flipper-ui-core/src/devices/BaseDevice.tsx deleted file mode 100644 index a393c16a2..000000000 --- a/desktop/flipper-ui-core/src/devices/BaseDevice.tsx +++ /dev/null @@ -1,378 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - */ - -import { - Device, - _SandyDevicePluginInstance, - _SandyPluginDefinition, - DeviceLogListener, - Idler, - createState, - getFlipperLib, - CrashLogListener, -} from 'flipper-plugin'; -import { - DeviceLogEntry, - DeviceOS, - DeviceType, - DeviceDescription, - FlipperServer, - CrashLog, - ServerAddOnControls, -} from 'flipper-common'; -import {DeviceSpec, PluginDetails} from 'flipper-common'; -import {getPluginKey} from '../utils/pluginKey'; -import {Base64} from 'js-base64'; -import {createServerAddOnControls} from '../utils/createServerAddOnControls'; - -type PluginDefinition = _SandyPluginDefinition; -type PluginMap = Map; - -export type DeviceExport = { - os: DeviceOS; - title: string; - deviceType: DeviceType; - serial: string; - pluginStates: Record; -}; - -export default class BaseDevice implements Device { - description: DeviceDescription; - flipperServer: FlipperServer; - isArchived = false; - hasDevicePlugins = false; // true if there are device plugins for this device (not necessarily enabled) - private readonly serverAddOnControls: ServerAddOnControls; - - constructor(flipperServer: FlipperServer, description: DeviceDescription) { - this.flipperServer = flipperServer; - this.description = description; - this.serverAddOnControls = createServerAddOnControls(this.flipperServer); - } - - get isConnected(): boolean { - return this.connected.get(); - } - - // operating system of this device - get os() { - return this.description.os; - } - - // human readable name for this device - get title(): string { - return this.description.title; - } - - // type of this device - get deviceType() { - return this.description.deviceType; - } - - // serial number for this device - get serial() { - return this.description.serial; - } - - // additional device specs used for plugin compatibility checks - get specs(): DeviceSpec[] { - return this.description.specs ?? []; - } - - // possible src of icon to display next to the device title - get icon() { - return this.description.icon; - } - - logListeners: Map = new Map(); - - crashListeners: Map = new Map(); - - readonly connected = createState(true); - - // if imported, stores the original source location - source = ''; - - // TODO: ideally we don't want BasePlugin to know about the concept of plugins - sandyPluginStates: Map = new Map< - string, - _SandyDevicePluginInstance - >(); - - supportsOS(os: DeviceOS) { - return os.toLowerCase() === this.os.toLowerCase(); - } - - displayTitle(): string { - return this.connected.get() ? this.title : `${this.title} (Offline)`; - } - - async exportState( - idler: Idler, - onStatusMessage: (msg: string) => void, - selectedPlugins: string[], - ): Promise> { - const pluginStates: Record = {}; - - for (const instance of this.sandyPluginStates.values()) { - if ( - selectedPlugins.includes(instance.definition.id) && - instance.isPersistable() - ) { - pluginStates[instance.definition.id] = await instance.exportState( - idler, - onStatusMessage, - ); - } - } - - return pluginStates; - } - - toJSON() { - return { - os: this.os, - title: this.title, - deviceType: this.deviceType, - serial: this.serial, - }; - } - - private deviceLogEventHandler = (payload: { - serial: string; - entry: DeviceLogEntry; - }) => { - if (payload.serial === this.serial && this.logListeners.size > 0) { - this.addLogEntry(payload.entry); - } - }; - - addLogEntry(entry: DeviceLogEntry) { - this.logListeners.forEach((listener) => { - // prevent breaking other listeners, if one listener doesn't work. - try { - listener(entry); - } catch (e) { - console.error(`Log listener exception:`, e); - } - }); - } - - async startLogging() { - this.flipperServer.on('device-log', this.deviceLogEventHandler); - } - - stopLogging() { - this.flipperServer.off('device-log', this.deviceLogEventHandler); - } - - addLogListener(callback: DeviceLogListener): Symbol { - if (this.logListeners.size === 0) { - this.startLogging(); - } - const id = Symbol(); - this.logListeners.set(id, callback); - return id; - } - - removeLogListener(id: Symbol) { - this.logListeners.delete(id); - if (this.logListeners.size === 0) { - this.stopLogging(); - } - } - - private crashLogEventHandler = (payload: { - serial: string; - crash: CrashLog; - }) => { - if (payload.serial === this.serial && this.crashListeners.size > 0) { - this.addCrashEntry(payload.crash); - } - }; - - addCrashEntry(entry: CrashLog) { - this.crashListeners.forEach((listener) => { - // prevent breaking other listeners, if one listener doesn't work. - try { - listener(entry); - } catch (e) { - console.error(`Crash listener exception:`, e); - } - }); - } - - async startCrashWatcher() { - this.flipperServer.on('device-crash', this.crashLogEventHandler); - } - - stopCrashWatcher() { - this.flipperServer.off('device-crash', this.crashLogEventHandler); - } - - addCrashListener(callback: CrashLogListener): Symbol { - if (this.crashListeners.size === 0) { - this.startCrashWatcher(); - } - const id = Symbol(); - this.crashListeners.set(id, callback); - return id; - } - - removeCrashListener(id: Symbol) { - this.crashListeners.delete(id); - if (this.crashListeners.size === 0) { - this.stopCrashWatcher(); - } - } - - async navigateToLocation(location: string) { - return this.flipperServer.exec('device-navigate', this.serial, location); - } - - async screenshot(): Promise { - if (!this.description.features.screenshotAvailable || this.isArchived) { - return; - } - return Base64.toUint8Array( - await this.flipperServer.exec('device-take-screenshot', this.serial), - ); - } - - async startScreenCapture(destination: string): Promise { - return this.flipperServer.exec( - 'device-start-screencapture', - this.serial, - destination, - ); - } - - async stopScreenCapture(): Promise { - return this.flipperServer.exec('device-stop-screencapture', this.serial); - } - - async executeShell(command: string): Promise { - return this.flipperServer.exec('device-shell-exec', this.serial, command); - } - - async sendMetroCommand(command: string): Promise { - return this.flipperServer.exec('metro-command', this.serial, command); - } - - async forwardPort(local: string, remote: string): Promise { - return this.flipperServer.exec( - 'device-forward-port', - this.serial, - local, - remote, - ); - } - - async clearLogs() { - return this.flipperServer.exec('device-clear-logs', this.serial); - } - - supportsPlugin(plugin: PluginDefinition | PluginDetails) { - let pluginDetails: PluginDetails; - if (plugin instanceof _SandyPluginDefinition) { - pluginDetails = plugin.details; - if (!pluginDetails.pluginType && !pluginDetails.supportedDevices) { - // TODO T84453692: this branch is to support plugins defined with the legacy approach. Need to remove this branch after some transition period when - // all the plugins will be migrated to the new approach with static compatibility metadata in package.json. - if (plugin instanceof _SandyPluginDefinition) { - return ( - plugin.isDevicePlugin && - (plugin.asDevicePluginModule().supportsDevice?.(this as any) ?? - false) - ); - } else { - return (plugin as any).supportsDevice(this); - } - } - } else { - pluginDetails = plugin; - } - return ( - pluginDetails.pluginType === 'device' && - (!pluginDetails.supportedDevices || - pluginDetails.supportedDevices?.some( - (d) => - (!d.os || d.os === this.os) && - (!d.type || d.type === this.deviceType) && - (d.archived === undefined || d.archived === this.isArchived) && - (!d.specs || d.specs.every((spec) => this.specs.includes(spec))), - )) - ); - } - - loadDevicePlugins( - devicePlugins: PluginMap, - enabledDevicePlugins: Set, - pluginStates?: Record, - ) { - if (!devicePlugins) { - return; - } - const plugins = Array.from(devicePlugins.values()).filter((p) => - enabledDevicePlugins?.has(p.id), - ); - for (const plugin of plugins) { - this.loadDevicePlugin(plugin, pluginStates?.[plugin.id]); - } - } - - loadDevicePlugin(plugin: PluginDefinition, initialState?: any) { - if (!this.supportsPlugin(plugin)) { - return; - } - this.hasDevicePlugins = true; - if (plugin instanceof _SandyPluginDefinition) { - try { - this.sandyPluginStates.set( - plugin.id, - new _SandyDevicePluginInstance( - this.serverAddOnControls, - getFlipperLib(), - plugin, - this, - // break circular dep, one of those days again... - getPluginKey(undefined, {serial: this.serial}, plugin.id), - initialState, - ), - ); - } catch (e) { - console.error(`Failed to start device plugin '${plugin.id}': `, e); - } - } - } - - unloadDevicePlugin(pluginId: string) { - const instance = this.sandyPluginStates.get(pluginId); - if (instance) { - instance.destroy(); - this.sandyPluginStates.delete(pluginId); - } - } - - disconnect() { - this.logListeners.clear(); - this.stopLogging(); - this.crashListeners.clear(); - this.stopCrashWatcher(); - this.connected.set(false); - } - - destroy() { - this.disconnect(); - this.sandyPluginStates.forEach((instance) => { - instance.destroy(); - }); - this.sandyPluginStates.clear(); - this.serverAddOnControls.unsubscribe(); - } -} diff --git a/desktop/flipper-ui-core/src/devices/TestDevice.tsx b/desktop/flipper-ui-core/src/devices/TestDevice.tsx index 9d6040604..22d9fc4f5 100644 --- a/desktop/flipper-ui-core/src/devices/TestDevice.tsx +++ b/desktop/flipper-ui-core/src/devices/TestDevice.tsx @@ -9,7 +9,7 @@ import {DeviceOS, DeviceType} from 'flipper-plugin'; import {DeviceSpec} from 'flipper-common'; -import BaseDevice from './BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {getRenderHostInstance} from '../RenderHost'; export class TestDevice extends BaseDevice { diff --git a/desktop/flipper-ui-core/src/dispatcher/__tests__/pluginManager.node.tsx b/desktop/flipper-ui-core/src/dispatcher/__tests__/pluginManager.node.tsx index 2586b32f5..19e6c223a 100644 --- a/desktop/flipper-ui-core/src/dispatcher/__tests__/pluginManager.node.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/__tests__/pluginManager.node.tsx @@ -21,7 +21,7 @@ import {_SandyPluginDefinition as SandyPluginDefinition} from 'flipper-plugin'; import MockFlipper from '../../__tests__/test-utils/MockFlipper'; import Client from '../../Client'; import React from 'react'; -import BaseDevice from '../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {awaitPluginCommandQueueEmpty} from '../pluginManager'; const pluginDetails1 = TestUtils.createMockPluginDetails({ diff --git a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx index c0d6ea8c3..a047f115c 100644 --- a/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/flipperServer.tsx @@ -19,7 +19,7 @@ import { } from 'flipper-common'; import Client from '../Client'; import {notification} from 'antd'; -import BaseDevice from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {ClientDescription, timeout} from 'flipper-common'; import {reportPlatformFailures} from 'flipper-common'; import {sideEffect} from '../utils/sideEffect'; @@ -300,8 +300,6 @@ export async function handleClientConnected( logger, store, undefined, - // TODO: Remove at the end of migration - // @ts-expect-error device, server, ); diff --git a/desktop/flipper-ui-core/src/dispatcher/handleOpenPluginDeeplink.tsx b/desktop/flipper-ui-core/src/dispatcher/handleOpenPluginDeeplink.tsx index 63d1d3804..df76e64dd 100644 --- a/desktop/flipper-ui-core/src/dispatcher/handleOpenPluginDeeplink.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/handleOpenPluginDeeplink.tsx @@ -27,7 +27,7 @@ import {loadPluginsFromMarketplace} from './pluginMarketplace'; import {loadPlugin, switchPlugin} from '../reducers/pluginManager'; import {startPluginDownload} from '../reducers/pluginDownloads'; import isProduction from '../utils/isProduction'; -import BaseDevice from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import Client from '../Client'; import {RocketOutlined} from '@ant-design/icons'; import {showEmulatorLauncher} from '../sandy-chrome/appinspect/LaunchEmulator'; @@ -122,8 +122,6 @@ export async function handleOpenPluginDeeplink( const client: Client | undefined = isDevicePlugin ? undefined : (deviceOrClient as Client); - // TODO: Remove at the end of migration - // @ts-expect-error const device: BaseDevice = isDevicePlugin ? (deviceOrClient as BaseDevice) : (deviceOrClient as Client).device; @@ -509,8 +507,6 @@ async function selectDevicesAndClient( : c.plugins.has(params.pluginId), ) .filter((c) => c.connected.get()) - // TODO: Remove at the end of migration - // @ts-expect-error .filter((c) => availableDevices.includes(c.device)); if (validClients.length === 1) { diff --git a/desktop/flipper-ui-core/src/dispatcher/tracking.tsx b/desktop/flipper-ui-core/src/dispatcher/tracking.tsx index 917ed618f..b944c6d5a 100644 --- a/desktop/flipper-ui-core/src/dispatcher/tracking.tsx +++ b/desktop/flipper-ui-core/src/dispatcher/tracking.tsx @@ -22,7 +22,7 @@ import { selectionChanged, } from '../reducers/usageTracking'; import produce from 'immer'; -import BaseDevice from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {deconstructClientId} from 'flipper-common'; import {sideEffect} from '../utils/sideEffect'; import {getSelectionInfo} from '../utils/info'; diff --git a/desktop/flipper-ui-core/src/plugin.tsx b/desktop/flipper-ui-core/src/plugin.tsx index d6736ecf1..c13d00e1a 100644 --- a/desktop/flipper-ui-core/src/plugin.tsx +++ b/desktop/flipper-ui-core/src/plugin.tsx @@ -10,7 +10,7 @@ import {Logger, Settings, ActivatablePluginDetails} from 'flipper-common'; import Client from './Client'; import {Component} from 'react'; -import BaseDevice from './devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {StaticView} from './reducers/connections'; import {State as ReduxState} from './reducers'; import {DEFAULT_MAX_QUEUE_SIZE} from './reducers/pluginMessageQueue'; diff --git a/desktop/flipper-ui-core/src/reducers/__tests__/connections.node.tsx b/desktop/flipper-ui-core/src/reducers/__tests__/connections.node.tsx index a56c21d74..abf94e6ca 100644 --- a/desktop/flipper-ui-core/src/reducers/__tests__/connections.node.tsx +++ b/desktop/flipper-ui-core/src/reducers/__tests__/connections.node.tsx @@ -21,7 +21,7 @@ import { } from '../../__tests__/test-utils/createMockFlipperWithPlugin'; import {Store} from '..'; import {getActiveClient, getActiveDevice} from '../../selectors/connections'; -import BaseDevice from '../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import Client from '../../Client'; import { mockConsole, diff --git a/desktop/flipper-ui-core/src/reducers/connections.tsx b/desktop/flipper-ui-core/src/reducers/connections.tsx index 774209064..1b608c945 100644 --- a/desktop/flipper-ui-core/src/reducers/connections.tsx +++ b/desktop/flipper-ui-core/src/reducers/connections.tsx @@ -10,7 +10,7 @@ import {ComponentType} from 'react'; import {produce} from 'immer'; -import type BaseDevice from '../devices/BaseDevice'; +import type {BaseDevice} from 'flipper-frontend-core'; import type Client from '../Client'; import type {UninitializedClient, DeviceOS, Logger} from 'flipper-common'; import type {Actions} from '.'; @@ -243,15 +243,11 @@ export default (state: State = INITAL_STATE, action: Actions): State => { selectedAppId = getAllClients(state).find( (c) => - // TODO: Remove after migration - // @ts-expect-error c.device === payload && c.query.app === state.userPreferredApp, )?.id ?? null; // nothing found, try first app if any if (!selectedAppId) { selectedAppId = - // TODO: Remove after migration - // @ts-expect-error getAllClients(state).find((c) => c.device === payload)?.id ?? null; } } @@ -284,11 +280,7 @@ export default (state: State = INITAL_STATE, action: Actions): State => { return { ...state, staticView: null, - // TODO: Remove after migration - // @ts-expect-error selectedDevice: device, - // TODO: Remove after migration - // @ts-expect-error userPreferredDevice: canBeDefaultDevice(device) ? device.title : state.userPreferredDevice, @@ -345,8 +337,6 @@ export default (state: State = INITAL_STATE, action: Actions): State => { return { ...state, selectedAppId: payload, - // TODO: Remove after migration - // @ts-expect-error selectedDevice: client.device, userPreferredDevice: client.device.title, userPreferredApp: client.query.app, diff --git a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppInspect.tsx b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppInspect.tsx index 2ebc1ab94..c7d50f52a 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppInspect.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppInspect.tsx @@ -18,7 +18,7 @@ import ScreenCaptureButtons from '../../chrome/ScreenCaptureButtons'; import MetroButton from '../../chrome/MetroButton'; import {BookmarkSection} from './BookmarkSection'; import Client from '../../Client'; -import BaseDevice from '../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {ExclamationCircleOutlined, FieldTimeOutlined} from '@ant-design/icons'; import {useSelector} from 'react-redux'; import { diff --git a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppSelector.tsx b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppSelector.tsx index 388b9ad79..bf88a6792 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppSelector.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/AppSelector.tsx @@ -25,7 +25,7 @@ import { selectClient, selectDevice, } from '../../reducers/connections'; -import BaseDevice from '../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import Client from '../../Client'; import {State} from '../../reducers'; import {brandColors, brandIcons, colors} from '../../ui/components/colors'; diff --git a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/PluginList.tsx b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/PluginList.tsx index 8d4cb828f..261363772 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/PluginList.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/PluginList.tsx @@ -23,7 +23,7 @@ import {useDispatch, useStore} from '../../utils/useStore'; import {getPluginTitle, getPluginTooltip} from '../../utils/pluginUtils'; import {selectPlugin} from '../../reducers/connections'; import Client from '../../Client'; -import BaseDevice from '../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {DownloadablePluginDetails} from 'flipper-common'; import { DownloadablePluginState, diff --git a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/PluginList.spec.tsx b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/PluginList.spec.tsx index 16a58846e..0c15acfc0 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/PluginList.spec.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/appinspect/__tests__/PluginList.spec.tsx @@ -12,7 +12,7 @@ import { MockFlipperResult, } from '../../../__tests__/test-utils/createMockFlipperWithPlugin'; import {FlipperPlugin} from '../../../plugin'; -import BaseDevice from '../../../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {_SandyPluginDefinition} from 'flipper-plugin'; import {TestUtils} from 'flipper-plugin'; import {selectPlugin} from '../../../reducers/connections'; diff --git a/desktop/flipper-ui-core/src/sandy-chrome/notification/Notification.tsx b/desktop/flipper-ui-core/src/sandy-chrome/notification/Notification.tsx index 03ced0517..3454fc8f1 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/notification/Notification.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/notification/Notification.tsx @@ -311,8 +311,6 @@ export function openNotification(store: Store, noti: PluginNotificationOrig) { selectPlugin({ selectedPlugin: noti.pluginId, selectedAppId: client.id, - // TODO: Will be fixed later in the stack - // @ts-expect-error selectedDevice: client.device, deepLinkPayload: noti.notification.action, }), diff --git a/desktop/flipper-ui-core/src/utils/__tests__/exportData.node.tsx b/desktop/flipper-ui-core/src/utils/__tests__/exportData.node.tsx index d16cbaebd..f5d064113 100644 --- a/desktop/flipper-ui-core/src/utils/__tests__/exportData.node.tsx +++ b/desktop/flipper-ui-core/src/utils/__tests__/exportData.node.tsx @@ -733,8 +733,6 @@ test('test determinePluginsToProcess for mutilple clients having plugins present logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -750,8 +748,6 @@ test('test determinePluginsToProcess for mutilple clients having plugins present logger, mockStore, new Set(['TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -767,8 +763,6 @@ test('test determinePluginsToProcess for mutilple clients having plugins present logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -829,8 +823,6 @@ test('test determinePluginsToProcess for no selected plugin present in any clien logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -846,8 +838,6 @@ test('test determinePluginsToProcess for no selected plugin present in any clien logger, mockStore, new Set(['TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -891,8 +881,6 @@ test('test determinePluginsToProcess for multiple clients on same device', async logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -908,8 +896,6 @@ test('test determinePluginsToProcess for multiple clients on same device', async logger, mockStore, new Set(['TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -958,8 +944,6 @@ test('test determinePluginsToProcess for multiple clients on different device', logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -975,8 +959,6 @@ test('test determinePluginsToProcess for multiple clients on different device', logger, mockStore, new Set(['TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -992,8 +974,6 @@ test('test determinePluginsToProcess for multiple clients on different device', logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -1009,8 +989,6 @@ test('test determinePluginsToProcess for multiple clients on different device', logger, mockStore, new Set(['TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error device1, flipperServer, ); @@ -1083,8 +1061,6 @@ test('test determinePluginsToProcess to ignore archived clients', async () => { logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error archivedDevice, flipperServer, ); @@ -1100,8 +1076,6 @@ test('test determinePluginsToProcess to ignore archived clients', async () => { logger, mockStore, new Set(['TestPlugin', 'TestDevicePlugin']), - // TODO: Remove at the end of migration - // @ts-expect-error archivedDevice, flipperServer, ); diff --git a/desktop/flipper-ui-core/src/utils/clientUtils.tsx b/desktop/flipper-ui-core/src/utils/clientUtils.tsx index b8ff0aec6..ca013e716 100644 --- a/desktop/flipper-ui-core/src/utils/clientUtils.tsx +++ b/desktop/flipper-ui-core/src/utils/clientUtils.tsx @@ -9,7 +9,7 @@ import {deconstructClientId} from 'flipper-common'; import type Client from '../Client'; -import type BaseDevice from '../devices/BaseDevice'; +import type {BaseDevice} from 'flipper-frontend-core'; export function currentActiveApps( clients: Array, diff --git a/desktop/flipper-ui-core/src/utils/createSandyPluginWrapper.tsx b/desktop/flipper-ui-core/src/utils/createSandyPluginWrapper.tsx index b8c10fb36..9647260d5 100644 --- a/desktop/flipper-ui-core/src/utils/createSandyPluginWrapper.tsx +++ b/desktop/flipper-ui-core/src/utils/createSandyPluginWrapper.tsx @@ -28,7 +28,7 @@ import {useStore} from './useStore'; import {setStaticView, StaticView} from '../reducers/connections'; import {getStore} from '../store'; import {setActiveNotifications} from '../reducers/notifications'; -import BaseDevice from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; export type SandyPluginModule = ConstructorParameters< typeof _SandyPluginDefinition diff --git a/desktop/flipper-ui-core/src/utils/exportData.tsx b/desktop/flipper-ui-core/src/utils/exportData.tsx index 31aedb4f3..01f5c657d 100644 --- a/desktop/flipper-ui-core/src/utils/exportData.tsx +++ b/desktop/flipper-ui-core/src/utils/exportData.tsx @@ -10,14 +10,14 @@ import * as React from 'react'; import {getLogger} from 'flipper-common'; import {Store, MiddlewareAPI} from '../reducers'; -import {DeviceExport} from '../devices/BaseDevice'; +import {DeviceExport} from 'flipper-frontend-core'; import {selectedPlugins, State as PluginsState} from '../reducers/plugins'; import {PluginNotification} from '../reducers/notifications'; import Client, {ClientExport} from '../Client'; import {getAppVersion} from './info'; import {pluginKey} from '../utils/pluginKey'; import {DevicePluginMap, ClientPluginMap} from '../plugin'; -import {default as BaseDevice} from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {ArchivedDevice} from 'flipper-frontend-core'; import {v4 as uuidv4} from 'uuid'; import {tryCatchReportPlatformFailures} from 'flipper-common'; @@ -540,14 +540,10 @@ export async function importDataToStore( ); store.dispatch({ type: 'REGISTER_DEVICE', - // TODO: Remove at the end of migration - // @ts-expect-error payload: archivedDevice, }); store.dispatch({ type: 'SELECT_DEVICE', - // TODO: Remove at the end of migration - // @ts-expect-error payload: archivedDevice, }); diff --git a/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx b/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx index c726f96f1..7fa8b3813 100644 --- a/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx +++ b/desktop/flipper-ui-core/src/utils/flipperLibImplementation/index.tsx @@ -21,7 +21,7 @@ import { } from 'flipper-common'; import type {Store} from '../../reducers'; import createPaste from '../../fb-stubs/createPaste'; -import type BaseDevice from '../../devices/BaseDevice'; +import type {BaseDevice} from 'flipper-frontend-core'; import constants from '../../fb-stubs/constants'; import {addNotification} from '../../reducers/notifications'; import {deconstructPluginKey} from 'flipper-common'; diff --git a/desktop/flipper-ui-core/src/utils/pluginUtils.tsx b/desktop/flipper-ui-core/src/utils/pluginUtils.tsx index 1979a1618..1650ad7d1 100644 --- a/desktop/flipper-ui-core/src/utils/pluginUtils.tsx +++ b/desktop/flipper-ui-core/src/utils/pluginUtils.tsx @@ -10,7 +10,7 @@ import type {PluginDefinition} from '../plugin'; import type {State, Store} from '../reducers'; import type {State as PluginsState} from '../reducers/plugins'; -import type BaseDevice from '../devices/BaseDevice'; +import type {BaseDevice} from 'flipper-frontend-core'; import type Client from '../Client'; import type { ActivatablePluginDetails, diff --git a/desktop/flipper-ui-core/src/utils/reduxDevToolsConfig.tsx b/desktop/flipper-ui-core/src/utils/reduxDevToolsConfig.tsx index 5560666a6..d4c81ce02 100644 --- a/desktop/flipper-ui-core/src/utils/reduxDevToolsConfig.tsx +++ b/desktop/flipper-ui-core/src/utils/reduxDevToolsConfig.tsx @@ -8,7 +8,7 @@ */ import {State} from '../reducers/index'; -import {DeviceExport} from '../devices/BaseDevice'; +import {DeviceExport} from 'flipper-frontend-core'; export const stateSanitizer = (state: State) => { if (state.connections && state.connections.devices) { diff --git a/desktop/flipper-ui-core/src/utils/screenshot.tsx b/desktop/flipper-ui-core/src/utils/screenshot.tsx index a44d7d9ba..0b9bb1ed9 100644 --- a/desktop/flipper-ui-core/src/utils/screenshot.tsx +++ b/desktop/flipper-ui-core/src/utils/screenshot.tsx @@ -7,7 +7,7 @@ * @format */ -import BaseDevice from '../devices/BaseDevice'; +import {BaseDevice} from 'flipper-frontend-core'; import {reportPlatformFailures} from 'flipper-common'; import {getRenderHostInstance} from '../RenderHost'; import {getFlipperLib, path} from 'flipper-plugin'; diff --git a/desktop/plugins/public/layout/index.tsx b/desktop/plugins/public/layout/index.tsx index 703c6f9b4..a76cef0ab 100644 --- a/desktop/plugins/public/layout/index.tsx +++ b/desktop/plugins/public/layout/index.tsx @@ -258,7 +258,6 @@ export default class LayoutPlugin extends FlipperPlugin< if (this.props.isArchivedDevice) { Promise.resolve(this.device) .then((d) => { - // @ts-expect-error const handle = (d as ArchivedDevice).getArchivedScreenshotHandle(); if (!handle) { throw new Error('No screenshot attached.');