react-native 0.73.0-rc.2 → 0.73.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Animated/nodes/AnimatedStyle.js +1 -1
- package/Libraries/AppDelegate/RCTAppDelegate.mm +1 -1
- package/Libraries/AppDelegate/React-RCTAppDelegate.podspec +6 -2
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +2 -1
- package/Libraries/promiseRejectionTrackingOptions.js +21 -7
- package/React/Base/RCTBridgeProxy.mm +11 -3
- package/React/Base/RCTConstants.h +1 -1
- package/React/Base/RCTConstants.m +1 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/Surface/RCTSurfaceRootShadowView.h +1 -1
- package/React/Base/Surface/RCTSurfaceRootShadowView.m +1 -1
- package/React/CoreModules/RCTDeviceInfo.mm +1 -1
- package/React/CoreModules/React-CoreModules.podspec +1 -1
- package/React/Modules/RCTUIManager.h +7 -0
- package/React/Modules/RCTUIManager.m +1 -1
- package/React/Views/RCTComponentData.m +1 -1
- package/React/Views/RCTLayout.h +1 -1
- package/React/Views/RCTRootShadowView.h +1 -1
- package/React/Views/RCTRootShadowView.m +1 -1
- package/React/Views/RCTShadowView.m +1 -1
- package/React/Views/ScrollView/RCTScrollView.m +1 -1
- package/React-Core.podspec +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +0 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactApplication.kt +0 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java +0 -1
- package/ReactAndroid/src/main/java/com/facebook/react/{interfaces/ReactHost.kt → ReactHost.kt} +2 -3
- package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/common/annotations/UnstableReactNativeAPI.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt +58 -8
- package/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt +16 -0
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java +0 -11
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +5 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/devloading/DevLoadingModule.java +6 -10
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessReactContext.java +8 -0
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.java +5 -0
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/JSTimerExecutor.java +4 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java +6 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java +41 -4
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/FabricViewStateManager.java +95 -0
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java +25 -6
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +33 -23
- package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +4 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/hermes/executor/HermesExecutorFactory.cpp +10 -7
- package/ReactCommon/react/bridging/Object.h +1 -1
- package/ReactCommon/react/renderer/attributedstring/conversions.h +6 -0
- package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +31 -3
- package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h +3 -1
- package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +46 -10
- package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +17 -17
- package/gradle/libs.versions.toml +1 -1
- package/package.json +10 -10
- package/scripts/cocoapods/utils.rb +4 -23
- package/scripts/codegen/generate-legacy-interop-components.js +8 -2
- package/scripts/react_native_pods.rb +1 -1
- package/sdks/hermes-engine/hermes-engine.podspec +7 -1
- package/sdks/hermes-engine/hermes-utils.rb +9 -6
- package/sdks/hermes-engine/utils/replace_hermes_version.js +8 -8
- package/sdks/hermesc/osx-bin/hermes +0 -0
- package/sdks/hermesc/osx-bin/hermesc +0 -0
- package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
- package/template/android/app/build.gradle +1 -1
- package/template/android/app/src/main/java/com/helloworld/MainApplication.kt +3 -10
- package/template/package.json +2 -2
- package/third-party-podspecs/glog.podspec +14 -1
- package/ReactCommon/jsinspector/.clang-tidy +0 -6
- package/ReactCommon/jsinspector/InspectorInterfaces.cpp +0 -106
- package/ReactCommon/jsinspector/InspectorInterfaces.h +0 -92
|
@@ -22,6 +22,7 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
|
|
22
22
|
import com.facebook.react.bridge.ReactNoCrashBridgeNotAllowedSoftException;
|
|
23
23
|
import com.facebook.react.bridge.ReactSoftExceptionLogger;
|
|
24
24
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
25
|
+
import com.facebook.react.config.ReactFeatureFlags;
|
|
25
26
|
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
|
26
27
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
|
27
28
|
import com.facebook.react.uimanager.events.EventDispatcher;
|
|
@@ -49,6 +50,9 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
|
|
49
50
|
BridgelessReactContext(Context context, ReactHostImpl host) {
|
|
50
51
|
super(context);
|
|
51
52
|
mReactHost = host;
|
|
53
|
+
if (ReactFeatureFlags.unstable_useFabricInterop) {
|
|
54
|
+
initializeInteropModules();
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
@Override
|
|
@@ -124,6 +128,10 @@ class BridgelessReactContext extends ReactApplicationContext implements EventDis
|
|
|
124
128
|
|
|
125
129
|
@Override
|
|
126
130
|
public <T extends JavaScriptModule> T getJSModule(Class<T> jsInterface) {
|
|
131
|
+
if (mInteropModuleRegistry != null
|
|
132
|
+
&& mInteropModuleRegistry.shouldReturnInteropModule(jsInterface)) {
|
|
133
|
+
return mInteropModuleRegistry.getInteropModule(jsInterface);
|
|
134
|
+
}
|
|
127
135
|
JavaScriptModule interfaceProxy =
|
|
128
136
|
(JavaScriptModule)
|
|
129
137
|
Proxy.newProxyInstance(
|
|
@@ -19,6 +19,7 @@ import com.facebook.react.module.model.ReactModuleInfo;
|
|
|
19
19
|
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
20
20
|
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
|
21
21
|
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
22
|
+
import com.facebook.react.modules.core.ExceptionsManagerModule;
|
|
22
23
|
import com.facebook.react.modules.debug.DevSettingsModule;
|
|
23
24
|
import com.facebook.react.modules.debug.SourceCodeModule;
|
|
24
25
|
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
|
|
@@ -36,6 +37,7 @@ import java.util.Map;
|
|
|
36
37
|
SourceCodeModule.class,
|
|
37
38
|
LogBoxModule.class,
|
|
38
39
|
DeviceEventManagerModule.class,
|
|
40
|
+
ExceptionsManagerModule.class,
|
|
39
41
|
})
|
|
40
42
|
class CoreReactPackage extends TurboReactPackage {
|
|
41
43
|
|
|
@@ -63,6 +65,8 @@ class CoreReactPackage extends TurboReactPackage {
|
|
|
63
65
|
return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
|
|
64
66
|
case LogBoxModule.NAME:
|
|
65
67
|
return new LogBoxModule(reactContext, mDevSupportManager);
|
|
68
|
+
case ExceptionsManagerModule.NAME:
|
|
69
|
+
return new ExceptionsManagerModule(mDevSupportManager);
|
|
66
70
|
default:
|
|
67
71
|
throw new IllegalArgumentException(
|
|
68
72
|
"In BridgelessReactPackage, could not find Native module for " + name);
|
|
@@ -85,6 +89,7 @@ class CoreReactPackage extends TurboReactPackage {
|
|
|
85
89
|
DevSettingsModule.class,
|
|
86
90
|
DeviceEventManagerModule.class,
|
|
87
91
|
LogBoxModule.class,
|
|
92
|
+
ExceptionsManagerModule.class,
|
|
88
93
|
};
|
|
89
94
|
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
|
|
90
95
|
for (Class<? extends NativeModule> moduleClass : moduleList) {
|
|
@@ -9,13 +9,15 @@ package com.facebook.react.runtime;
|
|
|
9
9
|
|
|
10
10
|
import com.facebook.infer.annotation.Nullsafe;
|
|
11
11
|
import com.facebook.jni.HybridData;
|
|
12
|
-
import com.facebook.jni.annotations.
|
|
12
|
+
import com.facebook.jni.annotations.DoNotStripAny;
|
|
13
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
13
14
|
import com.facebook.react.bridge.WritableArray;
|
|
14
15
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
15
16
|
import com.facebook.react.modules.core.JavaScriptTimerExecutor;
|
|
16
17
|
import com.facebook.soloader.SoLoader;
|
|
17
18
|
|
|
18
19
|
@Nullsafe(Nullsafe.Mode.LOCAL)
|
|
20
|
+
@DoNotStripAny
|
|
19
21
|
class JSTimerExecutor implements JavaScriptTimerExecutor {
|
|
20
22
|
|
|
21
23
|
static {
|
|
@@ -24,6 +26,7 @@ class JSTimerExecutor implements JavaScriptTimerExecutor {
|
|
|
24
26
|
|
|
25
27
|
@DoNotStrip private final HybridData mHybridData;
|
|
26
28
|
|
|
29
|
+
@DoNotStrip
|
|
27
30
|
public JSTimerExecutor(HybridData hybridData) {
|
|
28
31
|
mHybridData = hybridData;
|
|
29
32
|
}
|
|
@@ -25,6 +25,7 @@ import com.facebook.infer.annotation.ThreadConfined;
|
|
|
25
25
|
import com.facebook.infer.annotation.ThreadSafe;
|
|
26
26
|
import com.facebook.react.JSEngineResolutionAlgorithm;
|
|
27
27
|
import com.facebook.react.MemoryPressureRouter;
|
|
28
|
+
import com.facebook.react.ReactHost;
|
|
28
29
|
import com.facebook.react.ReactInstanceEventListener;
|
|
29
30
|
import com.facebook.react.bridge.Callback;
|
|
30
31
|
import com.facebook.react.bridge.JSBundleLoader;
|
|
@@ -48,7 +49,6 @@ import com.facebook.react.devsupport.DisabledDevSupportManager;
|
|
|
48
49
|
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
|
49
50
|
import com.facebook.react.fabric.ComponentFactory;
|
|
50
51
|
import com.facebook.react.fabric.FabricUIManager;
|
|
51
|
-
import com.facebook.react.interfaces.ReactHost;
|
|
52
52
|
import com.facebook.react.interfaces.TaskInterface;
|
|
53
53
|
import com.facebook.react.interfaces.exceptionmanager.ReactJsExceptionHandler;
|
|
54
54
|
import com.facebook.react.interfaces.fabric.ReactSurface;
|
|
@@ -638,6 +638,9 @@ public class ReactHostImpl implements ReactHost {
|
|
|
638
638
|
final String method = "handleHostException(message = \"" + e.getMessage() + "\")";
|
|
639
639
|
log(method);
|
|
640
640
|
|
|
641
|
+
if (DEV) {
|
|
642
|
+
mDevSupportManager.handleException(e);
|
|
643
|
+
}
|
|
641
644
|
destroy(method, e);
|
|
642
645
|
mReactHostDelegate.handleInstanceException(e);
|
|
643
646
|
}
|
|
@@ -922,6 +925,7 @@ public class ReactHostImpl implements ReactHost {
|
|
|
922
925
|
final JSBundleLoader bundleLoader = task.getResult();
|
|
923
926
|
final BridgelessReactContext reactContext = getOrCreateReactContext();
|
|
924
927
|
final DevSupportManager devSupportManager = getDevSupportManager();
|
|
928
|
+
reactContext.setJSExceptionHandler(devSupportManager);
|
|
925
929
|
|
|
926
930
|
log(method, "Creating ReactInstance");
|
|
927
931
|
final ReactInstance instance =
|
|
@@ -1036,6 +1040,7 @@ public class ReactHostImpl implements ReactHost {
|
|
|
1036
1040
|
|
|
1037
1041
|
final BridgelessReactContext reactContext = getOrCreateReactContext();
|
|
1038
1042
|
final DevSupportManager devSupportManager = getDevSupportManager();
|
|
1043
|
+
reactContext.setJSExceptionHandler(devSupportManager);
|
|
1039
1044
|
|
|
1040
1045
|
return getJsBundleLoader()
|
|
1041
1046
|
.onSuccess(
|
|
@@ -71,6 +71,7 @@ import java.util.HashSet;
|
|
|
71
71
|
import java.util.List;
|
|
72
72
|
import java.util.Map;
|
|
73
73
|
import java.util.Set;
|
|
74
|
+
import java.util.concurrent.ConcurrentHashMap;
|
|
74
75
|
import javax.annotation.Nullable;
|
|
75
76
|
|
|
76
77
|
/**
|
|
@@ -93,6 +94,7 @@ final class ReactInstance {
|
|
|
93
94
|
private final TurboModuleManager mTurboModuleManager;
|
|
94
95
|
private final FabricUIManager mFabricUIManager;
|
|
95
96
|
private final JavaTimerManager mJavaTimerManager;
|
|
97
|
+
private final Map<String, ViewManager> mViewManagers = new ConcurrentHashMap<>();
|
|
96
98
|
|
|
97
99
|
@DoNotStrip @Nullable private ComponentNameResolverManager mComponentNameResolverManager;
|
|
98
100
|
@DoNotStrip @Nullable private UIConstantsProviderManager mUIConstantsProviderManager;
|
|
@@ -489,8 +491,12 @@ final class ReactInstance {
|
|
|
489
491
|
}
|
|
490
492
|
|
|
491
493
|
private @Nullable ViewManager createViewManager(String viewManagerName) {
|
|
494
|
+
// Return cached view manager if available, no matter it's eagerly or lazily loaded
|
|
495
|
+
if (mViewManagers.containsKey(viewManagerName)) {
|
|
496
|
+
return mViewManagers.get(viewManagerName);
|
|
497
|
+
}
|
|
498
|
+
List<ReactPackage> packages = mReactPackages;
|
|
492
499
|
if (mDelegate != null) {
|
|
493
|
-
List<ReactPackage> packages = mReactPackages;
|
|
494
500
|
if (packages != null) {
|
|
495
501
|
synchronized (packages) {
|
|
496
502
|
for (ReactPackage reactPackage : packages) {
|
|
@@ -499,6 +505,7 @@ final class ReactInstance {
|
|
|
499
505
|
((ViewManagerOnDemandReactPackage) reactPackage)
|
|
500
506
|
.createViewManager(mBridgelessReactContext, viewManagerName);
|
|
501
507
|
if (viewManager != null) {
|
|
508
|
+
mViewManagers.put(viewManagerName, viewManager);
|
|
502
509
|
return viewManager;
|
|
503
510
|
}
|
|
504
511
|
}
|
|
@@ -507,7 +514,17 @@ final class ReactInstance {
|
|
|
507
514
|
}
|
|
508
515
|
}
|
|
509
516
|
|
|
510
|
-
|
|
517
|
+
// Once a view manager is not found in all react packages via lazy loading, fall back to default
|
|
518
|
+
// implementation: eagerly initialize all view managers
|
|
519
|
+
for (ReactPackage reactPackage : packages) {
|
|
520
|
+
List<ViewManager> viewManagersInPackage =
|
|
521
|
+
reactPackage.createViewManagers(mBridgelessReactContext);
|
|
522
|
+
for (ViewManager viewManager : viewManagersInPackage) {
|
|
523
|
+
mViewManagers.put(viewManager.getName(), viewManager);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
return mViewManagers.get(viewManagerName);
|
|
511
528
|
}
|
|
512
529
|
|
|
513
530
|
private @NonNull Collection<String> getViewManagerNames() {
|
|
@@ -534,8 +551,28 @@ final class ReactInstance {
|
|
|
534
551
|
|
|
535
552
|
private @NonNull NativeMap getUIManagerConstants() {
|
|
536
553
|
List<ViewManager> viewManagers = new ArrayList<ViewManager>();
|
|
537
|
-
|
|
538
|
-
|
|
554
|
+
boolean canLoadViewManagersLazily = true;
|
|
555
|
+
|
|
556
|
+
List<ReactPackage> packages = mReactPackages;
|
|
557
|
+
for (ReactPackage reactPackage : packages) {
|
|
558
|
+
if (!(reactPackage instanceof ViewManagerOnDemandReactPackage)) {
|
|
559
|
+
canLoadViewManagersLazily = false;
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
// 1, Retrive view managers via on demand loading
|
|
564
|
+
if (canLoadViewManagersLazily) {
|
|
565
|
+
for (String viewManagerName : getViewManagerNames()) {
|
|
566
|
+
viewManagers.add(createViewManager(viewManagerName));
|
|
567
|
+
}
|
|
568
|
+
} else {
|
|
569
|
+
// 2, There are packages that don't implement ViewManagerOnDemandReactPackage so we retrieve
|
|
570
|
+
// view managers via eager loading
|
|
571
|
+
for (ReactPackage reactPackage : packages) {
|
|
572
|
+
List<ViewManager> viewManagersInPackage =
|
|
573
|
+
reactPackage.createViewManagers(mBridgelessReactContext);
|
|
574
|
+
viewManagers.addAll(viewManagersInPackage);
|
|
575
|
+
}
|
|
539
576
|
}
|
|
540
577
|
Map<String, Object> constants =
|
|
541
578
|
UIManagerModule.createConstants(viewManagers, new HashMap<>(), new HashMap<>());
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
package com.facebook.react.uimanager;
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Nullable;
|
|
11
|
+
import com.facebook.common.logging.FLog;
|
|
12
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
13
|
+
import com.facebook.react.bridge.WritableMap;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This is a helper base class for ViewGroups that use Fabric State.
|
|
17
|
+
*
|
|
18
|
+
* <p>Reason to use this: UpdateState calls from the View layer to the Fabric core can fail, and
|
|
19
|
+
* optionally Fabric will call a "failure callback" if that happens. This class abstracts that and
|
|
20
|
+
* makes it easier ensure that State in Fabric is always up-to-date.
|
|
21
|
+
*
|
|
22
|
+
* <p>1. Whenever ViewManager.updateState is called, call View.setStateWrapper. 2. Instead of
|
|
23
|
+
* calling StateWrapper.updateState directly, call View.setState and it will automatically keep
|
|
24
|
+
* retrying the UpdateState call until it succeeds; or you call setState again; or the View layer is
|
|
25
|
+
* updated with a newer StateWrapper.
|
|
26
|
+
*/
|
|
27
|
+
@Deprecated(
|
|
28
|
+
since =
|
|
29
|
+
"Deprecated class since v0.73.0, please use com.facebook.react.uimanager.StateWrapper instead.",
|
|
30
|
+
forRemoval = true)
|
|
31
|
+
public class FabricViewStateManager {
|
|
32
|
+
private static final String TAG = "FabricViewStateManager";
|
|
33
|
+
|
|
34
|
+
@Deprecated
|
|
35
|
+
public interface HasFabricViewStateManager {
|
|
36
|
+
FabricViewStateManager getFabricViewStateManager();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Deprecated
|
|
40
|
+
public interface StateUpdateCallback {
|
|
41
|
+
WritableMap getStateUpdate();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Nullable private StateWrapper mStateWrapper = null;
|
|
45
|
+
|
|
46
|
+
@Deprecated
|
|
47
|
+
public void setStateWrapper(StateWrapper stateWrapper) {
|
|
48
|
+
mStateWrapper = stateWrapper;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@Deprecated
|
|
52
|
+
public boolean hasStateWrapper() {
|
|
53
|
+
return mStateWrapper != null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private void setState(
|
|
57
|
+
@Nullable final StateWrapper stateWrapper,
|
|
58
|
+
final StateUpdateCallback stateUpdateCallback,
|
|
59
|
+
final int numTries) {
|
|
60
|
+
// The StateWrapper will change, breaking the async loop, whenever the UpdateState MountItem
|
|
61
|
+
// is executed.
|
|
62
|
+
// The caller is responsible for detecting if data is up-to-date, and doing nothing, or
|
|
63
|
+
// detecting if state is stale and calling setState again.
|
|
64
|
+
if (stateWrapper == null) {
|
|
65
|
+
FLog.e(TAG, "setState called without a StateWrapper");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (stateWrapper != mStateWrapper) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// We bail out after an arbitrary number of tries. In practice this should never go higher
|
|
72
|
+
// than 2 or 3, but there's nothing guaranteeing that.
|
|
73
|
+
if (numTries > 60) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Nullable WritableMap stateUpdate = stateUpdateCallback.getStateUpdate();
|
|
78
|
+
if (stateUpdate == null) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// TODO: State update cannot fail; remove `failureRunnable` and custom retrying logic.
|
|
83
|
+
stateWrapper.updateState(stateUpdate);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@Deprecated
|
|
87
|
+
public void setState(final StateUpdateCallback stateUpdateCallback) {
|
|
88
|
+
setState(mStateWrapper, stateUpdateCallback, 0);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@Deprecated
|
|
92
|
+
public @Nullable ReadableMap getStateData() {
|
|
93
|
+
return mStateWrapper != null ? mStateWrapper.getStateData() : null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -123,9 +123,9 @@ public interface ReactShadowNode<T extends ReactShadowNode> {
|
|
|
123
123
|
*/
|
|
124
124
|
void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue);
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
/* package */ boolean dispatchUpdatesWillChangeLayout(float absoluteX, float absoluteY);
|
|
127
127
|
|
|
128
|
-
/* package */
|
|
128
|
+
/* package */ void dispatchUpdates(
|
|
129
129
|
float absoluteX,
|
|
130
130
|
float absoluteY,
|
|
131
131
|
UIViewOperationQueue uiViewOperationQueue,
|
|
@@ -337,9 +337,32 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
|
|
337
337
|
@Override
|
|
338
338
|
public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {}
|
|
339
339
|
|
|
340
|
-
/** @return true if layout (position or dimensions) changed, false otherwise. */
|
|
341
340
|
@Override
|
|
342
|
-
public boolean
|
|
341
|
+
public boolean dispatchUpdatesWillChangeLayout(float absoluteX, float absoluteY) {
|
|
342
|
+
if (!hasNewLayout()) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
float layoutX = getLayoutX();
|
|
347
|
+
float layoutY = getLayoutY();
|
|
348
|
+
int newAbsoluteLeft = Math.round(absoluteX + layoutX);
|
|
349
|
+
int newAbsoluteTop = Math.round(absoluteY + layoutY);
|
|
350
|
+
int newAbsoluteRight = Math.round(absoluteX + layoutX + getLayoutWidth());
|
|
351
|
+
int newAbsoluteBottom = Math.round(absoluteY + layoutY + getLayoutHeight());
|
|
352
|
+
|
|
353
|
+
int newScreenX = Math.round(layoutX);
|
|
354
|
+
int newScreenY = Math.round(layoutY);
|
|
355
|
+
int newScreenWidth = newAbsoluteRight - newAbsoluteLeft;
|
|
356
|
+
int newScreenHeight = newAbsoluteBottom - newAbsoluteTop;
|
|
357
|
+
|
|
358
|
+
return newScreenX != mScreenX
|
|
359
|
+
|| newScreenY != mScreenY
|
|
360
|
+
|| newScreenWidth != mScreenWidth
|
|
361
|
+
|| newScreenHeight != mScreenHeight;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
@Override
|
|
365
|
+
public void dispatchUpdates(
|
|
343
366
|
float absoluteX,
|
|
344
367
|
float absoluteY,
|
|
345
368
|
UIViewOperationQueue uiViewOperationQueue,
|
|
@@ -386,10 +409,6 @@ public class ReactShadowNodeImpl implements ReactShadowNode<ReactShadowNodeImpl>
|
|
|
386
409
|
getScreenHeight());
|
|
387
410
|
}
|
|
388
411
|
}
|
|
389
|
-
|
|
390
|
-
return layoutHasChanged;
|
|
391
|
-
} else {
|
|
392
|
-
return false;
|
|
393
412
|
}
|
|
394
413
|
}
|
|
395
414
|
|
|
@@ -29,7 +29,9 @@ import com.facebook.systrace.Systrace;
|
|
|
29
29
|
import com.facebook.systrace.SystraceMessage;
|
|
30
30
|
import com.facebook.yoga.YogaConstants;
|
|
31
31
|
import com.facebook.yoga.YogaDirection;
|
|
32
|
+
import java.util.ArrayList;
|
|
32
33
|
import java.util.Arrays;
|
|
34
|
+
import java.util.List;
|
|
33
35
|
import java.util.Map;
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -665,7 +667,20 @@ public class UIImplementation {
|
|
|
665
667
|
.arg("rootTag", cssRoot.getReactTag())
|
|
666
668
|
.flush();
|
|
667
669
|
try {
|
|
668
|
-
|
|
670
|
+
List<ReactShadowNode> onLayoutNodes = new ArrayList<>();
|
|
671
|
+
applyUpdatesRecursive(cssRoot, 0f, 0f, onLayoutNodes);
|
|
672
|
+
|
|
673
|
+
for (ReactShadowNode node : onLayoutNodes) {
|
|
674
|
+
mEventDispatcher.dispatchEvent(
|
|
675
|
+
OnLayoutEvent.obtain(
|
|
676
|
+
-1, /* surfaceId not used in classic renderer */
|
|
677
|
+
node.getReactTag(),
|
|
678
|
+
node.getScreenX(),
|
|
679
|
+
node.getScreenY(),
|
|
680
|
+
node.getScreenWidth(),
|
|
681
|
+
node.getScreenHeight()));
|
|
682
|
+
}
|
|
683
|
+
|
|
669
684
|
} finally {
|
|
670
685
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
|
671
686
|
}
|
|
@@ -951,39 +966,34 @@ public class UIImplementation {
|
|
|
951
966
|
}
|
|
952
967
|
}
|
|
953
968
|
|
|
954
|
-
protected void applyUpdatesRecursive(
|
|
969
|
+
protected void applyUpdatesRecursive(
|
|
970
|
+
ReactShadowNode cssNode,
|
|
971
|
+
float absoluteX,
|
|
972
|
+
float absoluteY,
|
|
973
|
+
List<ReactShadowNode> onLayoutNodes) {
|
|
955
974
|
if (!cssNode.hasUpdates()) {
|
|
956
975
|
return;
|
|
957
976
|
}
|
|
958
977
|
|
|
978
|
+
if (cssNode.dispatchUpdatesWillChangeLayout(absoluteX, absoluteY)
|
|
979
|
+
&& cssNode.shouldNotifyOnLayout()
|
|
980
|
+
&& !mShadowNodeRegistry.isRootNode(cssNode.getReactTag())) {
|
|
981
|
+
onLayoutNodes.add(cssNode);
|
|
982
|
+
}
|
|
983
|
+
|
|
959
984
|
Iterable<? extends ReactShadowNode> cssChildren = cssNode.calculateLayoutOnChildren();
|
|
960
985
|
if (cssChildren != null) {
|
|
961
986
|
for (ReactShadowNode cssChild : cssChildren) {
|
|
962
987
|
applyUpdatesRecursive(
|
|
963
|
-
cssChild,
|
|
988
|
+
cssChild,
|
|
989
|
+
absoluteX + cssNode.getLayoutX(),
|
|
990
|
+
absoluteY + cssNode.getLayoutY(),
|
|
991
|
+
onLayoutNodes);
|
|
964
992
|
}
|
|
965
993
|
}
|
|
966
994
|
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
boolean frameDidChange =
|
|
970
|
-
cssNode.dispatchUpdates(
|
|
971
|
-
absoluteX, absoluteY, mOperationsQueue, mNativeViewHierarchyOptimizer);
|
|
972
|
-
|
|
973
|
-
// Notify JS about layout event if requested
|
|
974
|
-
// and if the position or dimensions actually changed
|
|
975
|
-
// (consistent with iOS).
|
|
976
|
-
if (frameDidChange && cssNode.shouldNotifyOnLayout()) {
|
|
977
|
-
mEventDispatcher.dispatchEvent(
|
|
978
|
-
OnLayoutEvent.obtain(
|
|
979
|
-
-1, /* surfaceId not used in classic renderer */
|
|
980
|
-
tag,
|
|
981
|
-
cssNode.getScreenX(),
|
|
982
|
-
cssNode.getScreenY(),
|
|
983
|
-
cssNode.getScreenWidth(),
|
|
984
|
-
cssNode.getScreenHeight()));
|
|
985
|
-
}
|
|
986
|
-
}
|
|
995
|
+
cssNode.dispatchUpdates(absoluteX, absoluteY, mOperationsQueue, mNativeViewHierarchyOptimizer);
|
|
996
|
+
|
|
987
997
|
cssNode.markUpdateSeen();
|
|
988
998
|
mNativeViewHierarchyOptimizer.onViewUpdatesCompleted(cssNode);
|
|
989
999
|
}
|
|
@@ -59,6 +59,7 @@ public class TextAttributeProps {
|
|
|
59
59
|
public static final short TA_KEY_ACCESSIBILITY_ROLE = 24;
|
|
60
60
|
public static final short TA_KEY_LINE_BREAK_STRATEGY = 25;
|
|
61
61
|
public static final short TA_KEY_ROLE = 26;
|
|
62
|
+
public static final short TA_KEY_TEXT_TRANSFORM = 27;
|
|
62
63
|
|
|
63
64
|
public static final int UNSET = -1;
|
|
64
65
|
|
|
@@ -219,6 +220,9 @@ public class TextAttributeProps {
|
|
|
219
220
|
case TA_KEY_ROLE:
|
|
220
221
|
result.setRole(Role.values()[entry.getIntValue()]);
|
|
221
222
|
break;
|
|
223
|
+
case TA_KEY_TEXT_TRANSFORM:
|
|
224
|
+
result.setTextTransform(entry.getStringValue());
|
|
225
|
+
break;
|
|
222
226
|
}
|
|
223
227
|
}
|
|
224
228
|
|
|
@@ -226,7 +230,6 @@ public class TextAttributeProps {
|
|
|
226
230
|
// setNumberOfLines
|
|
227
231
|
// setColor
|
|
228
232
|
// setIncludeFontPadding
|
|
229
|
-
// setTextTransform
|
|
230
233
|
return result;
|
|
231
234
|
}
|
|
232
235
|
|
|
@@ -43,13 +43,16 @@ class HermesExecutorRuntimeAdapter
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
void tickleJs() override {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
thread_->runOnQueue(
|
|
47
|
+
[weakRuntime = std::weak_ptr<HermesRuntime>(runtime_)]() {
|
|
48
|
+
auto runtime = weakRuntime.lock();
|
|
49
|
+
if (!runtime) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
jsi::Function func =
|
|
53
|
+
runtime->global().getPropertyAsFunction(*runtime, "__tickleJs");
|
|
54
|
+
func.call(*runtime);
|
|
55
|
+
});
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
private:
|
|
@@ -31,7 +31,7 @@ struct Bridging<
|
|
|
31
31
|
std::shared_ptr<T>,
|
|
32
32
|
std::enable_if_t<std::is_base_of_v<jsi::HostObject, T>>> {
|
|
33
33
|
static std::shared_ptr<T> fromJs(jsi::Runtime& rt, const jsi::Object& value) {
|
|
34
|
-
return value.
|
|
34
|
+
return value.getHostObject<T>(rt);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
static jsi::Object toJs(jsi::Runtime& rt, std::shared_ptr<T> value) {
|
|
@@ -970,6 +970,7 @@ constexpr static MapBuffer::Key TA_KEY_LAYOUT_DIRECTION = 23;
|
|
|
970
970
|
constexpr static MapBuffer::Key TA_KEY_ACCESSIBILITY_ROLE = 24;
|
|
971
971
|
constexpr static MapBuffer::Key TA_KEY_LINE_BREAK_STRATEGY = 25;
|
|
972
972
|
constexpr static MapBuffer::Key TA_KEY_ROLE = 26;
|
|
973
|
+
constexpr static MapBuffer::Key TA_KEY_TEXT_TRANSFORM = 27;
|
|
973
974
|
|
|
974
975
|
// constants for ParagraphAttributes serialization
|
|
975
976
|
constexpr static MapBuffer::Key PA_KEY_MAX_NUMBER_OF_LINES = 0;
|
|
@@ -1077,6 +1078,11 @@ inline MapBuffer toMapBuffer(const TextAttributes& textAttributes) {
|
|
|
1077
1078
|
TA_KEY_LINE_BREAK_STRATEGY,
|
|
1078
1079
|
toString(*textAttributes.lineBreakStrategy));
|
|
1079
1080
|
}
|
|
1081
|
+
if (textAttributes.textTransform.has_value()) {
|
|
1082
|
+
builder.putString(
|
|
1083
|
+
TA_KEY_TEXT_TRANSFORM, toString(*textAttributes.textTransform));
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1080
1086
|
// Decoration
|
|
1081
1087
|
if (textAttributes.textDecorationColor) {
|
|
1082
1088
|
builder.putInt(
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include "LegacyViewManagerInteropComponentDescriptor.h"
|
|
9
9
|
#include <React/RCTBridge.h>
|
|
10
10
|
#include <React/RCTBridgeModuleDecorator.h>
|
|
11
|
+
#include <React/RCTBridgeProxy.h>
|
|
11
12
|
#include <React/RCTComponentData.h>
|
|
12
13
|
#include <React/RCTEventDispatcher.h>
|
|
13
14
|
#include <React/RCTModuleData.h>
|
|
@@ -73,19 +74,45 @@ static Class getViewManagerFromComponentName(const std::string &componentName)
|
|
|
73
74
|
return nil;
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
static Class getViewManagerClass(const std::string &componentName, RCTBridge *bridge, RCTBridgeProxy *bridgeProxy)
|
|
78
|
+
{
|
|
79
|
+
Class viewManager = getViewManagerFromComponentName(componentName);
|
|
80
|
+
if (viewManager != nil) {
|
|
81
|
+
return viewManager;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// If all the heuristics fail, let's try to retrieve the view manager from the bridge/bridgeProxy
|
|
85
|
+
if (bridge != nil) {
|
|
86
|
+
return [[bridge moduleForName:RCTNSStringFromString(componentName)] class];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (bridgeProxy != nil) {
|
|
90
|
+
return [[bridgeProxy moduleForName:RCTNSStringFromString(componentName) lazilyLoadIfNecessary:YES] class];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return nil;
|
|
94
|
+
}
|
|
95
|
+
|
|
76
96
|
static const std::shared_ptr<void> constructCoordinator(
|
|
77
97
|
const ContextContainer::Shared &contextContainer,
|
|
78
98
|
const ComponentDescriptor::Flavor &flavor)
|
|
79
99
|
{
|
|
80
|
-
auto componentName = *std::static_pointer_cast<std::string const>(flavor);
|
|
81
|
-
Class viewManagerClass = getViewManagerFromComponentName(componentName);
|
|
82
|
-
assert(viewManagerClass);
|
|
83
100
|
auto optionalBridge = contextContainer->find<std::shared_ptr<void>>("Bridge");
|
|
84
101
|
RCTBridge *bridge;
|
|
85
102
|
if (optionalBridge) {
|
|
86
103
|
bridge = unwrapManagedObjectWeakly(optionalBridge.value());
|
|
87
104
|
}
|
|
88
105
|
|
|
106
|
+
RCTBridgeProxy *bridgeProxy;
|
|
107
|
+
auto optionalBridgeProxy = contextContainer->find<std::shared_ptr<void>>("RCTBridgeProxy");
|
|
108
|
+
if (optionalBridgeProxy) {
|
|
109
|
+
bridgeProxy = unwrapManagedObjectWeakly(optionalBridgeProxy.value());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
auto componentName = *std::static_pointer_cast<std::string const>(flavor);
|
|
113
|
+
Class viewManagerClass = getViewManagerClass(componentName, bridge, bridgeProxy);
|
|
114
|
+
assert(viewManagerClass);
|
|
115
|
+
|
|
89
116
|
auto optionalEventDispatcher = contextContainer->find<std::shared_ptr<void>>("RCTEventDispatcher");
|
|
90
117
|
RCTEventDispatcher *eventDispatcher;
|
|
91
118
|
if (optionalEventDispatcher) {
|
|
@@ -104,6 +131,7 @@ static const std::shared_ptr<void> constructCoordinator(
|
|
|
104
131
|
return wrapManagedObject([[RCTLegacyViewManagerInteropCoordinator alloc]
|
|
105
132
|
initWithComponentData:componentData
|
|
106
133
|
bridge:bridge
|
|
134
|
+
bridgeProxy:bridgeProxy
|
|
107
135
|
bridgelessInteropData:bridgeModuleDecorator]);
|
|
108
136
|
}
|
|
109
137
|
|
|
@@ -14,13 +14,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
14
14
|
|
|
15
15
|
@class RCTComponentData;
|
|
16
16
|
@class RCTBridge;
|
|
17
|
+
@class RCTBridgeProxy;
|
|
17
18
|
|
|
18
19
|
typedef void (^InterceptorBlock)(std::string eventName, folly::dynamic event);
|
|
19
20
|
|
|
20
21
|
@interface RCTLegacyViewManagerInteropCoordinator : NSObject
|
|
21
22
|
|
|
22
23
|
- (instancetype)initWithComponentData:(RCTComponentData *)componentData
|
|
23
|
-
bridge:(RCTBridge *)bridge
|
|
24
|
+
bridge:(nullable RCTBridge *)bridge
|
|
25
|
+
bridgeProxy:(nullable RCTBridgeProxy *)bridgeProxy
|
|
24
26
|
bridgelessInteropData:(RCTBridgeModuleDecorator *)bridgelessInteropData;
|
|
25
27
|
|
|
26
28
|
- (UIView *)createPaperViewWithTag:(NSInteger)tag;
|