Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from facebook:master #286

Merged
merged 4 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions Libraries/Components/AppleTV/NativeTVNavigationEventEmitter.js

This file was deleted.

Large diffs are not rendered by default.

97 changes: 66 additions & 31 deletions Libraries/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ namespace facebook {
} // namespace react
} // namespace facebook

@protocol NativeAsyncStorageSpec <RCTBridgeModule, RCTTurboModule>
@protocol NativeAsyncLocalStorageSpec <RCTBridgeModule, RCTTurboModule>

- (void)multiGet:(NSArray *)keys
callback:(RCTResponseSenderBlock)callback;
Expand All @@ -442,11 +442,37 @@ namespace facebook {
namespace facebook {
namespace react {
/**
* ObjC++ class for module 'AsyncStorage'
* ObjC++ class for module 'AsyncLocalStorage'
*/
class JSI_EXPORT NativeAsyncStorageSpecJSI : public ObjCTurboModule {
class JSI_EXPORT NativeAsyncLocalStorageSpecJSI : public ObjCTurboModule {
public:
NativeAsyncStorageSpecJSI(const ObjCTurboModule::InitParams &params);
NativeAsyncLocalStorageSpecJSI(const ObjCTurboModule::InitParams &params);
};
} // namespace react
} // namespace facebook

@protocol NativeAsyncSQLiteDBStorageSpec <RCTBridgeModule, RCTTurboModule>

- (void)multiGet:(NSArray *)keys
callback:(RCTResponseSenderBlock)callback;
- (void)multiSet:(NSArray *)kvPairs
callback:(RCTResponseSenderBlock)callback;
- (void)multiMerge:(NSArray *)kvPairs
callback:(RCTResponseSenderBlock)callback;
- (void)multiRemove:(NSArray *)keys
callback:(RCTResponseSenderBlock)callback;
- (void)clear:(RCTResponseSenderBlock)callback;
- (void)getAllKeys:(RCTResponseSenderBlock)callback;

@end
namespace facebook {
namespace react {
/**
* ObjC++ class for module 'AsyncSQLiteDBStorage'
*/
class JSI_EXPORT NativeAsyncSQLiteDBStorageSpecJSI : public ObjCTurboModule {
public:
NativeAsyncSQLiteDBStorageSpecJSI(const ObjCTurboModule::InitParams &params);
};
} // namespace react
} // namespace facebook
Expand Down Expand Up @@ -1314,6 +1340,36 @@ namespace facebook {
} // namespace react
} // namespace facebook

@protocol NativeIntentAndroidSpec <RCTBridgeModule, RCTTurboModule>

- (void)getInitialURL:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)canOpenURL:(NSString *)url
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)openURL:(NSString *)url
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)openSettings:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)sendIntent:(NSString *)action
extras:(NSArray * _Nullable)extras
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;

@end
namespace facebook {
namespace react {
/**
* ObjC++ class for module 'IntentAndroid'
*/
class JSI_EXPORT NativeIntentAndroidSpecJSI : public ObjCTurboModule {
public:
NativeIntentAndroidSpecJSI(const ObjCTurboModule::InitParams &params);
};
} // namespace react
} // namespace facebook

@protocol NativeJSCHeapCaptureSpec <RCTBridgeModule, RCTTurboModule>

- (void)captureComplete:(NSString *)path
Expand Down Expand Up @@ -1417,7 +1473,7 @@ namespace facebook {
} // namespace react
} // namespace facebook

@protocol NativeLinkingSpec <RCTBridgeModule, RCTTurboModule>
@protocol NativeLinkingManagerSpec <RCTBridgeModule, RCTTurboModule>

- (void)getInitialURL:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
Expand All @@ -1429,22 +1485,18 @@ namespace facebook {
reject:(RCTPromiseRejectBlock)reject;
- (void)openSettings:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)sendIntent:(NSString *)action
extras:(NSArray * _Nullable)extras
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject;
- (void)addListener:(NSString *)eventName;
- (void)removeListeners:(double)count;

@end
namespace facebook {
namespace react {
/**
* ObjC++ class for module 'Linking'
* ObjC++ class for module 'LinkingManager'
*/
class JSI_EXPORT NativeLinkingSpecJSI : public ObjCTurboModule {
class JSI_EXPORT NativeLinkingManagerSpecJSI : public ObjCTurboModule {
public:
NativeLinkingSpecJSI(const ObjCTurboModule::InitParams &params);
NativeLinkingManagerSpecJSI(const ObjCTurboModule::InitParams &params);
};
} // namespace react
} // namespace facebook
Expand Down Expand Up @@ -2111,24 +2163,6 @@ namespace facebook {
} // namespace react
} // namespace facebook

@protocol NativeTVNavigationEventEmitterSpec <RCTBridgeModule, RCTTurboModule>

- (void)addListener:(NSString *)eventName;
- (void)removeListeners:(double)count;

@end
namespace facebook {
namespace react {
/**
* ObjC++ class for module 'TVNavigationEventEmitter'
*/
class JSI_EXPORT NativeTVNavigationEventEmitterSpecJSI : public ObjCTurboModule {
public:
NativeTVNavigationEventEmitterSpecJSI(const ObjCTurboModule::InitParams &params);
};
} // namespace react
} // namespace facebook

@protocol NativeTimingSpec <RCTBridgeModule, RCTTurboModule>

- (void)createTimer:(double)callbackID
Expand Down Expand Up @@ -2480,6 +2514,7 @@ inline JS::NativeAppState::Constants::Builder::Builder(Constants i) : _factory(^
}) {}



inline JS::NativeBlobModule::Constants::Builder::Builder(const Input i) : _factory(^{
NSMutableDictionary *d = [NSMutableDictionary new];
auto BLOB_URI_SCHEME = i.BLOB_URI_SCHEME.get();
Expand Down Expand Up @@ -2778,6 +2813,7 @@ inline bool JS::NativeImagePickerIOS::SpecOpenSelectDialogConfig::showVideos() c




inline JS::NativeJSDevSupport::Constants::Builder::Builder(const Input i) : _factory(^{
NSMutableDictionary *d = [NSMutableDictionary new];
auto ERROR_CODE_EXCEPTION = i.ERROR_CODE_EXCEPTION.get();
Expand Down Expand Up @@ -3027,7 +3063,6 @@ inline JS::NativeStatusBarManagerIOS::Constants::Builder::Builder(Constants i) :
return i.unsafeRawValue();
}) {}


inline JS::NativeToastAndroid::Constants::Builder::Builder(const Input i) : _factory(^{
NSMutableDictionary *d = [NSMutableDictionary new];
auto SHORT = i.SHORT.get();
Expand Down
29 changes: 21 additions & 8 deletions Libraries/Linking/Linking.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
import NativeEventEmitter from '../EventEmitter/NativeEventEmitter';
import InteractionManager from '../Interaction/InteractionManager';
import Platform from '../Utilities/Platform';
import NativeLinking from './NativeLinking';
import NativeLinkingManager from './NativeLinkingManager';
import NativeIntentAndroid from './NativeIntentAndroid';
import invariant from 'invariant';

/**
Expand All @@ -24,7 +25,7 @@ import invariant from 'invariant';
*/
class Linking extends NativeEventEmitter {
constructor() {
super(NativeLinking);
super(Platform.OS === 'ios' ? NativeLinkingManager : undefined);
}

/**
Expand Down Expand Up @@ -53,7 +54,11 @@ class Linking extends NativeEventEmitter {
*/
openURL(url: string): Promise<void> {
this._validateURL(url);
return NativeLinking.openURL(url);
if (Platform.OS === 'android') {
return NativeIntentAndroid.openURL(url);
} else {
return NativeLinkingManager.openURL(url);
}
}

/**
Expand All @@ -63,7 +68,11 @@ class Linking extends NativeEventEmitter {
*/
canOpenURL(url: string): Promise<boolean> {
this._validateURL(url);
return NativeLinking.canOpenURL(url);
if (Platform.OS === 'android') {
return NativeIntentAndroid.canOpenURL(url);
} else {
return NativeLinkingManager.canOpenURL(url);
}
}

/**
Expand All @@ -72,7 +81,11 @@ class Linking extends NativeEventEmitter {
* See https://reactnative.dev/docs/linking.html#opensettings
*/
openSettings(): Promise<void> {
return NativeLinking.openSettings();
if (Platform.OS === 'android') {
return NativeIntentAndroid.openSettings();
} else {
return NativeLinkingManager.openSettings();
}
}

/**
Expand All @@ -84,9 +97,9 @@ class Linking extends NativeEventEmitter {
getInitialURL(): Promise<?string> {
return Platform.OS === 'android'
? InteractionManager.runAfterInteractions().then(() =>
NativeLinking.getInitialURL(),
NativeIntentAndroid.getInitialURL(),
)
: NativeLinking.getInitialURL();
: NativeLinkingManager.getInitialURL();
}

/*
Expand All @@ -105,7 +118,7 @@ class Linking extends NativeEventEmitter {
}>,
): Promise<void> {
if (Platform.OS === 'android') {
return NativeLinking.sendIntent(action, extras);
return NativeIntentAndroid.sendIntent(action, extras);
} else {
return new Promise((resolve, reject) => reject(new Error('Unsupported')));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@

import type {TurboModule} from '../TurboModule/RCTExport';
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
import Platform from '../Utilities/Platform';

export interface Spec extends TurboModule {
// Common interface
+getInitialURL: () => Promise<string>;
+canOpenURL: (url: string) => Promise<boolean>;
+openURL: (url: string) => Promise<void>;
+openSettings: () => Promise<void>;

// Android only
+sendIntent: (
action: string,
extras: ?Array<{
Expand All @@ -30,12 +26,6 @@ export interface Spec extends TurboModule {
...
}>,
) => Promise<void>;

// Events
+addListener: (eventName: string) => void;
+removeListeners: (count: number) => void;
}

export default ((Platform.OS === 'android'
? TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid')
: TurboModuleRegistry.getEnforcing<Spec>('LinkingManager')): Spec);
export default (TurboModuleRegistry.getEnforcing<Spec>('IntentAndroid'): Spec);
28 changes: 28 additions & 0 deletions Libraries/Linking/NativeLinkingManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 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.
*
* @flow strict
* @format
*/

'use strict';

import type {TurboModule} from '../TurboModule/RCTExport';
import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
// Common interface
+getInitialURL: () => Promise<string>;
+canOpenURL: (url: string) => Promise<boolean>;
+openURL: (url: string) => Promise<void>;
+openSettings: () => Promise<void>;

// Events
+addListener: (eventName: string) => void;
+removeListeners: (count: number) => void;
}

export default (TurboModuleRegistry.getEnforcing<Spec>('LinkingManager'): Spec);
4 changes: 2 additions & 2 deletions Libraries/LinkingIOS/RCTLinkingManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static void postNotificationWithURL(NSURL *URL, id sender)
userInfo:payload];
}

@interface RCTLinkingManager() <NativeLinkingSpec>
@interface RCTLinkingManager() <NativeLinkingManagerSpec>
@end

@implementation RCTLinkingManager
Expand Down Expand Up @@ -187,7 +187,7 @@ - (void)handleOpenURLNotification:(NSNotification *)notification

- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params
{
return std::make_shared<facebook::react::NativeLinkingSpecJSI>(params);
return std::make_shared<facebook::react::NativeLinkingManagerSpecJSI>(params);
}

@end
Expand Down
5 changes: 3 additions & 2 deletions Libraries/Storage/AsyncStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@

'use strict';

import NativeAsyncStorage from './NativeAsyncStorage';
import NativeAsyncLocalStorage from './NativeAsyncLocalStorage';
import NativeAsyncSQLiteDBStorage from './NativeAsyncSQLiteDBStorage';
import invariant from 'invariant';

// Use SQLite if available, otherwise file storage.
const RCTAsyncStorage = NativeAsyncStorage;
const RCTAsyncStorage = NativeAsyncSQLiteDBStorage || NativeAsyncLocalStorage;

/**
* `AsyncStorage` is a simple, unencrypted, asynchronous, persistent, key-value
Expand Down
Loading