@callstack/react-native-brownfield 0.0.3 → 1.0.0-rc.0

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 (65) hide show
  1. package/README.md +26 -1
  2. package/ReactNativeBrownfield.podspec +10 -3
  3. package/android/build.gradle +89 -16
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt +90 -18
  6. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfieldModule.kt +22 -21
  7. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfieldPackage.kt +9 -9
  8. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeFragment.kt +139 -143
  9. package/ios/ReactNativeBrownfield.swift +119 -0
  10. package/ios/ReactNativeBrownfieldModule.m +8 -11
  11. package/ios/ReactNativeBrownfieldModule.swift +18 -0
  12. package/ios/ReactNativeView.swift +42 -0
  13. package/ios/ReactNativeViewController.swift +66 -0
  14. package/lib/commonjs/RNBrownfieldSpec.js +9 -0
  15. package/lib/commonjs/RNBrownfieldSpec.js.map +1 -0
  16. package/lib/commonjs/index.js +31 -0
  17. package/lib/commonjs/index.js.map +1 -0
  18. package/lib/commonjs/package.json +1 -0
  19. package/lib/module/RNBrownfieldSpec.js +5 -0
  20. package/lib/module/RNBrownfieldSpec.js.map +1 -0
  21. package/lib/module/index.js +26 -0
  22. package/lib/module/index.js.map +1 -0
  23. package/lib/module/package.json +1 -0
  24. package/lib/typescript/src/RNBrownfieldSpec.d.ts +20 -0
  25. package/lib/typescript/src/RNBrownfieldSpec.d.ts.map +1 -0
  26. package/lib/typescript/src/index.d.ts +6 -0
  27. package/lib/typescript/src/index.d.ts.map +1 -0
  28. package/package.json +126 -18
  29. package/src/RNBrownfieldSpec.ts +23 -0
  30. package/src/{index.js → index.ts} +9 -9
  31. package/.eslintrc.js +0 -6
  32. package/.flowconfig +0 -100
  33. package/CODE_OF_CONDUCT.md +0 -73
  34. package/android/.gradle/4.10/fileChanges/last-build.bin +0 -0
  35. package/android/.gradle/4.10/fileHashes/fileHashes.bin +0 -0
  36. package/android/.gradle/4.10/fileHashes/fileHashes.lock +0 -0
  37. package/android/.gradle/4.10/gc.properties +0 -0
  38. package/android/.gradle/5.1.1/fileChanges/last-build.bin +0 -0
  39. package/android/.gradle/5.1.1/fileHashes/fileHashes.lock +0 -0
  40. package/android/.gradle/5.1.1/gc.properties +0 -0
  41. package/android/.gradle/vcs-1/gc.properties +0 -0
  42. package/android/.idea/encodings.xml +0 -4
  43. package/android/.idea/gradle.xml +0 -12
  44. package/android/.idea/misc.xml +0 -14
  45. package/android/.idea/runConfigurations.xml +0 -12
  46. package/android/.idea/vcs.xml +0 -6
  47. package/android/.idea/workspace.xml +0 -126
  48. package/android/android.iml +0 -16
  49. package/android/local.properties +0 -8
  50. package/android/react-native-brownfield.iml +0 -201
  51. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeActivity.kt +0 -170
  52. package/babel.config.js +0 -13
  53. package/docs/JAVA.md +0 -305
  54. package/docs/KOTLIN.md +0 -274
  55. package/docs/OBJECTIVE_C.md +0 -150
  56. package/docs/SWIFT.md +0 -164
  57. package/ios/ReactNativeBrownfield.h +0 -24
  58. package/ios/ReactNativeBrownfield.m +0 -82
  59. package/ios/ReactNativeBrownfieldNotifications.h +0 -4
  60. package/ios/ReactNativeBrownfieldNotifications.m +0 -4
  61. package/ios/ReactNativeViewController.h +0 -15
  62. package/ios/ReactNativeViewController.m +0 -64
  63. package/prettier.config.js +0 -7
  64. package/react-native.config.js +0 -9
  65. package/types/index.d.ts +0 -11
@@ -1,150 +0,0 @@
1
- ## Objective-C
2
-
3
- React Native Brownfield provides first-class support for Objective-C.
4
-
5
- ### Linking
6
-
7
- The library is meant to work with [auto linking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md). In case you can't use this feature, please check out the following options:
8
-
9
- <details>
10
- <summary>react-native link</summary>
11
- Run the following command in your terminal:
12
-
13
- ```bash
14
- react-native link @react-native-community/slider
15
- ```
16
- </details>
17
-
18
- <details>
19
- <summary>CocoaPods</summary>
20
- Add the following line to your `Podfile`:
21
-
22
- ```ruby
23
- pod 'ReactNativeBrownfield', :path => '../node_modules/@callstack/react-native-brownfield/ios'
24
- ```
25
- </details>
26
-
27
- <details>
28
- <summary>Manually link the library on iOS</summary>
29
-
30
- ### `Open project.xcodeproj in Xcode`
31
-
32
- Drag `ReactNativeBrownfield.xcodeproj` to your project on Xcode (usually under the Libraries group on Xcode):
33
-
34
- ![xcode-add](https://facebook.github.io/react-native/docs/assets/AddToLibraries.png)
35
-
36
- ### Link `libReactNativeBrownfield.a` binary with libraries
37
-
38
- Click on your main project file (the one that represents the `.xcodeproj`) select `Build Phases` and drag the static library from the `Products` folder inside the Library you are importing to `Link Binary With Libraries` (or use the `+` sign and choose library from the list):
39
-
40
- ![xcode-link](https://facebook.github.io/react-native/docs/assets/AddToBuildPhases.png)
41
- </details>
42
-
43
- ### API Reference
44
-
45
- #### ReactNativeBrownfield
46
-
47
- You can import the object from:
48
-
49
- ```objc
50
- #import <ReactNativeBrownfield/ReactNativeBrownfield.h>
51
- ```
52
-
53
- ---
54
-
55
- **Statics:**
56
-
57
- `shared`
58
-
59
- A singleton that keeps an instance of ReactNativeBrownfield object.
60
-
61
- Examples:
62
-
63
- ```objc
64
- [ReactNativeBrownfield shared]
65
- ```
66
-
67
- ---
68
-
69
- **Properties:**
70
-
71
- | Property | Type | Default | Description |
72
- | -------------------- | --------- | -------------- | -------------------------------------------------- |
73
- | bridge | RCTBridge | nil | Launch options, typically passed from AppDelegate. |
74
- | entryFile | NSString | index | Path to JavaScript root. |
75
- | fallbackResource | NSString | nil | Path to bundle fallback resource. |
76
- | bundlePath | NSString | main.jsbundle | Path to bundle fallback resource. |
77
-
78
- ---
79
-
80
- **Methods:**
81
-
82
- `startReactNative`
83
-
84
- Starts React Native, produces an instance of a bridge. You can use it to initialize React Native in your app.
85
-
86
- Params:
87
-
88
- | Param | Required | Type | Description |
89
- | ----------------------- | -------- | ------------- | ----------------------------------------------------- |
90
- | onBundleLoaded | No | void(^)(void) | Callback invoked after JS bundle is fully loaded. |
91
- | launchOptions | No | NSDictionary | Launch options, typically passed from AppDelegate. |
92
-
93
- Examples:
94
-
95
- ```objc
96
- [[ReactNativeBrownfield shared] startReactNative];
97
- ```
98
-
99
- ```objc
100
- [[ReactNativeBrownfield shared] startReactNative:^(void){
101
- NSLog(@"React Native started");
102
- }];
103
- ```
104
-
105
- ```objc
106
- [[ReactNativeBrownfield shared] startReactNative:^(void){
107
- NSLog(@"React Native started");
108
- }, launchOptions];
109
- ```
110
-
111
- ---
112
-
113
- #### ReactNativeViewController
114
-
115
- A view controller that's rendering `RCTRootView` within its bounds. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. It's the simplest way to embed React Native into your navigation stack.
116
-
117
- You can import it from:
118
-
119
- ```objc
120
- #import <ReactNativeBrownfield/ReactNativeViewController.h>
121
- ```
122
-
123
- ---
124
-
125
- **Constructors:**
126
-
127
- `[ReactNativeViewController initWithModuleName:moduleName andInitialProperties:initialProps]`
128
-
129
- | Param | Required | Type | Description |
130
- | ------------------ | --------- | ------------- | ------------------------------------------------------------- |
131
- | moduleName | Yes | NSString | Name of React Native component registered to `AppRegistry`. |
132
- | initialProperties | No | NSString | Initial properties to be passed to React Native component. |
133
-
134
- Examples:
135
-
136
- ```objc
137
- [[ReactNativeViewController alloc] initWithModuleName:@"ReactNative"]
138
- ```
139
-
140
- ```objc
141
- [[ReactNativeViewController alloc] initWithModuleName:@"ReactNative" andInitialProperties:@{@"score": 12}]
142
- ```
143
-
144
- ---
145
-
146
- ### Example
147
-
148
- You can find an example app [here](../example/objc).
149
-
150
-
package/docs/SWIFT.md DELETED
@@ -1,164 +0,0 @@
1
- ## Swift
2
-
3
- React Native Brownfield provides first-class support for Swift.
4
-
5
- ### `use_frameworks!` support
6
-
7
- It is possible to build `react-native-brownfield` with `use_frameworks!` directive in CocoaPods as long as `React` can be built this way.
8
-
9
- | React Native version | `use_frameworks!` compatibility |
10
- | -------------------------- | ------------------------------- |
11
- | <= 0.59.X | Compatible |
12
- | 0.60.X | Not compatible |
13
- | 0.61.0-rc.0 | Not compatible |
14
-
15
- Please reffer to [this issue](https://github.com/facebook/react-native/issues/25349) to learn more about `use_frameworks!` state in React Native.
16
-
17
- Until this behavior is fixed, you can access `react-native-brownfield` API in Swift via [Bridging Header](../example/swift/BridgingHeader.h).
18
-
19
- ### Linking
20
-
21
- The library is meant to work with [auto linking](https://github.com/react-native-community/cli/blob/master/docs/autolinking.md). In case you can't use this feature, please check out the following options:
22
-
23
- <details>
24
- <summary>react-native link</summary>
25
- Run the following command in your terminal:
26
-
27
- ```bash
28
- react-native link @react-native-community/slider
29
- ```
30
- </details>
31
-
32
- <details>
33
- <summary>CocoaPods</summary>
34
- Add the following line to your `Podfile`:
35
-
36
- ```ruby
37
- pod 'ReactNativeBrownfield', :path => '../node_modules/@callstack/react-native-brownfield/ios'
38
- ```
39
- </details>
40
-
41
- <details>
42
- <summary>Manually link the library on iOS</summary>
43
-
44
- ### `Open project.xcodeproj in Xcode`
45
-
46
- Drag `ReactNativeBrownfield.xcodeproj` to your project on Xcode (usually under the Libraries group on Xcode):
47
-
48
- ![xcode-add](https://facebook.github.io/react-native/docs/assets/AddToLibraries.png)
49
-
50
- ### Link `libReactNativeBrownfield.a` binary with libraries
51
-
52
- Click on your main project file (the one that represents the `.xcodeproj`) select `Build Phases` and drag the static library from the `Products` folder inside the Library you are importing to `Link Binary With Libraries` (or use the `+` sign and choose library from the list):
53
-
54
- ![xcode-link](https://facebook.github.io/react-native/docs/assets/AddToBuildPhases.png)
55
- </details>
56
-
57
- ### API Reference
58
-
59
- #### ReactNativeBrownfield
60
-
61
- You can import the object from:
62
-
63
- ```swift
64
- import ReactNativeBrownfield
65
- ```
66
-
67
- ---
68
-
69
- **Statics:**
70
-
71
- `shared()`
72
-
73
- A singleton that keeps an instance of ReactNativeBrownfield object.
74
-
75
- Examples:
76
-
77
- ```swift
78
- ReactNativeBrownfield.shared()
79
- ```
80
-
81
- ---
82
-
83
- **Properties:**
84
-
85
- | Property | Type | Default | Description |
86
- | -------------------- | --------- | -------------- | -------------------------------------------------- |
87
- | bridge | RCTBridge | nil | Launch options, typically passed from AppDelegate. |
88
- | entryFile | NSString | index | Path to JavaScript root. |
89
- | fallbackResource | NSString | nil | Path to bundle fallback resource. |
90
- | bundlePath | NSString | main.jsbundle | Path to bundle fallback resource. |
91
-
92
- ---
93
-
94
- **Methods:**
95
-
96
- `startReactNative`
97
-
98
- Starts React Native, produces an instance of a bridge. You can use it to initialize React Native in your app.
99
-
100
- Params:
101
-
102
- | Param | Required | Type | Description |
103
- | ----------------------- | -------- | ------------- | ----------------------------------------------------- |
104
- | onBundleLoaded | No | () -> void | Callback invoked after JS bundle is fully loaded. |
105
- | launchOptions | No | NSDictionary | Launch options, typically passed from AppDelegate. |
106
-
107
- Examples:
108
-
109
- ```swift
110
- ReactNativeBrownfield.shared().startReactNative()
111
- ```
112
-
113
- ```swift
114
- ReactNativeBrownfield.shared().startReactNative {
115
- print("React Native started")
116
- }
117
- ```
118
-
119
- ```swift
120
- ReactNativeBrownfield.shared().startReactNative({
121
- print("React Native started")
122
- }, launchOptions)
123
- ```
124
-
125
- ---
126
-
127
- #### ReactNativeViewController
128
-
129
- A view controller that's rendering `RCTRootView` within its bounds. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. It's the simplest way to embed React Native into your navigation stack.
130
-
131
- You can import it from:
132
-
133
- ```swift
134
- import ReactNativeBrownfield
135
- ```
136
-
137
- ---
138
-
139
- **Constructors:**
140
-
141
- `ReactNativeViewController(moduleName: moduleName, initialProperites:initialProperties)`
142
-
143
- | Param | Required | Type | Description |
144
- | ------------------ | --------- | ------------- | ------------------------------------------------------------- |
145
- | moduleName | Yes | NSString | Name of React Native component registered to `AppRegistry`. |
146
- | initialProperties | No | NSString | Initial properties to be passed to React Native component. |
147
-
148
- Examples:
149
-
150
- ```swift
151
- ReactNativeViewController(moduleName: "ReactNative")
152
- ```
153
-
154
- ```swift
155
- ReactNativeViewController(moduleName: "ReactNative", initialProperites:["score": 12])
156
- ```
157
-
158
- ---
159
-
160
- ### Example
161
-
162
- You can find an example app [here](../example/swift).
163
-
164
-
@@ -1,24 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <React/RCTBridge.h>
3
- #import <React/RCTBridgeDelegate.h>
4
-
5
- NS_ASSUME_NONNULL_BEGIN
6
-
7
- @interface ReactNativeBrownfield : NSObject<RCTBridgeDelegate> {
8
- void (^_onBundleLoaded)(void);
9
- }
10
-
11
- @property (nonatomic, copy) NSString *entryFile;
12
- @property (nonatomic, copy, nullable) NSString *fallbackResource;
13
- @property (nonatomic, copy) NSString *bundlePath;
14
- @property (nonatomic) RCTBridge *bridge;
15
-
16
- +(ReactNativeBrownfield*)shared;
17
-
18
- -(void)startReactNative;
19
- -(void)startReactNative:(void(^)(void))onBundleLoaded;
20
- -(void)startReactNative:(void(^)(void))onBundleLoaded launchOptions:(NSDictionary *)launchOptions;
21
-
22
- @end
23
-
24
- NS_ASSUME_NONNULL_END
@@ -1,82 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import <React/RCTBundleURLProvider.h>
3
-
4
- #import "ReactNativeBrownfield.h"
5
-
6
- @implementation ReactNativeBrownfield
7
-
8
- @synthesize entryFile = _entryFile;
9
- @synthesize fallbackResource = _fallbackResource;
10
- @synthesize bundlePath = _bundlePath;
11
- @synthesize bridge;
12
-
13
- + (ReactNativeBrownfield*)shared {
14
- static ReactNativeBrownfield *sharedBridgeManager = nil;
15
-
16
- static dispatch_once_t onceToken;
17
- dispatch_once(&onceToken, ^{
18
- sharedBridgeManager = [self new];
19
- });
20
-
21
- return sharedBridgeManager;
22
- }
23
-
24
- - (id)init {
25
- if (self = [super init]) {
26
- _entryFile = @"index";
27
- _fallbackResource = nil;
28
- _bundlePath = @"main.jsbundle";
29
- }
30
- return self;
31
- }
32
-
33
- - (void)startReactNative {
34
- [self startReactNative:nil];
35
- }
36
-
37
- - (void)startReactNative:(void(^)(void))onBundleLoaded {
38
- [self startReactNative:onBundleLoaded launchOptions:nil];
39
- }
40
-
41
- - (void)startReactNative:(void(^)(void))onBundleLoaded launchOptions:(NSDictionary *)launchOptions {
42
- if (bridge != nil) {
43
- return;
44
- }
45
-
46
- bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
47
-
48
- if (onBundleLoaded != nil) {
49
- _onBundleLoaded = [onBundleLoaded copy];
50
-
51
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jsLoaded:) name:RCTJavaScriptDidLoadNotification object:nil];
52
- }
53
- }
54
-
55
- - (void)jsLoaded:(NSNotification*)notification {
56
- _onBundleLoaded();
57
- _onBundleLoaded = nil;
58
- [[NSNotificationCenter defaultCenter] removeObserver:self];
59
- }
60
-
61
- #pragma mark - RCTBridgeDelegate Methods
62
-
63
- - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge {
64
- #if DEBUG
65
- return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:_entryFile fallbackResource:_fallbackResource];
66
- #else
67
- NSArray<NSString *> *resourceURLComponents = [_bundlePath componentsSeparatedByString:@"."];
68
- NSRange withoutLast;
69
-
70
- withoutLast.location = 0;
71
- withoutLast.length = [resourceURLComponents count] - 2;
72
-
73
- NSArray<NSString *> *resourceURLComponentsWithoutExtension = [resourceURLComponents subarrayWithRange:withoutLast];
74
-
75
- return [[NSBundle mainBundle]
76
- URLForResource:[resourceURLComponentsWithoutExtension componentsJoinedByString:@""]
77
- withExtension:resourceURLComponents[resourceURLComponents.count - 1]
78
- ];
79
- #endif
80
- }
81
-
82
- @end
@@ -1,4 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- extern NSString * const TogglePopGestureRecognizerNotification;
4
- extern NSString * const PopToNativeNotification;
@@ -1,4 +0,0 @@
1
- #import "ReactNativeBrownfieldNotifications.h"
2
-
3
- NSString * const TogglePopGestureRecognizerNotification = @"TogglePopGestureRecognizerNotification";
4
- NSString * const PopToNativeNotification = @"PopToNativeNotification";
@@ -1,15 +0,0 @@
1
- #import <UIKit/UIKit.h>
2
-
3
- NS_ASSUME_NONNULL_BEGIN
4
-
5
- @interface ReactNativeViewController : UIViewController
6
-
7
- @property (nonatomic, copy) NSString *moduleName;
8
- @property (nonatomic, copy, nullable) NSDictionary *initialProperties;
9
-
10
- -(instancetype)initWithModuleName:(NSString *)moduleName;
11
- -(instancetype)initWithModuleName:(NSString *)moduleName andInitialProperties:(NSDictionary*)initialProperties;
12
-
13
- @end
14
-
15
- NS_ASSUME_NONNULL_END
@@ -1,64 +0,0 @@
1
- #import "ReactNativeViewController.h"
2
- #import <React/RCTRootView.h>
3
- #import <React/RCTBridge.h>
4
- #import "ReactNativeBrownfield.h"
5
- #import "ReactNativeBrownfieldNotifications.h"
6
-
7
- @implementation ReactNativeViewController
8
-
9
- @synthesize moduleName = _moduleName;
10
- @synthesize initialProperties = _initialProperties;
11
-
12
- -(instancetype)initWithModuleName:(NSString *)moduleName {
13
- return [self initWithModuleName:moduleName andInitialProperties:nil];
14
- }
15
-
16
- -(instancetype)initWithModuleName:(NSString *)moduleName
17
- andInitialProperties:(NSDictionary*)initialProperties {
18
- self = [super init];
19
- _moduleName = moduleName;
20
- _initialProperties = initialProperties;
21
-
22
- return self;
23
- }
24
-
25
- -(void)viewDidLoad {
26
- RCTBridge *bridge = [[ReactNativeBrownfield shared] bridge];
27
- if (bridge == nil) {
28
- NSLog(@"Error: You need to start React Native in order to use ReactNativeViewController, make sure to run [[BridgeManager shared] startReactNative] before instantiating it.");
29
- return;
30
- }
31
-
32
- if (_moduleName) {
33
- RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:_moduleName initialProperties:_initialProperties];
34
- self.view = reactView;
35
-
36
- [[NSNotificationCenter defaultCenter]
37
- addObserver:self selector:@selector(togglePopGestureRecognizer:)
38
- name:TogglePopGestureRecognizerNotification object:nil];
39
- [[NSNotificationCenter defaultCenter]
40
- addObserver:self selector:@selector(popToNative:)
41
- name:PopToNativeNotification object:nil];
42
- }
43
- }
44
-
45
- - (void)dealloc {
46
- [[NSNotificationCenter defaultCenter] removeObserver:self];
47
- }
48
-
49
- - (void)togglePopGestureRecognizer:(NSNotification*)notification {
50
- NSDictionary *userInfo = notification.userInfo;
51
- BOOL enabled = [[userInfo objectForKey:@"enabled"] boolValue];
52
- self.navigationController.interactivePopGestureRecognizer.enabled = enabled;
53
- }
54
-
55
- - (void)popToNative:(NSNotification*)notification {
56
- NSDictionary *userInfo = notification.userInfo;
57
- BOOL animated = [[userInfo objectForKey:@"animated"] boolValue];
58
-
59
- dispatch_async(dispatch_get_main_queue(), ^{
60
- [self.navigationController popViewControllerAnimated:animated];
61
- });
62
- }
63
-
64
- @end
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- singleQuote: true,
3
- trailingComma: 'all',
4
- bracketSpacing: false,
5
- jsxBracketSameLine: true,
6
- parser: 'flow',
7
- };
@@ -1,9 +0,0 @@
1
- const root = process.cwd();
2
-
3
- module.exports = {
4
- dependencies: {
5
- 'react-native-brownfield': {
6
- root,
7
- },
8
- },
9
- };
package/types/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- declare module 'react-native-brownfield' {
2
- /**
3
- * A method to pop to native screen used to push React Native experience.
4
- */
5
- export function popToNative(animated?: boolean): void;
6
-
7
- /**
8
- * A method used to toggle iOS native back gesture and Android hardware back button.
9
- */
10
- export function setNativeGesturesAndButtonsEnabled(enabled: boolean): void;
11
- }