react-native-macos 0.77.6 → 0.77.7
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/Blob/RCTBlobManager.h +0 -0
- package/Libraries/Blob/RCTBlobManager.mm +0 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +0 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Network/RCTDataRequestHandler.mm +17 -3
- package/Libraries/Network/RCTFileRequestHandler.mm +17 -3
- package/Libraries/StyleSheet/normalizeColor.js +0 -0
- package/React/Base/RCTJavaScriptLoader.h +0 -0
- package/React/Base/RCTJavaScriptLoader.mm +0 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/DevSupport/RCTPausedInDebuggerOverlayController.mm +3 -5
- package/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +18 -4
- package/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +1 -4
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +22 -3
- package/React/Fabric/Mounting/ComponentViews/Switch/RCTSwitchComponentView.mm +1 -1
- package/React/Fabric/Surface/RCTFabricSurface.mm +1 -0
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +13 -8
- package/ReactAndroid/src/main/java/com/facebook/react/modules/statusbar/StatusBarModule.kt +3 -16
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/DisplayMetricsHolder.kt +13 -0
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +0 -3
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/style/BorderRadiusStyle.kt +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.kt +39 -0
- package/ReactCommon/React-FabricComponents.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/renderer/components/modal/CMakeLists.txt +4 -1
- package/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h +3 -2
- package/ReactCommon/react/renderer/components/modal/ModalHostViewState.h +4 -12
- package/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.h +2 -2
- package/ReactCommon/react/renderer/components/modal/ModalHostViewUtils.mm +1 -1
- package/ReactCommon/react/renderer/components/modal/platform/android/JReactModalHostView.h +38 -0
- package/ReactCommon/react/renderer/components/modal/platform/android/ModalHostViewUtils.cpp +18 -0
- package/ReactCommon/react/renderer/components/modal/platform/cxx/ModalHostViewUtils.cpp +17 -0
- package/ReactCommon/react/renderer/components/scrollview/ScrollEvent.cpp +33 -0
- package/ReactCommon/react/renderer/components/scrollview/ScrollEvent.h +17 -0
- package/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.cpp +3 -2
- package/ReactCommon/react/renderer/components/scrollview/ScrollViewEventEmitter.h +2 -1
- package/ReactCommon/react/runtime/TimerManager.cpp +6 -4
- package/ReactCommon/react/runtime/TimerManager.h +3 -1
- package/ReactCommon/react/runtime/tests/cxx/ReactInstanceTest.cpp +9 -5
- package/local-cli/cli.js +0 -0
- package/package.json +12 -12
- package/scripts/cocoapods/autolinking.rb +206 -0
- package/scripts/cocoapods/autolinking_utils.rb +25 -0
- package/scripts/cocoapods/codegen.rb +59 -0
- package/scripts/cocoapods/codegen_script_phase_extractor.rb +13 -0
- package/scripts/cocoapods/codegen_utils.rb +389 -0
- package/scripts/cocoapods/fabric.rb +18 -0
- package/scripts/cocoapods/helpers.rb +150 -0
- package/scripts/cocoapods/jsengine.rb +33 -0
- package/scripts/cocoapods/local_podspec_patch.rb +51 -0
- package/scripts/cocoapods/new_architecture.rb +194 -0
- package/scripts/cocoapods/privacy_manifest_utils.rb +194 -0
- package/scripts/cocoapods/runtime.rb +18 -0
- package/scripts/cocoapods/spm.rb +94 -0
- package/scripts/cocoapods/utils.rb +729 -0
- package/scripts/codegen/codegen-utils.js +51 -0
- package/scripts/codegen/generate-artifacts-executor.js +982 -0
- package/scripts/codegen/generate-specs-cli-executor.js +128 -0
- package/scripts/codegen/templates/RCTAppDependencyProviderH.template +25 -0
- package/scripts/codegen/templates/RCTAppDependencyProviderMM.template +55 -0
- package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderH.template +18 -0
- package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderMM.template +33 -0
- package/scripts/codegen/templates/RCTThirdPartyComponentsProviderH.template +16 -0
- package/scripts/codegen/templates/RCTThirdPartyComponentsProviderMM.template +23 -0
- package/scripts/codegen/templates/ReactAppDependencyProvider.podspec.template +34 -0
- package/scripts/compose-source-maps.js +0 -0
- package/scripts/ios-configure-glog.sh +0 -0
- package/scripts/node-binary.sh +0 -0
- package/scripts/packager.sh +0 -0
- package/scripts/react-native-xcode.sh +0 -0
- package/scripts/react_native_pods_utils/script_phases.sh +0 -0
- package/scripts/xcode/ccache-clang++.sh +0 -0
- package/scripts/xcode/ccache-clang.sh +0 -0
- package/scripts/xcode/with-environment.sh +0 -0
- package/sdks/hermes-engine/hermes-engine.podspec +168 -0
- package/sdks/hermes-engine/hermes-utils.rb +341 -0
- package/sdks/hermes-engine/utils/build-apple-framework.sh +225 -0
- package/sdks/hermes-engine/utils/build-hermes-xcode.sh +100 -0
- package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +18 -0
- package/sdks/hermes-engine/utils/build-ios-framework.sh +90 -0
- package/sdks/hermes-engine/utils/build-mac-framework.sh +22 -0
- package/sdks/hermes-engine/utils/copy-hermes-xcode.sh +7 -0
- package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +32 -0
- package/sdks/hermes-engine/utils/replace_hermes_version.js +106 -0
- package/scripts/featureflags/README.md +0 -156
- package/scripts/featureflags/index.js +0 -39
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <react/renderer/graphics/Size.h>
|
|
12
|
+
|
|
13
|
+
namespace facebook::react {
|
|
14
|
+
|
|
15
|
+
class JReactModalHostView
|
|
16
|
+
: public facebook::jni::JavaClass<JReactModalHostView> {
|
|
17
|
+
public:
|
|
18
|
+
static auto constexpr kJavaDescriptor =
|
|
19
|
+
"Lcom/facebook/react/views/modal/ReactModalHostView;";
|
|
20
|
+
|
|
21
|
+
static Size getDisplayMetrics() {
|
|
22
|
+
static auto method =
|
|
23
|
+
JReactModalHostView::javaClassStatic()->getStaticMethod<jlong()>(
|
|
24
|
+
"getScreenDisplayMetricsWithoutInsets");
|
|
25
|
+
auto result = method(javaClassStatic());
|
|
26
|
+
|
|
27
|
+
// Inspired from yogaMeassureToSize from conversions.h
|
|
28
|
+
int32_t wBits = 0xFFFFFFFF & (result >> 32);
|
|
29
|
+
int32_t hBits = 0xFFFFFFFF & result;
|
|
30
|
+
|
|
31
|
+
auto* measuredWidth = reinterpret_cast<float*>(&wBits);
|
|
32
|
+
auto* measuredHeight = reinterpret_cast<float*>(&hBits);
|
|
33
|
+
|
|
34
|
+
return Size{.width = *measuredWidth, .height = *measuredHeight};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,18 @@
|
|
|
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 <react/renderer/components/modal/ModalHostViewUtils.h>
|
|
9
|
+
#include <react/renderer/graphics/Size.h>
|
|
10
|
+
#include "JReactModalHostView.h"
|
|
11
|
+
|
|
12
|
+
namespace facebook::react {
|
|
13
|
+
|
|
14
|
+
Size ModalHostViewScreenSize() {
|
|
15
|
+
return JReactModalHostView::getDisplayMetrics();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
} // namespace facebook::react
|
|
@@ -0,0 +1,17 @@
|
|
|
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 <react/renderer/components/modal/ModalHostViewUtils.h>
|
|
9
|
+
#include <react/renderer/graphics/Size.h>
|
|
10
|
+
|
|
11
|
+
namespace facebook::react {
|
|
12
|
+
|
|
13
|
+
Size ModalHostViewScreenSize() {
|
|
14
|
+
return Size{0, 0};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
} // namespace facebook::react
|
|
@@ -76,6 +76,39 @@ EventPayloadType ScrollEvent::getType() const {
|
|
|
76
76
|
return EventPayloadType::ScrollEvent;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
jsi::Value ScrollEndDragEvent::asJSIValue(jsi::Runtime& runtime) const {
|
|
80
|
+
auto payload = ScrollEvent::asJSIValue(runtime).asObject(runtime);
|
|
81
|
+
|
|
82
|
+
{
|
|
83
|
+
auto targetContentOffsetObj = jsi::Object(runtime);
|
|
84
|
+
targetContentOffsetObj.setProperty(runtime, "x", targetContentOffset.x);
|
|
85
|
+
targetContentOffsetObj.setProperty(runtime, "y", targetContentOffset.y);
|
|
86
|
+
payload.setProperty(runtime, "targetContentOffset", targetContentOffsetObj);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
{
|
|
90
|
+
auto velocityObj = jsi::Object(runtime);
|
|
91
|
+
velocityObj.setProperty(runtime, "x", velocity.x);
|
|
92
|
+
velocityObj.setProperty(runtime, "y", velocity.y);
|
|
93
|
+
payload.setProperty(runtime, "velocity", velocityObj);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return payload;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
folly::dynamic ScrollEndDragEvent::asDynamic() const {
|
|
100
|
+
auto metrics = ScrollEvent::asDynamic();
|
|
101
|
+
|
|
102
|
+
auto targetContentOffsetObj = folly::dynamic::object(
|
|
103
|
+
"x", targetContentOffset.x)("y", targetContentOffset.y);
|
|
104
|
+
metrics["targetContentOffset"] = std::move(targetContentOffsetObj);
|
|
105
|
+
|
|
106
|
+
auto velocityObj = folly::dynamic::object("x", velocity.x)("y", velocity.y);
|
|
107
|
+
metrics["velocity"] = std::move(velocityObj);
|
|
108
|
+
|
|
109
|
+
return metrics;
|
|
110
|
+
};
|
|
111
|
+
|
|
79
112
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
80
113
|
|
|
81
114
|
std::string getDebugName(const ScrollEvent& /*scrollEvent*/) {
|
|
@@ -37,6 +37,23 @@ struct ScrollEvent : public EventPayload {
|
|
|
37
37
|
EventPayloadType getType() const override;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
struct ScrollEndDragEvent : public ScrollEvent {
|
|
41
|
+
Point targetContentOffset;
|
|
42
|
+
Point velocity;
|
|
43
|
+
|
|
44
|
+
ScrollEndDragEvent() = default;
|
|
45
|
+
|
|
46
|
+
ScrollEndDragEvent(const ScrollEvent& scrollEvent)
|
|
47
|
+
: ScrollEvent(scrollEvent), targetContentOffset({}), velocity({}) {}
|
|
48
|
+
|
|
49
|
+
folly::dynamic asDynamic() const;
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* EventPayload implementations
|
|
53
|
+
*/
|
|
54
|
+
jsi::Value asJSIValue(jsi::Runtime& runtime) const override;
|
|
55
|
+
};
|
|
56
|
+
|
|
40
57
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
41
58
|
|
|
42
59
|
std::string getDebugName(const ScrollEvent& scrollEvent);
|
|
@@ -25,8 +25,9 @@ void ScrollViewEventEmitter::onScrollBeginDrag(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
void ScrollViewEventEmitter::onScrollEndDrag(
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const ScrollEndDragEvent& scrollEvent) const {
|
|
29
|
+
dispatchEvent(
|
|
30
|
+
"scrollEndDrag", std::make_shared<ScrollEndDragEvent>(scrollEvent));
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
void ScrollViewEventEmitter::onMomentumScrollBegin(
|
|
@@ -21,10 +21,11 @@ class ScrollViewEventEmitter : public ViewEventEmitter {
|
|
|
21
21
|
using ViewEventEmitter::ViewEventEmitter;
|
|
22
22
|
|
|
23
23
|
using Metrics = ScrollEvent;
|
|
24
|
+
using EndDragMetrics = ScrollEndDragEvent;
|
|
24
25
|
|
|
25
26
|
void onScroll(const ScrollEvent& scrollEvent) const;
|
|
26
27
|
void onScrollBeginDrag(const ScrollEvent& scrollEvent) const;
|
|
27
|
-
void onScrollEndDrag(const
|
|
28
|
+
void onScrollEndDrag(const ScrollEndDragEvent& scrollEvent) const;
|
|
28
29
|
void onMomentumScrollBegin(const ScrollEvent& scrollEvent) const;
|
|
29
30
|
void onMomentumScrollEnd(const ScrollEvent& scrollEvent) const;
|
|
30
31
|
void onScrollToTop(const ScrollEvent& scrollEvent) const;
|
|
@@ -300,8 +300,9 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
if (!args[0].isObject() || !args[0].asObject(rt).isFunction(rt)) {
|
|
303
|
-
// Do not throw any error to match web spec
|
|
304
|
-
|
|
303
|
+
// Do not throw any error to match web spec; instead return 0, an
|
|
304
|
+
// invalid timer id
|
|
305
|
+
return 0;
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
auto callback = args[0].getObject(rt).getFunction(rt);
|
|
@@ -358,8 +359,9 @@ void TimerManager::attachGlobals(jsi::Runtime& runtime) {
|
|
|
358
359
|
}
|
|
359
360
|
|
|
360
361
|
if (!args[0].isObject() || !args[0].asObject(rt).isFunction(rt)) {
|
|
361
|
-
throw
|
|
362
|
-
|
|
362
|
+
// Do not throw any error to match web spec; instead return 0, an
|
|
363
|
+
// invalid timer id
|
|
364
|
+
return 0;
|
|
363
365
|
}
|
|
364
366
|
auto callback = args[0].getObject(rt).getFunction(rt);
|
|
365
367
|
auto delay = count > 1
|
|
@@ -93,7 +93,9 @@ class TimerManager {
|
|
|
93
93
|
|
|
94
94
|
// Each timeout that is registered on this queue gets a sequential id. This
|
|
95
95
|
// is the global count from which those are assigned.
|
|
96
|
-
|
|
96
|
+
// As per WHATWG HTML 8.6.1 (Timers) ids must be greater than zero, i.e. start
|
|
97
|
+
// at 1
|
|
98
|
+
TimerHandle timerIndex_{1};
|
|
97
99
|
|
|
98
100
|
// The React Native microtask queue is used to back public APIs including
|
|
99
101
|
// `queueMicrotask`, `clearImmediate`, and `setImmediate` (which is used by
|
|
@@ -266,7 +266,9 @@ TEST_F(ReactInstanceTest, testSetTimeoutWithoutDelay) {
|
|
|
266
266
|
EXPECT_CALL(
|
|
267
267
|
*mockRegistry_,
|
|
268
268
|
createTimer(_, 0)); // If delay is not provided, it should use 0
|
|
269
|
-
eval("setTimeout(() => {});");
|
|
269
|
+
auto val = eval("setTimeout(() => {});");
|
|
270
|
+
expectNoError();
|
|
271
|
+
EXPECT_EQ(val.asNumber(), 1); // First timer id should start at 1
|
|
270
272
|
}
|
|
271
273
|
|
|
272
274
|
TEST_F(ReactInstanceTest, testSetTimeoutWithPassThroughArgs) {
|
|
@@ -298,8 +300,9 @@ TEST_F(ReactInstanceTest, testSetTimeoutWithInvalidArgs) {
|
|
|
298
300
|
getErrorMessage("setTimeout();"),
|
|
299
301
|
"setTimeout must be called with at least one argument (the function to call).");
|
|
300
302
|
|
|
301
|
-
eval("setTimeout('invalid')
|
|
303
|
+
auto val = eval("setTimeout('invalid')");
|
|
302
304
|
expectNoError();
|
|
305
|
+
EXPECT_EQ(val.asNumber(), 0);
|
|
303
306
|
|
|
304
307
|
eval("setTimeout(() => {}, 'invalid');");
|
|
305
308
|
expectNoError();
|
|
@@ -416,9 +419,10 @@ TEST_F(ReactInstanceTest, testSetIntervalWithInvalidArgs) {
|
|
|
416
419
|
EXPECT_EQ(
|
|
417
420
|
getErrorMessage("setInterval();"),
|
|
418
421
|
"setInterval must be called with at least one argument (the function to call).");
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
+
|
|
423
|
+
auto val = eval("setInterval('invalid', 100)");
|
|
424
|
+
expectNoError();
|
|
425
|
+
EXPECT_EQ(val.asNumber(), 0);
|
|
422
426
|
}
|
|
423
427
|
|
|
424
428
|
TEST_F(ReactInstanceTest, testClearInterval) {
|
package/local-cli/cli.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-macos",
|
|
3
|
-
"version": "0.77.
|
|
3
|
+
"version": "0.77.7",
|
|
4
4
|
"description": "React Native for macOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"peerDependencies": {
|
|
103
103
|
"@types/react": "^18.2.6",
|
|
104
104
|
"react": "^18.2.0",
|
|
105
|
-
"react-native": "0.77.
|
|
105
|
+
"react-native": "0.77.3"
|
|
106
106
|
},
|
|
107
107
|
"peerDependenciesMeta": {
|
|
108
108
|
"@types/react": {
|
|
@@ -111,13 +111,13 @@
|
|
|
111
111
|
},
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@jest/create-cache-key-function": "^29.6.3",
|
|
114
|
-
"@react-native-macos/virtualized-lists": "0.77.
|
|
115
|
-
"@react-native/assets-registry": "0.77.
|
|
116
|
-
"@react-native/codegen": "0.77.
|
|
117
|
-
"@react-native/community-cli-plugin": "0.77.
|
|
118
|
-
"@react-native/gradle-plugin": "0.77.
|
|
119
|
-
"@react-native/js-polyfills": "0.77.
|
|
120
|
-
"@react-native/normalize-colors": "0.77.
|
|
114
|
+
"@react-native-macos/virtualized-lists": "0.77.7",
|
|
115
|
+
"@react-native/assets-registry": "0.77.3",
|
|
116
|
+
"@react-native/codegen": "0.77.3",
|
|
117
|
+
"@react-native/community-cli-plugin": "0.77.3",
|
|
118
|
+
"@react-native/gradle-plugin": "0.77.3",
|
|
119
|
+
"@react-native/js-polyfills": "0.77.3",
|
|
120
|
+
"@react-native/normalize-colors": "0.77.3",
|
|
121
121
|
"abort-controller": "^3.0.0",
|
|
122
122
|
"anser": "^1.4.9",
|
|
123
123
|
"ansi-regex": "^5.0.0",
|
|
@@ -133,8 +133,8 @@
|
|
|
133
133
|
"jest-environment-node": "^29.6.3",
|
|
134
134
|
"jsc-android": "^250231.0.0",
|
|
135
135
|
"memoize-one": "^5.0.0",
|
|
136
|
-
"metro-runtime": "^0.81.
|
|
137
|
-
"metro-source-map": "^0.81.
|
|
136
|
+
"metro-runtime": "^0.81.5",
|
|
137
|
+
"metro-source-map": "^0.81.5",
|
|
138
138
|
"nullthrows": "^1.1.1",
|
|
139
139
|
"pretty-format": "^29.7.0",
|
|
140
140
|
"promise": "^8.3.0",
|
|
@@ -166,4 +166,4 @@
|
|
|
166
166
|
}
|
|
167
167
|
]
|
|
168
168
|
}
|
|
169
|
-
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
require 'json'
|
|
7
|
+
require 'pathname'
|
|
8
|
+
require 'cocoapods'
|
|
9
|
+
require_relative './autolinking_utils.rb'
|
|
10
|
+
require_relative '../react_native_pods.rb'
|
|
11
|
+
|
|
12
|
+
# Your project will have to depend on the @react-native-community/cli if you use this method
|
|
13
|
+
# for listing React native modules.
|
|
14
|
+
#
|
|
15
|
+
# Parameters:
|
|
16
|
+
# - config_command: the command to run to get the application's current config, e.g. ['npx', '@react-native-community/cli', 'config']
|
|
17
|
+
def list_native_modules!(config_command)
|
|
18
|
+
|
|
19
|
+
if !(config_command.is_a? Array and config_command.size > 0)
|
|
20
|
+
Pod::UI.warn "Expected a list_native_modules! to be called with a config command", [
|
|
21
|
+
"Unable to autolink if no config is provided for the current project."
|
|
22
|
+
]
|
|
23
|
+
exit(1)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Ignore stderr output, we're only interested in stdout and the return code. Libraries can output warnings to
|
|
27
|
+
# stderr which create problems for JSON deserializing.
|
|
28
|
+
json, _, status = Pod::Executable.capture_command(config_command[0], config_command[1..], capture: :both)
|
|
29
|
+
|
|
30
|
+
if not status.success?
|
|
31
|
+
Pod::UI.warn "The command: '#{config_command.join(" ").bold.yellow}' returned a status code of #{status.exitstatus.to_s.bold.red}", [
|
|
32
|
+
"In order to autolink using Cocoapods, this framework uses @react-native-community/cli to discover React Native native modules",
|
|
33
|
+
"Please either add it: yarn add -D @react-native-community/cli or consult your framework's documentation."
|
|
34
|
+
]
|
|
35
|
+
exit(status.exitstatus)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
config = JSON.parse(json)
|
|
39
|
+
|
|
40
|
+
packages = config["dependencies"]
|
|
41
|
+
ios_project_root = Pathname.new(config["project"]["ios"]["sourceDir"])
|
|
42
|
+
react_native_path = Pathname.new(config["reactNativePath"])
|
|
43
|
+
found_pods = []
|
|
44
|
+
|
|
45
|
+
packages.each do |package_name, package|
|
|
46
|
+
next unless package_config = package["platforms"]["ios"]
|
|
47
|
+
|
|
48
|
+
name = package["name"]
|
|
49
|
+
podspec_path = package_config["podspecPath"]
|
|
50
|
+
script_phases = package_config["scriptPhases"]
|
|
51
|
+
configurations = package_config["configurations"]
|
|
52
|
+
|
|
53
|
+
# Add a warning to the queue and continue to the next dependency if the podspec_path is nil/empty
|
|
54
|
+
if podspec_path.nil? || podspec_path.empty?
|
|
55
|
+
Pod::UI.warn("list_native_modules! skipped the react-native dependency '#{name}'. No podspec file was found.",
|
|
56
|
+
[
|
|
57
|
+
"Check to see if there is an updated version that contains the necessary podspec file",
|
|
58
|
+
"Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven podspec. See https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec",
|
|
59
|
+
"If necessary, you can disable autolinking for the dependency and link it manually. See https://github.com/react-native-community/cli/blob/main/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library"
|
|
60
|
+
])
|
|
61
|
+
next
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
spec = Pod::Specification.from_file(podspec_path)
|
|
65
|
+
|
|
66
|
+
# Skip pods that do not support the platform of the current target.
|
|
67
|
+
next unless AutolinkingUtils.is_platform_supported?(current_target_definition, spec)
|
|
68
|
+
|
|
69
|
+
podspec_dir_path = Pathname.new(File.dirname(podspec_path))
|
|
70
|
+
|
|
71
|
+
relative_path = podspec_dir_path.relative_path_from ios_project_root
|
|
72
|
+
|
|
73
|
+
found_pods.push({
|
|
74
|
+
"configurations": configurations,
|
|
75
|
+
"name": name,
|
|
76
|
+
"root": package["root"],
|
|
77
|
+
"path": relative_path.to_path,
|
|
78
|
+
"podspec_path": podspec_path,
|
|
79
|
+
"script_phases": script_phases
|
|
80
|
+
})
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
if found_pods.size > 0
|
|
84
|
+
pods = found_pods.map { |p| p[:name] }.sort.to_sentence
|
|
85
|
+
Pod::UI.puts "Found #{found_pods.size} #{"module".pluralize(found_pods.size)} for target `#{current_target_definition.name}`"
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
"ios_packages": found_pods,
|
|
90
|
+
"ios_project_root_path": ios_project_root.to_s,
|
|
91
|
+
"react_native_path": react_native_path.relative_path_from(ios_project_root).to_s
|
|
92
|
+
}
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Your project will have to depend on the @react-native-community/cli if you use this method
|
|
96
|
+
# for listing React native modules.
|
|
97
|
+
#
|
|
98
|
+
# Parameters:
|
|
99
|
+
# - config:
|
|
100
|
+
# - :ios_packages - Array of React Native iOS packages, e.g. [{ package_name: "Foo", package: { .. }}, ...]
|
|
101
|
+
# - :ios_project_root_path - Absolute path to the react_native project's ios folder, e.g. /Users/foobar/project/rn_project/ios
|
|
102
|
+
# - :react_native_path - Relative path to the react_native from the project, e.g. ./node_modules/react-native
|
|
103
|
+
def link_native_modules!(config)
|
|
104
|
+
Pod::UI.puts "link_native_modules! #{config}"
|
|
105
|
+
|
|
106
|
+
if !(
|
|
107
|
+
config[:ios_packages].is_a? Array and
|
|
108
|
+
config[:ios_project_root_path].is_a? String and
|
|
109
|
+
config[:react_native_path].is_a? String
|
|
110
|
+
)
|
|
111
|
+
Pod::UI.warn("link_native_modules! has been called with a malformed 'config' parameter",
|
|
112
|
+
[
|
|
113
|
+
"This is the config argument passed: #{config.inspect}",
|
|
114
|
+
]);
|
|
115
|
+
exit(1)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
ios_project_root = config[:ios_project_root_path]
|
|
119
|
+
|
|
120
|
+
packages = config[:ios_packages]
|
|
121
|
+
found_pods = []
|
|
122
|
+
|
|
123
|
+
packages.each do |package|
|
|
124
|
+
podspec_path = package[:podspec_path]
|
|
125
|
+
configurations = package[:configurations]
|
|
126
|
+
|
|
127
|
+
# Add a warning to the queue and continue to the next dependency if the podspec_path is nil/empty
|
|
128
|
+
if podspec_path.nil? || podspec_path.empty?
|
|
129
|
+
Pod::UI.warn("use_native_modules! skipped the react-native dependency '#{package[:name]}'. No podspec file was found.",
|
|
130
|
+
[
|
|
131
|
+
"Check to see if there is an updated version that contains the necessary podspec file",
|
|
132
|
+
"Contact the library maintainers or send them a PR to add a podspec. The react-native-webview podspec is a good example of a package.json driven podspec. See https://github.com/react-native-community/react-native-webview/blob/master/react-native-webview.podspec",
|
|
133
|
+
"If necessary, you can disable autolinking for the dependency and link it manually. See https://github.com/react-native-community/cli/blob/main/docs/autolinking.md#how-can-i-disable-autolinking-for-unsupported-library"
|
|
134
|
+
])
|
|
135
|
+
next
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
spec = Pod::Specification.from_file(podspec_path)
|
|
139
|
+
|
|
140
|
+
# Don't try track packages that exclude our platforms
|
|
141
|
+
next unless AutolinkingUtils.is_platform_supported?(current_target_definition, spec)
|
|
142
|
+
|
|
143
|
+
# We want to do a look up inside the current CocoaPods target
|
|
144
|
+
# to see if it's already included, this:
|
|
145
|
+
# 1. Gives you the chance to define it beforehand
|
|
146
|
+
# 2. Ensures CocoaPods won't explode if it's included twice
|
|
147
|
+
#
|
|
148
|
+
this_target = current_target_definition
|
|
149
|
+
existing_deps = current_target_definition.dependencies
|
|
150
|
+
|
|
151
|
+
# Skip dependencies that the user already activated themselves.
|
|
152
|
+
next if existing_deps.find do |existing_dep|
|
|
153
|
+
existing_dep.name.split('/').first == spec.name
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
podspec_dir_path = Pathname.new(File.dirname(podspec_path))
|
|
157
|
+
|
|
158
|
+
relative_path = podspec_dir_path.relative_path_from ios_project_root
|
|
159
|
+
|
|
160
|
+
# Register the found React Native module into our collection of Pods.
|
|
161
|
+
pod spec.name, :path => relative_path.to_path, :configurations => configurations
|
|
162
|
+
|
|
163
|
+
if package[:script_phases] && !this_target.abstract?
|
|
164
|
+
# Can be either an object, or an array of objects
|
|
165
|
+
Array(package[:script_phases]).each do |phase|
|
|
166
|
+
# see https://www.rubydoc.info/gems/cocoapods-core/Pod/Podfile/DSL#script_phase-instance_method
|
|
167
|
+
# for the full object keys
|
|
168
|
+
Pod::UI.puts "Adding a custom script phase for Pod #{spec.name}: #{phase["name"] || 'No name specified.'}"
|
|
169
|
+
|
|
170
|
+
# Support passing in a path relative to the root of the package
|
|
171
|
+
if phase["path"]
|
|
172
|
+
phase["script"] = File.read(File.expand_path(phase["path"], package[:root]))
|
|
173
|
+
phase.delete("path")
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Support converting the execution position into a symbol
|
|
177
|
+
phase["execution_position"] = phase["execution_position"]&.to_sym
|
|
178
|
+
|
|
179
|
+
phase = Hash[phase.map { |k, v| [k.to_sym, v] }]
|
|
180
|
+
script_phase phase
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
found_pods.push spec
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
if found_pods.size > 0
|
|
188
|
+
pods = found_pods.map { |p| p.name }.sort.to_sentence
|
|
189
|
+
Pod::UI.puts "Auto-linking React Native #{"module".pluralize(found_pods.size)} for target `#{current_target_definition.name}`: #{pods}"
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
return {
|
|
193
|
+
:reactNativePath => config[:react_native_path]
|
|
194
|
+
}
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
$default_command = ['node', '-e', "process.argv=['', '', 'config'];require('@react-native-community/cli').run()"];
|
|
198
|
+
|
|
199
|
+
# Autolink your native modules
|
|
200
|
+
#
|
|
201
|
+
# Parameters:
|
|
202
|
+
# - config_command: the command to run to get the application's current config, e.g. ['npx', '@react-native-community/cli', 'config'],
|
|
203
|
+
# you can override this if you'd like to avoid the dependency. e.g. ['cat', 'your_config.json']
|
|
204
|
+
def use_native_modules!(config_command = $default_command)
|
|
205
|
+
return link_native_modules!(list_native_modules!(config_command))
|
|
206
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
class AutolinkingUtils
|
|
7
|
+
|
|
8
|
+
def self.nested_path_exists?(object, *path)
|
|
9
|
+
path.reduce(object) do |obj, method|
|
|
10
|
+
return false unless obj.respond_to?(method)
|
|
11
|
+
obj.public_send(method)
|
|
12
|
+
end
|
|
13
|
+
return true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.is_platform_supported?(current_target_definition, spec)
|
|
17
|
+
platform = current_target_definition.platform
|
|
18
|
+
if !platform
|
|
19
|
+
# Historically we've supported platforms that aren't specifically excluded.
|
|
20
|
+
return true
|
|
21
|
+
end
|
|
22
|
+
return spec.supported_on_platform?(platform.name)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
require_relative './helpers.rb'
|
|
7
|
+
|
|
8
|
+
# It builds the codegen CLI if it is not present
|
|
9
|
+
#
|
|
10
|
+
# Parameters:
|
|
11
|
+
# - react_native_path: the path to the react native installation
|
|
12
|
+
# - relative_installation_root: the path to the relative installation root of the pods
|
|
13
|
+
# - dir_manager: a class that implements the `Dir` interface. Defaults to `Dir`, the Dependency can be injected for testing purposes.
|
|
14
|
+
# @throws an error if it could not find the codegen folder.
|
|
15
|
+
def build_codegen!(react_native_path, relative_installation_root, dir_manager: Dir)
|
|
16
|
+
codegen_repo_path = "#{basePath(react_native_path, relative_installation_root)}/../react-native-codegen"
|
|
17
|
+
return unless dir_manager.exist?(codegen_repo_path) && !dir_manager.exist?("#{codegen_repo_path}/lib")
|
|
18
|
+
|
|
19
|
+
Pod::UI.puts "[Codegen] building #{codegen_repo_path}"
|
|
20
|
+
system("#{codegen_repo_path}/scripts/oss/build.sh")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# keeping the run_codegen! method for testing purposes
|
|
24
|
+
def run_codegen!(
|
|
25
|
+
app_path,
|
|
26
|
+
config_file_dir,
|
|
27
|
+
new_arch_enabled: false,
|
|
28
|
+
disable_codegen: false,
|
|
29
|
+
react_native_path: "../node_modules/react-native",
|
|
30
|
+
fabric_enabled: false,
|
|
31
|
+
hermes_enabled: true,
|
|
32
|
+
codegen_output_dir: 'build/generated/ios',
|
|
33
|
+
config_key: 'codegenConfig',
|
|
34
|
+
package_json_file: '~/app/package.json',
|
|
35
|
+
folly_version: Helpers::Constants.folly_config()[:version],
|
|
36
|
+
codegen_utils: CodegenUtils.new()
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
codegen_utils.use_react_native_codegen_discovery!(
|
|
40
|
+
disable_codegen,
|
|
41
|
+
app_path,
|
|
42
|
+
:react_native_path => react_native_path,
|
|
43
|
+
:fabric_enabled => fabric_enabled,
|
|
44
|
+
:hermes_enabled => hermes_enabled,
|
|
45
|
+
:config_file_dir => config_file_dir,
|
|
46
|
+
:codegen_output_dir => codegen_output_dir,
|
|
47
|
+
:config_key => config_key,
|
|
48
|
+
:folly_version => folly_version
|
|
49
|
+
)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def basePath(react_native_path, relative_installation_root)
|
|
53
|
+
expanded_path = File.expand_path(react_native_path)
|
|
54
|
+
if expanded_path == react_native_path
|
|
55
|
+
react_native_path
|
|
56
|
+
else
|
|
57
|
+
File.join(relative_installation_root.to_s, react_native_path)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
class CodegenScriptPhaseExtractor
|
|
7
|
+
def initialize()
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def extract_script_phase(options)
|
|
11
|
+
get_script_phases_with_codegen_discovery(options)
|
|
12
|
+
end
|
|
13
|
+
end
|