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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ef5fa275a3
commit
fd380a4c1e
@@ -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';
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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) =>
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<string, PluginDefinition>;
|
||||
|
||||
export type DeviceExport = {
|
||||
os: DeviceOS;
|
||||
title: string;
|
||||
deviceType: DeviceType;
|
||||
serial: string;
|
||||
pluginStates: Record<string, any>;
|
||||
};
|
||||
|
||||
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<Symbol, DeviceLogListener> = new Map();
|
||||
|
||||
crashListeners: Map<Symbol, CrashLogListener> = 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<string, _SandyDevicePluginInstance> = 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<Record<string, any>> {
|
||||
const pluginStates: Record<string, any> = {};
|
||||
|
||||
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<Uint8Array | undefined> {
|
||||
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<void> {
|
||||
return this.flipperServer.exec(
|
||||
'device-start-screencapture',
|
||||
this.serial,
|
||||
destination,
|
||||
);
|
||||
}
|
||||
|
||||
async stopScreenCapture(): Promise<string | null> {
|
||||
return this.flipperServer.exec('device-stop-screencapture', this.serial);
|
||||
}
|
||||
|
||||
async executeShell(command: string): Promise<string> {
|
||||
return this.flipperServer.exec('device-shell-exec', this.serial, command);
|
||||
}
|
||||
|
||||
async sendMetroCommand(command: string): Promise<void> {
|
||||
return this.flipperServer.exec('metro-command', this.serial, command);
|
||||
}
|
||||
|
||||
async forwardPort(local: string, remote: string): Promise<boolean> {
|
||||
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<string>,
|
||||
pluginStates?: Record<string, any>,
|
||||
) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -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<Client>,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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.');
|
||||
|
||||
Reference in New Issue
Block a user