Skip to content

Commit

Permalink
Merge branch 'main' into android-publish-task
Browse files Browse the repository at this point in the history
  • Loading branch information
passy authored Sep 27, 2021
2 parents 4ce16a3 + b539f4d commit 1be9e63
Show file tree
Hide file tree
Showing 34 changed files with 299 additions and 174 deletions.
2 changes: 1 addition & 1 deletion Flipper.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

flipperkit_version = '0.108.0'
flipperkit_version = '0.111.0'
Pod::Spec.new do |spec|
spec.name = 'Flipper'
spec.version = flipperkit_version
Expand Down
2 changes: 1 addition & 1 deletion FlipperKit.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

folly_compiler_flags = '-DDEBUG=1 -DFLIPPER_OSS=1 -DFB_SONARKIT_ENABLED=1 -DFOLLY_HAVE_BACKTRACE=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_HAVE_LIBGFLAGS=0 -DFOLLY_HAVE_LIBJEMALLOC=0 -DFOLLY_HAVE_PREADV=0 -DFOLLY_HAVE_PWRITEV=0 -DFOLLY_HAVE_TFO=0 -DFOLLY_USE_SYMBOLIZER=0'
yogakit_version = '~> 1.18'
flipperkit_version = '0.108.0'
flipperkit_version = '0.111.0'
Pod::Spec.new do |spec|
spec.name = 'FlipperKit'
spec.version = flipperkit_version
Expand Down
9 changes: 7 additions & 2 deletions desktop/app/src/__tests__/disconnect.node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
createState,
DevicePluginClient,
PluginClient,
sleep,
} from 'flipper-plugin';
import {handleClientConnected} from '../dispatcher/flipperServer';
import {TestDevice} from '../test-utils/TestDevice';
Expand Down Expand Up @@ -106,6 +105,13 @@ test('New device with same serial removes & cleans the old one', async () => {
'MockAndroidDevice',
'Android',
);
expect(() => {
store.dispatch({
type: 'REGISTER_DEVICE',
payload: device2,
});
}).toThrow('still connected');
device.destroy();
store.dispatch({
type: 'REGISTER_DEVICE',
payload: device2,
Expand All @@ -115,7 +121,6 @@ test('New device with same serial removes & cleans the old one', async () => {
store.getState().connections.enabledDevicePlugins,
);

await sleep(100);
expect(device.isArchived).toBe(false);
expect(device.connected.get()).toBe(false);
expect(instance.instanceApi.destroy).toBeCalledTimes(1);
Expand Down
14 changes: 14 additions & 0 deletions desktop/app/src/devices/ArchivedDevice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,18 @@ export default class ArchivedDevice extends BaseDevice {
getArchivedScreenshotHandle(): string | null {
return this.archivedScreenshotHandle;
}

/**
* @override
*/
async startLogging() {
// No-op
}

/**
* @override
*/
async stopLogging() {
// No-op
}
}
15 changes: 15 additions & 0 deletions desktop/app/src/dispatcher/flipperServer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ export default async (store: Store, logger: Logger) => {
serial: deviceInfo.serial,
});

const existing = store
.getState()
.connections.devices.find(
(device) => device.serial === deviceInfo.serial,
);
// handled outside reducer, as it might emit new redux actions...
if (existing) {
if (existing.connected.get()) {
console.warn(
`Tried to replace still connected device '${existing.serial}' with a new instance.`,
);
}
existing.destroy();
}

const device = new BaseDevice(server, deviceInfo);
device.loadDevicePlugins(
store.getState().plugins.devicePlugins,
Expand Down
14 changes: 7 additions & 7 deletions desktop/app/src/reducers/__tests__/connections.node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ afterEach(() => {
_setFlipperLibImplementation(undefined);
});

test('doing a double REGISTER_DEVICE keeps the last', () => {
test('doing a double REGISTER_DEVICE fails', () => {
const device1 = new TestDevice('serial', 'physical', 'title', 'Android');
const device2 = new TestDevice('serial', 'physical', 'title2', 'Android');
const initialState: State = reducer(undefined, {
Expand All @@ -31,12 +31,12 @@ test('doing a double REGISTER_DEVICE keeps the last', () => {
expect(initialState.devices.length).toBe(1);
expect(initialState.devices[0]).toBe(device1);

const endState = reducer(initialState, {
type: 'REGISTER_DEVICE',
payload: device2,
});
expect(endState.devices.length).toBe(1);
expect(endState.devices[0]).toBe(device2);
expect(() => {
reducer(initialState, {
type: 'REGISTER_DEVICE',
payload: device2,
});
}).toThrow('still connected');
});

test('register, remove, re-register a metro device works correctly', () => {
Expand Down
7 changes: 1 addition & 6 deletions desktop/app/src/reducers/connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,8 @@ export default (state: State = INITAL_STATE, action: Actions): State => {
if (existing !== -1) {
const d = newDevices[existing];
if (d.connected.get()) {
console.warn(
`Tried to replace still connected device '${d.serial}' with a new instance`,
);
throw new Error(`Cannot register, '${d.serial}' is still connected`);
}
setImmediate(() => {
d.destroy();
});
newDevices[existing] = payload;
} else {
newDevices.push(payload);
Expand Down
9 changes: 4 additions & 5 deletions desktop/app/src/utils/__tests__/exportData.node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
PluginClient,
DevicePluginClient,
sleep,
Device,
} from 'flipper-plugin';
import {selectPlugin} from '../../reducers/connections';
import {TestIdler} from '../Idler';
Expand Down Expand Up @@ -71,7 +72,7 @@ function generateNotifications(
return {id, title, message, severity};
}

function generateClientIdentifier(device: TestDevice, app: string): string {
function generateClientIdentifier(device: Device, app: string): string {
const {os, deviceType, serial} = device;
const identifier = `${app}#${os}#${deviceType}#${serial}`;
return identifier;
Expand All @@ -97,10 +98,8 @@ function generateClientFromClientWithSalt(
query: {app, os, device, device_id: salt + '-' + device_id},
};
}
function generateClientFromDevice(
device: TestDevice,
app: string,
): ClientExport {

function generateClientFromDevice(device: Device, app: string): ClientExport {
const {os, deviceType, serial} = device;
const identifier = generateClientIdentifier(device, app);
return {
Expand Down
2 changes: 1 addition & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
"tsc-plugins": "./ts-node scripts/tsc-plugins.ts",
"watch": "cross-env TZ=Pacific/Pohnpei node --expose-gc --stack-trace-limit=40 ./node_modules/.bin/jest --watch"
},
"version": "0.111.0",
"version": "0.112.0",
"workspaces": {
"packages": [
"app",
Expand Down
2 changes: 1 addition & 1 deletion desktop/plugins/public/layout/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ gradle configuration:

```groovy
dependencies {
debugImplementation 'com.facebook.flipper:flipper-litho-plugin:0.111.0'
debugImplementation 'com.facebook.flipper:flipper-litho-plugin:0.112.0'
debugImplementation 'com.facebook.litho:litho-annotations:0.19.0'
// ...
}
Expand Down
2 changes: 1 addition & 1 deletion desktop/plugins/public/leak_canary/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Ensure that you already have an explicit dependency in your application's

```groovy
dependencies {
debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.111.0'
debugImplementation 'com.facebook.flipper:flipper-leakcanary2-plugin:0.112.0'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
}
```
Expand Down
2 changes: 1 addition & 1 deletion desktop/plugins/public/network/docs/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The network plugin is shipped as a separate Maven artifact:

```groovy
dependencies {
debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.111.0'
debugImplementation 'com.facebook.flipper:flipper-network-plugin:0.112.0'
}
```

Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started/android-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ repositories {
}
dependencies {
debugImplementation 'com.facebook.flipper:flipper:0.111.0'
debugImplementation 'com.facebook.flipper:flipper:0.112.0'
debugImplementation 'com.facebook.soloader:soloader:0.10.1'
releaseImplementation 'com.facebook.flipper:flipper-noop:0.111.0'
releaseImplementation 'com.facebook.flipper:flipper-noop:0.112.0'
}
```

Expand Down Expand Up @@ -101,10 +101,10 @@ repositories {
}
dependencies {
debugImplementation 'com.facebook.flipper:flipper:0.111.1-SNAPSHOT'
debugImplementation 'com.facebook.flipper:flipper:0.112.1-SNAPSHOT'
debugImplementation 'com.facebook.soloader:soloader:0.10.1'
releaseImplementation 'com.facebook.flipper:flipper-noop:0.111.1-SNAPSHOT'
releaseImplementation 'com.facebook.flipper:flipper-noop:0.112.1-SNAPSHOT'
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/ios-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The following configuration assumed CocoaPods 1.9+.

```ruby
project 'MyApp.xcodeproj'
flipperkit_version = '0.108.0'
flipperkit_version = '0.111.0'

target 'MyApp' do
platform :ios, '10.0'
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/react-native-ios.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ In 0.62, the setup includes a bit more code (which was moved to a helper in 0.63
platform :ios, '9.0'

def flipper_pods()
flipperkit_version = '0.111.0' # should match the version of your Flipper client app
flipperkit_version = '0.112.0' # should match the version of your Flipper client app
pod 'FlipperKit', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/FlipperKitLayoutPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version, :configuration => 'Debug'
Expand Down
4 changes: 2 additions & 2 deletions docs/getting-started/react-native.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ By default React Native might ship with an outdated Flipper SDK. To make sure yo

Android:

1. Bump the `FLIPPER_VERSION` variable in `android/gradle.properties`, for example: `FLIPPER_VERSION=0.111.0`.
1. Bump the `FLIPPER_VERSION` variable in `android/gradle.properties`, for example: `FLIPPER_VERSION=0.112.0`.
2. Run `./gradlew clean` in the `android` directory.

iOS:

1. Call `use_flipper` with a specific version in `ios/Podfile`, for example: `use_flipper!({ 'Flipper' => '0.111.0' })`.
1. Call `use_flipper` with a specific version in `ios/Podfile`, for example: `use_flipper!({ 'Flipper' => '0.112.0' })`.
2. Run `pod install` in the `ios` directory.

## Manual Setup
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# LICENSE file in the root directory of this source tree.

# POM publishing constants
VERSION_NAME=0.111.1-SNAPSHOT
VERSION_NAME=0.112.1-SNAPSHOT
GROUP=com.facebook.flipper
SONATYPE_STAGING_PROFILE=comfacebook
POM_URL=https://github.com/facebook/flipper
Expand Down
4 changes: 2 additions & 2 deletions iOS/FlipperKit/FlipperClient.mm
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ - (instancetype)init {
_cppClient = facebook::flipper::FlipperClient::instance();

// To switch to a websocket provider, uncomment the line below.
// facebook::flipper::FlipperSocketProvider::setDefaultProvider(
// std::make_unique<facebook::flipper::FlipperWebSocketProvider>());
facebook::flipper::FlipperSocketProvider::setDefaultProvider(
std::make_unique<facebook::flipper::FlipperWebSocketProvider>());

} catch (const std::system_error& e) {
// Probably ran out of disk space.
Expand Down
11 changes: 10 additions & 1 deletion iOS/FlipperKit/FlipperPlatformWebSocket.mm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,16 @@ - (void)webSocketDidOpen:(SRWebSocket*)webSocket {
}

- (void)webSocket:(SRWebSocket*)webSocket didFailWithError:(NSError*)error {
_eventHandler(facebook::flipper::SocketEvent::ERROR);
/** Check for the error domain and code. Need to filter out SSL handshake
errors and dispatch them accordingly. CFNetwork SSLHandshake failed:
- Domain: NSOSStatusErrorDomain
- Code: -9806
*/
if ([[error domain] isEqual:NSOSStatusErrorDomain] && [error code] == -9806) {
_eventHandler(facebook::flipper::SocketEvent::SSL_ERROR);
} else {
_eventHandler(facebook::flipper::SocketEvent::ERROR);
}
_socket = nil;
}

Expand Down
11 changes: 11 additions & 0 deletions iOS/FlipperKit/FlipperWebSocket.mm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ void put(std::string key, int value) override {
fullfilled = true;
if (event == SocketEvent::OPEN) {
promise.set_value(true);
} else if (event == SocketEvent::SSL_ERROR) {
try {
promise.set_exception(
std::make_exception_ptr(folly::AsyncSocketException(
folly::AsyncSocketException::SSL_ERROR,
"SSL handshake failed")));
} catch (...) {
// set_exception() may throw an exception
// In that case, just set the value to false.
promise.set_value(false);
}
} else {
promise.set_value(false);
}
Expand Down
Loading

0 comments on commit 1be9e63

Please sign in to comment.