Move settings, launcherSettings, GKs to app / flipper-server-core
Summary: This diff moves a lot of stuff from the client to the server. This diff is fairly large, as a lot of concept closely relate, although some things have split off to the earlier diffs in the stack, or are still to follow (like making intern requests). This diff primarily moves reading and storing settings and GKs from client to server (both flipper and launcher settings). This means that settings are no longer persisted by Redux (which only exists on client). Most other changes are fallout from that. For now settings are just one big object, although we might need to separate settings that are only make sense in an Electron context. For example launcher settings. Reviewed By: passy, aigoncharov Differential Revision: D32498649 fbshipit-source-id: d842faf7a7f03774b621c7656e53a9127afc6192
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eed19b3a3d
commit
bca169df73
@@ -44,3 +44,4 @@ export {
|
||||
export * from './user-session';
|
||||
export * from './GK';
|
||||
export * from './clientUtils';
|
||||
export * from './settings';
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
DeviceType as PluginDeviceType,
|
||||
OS as PluginOS,
|
||||
} from 'flipper-plugin-lib';
|
||||
import {LauncherSettings, ProcessConfig, Settings} from './settings';
|
||||
|
||||
// In the future, this file would deserve it's own package, as it doesn't really relate to plugins.
|
||||
// Since flipper-plugin however is currently shared among server, client and defines a lot of base types, leaving it here for now.
|
||||
@@ -123,6 +124,7 @@ export type IOSDeviceParams = {
|
||||
};
|
||||
|
||||
export type FlipperServerCommands = {
|
||||
'get-config': () => Promise<FlipperServerConfig>;
|
||||
'device-start-logging': (serial: string) => Promise<void>;
|
||||
'device-stop-logging': (serial: string) => Promise<void>;
|
||||
'device-supports-screenshot': (serial: string) => Promise<boolean>;
|
||||
@@ -151,10 +153,36 @@ export type FlipperServerCommands = {
|
||||
'android-launch-emulator': (name: string, coldboot: boolean) => Promise<void>;
|
||||
'ios-get-simulators': (bootedOnly: boolean) => Promise<IOSDeviceParams[]>;
|
||||
'ios-launch-simulator': (udid: string) => Promise<void>;
|
||||
'persist-settings': (settings: Settings) => Promise<void>;
|
||||
'persist-launcher-settings': (settings: LauncherSettings) => Promise<void>;
|
||||
};
|
||||
|
||||
type ENVIRONMENT_VARIABLES =
|
||||
| 'NODE_ENV'
|
||||
| 'DEV_SERVER_URL'
|
||||
| 'CONFIG'
|
||||
| 'FLIPPER_ENABLED_PLUGINS';
|
||||
type ENVIRONMENT_PATHS =
|
||||
| 'appPath'
|
||||
| 'homePath'
|
||||
| 'execPath'
|
||||
| 'staticPath'
|
||||
| 'tempPath'
|
||||
| 'desktopPath';
|
||||
|
||||
export type FlipperServerConfig = {
|
||||
isProduction: boolean;
|
||||
gatekeepers: Record<string, boolean>;
|
||||
env: Partial<Record<ENVIRONMENT_VARIABLES, string>>;
|
||||
paths: Record<ENVIRONMENT_PATHS, string>;
|
||||
settings: Settings;
|
||||
launcherSettings: LauncherSettings;
|
||||
processConfig: ProcessConfig;
|
||||
validWebSocketOrigins: string[];
|
||||
};
|
||||
|
||||
export interface FlipperServer {
|
||||
start(): Promise<void>;
|
||||
connect(): Promise<void>;
|
||||
on<Event extends keyof FlipperServerEvents>(
|
||||
event: Event,
|
||||
callback: (payload: FlipperServerEvents[Event]) => void,
|
||||
|
||||
70
desktop/flipper-common/src/settings.tsx
Normal file
70
desktop/flipper-common/src/settings.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
export enum Tristate {
|
||||
True,
|
||||
False,
|
||||
Unset,
|
||||
}
|
||||
|
||||
/** Settings used by both Server and UI.
|
||||
* TODO: some settings might be flipper environment specific,
|
||||
* and should ideally bemoved to local storage, like 'darkMode'
|
||||
*/
|
||||
export type Settings = {
|
||||
androidHome: string;
|
||||
enableAndroid: boolean;
|
||||
enableIOS: boolean;
|
||||
enablePhysicalIOS: boolean;
|
||||
/**
|
||||
* If unset, this will assume the value of the GK setting.
|
||||
* Note that this setting has no effect in the open source version
|
||||
* of Flipper.
|
||||
*/
|
||||
enablePrefetching: Tristate;
|
||||
idbPath: string;
|
||||
reactNative: {
|
||||
shortcuts: {
|
||||
enabled: boolean;
|
||||
reload: string;
|
||||
openDevMenu: string;
|
||||
};
|
||||
};
|
||||
darkMode: 'dark' | 'light' | 'system';
|
||||
showWelcomeAtStartup: boolean;
|
||||
suppressPluginErrors: boolean;
|
||||
};
|
||||
|
||||
export enum ReleaseChannel {
|
||||
DEFAULT = 'default',
|
||||
STABLE = 'stable',
|
||||
INSIDERS = 'insiders',
|
||||
}
|
||||
|
||||
/** Launcher settings only apply to Electron, and aren't managed or relevant for flipper-server-core */
|
||||
export type LauncherSettings = {
|
||||
releaseChannel: ReleaseChannel;
|
||||
ignoreLocalPin: boolean;
|
||||
};
|
||||
|
||||
// Settings that primarily only apply to Eelectron atm
|
||||
// TODO: further separte between flipper-ui config and Electron config
|
||||
export type ProcessConfig = {
|
||||
disabledPlugins: Set<string>;
|
||||
lastWindowPosition: {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
} | null;
|
||||
screenCapturePath: string | null;
|
||||
launcherMsg: string | null;
|
||||
// Controls whether to delegate to the launcher if present.
|
||||
launcherEnabled: boolean;
|
||||
};
|
||||
@@ -64,9 +64,6 @@ export function getLogger(): Logger {
|
||||
|
||||
// only for testing
|
||||
export function setLoggerInstance(logger: Logger) {
|
||||
if (!isTest() && instance) {
|
||||
console.warn('Logger was already initialised');
|
||||
}
|
||||
instance = logger;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user