@callstack/react-native-brownfield 1.0.0-rc.0 → 1.0.0-rc.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.
Files changed (38) hide show
  1. package/ReactBrownfield.podspec +27 -0
  2. package/android/build.gradle +15 -0
  3. package/android/src/newarch/ReactNativeBrownfieldModule.kt +37 -0
  4. package/android/src/{main/java/com/callstack/reactnativebrownfield → oldarch}/ReactNativeBrownfieldModule.kt +6 -1
  5. package/ios/ReactNativeBrownfield.swift +54 -33
  6. package/ios/ReactNativeBrownfieldModule.h +6 -2
  7. package/ios/{ReactNativeBrownfieldModule.m → ReactNativeBrownfieldModule.mm} +7 -3
  8. package/ios/ReactNativeBrownfieldModule.swift +2 -2
  9. package/ios/ReactNativeView.swift +5 -4
  10. package/ios/ReactNativeViewController.swift +17 -18
  11. package/lib/commonjs/NativeReactNativeBrownfieldModule.js +2 -0
  12. package/lib/commonjs/NativeReactNativeBrownfieldModule.js.map +1 -0
  13. package/lib/commonjs/index.js +1 -30
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/module/NativeReactNativeBrownfieldModule.js +2 -0
  16. package/lib/module/NativeReactNativeBrownfieldModule.js.map +1 -0
  17. package/lib/module/index.js +1 -25
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/typescript/{src/RNBrownfieldSpec.d.ts → commonjs/src/NativeReactNativeBrownfieldModule.d.ts} +2 -2
  20. package/lib/typescript/commonjs/src/NativeReactNativeBrownfieldModule.d.ts.map +1 -0
  21. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  22. package/lib/typescript/module/src/NativeReactNativeBrownfieldModule.d.ts +20 -0
  23. package/lib/typescript/module/src/NativeReactNativeBrownfieldModule.d.ts.map +1 -0
  24. package/lib/typescript/module/src/index.d.ts +6 -0
  25. package/lib/typescript/module/src/index.d.ts.map +1 -0
  26. package/package.json +33 -7
  27. package/src/{RNBrownfieldSpec.ts → NativeReactNativeBrownfieldModule.ts} +1 -1
  28. package/src/index.ts +3 -3
  29. package/ReactNativeBrownfield.podspec +0 -27
  30. package/lib/commonjs/RNBrownfieldSpec.js +0 -9
  31. package/lib/commonjs/RNBrownfieldSpec.js.map +0 -1
  32. package/lib/module/RNBrownfieldSpec.js +0 -5
  33. package/lib/module/RNBrownfieldSpec.js.map +0 -1
  34. package/lib/typescript/src/RNBrownfieldSpec.d.ts.map +0 -1
  35. package/lib/typescript/src/index.d.ts.map +0 -1
  36. /package/lib/{commonjs → typescript/commonjs}/package.json +0 -0
  37. /package/lib/typescript/{src → commonjs/src}/index.d.ts +0 -0
  38. /package/lib/{module → typescript/module}/package.json +0 -0
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ Pod::Spec.new do |spec|
6
+ spec.name = "ReactBrownfield"
7
+ spec.version = package['version']
8
+ spec.summary = package['description']
9
+ spec.license = package['license']
10
+
11
+ spec.authors = package['author']
12
+ spec.homepage = package['homepage']
13
+ spec.platform = :ios, "14.0"
14
+
15
+ spec.module_name = "ReactBrownfield"
16
+ spec.source = { :git => "git@github.com:callstack/react-native-brownfield.git", :tag => "#{spec.version}" }
17
+ spec.source_files = "ios/**/*.{h,m,mm,swift}"
18
+ spec.pod_target_xcconfig = {
19
+ 'DEFINES_MODULE' => 'YES',
20
+ 'OTHER_SWIFT_FLAGS' => "-enable-experimental-feature AccessLevelOnImport"
21
+ }
22
+
23
+ spec.dependency 'ReactAppDependencyProvider'
24
+ add_dependency(spec, "React-RCTAppDelegate")
25
+
26
+ install_modules_dependencies(spec)
27
+ end
@@ -84,6 +84,21 @@ android {
84
84
  sourceCompatibility JavaVersion.VERSION_1_8
85
85
  targetCompatibility JavaVersion.VERSION_1_8
86
86
  }
87
+
88
+ sourceSets {
89
+ main {
90
+ if (isNewArchitectureEnabled()) {
91
+ java.srcDirs += [
92
+ "src/newarch",
93
+ // Codegen specs
94
+ "generated/java",
95
+ "generated/jni"
96
+ ]
97
+ } else {
98
+ java.srcDirs += ["src/oldarch"]
99
+ }
100
+ }
101
+ }
87
102
  }
88
103
 
89
104
  repositories {
@@ -0,0 +1,37 @@
1
+ package com.callstack.reactnativebrownfield
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactMethod
5
+
6
+ class ReactNativeBrownfieldModule(reactContext: ReactApplicationContext) :
7
+ NativeReactNativeBrownfieldModuleSpec(reactContext) {
8
+ companion object {
9
+ var shouldPopToNative: Boolean = false
10
+ }
11
+
12
+ @ReactMethod
13
+ override fun popToNative(animated: Boolean) {
14
+ shouldPopToNative = true
15
+ onBackPressed()
16
+ }
17
+
18
+ @ReactMethod
19
+ override fun setPopGestureRecognizerEnabled(enabled: Boolean) {
20
+ shouldPopToNative = enabled
21
+ }
22
+
23
+ @ReactMethod
24
+ override fun setHardwareBackButtonEnabled(enabled: Boolean) {
25
+ shouldPopToNative = enabled
26
+ }
27
+
28
+ private fun onBackPressed() {
29
+ reactApplicationContext.currentActivity?.runOnUiThread {
30
+ reactApplicationContext.currentActivity?.onBackPressed()
31
+ }
32
+ }
33
+
34
+ override fun getName(): String {
35
+ return "ReactNativeBrownfield"
36
+ }
37
+ }
@@ -11,11 +11,16 @@ class ReactNativeBrownfieldModule(reactContext: ReactApplicationContext) :
11
11
  }
12
12
 
13
13
  @ReactMethod
14
- fun popToNative() {
14
+ fun popToNative(animated: Boolean) {
15
15
  shouldPopToNative = true
16
16
  onBackPressed()
17
17
  }
18
18
 
19
+ @ReactMethod
20
+ fun setPopGestureRecognizerEnabled(enabled: Boolean) {
21
+ shouldPopToNative = enabled
22
+ }
23
+
19
24
  @ReactMethod
20
25
  fun setHardwareBackButtonEnabled(isFirstRoute: Boolean) {
21
26
  shouldPopToNative = isFirstRoute
@@ -1,16 +1,44 @@
1
- import React
2
- import React_RCTAppDelegate
3
- import ReactAppDependencyProvider
1
+ import UIKit
2
+ internal import React
3
+ internal import React_RCTAppDelegate
4
+ internal import ReactAppDependencyProvider
4
5
 
5
- @objc public class ReactNativeBrownfield: RCTDefaultReactNativeFactoryDelegate {
6
- @objc public static let shared = ReactNativeBrownfield()
7
- private var onBundleLoaded: (() -> Void)?
6
+ class ReactNativeBrownfieldDelegate: RCTDefaultReactNativeFactoryDelegate {
7
+ var entryFile = "index"
8
+ // MARK: - RCTReactNativeFactoryDelegate Methods
9
+
10
+ override func sourceURL(for bridge: RCTBridge) -> URL? {
11
+ return bundleURL()
12
+ }
13
+
14
+ public override func bundleURL() -> URL? {
15
+ #if DEBUG
16
+ return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: entryFile)
17
+ #else
18
+ let resourceURLComponents = bundlePath.components(separatedBy: ".")
19
+ let withoutLast = resourceURLComponents[..<(resourceURLComponents.count - 1)]
20
+ let resourceName = withoutLast.joined()
21
+ let fileExtension = resourceURLComponents.last ?? ""
22
+
23
+ return Bundle.main.url(forResource: resourceName, withExtension: fileExtension)
24
+ #endif
25
+ }
26
+ }
8
27
 
28
+ @objc public class ReactNativeBrownfield: NSObject {
29
+ public static let shared = ReactNativeBrownfield()
30
+ private var onBundleLoaded: (() -> Void)?
31
+ private var delegate = ReactNativeBrownfieldDelegate()
32
+
9
33
  /**
10
34
  * Path to JavaScript root.
11
35
  * Default value: "index"
12
36
  */
13
- @objc public var entryFile: String = "index"
37
+ @objc public var entryFile: String = "index" {
38
+ didSet {
39
+ delegate.entryFile = entryFile
40
+ }
41
+ }
14
42
  /**
15
43
  * Path to bundle fallback resource.
16
44
  * Default value: nil
@@ -25,14 +53,14 @@ import ReactAppDependencyProvider
25
53
  * React Native factory instance created when starting React Native.
26
54
  * Default value: nil
27
55
  */
28
- @objc public var reactNativeFactory: RCTReactNativeFactory? = nil
56
+ private var reactNativeFactory: RCTReactNativeFactory? = nil
29
57
  /**
30
58
  * Root view factory used to create React Native views.
31
59
  */
32
- @objc lazy public var rootViewFactory: RCTRootViewFactory? = {
60
+ lazy private var rootViewFactory: RCTRootViewFactory? = {
33
61
  return reactNativeFactory?.rootViewFactory
34
62
  }()
35
-
63
+
36
64
  /**
37
65
  * Starts React Native with default parameters.
38
66
  */
@@ -40,9 +68,21 @@ import ReactAppDependencyProvider
40
68
  startReactNative(onBundleLoaded: nil)
41
69
  }
42
70
 
71
+ @objc public func view(
72
+ moduleName: String,
73
+ initialProps: [AnyHashable: Any]?,
74
+ launchOptions: [AnyHashable: Any]? = nil
75
+ ) -> UIView? {
76
+ reactNativeFactory?.rootViewFactory.view(
77
+ withModuleName: moduleName,
78
+ initialProperties: initialProps,
79
+ launchOptions: launchOptions
80
+ )
81
+ }
82
+
43
83
  /**
44
84
  * Starts React Native with optional callback when bundle is loaded.
45
- *
85
+ *
46
86
  * @param onBundleLoaded Optional callback invoked after JS bundle is fully loaded.
47
87
  */
48
88
  @objc public func startReactNative(onBundleLoaded: (() -> Void)?) {
@@ -51,15 +91,15 @@ import ReactAppDependencyProvider
51
91
 
52
92
  /**
53
93
  * Starts React Native with optional callback and launch options.
54
- *
94
+ *
55
95
  * @param onBundleLoaded Optional callback invoked after JS bundle is fully loaded.
56
96
  * @param launchOptions Launch options, typically passed from AppDelegate.
57
97
  */
58
98
  @objc public func startReactNative(onBundleLoaded: (() -> Void)?, launchOptions: [AnyHashable: Any]?) {
59
99
  guard reactNativeFactory == nil else { return }
60
100
 
61
- self.dependencyProvider = RCTAppDependencyProvider()
62
- self.reactNativeFactory = RCTReactNativeFactory(delegate: self)
101
+ delegate.dependencyProvider = RCTAppDependencyProvider()
102
+ self.reactNativeFactory = RCTReactNativeFactory(delegate: delegate)
63
103
 
64
104
  if let onBundleLoaded {
65
105
  self.onBundleLoaded = onBundleLoaded
@@ -86,25 +126,6 @@ import ReactAppDependencyProvider
86
126
  onBundleLoaded = nil
87
127
  NotificationCenter.default.removeObserver(self)
88
128
  }
89
-
90
- // MARK: - RCTReactNativeFactoryDelegate Methods
91
-
92
- @objc public override func sourceURL(for bridge: RCTBridge) -> URL? {
93
- return bundleURL()
94
- }
95
-
96
- public override func bundleURL() -> URL? {
97
- #if DEBUG
98
- return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: entryFile)
99
- #else
100
- let resourceURLComponents = bundlePath.components(separatedBy: ".")
101
- let withoutLast = resourceURLComponents[..<(resourceURLComponents.count - 1)]
102
- let resourceName = withoutLast.joined()
103
- let fileExtension = resourceURLComponents.last ?? ""
104
-
105
- return Bundle.main.url(forResource: resourceName, withExtension: fileExtension)
106
- #endif
107
- }
108
129
  }
109
130
 
110
131
  extension Notification.Name {
@@ -1,4 +1,8 @@
1
- #import <React/RCTBridgeModule.h>
1
+ #ifdef __cplusplus
2
2
 
3
- @interface ReactNativeBrownfieldModule : NSObject <RCTBridgeModule>
3
+ #import <ReactNativeBrownfield/ReactNativeBrownfield.h>
4
+
5
+ @interface ReactNativeBrownfieldModule : NSObject <NativeReactNativeBrownfieldModuleSpec>
4
6
  @end
7
+
8
+ #endif
@@ -1,9 +1,9 @@
1
1
  #import "ReactNativeBrownfieldModule.h"
2
2
 
3
- #if __has_include("ReactNativeBrownfield/ReactNativeBrownfield-Swift.h")
4
- #import "ReactNativeBrownfield/ReactNativeBrownfield-Swift.h"
3
+ #if __has_include("ReactBrownfield/ReactBrownfield-Swift.h")
4
+ #import "ReactBrownfield/ReactBrownfield-Swift.h"
5
5
  #else
6
- #import "ReactNativeBrownfield-Swift.h"
6
+ #import "ReactBrownfield-Swift.h"
7
7
  #endif
8
8
 
9
9
  @implementation ReactNativeBrownfieldModule
@@ -18,4 +18,8 @@ RCT_EXPORT_METHOD(popToNative:(BOOL)animated) {
18
18
  [ReactNativeBrownfieldModuleImpl popToNativeWithAnimated:animated];
19
19
  }
20
20
 
21
+ - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const facebook::react::ObjCTurboModule::InitParams &)params {
22
+ return std::make_shared<facebook::react::NativeReactNativeBrownfieldModuleSpecJSI>(params);
23
+ }
24
+
21
25
  @end
@@ -1,4 +1,4 @@
1
- import React
1
+ internal import React
2
2
 
3
3
  @objcMembers
4
4
  public class ReactNativeBrownfieldModuleImpl: NSObject {
@@ -8,7 +8,7 @@ public class ReactNativeBrownfieldModuleImpl: NSObject {
8
8
  NotificationCenter.default.post(name: Notification.Name.togglePopGestureRecognizer, object: nil, userInfo: userInfo)
9
9
  }
10
10
  }
11
-
11
+
12
12
  static public func popToNative(animated: Bool) {
13
13
  let userInfo = ["animated": animated]
14
14
  DispatchQueue.main.async {
@@ -6,11 +6,11 @@ import SwiftUI
6
6
  struct ReactNativeViewRepresentable: UIViewControllerRepresentable {
7
7
  var moduleName: String
8
8
  var initialProperties: [String: Any] = [:]
9
-
9
+
10
10
  func makeUIViewController(context: Context) -> UIViewController {
11
11
  return ReactNativeViewController(moduleName: moduleName)
12
12
  }
13
-
13
+
14
14
  func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
15
15
  }
16
16
 
@@ -18,16 +18,17 @@ struct ReactNativeViewRepresentable: UIViewControllerRepresentable {
18
18
  Exposes React Native view to SwiftUI.
19
19
  Supports pop to native when using SwiftUI's NavigationView or NavigationStack.
20
20
  */
21
+ @available(iOS 15.0, *)
21
22
  public struct ReactNativeView: View {
22
23
  @Environment(\.dismiss) var dismiss
23
24
  var moduleName: String
24
25
  var initialProperties: [String: Any] = [:]
25
-
26
+
26
27
  public init(moduleName: String, initialProperties: [String : Any] = [:]) {
27
28
  self.moduleName = moduleName
28
29
  self.initialProperties = initialProperties
29
30
  }
30
-
31
+
31
32
  public var body: some View {
32
33
  ReactNativeViewRepresentable(
33
34
  moduleName: moduleName,
@@ -1,38 +1,37 @@
1
1
  import UIKit
2
- import React
2
+ internal import React
3
3
 
4
4
  @objc public class ReactNativeViewController: UIViewController {
5
5
  private var moduleName: String
6
6
  private var initialProperties: [String: Any]?
7
-
7
+
8
8
  @objc public init(moduleName: String, initialProperties: [String: Any]? = nil) {
9
9
  self.moduleName = moduleName
10
10
  self.initialProperties = initialProperties
11
11
  super.init(nibName: nil, bundle: nil)
12
12
  }
13
-
13
+
14
14
  required init?(coder: NSCoder) {
15
15
  fatalError("init(coder:) has not been implemented")
16
16
  }
17
-
17
+
18
18
  public override func viewDidLoad() {
19
19
  super.viewDidLoad()
20
-
21
- guard let factory = ReactNativeBrownfield.shared.rootViewFactory else {
22
- print("Error: You need to start React Native in order to use ReactNativeViewController, make sure to run BridgeManager.shared.startReactNative() before instantiating it.")
23
- return
24
- }
25
-
20
+
26
21
  if !moduleName.isEmpty {
27
- view = factory.view(withModuleName: moduleName, initialProperties: initialProperties)
28
-
22
+ view = ReactNativeBrownfield.shared.view(
23
+ moduleName: moduleName,
24
+ initialProps: initialProperties,
25
+ launchOptions: nil
26
+ )
27
+
29
28
  NotificationCenter.default.addObserver(
30
29
  self,
31
30
  selector: #selector(togglePopGestureRecognizer(_:)),
32
31
  name: NSNotification.Name.togglePopGestureRecognizer,
33
32
  object: nil
34
33
  )
35
-
34
+
36
35
  NotificationCenter.default.addObserver(
37
36
  self,
38
37
  selector: #selector(popToNative(_:)),
@@ -41,24 +40,24 @@ import React
41
40
  )
42
41
  }
43
42
  }
44
-
43
+
45
44
  deinit {
46
45
  NotificationCenter.default.removeObserver(self)
47
46
  }
48
-
47
+
49
48
  @objc private func togglePopGestureRecognizer(_ notification: Notification) {
50
49
  guard let userInfo = notification.userInfo,
51
50
  let enabled = userInfo["enabled"] as? Bool else { return }
52
-
51
+
53
52
  DispatchQueue.main.async { [weak self] in
54
53
  self?.navigationController?.interactivePopGestureRecognizer?.isEnabled = enabled
55
54
  }
56
55
  }
57
-
56
+
58
57
  @objc private func popToNative(_ notification: Notification) {
59
58
  guard let userInfo = notification.userInfo,
60
59
  let animated = userInfo["animated"] as? Bool else { return }
61
-
60
+
62
61
  DispatchQueue.main.async { [weak self] in
63
62
  self?.navigationController?.popViewController(animated: animated)
64
63
  }
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var _default=exports.default=_reactNative.TurboModuleRegistry.getEnforcing('ReactNativeBrownfield');
2
+ //# sourceMappingURL=NativeReactNativeBrownfieldModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactNativeBrownfieldModule.ts"],"mappings":"gFACA,IAAAA,YAAA,CAAAC,OAAA,iBAAmD,IAAAC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAqBpCC,gCAAmB,CAACC,YAAY,CAAO,uBAAuB,CAAC","ignoreList":[]}
@@ -1,31 +1,2 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _reactNative = require("react-native");
8
- var _RNBrownfieldSpec = _interopRequireDefault(require("./RNBrownfieldSpec"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- const ReactNativeBrownfield = {
11
- popToNative: animated => {
12
- if (_reactNative.Platform.OS === 'ios') {
13
- _RNBrownfieldSpec.default.popToNative(animated);
14
- } else if (_reactNative.Platform.OS === 'android') {
15
- _RNBrownfieldSpec.default.popToNative();
16
- } else {
17
- console.warn('Not implemented: popToNative');
18
- }
19
- },
20
- setNativeBackGestureAndButtonEnabled: enabled => {
21
- if (_reactNative.Platform.OS === 'ios') {
22
- _RNBrownfieldSpec.default.setPopGestureRecognizerEnabled(enabled);
23
- } else if (_reactNative.Platform.OS === 'android') {
24
- _RNBrownfieldSpec.default.setHardwareBackButtonEnabled(enabled);
25
- } else {
26
- console.warn('Not implemented: setNativeGesturesAndButtonsEnabled');
27
- }
28
- }
29
- };
30
- var _default = exports.default = ReactNativeBrownfield;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var _NativeReactNativeBrownfieldModule=_interopRequireDefault(require("./NativeReactNativeBrownfieldModule"));var ReactNativeBrownfield={popToNative:function popToNative(animated){if(_reactNative.Platform.OS==='ios'){_NativeReactNativeBrownfieldModule.default.popToNative(!!animated);}else if(_reactNative.Platform.OS==='android'){_NativeReactNativeBrownfieldModule.default.popToNative(false);}else{console.warn('Not implemented: popToNative');}},setNativeBackGestureAndButtonEnabled:function setNativeBackGestureAndButtonEnabled(enabled){if(_reactNative.Platform.OS==='ios'){_NativeReactNativeBrownfieldModule.default.setPopGestureRecognizerEnabled(enabled);}else if(_reactNative.Platform.OS==='android'){_NativeReactNativeBrownfieldModule.default.setHardwareBackButtonEnabled(enabled);}else{console.warn('Not implemented: setNativeGesturesAndButtonsEnabled');}}};var _default=exports.default=ReactNativeBrownfield;
31
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_RNBrownfieldSpec","_interopRequireDefault","e","__esModule","default","ReactNativeBrownfield","popToNative","animated","Platform","OS","ReactNativeBrownfieldModule","console","warn","setNativeBackGestureAndButtonEnabled","enabled","setPopGestureRecognizerEnabled","setHardwareBackButtonEnabled","_default","exports"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA6D,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7D,MAAMG,qBAAqB,GAAG;EAC5BC,WAAW,EAAGC,QAAkB,IAAW;IACzC,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;MACzBC,yBAA2B,CAACJ,WAAW,CAACC,QAAQ,CAAC;IACnD,CAAC,MAAM,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MACpCC,yBAA2B,CAACJ,WAAW,CAAC,CAAC;IAC3C,CAAC,MAAM;MACLK,OAAO,CAACC,IAAI,CAAC,8BAA8B,CAAC;IAC9C;EACF,CAAC;EAEDC,oCAAoC,EAAGC,OAAgB,IAAW;IAChE,IAAIN,qBAAQ,CAACC,EAAE,KAAK,KAAK,EAAE;MACzBC,yBAA2B,CAACK,8BAA8B,CAACD,OAAO,CAAC;IACrE,CAAC,MAAM,IAAIN,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;MACpCC,yBAA2B,CAACM,4BAA4B,CAACF,OAAO,CAAC;IACnE,CAAC,MAAM;MACLH,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;IACrE;EACF;AACF,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAd,OAAA,GAEaC,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_NativeReactNativeBrownfieldModule","_interopRequireDefault","ReactNativeBrownfield","popToNative","animated","Platform","OS","ReactNativeBrownfieldModule","console","warn","setNativeBackGestureAndButtonEnabled","enabled","setPopGestureRecognizerEnabled","setHardwareBackButtonEnabled","_default","exports","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"mKAAA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,kCAAA,CAAAC,sBAAA,CAAAF,OAAA,yCAEA,GAAM,CAAAG,qBAAqB,CAAG,CAC5BC,WAAW,CAAE,QAAb,CAAAA,WAAWA,CAAGC,QAAkB,CAAW,CACzC,GAAIC,qBAAQ,CAACC,EAAE,GAAK,KAAK,CAAE,CACzBC,0CAA2B,CAACJ,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,CACrD,CAAC,IAAM,IAAIC,qBAAQ,CAACC,EAAE,GAAK,SAAS,CAAE,CACpCC,0CAA2B,CAACJ,WAAW,CAAC,KAAK,CAAC,CAChD,CAAC,IAAM,CACLK,OAAO,CAACC,IAAI,CAAC,8BAA8B,CAAC,CAC9C,CACF,CAAC,CAEDC,oCAAoC,CAAE,QAAtC,CAAAA,oCAAoCA,CAAGC,OAAgB,CAAW,CAChE,GAAIN,qBAAQ,CAACC,EAAE,GAAK,KAAK,CAAE,CACzBC,0CAA2B,CAACK,8BAA8B,CAACD,OAAO,CAAC,CACrE,CAAC,IAAM,IAAIN,qBAAQ,CAACC,EAAE,GAAK,SAAS,CAAE,CACpCC,0CAA2B,CAACM,4BAA4B,CAACF,OAAO,CAAC,CACnE,CAAC,IAAM,CACLH,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC,CACrE,CACF,CACF,CAAC,CAAC,IAAAK,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEad,qBAAqB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var _default=exports.default=_reactNative.TurboModuleRegistry.getEnforcing('ReactNativeBrownfield');
2
+ //# sourceMappingURL=NativeReactNativeBrownfieldModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeReactNativeBrownfieldModule.ts"],"mappings":"gFACA,IAAAA,YAAA,CAAAC,OAAA,iBAAmD,IAAAC,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAqBpCC,gCAAmB,CAACC,YAAY,CAAO,uBAAuB,CAAC","ignoreList":[]}
@@ -1,26 +1,2 @@
1
- "use strict";
2
-
3
- import { Platform } from 'react-native';
4
- import ReactNativeBrownfieldModule from './RNBrownfieldSpec';
5
- const ReactNativeBrownfield = {
6
- popToNative: animated => {
7
- if (Platform.OS === 'ios') {
8
- ReactNativeBrownfieldModule.popToNative(animated);
9
- } else if (Platform.OS === 'android') {
10
- ReactNativeBrownfieldModule.popToNative();
11
- } else {
12
- console.warn('Not implemented: popToNative');
13
- }
14
- },
15
- setNativeBackGestureAndButtonEnabled: enabled => {
16
- if (Platform.OS === 'ios') {
17
- ReactNativeBrownfieldModule.setPopGestureRecognizerEnabled(enabled);
18
- } else if (Platform.OS === 'android') {
19
- ReactNativeBrownfieldModule.setHardwareBackButtonEnabled(enabled);
20
- } else {
21
- console.warn('Not implemented: setNativeGesturesAndButtonsEnabled');
22
- }
23
- }
24
- };
25
- export default ReactNativeBrownfield;
1
+ var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _reactNative=require("react-native");var _NativeReactNativeBrownfieldModule=_interopRequireDefault(require("./NativeReactNativeBrownfieldModule"));var ReactNativeBrownfield={popToNative:function popToNative(animated){if(_reactNative.Platform.OS==='ios'){_NativeReactNativeBrownfieldModule.default.popToNative(!!animated);}else if(_reactNative.Platform.OS==='android'){_NativeReactNativeBrownfieldModule.default.popToNative(false);}else{console.warn('Not implemented: popToNative');}},setNativeBackGestureAndButtonEnabled:function setNativeBackGestureAndButtonEnabled(enabled){if(_reactNative.Platform.OS==='ios'){_NativeReactNativeBrownfieldModule.default.setPopGestureRecognizerEnabled(enabled);}else if(_reactNative.Platform.OS==='android'){_NativeReactNativeBrownfieldModule.default.setHardwareBackButtonEnabled(enabled);}else{console.warn('Not implemented: setNativeGesturesAndButtonsEnabled');}}};var _default=exports.default=ReactNativeBrownfield;
26
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","ReactNativeBrownfieldModule","ReactNativeBrownfield","popToNative","animated","OS","console","warn","setNativeBackGestureAndButtonEnabled","enabled","setPopGestureRecognizerEnabled","setHardwareBackButtonEnabled"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,OAAOC,2BAA2B,MAAM,oBAAoB;AAE5D,MAAMC,qBAAqB,GAAG;EAC5BC,WAAW,EAAGC,QAAkB,IAAW;IACzC,IAAIJ,QAAQ,CAACK,EAAE,KAAK,KAAK,EAAE;MACzBJ,2BAA2B,CAACE,WAAW,CAACC,QAAQ,CAAC;IACnD,CAAC,MAAM,IAAIJ,QAAQ,CAACK,EAAE,KAAK,SAAS,EAAE;MACpCJ,2BAA2B,CAACE,WAAW,CAAC,CAAC;IAC3C,CAAC,MAAM;MACLG,OAAO,CAACC,IAAI,CAAC,8BAA8B,CAAC;IAC9C;EACF,CAAC;EAEDC,oCAAoC,EAAGC,OAAgB,IAAW;IAChE,IAAIT,QAAQ,CAACK,EAAE,KAAK,KAAK,EAAE;MACzBJ,2BAA2B,CAACS,8BAA8B,CAACD,OAAO,CAAC;IACrE,CAAC,MAAM,IAAIT,QAAQ,CAACK,EAAE,KAAK,SAAS,EAAE;MACpCJ,2BAA2B,CAACU,4BAA4B,CAACF,OAAO,CAAC;IACnE,CAAC,MAAM;MACLH,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC;IACrE;EACF;AACF,CAAC;AAED,eAAeL,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_NativeReactNativeBrownfieldModule","_interopRequireDefault","ReactNativeBrownfield","popToNative","animated","Platform","OS","ReactNativeBrownfieldModule","console","warn","setNativeBackGestureAndButtonEnabled","enabled","setPopGestureRecognizerEnabled","setHardwareBackButtonEnabled","_default","exports","default"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"mKAAA,IAAAA,YAAA,CAAAC,OAAA,iBACA,IAAAC,kCAAA,CAAAC,sBAAA,CAAAF,OAAA,yCAEA,GAAM,CAAAG,qBAAqB,CAAG,CAC5BC,WAAW,CAAE,QAAb,CAAAA,WAAWA,CAAGC,QAAkB,CAAW,CACzC,GAAIC,qBAAQ,CAACC,EAAE,GAAK,KAAK,CAAE,CACzBC,0CAA2B,CAACJ,WAAW,CAAC,CAAC,CAACC,QAAQ,CAAC,CACrD,CAAC,IAAM,IAAIC,qBAAQ,CAACC,EAAE,GAAK,SAAS,CAAE,CACpCC,0CAA2B,CAACJ,WAAW,CAAC,KAAK,CAAC,CAChD,CAAC,IAAM,CACLK,OAAO,CAACC,IAAI,CAAC,8BAA8B,CAAC,CAC9C,CACF,CAAC,CAEDC,oCAAoC,CAAE,QAAtC,CAAAA,oCAAoCA,CAAGC,OAAgB,CAAW,CAChE,GAAIN,qBAAQ,CAACC,EAAE,GAAK,KAAK,CAAE,CACzBC,0CAA2B,CAACK,8BAA8B,CAACD,OAAO,CAAC,CACrE,CAAC,IAAM,IAAIN,qBAAQ,CAACC,EAAE,GAAK,SAAS,CAAE,CACpCC,0CAA2B,CAACM,4BAA4B,CAACF,OAAO,CAAC,CACnE,CAAC,IAAM,CACLH,OAAO,CAACC,IAAI,CAAC,qDAAqD,CAAC,CACrE,CACF,CACF,CAAC,CAAC,IAAAK,QAAA,CAAAC,OAAA,CAAAC,OAAA,CAEad,qBAAqB","ignoreList":[]}
@@ -3,7 +3,7 @@ export interface Spec extends TurboModule {
3
3
  /**
4
4
  * Navigate back to the native part of the application.
5
5
  */
6
- popToNative(animated?: boolean): void;
6
+ popToNative(animated: boolean): void;
7
7
  /**
8
8
  * Enable or disable the iOS swipe back gesture.
9
9
  * @platform ios
@@ -17,4 +17,4 @@ export interface Spec extends TurboModule {
17
17
  }
18
18
  declare const _default: Spec;
19
19
  export default _default;
20
- //# sourceMappingURL=RNBrownfieldSpec.d.ts.map
20
+ //# sourceMappingURL=NativeReactNativeBrownfieldModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeReactNativeBrownfieldModule.d.ts","sourceRoot":"","sources":["../../../../src/NativeReactNativeBrownfieldModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,8BAA8B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvD;;;OAGG;IACH,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACtD;;AAED,wBAA+E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,qBAAqB;6BACA,OAAO,KAAG,IAAI;oDAUS,OAAO,KAAG,IAAI;CAS/D,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { TurboModule } from 'react-native';
2
+ export interface Spec extends TurboModule {
3
+ /**
4
+ * Navigate back to the native part of the application.
5
+ */
6
+ popToNative(animated: boolean): void;
7
+ /**
8
+ * Enable or disable the iOS swipe back gesture.
9
+ * @platform ios
10
+ */
11
+ setPopGestureRecognizerEnabled(enabled: boolean): void;
12
+ /**
13
+ * Enable or disable the Android hardware back button.
14
+ * @platform android
15
+ */
16
+ setHardwareBackButtonEnabled(enabled: boolean): void;
17
+ }
18
+ declare const _default: Spec;
19
+ export default _default;
20
+ //# sourceMappingURL=NativeReactNativeBrownfieldModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeReactNativeBrownfieldModule.d.ts","sourceRoot":"","sources":["../../../../src/NativeReactNativeBrownfieldModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAErC;;;OAGG;IACH,8BAA8B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvD;;;OAGG;IACH,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACtD;;AAED,wBAA+E"}
@@ -0,0 +1,6 @@
1
+ declare const ReactNativeBrownfield: {
2
+ popToNative: (animated?: boolean) => void;
3
+ setNativeBackGestureAndButtonEnabled: (enabled: boolean) => void;
4
+ };
5
+ export default ReactNativeBrownfield;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,qBAAqB;6BACA,OAAO,KAAG,IAAI;oDAUS,OAAO,KAAG,IAAI;CAS/D,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@callstack/react-native-brownfield",
3
- "version": "1.0.0-rc.0",
3
+ "version": "1.0.0-rc.2",
4
4
  "license": "MIT",
5
5
  "author": "Michal Chudziak <mike.chudziak@callstack.com>",
6
6
  "contributors": [
@@ -10,8 +10,21 @@
10
10
  "description": "Brownfield helpers for React Native",
11
11
  "main": "lib/commonjs/index",
12
12
  "module": "lib/module/index",
13
- "types": "lib/typescript/src/index.d.ts",
13
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
14
14
  "react-native": "src/index",
15
+ "exports": {
16
+ ".": {
17
+ "import": {
18
+ "types": "./lib/typescript/module/src/index.d.ts",
19
+ "default": "./lib/module/index.js"
20
+ },
21
+ "require": {
22
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
23
+ "default": "./lib/commonjs/index.js"
24
+ }
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
15
28
  "scripts": {
16
29
  "lint": "eslint . --fix",
17
30
  "typecheck": "tsc --noEmit",
@@ -117,9 +130,9 @@
117
130
  }
118
131
  },
119
132
  "codegenConfig": {
120
- "name": "RNBrownfieldSpec",
133
+ "name": "ReactNativeBrownfield",
121
134
  "type": "modules",
122
- "jsSrcsDir": "src",
135
+ "jsSrcsDir": "./src",
123
136
  "android": {
124
137
  "javaPackageName": "com.callstack.reactnativebrownfield"
125
138
  }
@@ -135,12 +148,25 @@
135
148
  "source": "src",
136
149
  "output": "lib",
137
150
  "targets": [
138
- "commonjs",
139
- "module",
151
+ [
152
+ "commonjs",
153
+ {
154
+ "esm": true,
155
+ "configFile": true
156
+ }
157
+ ],
158
+ [
159
+ "module",
160
+ {
161
+ "esm": true,
162
+ "configFile": true
163
+ }
164
+ ],
140
165
  [
141
166
  "typescript",
142
167
  {
143
- "project": "tsconfig.build.json"
168
+ "project": "tsconfig.build.json",
169
+ "esm": true
144
170
  }
145
171
  ]
146
172
  ]
@@ -5,7 +5,7 @@ export interface Spec extends TurboModule {
5
5
  /**
6
6
  * Navigate back to the native part of the application.
7
7
  */
8
- popToNative(animated?: boolean): void;
8
+ popToNative(animated: boolean): void;
9
9
 
10
10
  /**
11
11
  * Enable or disable the iOS swipe back gesture.
package/src/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Platform } from 'react-native';
2
- import ReactNativeBrownfieldModule from './RNBrownfieldSpec';
2
+ import ReactNativeBrownfieldModule from './NativeReactNativeBrownfieldModule';
3
3
 
4
4
  const ReactNativeBrownfield = {
5
5
  popToNative: (animated?: boolean): void => {
6
6
  if (Platform.OS === 'ios') {
7
- ReactNativeBrownfieldModule.popToNative(animated);
7
+ ReactNativeBrownfieldModule.popToNative(!!animated);
8
8
  } else if (Platform.OS === 'android') {
9
- ReactNativeBrownfieldModule.popToNative();
9
+ ReactNativeBrownfieldModule.popToNative(false);
10
10
  } else {
11
11
  console.warn('Not implemented: popToNative');
12
12
  }
@@ -1,27 +0,0 @@
1
- require 'json'
2
-
3
- is_new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
4
- new_arch_enabled_flag = (is_new_arch_enabled ? " -DRCT_NEW_ARCH_ENABLED" : "")
5
- other_cflags = "$(inherited)" + new_arch_enabled_flag
6
-
7
- package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
8
-
9
- Pod::Spec.new do |spec|
10
- spec.name = "ReactNativeBrownfield"
11
- spec.version = package['version']
12
- spec.summary = package['description']
13
- spec.license = package['license']
14
-
15
- spec.authors = package['author']
16
- spec.homepage = package['homepage']
17
- spec.platform = :ios, "9.0"
18
-
19
- # s.source = { :git => "git@github.com/michalchudziak/react-native-brownfield.git", :tag => "v#{s.version}" }
20
- spec.source = { :path => "." }
21
- spec.source_files = "ios/**/*.{h,m,mm,swift}"
22
- spec.compiler_flags = new_arch_enabled_flag
23
- spec.pod_target_xcconfig = { 'OTHER_CPLUSPLUSFLAGS' => other_cflags, 'DEFINES_MODULE' => 'YES' }
24
-
25
- install_modules_dependencies(spec)
26
- spec.dependency 'ReactAppDependencyProvider'
27
- end
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _reactNative = require("react-native");
8
- var _default = exports.default = _reactNative.TurboModuleRegistry.getEnforcing('ReactNativeBrownfield');
9
- //# sourceMappingURL=RNBrownfieldSpec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["RNBrownfieldSpec.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAqBpCC,gCAAmB,CAACC,YAAY,CAAO,uBAAuB,CAAC","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- import { TurboModuleRegistry } from 'react-native';
4
- export default TurboModuleRegistry.getEnforcing('ReactNativeBrownfield');
5
- //# sourceMappingURL=RNBrownfieldSpec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["RNBrownfieldSpec.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAqBlD,eAAeA,mBAAmB,CAACC,YAAY,CAAO,uBAAuB,CAAC","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"RNBrownfieldSpec.d.ts","sourceRoot":"","sources":["../../../src/RNBrownfieldSpec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC;;OAEG;IACH,WAAW,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtC;;;OAGG;IACH,8BAA8B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvD;;;OAGG;IACH,4BAA4B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACtD;;AAED,wBAA+E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,qBAAqB;6BACA,OAAO,KAAG,IAAI;oDAUS,OAAO,KAAG,IAAI;CAS/D,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
File without changes
File without changes