react-native-windows 0.69.5 → 0.70.0-preview.2
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/.flowconfig +5 -1
- package/Chakra/ChakraHelpers.cpp +1 -1
- package/Chakra/ChakraPlatform.cpp +1 -1
- package/Chakra/ChakraValue.cpp +6 -3
- package/Chakra/ChakraValue.h +1 -1
- package/Directory.Build.props +7 -7
- package/Folly/Folly.vcxproj +20 -13
- package/Folly/cgmanifest.json +14 -0
- package/Libraries/Alert/Alert.js +18 -4
- package/Libraries/Alert/Alert.windows.js +4 -0
- package/Libraries/Alert/NativeAlertManager.js +1 -0
- package/Libraries/Animated/Animated.js +2 -2
- package/Libraries/Animated/AnimatedEvent.js +7 -4
- package/Libraries/Animated/AnimatedImplementation.js +17 -3
- package/Libraries/Animated/AnimatedMock.js +7 -2
- package/Libraries/Animated/NativeAnimatedHelper.js +220 -95
- package/Libraries/Animated/NativeAnimatedModule.js +3 -0
- package/Libraries/Animated/NativeAnimatedTurboModule.js +3 -0
- package/Libraries/Animated/animations/SpringAnimation.js +3 -3
- package/Libraries/Animated/animations/TimingAnimation.js +3 -3
- package/Libraries/Animated/createAnimatedComponent.js +8 -1
- package/Libraries/Animated/nodes/AnimatedAddition.js +3 -1
- package/Libraries/Animated/nodes/AnimatedColor.js +50 -29
- package/Libraries/Animated/nodes/AnimatedDiffClamp.js +3 -1
- package/Libraries/Animated/nodes/AnimatedDivision.js +3 -1
- package/Libraries/Animated/nodes/AnimatedInterpolation.js +22 -21
- package/Libraries/Animated/nodes/AnimatedModulo.js +3 -1
- package/Libraries/Animated/nodes/AnimatedMultiplication.js +3 -2
- package/Libraries/Animated/nodes/AnimatedProps.js +20 -12
- package/Libraries/Animated/nodes/AnimatedStyle.js +19 -16
- package/Libraries/Animated/nodes/AnimatedSubtraction.js +3 -1
- package/Libraries/Animated/nodes/AnimatedTransform.js +5 -5
- package/Libraries/Animated/nodes/AnimatedValue.js +14 -5
- package/Libraries/Animated/nodes/AnimatedValueXY.js +28 -1
- package/Libraries/Animated/useAnimatedProps.js +1 -0
- package/Libraries/AppState/AppState.js +0 -32
- package/Libraries/AppTheme/AppTheme.js +14 -8
- package/Libraries/AppTheme/AppThemeTypes.d.ts +0 -3
- package/Libraries/BatchedBridge/MessageQueue.js +21 -15
- package/Libraries/BatchedBridge/NativeModules.js +3 -4
- package/Libraries/Blob/FileReader.js +0 -6
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +0 -20
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +0 -20
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -0
- package/Libraries/Components/Keyboard/Keyboard.js +0 -11
- package/Libraries/Components/Pressable/Pressable.js +2 -0
- package/Libraries/Components/Pressable/Pressable.windows.js +2 -0
- package/Libraries/Components/SafeAreaView/RCTSafeAreaViewNativeComponent.js +1 -3
- package/Libraries/Components/SafeAreaView/SafeAreaView.js +3 -30
- package/Libraries/Components/SafeAreaView/SafeAreaView.windows.js +4 -30
- package/Libraries/Components/ScrollView/ScrollView.js +13 -11
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +5 -3
- package/Libraries/Components/StatusBar/StatusBar.js +10 -7
- package/Libraries/Components/TextInput/InputAccessoryView.js +14 -13
- package/Libraries/Components/TextInput/TextInput.js +12 -2
- package/Libraries/Components/TextInput/TextInput.windows.js +12 -2
- package/Libraries/Components/Touchable/PooledClass.js +16 -4
- package/Libraries/Components/Touchable/Touchable.js +50 -1
- package/Libraries/Components/Touchable/Touchable.windows.js +972 -0
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +6 -2
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +0 -7
- package/Libraries/Components/View/ViewPropTypes.js +3 -8
- package/Libraries/Components/View/ViewPropTypes.windows.js +3 -8
- package/Libraries/Core/ExceptionsManager.js +2 -0
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/Timers/JSTimers.js +2 -2
- package/Libraries/Core/polyfillPromise.js +0 -32
- package/Libraries/Core/setUpBatchedBridge.js +5 -1
- package/Libraries/Core/setUpPerformance.js +1 -1
- package/Libraries/EventEmitter/NativeEventEmitter.js +0 -13
- package/Libraries/Image/AssetSourceResolver.js +2 -2
- package/Libraries/Image/Image.android.js +5 -3
- package/Libraries/Image/Image.ios.js +6 -3
- package/Libraries/Image/Image.windows.js +6 -3
- package/Libraries/Image/ImageSource.js +7 -5
- package/Libraries/Inspector/ElementBox.js +2 -2
- package/Libraries/Inspector/NetworkOverlay.js +13 -8
- package/Libraries/Interaction/PanResponder.js +16 -14
- package/Libraries/Linking/Linking.js +0 -11
- package/Libraries/Lists/FlatList.js +3 -2
- package/Libraries/Lists/SectionList.js +2 -0
- package/Libraries/Lists/ViewabilityHelper.js +7 -3
- package/Libraries/Lists/VirtualizeUtils.js +33 -20
- package/Libraries/Lists/VirtualizedList.js +93 -47
- package/Libraries/Lists/VirtualizedListContext.js +1 -0
- package/Libraries/Lists/VirtualizedSectionList.js +14 -9
- package/Libraries/Lists/__tests__/VirtualizeUtils-test.js +19 -18
- package/Libraries/Lists/__tests__/VirtualizedList-test.js +10 -6
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
- package/Libraries/LogBox/LogBox.js +3 -1
- package/Libraries/LogBox/UI/AnsiHighlight.js +2 -0
- package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +3 -0
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +0 -3
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +8 -3
- package/Libraries/NativeComponent/BaseViewConfig.android.js +9 -18
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +26 -12
- package/Libraries/NativeComponent/BaseViewConfig.windows.js +26 -12
- package/Libraries/Network/XMLHttpRequest.js +9 -11
- package/Libraries/Performance/PureComponentDebug.js +1 -0
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +9 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +16 -0
- package/Libraries/Pressability/Pressability.js +26 -16
- package/Libraries/Pressability/Pressability.windows.js +30 -17
- package/Libraries/Promise.js +0 -1
- package/Libraries/ReactNative/AppRegistry.js +16 -13
- package/Libraries/ReactNative/BridgelessUIManager.js +2 -0
- package/Libraries/ReactNative/PaperUIManager.js +9 -9
- package/Libraries/ReactNative/PaperUIManager.windows.js +7 -8
- package/Libraries/ReactNative/ReactNativeFeatureFlags.js +12 -0
- package/Libraries/ReactNative/ReactNativeRuntimeDiagnostics.js +68 -0
- package/Libraries/ReactNative/getNativeComponentAttributes.js +6 -7
- package/Libraries/ReactNative/renderApplication.js +1 -1
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +4443 -3615
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +1496 -1170
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +1694 -1356
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +4439 -3588
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +1583 -1249
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +1719 -1372
- package/Libraries/Storage/AsyncStorage.js +7 -1
- package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +8 -0
- package/Libraries/StyleSheet/flattenStyle.js +1 -1
- package/Libraries/StyleSheet/processTransform.js +2 -0
- package/Libraries/StyleSheet/processTransform.windows.js +2 -0
- package/Libraries/StyleSheet/splitLayoutProps.js +2 -0
- package/Libraries/Text/Text.js +15 -7
- package/Libraries/Text/Text.windows.js +14 -7
- package/Libraries/Types/CoreEventTypes.js +137 -11
- package/Libraries/Types/CoreEventTypes.windows.js +147 -22
- package/Libraries/Utilities/Dimensions.js +0 -13
- package/Libraries/Utilities/HMRClient.js +3 -3
- package/Libraries/Utilities/Platform.ios.js +0 -7
- package/Libraries/Utilities/ReactNativeTestTools.js +3 -1
- package/Libraries/Utilities/codegenNativeCommands.js +11 -2
- package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
- package/Libraries/Utilities/stringifySafe.js +3 -1
- package/Libraries/Utilities/truncate.js +1 -1
- package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +2 -2
- package/Libraries/Vibration/Vibration.js +1 -1
- package/Libraries/WebSocket/WebSocket.js +1 -0
- package/Libraries/vendor/emitter/EventEmitter.js +105 -12
- package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +73 -117
- package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +24 -12
- package/Microsoft.ReactNative/CoreApp.cpp +303 -0
- package/Microsoft.ReactNative/CoreAppPage.cpp +21 -0
- package/Microsoft.ReactNative/CoreAppPage.h +15 -0
- package/Microsoft.ReactNative/CoreAppPage.idl +12 -0
- package/Microsoft.ReactNative/CoreAppPage.xaml +14 -0
- package/Microsoft.ReactNative/Fabric/ActivityIndicatorComponentView.cpp +1 -2
- package/Microsoft.ReactNative/Fabric/ActivityIndicatorComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ImageComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ImageComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ParagraphComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ParagraphComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ScrollViewComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ScrollViewComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/SliderComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/SliderComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/SwitchComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/TextComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/TextComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/TextInput/WindowsTextInputComponentView.h +1 -1
- package/Microsoft.ReactNative/Fabric/ViewComponentView.cpp +1 -1
- package/Microsoft.ReactNative/Fabric/ViewComponentView.h +1 -1
- package/Microsoft.ReactNative/GlyphViewManager.cpp +1 -0
- package/Microsoft.ReactNative/IReactDispatcher.cpp +18 -0
- package/Microsoft.ReactNative/IReactDispatcher.h +18 -3
- package/Microsoft.ReactNative/IReactDispatcher.idl +15 -0
- package/Microsoft.ReactNative/IReactNotificationService.cpp +197 -70
- package/Microsoft.ReactNative/IReactNotificationService.h +11 -30
- package/Microsoft.ReactNative/IReactPropertyBag.cpp +9 -0
- package/Microsoft.ReactNative/IReactPropertyBag.h +3 -0
- package/Microsoft.ReactNative/IReactPropertyBag.idl +3 -0
- package/Microsoft.ReactNative/JsiApi.cpp +41 -1
- package/Microsoft.ReactNative/JsiApi.h +3 -0
- package/Microsoft.ReactNative/JsiApi.idl +19 -1
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +18 -2
- package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +7 -7
- package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.h +1 -1
- package/Microsoft.ReactNative/Modules/AlertModule.cpp +15 -12
- package/Microsoft.ReactNative/Modules/AlertModule.h +1 -1
- package/Microsoft.ReactNative/Modules/AppStateModule.cpp +45 -9
- package/Microsoft.ReactNative/Modules/AppStateModule.h +9 -3
- package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.h +1 -1
- package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
- package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -1
- package/Microsoft.ReactNative/Modules/DeviceInfoModule.h +1 -1
- package/Microsoft.ReactNative/Modules/I18nManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.cpp +1 -1
- package/Microsoft.ReactNative/Modules/ImageViewManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LinkingManagerModule.h +1 -1
- package/Microsoft.ReactNative/Modules/LogBoxModule.h +1 -1
- package/Microsoft.ReactNative/Modules/NativeUIManager.cpp +66 -39
- package/Microsoft.ReactNative/Modules/PaperUIManagerModule.cpp +41 -11
- package/Microsoft.ReactNative/Modules/PaperUIManagerModule.h +1 -1
- package/Microsoft.ReactNative/QuirkSettings.cpp +22 -0
- package/Microsoft.ReactNative/QuirkSettings.h +10 -0
- package/Microsoft.ReactNative/QuirkSettings.idl +7 -0
- package/Microsoft.ReactNative/ReactApplication.cpp +44 -0
- package/Microsoft.ReactNative/ReactApplication.h +40 -5
- package/Microsoft.ReactNative/ReactHost/JSCallInvokerScheduler.cpp +5 -2
- package/Microsoft.ReactNative/ReactHost/JSCallInvokerScheduler.h +1 -0
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +23 -4
- package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
- package/Microsoft.ReactNative/ReactPointerEventArgs.cpp +12 -2
- package/Microsoft.ReactNative/Utils/BatchingEventEmitter.cpp +1 -0
- package/Microsoft.ReactNative/Utils/Helpers.cpp +1 -1
- package/Microsoft.ReactNative/Utils/Helpers.h +1 -1
- package/Microsoft.ReactNative/Utils/PropertyUtils.h +1 -1
- package/Microsoft.ReactNative/Utils/TransformableText.h +1 -1
- package/Microsoft.ReactNative/Utils/ValueUtils.cpp +0 -1
- package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +9 -7
- package/Microsoft.ReactNative/Views/DynamicAutomationProperties.cpp +3 -3
- package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +13 -1
- package/Microsoft.ReactNative/Views/FrameworkElementTransferProperties.cpp +1 -1
- package/Microsoft.ReactNative/Views/FrameworkElementViewManager.cpp +63 -13
- package/Microsoft.ReactNative/Views/Image/ImageViewManager.cpp +1 -1
- package/Microsoft.ReactNative/Views/Image/ReactImage.cpp +5 -6
- package/Microsoft.ReactNative/Views/Image/ReactImage.h +4 -4
- package/Microsoft.ReactNative/Views/Text/TextTransformParentVisitor.h +1 -1
- package/Microsoft.ReactNative/Views/TextInputViewManager.cpp +21 -2
- package/Microsoft.ReactNative/Views/TextViewManager.cpp +6 -3
- package/Microsoft.ReactNative/Views/TouchEventHandler.cpp +1 -1
- package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +7 -1
- package/Microsoft.ReactNative/Views/ViewPanel.cpp +4 -0
- package/Microsoft.ReactNative/Views/ViewViewManager.cpp +8 -3
- package/Microsoft.ReactNative/Views/cppwinrt/DynamicAutomationPeer.idl +2 -0
- package/Microsoft.ReactNative/microsoft.reactnative.def +4 -1
- package/Microsoft.ReactNative.Cxx/AppModelHelpers.h +17 -0
- package/Microsoft.ReactNative.Cxx/CoreApp.h +60 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.cpp +65 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +13 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiValueHelpers.cpp +53 -0
- package/Microsoft.ReactNative.Cxx/JSI/JsiValueHelpers.h +32 -0
- package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +14 -2
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +3 -0
- package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +7 -0
- package/Microsoft.ReactNative.Managed/packages.lock.json +1 -24
- package/Mso/dispatchQueue/dispatchQueue.h +12 -4
- package/Mso/src/dispatchQueue/looperScheduler.cpp +36 -9
- package/Mso/src/dispatchQueue/queueService.cpp +2 -2
- package/Mso/src/dispatchQueue/queueService.h +2 -2
- package/Mso/src/memoryApi/memoryApi.cpp +3 -0
- package/PropertySheets/Generated/PackageVersion.g.props +3 -3
- package/PropertySheets/JSEngine.props +1 -1
- package/PropertySheets/Release.props +6 -0
- package/ReactCommon/ReactCommon.vcxproj +11 -21
- package/ReactCommon/ReactCommon.vcxproj.filters +64 -46
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.h +145 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +344 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/BaseTextProps.cpp +313 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/ViewProps.cpp +455 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/ConcreteComponentDescriptor.h +216 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/PropsMacros.h +91 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/graphics/RectangleEdges.h +100 -0
- package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/CompactValue.h +3 -1
- package/Scripts/Microsoft.ReactNative.nuspec +6 -0
- package/Scripts/Microsoft.ReactNative.targets +7 -0
- package/Shared/DevSettings.h +4 -0
- package/Shared/JSI/ChakraRuntime.cpp +11 -2
- package/Shared/JSI/ChakraRuntime.h +2 -0
- package/Shared/Modules/BlobModule.cpp +4 -4
- package/Shared/Modules/BlobModule.h +1 -1
- package/Shared/Modules/FileReaderModule.cpp +3 -2
- package/Shared/Modules/IBlobPersistor.h +1 -1
- package/Shared/Networking/IHttpResource.h +1 -0
- package/Shared/Networking/OriginPolicyHttpFilter.cpp +16 -10
- package/Shared/Networking/WinRTHttpResource.cpp +34 -2
- package/Shared/OInstance.cpp +14 -6
- package/Shared/Threading/BatchingQueueThread.cpp +23 -12
- package/Shared/Utils.cpp +2 -5
- package/codegen/NativeAlertManagerSpec.g.h +2 -0
- package/codegen/NativeAnimatedModuleSpec.g.h +6 -0
- package/codegen/NativeAnimatedTurboModuleSpec.g.h +6 -0
- package/codegen/react/components/rnwcore/Props.cpp +2 -2
- package/codegen/react/components/rnwcore/Props.h +1 -1
- package/fmt/cgmanifest.json +14 -0
- package/fmt/fmt.vcxproj +25 -11
- package/jest/assetFileTransformer.js +3 -2
- package/jest/setup.js +4 -0
- package/package.json +27 -28
- package/rntypes/index.d.ts +0 -1
- package/template/cs-app-WinAppSDK/proj/{NuGet.Config → NuGet_Config} +0 -0
- package/template/metro.devMode.config.js +49 -2
- package/template/shared-app/proj/{NuGet.Config → NuGet_Config} +0 -0
- package/template/shared-lib/proj/{NuGet.Config → NuGet_Config} +0 -0
- package/Libraries/vendor/emitter/EventSubscription.js +0 -19
- package/Libraries/vendor/emitter/_EmitterSubscription.js +0 -62
- package/Libraries/vendor/emitter/_EventEmitter.js +0 -184
- package/Libraries/vendor/emitter/_EventSubscription.js +0 -45
- package/Libraries/vendor/emitter/_EventSubscriptionVendor.js +0 -108
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +0 -87
- package/Scripts/copyRNLibraries.js +0 -99
- package/jest/preprocessor.js +0 -40
- package/jest/preprocessor_DO_NOT_USE.js +0 -122
|
@@ -0,0 +1,344 @@
|
|
|
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
|
+
#include "NativeToJsBridge.h"
|
|
9
|
+
|
|
10
|
+
#include <ReactCommon/CallInvoker.h>
|
|
11
|
+
#include <folly/MoveWrapper.h>
|
|
12
|
+
#include <folly/json.h>
|
|
13
|
+
#include <glog/logging.h>
|
|
14
|
+
#include <jsi/jsi.h>
|
|
15
|
+
#include <reactperflogger/BridgeNativeModulePerfLogger.h>
|
|
16
|
+
|
|
17
|
+
#include "ErrorUtils.h"
|
|
18
|
+
#include "Instance.h"
|
|
19
|
+
#include "JSBigString.h"
|
|
20
|
+
#include "MessageQueueThread.h"
|
|
21
|
+
#include "MethodCall.h"
|
|
22
|
+
#include "ModuleRegistry.h"
|
|
23
|
+
#include "RAMBundleRegistry.h"
|
|
24
|
+
#include "SystraceSection.h"
|
|
25
|
+
|
|
26
|
+
#include <memory>
|
|
27
|
+
|
|
28
|
+
#ifdef WITH_FBSYSTRACE
|
|
29
|
+
#include <fbsystrace.h>
|
|
30
|
+
#include <jsi/jsi/jsi.h>
|
|
31
|
+
|
|
32
|
+
using fbsystrace::FbSystraceAsyncFlow;
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
namespace facebook {
|
|
36
|
+
namespace react {
|
|
37
|
+
|
|
38
|
+
// This class manages calls from JS to native code.
|
|
39
|
+
class JsToNativeBridge : public react::ExecutorDelegate {
|
|
40
|
+
public:
|
|
41
|
+
JsToNativeBridge(
|
|
42
|
+
std::shared_ptr<ModuleRegistry> registry,
|
|
43
|
+
std::shared_ptr<InstanceCallback> callback)
|
|
44
|
+
: m_registry(registry), m_callback(callback) {}
|
|
45
|
+
|
|
46
|
+
std::shared_ptr<ModuleRegistry> getModuleRegistry() override {
|
|
47
|
+
return m_registry;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
bool isBatchActive() {
|
|
51
|
+
return m_batchHadNativeModuleOrTurboModuleCalls;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void callNativeModules(
|
|
55
|
+
__unused JSExecutor &executor,
|
|
56
|
+
folly::dynamic &&calls,
|
|
57
|
+
bool isEndOfBatch) override {
|
|
58
|
+
CHECK(m_registry || calls.empty())
|
|
59
|
+
<< "native module calls cannot be completed with no native modules";
|
|
60
|
+
m_batchHadNativeModuleOrTurboModuleCalls =
|
|
61
|
+
m_batchHadNativeModuleOrTurboModuleCalls || !calls.empty();
|
|
62
|
+
|
|
63
|
+
std::vector<MethodCall> methodCalls = parseMethodCalls(std::move(calls));
|
|
64
|
+
BridgeNativeModulePerfLogger::asyncMethodCallBatchPreprocessEnd(
|
|
65
|
+
(int)methodCalls.size());
|
|
66
|
+
|
|
67
|
+
// An exception anywhere in here stops processing of the batch. This
|
|
68
|
+
// was the behavior of the Android bridge, and since exception handling
|
|
69
|
+
// terminates the whole bridge, there's not much point in continuing.
|
|
70
|
+
for (auto &call : methodCalls) {
|
|
71
|
+
m_registry->callNativeMethod(
|
|
72
|
+
call.moduleId, call.methodId, std::move(call.arguments), call.callId);
|
|
73
|
+
}
|
|
74
|
+
if (isEndOfBatch) {
|
|
75
|
+
// onBatchComplete will be called on the native (module) queue, but
|
|
76
|
+
// decrementPendingJSCalls will be called sync. Be aware that the bridge
|
|
77
|
+
// may still be processing native calls when the bridge idle signaler
|
|
78
|
+
// fires.
|
|
79
|
+
if (m_batchHadNativeModuleOrTurboModuleCalls) {
|
|
80
|
+
m_callback->onBatchComplete();
|
|
81
|
+
m_batchHadNativeModuleOrTurboModuleCalls = false;
|
|
82
|
+
}
|
|
83
|
+
m_callback->decrementPendingJSCalls();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
MethodCallResult callSerializableNativeHook(
|
|
88
|
+
__unused JSExecutor &executor,
|
|
89
|
+
unsigned int moduleId,
|
|
90
|
+
unsigned int methodId,
|
|
91
|
+
folly::dynamic &&args) override {
|
|
92
|
+
return m_registry->callSerializableNativeHook(
|
|
93
|
+
moduleId, methodId, std::move(args));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
void recordTurboModuleAsyncMethodCall() {
|
|
97
|
+
m_batchHadNativeModuleOrTurboModuleCalls = true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private:
|
|
101
|
+
// These methods are always invoked from an Executor. The NativeToJsBridge
|
|
102
|
+
// keeps a reference to the executor, and when destroy() is called, the
|
|
103
|
+
// executor is destroyed synchronously on its queue.
|
|
104
|
+
std::shared_ptr<ModuleRegistry> m_registry;
|
|
105
|
+
std::shared_ptr<InstanceCallback> m_callback;
|
|
106
|
+
bool m_batchHadNativeModuleOrTurboModuleCalls = false;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
NativeToJsBridge::NativeToJsBridge(
|
|
110
|
+
JSExecutorFactory *jsExecutorFactory,
|
|
111
|
+
std::shared_ptr<ModuleRegistry> registry,
|
|
112
|
+
std::shared_ptr<MessageQueueThread> jsQueue,
|
|
113
|
+
std::shared_ptr<InstanceCallback> callback)
|
|
114
|
+
: m_destroyed(std::make_shared<bool>(false)),
|
|
115
|
+
m_delegate(std::make_shared<JsToNativeBridge>(registry, callback)),
|
|
116
|
+
m_executor(jsExecutorFactory->createJSExecutor(m_delegate, jsQueue)),
|
|
117
|
+
m_executorMessageQueueThread(std::move(jsQueue)),
|
|
118
|
+
m_inspectable(m_executor->isInspectable()) {}
|
|
119
|
+
|
|
120
|
+
// This must be called on the same thread on which the constructor was called.
|
|
121
|
+
NativeToJsBridge::~NativeToJsBridge() {
|
|
122
|
+
CHECK(*m_destroyed)
|
|
123
|
+
<< "NativeToJsBridge::destroy() must be called before deallocating the NativeToJsBridge!";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
void NativeToJsBridge::initializeRuntime() {
|
|
127
|
+
runOnExecutorQueue(
|
|
128
|
+
[](JSExecutor *executor) mutable { executor->initializeRuntime(); });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
void NativeToJsBridge::loadBundle(
|
|
132
|
+
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
|
133
|
+
std::unique_ptr<const JSBigString> startupScript,
|
|
134
|
+
std::string startupScriptSourceURL) {
|
|
135
|
+
runOnExecutorQueue(
|
|
136
|
+
[this,
|
|
137
|
+
bundleRegistryWrap = folly::makeMoveWrapper(std::move(bundleRegistry)),
|
|
138
|
+
startupScript = folly::makeMoveWrapper(std::move(startupScript)),
|
|
139
|
+
startupScriptSourceURL =
|
|
140
|
+
std::move(startupScriptSourceURL)](JSExecutor *executor) mutable {
|
|
141
|
+
auto bundleRegistry = bundleRegistryWrap.move();
|
|
142
|
+
if (bundleRegistry) {
|
|
143
|
+
executor->setBundleRegistry(std::move(bundleRegistry));
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
executor->loadBundle(
|
|
147
|
+
std::move(*startupScript), std::move(startupScriptSourceURL));
|
|
148
|
+
} catch (...) {
|
|
149
|
+
m_applicationScriptHasFailure = true;
|
|
150
|
+
throw;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void NativeToJsBridge::loadBundleSync(
|
|
156
|
+
std::unique_ptr<RAMBundleRegistry> bundleRegistry,
|
|
157
|
+
std::unique_ptr<const JSBigString> startupScript,
|
|
158
|
+
std::string startupScriptSourceURL) {
|
|
159
|
+
if (bundleRegistry) {
|
|
160
|
+
m_executor->setBundleRegistry(std::move(bundleRegistry));
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
m_executor->loadBundle(
|
|
164
|
+
std::move(startupScript), std::move(startupScriptSourceURL));
|
|
165
|
+
} catch (...) {
|
|
166
|
+
m_applicationScriptHasFailure = true;
|
|
167
|
+
throw;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
void NativeToJsBridge::callFunction(
|
|
172
|
+
std::string &&module,
|
|
173
|
+
std::string &&method,
|
|
174
|
+
folly::dynamic &&arguments) {
|
|
175
|
+
int systraceCookie = -1;
|
|
176
|
+
#ifdef WITH_FBSYSTRACE
|
|
177
|
+
systraceCookie = m_systraceCookie++;
|
|
178
|
+
FbSystraceAsyncFlow::begin(
|
|
179
|
+
TRACE_TAG_REACT_CXX_BRIDGE, "JSCall", systraceCookie);
|
|
180
|
+
#endif
|
|
181
|
+
|
|
182
|
+
runOnExecutorQueue([this,
|
|
183
|
+
module = std::move(module),
|
|
184
|
+
method = std::move(method),
|
|
185
|
+
arguments = std::move(arguments),
|
|
186
|
+
systraceCookie](JSExecutor *executor) {
|
|
187
|
+
if (m_applicationScriptHasFailure) {
|
|
188
|
+
LOG(ERROR)
|
|
189
|
+
<< "Attempting to call JS function on a bad application bundle: "
|
|
190
|
+
<< module.c_str() << "." << method.c_str() << "()";
|
|
191
|
+
throw std::runtime_error(
|
|
192
|
+
"Attempting to call JS function on a bad application bundle: " +
|
|
193
|
+
module + "." + method + "()");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
#ifdef WITH_FBSYSTRACE
|
|
197
|
+
FbSystraceAsyncFlow::end(
|
|
198
|
+
TRACE_TAG_REACT_CXX_BRIDGE, "JSCall", systraceCookie);
|
|
199
|
+
SystraceSection s(
|
|
200
|
+
"NativeToJsBridge::callFunction", "module", module, "method", method);
|
|
201
|
+
#else
|
|
202
|
+
(void)(systraceCookie);
|
|
203
|
+
#endif
|
|
204
|
+
// This is safe because we are running on the executor's thread: it won't
|
|
205
|
+
// destruct until after it's been unregistered (which we check above) and
|
|
206
|
+
// that will happen on this thread
|
|
207
|
+
executor->callFunction(module, method, arguments);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
void NativeToJsBridge::invokeCallback(
|
|
212
|
+
double callbackId,
|
|
213
|
+
folly::dynamic &&arguments) {
|
|
214
|
+
int systraceCookie = -1;
|
|
215
|
+
#ifdef WITH_FBSYSTRACE
|
|
216
|
+
systraceCookie = m_systraceCookie++;
|
|
217
|
+
FbSystraceAsyncFlow::begin(
|
|
218
|
+
TRACE_TAG_REACT_CXX_BRIDGE, "<callback>", systraceCookie);
|
|
219
|
+
#endif
|
|
220
|
+
|
|
221
|
+
runOnExecutorQueue(
|
|
222
|
+
[this, callbackId, arguments = std::move(arguments), systraceCookie](
|
|
223
|
+
JSExecutor *executor) {
|
|
224
|
+
if (m_applicationScriptHasFailure) {
|
|
225
|
+
LOG(ERROR)
|
|
226
|
+
<< "Attempting to call JS callback on a bad application bundle: "
|
|
227
|
+
<< callbackId;
|
|
228
|
+
throw std::runtime_error(
|
|
229
|
+
"Attempting to invoke JS callback on a bad application bundle.");
|
|
230
|
+
}
|
|
231
|
+
#ifdef WITH_FBSYSTRACE
|
|
232
|
+
FbSystraceAsyncFlow::end(
|
|
233
|
+
TRACE_TAG_REACT_CXX_BRIDGE, "<callback>", systraceCookie);
|
|
234
|
+
SystraceSection s("NativeToJsBridge::invokeCallback");
|
|
235
|
+
#else
|
|
236
|
+
(void)(systraceCookie);
|
|
237
|
+
#endif
|
|
238
|
+
executor->invokeCallback(callbackId, arguments);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
void NativeToJsBridge::registerBundle(
|
|
243
|
+
uint32_t bundleId,
|
|
244
|
+
const std::string &bundlePath) {
|
|
245
|
+
runOnExecutorQueue([bundleId, bundlePath](JSExecutor *executor) {
|
|
246
|
+
executor->registerBundle(bundleId, bundlePath);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
void NativeToJsBridge::setGlobalVariable(
|
|
251
|
+
std::string propName,
|
|
252
|
+
std::unique_ptr<const JSBigString> jsonValue) {
|
|
253
|
+
runOnExecutorQueue([propName = std::move(propName),
|
|
254
|
+
jsonValue = folly::makeMoveWrapper(std::move(jsonValue))](
|
|
255
|
+
JSExecutor *executor) mutable {
|
|
256
|
+
executor->setGlobalVariable(propName, jsonValue.move());
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
void *NativeToJsBridge::getJavaScriptContext() {
|
|
261
|
+
// TODO(cjhopman): this seems unsafe unless we require that it is only called
|
|
262
|
+
// on the main js queue.
|
|
263
|
+
return m_executor->getJavaScriptContext();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
bool NativeToJsBridge::isInspectable() {
|
|
267
|
+
return m_inspectable;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
bool NativeToJsBridge::isBatchActive() {
|
|
271
|
+
return m_delegate->isBatchActive();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
void NativeToJsBridge::handleMemoryPressure(int pressureLevel) {
|
|
275
|
+
runOnExecutorQueue([=](JSExecutor *executor) {
|
|
276
|
+
executor->handleMemoryPressure(pressureLevel);
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
void NativeToJsBridge::destroy() {
|
|
281
|
+
// All calls made through runOnExecutorQueue have an early exit if
|
|
282
|
+
// m_destroyed is true. Setting this before the runOnQueueSync will cause
|
|
283
|
+
// pending work to be cancelled and we won't have to wait for it.
|
|
284
|
+
*m_destroyed = true;
|
|
285
|
+
m_executorMessageQueueThread->runOnQueueSync([this] {
|
|
286
|
+
m_executor->destroy();
|
|
287
|
+
m_executorMessageQueueThread->quitSynchronous();
|
|
288
|
+
m_executor = nullptr;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
void NativeToJsBridge::runOnExecutorQueue(
|
|
293
|
+
std::function<void(JSExecutor *)> task) {
|
|
294
|
+
if (*m_destroyed) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
std::shared_ptr<bool> isDestroyed = m_destroyed;
|
|
299
|
+
m_executorMessageQueueThread->runOnQueue(
|
|
300
|
+
[this, isDestroyed, task = std::move(task)] {
|
|
301
|
+
if (*isDestroyed) {
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// The executor is guaranteed to be valid for the duration of the task
|
|
306
|
+
// because:
|
|
307
|
+
// 1. the executor is only destroyed after it is unregistered
|
|
308
|
+
// 2. the executor is unregistered on this queue
|
|
309
|
+
// 3. we just confirmed that the executor hasn't been unregistered above
|
|
310
|
+
task(m_executor.get());
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
std::shared_ptr<CallInvoker> NativeToJsBridge::getDecoratedNativeCallInvoker(
|
|
315
|
+
std::shared_ptr<CallInvoker> nativeInvoker) {
|
|
316
|
+
class NativeCallInvoker : public CallInvoker {
|
|
317
|
+
private:
|
|
318
|
+
std::weak_ptr<JsToNativeBridge> m_jsToNativeBridge;
|
|
319
|
+
std::shared_ptr<CallInvoker> m_nativeInvoker;
|
|
320
|
+
|
|
321
|
+
public:
|
|
322
|
+
NativeCallInvoker(
|
|
323
|
+
std::weak_ptr<JsToNativeBridge> jsToNativeBridge,
|
|
324
|
+
std::shared_ptr<CallInvoker> nativeInvoker)
|
|
325
|
+
: m_jsToNativeBridge(jsToNativeBridge),
|
|
326
|
+
m_nativeInvoker(nativeInvoker) {}
|
|
327
|
+
|
|
328
|
+
void invokeAsync(std::function<void()> &&func) override {
|
|
329
|
+
if (auto strongJsToNativeBridge = m_jsToNativeBridge.lock()) {
|
|
330
|
+
strongJsToNativeBridge->recordTurboModuleAsyncMethodCall();
|
|
331
|
+
}
|
|
332
|
+
m_nativeInvoker->invokeAsync(std::move(func));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
void invokeSync(std::function<void()> &&func) override {
|
|
336
|
+
m_nativeInvoker->invokeSync(std::move(func));
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
return std::make_shared<NativeCallInvoker>(m_delegate, nativeInvoker);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
} // namespace react
|
|
344
|
+
} // namespace facebook
|
package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/BaseTextProps.cpp
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
#include "BaseTextProps.h"
|
|
9
|
+
|
|
10
|
+
#include <react/renderer/attributedstring/conversions.h>
|
|
11
|
+
#include <react/renderer/core/propsConversions.h>
|
|
12
|
+
#include <react/renderer/debug/DebugStringConvertibleItem.h>
|
|
13
|
+
#include <react/renderer/graphics/conversions.h>
|
|
14
|
+
|
|
15
|
+
#define GET_FIELD_VALUE(field, fieldName, defaultValue, rawValue) \
|
|
16
|
+
(rawValue.hasValue() ? ([&rawValue,&context]{ \
|
|
17
|
+
decltype(defaultValue) res; \
|
|
18
|
+
fromRawValue(context, rawValue, res); \
|
|
19
|
+
return res; \
|
|
20
|
+
}()) \
|
|
21
|
+
: defaultValue);
|
|
22
|
+
|
|
23
|
+
#define REBUILD_FIELD_SWITCH_CASE( \
|
|
24
|
+
defaults, rawValue, property, field, fieldName) \
|
|
25
|
+
case CONSTEXPR_RAW_PROPS_KEY_HASH(fieldName): { \
|
|
26
|
+
property.field = \
|
|
27
|
+
GET_FIELD_VALUE(field, fieldName, defaults.field, rawValue); \
|
|
28
|
+
return; \
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
namespace facebook {
|
|
33
|
+
namespace react {
|
|
34
|
+
|
|
35
|
+
bool BaseTextProps::enablePropIteratorSetter = false;
|
|
36
|
+
|
|
37
|
+
static TextAttributes convertRawProp(
|
|
38
|
+
PropsParserContext const &context,
|
|
39
|
+
RawProps const &rawProps,
|
|
40
|
+
TextAttributes const &sourceTextAttributes,
|
|
41
|
+
TextAttributes const &defaultTextAttributes) {
|
|
42
|
+
auto textAttributes = TextAttributes{};
|
|
43
|
+
|
|
44
|
+
// Color (not accessed by ViewProps)
|
|
45
|
+
textAttributes.foregroundColor = convertRawProp(
|
|
46
|
+
context,
|
|
47
|
+
rawProps,
|
|
48
|
+
"color",
|
|
49
|
+
sourceTextAttributes.foregroundColor,
|
|
50
|
+
defaultTextAttributes.foregroundColor);
|
|
51
|
+
|
|
52
|
+
// Font
|
|
53
|
+
textAttributes.fontFamily = convertRawProp(
|
|
54
|
+
context,
|
|
55
|
+
rawProps,
|
|
56
|
+
"fontFamily",
|
|
57
|
+
sourceTextAttributes.fontFamily,
|
|
58
|
+
defaultTextAttributes.fontFamily);
|
|
59
|
+
textAttributes.fontSize = convertRawProp(
|
|
60
|
+
context,
|
|
61
|
+
rawProps,
|
|
62
|
+
"fontSize",
|
|
63
|
+
sourceTextAttributes.fontSize,
|
|
64
|
+
defaultTextAttributes.fontSize);
|
|
65
|
+
textAttributes.fontSizeMultiplier = convertRawProp(
|
|
66
|
+
context,
|
|
67
|
+
rawProps,
|
|
68
|
+
"fontSizeMultiplier",
|
|
69
|
+
sourceTextAttributes.fontSizeMultiplier,
|
|
70
|
+
defaultTextAttributes.fontSizeMultiplier);
|
|
71
|
+
textAttributes.fontWeight = convertRawProp(
|
|
72
|
+
context,
|
|
73
|
+
rawProps,
|
|
74
|
+
"fontWeight",
|
|
75
|
+
sourceTextAttributes.fontWeight,
|
|
76
|
+
defaultTextAttributes.fontWeight);
|
|
77
|
+
textAttributes.fontStyle = convertRawProp(
|
|
78
|
+
context,
|
|
79
|
+
rawProps,
|
|
80
|
+
"fontStyle",
|
|
81
|
+
sourceTextAttributes.fontStyle,
|
|
82
|
+
defaultTextAttributes.fontStyle);
|
|
83
|
+
textAttributes.fontVariant = convertRawProp(
|
|
84
|
+
context,
|
|
85
|
+
rawProps,
|
|
86
|
+
"fontVariant",
|
|
87
|
+
sourceTextAttributes.fontVariant,
|
|
88
|
+
defaultTextAttributes.fontVariant);
|
|
89
|
+
textAttributes.allowFontScaling = convertRawProp(
|
|
90
|
+
context,
|
|
91
|
+
rawProps,
|
|
92
|
+
"allowFontScaling",
|
|
93
|
+
sourceTextAttributes.allowFontScaling,
|
|
94
|
+
defaultTextAttributes.allowFontScaling);
|
|
95
|
+
textAttributes.letterSpacing = convertRawProp(
|
|
96
|
+
context,
|
|
97
|
+
rawProps,
|
|
98
|
+
"letterSpacing",
|
|
99
|
+
sourceTextAttributes.letterSpacing,
|
|
100
|
+
defaultTextAttributes.letterSpacing);
|
|
101
|
+
textAttributes.textTransform = convertRawProp(
|
|
102
|
+
context,
|
|
103
|
+
rawProps,
|
|
104
|
+
"textTransform",
|
|
105
|
+
sourceTextAttributes.textTransform,
|
|
106
|
+
defaultTextAttributes.textTransform);
|
|
107
|
+
|
|
108
|
+
// Paragraph
|
|
109
|
+
textAttributes.lineHeight = convertRawProp(
|
|
110
|
+
context,
|
|
111
|
+
rawProps,
|
|
112
|
+
"lineHeight",
|
|
113
|
+
sourceTextAttributes.lineHeight,
|
|
114
|
+
defaultTextAttributes.lineHeight);
|
|
115
|
+
textAttributes.alignment = convertRawProp(
|
|
116
|
+
context,
|
|
117
|
+
rawProps,
|
|
118
|
+
"textAlign",
|
|
119
|
+
sourceTextAttributes.alignment,
|
|
120
|
+
defaultTextAttributes.alignment);
|
|
121
|
+
textAttributes.baseWritingDirection = convertRawProp(
|
|
122
|
+
context,
|
|
123
|
+
rawProps,
|
|
124
|
+
"baseWritingDirection",
|
|
125
|
+
sourceTextAttributes.baseWritingDirection,
|
|
126
|
+
defaultTextAttributes.baseWritingDirection);
|
|
127
|
+
|
|
128
|
+
// Decoration
|
|
129
|
+
textAttributes.textDecorationColor = convertRawProp(
|
|
130
|
+
context,
|
|
131
|
+
rawProps,
|
|
132
|
+
"textDecorationColor",
|
|
133
|
+
sourceTextAttributes.textDecorationColor,
|
|
134
|
+
defaultTextAttributes.textDecorationColor);
|
|
135
|
+
textAttributes.textDecorationLineType = convertRawProp(
|
|
136
|
+
context,
|
|
137
|
+
rawProps,
|
|
138
|
+
"textDecorationLine",
|
|
139
|
+
sourceTextAttributes.textDecorationLineType,
|
|
140
|
+
defaultTextAttributes.textDecorationLineType);
|
|
141
|
+
textAttributes.textDecorationStyle = convertRawProp(
|
|
142
|
+
context,
|
|
143
|
+
rawProps,
|
|
144
|
+
"textDecorationStyle",
|
|
145
|
+
sourceTextAttributes.textDecorationStyle,
|
|
146
|
+
defaultTextAttributes.textDecorationStyle);
|
|
147
|
+
|
|
148
|
+
// Shadow
|
|
149
|
+
textAttributes.textShadowOffset = convertRawProp(
|
|
150
|
+
context,
|
|
151
|
+
rawProps,
|
|
152
|
+
"textShadowOffset",
|
|
153
|
+
sourceTextAttributes.textShadowOffset,
|
|
154
|
+
defaultTextAttributes.textShadowOffset);
|
|
155
|
+
textAttributes.textShadowRadius = convertRawProp(
|
|
156
|
+
context,
|
|
157
|
+
rawProps,
|
|
158
|
+
"textShadowRadius",
|
|
159
|
+
sourceTextAttributes.textShadowRadius,
|
|
160
|
+
defaultTextAttributes.textShadowRadius);
|
|
161
|
+
textAttributes.textShadowColor = convertRawProp(
|
|
162
|
+
context,
|
|
163
|
+
rawProps,
|
|
164
|
+
"textShadowColor",
|
|
165
|
+
sourceTextAttributes.textShadowColor,
|
|
166
|
+
defaultTextAttributes.textShadowColor);
|
|
167
|
+
|
|
168
|
+
// Special
|
|
169
|
+
textAttributes.isHighlighted = convertRawProp(
|
|
170
|
+
context,
|
|
171
|
+
rawProps,
|
|
172
|
+
"isHighlighted",
|
|
173
|
+
sourceTextAttributes.isHighlighted,
|
|
174
|
+
defaultTextAttributes.isHighlighted);
|
|
175
|
+
|
|
176
|
+
// In general, we want this class to access props in the same order
|
|
177
|
+
// that ViewProps accesses them in, so that RawPropParser can optimize
|
|
178
|
+
// accesses. This is both theoretical, and ParagraphProps takes advantage
|
|
179
|
+
// of this.
|
|
180
|
+
// In particular: accessibilityRole, opacity, and backgroundColor also
|
|
181
|
+
// are parsed first by ViewProps (and indirectly AccessibilityProps).
|
|
182
|
+
// However, since RawPropsParser will always store these props /before/
|
|
183
|
+
// the unique BaseTextProps props, it is most efficient to parse these, in
|
|
184
|
+
// order, /after/ all of the other BaseTextProps, so that the RawPropsParser
|
|
185
|
+
// index rolls over only once instead of twice.
|
|
186
|
+
textAttributes.accessibilityRole = convertRawProp(
|
|
187
|
+
context,
|
|
188
|
+
rawProps,
|
|
189
|
+
"accessibilityRole",
|
|
190
|
+
sourceTextAttributes.accessibilityRole,
|
|
191
|
+
defaultTextAttributes.accessibilityRole);
|
|
192
|
+
|
|
193
|
+
// Color (accessed in this order by ViewProps)
|
|
194
|
+
textAttributes.opacity = convertRawProp(
|
|
195
|
+
context,
|
|
196
|
+
rawProps,
|
|
197
|
+
"opacity",
|
|
198
|
+
sourceTextAttributes.opacity,
|
|
199
|
+
defaultTextAttributes.opacity);
|
|
200
|
+
textAttributes.backgroundColor = convertRawProp(
|
|
201
|
+
context,
|
|
202
|
+
rawProps,
|
|
203
|
+
"backgroundColor",
|
|
204
|
+
sourceTextAttributes.backgroundColor,
|
|
205
|
+
defaultTextAttributes.backgroundColor);
|
|
206
|
+
|
|
207
|
+
return textAttributes;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
BaseTextProps::BaseTextProps(
|
|
211
|
+
const PropsParserContext &context,
|
|
212
|
+
const BaseTextProps &sourceProps,
|
|
213
|
+
const RawProps &rawProps)
|
|
214
|
+
: textAttributes(
|
|
215
|
+
BaseTextProps::enablePropIteratorSetter
|
|
216
|
+
? sourceProps.textAttributes
|
|
217
|
+
: convertRawProp(
|
|
218
|
+
context,
|
|
219
|
+
rawProps,
|
|
220
|
+
sourceProps.textAttributes,
|
|
221
|
+
TextAttributes{})){};
|
|
222
|
+
|
|
223
|
+
void BaseTextProps::setProp(
|
|
224
|
+
const PropsParserContext &context,
|
|
225
|
+
RawPropsPropNameHash hash,
|
|
226
|
+
const char *propName,
|
|
227
|
+
RawValue const &value) {
|
|
228
|
+
static auto defaults = TextAttributes{};
|
|
229
|
+
|
|
230
|
+
switch (hash) {
|
|
231
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
232
|
+
defaults, value, textAttributes, foregroundColor, "color");
|
|
233
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
234
|
+
defaults, value, textAttributes, fontFamily, "fontFamily");
|
|
235
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
236
|
+
defaults, value, textAttributes, fontSize, "fontSize");
|
|
237
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
238
|
+
defaults,
|
|
239
|
+
value,
|
|
240
|
+
textAttributes,
|
|
241
|
+
fontSizeMultiplier,
|
|
242
|
+
"fontSizeMultiplier");
|
|
243
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
244
|
+
defaults, value, textAttributes, fontWeight, "fontWeight");
|
|
245
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
246
|
+
defaults, value, textAttributes, fontStyle, "fontStyle");
|
|
247
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
248
|
+
defaults, value, textAttributes, fontVariant, "fontVariant");
|
|
249
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
250
|
+
defaults, value, textAttributes, allowFontScaling, "allowFontScaling");
|
|
251
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
252
|
+
defaults, value, textAttributes, letterSpacing, "letterSpacing");
|
|
253
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
254
|
+
defaults, value, textAttributes, textTransform, "textTransform");
|
|
255
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
256
|
+
defaults, value, textAttributes, lineHeight, "lineHeight");
|
|
257
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
258
|
+
defaults, value, textAttributes, alignment, "textAlign");
|
|
259
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
260
|
+
defaults,
|
|
261
|
+
value,
|
|
262
|
+
textAttributes,
|
|
263
|
+
baseWritingDirection,
|
|
264
|
+
"baseWritingDirection");
|
|
265
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
266
|
+
defaults,
|
|
267
|
+
value,
|
|
268
|
+
textAttributes,
|
|
269
|
+
textDecorationColor,
|
|
270
|
+
"textDecorationColor");
|
|
271
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
272
|
+
defaults,
|
|
273
|
+
value,
|
|
274
|
+
textAttributes,
|
|
275
|
+
textDecorationLineType,
|
|
276
|
+
"textDecorationLine");
|
|
277
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
278
|
+
defaults,
|
|
279
|
+
value,
|
|
280
|
+
textAttributes,
|
|
281
|
+
textDecorationStyle,
|
|
282
|
+
"textDecorationStyle");
|
|
283
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
284
|
+
defaults, value, textAttributes, textShadowOffset, "textShadowOffset");
|
|
285
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
286
|
+
defaults, value, textAttributes, textShadowRadius, "textShadowRadius");
|
|
287
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
288
|
+
defaults, value, textAttributes, textShadowColor, "textShadowColor");
|
|
289
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
290
|
+
defaults, value, textAttributes, isHighlighted, "isHighlighted");
|
|
291
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
292
|
+
defaults,
|
|
293
|
+
value,
|
|
294
|
+
textAttributes,
|
|
295
|
+
accessibilityRole,
|
|
296
|
+
"accessibilityRole");
|
|
297
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
298
|
+
defaults, value, textAttributes, opacity, "opacity");
|
|
299
|
+
REBUILD_FIELD_SWITCH_CASE(
|
|
300
|
+
defaults, value, textAttributes, backgroundColor, "backgroundColor");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
#pragma mark - DebugStringConvertible
|
|
305
|
+
|
|
306
|
+
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
307
|
+
SharedDebugStringConvertibleList BaseTextProps::getDebugProps() const {
|
|
308
|
+
return textAttributes.getDebugProps();
|
|
309
|
+
}
|
|
310
|
+
#endif
|
|
311
|
+
|
|
312
|
+
} // namespace react
|
|
313
|
+
} // namespace facebook
|