@callstack/react-native-brownfield 0.1.0 → 1.0.0-rc.1

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 (47) hide show
  1. package/README.md +24 -1
  2. package/ReactBrownfield.podspec +22 -0
  3. package/android/build.gradle +103 -15
  4. package/android/gradle.properties +5 -0
  5. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt +82 -15
  6. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfieldPackage.kt +9 -9
  7. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeFragment.kt +139 -145
  8. package/android/src/newarch/ReactNativeBrownfieldModule.kt +37 -0
  9. package/android/src/oldarch/ReactNativeBrownfieldModule.kt +38 -0
  10. package/ios/ReactNativeBrownfield.swift +119 -0
  11. package/ios/ReactNativeBrownfieldModule.h +7 -2
  12. package/ios/ReactNativeBrownfieldModule.mm +25 -0
  13. package/ios/ReactNativeBrownfieldModule.swift +18 -0
  14. package/ios/ReactNativeView.swift +43 -0
  15. package/ios/ReactNativeViewController.swift +66 -0
  16. package/lib/commonjs/NativeReactNativeBrownfieldModule.js +2 -0
  17. package/lib/commonjs/NativeReactNativeBrownfieldModule.js.map +1 -0
  18. package/lib/commonjs/index.js +1 -28
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/module/NativeReactNativeBrownfieldModule.js +2 -0
  21. package/lib/module/NativeReactNativeBrownfieldModule.js.map +1 -0
  22. package/lib/module/index.js +1 -22
  23. package/lib/module/index.js.map +1 -1
  24. package/lib/typescript/commonjs/package.json +1 -0
  25. package/lib/typescript/commonjs/src/NativeReactNativeBrownfieldModule.d.ts +20 -0
  26. package/lib/typescript/commonjs/src/NativeReactNativeBrownfieldModule.d.ts.map +1 -0
  27. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  28. package/lib/typescript/module/package.json +1 -0
  29. package/lib/typescript/module/src/NativeReactNativeBrownfieldModule.d.ts +20 -0
  30. package/lib/typescript/module/src/NativeReactNativeBrownfieldModule.d.ts.map +1 -0
  31. package/lib/typescript/module/src/index.d.ts +6 -0
  32. package/lib/typescript/module/src/index.d.ts.map +1 -0
  33. package/package.json +62 -31
  34. package/src/NativeReactNativeBrownfieldModule.ts +23 -0
  35. package/src/index.ts +6 -7
  36. package/ReactNativeBrownfield.podspec +0 -20
  37. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeActivity.kt +0 -188
  38. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfieldModule.kt +0 -32
  39. package/ios/ReactNativeBrownfield.h +0 -24
  40. package/ios/ReactNativeBrownfield.m +0 -82
  41. package/ios/ReactNativeBrownfieldModule.m +0 -24
  42. package/ios/ReactNativeBrownfieldNotifications.h +0 -4
  43. package/ios/ReactNativeBrownfieldNotifications.m +0 -4
  44. package/ios/ReactNativeViewController.h +0 -15
  45. package/ios/ReactNativeViewController.m +0 -66
  46. package/lib/typescript/src/index.d.ts.map +0 -1
  47. /package/lib/typescript/{src → commonjs/src}/index.d.ts +0 -0
@@ -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];
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,24 +0,0 @@
1
- #import "ReactNativeBrownfieldModule.h"
2
- #import "ReactNativeBrownfieldNotifications.h"
3
-
4
- @implementation ReactNativeBrownfieldModule
5
-
6
- RCT_EXPORT_MODULE(ReactNativeBrownfield);
7
-
8
- RCT_EXPORT_METHOD(setPopGestureRecognizerEnabled:(BOOL)enabled) {
9
- NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@(enabled) forKey:@"enabled"];
10
-
11
- [[NSNotificationCenter defaultCenter]
12
- postNotificationName:TogglePopGestureRecognizerNotification
13
- object:nil userInfo:userInfo];
14
- }
15
-
16
- RCT_EXPORT_METHOD(popToNative:(BOOL)animated) {
17
- NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@(animated) forKey:@"animated"];
18
-
19
- [[NSNotificationCenter defaultCenter]
20
- postNotificationName:PopToNativeNotification
21
- object:nil userInfo:userInfo];
22
- }
23
-
24
- @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,66 +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
- dispatch_async(dispatch_get_main_queue(), ^{
53
- self.navigationController.interactivePopGestureRecognizer.enabled = enabled;
54
- });
55
- }
56
-
57
- - (void)popToNative:(NSNotification*)notification {
58
- NSDictionary *userInfo = notification.userInfo;
59
- BOOL animated = [[userInfo objectForKey:@"animated"] boolValue];
60
-
61
- dispatch_async(dispatch_get_main_queue(), ^{
62
- [self.navigationController popViewControllerAnimated:animated];
63
- });
64
- }
65
-
66
- @end
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,qBAAqB;6BACA,OAAO,KAAG,IAAI;oDAUS,OAAO,KAAG,IAAI;CAW/D,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
File without changes