Move Metro control buttons to titlebar
Summary: The Metro control buttons are now in the titlebar. This has a few benefits: - the buttons are accessible if you are inspecting other metro plugins - the buttons are even usuable if you selected an app on the actual device. This should help with reducing the cognitive dissonance of having apps both as 'android' app and metro device - killed the Metro plugin again :) Reviewed By: nikoant Differential Revision: D19789455 fbshipit-source-id: 476fd0af1d3fc7b51a33f1af6d3fc3578aeeefae
This commit is contained in:
committed by
Facebook Github Bot
parent
182b2a629d
commit
3dcfe9f3ae
@@ -1,171 +0,0 @@
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
FlipperDevicePlugin,
|
||||
Device,
|
||||
View,
|
||||
Button,
|
||||
Toolbar,
|
||||
ButtonGroup,
|
||||
MetroDevice,
|
||||
} from 'flipper';
|
||||
|
||||
type LogEntry = {};
|
||||
|
||||
export type PersistedState = {
|
||||
logs: LogEntry[];
|
||||
};
|
||||
|
||||
type State = {};
|
||||
|
||||
/*
|
||||
Flow types for events
|
||||
|
||||
/
|
||||
A tagged union of all the actions that may happen and we may want to
|
||||
report to the tool user.
|
||||
/
|
||||
export type ReportableEvent =
|
||||
| {
|
||||
port: number,
|
||||
projectRoots: $ReadOnlyArray<string>,
|
||||
type: 'initialize_started',
|
||||
...
|
||||
}
|
||||
| {type: 'initialize_done', ...}
|
||||
| {
|
||||
type: 'initialize_failed',
|
||||
port: number,
|
||||
error: Error,
|
||||
...
|
||||
}
|
||||
| {
|
||||
buildID: string,
|
||||
type: 'bundle_build_done',
|
||||
...
|
||||
}
|
||||
| {
|
||||
buildID: string,
|
||||
type: 'bundle_build_failed',
|
||||
...
|
||||
}
|
||||
| {
|
||||
buildID: string,
|
||||
bundleDetails: BundleDetails,
|
||||
type: 'bundle_build_started',
|
||||
...
|
||||
}
|
||||
| {
|
||||
error: Error,
|
||||
type: 'bundling_error',
|
||||
...
|
||||
}
|
||||
| {type: 'dep_graph_loading', ...}
|
||||
| {type: 'dep_graph_loaded', ...}
|
||||
| {
|
||||
buildID: string,
|
||||
type: 'bundle_transform_progressed',
|
||||
transformedFileCount: number,
|
||||
totalFileCount: number,
|
||||
...
|
||||
}
|
||||
| {
|
||||
type: 'global_cache_error',
|
||||
error: Error,
|
||||
...
|
||||
}
|
||||
| {
|
||||
type: 'global_cache_disabled',
|
||||
reason: GlobalCacheDisabledReason,
|
||||
...
|
||||
}
|
||||
| {type: 'transform_cache_reset', ...}
|
||||
| {
|
||||
type: 'worker_stdout_chunk',
|
||||
chunk: string,
|
||||
...
|
||||
}
|
||||
| {
|
||||
type: 'worker_stderr_chunk',
|
||||
chunk: string,
|
||||
...
|
||||
}
|
||||
| {
|
||||
type: 'hmr_client_error',
|
||||
error: Error,
|
||||
...
|
||||
}
|
||||
| {
|
||||
type: 'client_log',
|
||||
level:
|
||||
| 'trace'
|
||||
| 'info'
|
||||
| 'warn'
|
||||
| 'error'
|
||||
| 'log'
|
||||
| 'group'
|
||||
| 'groupCollapsed'
|
||||
| 'groupEnd'
|
||||
| 'debug',
|
||||
data: Array<mixed>,
|
||||
...
|
||||
};
|
||||
*/
|
||||
|
||||
export default class MetroPlugin extends FlipperDevicePlugin<
|
||||
State,
|
||||
any,
|
||||
PersistedState
|
||||
> {
|
||||
static supportsDevice(device: Device) {
|
||||
return device.os === 'Metro';
|
||||
}
|
||||
|
||||
get ws(): WebSocket {
|
||||
return (this.device as MetroDevice).ws;
|
||||
}
|
||||
|
||||
sendCommand(command: string) {
|
||||
if (this.ws) {
|
||||
this.ws.send(
|
||||
JSON.stringify({
|
||||
version: 2,
|
||||
type: 'command',
|
||||
command,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
<Toolbar>
|
||||
<ButtonGroup>
|
||||
Work-in-progress
|
||||
<Button
|
||||
onClick={() => {
|
||||
this.sendCommand('reload');
|
||||
}}>
|
||||
Reload RN
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
this.sendCommand('devMenu');
|
||||
}}>
|
||||
Dev Menu
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
</Toolbar>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "Metro",
|
||||
"version": "0.1.0",
|
||||
"description": "A plugin to manage React Native applications served trough Metro",
|
||||
"main": "index.tsx",
|
||||
"repository": "https://github.com/facebook/flipper",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"flipper-plugin",
|
||||
"react-native",
|
||||
"metro"
|
||||
],
|
||||
"title": "Metro Bundler",
|
||||
"bugs": {
|
||||
"email": "mweststrate@fb.com"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
Reference in New Issue
Block a user