Skip to content

Commit

Permalink
Merge branch 'main' into automatic-content-grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed May 27, 2022
2 parents d2c8bfb + 0ef73f2 commit 334b24d
Show file tree
Hide file tree
Showing 142 changed files with 2,319 additions and 3,381 deletions.
17 changes: 14 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ references:
attach_workspace:
at: *hermes_workspace_root

# -------------------------
# Dependency Anchors
# -------------------------
dependency_versions:
# The Xcode version used on CircleCI OSS tests must be kept in sync with
# the Xcode version used on Sandcastle OSS tests. See _XCODE_VERSION in
# tools/utd/migrated_nbtd_jobs/react_native_oss.td
xcode_version: &xcode_version "13.3.1"
nodelts_image: &nodelts_image "cimg/node:16.14"
nodeprevlts_image: &nodeprevlts_image "cimg/node:14.19"

# -------------------------
# Cache Key Anchors
# -------------------------
Expand Down Expand Up @@ -71,12 +82,12 @@ executors:
<<: *defaults
docker:
# Note: Version set separately for Windows builds, see below.
- image: cimg/node:16.14
- image: *nodelts_image
resource_class: "xlarge"
nodeprevlts:
<<: *defaults
docker:
- image: cimg/node:14.19
- image: *nodeprevlts_image
resource_class: "xlarge"
reactnativeandroid:
<<: *defaults
Expand All @@ -96,7 +107,7 @@ executors:
reactnativeios:
<<: *defaults
macos:
xcode: &_XCODE_VERSION "13.3.0"
xcode: *xcode_version
resource_class: macos.x86.medium.gen2

# -------------------------
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/danger_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
- run: yarn install
working-directory: bots
- name: Danger
run: yarn danger ci --use-github-checks --failOnErrors --id danger_pr
run: DANGER_GITHUB_API_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" yarn danger ci --use-github-checks --failOnErrors --id danger_pr
working-directory: bots
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLIC_PULLBOT_GITHUB_TOKEN_A: a6edf8e8d40ce4e8b11a
PUBLIC_PULLBOT_GITHUB_TOKEN_B: 150e1341f4dd9c944d2a
8 changes: 8 additions & 0 deletions Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ const API = {
invariant(NativeAnimatedModule, 'Native animated module is not available');
flushQueueTimeout = null;

// Early returns before calling any APIs
if (useSingleOpBatching && singleOpQueue.length === 0) {
return;
}
if (!useSingleOpBatching && queue.length === 0) {
return;
}

if (useSingleOpBatching) {
// Set up event listener for callbacks if it's not set up
if (
Expand Down
6 changes: 1 addition & 5 deletions Libraries/Animated/nodes/AnimatedProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,7 @@ class AnimatedProps extends AnimatedNode {
for (const key in this._props) {
const value = this._props[key];
if (value instanceof AnimatedNode) {
if (!value.__isNative || value instanceof AnimatedStyle) {
// We cannot use value of natively driven nodes this way as the value we have access from
// JS may not be up to date.
props[key] = value.__getValue();
}
props[key] = value.__getValue();
} else if (value instanceof AnimatedEvent) {
props[key] = value.__getHandler();
} else {
Expand Down
6 changes: 1 addition & 5 deletions Libraries/Animated/nodes/AnimatedStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ class AnimatedStyle extends AnimatedWithChildren {
for (const key in style) {
const value = style[key];
if (value instanceof AnimatedNode) {
if (!value.__isNative) {
// We cannot use value of natively driven nodes this way as the value we have access from
// JS may not be up to date.
updatedStyle[key] = value.__getValue();
}
updatedStyle[key] = value.__getValue();
} else if (value && !Array.isArray(value) && typeof value === 'object') {
// Support animating nested values (for example: shadowOffset.height)
updatedStyle[key] = this._walkStyleAndGetValues(value);
Expand Down
25 changes: 16 additions & 9 deletions Libraries/BatchedBridge/MessageQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,22 @@ class MessageQueue {
this.__spy({type: TO_JS, module, method, args});
}
const moduleMethods = this.getCallableModule(module);
invariant(
!!moduleMethods,
`Module ${module} is not a registered callable module (calling ${method}). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`,
);
invariant(
!!moduleMethods[method],
`Method ${method} does not exist on module ${module}`,
);
if (!moduleMethods) {
const callableModuleNames = Object.keys(this._lazyCallableModules);
const n = callableModuleNames.length;
const callableModuleNameList = callableModuleNames.join(', ');
invariant(
false,
`Failed to call into JavaScript module method ${module}.${method}(). Module has not been registered as callable. Registered callable JavaScript modules (n = ${n}): ${callableModuleNameList}.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`,
);
}
if (!moduleMethods[method]) {
invariant(
false,
`Failed to call into JavaScript module method ${module}.${method}(). Module exists, but the method is undefined.`,
);
}
moduleMethods[method].apply(moduleMethods, args);
Systrace.endEvent();
}
Expand Down
4 changes: 2 additions & 2 deletions Libraries/BatchedBridge/__tests__/MessageQueue-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ describe('MessageQueue', function () {
const unknownModule = 'UnknownModule',
unknownMethod = 'UnknownMethod';
expect(() => queue.__callFunction(unknownModule, unknownMethod)).toThrow(
`Module ${unknownModule} is not a registered callable module (calling ${unknownMethod}). A frequent cause of the error is that the application entry file path is incorrect.
This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`,
`Failed to call into JavaScript module method ${unknownModule}.${unknownMethod}(). Module has not been registered as callable. Registered callable JavaScript modules (n = 1): MessageQueueTestModule.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native.`,
);
});

Expand Down
15 changes: 11 additions & 4 deletions React/CxxUtils/RCTFollyConvert.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,22 @@ id convertFollyDynamicToId(const folly::dynamic &dyn)
return [[NSString alloc] initWithBytes:dyn.c_str() length:dyn.size() encoding:NSUTF8StringEncoding];
case folly::dynamic::ARRAY: {
NSMutableArray *array = [[NSMutableArray alloc] initWithCapacity:dyn.size()];
for (auto &elem : dyn) {
[array addObject:convertFollyDynamicToId(elem)];
for (const auto &elem : dyn) {
id value = convertFollyDynamicToId(elem);
if (value) {
[array addObject:value];
}
}
return array;
}
case folly::dynamic::OBJECT: {
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:dyn.size()];
for (auto &elem : dyn.items()) {
dict[convertFollyDynamicToId(elem.first)] = convertFollyDynamicToId(elem.second);
for (const auto &elem : dyn.items()) {
id key = convertFollyDynamicToId(elem.first);
id value = convertFollyDynamicToId(elem.second);
if (key && value) {
dict[key] = value;
}
}
return dict;
}
Expand Down
1 change: 0 additions & 1 deletion React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ - (RCTScheduler *)_createScheduler
auto weakRuntimeScheduler = _contextContainer->find<std::weak_ptr<RuntimeScheduler>>("RuntimeScheduler");
auto runtimeScheduler = weakRuntimeScheduler.has_value() ? weakRuntimeScheduler.value().lock() : nullptr;
if (runtimeScheduler) {
runtimeScheduler->setEnableYielding(true);
runtimeExecutor = [runtimeScheduler](std::function<void(jsi::Runtime & runtime)> &&callback) {
runtimeScheduler->scheduleWork(std::move(callback));
};
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public void requestChildFocus(View child, View focused) {
super.requestChildFocus(child, focused);
}

private void dispatchJSPointerEvent(MotionEvent event) {
protected void dispatchJSPointerEvent(MotionEvent event) {
if (mReactInstanceManager == null
|| !mIsAttachedToInstance
|| mReactInstanceManager.getCurrentReactContext() == null) {
Expand All @@ -361,7 +361,7 @@ private void dispatchJSPointerEvent(MotionEvent event) {
}
}

private void dispatchJSTouchEvent(MotionEvent event) {
protected void dispatchJSTouchEvent(MotionEvent event) {
if (mReactInstanceManager == null
|| !mIsAttachedToInstance
|| mReactInstanceManager.getCurrentReactContext() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,7 @@ public void queueAndExecuteBatchedOperations(final ReadableArray opsAndArgs) {
BatchExecutionOpCodes command = BatchExecutionOpCodes.fromId(opsAndArgs.getInt(i++));
switch (command) {
case OP_CODE_GET_VALUE:
case OP_START_LISTENING_TO_ANIMATED_NODE_VALUE:
case OP_STOP_LISTENING_TO_ANIMATED_NODE_VALUE:
case OP_CODE_STOP_ANIMATION:
case OP_CODE_FLATTEN_ANIMATED_NODE_OFFSET:
Expand All @@ -1059,7 +1060,6 @@ public void queueAndExecuteBatchedOperations(final ReadableArray opsAndArgs) {
break;
case OP_CODE_CREATE_ANIMATED_NODE:
case OP_CODE_UPDATE_ANIMATED_NODE_CONFIG:
case OP_START_LISTENING_TO_ANIMATED_NODE_VALUE:
case OP_CODE_CONNECT_ANIMATED_NODES:
case OP_CODE_DISCONNECT_ANIMATED_NODES:
case OP_CODE_SET_ANIMATED_NODE_VALUE:
Expand Down Expand Up @@ -1115,7 +1115,6 @@ public void execute(NativeAnimatedNodesManager animatedNodesManager) {
break;
case OP_START_LISTENING_TO_ANIMATED_NODE_VALUE:
final int tag = opsAndArgs.getInt(i++);
final int value = opsAndArgs.getInt(i++);
final AnimatedNodeValueListener listener =
new AnimatedNodeValueListener() {
public void onValueUpdate(double value) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,8 @@ public class ReactFeatureFlags {
/** Feature flag to configure synchronized queue access for Animated module */
public static boolean enableSynchronizationForAnimated = false;

private static boolean mapBufferSerializationEnabled = false;

/** Enables or disables MapBuffer Serialization */
public static void setMapBufferSerializationEnabled(boolean enabled) {
mapBufferSerializationEnabled = enabled;
}

public static boolean isMapBufferSerializationEnabled() {
return mapBufferSerializationEnabled;
}
public static boolean mapBufferSerializationEnabled = false;

/** Feature Flag to use overflowInset values provided by Yoga */
public static boolean useOverflowInset = false;
Expand Down Expand Up @@ -116,4 +108,15 @@ public static boolean isMapBufferSerializationEnabled() {

/** Feature Flag to control RN Android scrollEventThrottle prop. */
public static boolean enableScrollEventThrottle = false;

/**
* Feature flag that controls how turbo modules are exposed to JS
*
* <ul>
* <li>0 = as a HostObject
* <li>1 = as a plain object, backed with a HostObject as prototype
* <li>2 = as a plain object, with all methods eagerly configured
* </ul>
*/
public static int turboModuleBindingMode = 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public UIManager get() {
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.registerBinding");
final Binding binding = new Binding();

if (ReactFeatureFlags.isMapBufferSerializationEnabled()) {
if (ReactFeatureFlags.mapBufferSerializationEnabled) {
MapBufferSoLoader.staticInit();
}

Expand Down
Loading

0 comments on commit 334b24d

Please sign in to comment.