react-native-navigation 8.5.0 → 8.6.0-snapshot.2091
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/ReactNativeNavigation.podspec +9 -33
- package/android/src/androidTest/java/com/reactnativenavigation/TestApplication.kt +0 -2
- package/android/src/main/java/com/reactnativenavigation/views/touch/OverlayTouchDelegate.kt +14 -3
- package/android/src/test/java/com/reactnativenavigation/TestApplication.kt +29 -0
- package/autolink/fixtures/rn79/AppDelegate.swift.template +48 -0
- package/autolink/fixtures/rn79/MainActivity.kt.template +22 -0
- package/autolink/fixtures/rn79/MainApplication.kt.template +44 -0
- package/autolink/fixtures/rn79/build.gradle.template +21 -0
- package/autolink/postlink/__helpers__/fixtures.js +2 -0
- package/autolink/postlink/__helpers__/generate_version_header.js +117 -0
- package/autolink/postlink/__helpers__/reactNativeVersion.js +160 -0
- package/autolink/postlink/__snapshots__/{appDelegateLinker.test.js.snap → appDelegateLinker77.test.js.snap} +2 -2
- package/autolink/postlink/__snapshots__/appDelegateLinker79.test.js.snap +39 -0
- package/autolink/postlink/appDelegateLinker.js +76 -2
- package/autolink/postlink/appDelegateLinker77.test.js +51 -0
- package/autolink/postlink/appDelegateLinker79.test.js +32 -0
- package/autolink/postlink/path.js +0 -2
- package/ios/RNNAppDelegate.h +33 -1
- package/ios/RNNAppDelegate.mm +75 -68
- package/ios/RNNRefreshControll.m +91 -0
- package/ios/RNNSideMenu/MMDrawerController/MMDrawerController.mm +6 -1
- package/ios/ReactNativeNavigation.xcodeproj/project.pbxproj +5 -1
- package/lib/typescript/Mock/Components/SideMenu.d.ts +148 -8
- package/lib/typescript/Mock/Components/SideMenu.d.ts.map +1 -1
- package/package.json +17 -15
- package/android/src/test/java/com/reactnativenavigation/TestApplication.java +0 -43
- package/autolink/postlink/appDelegateLinker.test.js +0 -45
|
@@ -1,31 +1,11 @@
|
|
|
1
1
|
require 'json'
|
|
2
|
-
require 'find'
|
|
3
2
|
|
|
4
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
5
|
-
|
|
6
4
|
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
7
5
|
|
|
8
|
-
# Detect if this is a Swift project by looking for user AppDelegate.swift files
|
|
9
|
-
start_dir = File.expand_path('../', __dir__)
|
|
10
|
-
swift_delegate_path = nil
|
|
11
|
-
Find.find(start_dir) do |path|
|
|
12
|
-
if path =~ /AppDelegate\.swift$/
|
|
13
|
-
swift_delegate_path = path
|
|
14
|
-
break
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
swift_project = swift_delegate_path && File.exist?(swift_delegate_path)
|
|
19
|
-
|
|
20
|
-
# Debug output
|
|
21
|
-
if swift_project
|
|
22
|
-
puts "ReactNativeNavigation: Swift AppDelegate detected - enabling Swift-compatible configuration"
|
|
23
|
-
else
|
|
24
|
-
puts "ReactNativeNavigation: Objective-C AppDelegate detected - using standard configuration"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
6
|
Pod::Spec.new do |s|
|
|
28
7
|
s.name = "ReactNativeNavigation"
|
|
8
|
+
s.prepare_command = 'node autolink/postlink/__helpers__/generate_version_header.js'
|
|
29
9
|
s.version = package['version']
|
|
30
10
|
s.summary = package['description']
|
|
31
11
|
|
|
@@ -40,13 +20,12 @@ Pod::Spec.new do |s|
|
|
|
40
20
|
s.subspec 'Core' do |ss|
|
|
41
21
|
s.source = { :git => "https://github.com/wix/react-native-navigation.git", :tag => "#{s.version}" }
|
|
42
22
|
s.source_files = 'ios/**/*.{h,m,mm,cpp}'
|
|
43
|
-
s.exclude_files = "ios/ReactNativeNavigationTests/**/*.*", "
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
end
|
|
23
|
+
s.exclude_files = "ios/ReactNativeNavigationTests/**/*.*", "ios/OCMock/**/*.*"
|
|
24
|
+
|
|
25
|
+
s.public_header_files = [
|
|
26
|
+
'ios/RNNAppDelegate.h',
|
|
27
|
+
'ios/ReactNativeVersionExtracted.h'
|
|
28
|
+
]
|
|
50
29
|
end
|
|
51
30
|
|
|
52
31
|
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32 -DFOLLY_CFG_NO_COROUTINES=1'
|
|
@@ -58,11 +37,8 @@ Pod::Spec.new do |s|
|
|
|
58
37
|
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
59
38
|
}
|
|
60
39
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
xcconfig_settings["DEFINES_MODULE"] = "YES"
|
|
64
|
-
end
|
|
65
|
-
|
|
40
|
+
xcconfig_settings["DEFINES_MODULE"] = "YES"
|
|
41
|
+
|
|
66
42
|
s.pod_target_xcconfig = xcconfig_settings
|
|
67
43
|
|
|
68
44
|
if fabric_enabled
|
|
@@ -3,10 +3,8 @@ package com.reactnativenavigation
|
|
|
3
3
|
import com.facebook.react.ReactHost
|
|
4
4
|
import com.facebook.react.ReactNativeHost
|
|
5
5
|
import com.facebook.react.ReactPackage
|
|
6
|
-
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
|
|
7
6
|
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
|
8
7
|
import com.facebook.react.shell.MainReactPackage
|
|
9
|
-
import com.reactnativenavigation.NavigationPackage
|
|
10
8
|
import com.reactnativenavigation.react.NavigationReactNativeHost
|
|
11
9
|
|
|
12
10
|
class TestApplication : NavigationApplication() {
|
|
@@ -4,7 +4,6 @@ import android.view.MotionEvent
|
|
|
4
4
|
import android.view.View
|
|
5
5
|
import android.view.ViewGroup
|
|
6
6
|
import androidx.annotation.VisibleForTesting
|
|
7
|
-
import com.facebook.react.views.debuggingoverlay.DebuggingOverlay
|
|
8
7
|
import com.reactnativenavigation.options.params.Bool
|
|
9
8
|
import com.reactnativenavigation.options.params.NullBool
|
|
10
9
|
import com.reactnativenavigation.react.ReactView
|
|
@@ -57,7 +56,19 @@ open class OverlayTouchDelegate(
|
|
|
57
56
|
return false
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
private fun debuggingOverlay(childItem: View?): Boolean
|
|
61
|
-
childItem is ViewGroup
|
|
59
|
+
private fun debuggingOverlay(childItem: View?): Boolean {
|
|
60
|
+
if (childItem !is ViewGroup) return false
|
|
61
|
+
val firstChild = childItem.getChildAt(0) ?: return false
|
|
62
|
+
return isDebuggingOverlay(firstChild)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private fun isDebuggingOverlay(view: View): Boolean {
|
|
66
|
+
return try {
|
|
67
|
+
val className = view.javaClass.name
|
|
68
|
+
className == "com.facebook.react.views.debuggingoverlay.DebuggingOverlay"
|
|
69
|
+
} catch (e: Exception) {
|
|
70
|
+
false
|
|
71
|
+
}
|
|
72
|
+
}
|
|
62
73
|
|
|
63
74
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package com.reactnativenavigation
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import androidx.appcompat.R
|
|
5
|
+
import com.facebook.react.ReactApplication
|
|
6
|
+
import com.facebook.react.ReactHost
|
|
7
|
+
import com.facebook.react.ReactNativeHost
|
|
8
|
+
import com.facebook.react.ReactPackage
|
|
9
|
+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
|
10
|
+
|
|
11
|
+
class TestApplication : Application(), ReactApplication {
|
|
12
|
+
override val reactNativeHost: ReactNativeHost = object : ReactNativeHost(this) {
|
|
13
|
+
override fun getUseDeveloperSupport(): Boolean {
|
|
14
|
+
return true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
override fun getPackages(): MutableList<ReactPackage> {
|
|
18
|
+
return mutableListOf()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun onCreate() {
|
|
23
|
+
super.onCreate()
|
|
24
|
+
setTheme(R.style.Theme_AppCompat)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override val reactHost: ReactHost
|
|
28
|
+
get() = getDefaultReactHost(this, reactNativeHost)
|
|
29
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import React
|
|
3
|
+
import React_RCTAppDelegate
|
|
4
|
+
import ReactAppDependencyProvider
|
|
5
|
+
|
|
6
|
+
@main
|
|
7
|
+
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
8
|
+
var window: UIWindow?
|
|
9
|
+
|
|
10
|
+
var reactNativeDelegate: ReactNativeDelegate?
|
|
11
|
+
var reactNativeFactory: RCTReactNativeFactory?
|
|
12
|
+
|
|
13
|
+
func application(
|
|
14
|
+
_ application: UIApplication,
|
|
15
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
16
|
+
) -> Bool {
|
|
17
|
+
let delegate = ReactNativeDelegate()
|
|
18
|
+
let factory = RCTReactNativeFactory(delegate: delegate)
|
|
19
|
+
delegate.dependencyProvider = RCTAppDependencyProvider()
|
|
20
|
+
|
|
21
|
+
reactNativeDelegate = delegate
|
|
22
|
+
reactNativeFactory = factory
|
|
23
|
+
|
|
24
|
+
window = UIWindow(frame: UIScreen.main.bounds)
|
|
25
|
+
|
|
26
|
+
factory.startReactNative(
|
|
27
|
+
withModuleName: "RN79",
|
|
28
|
+
in: window,
|
|
29
|
+
launchOptions: launchOptions
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return true
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
37
|
+
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
38
|
+
self.bundleURL()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
override func bundleURL() -> URL? {
|
|
42
|
+
#if DEBUG
|
|
43
|
+
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
44
|
+
#else
|
|
45
|
+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
|
46
|
+
#endif
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package com.app
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactActivity
|
|
4
|
+
import com.facebook.react.ReactActivityDelegate
|
|
5
|
+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
|
|
6
|
+
import com.facebook.react.defaults.DefaultReactActivityDelegate
|
|
7
|
+
|
|
8
|
+
class MainActivity : ReactActivity() {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns the name of the main component registered from JavaScript. This is used to schedule
|
|
12
|
+
* rendering of the component.
|
|
13
|
+
*/
|
|
14
|
+
override fun getMainComponentName(): String = "rn770"
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
|
|
18
|
+
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
|
|
19
|
+
*/
|
|
20
|
+
override fun createReactActivityDelegate(): ReactActivityDelegate =
|
|
21
|
+
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
|
|
22
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
package com.app
|
|
2
|
+
|
|
3
|
+
import android.app.Application
|
|
4
|
+
import com.facebook.react.PackageList
|
|
5
|
+
import com.facebook.react.ReactApplication
|
|
6
|
+
import com.facebook.react.ReactHost
|
|
7
|
+
import com.facebook.react.ReactNativeHost
|
|
8
|
+
import com.facebook.react.ReactPackage
|
|
9
|
+
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
|
|
10
|
+
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
|
11
|
+
import com.facebook.react.defaults.DefaultReactNativeHost
|
|
12
|
+
import com.facebook.react.soloader.OpenSourceMergedSoMapping
|
|
13
|
+
import com.facebook.soloader.SoLoader
|
|
14
|
+
|
|
15
|
+
class MainApplication : Application(), ReactApplication {
|
|
16
|
+
|
|
17
|
+
override val reactNativeHost: ReactNativeHost =
|
|
18
|
+
object : DefaultReactNativeHost(this) {
|
|
19
|
+
override fun getPackages(): List<ReactPackage> =
|
|
20
|
+
PackageList(this).packages.apply {
|
|
21
|
+
// Packages that cannot be autolinked yet can be added manually here, for example:
|
|
22
|
+
// add(MyReactNativePackage())
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun getJSMainModuleName(): String = "index"
|
|
26
|
+
|
|
27
|
+
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
|
|
28
|
+
|
|
29
|
+
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
30
|
+
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override val reactHost: ReactHost
|
|
34
|
+
get() = getDefaultReactHost(applicationContext, reactNativeHost)
|
|
35
|
+
|
|
36
|
+
override fun onCreate() {
|
|
37
|
+
super.onCreate()
|
|
38
|
+
SoLoader.init(this, OpenSourceMergedSoMapping)
|
|
39
|
+
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
40
|
+
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
|
41
|
+
load()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext {
|
|
3
|
+
buildToolsVersion = "35.0.0"
|
|
4
|
+
minSdkVersion = 24
|
|
5
|
+
compileSdkVersion = 35
|
|
6
|
+
targetSdkVersion = 35
|
|
7
|
+
ndkVersion = "27.1.12297006"
|
|
8
|
+
kotlinVersion = "2.0.21"
|
|
9
|
+
}
|
|
10
|
+
repositories {
|
|
11
|
+
google()
|
|
12
|
+
mavenCentral()
|
|
13
|
+
}
|
|
14
|
+
dependencies {
|
|
15
|
+
classpath("com.android.tools.build:gradle")
|
|
16
|
+
classpath("com.facebook.react:react-native-gradle-plugin")
|
|
17
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.facebook.react.rootproject"
|
|
@@ -21,4 +21,6 @@ module.exports = {
|
|
|
21
21
|
prepareFixtureDuplicate,
|
|
22
22
|
prepareFixtureDuplicate77: ({ userFixtureFileName, patchedFixtureFileName }) =>
|
|
23
23
|
prepareFixtureDuplicate({ rnVersion: '77', userFixtureFileName, patchedFixtureFileName }),
|
|
24
|
+
prepareFixtureDuplicate79: ({ userFixtureFileName, patchedFixtureFileName }) =>
|
|
25
|
+
prepareFixtureDuplicate({ rnVersion: '79', userFixtureFileName, patchedFixtureFileName }),
|
|
24
26
|
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { getReactNativeVersion, findProjectPackageJson } = require('./reactNativeVersion');
|
|
5
|
+
|
|
6
|
+
// Logging helper that writes to both stderr and a log file
|
|
7
|
+
function log(message) {
|
|
8
|
+
console.error(message);
|
|
9
|
+
|
|
10
|
+
// Also write to a log file for debugging if stderr is suppressed
|
|
11
|
+
try {
|
|
12
|
+
const logFile = path.join(__dirname, '../../../ios/rnn_version_detection.log');
|
|
13
|
+
const timestamp = new Date().toISOString();
|
|
14
|
+
fs.appendFileSync(logFile, `[${timestamp}] ${message}\n`, 'utf8');
|
|
15
|
+
} catch (e) {
|
|
16
|
+
// Ignore log file errors
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function generateVersionHeader() {
|
|
21
|
+
const startDir = __dirname;
|
|
22
|
+
|
|
23
|
+
log(`[RNN] === React Native Version Detection ===`);
|
|
24
|
+
log(`[RNN] Script location (__dirname): ${startDir}`);
|
|
25
|
+
log(`[RNN] Working directory (cwd): ${process.cwd()}`);
|
|
26
|
+
|
|
27
|
+
const packageJsonPath = findProjectPackageJson();
|
|
28
|
+
|
|
29
|
+
if (!packageJsonPath) {
|
|
30
|
+
log('[RNN] ❌ ERROR: Project package.json not found');
|
|
31
|
+
log('[RNN] This usually means the script could not locate your React Native project.');
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
log(`[RNN] ✓ Found package.json: ${packageJsonPath}`);
|
|
36
|
+
|
|
37
|
+
// Determine actual source of version
|
|
38
|
+
const projectRoot = path.dirname(packageJsonPath);
|
|
39
|
+
const rnPackageJsonPath = path.join(projectRoot, 'node_modules', 'react-native', 'package.json');
|
|
40
|
+
let versionSource = packageJsonPath;
|
|
41
|
+
let versionSourceType = 'package.json';
|
|
42
|
+
|
|
43
|
+
if (fs.existsSync(rnPackageJsonPath)) {
|
|
44
|
+
versionSource = rnPackageJsonPath;
|
|
45
|
+
versionSourceType = 'node_modules/react-native/package.json (installed version)';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const versionInfo = getReactNativeVersion();
|
|
49
|
+
|
|
50
|
+
if (!versionInfo) {
|
|
51
|
+
log('[RNN] ❌ ERROR: react-native not found in package.json or node_modules');
|
|
52
|
+
log('[RNN] Make sure react-native is installed and listed as a dependency.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
log(`[RNN] ✓ React Native ${versionInfo.raw} (source: ${versionSourceType})`);
|
|
57
|
+
|
|
58
|
+
const { major, minor, patch } = versionInfo;
|
|
59
|
+
|
|
60
|
+
// Generate header content
|
|
61
|
+
const headerContent = `//
|
|
62
|
+
// ReactNativeVersionExtracted.h
|
|
63
|
+
// React Native version: ${versionInfo.raw}
|
|
64
|
+
// Generated on: ${new Date().toISOString()}
|
|
65
|
+
// Source: ${versionSource}
|
|
66
|
+
//
|
|
67
|
+
|
|
68
|
+
#ifndef ReactNativeVersionExtracted_h
|
|
69
|
+
#define ReactNativeVersionExtracted_h
|
|
70
|
+
|
|
71
|
+
static const int REACT_NATIVE_VERSION_MAJOR = ${major};
|
|
72
|
+
static const int REACT_NATIVE_VERSION_MINOR = ${minor};
|
|
73
|
+
static const int REACT_NATIVE_VERSION_PATCH = ${patch};
|
|
74
|
+
|
|
75
|
+
#define RN_VERSION_MAJOR ${major}
|
|
76
|
+
#define RN_VERSION_MINOR ${minor}
|
|
77
|
+
#define RN_VERSION_PATCH ${patch}
|
|
78
|
+
|
|
79
|
+
#endif
|
|
80
|
+
`;
|
|
81
|
+
|
|
82
|
+
// Find RNN root by looking upwards from script location for RNN's package.json
|
|
83
|
+
let currentDir = __dirname;
|
|
84
|
+
let rnnPackageJson = null;
|
|
85
|
+
|
|
86
|
+
for (let i = 0; i < 5; i++) {
|
|
87
|
+
const potential = path.join(currentDir, 'package.json');
|
|
88
|
+
if (fs.existsSync(potential)) {
|
|
89
|
+
const pkg = JSON.parse(fs.readFileSync(potential, 'utf8'));
|
|
90
|
+
// This is RNN's package.json if name matches
|
|
91
|
+
if (pkg.name === 'react-native-navigation') {
|
|
92
|
+
rnnPackageJson = currentDir;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
currentDir = path.resolve(currentDir, '..');
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!rnnPackageJson) {
|
|
100
|
+
log('[RNN] ❌ ERROR: Could not find react-native-navigation root directory');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const outputFile = path.join(rnnPackageJson, 'ios/ReactNativeVersionExtracted.h');
|
|
105
|
+
|
|
106
|
+
fs.writeFileSync(outputFile, headerContent, 'utf8');
|
|
107
|
+
log(`[RNN] ✅ Generated header: ${outputFile}`);
|
|
108
|
+
log(`[RNN] ✅ Version constants: ${major}.${minor}.${patch}`);
|
|
109
|
+
log(`[RNN] === Completed Successfully ===`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Run if called directly
|
|
113
|
+
if (require.main === module) {
|
|
114
|
+
generateVersionHeader();
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = { generateVersionHeader };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
var fs = require('fs');
|
|
3
|
+
var nodePath = require('path');
|
|
4
|
+
var { warnn } = require('../log');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Find the project root package.json
|
|
8
|
+
* @returns {string|null} Path to project's package.json or null if not found
|
|
9
|
+
*/
|
|
10
|
+
function findProjectPackageJson() {
|
|
11
|
+
var searchDirs = [process.cwd(), __dirname];
|
|
12
|
+
|
|
13
|
+
// PRIORITY: Check if we're in RNN's own directory structure (workspace/CI scenario)
|
|
14
|
+
// In this case, __dirname would be like: /path/to/rnn/autolink/postlink/__helpers__
|
|
15
|
+
// And we want to find: /path/to/rnn/playground/package.json
|
|
16
|
+
var currentPath = __dirname;
|
|
17
|
+
|
|
18
|
+
// Walk up to find RNN root (containing this autolink folder)
|
|
19
|
+
for (var k = 0; k < 5; k++) {
|
|
20
|
+
// Check if this looks like RNN root by checking for playground subdirectory
|
|
21
|
+
var playgroundPath = nodePath.join(currentPath, 'playground');
|
|
22
|
+
var playgroundPackageJson = nodePath.join(playgroundPath, 'package.json');
|
|
23
|
+
|
|
24
|
+
if (fs.existsSync(playgroundPackageJson)) {
|
|
25
|
+
try {
|
|
26
|
+
var pkg = JSON.parse(fs.readFileSync(playgroundPackageJson, 'utf8'));
|
|
27
|
+
if ((pkg.dependencies && pkg.dependencies['react-native']) ||
|
|
28
|
+
(pkg.devDependencies && pkg.devDependencies['react-native'])) {
|
|
29
|
+
// Found it! Prioritize this path
|
|
30
|
+
searchDirs.unshift(playgroundPath);
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
} catch (e) { }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var parent = nodePath.dirname(currentPath);
|
|
37
|
+
if (parent === currentPath) break;
|
|
38
|
+
currentPath = parent;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// If we're inside a package (like in node_modules or a workspace),
|
|
42
|
+
// also try searching from common project locations
|
|
43
|
+
currentPath = __dirname;
|
|
44
|
+
for (var k = 0; k < 10; k++) {
|
|
45
|
+
var basename = nodePath.basename(currentPath);
|
|
46
|
+
|
|
47
|
+
// If we're in node_modules, the parent is likely the project root
|
|
48
|
+
if (basename === 'node_modules') {
|
|
49
|
+
searchDirs.push(nodePath.dirname(currentPath));
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// If we find a workspace scenario (e.g., we're in the workspace root but project is in subdirectory)
|
|
54
|
+
// Check for common subdirectories like 'playground', 'example', 'app'
|
|
55
|
+
var commonProjectDirs = ['playground', 'example', 'app', 'demo'];
|
|
56
|
+
for (var m = 0; m < commonProjectDirs.length; m++) {
|
|
57
|
+
var potentialProjectDir = nodePath.join(currentPath, commonProjectDirs[m]);
|
|
58
|
+
if (fs.existsSync(potentialProjectDir)) {
|
|
59
|
+
searchDirs.push(potentialProjectDir);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
var parent = nodePath.dirname(currentPath);
|
|
64
|
+
if (parent === currentPath) break;
|
|
65
|
+
currentPath = parent;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
for (var j = 0; j < searchDirs.length; j++) {
|
|
69
|
+
var searchDir = searchDirs[j];
|
|
70
|
+
for (var i = 0; i < 10; i++) {
|
|
71
|
+
var packagePath = nodePath.join(searchDir, 'package.json');
|
|
72
|
+
if (fs.existsSync(packagePath)) {
|
|
73
|
+
try {
|
|
74
|
+
var pkg = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
|
|
75
|
+
if ((pkg.dependencies && pkg.dependencies['react-native']) ||
|
|
76
|
+
(pkg.devDependencies && pkg.devDependencies['react-native'])) {
|
|
77
|
+
// Exclude react-native-navigation's own package.json to avoid false positives
|
|
78
|
+
// in workspace/monorepo scenarios
|
|
79
|
+
if (pkg.name !== 'react-native-navigation') {
|
|
80
|
+
return packagePath;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} catch (e) { }
|
|
84
|
+
}
|
|
85
|
+
var parent = nodePath.dirname(searchDir);
|
|
86
|
+
if (parent === searchDir) break;
|
|
87
|
+
searchDir = parent;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Get React Native version as parsed object from node_modules
|
|
96
|
+
* @returns {Object|null} { major, minor, patch, raw } or null
|
|
97
|
+
*/
|
|
98
|
+
function getReactNativeVersion() {
|
|
99
|
+
var projectPackageJsonPath = findProjectPackageJson();
|
|
100
|
+
if (!projectPackageJsonPath) {
|
|
101
|
+
warnn('Could not find package.json to detect React Native version');
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var projectRoot = nodePath.dirname(projectPackageJsonPath);
|
|
106
|
+
|
|
107
|
+
// First, try to read from node_modules/react-native/package.json (actual installed version)
|
|
108
|
+
var rnPackageJsonPath = nodePath.join(projectRoot, 'node_modules', 'react-native', 'package.json');
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
if (fs.existsSync(rnPackageJsonPath)) {
|
|
112
|
+
var rnPackageJson = JSON.parse(fs.readFileSync(rnPackageJsonPath, 'utf8'));
|
|
113
|
+
var rnVersion = rnPackageJson.version;
|
|
114
|
+
|
|
115
|
+
if (rnVersion) {
|
|
116
|
+
var parts = rnVersion.split('.');
|
|
117
|
+
return {
|
|
118
|
+
major: parseInt(parts[0]) || 0,
|
|
119
|
+
minor: parseInt(parts[1]) || 0,
|
|
120
|
+
patch: parseInt(parts[2]) || 0,
|
|
121
|
+
raw: rnVersion
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
} catch (e) {
|
|
126
|
+
// Fall through to backup method
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Fallback: read from project's package.json dependencies
|
|
130
|
+
try {
|
|
131
|
+
var packageJson = JSON.parse(fs.readFileSync(projectPackageJsonPath, 'utf8'));
|
|
132
|
+
var rnVersion = packageJson.dependencies && packageJson.dependencies['react-native'] ||
|
|
133
|
+
packageJson.devDependencies && packageJson.devDependencies['react-native'];
|
|
134
|
+
|
|
135
|
+
if (!rnVersion) {
|
|
136
|
+
warnn('React Native not found in package.json or node_modules');
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Parse version (remove ^, ~, >=, etc.)
|
|
141
|
+
var cleanVersion = rnVersion.replace(/^[\^~>=<]+/, '');
|
|
142
|
+
var parts = cleanVersion.split('.');
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
major: parseInt(parts[0]) || 0,
|
|
146
|
+
minor: parseInt(parts[1]) || 0,
|
|
147
|
+
patch: parseInt(parts[2]) || 0,
|
|
148
|
+
raw: rnVersion
|
|
149
|
+
};
|
|
150
|
+
} catch (e) {
|
|
151
|
+
warnn('Error detecting React Native version: ' + e.message);
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
module.exports = {
|
|
157
|
+
findProjectPackageJson: findProjectPackageJson,
|
|
158
|
+
getReactNativeVersion: getReactNativeVersion
|
|
159
|
+
};
|
|
160
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`appDelegateLinker should work for RN 0.77 with Objective-C 1`] = `
|
|
3
|
+
exports[`appDelegateLinker should work for RN 0.77 & 0.78 with Objective-C 1`] = `
|
|
4
4
|
"#import "AppDelegate.h"
|
|
5
5
|
#import <ReactNativeNavigation/ReactNativeNavigation.h>
|
|
6
6
|
|
|
@@ -36,7 +36,7 @@ exports[`appDelegateLinker should work for RN 0.77 with Objective-C 1`] = `
|
|
|
36
36
|
@end "
|
|
37
37
|
`;
|
|
38
38
|
|
|
39
|
-
exports[`appDelegateLinker should work for RN 0.77 with Swift 1`] = `
|
|
39
|
+
exports[`appDelegateLinker should work for RN 0.77 & 0.78 with Swift 1`] = `
|
|
40
40
|
"import UIKit
|
|
41
41
|
import React
|
|
42
42
|
import ReactNativeNavigation
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`appDelegateLinker should work with Swift bridgeless RN 0.79 1`] = `
|
|
4
|
+
"import UIKit
|
|
5
|
+
import React
|
|
6
|
+
import ReactNativeNavigation
|
|
7
|
+
import ReactAppDependencyProvider
|
|
8
|
+
|
|
9
|
+
@main
|
|
10
|
+
class AppDelegate: RNNAppDelegate {
|
|
11
|
+
|
|
12
|
+
override func application(
|
|
13
|
+
_ application: UIApplication,
|
|
14
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
15
|
+
) -> Bool {
|
|
16
|
+
self.reactNativeDelegate = ReactNativeDelegate()
|
|
17
|
+
super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
return true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
26
|
+
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
27
|
+
self.bundleURL()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override func bundleURL() -> URL? {
|
|
31
|
+
#if DEBUG
|
|
32
|
+
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
33
|
+
#else
|
|
34
|
+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
}"
|
|
38
|
+
`;
|
|
39
|
+
|