@callstack/react-native-brownfield 0.0.2 → 0.1.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 (42) hide show
  1. package/README.md +2 -0
  2. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeActivity.kt +23 -5
  3. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt +10 -5
  4. package/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeFragment.kt +7 -5
  5. package/ios/ReactNativeBrownfield.m +1 -1
  6. package/ios/ReactNativeViewController.m +3 -1
  7. package/lib/commonjs/index.js +29 -0
  8. package/lib/commonjs/index.js.map +1 -0
  9. package/lib/module/index.js +23 -0
  10. package/lib/module/index.js.map +1 -0
  11. package/lib/typescript/src/index.d.ts +6 -0
  12. package/lib/typescript/src/index.d.ts.map +1 -0
  13. package/package.json +120 -17
  14. package/src/{index.js → index.ts} +3 -2
  15. package/.eslintrc.js +0 -6
  16. package/.flowconfig +0 -100
  17. package/CODE_OF_CONDUCT.md +0 -73
  18. package/android/.gradle/4.10/fileChanges/last-build.bin +0 -0
  19. package/android/.gradle/4.10/fileHashes/fileHashes.bin +0 -0
  20. package/android/.gradle/4.10/fileHashes/fileHashes.lock +0 -0
  21. package/android/.gradle/4.10/gc.properties +0 -0
  22. package/android/.gradle/5.1.1/fileChanges/last-build.bin +0 -0
  23. package/android/.gradle/5.1.1/fileHashes/fileHashes.lock +0 -0
  24. package/android/.gradle/5.1.1/gc.properties +0 -0
  25. package/android/.gradle/vcs-1/gc.properties +0 -0
  26. package/android/.idea/encodings.xml +0 -4
  27. package/android/.idea/gradle.xml +0 -12
  28. package/android/.idea/misc.xml +0 -14
  29. package/android/.idea/runConfigurations.xml +0 -12
  30. package/android/.idea/vcs.xml +0 -6
  31. package/android/.idea/workspace.xml +0 -126
  32. package/android/android.iml +0 -16
  33. package/android/local.properties +0 -8
  34. package/android/react-native-brownfield.iml +0 -201
  35. package/babel.config.js +0 -13
  36. package/docs/JAVA.md +0 -305
  37. package/docs/KOTLIN.md +0 -274
  38. package/docs/OBJECTIVE_C.md +0 -150
  39. package/docs/SWIFT.md +0 -164
  40. package/prettier.config.js +0 -7
  41. package/react-native.config.js +0 -9
  42. package/types/index.d.ts +0 -11
package/docs/JAVA.md DELETED
@@ -1,305 +0,0 @@
1
- ## Java
2
-
3
- React Native Brownfield provides first-class support for Java.
4
-
5
- ### Kotlin setup
6
-
7
- Even though the library provides a first-class Java support, it's written in Kotlin. To compile the project with React Native Brownfield, we need to make sure that our project's `build.gradle` file contains the required Gradle plugin.
8
-
9
- ```java
10
- buildscript {
11
- ext {
12
- ...
13
- kotlinVersion = '1.3.31'
14
- }
15
- dependencies {
16
- ...
17
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
18
- }
19
- }
20
- ```
21
-
22
- ### Linking
23
-
24
- 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:
25
-
26
- <details>
27
- <summary>react-native link</summary>
28
- Run the following command in your terminal:
29
-
30
- ```bash
31
- react-native link @callstack/react-native-brownfield
32
- ```
33
- </details>
34
-
35
- <details>
36
- <summary>Manually link the library on Android</summary>
37
-
38
- #### `android/settings.gradle`
39
- ```groovy
40
- include ':react-native-brownfield'
41
- project(':react-native-brownfield').projectDir = new File(rootProject.projectDir, '../node_modules/@callstack/react-native-brownfield/android')
42
- ```
43
-
44
- #### `android/app/build.gradle`
45
- ```groovy
46
- dependencies {
47
- ...
48
- implementation project(':react-native-brownfield')
49
- }
50
- ```
51
-
52
- #### `android/app/src/main/.../MainApplication.java`
53
- On top, where imports are:
54
-
55
- ```java
56
- import com.callstack.reactnativebrownfield.ReactNativeBrownfieldPackage;
57
- ```
58
-
59
- Add the `ReactNativeBrownfieldPackage` class to your list of exported packages.
60
-
61
- ```java
62
- @Override
63
- protected List<ReactPackage> getPackages() {
64
- return Arrays.asList(
65
- new MainReactPackage(),
66
- new ReactNativeBrownfieldPackage()
67
- );
68
- }
69
- ```
70
- </details>
71
-
72
- ### API Reference
73
-
74
- #### ReactNativeBrownfield
75
-
76
- You can import the object from:
77
-
78
- ```java
79
- import com.callstack.reactnativebrownfield.ReactNativeBrownfield;
80
- ```
81
-
82
- ---
83
-
84
- **Statics:**
85
-
86
- `initialize`
87
-
88
- A function used to initialize a React Native Brownfield singleton. Keep in mind that it **doesn't** load React Native bundle.
89
-
90
- Params:
91
-
92
- | Param | Required | Type | Description |
93
- | ----------------------- | -------- | -------------------- | --------------------------------------------------------- |
94
- | application | Yes | Application | Main application. |
95
- | rnHost | No* | ReactNativeHost | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). |
96
- | packages | No* | List<ReactPackage> | List of your React Native Native modules. |
97
- | options | No* | HashMap<String, Any> | Map of initial options. __Options listed below.__ |
98
-
99
- > * - Those fields aren't itself required, but at least one of them is. See examples below.
100
-
101
- Available options:
102
- - useDeveloperSupport: Boolean - Flag to use dev support.
103
- - packages: List<ReactPackage> - List of your React Native Native modules.
104
- - mainModuleName: String - Path to react native entry file.
105
-
106
- Examples:
107
-
108
- ```java
109
- private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
110
- @Override
111
- public boolean getUseDeveloperSupport() {
112
- return BuildConfig.DEBUG;
113
- }
114
-
115
- @Override
116
- protected List<ReactPackage> getPackages() {
117
- @SuppressWarnings("UnnecessaryLocalVariable")
118
- List<ReactPackage> packages = new PackageList(this).getPackages();
119
- // Packages that cannot be autolinked yet can be added manually here, for example:
120
- // packages.add(new MyReactNativePackage());
121
- return packages;
122
- }
123
-
124
- @Override
125
- protected String getJSMainModuleName() {
126
- return "index";
127
- }
128
- };
129
-
130
- ReactNativeBrownfield.initialize(this, mReactNativeHost);
131
- ```
132
-
133
- ```java
134
- List<ReactPackage> packages = new PackageList(this).getPackages();
135
-
136
- ReactNativeBrownfield.initialize(this, packages);
137
- ```
138
-
139
- ```java
140
- List<ReactPackage> packages = new PackageList(this).getPackages();
141
- HashMap<String, Object> options = new HashMap<String, Any>();
142
- options.put("packages", packages);
143
- options.put("mainModuleName", "example/index");
144
-
145
- ReactNativeBrownfield.initialize(this, options);
146
- ```
147
-
148
- ---
149
-
150
- `getShared`
151
-
152
- A singleton that keeps an instance of ReactNativeBrownfield object.
153
-
154
- Examples:
155
-
156
- ```java
157
- ReactNativeBrownfield.getShared()
158
- ```
159
-
160
- ---
161
-
162
- **Properties:**
163
-
164
- | Property | Type | Default | Description |
165
- | --------------- | --------------- | -------------- | --------------------------------------------------------- |
166
- | reactNativeHost | ReactNativeHost | null | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). |
167
-
168
- ---
169
-
170
- **Methods:**
171
-
172
- `startReactNative`
173
-
174
- Starts React Native, produces an instance of a bridge. You can use it to initialize React Native in your app.
175
-
176
- Params:
177
-
178
- | Param | Required | Type | Description |
179
- | ----------------------- | -------- | ------------- | ----------------------------------------------------- |
180
- | startReactNative | No | Lambda | Callback invoked after JS bundle is fully loaded. |
181
-
182
- Examples:
183
-
184
- ```java
185
- ReactNativeBrownfield.getShared().startReactNative();
186
- ```
187
-
188
- ```java
189
- ReactNativeBrownfield.getShared().startReactNative(init -> {
190
- Log.d("loaded", "React Native loaded");
191
- });
192
- ```
193
-
194
- ---
195
-
196
- #### ReactNativeActivity
197
-
198
- An activity rendering `ReactRootView` with a given module name. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. All the lifecycles are proxied to `ReactInstanceManager`.
199
-
200
- ```java
201
- import com.callstack.reactnativebrownfield.ReactNativeActivity;
202
- ```
203
-
204
- ---
205
-
206
- **Statics:**
207
-
208
- `createReactActivityIntent`
209
-
210
- Creates an Intent with ReactNativeActivity, you can use it as a parameter in the `startActivity` method in order to push a new activity with embedded React Native.
211
-
212
- Params:
213
-
214
- | Param | Required | Type | Description |
215
- | ----------------------- | -------- | ------------------------------------------- | ----------------------------------------------------------- |
216
- | context | Yes | Context | Application context. |
217
- | moduleName | Yes | String | Name of React Native component registered to `AppRegistry`. |
218
- | initialProps | No | Bundle || HashMap<String, *> || ReadableMap | Initial properties to be passed to React Native component. |
219
-
220
- Examples:
221
-
222
- ```java
223
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative");
224
- ```
225
-
226
- ```java
227
- Bundle bundle = new Bundle();
228
- bundle.putInt("score", 12);
229
-
230
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", bundle);
231
- ```
232
-
233
- ```java
234
- HashMap map = new HashMap<String, *>();
235
- map.put("score", 12);
236
-
237
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map);
238
- ```
239
-
240
- ```java
241
- WritableMap map = new WritableMap();
242
- map.putInt("score", 12);
243
-
244
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map);
245
- ```
246
-
247
- ---
248
-
249
- #### ReactNativeFragment
250
-
251
- An fragment rendering `ReactRootView` with a given module name. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. All the lifecycles are proxied to `ReactInstanceManager`. It's the simplest way to embed React Native into your navigation stack.
252
-
253
- ```java
254
- import com.callstack.reactnativebrownfield.ReactNativeActivity;
255
- ```
256
-
257
- ---
258
-
259
- **Statics:**
260
-
261
- `createReactNativeFragment`
262
-
263
- Creates a Fragment with ReactNativeActivity, you can use it as a parameter in the `startActivity` method in order to push a new activity with embedded React Native.
264
-
265
- Params:
266
-
267
- | Param | Required | Type | Description |
268
- | ----------------------- | -------- | ------------------------------------------- | ----------------------------------------------------------- |
269
- | moduleName | Yes | String | Name of React Native component registered to `AppRegistry`. |
270
- | initialProps | No | Bundle || HashMap<String, *> || ReadableMap | Initial properties to be passed to React Native component. |
271
-
272
- Examples:
273
-
274
- ```java
275
- ReactNativeActivity.createReactNativeFragment("ReactNative");
276
- ```
277
-
278
- ```java
279
- Bundle bundle = new Bundle();
280
- bundle.putInt("score", 12);
281
-
282
- ReactNativeActivity.createReactNativeFragment("ReactNative", bundle);
283
- ```
284
-
285
- ```java
286
- HashMap map = new HashMap<String, *>();
287
- map.put("score", 12);
288
-
289
- ReactNativeActivity.createReactNativeFragment("ReactNative", map);
290
- ```
291
-
292
- ```java
293
- WritableMap map = new WritableMap();
294
- map.putInt("score", 12);
295
-
296
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map);
297
- ```
298
-
299
- ---
300
-
301
- ### Example
302
-
303
- You can find an example app [here](../example/java).
304
-
305
-
package/docs/KOTLIN.md DELETED
@@ -1,274 +0,0 @@
1
- ## Kotlin
2
-
3
- React Native Brownfield provides first-class support for Kotlin.
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 @callstack/react-native-brownfield
15
- ```
16
- </details>
17
-
18
- <details>
19
- <summary>Manually link the library on Android</summary>
20
-
21
- #### `android/settings.gradle`
22
- ```groovy
23
- include ':react-native-brownfield'
24
- project(':react-native-brownfield').projectDir = new File(rootProject.projectDir, '../node_modules/@callstack/react-native-brownfield/android')
25
- ```
26
-
27
- #### `android/app/build.gradle`
28
- ```groovy
29
- dependencies {
30
- ...
31
- implementation project(':react-native-brownfield')
32
- }
33
- ```
34
-
35
- #### `android/app/src/main/.../MainApplication.kt`
36
- On top, where imports are:
37
-
38
- ```kotlin
39
- import com.callstack.reactnativebrownfield.ReactNativeBrownfieldPackage
40
- ```
41
-
42
- Add the `ReactNativeBrownfieldPackage` class to your list of exported packages.
43
-
44
- ```kotlin
45
- val packages = listOf<ReactPackage>(MainReactPackage(), ReactNativeBrownfieldPackage())
46
- ```
47
- </details>
48
-
49
- ### API Reference
50
-
51
- #### ReactNativeBrownfield
52
-
53
- You can import the object from:
54
-
55
- ```java
56
- import com.callstack.reactnativebrownfield.ReactNativeBrownfield
57
- ```
58
-
59
- ---
60
-
61
- **Statics:**
62
-
63
- `initialize`
64
-
65
- A function used to initialize a React Native Brownfield singleton. Keep in mind that it **doesn't** load React Native bundle.
66
-
67
- Params:
68
-
69
- | Param | Required | Type | Description |
70
- | ----------------------- | -------- | -------------------- | --------------------------------------------------------- |
71
- | application | Yes | Application | Main application. |
72
- | rnHost | No* | ReactNativeHost | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). |
73
- | packages | No* | List<ReactPackage> | List of your React Native Native modules. |
74
- | options | No* | HashMap<String, Any> | Map of initial options. __Options listed below.__ |
75
-
76
- > * - Those fields aren't itself required, but at least one of them is. See examples below.
77
-
78
- Available options:
79
- - useDeveloperSupport: Boolean - Flag to use dev support.
80
- - packages: List<ReactPackage> - List of your React Native Native modules.
81
- - mainModuleName: String - Path to react native entry file.
82
-
83
- Examples:
84
-
85
- ```kotlin
86
- val mReactNativeHost = object : ReactNativeHost(application) {
87
- override fun getUseDeveloperSupport(): Boolean {
88
- return BuildConfig.DEBUG
89
- }
90
-
91
- override fun getPackages(): List<ReactPackage> {
92
- return listOf<ReactPackage>(PackageList(this).getPackages())
93
- }
94
-
95
- override fun getJSMainModuleName(): String {
96
- return "index"
97
- }
98
- }
99
-
100
- ReactNativeBrownfield.initialize(this, mReactNativeHost)
101
- ```
102
-
103
- ```kotlin
104
- val packages = PackageList(this).getPackages()
105
-
106
- ReactNativeBrownfield.initialize(this, packages)
107
- ```
108
-
109
- ```kotlin
110
- val packages = PackageList(this).getPackages()
111
- val options = hashMapOf<String, Any>(
112
- "packages" to packages,
113
- "mainModuleName" to "example/index"
114
- )
115
-
116
- ReactNativeBrownfield.initialize(this, options)
117
- ```
118
-
119
- ---
120
-
121
- `shared`
122
-
123
- A singleton that keeps an instance of ReactNativeBrownfield object.
124
-
125
- Examples:
126
-
127
- ```kotlin
128
- ReactNativeBrownfield.shared
129
- ```
130
-
131
- ---
132
-
133
- **Properties:**
134
-
135
- | Property | Type | Default | Description |
136
- | --------------- | --------------- | -------------- | --------------------------------------------------------- |
137
- | reactNativeHost | ReactNativeHost | null | An instance of [ReactNativeHost](https://bit.ly/2ZnwgnA). |
138
-
139
- ---
140
-
141
- **Methods:**
142
-
143
- `startReactNative`
144
-
145
- Starts React Native, produces an instance of a bridge. You can use it to initialize React Native in your app.
146
-
147
- Params:
148
-
149
- | Param | Required | Type | Description |
150
- | ----------------------- | -------- | ------------- | ----------------------------------------------------- |
151
- | startReactNative | No | (loaded: boolean) -> Unit | Callback invoked after JS bundle is fully loaded. |
152
-
153
- Examples:
154
-
155
- ```kotlin
156
- ReactNativeBrownfield.shared.startReactNative()
157
- ```
158
-
159
- ```kotlin
160
- ReactNativeBrownfield.shared.startReactNative {
161
- Log.d("loaded", "React Native loaded");
162
- }
163
- ```
164
-
165
- ---
166
-
167
- #### ReactNativeActivity
168
-
169
- An activity rendering `ReactRootView` with a given module name. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. All the lifecycles are proxied to `ReactInstanceManager`.
170
-
171
- ```kotlin
172
- import com.callstack.reactnativebrownfield.ReactNativeActivity
173
- ```
174
-
175
- ---
176
-
177
- **Statics:**
178
-
179
- `createReactActivityIntent`
180
-
181
- Creates an Intent with ReactNativeActivity, you can use it as a parameter in the `startActivity` method in order to push a new activity with embedded React Native.
182
-
183
- Params:
184
-
185
- | Param | Required | Type | Description |
186
- | ----------------------- | -------- | ------------------------------------------- | ----------------------------------------------------------- |
187
- | context | Yes | Context | Application context. |
188
- | moduleName | Yes | String | Name of React Native component registered to `AppRegistry`. |
189
- | initialProps | No | Bundle || HashMap<String, *> || ReadableMap | Initial properties to be passed to React Native component. |
190
-
191
- Examples:
192
-
193
- ```kotlin
194
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative")
195
- ```
196
-
197
- ```kotlin
198
- val bundle = Bundle()
199
- bundle.putInt("score", 12)
200
-
201
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", bundle)
202
- ```
203
-
204
- ```kotlin
205
- val map = hasnMapOf<String, *>("score" to 12)
206
-
207
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map)
208
- ```
209
-
210
- ```kotlin
211
- val map = WritableMap();
212
- map.putInt("score", 12);
213
-
214
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map)
215
- ```
216
-
217
- ---
218
-
219
- #### ReactNativeFragment
220
-
221
- An fragment rendering `ReactRootView` with a given module name. It automatically uses an instance of a bridge created in `startReactNative` method. It works well with exposed JavaScript module. All the lifecycles are proxied to `ReactInstanceManager`. It's the simplest way to embed React Native into your navigation stack.
222
-
223
- ```kotlin
224
- import com.callstack.reactnativebrownfield.ReactNativeActivity
225
- ```
226
-
227
- ---
228
-
229
- **Statics:**
230
-
231
- `createReactNativeFragment`
232
-
233
- Creates a Fragment with ReactNativeActivity, you can use it as a parameter in the `startActivity` method in order to push a new activity with embedded React Native.
234
-
235
- Params:
236
-
237
- | Param | Required | Type | Description |
238
- | ----------------------- | -------- | ------------------------------------------- | ----------------------------------------------------------- |
239
- | moduleName | Yes | String | Name of React Native component registered to `AppRegistry`. |
240
- | initialProps | No | Bundle || HashMap<String, *> || ReadableMap | Initial properties to be passed to React Native component. |
241
-
242
- Examples:
243
-
244
- ```kotlin
245
- ReactNativeActivity.createReactNativeFragment("ReactNative")
246
- ```
247
-
248
- ```kotlin
249
- val bundle = new Bundle()
250
- bundle.putInt("score", 12)
251
-
252
- ReactNativeActivity.createReactNativeFragment("ReactNative", bundle)
253
- ```
254
-
255
- ```kotlin
256
- val map = hashMapOf<String, *>("score" to 12)
257
-
258
- ReactNativeActivity.createReactNativeFragment("ReactNative", map)
259
- ```
260
-
261
- ```kotlin
262
- val map = WritableMap()
263
- map.putInt("score", 12)
264
-
265
- ReactNativeActivity.createReactActivityIntent(context, "ReactNative", map)
266
- ```
267
-
268
- ---
269
-
270
- ### Example
271
-
272
- You can find an example app [here](../example/java).
273
-
274
-