Skip to content

Commit

Permalink
Merge branch 'master' into ScrollView-automaticallyAdjustsScrollIndic…
Browse files Browse the repository at this point in the history
…atorInsets
  • Loading branch information
Luna authored May 10, 2021
2 parents 819c91e + d87542e commit 7478a04
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 108 deletions.
2 changes: 0 additions & 2 deletions Libraries/Animated/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,4 @@ module.exports = {
* Expose Event class, so it can be used as a type for type checkers.
*/
Event: AnimatedEvent,

__PropsOnlyForTests: AnimatedProps,
};
1 change: 0 additions & 1 deletion Libraries/Animated/AnimatedMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,4 @@ module.exports = {
forkEvent: AnimatedImplementation.forkEvent,
unforkEvent: AnimatedImplementation.unforkEvent,
Event: AnimatedEvent,
__PropsOnlyForTests: AnimatedProps,
};
8 changes: 5 additions & 3 deletions Libraries/Animated/__tests__/Animated-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @emails oncall+react_native
*/

import AnimatedProps from '../nodes/AnimatedProps';
import TestRenderer from 'react-test-renderer';
import * as React from 'react';

Expand All @@ -21,6 +22,7 @@ jest.mock('../../BatchedBridge/NativeModules', () => ({
}));

let Animated = require('../Animated');

describe('Animated tests', () => {
beforeEach(() => {
jest.resetModules();
Expand All @@ -32,7 +34,7 @@ describe('Animated tests', () => {

const callback = jest.fn();

const node = new Animated.__PropsOnlyForTests(
const node = new AnimatedProps(
{
style: {
backgroundColor: 'red',
Expand Down Expand Up @@ -786,7 +788,7 @@ describe('Animated tests', () => {

const callback = jest.fn();

const node = new Animated.__PropsOnlyForTests(
const node = new AnimatedProps(
{
style: {
opacity: vec.x.interpolate({
Expand Down Expand Up @@ -890,7 +892,7 @@ describe('Animated tests', () => {
const value3 = new Animated.Value(0);
const value4 = Animated.add(value3, Animated.multiply(value1, value2));
const callback = jest.fn();
const view = new Animated.__PropsOnlyForTests(
const view = new AnimatedProps(
{
style: {
transform: [
Expand Down
6 changes: 6 additions & 0 deletions Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const Text: React.AbstractComponent<
ellipsizeMode,
onLongPress,
onPress,
onPressIn,
onPressOut,
onResponderGrant,
onResponderMove,
onResponderRelease,
Expand Down Expand Up @@ -64,9 +66,11 @@ const Text: React.AbstractComponent<
onPress,
onPressIn(event) {
setHighlighted(!suppressHighlighting);
onPressIn?.(event);
},
onPressOut(event) {
setHighlighted(false);
onPressOut?.(event);
},
onResponderTerminationRequest_DEPRECATED: onResponderTerminationRequest,
onStartShouldSetResponder_DEPRECATED: onStartShouldSetResponder,
Expand All @@ -78,6 +82,8 @@ const Text: React.AbstractComponent<
pressRetentionOffset,
onLongPress,
onPress,
onPressIn,
onPressOut,
onResponderTerminationRequest,
onStartShouldSetResponder,
suppressHighlighting,
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Text/TextProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export type TextProps = $ReadOnly<{|
* See https://reactnative.dev/docs/text.html#onpress
*/
onPress?: ?(event: PressEvent) => mixed,
onPressIn?: ?(event: PressEvent) => mixed,
onPressOut?: ?(event: PressEvent) => mixed,
onResponderGrant?: ?(event: PressEvent) => void,
onResponderMove?: ?(event: PressEvent) => void,
onResponderRelease?: ?(event: PressEvent) => void,
Expand Down
8 changes: 7 additions & 1 deletion Libraries/Utilities/PerformanceLoggerContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

import * as React from 'react';
import {useContext} from 'react';
import GlobalPerformanceLogger from './GlobalPerformanceLogger';
import type {IPerformanceLogger} from './createPerformanceLogger';

Expand All @@ -24,4 +25,9 @@ const PerformanceLoggerContext: React.Context<IPerformanceLogger> = React.create
if (__DEV__) {
PerformanceLoggerContext.displayName = 'PerformanceLoggerContext';
}
module.exports = PerformanceLoggerContext;

export function usePerformanceLogger(): IPerformanceLogger {
return useContext(PerformanceLoggerContext);
}

export default PerformanceLoggerContext;
6 changes: 3 additions & 3 deletions React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ RCT_EXTERN void RCTEnableTurboModuleEagerInit(BOOL enabled);
RCT_EXTERN BOOL RCTTurboModuleSharedMutexInitEnabled(void);
RCT_EXTERN void RCTEnableTurboModuleSharedMutexInit(BOOL enabled);

// Turn on TurboModule shared mutex initialization
RCT_EXTERN BOOL RCTTurboModuleBlockGuardEnabled(void);
RCT_EXTERN void RCTEnableTurboModuleBlockGuard(BOOL enabled);
// Turn on TurboModule block guard for promises.
RCT_EXTERN BOOL RCTTurboModulePromisesBlockGuardEnabled(void);
RCT_EXTERN void RCTEnableTurboModulePromisesBlockGuard(BOOL enabled);

/**
* Async batched bridge used to communicate with the JavaScript application.
Expand Down
10 changes: 5 additions & 5 deletions React/Base/RCTBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ void RCTEnableTurboModuleSharedMutexInit(BOOL enabled)
turboModuleSharedMutexInitEnabled = enabled;
}

static BOOL turboModuleBlockGuardEnabled = NO;
BOOL RCTTurboModuleBlockGuardEnabled(void)
static BOOL turboModulePromisesBlockGuardEnabled = NO;
BOOL RCTTurboModulePromisesBlockGuardEnabled(void)
{
return turboModuleBlockGuardEnabled;
return turboModulePromisesBlockGuardEnabled;
}

void RCTEnableTurboModuleBlockGuard(BOOL enabled)
void RCTEnableTurboModulePromisesBlockGuard(BOOL enabled)
{
turboModuleBlockGuardEnabled = enabled;
turboModulePromisesBlockGuardEnabled = enabled;
}

@interface RCTBridge () <RCTReloadListener>
Expand Down
16 changes: 0 additions & 16 deletions React/Base/RCTBundleHolderModule.h

This file was deleted.

1 change: 0 additions & 1 deletion React/Base/RCTJSInvokerModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@

@optional
@property (nonatomic, copy) void (^invokeJS)(NSString *module, NSString *method, NSArray *args);
@property (nonatomic, copy) void (^invokeJSWithModuleDotMethod)(NSString *moduleDotMethod, NSArray *args);

@end
63 changes: 27 additions & 36 deletions React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#import <FBReactNativeSpec/FBReactNativeSpec.h>
#import <React/RCTBridge+Private.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTBundleHolderModule.h>
#import <React/RCTDevMenu.h>
#import <React/RCTEventDispatcherProtocol.h>
#import <React/RCTLog.h>
Expand Down Expand Up @@ -114,12 +113,7 @@ - (void)_reloadWithDefaults:(NSDictionary *)defaultValues

@end

@interface RCTDevSettings () <
RCTBridgeModule,
RCTInvalidating,
NativeDevSettingsSpec,
RCTBundleHolderModule,
RCTDevSettingsInspectable> {
@interface RCTDevSettings () <RCTBridgeModule, RCTInvalidating, NativeDevSettingsSpec, RCTDevSettingsInspectable> {
BOOL _isJSLoaded;
#if ENABLE_PACKAGER_CONNECTION
RCTHandlerToken _reloadToken;
Expand All @@ -133,8 +127,8 @@ @interface RCTDevSettings () <

@implementation RCTDevSettings

@synthesize bundleURL = _bundleURL;
@synthesize isInspectable = _isInspectable;
@synthesize bundleManager = _bundleManager;

RCT_EXPORT_MODULE()

Expand Down Expand Up @@ -172,16 +166,32 @@ - (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource
return self;
}

#if RCT_ENABLE_INSPECTOR
// In bridgeless mode, `setBridge` is not called, so dev server connection
// must be kicked off here.
- (void)setBundleURL:(NSURL *)bundleURL
- (void)setBundleManager:(RCTBundleManager *)bundleManager
{
_bundleURL = bundleURL;
[RCTInspectorDevServerHelper connectWithBundleURL:_bundleURL];
}
_bundleManager = bundleManager;

#if RCT_ENABLE_INSPECTOR
if (self.bridge) {
// We need this dispatch to the main thread because the bridge is not yet
// finished with its initialisation. By the time it relinquishes control of
// the main thread, this operation can be performed.
dispatch_async(dispatch_get_main_queue(), ^{
[self.bridge
dispatchBlock:^{
[RCTInspectorDevServerHelper connectWithBundleURL:bundleManager.bundleURL];
}
queue:RCTJSThread];
});
} else {
[RCTInspectorDevServerHelper connectWithBundleURL:bundleManager.bundleURL];
}
#endif

dispatch_async(dispatch_get_main_queue(), ^{
[self _synchronizeAllSettings];
});
}

- (void)setBridge:(RCTBridge *)bridge
{
[super setBridge:bridge];
Expand All @@ -198,23 +208,6 @@ - (void)setBridge:(RCTBridge *)bridge
queue:dispatch_get_main_queue()
forMethod:@"reload"];
#endif

#if RCT_ENABLE_INSPECTOR
// We need this dispatch to the main thread because the bridge is not yet
// finished with its initialisation. By the time it relinquishes control of
// the main thread, this operation can be performed.
dispatch_async(dispatch_get_main_queue(), ^{
[bridge
dispatchBlock:^{
[RCTInspectorDevServerHelper connectWithBundleURL:bridge.bundleURL];
}
queue:RCTJSThread];
});
#endif

dispatch_async(dispatch_get_main_queue(), ^{
[self _synchronizeAllSettings];
});
}

- (dispatch_queue_t)methodQueue
Expand Down Expand Up @@ -269,10 +262,8 @@ - (BOOL)isRemoteDebuggingAvailable

- (BOOL)isHotLoadingAvailable
{
if (self.bridge.bundleURL) {
return !self.bridge.bundleURL.fileURL; // Only works when running from server
} else if (self.bundleURL) {
return !self.bundleURL.fileURL;
if (self.bundleManager.bundleURL) {
return !self.bundleManager.bundleURL.fileURL;
}
return NO;
}
Expand Down
9 changes: 6 additions & 3 deletions React/CoreModules/RCTEventDispatcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ @implementation RCTEventDispatcher {
@synthesize bridge = _bridge;
@synthesize dispatchToJSThread = _dispatchToJSThread;
@synthesize invokeJS = _invokeJS;
@synthesize invokeJSWithModuleDotMethod = _invokeJSWithModuleDotMethod;

RCT_EXPORT_MODULE()

Expand Down Expand Up @@ -198,8 +197,12 @@ - (void)dispatchEvent:(id<RCTEvent>)event
{
if (_bridge) {
[_bridge enqueueJSCall:[[event class] moduleDotMethod] args:[event arguments]];
} else if (_invokeJSWithModuleDotMethod) {
_invokeJSWithModuleDotMethod([[event class] moduleDotMethod], [event arguments]);
} else if (_invokeJS) {
NSString *moduleDotMethod = [[event class] moduleDotMethod];
NSArray<NSString *> *const components = [moduleDotMethod componentsSeparatedByString:@"."];
NSString *const moduleName = components[0];
NSString *const methodName = components[1];
_invokeJS(moduleName, methodName, [event arguments]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ public class ReactFeatureFlags {
*/
public static boolean enableFabricLogs = false;

/**
* Should this application use a {@link com.facebook.react.uimanager.ViewManagerDelegate} (if
* provided) to update the view properties. If {@code false}, then the generated {@code
* ...$$PropsSetter} class will be used instead.
*/
public static boolean useViewManagerDelegates = false;

/**
* Should this application use a {@link com.facebook.react.uimanager.ViewManagerDelegate} (if
* provided) to execute the view commands. If {@code false}, then {@code receiveCommand} method
Expand Down
Loading

0 comments on commit 7478a04

Please sign in to comment.