├── .gitignore ├── .npmignore ├── EXTRA_FEATURES.md ├── LICENSE ├── MANUAL_INSTALATION.md ├── NPM_SCRIPTS.md ├── OBSERVATIONS.md ├── README.md ├── SETUP.md ├── android ├── .gitignore ├── build.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ └── main │ ├── AndroidManifest.xml │ └── java │ └── com │ └── fabricio │ └── vergal │ └── RNWorkers │ ├── RNWorker.java │ ├── RNWorkersManager.java │ ├── RNWorkersModule.java │ ├── RNWorkersPackage.java │ ├── RNWorkersUtils.java │ └── SimpleLifecycleCallbacks.java ├── example ├── .babelrc ├── .buckconfig ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── README.md ├── __tests__ │ ├── index.android.js │ └── index.ios.js ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── assets │ │ │ ├── index.worker.bundle │ │ │ ├── index.worker.bundle.meta │ │ │ └── index.worker.map │ │ │ ├── java │ │ │ └── com │ │ │ │ └── rnapp │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ └── node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png │ │ │ ├── drawable-mdpi │ │ │ └── node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png │ │ │ ├── drawable-xhdpi │ │ │ └── node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png │ │ │ ├── drawable-xxhdpi │ │ │ └── node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png │ │ │ ├── drawable-xxxhdpi │ │ │ └── node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── keystores │ │ ├── BUCK │ │ └── debug.keystore.properties │ └── settings.gradle ├── index.android.js ├── index.ios.js ├── index.worker.js ├── ios │ ├── rnapp.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── rnapp.xcscheme │ ├── rnapp │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── rnapp-Bridging-Header.h │ └── rnappTests │ │ ├── Info.plist │ │ └── rnappTests.m └── package.json ├── index.js ├── ios ├── RNWorkers.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── fabriciovergal.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── fabriciovergal.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── RNWorkers.xcscheme │ │ └── xcschememanagement.plist └── RNWorkers │ ├── RNWorkers.h │ ├── RNWorkers.m │ ├── RNWorkersManager.h │ └── RNWorkersManager.m ├── package.json └── src └── createWorker.js /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | .idea -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /example 2 | -------------------------------------------------------------------------------- /EXTRA_FEATURES.md: -------------------------------------------------------------------------------- 1 | 2 | ## Extra Features 3 | 4 | All extra features must be defined before creating any worker. 5 | 6 | ### Simulation 7 | 8 | With Simulation enabled no aditional worker will started and the worker code on app main process. 9 | To make it works you need to load the workers entry point when enabled. 10 | You don't need to start any aditional packager using this option. 11 | 12 | ```java 13 | public class MainApplication extends Application implements ReactApplication { 14 | 15 | @Override 16 | public void onCreate() { 17 | super.onCreate(); 18 | SoLoader.init(this, /* native exopackage */ false); 19 | RNWorkersManager.getInstance().setSimulationEnabled(true); 20 | RNWorkersManager.getInstance().init(this, BuildConfig.DEBUG); 21 | } 22 | } 23 | ``` 24 | 25 | ```swift 26 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool{ 27 |   RNWorkersManager.sharedInstance().simulationEnabled = true 28 | RNWorkersManager.sharedInstance().initWorker() 29 | 30 | (...) 31 | } 32 | ``` 33 | 34 | ```javascript 35 | 36 | import { Worker, isSimulationEnabled } from 'rn-workers'; 37 | 38 | if (isSimulationEnabled) { 39 | /* eslint-disable global-require */ 40 | require('../../../index.worker'); 41 | /* eslint-enable global-require */ 42 | } 43 | ``` 44 | 45 | 46 | 47 | ### PreferResouce (Not supported on iOS) 48 | 49 | With PreferResource enabled the library will try to load a pre generated worker jsbundle from given resource name. 50 | You don't need to start any aditional packager using this option. 51 | 52 | ```java 53 | public class MainApplication extends Application implements ReactApplication { 54 | 55 | @Override 56 | public void onCreate() { 57 | super.onCreate(); 58 | SoLoader.init(this, /* native exopackage */ false); 59 | RNWorkersManager.getInstance().setPreferResourceEnabled(true); 60 | RNWorkersManager.getInstance().init(this, BuildConfig.DEBUG); 61 | } 62 | } 63 | ``` 64 | 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 fabriciovergal 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MANUAL_INSTALATION.md: -------------------------------------------------------------------------------- 1 | ### Manual Instalation 2 | 3 | #### iOS 4 | 5 | 1. In the XCode's "Project navigator", right click on your project's Libraries folder ➜ `Add Files to <...>` 6 | 2. Go to `node_modules` ➜ `rn-workers` ➜ `ios` ➜ select `RNWorkers.xcodeproj` 7 | 3. Add `RNWorkers.a` to `Build Phases -> Link Binary With Libraries` 8 | 4. Pray and try to compile 9 | 10 | #### Android 11 | 12 | 1. Add the following lines to `android/settings.gradle`: 13 | 14 | ```gradle 15 | include ':rn-workers' 16 | project(':rn-workers').projectDir = new File(rootProject.projectDir, '../node_modules/rn-workers/android') 17 | ``` 18 | 19 | 2. Add the compile line to the dependencies in `android/app/build.gradle`: 20 | 21 | ```gradle 22 | dependencies { 23 | compile project(':rn-workers') 24 | } 25 | ``` 26 | 3. Add the import and link the package in `MainApplication.java`: 27 | 28 | ```java 29 |   30 |    public class MainApplication extends Application implements ReactApplication { 31 | @Override 32 | protected List getPackages() { 33 | return Arrays.asList( 34 | new MainReactPackage(), 35 |                new RNWorkersPackage() // <-- add this line 36 | ); 37 | } 38 | } 39 | ``` 40 | 41 | -------------------------------------------------------------------------------- /NPM_SCRIPTS.md: -------------------------------------------------------------------------------- 1 | # NPM Scripts 2 | 3 | 4 | 5 | ```json 6 | "start-app": "node node_modules/react-native/local-cli/cli.js start --reset-cache", 7 | 8 | "start-worker": "node node_modules/react-native/local-cli/cli.js start --port 8082 --reset-cache", 9 | 10 | "start": "concurrently --kill-others \"npm run start-app\" \"npm run start-worker\"", 11 | 12 | "adb-reverse": "adb reverse tcp:8081 tcp:8081 && adb reverse tcp:8082 tcp:8082", 13 | 14 | "bundle-app-ios": "node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./ios --entry-file index.ios.js --platform ios --bundle-output ./ios/main.jsbundle --sourcemap-output ./sourcemap/ios.main.map", 15 | 16 | "bundle-app-android": "node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.android.js --platform android --bundle-output ./android/app/src/main/assets/index.android.bundle --sourcemap-output ./sourcemap/android.main.map", 17 | 18 | "bundle-worker-ios": "node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./ios --entry-file index.worker.js --platform ios --bundle-output ./ios/worker.jsbundle --sourcemap-output ./sourcemap/ios.worker.map", 19 | 20 | "bundle-worker-android": "node node_modules/react-native/local-cli/cli.js bundle --dev false --assets-dest ./android/app/src/main/res/ --entry-file index.worker.js --platform android --bundle-output ./android/app/src/main/assets/index.worker.bundle --sourcemap-output ./sourcemap/android.worker.map", 21 | 22 | "bundle-ios": "npm run bundle-app-ios && npm run bundle-worker-ios", 23 | 24 | "bundle-android": "npm run bundle-app-android && npm run bundle-worker-android", 25 | 26 | "bundle": "concurrently --kill-others \"npm run bundle-ios\" \"run bundle-android\" 27 | ``` 28 | -------------------------------------------------------------------------------- /OBSERVATIONS.md: -------------------------------------------------------------------------------- 1 | # Observation 2 | 3 | * To start the project you need to manually start a second Packager using port 8082 4 | * Release bundle packaging must be done manually 5 | 6 | ### iOS 7 | 8 | * Sometime you need to start and stop the debugger to fully reload the worker js 9 | * Start the app debugger will automatically start the worker debugger 10 | 11 | ### Android 12 | 13 | * You need to manually execute adb reverse tcp:8082 tcp:8082 14 | * Two DevMenu will apears on shake (one for app and other for worker) 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NO LONGER MAINTAINED 2 | 3 | Please consider using instead: https://github.com/joltup/react-native-threads 4 | 5 | # react-native-workers (RN 0.43^) 6 | Do heavy data process outside of your UI JS thread. 7 | 8 | Before using this kind of solution you should check if [InteractionManager.runAfterInteractions](https://facebook.github.io/react-native/docs/interactionmanager.html) is not enough for your needs, because creating a aditional worker can considerably increase app memory usage. 9 | 10 | I mostly use this library for a personal project, that wrap a native database with a graphql api. So the updates may follow my needs, but any PR is welcome. 11 | 12 | ### Automatic Instalation 13 | ``` 14 | npm install --save rn-workers 15 | react-native link rn-workers 16 | ``` 17 | Or [Install manually](https://github.com/fabriciovergal/react-native-workers/blob/master/MANUAL_INSTALATION.md) 18 | 19 | Prepare your project following this [SETUP GUIDE](https://github.com/fabriciovergal/react-native-workers/blob/master/SETUP.md) 20 | 21 | ### App side 22 | 23 | ```javascript 24 | //index.ios.js 25 | import { Worker } from 'rn-workers' 26 | 27 | export default class rnapp extends React.Component { 28 | 29 | componentDidMount () { 30 | //Create using default worker port (8082) 31 | this.worker = new Worker(); 32 | 33 | //Create worker pointing to custom one 34 | this.worker2 = new Worker(8083); 35 | 36 | 37 | //Add listener to receve messages 38 | this.worker.onmessage = message => this.setState({ 39 | text: message, 40 | count: this.state.count + 1 41 | }); 42 | 43 | //Send message to worker (Only strings is allowed for now) 44 |            this.worker.postMessage("Hey Worker!") 45 | } 46 | 47 | componentWillUnmount () { 48 | //Terminate worker 49 | this.worker.terminate(); 50 | } 51 | 52 | (...) 53 | } 54 | ``` 55 | 56 | ### Worker side 57 | 58 | ```javascript 59 | //index.worker.js 60 | import { WorkerService } from 'rn-workers' 61 | 62 | const worker = new WorkerService(); 63 | worker.onmessage = message => { 64 | //Reply the message back to app 65 | worker.postMessage("Hello from the other side (" + message + ")") 66 | }; 67 | 68 | ``` 69 | 70 | ## Aditional Information 71 | 72 | * [Observation](https://github.com/fabriciovergal/react-native-workers/blob/master/OBSERVATIONS.md) 73 | * [Other features](https://github.com/fabriciovergal/react-native-workers/blob/master/EXTRA_FEATURES.md) 74 | * [Npm useful scripts](https://github.com/fabriciovergal/react-native-workers/blob/master/NPM_SCRIPTS.md) 75 | 76 | # License 77 | ~~Cancer~~ GPL ..... just kindind, its Apache 2.0 78 | -------------------------------------------------------------------------------- /SETUP.md: -------------------------------------------------------------------------------- 1 | # Setup 2 | 3 | ## iOS 4 | 5 | ```swift 6 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool{ 7 | //CRITICAL: Must be initialized before creation of rootView to be possible to debug on chrome console 8 | RNWorkersManager.sharedInstance().initWorker() 9 | 10 | // Objective C equivalent 11 | // [[RNWorkersManager sharedInstance] initWorker]; 12 | 13 | let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index.ios", 14 | fallbackResource: "main") 15 | 16 | let rootView = RCTRootView.init(bundleURL: jsCodeLocation, moduleName: "rnapp", initialProperties: nil, launchOptions: launchOptions) 17 | rootView?.backgroundColor = UIColor.init(colorLiteralRed: 1, green: 1, blue: 1, alpha: 1) 18 | 19 | let rootViewController = UIViewController() 20 | rootViewController.view = rootView 21 | 22 | //Pass rootView referece 23 | RNWorkersManager.sharedInstance().start(with: rootView) 24 | 25 | // Objective C equivalent 26 | // [[RNWorkersManager sharedInstance] startWorkersWithRootView:rootView]; 27 | 28 | self.window = UIWindow.init(frame: UIScreen.main.bounds) 29 | self.window!.rootViewController = rootViewController 30 | self.window!.makeKeyAndVisible() 31 | 32 | return true 33 | } 34 | ``` 35 | 36 | ## Android 37 | 38 | ```java 39 | public class MainApplication extends Application implements ReactApplication { 40 | 41 | (...) 42 | 43 | @Override 44 | public void onCreate() { 45 | super.onCreate(); 46 | SoLoader.init(this, /* native exopackage */ false); 47 | //Initialize Manager instance 48 | RNWorkersManager.getInstance().init(this, BuildConfig.DEBUG); 49 | } 50 | } 51 | ``` 52 | 53 | ```java 54 | public class MainActivity extends ReactActivity { 55 | 56 | (...) 57 | 58 | @Override 59 | protected void onCreate(Bundle savedInstanceState) { 60 | //CRITICAL: Must be started before super.onCreate to be possible to debug on chrome console 61 | RNWorkersManager.getInstance().startWorkers(); 62 | super.onCreate(savedInstanceState); 63 | } 64 | } 65 | ``` 66 | 67 | ## Javascript 68 | 69 | 1. Create a index.worker.js in the react-native root project (same level of index.ios.js and index.android.js) 70 | 2. import a worker.jsbundle in iOS Project and index.worker.jsbundle on Android Project 71 | 72 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | # Android/IntelliJ 2 | # 3 | build/ 4 | .idea 5 | .gradle 6 | local.properties 7 | *.iml -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 22 10 | versionCode 1 11 | versionName "1.0" 12 | ndk { 13 | abiFilters "armeabi-v7a", "x86" 14 | } 15 | } 16 | } 17 | 18 | repositories { 19 | mavenLocal() 20 | jcenter() 21 | maven { 22 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 23 | url "$rootDir/../node_modules/react-native/android" 24 | } 25 | } 26 | 27 | dependencies { 28 | compile 'com.facebook.react:react-native:+' 29 | } 30 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /android/src/main/java/com/fabricio/vergal/RNWorkers/RNWorker.java: -------------------------------------------------------------------------------- 1 | package com.fabricio.vergal.RNWorkers; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactInstanceManager.ReactInstanceEventListener; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.bridge.ReactContext; 11 | import com.facebook.react.devsupport.RedBoxHandler; 12 | import com.facebook.react.shell.MainReactPackage; 13 | 14 | import java.util.ArrayList; 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | import javax.annotation.Nullable; 19 | 20 | import static com.fabricio.vergal.RNWorkers.RNWorkersUtils.replacePrefs; 21 | 22 | 23 | public class RNWorker implements ReactInstanceEventListener { 24 | 25 | public static final String DEBUG_HOST_FORMAT = "localhost:%d"; 26 | public static final String DEFAULT_JS_ENTRY_POINT = "index.worker"; 27 | public static final String DEFAULT_JS_BUNDLE_ASSET = "index.worker.bundle"; 28 | public static final String PREFS_DEBUG_SERVER_HOST_KEY = "debug_http_host"; 29 | public static final int DEFAULT_WORKER_PORT = 8082; 30 | 31 | private final Application mApplication; 32 | private final int mPort; 33 | private final String mEntryPoint; 34 | private final String mBundleAsset; 35 | private final String mBundleFile; 36 | private final RedBoxHandler mRedBoxHandler; 37 | private final List mPackages; 38 | private final boolean mDeveloperSupport; 39 | 40 | private ReactApplicationContext mReactContext; 41 | private ReactNativeHost mHost; 42 | 43 | public RNWorker(final Application application, 44 | final int port, 45 | final String entryPoint, 46 | final String bundleAsset, 47 | final String bundleFile, 48 | final RedBoxHandler redBoxHandler, 49 | final List packages, 50 | final boolean developerSupport) { 51 | mApplication = application; 52 | mPort = port; 53 | mEntryPoint = entryPoint; 54 | mBundleAsset = bundleAsset; 55 | mBundleFile = bundleFile; 56 | mRedBoxHandler = redBoxHandler; 57 | mPackages = packages; 58 | mDeveloperSupport = developerSupport; 59 | } 60 | 61 | public static RNWorker createDefault( 62 | final T application, final boolean developerSupport) { 63 | return new Builder(application, developerSupport) 64 | .entryPoint(DEFAULT_JS_ENTRY_POINT) 65 | .bundleAsset(DEFAULT_JS_BUNDLE_ASSET) 66 | .port(DEFAULT_WORKER_PORT) 67 | .build(); 68 | } 69 | 70 | 71 | public void start(final boolean preferResource) { 72 | createHost(preferResource); 73 | mHost.getReactInstanceManager().addReactInstanceEventListener(this); 74 | if (!mHost.getReactInstanceManager().hasStartedCreatingInitialContext()) { 75 | mHost.getReactInstanceManager().createReactContextInBackground(); 76 | } 77 | 78 | mHost.getReactInstanceManager().onHostResume(null, null); 79 | } 80 | 81 | public void stop() { 82 | mHost.getReactInstanceManager().onHostPause(); 83 | mHost.getReactInstanceManager().removeReactInstanceEventListener(this); 84 | mHost.getReactInstanceManager().onHostDestroy(); 85 | } 86 | 87 | public int getPort() { 88 | return mPort; 89 | } 90 | 91 | public ReactApplicationContext getReactContext() { 92 | return mReactContext; 93 | } 94 | 95 | @Override 96 | public void onReactContextInitialized(ReactContext context) { 97 | mReactContext = (ReactApplicationContext) context; 98 | } 99 | 100 | private void createHost(final boolean preferResource) { 101 | if (mHost == null) { 102 | if (preferResource && mBundleAsset == null && mBundleFile == null) { 103 | throw new RuntimeException("preferResource is enabled but no resource was provided"); 104 | } 105 | 106 | mHost = new ReactNativeHost(mApplication) { 107 | @Override 108 | public boolean getUseDeveloperSupport() { 109 | return preferResource ? false : mDeveloperSupport; 110 | } 111 | 112 | @Override 113 | protected List getPackages() { 114 | return mPackages; 115 | } 116 | 117 | @Override 118 | protected String getJSMainModuleName() { 119 | return preferResource ? null : mEntryPoint; 120 | } 121 | 122 | @Nullable 123 | @Override 124 | protected String getBundleAssetName() { 125 | return mBundleAsset; 126 | } 127 | 128 | @Nullable 129 | @Override 130 | protected String getJSBundleFile() { 131 | return mBundleFile; 132 | } 133 | 134 | @Nullable 135 | @Override 136 | protected RedBoxHandler getRedBoxHandler() { 137 | return mRedBoxHandler; 138 | } 139 | }; 140 | 141 | 142 | if (!preferResource && mDeveloperSupport) { 143 | try { 144 | replacePrefs(mApplication, mHost, mPort, DEBUG_HOST_FORMAT, 145 | PREFS_DEBUG_SERVER_HOST_KEY); 146 | } catch (Exception e) { 147 | } 148 | } 149 | 150 | } 151 | } 152 | 153 | public static class Builder { 154 | 155 | private final Application mApplication; 156 | private final List mPackages; 157 | private RedBoxHandler mRedBoxHandler; 158 | private String mEntryPoint; 159 | private String mBundleAsset; 160 | private String mBundleFile; 161 | private boolean mDeveloperSupport; 162 | private int mPort; 163 | 164 | public Builder(final Application application, final boolean developerSupport) { 165 | mApplication = application; 166 | mDeveloperSupport = developerSupport; 167 | mPackages = new ArrayList<>(); 168 | mEntryPoint = null; 169 | mBundleAsset = null; 170 | mBundleFile = null; 171 | mPort = 8082; 172 | } 173 | 174 | public Builder entryPoint(final String entryPoint) { 175 | mEntryPoint = entryPoint; 176 | return this; 177 | } 178 | 179 | public Builder bundleAsset(final String bundleAsset) { 180 | mBundleAsset = bundleAsset; 181 | return this; 182 | } 183 | 184 | 185 | public Builder bundleFile(final String bundleFile) { 186 | mBundleFile = bundleFile; 187 | return this; 188 | } 189 | 190 | public Builder redBoxHandler(final RedBoxHandler handler) { 191 | mRedBoxHandler = handler; 192 | return this; 193 | } 194 | 195 | 196 | public Builder port(final int port) { 197 | mPort = port; 198 | return this; 199 | } 200 | 201 | public Builder packages(final ReactPackage pkg, final ReactPackage... pkgs) { 202 | if (pkg != null) { 203 | mPackages.add(pkg); 204 | } 205 | 206 | if (pkgs != null && pkgs.length > 0) { 207 | mPackages.addAll(Arrays.asList(pkgs)); 208 | } 209 | 210 | return this; 211 | } 212 | 213 | public Builder packages(final List pkgs) { 214 | if (pkgs != null && pkgs.size() > 0) { 215 | mPackages.addAll(pkgs); 216 | } 217 | 218 | return this; 219 | } 220 | 221 | public RNWorker build() { 222 | 223 | 224 | boolean containMainReactPackage = false; 225 | boolean containRNWorkerPackage = false; 226 | for (final ReactPackage pkg : mPackages) { 227 | if (pkg instanceof MainReactPackage) { 228 | containMainReactPackage = true; 229 | } else if (pkg instanceof RNWorkersPackage) { 230 | containRNWorkerPackage = true; 231 | } 232 | } 233 | 234 | if (!containMainReactPackage) { 235 | mPackages.add(new MainReactPackage()); 236 | } 237 | 238 | if (!containRNWorkerPackage) { 239 | mPackages.add(new RNWorkersPackage()); 240 | } 241 | 242 | return new RNWorker(mApplication, mPort, mEntryPoint, mBundleAsset, mBundleFile, 243 | mRedBoxHandler, mPackages, mDeveloperSupport); 244 | } 245 | } 246 | } -------------------------------------------------------------------------------- /android/src/main/java/com/fabricio/vergal/RNWorkers/RNWorkersManager.java: -------------------------------------------------------------------------------- 1 | package com.fabricio.vergal.RNWorkers; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager.ReactInstanceEventListener; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.bridge.ReactContext; 11 | 12 | import java.util.ArrayList; 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class RNWorkersManager { 17 | 18 | private static RNWorkersManager sInstance; 19 | private ReactNativeHost mMainHost; 20 | private ReactApplicationContext mMainReactContext; 21 | private boolean mSimulationEnabled = false; 22 | private boolean mPreferResourceEnabled = false; 23 | private final ReactInstanceEventListener mMainHostListener = new ReactInstanceEventListener() { 24 | @Override 25 | public void onReactContextInitialized(ReactContext context) { 26 | mMainReactContext = (ReactApplicationContext) context; 27 | } 28 | }; 29 | private List mRNWorkers; 30 | private final SimpleLifecycleCallbacks mLifecycleCallbacks = new SimpleLifecycleCallbacks() { 31 | @Override 32 | public void onActivityDestroyed(Activity activity) { 33 | if (mSimulationEnabled) { 34 | return; 35 | } 36 | 37 | for (final RNWorker worker : mRNWorkers) { 38 | worker.stop(); 39 | } 40 | } 41 | }; 42 | 43 | public static RNWorkersManager getInstance() { 44 | if (sInstance == null) { 45 | sInstance = new RNWorkersManager(); 46 | } 47 | 48 | return sInstance; 49 | } 50 | 51 | public void init(final T reactApp, 52 | final RNWorker... workers) { 53 | mMainHost = reactApp.getReactNativeHost(); 54 | mRNWorkers = new ArrayList<>(); 55 | if (workers != null && workers.length > 0) { 56 | mRNWorkers.addAll(Arrays.asList(workers)); 57 | } 58 | 59 | mMainHost.getReactInstanceManager().addReactInstanceEventListener(mMainHostListener); 60 | reactApp.registerActivityLifecycleCallbacks(mLifecycleCallbacks); 61 | } 62 | 63 | public void init( 64 | final T reactApp, boolean developerSupport) { 65 | init(reactApp, RNWorker.createDefault(reactApp, developerSupport)); 66 | } 67 | 68 | 69 | public void startWorkers() { 70 | if (mSimulationEnabled) { 71 | return; 72 | } 73 | 74 | for (final RNWorker worker : mRNWorkers) { 75 | worker.start(mPreferResourceEnabled); 76 | } 77 | } 78 | 79 | public ReactApplicationContext getMainReactContext() { 80 | return mMainReactContext; 81 | } 82 | 83 | public ReactApplicationContext getWorkerReactContext(int port) { 84 | if (mSimulationEnabled) { 85 | return mMainReactContext; 86 | } 87 | 88 | 89 | for (final RNWorker worker : mRNWorkers) { 90 | if (worker.getPort() == port) { 91 | return worker.getReactContext(); 92 | } 93 | } 94 | 95 | return null; 96 | } 97 | 98 | public boolean isSimulationEnabled() { 99 | return mSimulationEnabled; 100 | } 101 | 102 | public void setSimulationEnabled(boolean enabled) { 103 | mSimulationEnabled = enabled; 104 | } 105 | 106 | public void setPreferResourceEnabled(boolean enabled) { 107 | mPreferResourceEnabled = enabled; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /android/src/main/java/com/fabricio/vergal/RNWorkers/RNWorkersModule.java: -------------------------------------------------------------------------------- 1 | package com.fabricio.vergal.RNWorkers; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 5 | import com.facebook.react.bridge.ReactMethod; 6 | import com.facebook.react.modules.core.DeviceEventManagerModule; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | import javax.annotation.Nullable; 12 | 13 | 14 | public class RNWorkersModule extends ReactContextBaseJavaModule { 15 | 16 | public RNWorkersModule(final ReactApplicationContext reactContext) { 17 | super(reactContext); 18 | } 19 | 20 | @Override 21 | public String getName() { 22 | return "RNWorkers"; 23 | } 24 | 25 | @Nullable 26 | @Override 27 | public Map getConstants() { 28 | final Map constants = new HashMap<>(); 29 | constants.put("simulationEnabled", RNWorkersManager.getInstance().isSimulationEnabled()); 30 | return constants; 31 | } 32 | 33 | @ReactMethod 34 | public void sendMessageToWorker(final int port, final String message) { 35 | final ReactApplicationContext context = RNWorkersManager.getInstance().getWorkerReactContext(port); 36 | if (context == null) { 37 | return; 38 | } 39 | 40 | context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) 41 | .emit("RNWorkers", message); 42 | } 43 | 44 | @ReactMethod 45 | public void sendMessageToApp(final String message) { 46 | final ReactApplicationContext context = RNWorkersManager.getInstance().getMainReactContext(); 47 | if (context == null) { 48 | return; 49 | } 50 | 51 | context.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) 52 | .emit("RNWorkersApp", message); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /android/src/main/java/com/fabricio/vergal/RNWorkers/RNWorkersPackage.java: -------------------------------------------------------------------------------- 1 | package com.fabricio.vergal.RNWorkers; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.JavaScriptModule; 5 | import com.facebook.react.bridge.NativeModule; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.uimanager.ViewManager; 8 | 9 | import java.util.Arrays; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class RNWorkersPackage implements ReactPackage { 14 | 15 | @Override 16 | public List createViewManagers(ReactApplicationContext reactContext) { 17 | return Collections.emptyList(); 18 | } 19 | 20 | @Override 21 | public List createNativeModules(ReactApplicationContext reactContext) { 22 | return Arrays.asList( 23 | new RNWorkersModule(reactContext) 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /android/src/main/java/com/fabricio/vergal/RNWorkers/RNWorkersUtils.java: -------------------------------------------------------------------------------- 1 | package com.fabricio.vergal.RNWorkers; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | 6 | import com.facebook.react.ReactInstanceManager; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.modules.debug.interfaces.DeveloperSettings; 9 | 10 | import java.lang.reflect.Field; 11 | import java.lang.reflect.Method; 12 | import java.util.Map; 13 | import java.util.Set; 14 | 15 | import static android.content.Context.MODE_PRIVATE; 16 | 17 | public class RNWorkersUtils { 18 | 19 | static Field getField(final T object, final Class type) { 20 | final Class clazz = object.getClass(); 21 | final Field[] fields = clazz.getDeclaredFields(); 22 | for (int i = 0; i < fields.length; i++) { 23 | if (fields[i].getType().equals(type)) { 24 | return fields[i]; 25 | } 26 | } 27 | 28 | return null; 29 | 30 | } 31 | 32 | static Field getField(final T object, final String name) { 33 | final Class clazz = object.getClass(); 34 | final Field[] fields = clazz.getDeclaredFields(); 35 | for (int i = 0; i < fields.length; i++) { 36 | if (fields[i].getName().equals(name)) { 37 | return fields[i]; 38 | } 39 | } 40 | 41 | return null; 42 | } 43 | 44 | static Method getMethod(final T object, final String name) { 45 | final Class clazz = object.getClass(); 46 | final Method[] methods = clazz.getDeclaredMethods(); 47 | for (int i = 0; i < methods.length; i++) { 48 | if (methods[i].getName().equals(name)) { 49 | return methods[i]; 50 | } 51 | } 52 | 53 | return null; 54 | } 55 | 56 | 57 | static void putObject(final SharedPreferences.Editor editor, final String key, 58 | final Object value) { 59 | if (value == null) { 60 | return; 61 | } 62 | 63 | if (value instanceof String) { 64 | editor.putString(key, (String) value); 65 | } else if (value instanceof Integer) { 66 | editor.putInt(key, (Integer) value); 67 | } else if (value instanceof Long) { 68 | editor.putLong(key, (Long) value); 69 | } else if (value instanceof Float) { 70 | editor.putFloat(key, (Float) value); 71 | } else if (value instanceof Boolean) { 72 | editor.putBoolean(key, (Boolean) value); 73 | } else if (value instanceof Set) { 74 | editor.putStringSet(key, (Set) value); 75 | } 76 | } 77 | 78 | protected static void replacePrefs(final Context context, 79 | final ReactNativeHost host, 80 | final int port, 81 | final String debugHostFormat, 82 | final String prefsDebugServerHostKey) throws IllegalAccessException { 83 | 84 | final String debugHost = String.format(debugHostFormat, port); 85 | final ReactInstanceManager manager = host.getReactInstanceManager(); 86 | final DeveloperSettings settings = manager.getDevSupportManager().getDevSettings(); 87 | final Field sharedPreferenceField = getField(settings, SharedPreferences.class); 88 | 89 | sharedPreferenceField.setAccessible(true); 90 | final SharedPreferences preferences = (SharedPreferences) sharedPreferenceField.get(settings); 91 | final SharedPreferences newPreferences = context.getSharedPreferences(debugHost, MODE_PRIVATE); 92 | final SharedPreferences.Editor editor = newPreferences.edit(); 93 | 94 | for (final Map.Entry entry : preferences.getAll().entrySet()) { 95 | RNWorkersUtils.putObject(editor, entry.getKey(), entry.getValue()); 96 | } 97 | 98 | editor.putString(prefsDebugServerHostKey, debugHost); 99 | editor.apply(); 100 | 101 | preferences.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() { 102 | @Override 103 | public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String keyChanged) { 104 | final SharedPreferences.Editor editor = newPreferences.edit(); 105 | for (final Map.Entry entry : sharedPreferences.getAll().entrySet()) { 106 | if (!entry.getKey().contains(prefsDebugServerHostKey)) { 107 | RNWorkersUtils.putObject(editor, entry.getKey(), entry.getValue()); 108 | } 109 | } 110 | 111 | editor.apply(); 112 | } 113 | }); 114 | 115 | sharedPreferenceField.set(settings, newPreferences); 116 | final SharedPreferences.OnSharedPreferenceChangeListener listener = (SharedPreferences.OnSharedPreferenceChangeListener) settings; 117 | newPreferences.registerOnSharedPreferenceChangeListener(listener); 118 | 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /android/src/main/java/com/fabricio/vergal/RNWorkers/SimpleLifecycleCallbacks.java: -------------------------------------------------------------------------------- 1 | package com.fabricio.vergal.RNWorkers; 2 | 3 | import android.app.Activity; 4 | import android.app.Application; 5 | import android.os.Bundle; 6 | 7 | abstract class SimpleLifecycleCallbacks implements Application.ActivityLifecycleCallbacks { 8 | 9 | @Override 10 | public void onActivityCreated(Activity activity, Bundle bundle) { 11 | } 12 | 13 | @Override 14 | public void onActivityStarted(Activity activity) { 15 | } 16 | 17 | @Override 18 | public void onActivityResumed(Activity activity) { 19 | } 20 | 21 | @Override 22 | public void onActivityPaused(Activity activity) { 23 | } 24 | 25 | @Override 26 | public void onActivityStopped(Activity activity) { 27 | } 28 | 29 | @Override 30 | public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native-stage-0/decorator-support"] 3 | } -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | 41 | unsafe.enable_getters_and_setters=true 42 | 43 | [version] 44 | ^0.36.0 45 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # Setup 2 | 3 | 1. npm install 4 | 2. react-native start 5 | 3. react-native start --port 8082 6 | 4. (ANDROID) adb reverse tcp:8082 tcp:8082 7 | 5. react-native run-ios or react-native run-android 8 | -------------------------------------------------------------------------------- /example/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /example/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /example/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.rnapp', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.rnapp', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.rnapp" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile project(':rn-workers') 130 | compile fileTree(dir: "libs", include: ["*.jar"]) 131 | compile "com.android.support:appcompat-v7:23.0.1" 132 | compile "com.facebook.react:react-native:+" // From node_modules 133 | } 134 | 135 | // Run this once to be able to run the application with BUCK 136 | // puts all compile dependencies into folder libs for BUCK to use 137 | task copyDownloadableDepsToLibs(type: Copy) { 138 | from configurations.compile 139 | into 'libs' 140 | } 141 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /example/android/app/src/main/assets/index.worker.bundle.meta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/assets/index.worker.bundle.meta -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/rnapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.rnapp; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.fabricio.vergal.RNWorkers.RNWorkersManager; 6 | import com.facebook.react.ReactActivity; 7 | 8 | public class MainActivity extends ReactActivity { 9 | 10 | /** 11 | * Returns the name of the main component registered from JavaScript. 12 | * This is used to schedule rendering of the component. 13 | */ 14 | @Override 15 | protected String getMainComponentName() { 16 | return "rnapp"; 17 | } 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | RNWorkersManager.getInstance().startWorkers(); 22 | super.onCreate(savedInstanceState); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/rnapp/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.rnapp; 2 | 3 | import android.app.Application; 4 | 5 | import com.fabricio.vergal.RNWorkers.RNWorkersManager; 6 | import com.fabricio.vergal.RNWorkers.RNWorkersPackage; 7 | import com.facebook.react.ReactApplication; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | import com.facebook.soloader.SoLoader; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | 17 | public class MainApplication extends Application implements ReactApplication { 18 | 19 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 20 | @Override 21 | public boolean getUseDeveloperSupport() { 22 | return BuildConfig.DEBUG; 23 | } 24 | 25 | @Override 26 | protected List getPackages() { 27 | return Arrays.asList( 28 | new MainReactPackage(), 29 | new RNWorkersPackage() 30 | ); 31 | } 32 | }; 33 | 34 | @Override 35 | public ReactNativeHost getReactNativeHost() { 36 | return mReactNativeHost; 37 | } 38 | 39 | @Override 40 | public void onCreate() { 41 | super.onCreate(); 42 | SoLoader.init(this, false); 43 | RNWorkersManager.getInstance().init(this, BuildConfig.DEBUG); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-hdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/drawable-hdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-mdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/drawable-mdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xhdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/drawable-xhdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xxhdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/drawable-xxhdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-xxxhdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/drawable-xxxhdpi/node_modules_reactnative_libraries_customcomponents_navigationexperimental_assets_backicon.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | rnapp 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jan 24 17:20:57 BRST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /example/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'rnapp' 2 | include ':rn-workers' 3 | project(':rn-workers').projectDir = new File(rootProject.projectDir, '../node_modules/rn-workers/android') 4 | 5 | include ':app' 6 | -------------------------------------------------------------------------------- /example/index.android.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Worker }from 'rn-workers' 3 | import { AppRegistry, StyleSheet, Text, View, TouchableOpacity } from 'react-native'; 4 | 5 | export default class rnapp extends Component { 6 | 7 | constructor(props, context) { 8 | super(props, context); 9 | this.state = { 10 | text: "", 11 | count: 0, 12 | increment: 0, 13 | } 14 | } 15 | 16 | componentDidMount() { 17 | this.worker = new Worker(); 18 | this.worker.onmessage = message => this.setState({ 19 | text: message, 20 | count: this.state.count + 1 21 | }); 22 | 23 | this.interval = setInterval(() => this.setState({ 24 | increment: this.state.increment + 1 25 | }), 100); 26 | } 27 | 28 | componentWillUnmount() { 29 | this.worker.terminate(); 30 | clearInterval(this.interval) 31 | } 32 | 33 | render() { 34 | return ( 35 | 36 | this.worker.postMessage("" + this.state.count)}> 37 | 38 | {"Send Message (" + this.state.count + ")"} 39 | 40 | 41 | 42 | {this.state.text} 43 | 44 | 45 | {"Should not freeze: " + this.state.increment} 46 | 47 | 48 | ); 49 | } 50 | } 51 | 52 | const styles = StyleSheet.create({ 53 | container: { 54 | flex: 1, 55 | justifyContent: 'center', 56 | alignItems: 'center', 57 | backgroundColor: '#F5FCFF', 58 | }, 59 | clickMe: { 60 | fontSize: 20, 61 | textAlign: 'center', 62 | margin: 10, 63 | }, 64 | text: { 65 | textAlign: 'center', 66 | color: '#333333', 67 | marginBottom: 5, 68 | }, 69 | }); 70 | 71 | AppRegistry.registerComponent('rnapp', () => rnapp); 72 | -------------------------------------------------------------------------------- /example/index.ios.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Worker }from 'rn-workers' 3 | import { AppRegistry, StyleSheet, Text, View, TouchableOpacity } from 'react-native'; 4 | 5 | export default class rnapp extends Component { 6 | 7 | constructor(props, context) { 8 | super(props, context); 9 | this.state = { 10 | text: "", 11 | count: 0, 12 | increment: 0, 13 | } 14 | } 15 | 16 | componentDidMount() { 17 | this.worker = new Worker(); 18 | this.worker.onmessage = message => this.setState({ 19 | text: message, 20 | count: this.state.count + 1 21 | }); 22 | 23 | this.interval = setInterval(() => this.setState({ 24 | increment: this.state.increment + 1 25 | }), 100); 26 | } 27 | 28 | componentWillUnmount() { 29 | this.worker.terminate(); 30 | clearInterval(this.interval) 31 | } 32 | 33 | render() { 34 | return ( 35 | 36 | this.worker.postMessage("" + this.state.count)}> 37 | 38 | {"Send Message (" + this.state.count + ")"} 39 | 40 | 41 | 42 | {this.state.text} 43 | 44 | 45 | {"Should not freeze: " + this.state.increment} 46 | 47 | 48 | ); 49 | } 50 | } 51 | 52 | const styles = StyleSheet.create({ 53 | container: { 54 | flex: 1, 55 | justifyContent: 'center', 56 | alignItems: 'center', 57 | backgroundColor: '#F5FCFF', 58 | }, 59 | clickMe: { 60 | fontSize: 20, 61 | textAlign: 'center', 62 | margin: 10, 63 | }, 64 | text: { 65 | textAlign: 'center', 66 | color: '#333333', 67 | marginBottom: 5, 68 | }, 69 | }); 70 | 71 | AppRegistry.registerComponent('rnapp', () => rnapp); 72 | -------------------------------------------------------------------------------- /example/index.worker.js: -------------------------------------------------------------------------------- 1 | import { WorkerService } from 'rn-workers' 2 | 3 | const worker = new WorkerService(); 4 | worker.onmessage = message => { 5 | const now = Date.now(); 6 | while (Date.now() < now + 2000); 7 | worker.postMessage("Hello from the other side (" + message + ")") 8 | }; -------------------------------------------------------------------------------- /example/ios/rnapp.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; 11 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; 12 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; 13 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; 14 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; 15 | 00E356F31AD99517003FC87E /* rnappTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* rnappTests.m */; }; 16 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; }; 17 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; }; 18 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; }; 19 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 20 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 21 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 22 | 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; 23 | 2782837A46484262943EB52A /* libRNWorkers.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D37483E2F304DF2993E970B /* libRNWorkers.a */; }; 24 | 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 25 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; 26 | BB31A6691E4BBC9D007365A3 /* worker.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = BB31A6681E4BBC9D007365A3 /* worker.jsbundle */; }; 27 | BB9D0ABF1E2816B500CD2926 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB9D0ABD1E2816B500CD2926 /* AppDelegate.swift */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXContainerItemProxy section */ 31 | 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 34 | proxyType = 2; 35 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 36 | remoteInfo = RCTActionSheet; 37 | }; 38 | 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { 39 | isa = PBXContainerItemProxy; 40 | containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 41 | proxyType = 2; 42 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 43 | remoteInfo = RCTGeolocation; 44 | }; 45 | 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { 46 | isa = PBXContainerItemProxy; 47 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 48 | proxyType = 2; 49 | remoteGlobalIDString = 58B5115D1A9E6B3D00147676; 50 | remoteInfo = RCTImage; 51 | }; 52 | 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { 53 | isa = PBXContainerItemProxy; 54 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 55 | proxyType = 2; 56 | remoteGlobalIDString = 58B511DB1A9E6C8500147676; 57 | remoteInfo = RCTNetwork; 58 | }; 59 | 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { 60 | isa = PBXContainerItemProxy; 61 | containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 62 | proxyType = 2; 63 | remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; 64 | remoteInfo = RCTVibration; 65 | }; 66 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { 67 | isa = PBXContainerItemProxy; 68 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; 69 | proxyType = 1; 70 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A; 71 | remoteInfo = rnapp; 72 | }; 73 | 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = { 74 | isa = PBXContainerItemProxy; 75 | containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 76 | proxyType = 2; 77 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 78 | remoteInfo = RCTSettings; 79 | }; 80 | 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = { 81 | isa = PBXContainerItemProxy; 82 | containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 83 | proxyType = 2; 84 | remoteGlobalIDString = 3C86DF461ADF2C930047B81A; 85 | remoteInfo = RCTWebSocket; 86 | }; 87 | 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { 88 | isa = PBXContainerItemProxy; 89 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 90 | proxyType = 2; 91 | remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; 92 | remoteInfo = React; 93 | }; 94 | 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */ = { 95 | isa = PBXContainerItemProxy; 96 | containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 97 | proxyType = 2; 98 | remoteGlobalIDString = 2D2A283A1D9B042B00D4039D; 99 | remoteInfo = "RCTImage-tvOS"; 100 | }; 101 | 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */ = { 102 | isa = PBXContainerItemProxy; 103 | containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 104 | proxyType = 2; 105 | remoteGlobalIDString = 2D2A28471D9B043800D4039D; 106 | remoteInfo = "RCTLinking-tvOS"; 107 | }; 108 | 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 109 | isa = PBXContainerItemProxy; 110 | containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 111 | proxyType = 2; 112 | remoteGlobalIDString = 2D2A28541D9B044C00D4039D; 113 | remoteInfo = "RCTNetwork-tvOS"; 114 | }; 115 | 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 116 | isa = PBXContainerItemProxy; 117 | containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 118 | proxyType = 2; 119 | remoteGlobalIDString = 2D2A28611D9B046600D4039D; 120 | remoteInfo = "RCTSettings-tvOS"; 121 | }; 122 | 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */ = { 123 | isa = PBXContainerItemProxy; 124 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 125 | proxyType = 2; 126 | remoteGlobalIDString = 2D2A287B1D9B048500D4039D; 127 | remoteInfo = "RCTText-tvOS"; 128 | }; 129 | 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */ = { 130 | isa = PBXContainerItemProxy; 131 | containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 132 | proxyType = 2; 133 | remoteGlobalIDString = 2D2A28881D9B049200D4039D; 134 | remoteInfo = "RCTWebSocket-tvOS"; 135 | }; 136 | 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */ = { 137 | isa = PBXContainerItemProxy; 138 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 139 | proxyType = 2; 140 | remoteGlobalIDString = 2D2A28131D9B038B00D4039D; 141 | remoteInfo = "React-tvOS"; 142 | }; 143 | 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */ = { 144 | isa = PBXContainerItemProxy; 145 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 146 | proxyType = 2; 147 | remoteGlobalIDString = 3D3C059A1DE3340900C268FA; 148 | remoteInfo = yoga; 149 | }; 150 | 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */ = { 151 | isa = PBXContainerItemProxy; 152 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 153 | proxyType = 2; 154 | remoteGlobalIDString = 3D3C06751DE3340C00C268FA; 155 | remoteInfo = "yoga-tvOS"; 156 | }; 157 | 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */ = { 158 | isa = PBXContainerItemProxy; 159 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 160 | proxyType = 2; 161 | remoteGlobalIDString = 3D3CD9251DE5FBEC00167DC4; 162 | remoteInfo = cxxreact; 163 | }; 164 | 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 165 | isa = PBXContainerItemProxy; 166 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 167 | proxyType = 2; 168 | remoteGlobalIDString = 3D3CD9321DE5FBEE00167DC4; 169 | remoteInfo = "cxxreact-tvOS"; 170 | }; 171 | 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 172 | isa = PBXContainerItemProxy; 173 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 174 | proxyType = 2; 175 | remoteGlobalIDString = 3D3CD90B1DE5FBD600167DC4; 176 | remoteInfo = jschelpers; 177 | }; 178 | 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */ = { 179 | isa = PBXContainerItemProxy; 180 | containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; 181 | proxyType = 2; 182 | remoteGlobalIDString = 3D3CD9181DE5FBD800167DC4; 183 | remoteInfo = "jschelpers-tvOS"; 184 | }; 185 | 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { 186 | isa = PBXContainerItemProxy; 187 | containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; 188 | proxyType = 2; 189 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 190 | remoteInfo = RCTAnimation; 191 | }; 192 | 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */ = { 193 | isa = PBXContainerItemProxy; 194 | containerPortal = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; 195 | proxyType = 2; 196 | remoteGlobalIDString = 2D2A28201D9B03D100D4039D; 197 | remoteInfo = "RCTAnimation-tvOS"; 198 | }; 199 | 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { 200 | isa = PBXContainerItemProxy; 201 | containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 202 | proxyType = 2; 203 | remoteGlobalIDString = 134814201AA4EA6300B7C361; 204 | remoteInfo = RCTLinking; 205 | }; 206 | 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { 207 | isa = PBXContainerItemProxy; 208 | containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 209 | proxyType = 2; 210 | remoteGlobalIDString = 58B5119B1A9E6C1200147676; 211 | remoteInfo = RCTText; 212 | }; 213 | BB9AE90E1E32C6D50004E328 /* PBXContainerItemProxy */ = { 214 | isa = PBXContainerItemProxy; 215 | containerPortal = 73D77C5BBED547A89C0A913A /* RNWorkers.xcodeproj */; 216 | proxyType = 2; 217 | remoteGlobalIDString = BB2E77021E2A695C003CD6F3; 218 | remoteInfo = RNWorkers; 219 | }; 220 | /* End PBXContainerItemProxy section */ 221 | 222 | /* Begin PBXFileReference section */ 223 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; }; 224 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; }; 225 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = "../node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj"; sourceTree = ""; }; 226 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; }; 227 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; }; 228 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; }; 229 | 00E356EE1AD99517003FC87E /* rnappTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = rnappTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 230 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 231 | 00E356F21AD99517003FC87E /* rnappTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = rnappTests.m; sourceTree = ""; }; 232 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; }; 233 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; }; 234 | 13B07F961A680F5B00A75B9A /* rnapp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = rnapp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 235 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 236 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = rnapp/Images.xcassets; sourceTree = ""; }; 237 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = rnapp/Info.plist; sourceTree = ""; }; 238 | 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; }; 239 | 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTAnimation.xcodeproj; path = "../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj"; sourceTree = ""; }; 240 | 73D77C5BBED547A89C0A913A /* RNWorkers.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNWorkers.xcodeproj; path = "../node_modules/rn-workers/ios/RNWorkers.xcodeproj"; sourceTree = ""; }; 241 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; }; 242 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; }; 243 | 8D37483E2F304DF2993E970B /* libRNWorkers.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNWorkers.a; sourceTree = ""; }; 244 | BB31A6681E4BBC9D007365A3 /* worker.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = worker.jsbundle; sourceTree = ""; }; 245 | BB9D0ABD1E2816B500CD2926 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AppDelegate.swift; path = rnapp/AppDelegate.swift; sourceTree = ""; }; 246 | BB9D0ABE1E2816B500CD2926 /* rnapp-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "rnapp-Bridging-Header.h"; path = "rnapp/rnapp-Bridging-Header.h"; sourceTree = ""; }; 247 | /* End PBXFileReference section */ 248 | 249 | /* Begin PBXFrameworksBuildPhase section */ 250 | 00E356EB1AD99517003FC87E /* Frameworks */ = { 251 | isa = PBXFrameworksBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */, 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { 259 | isa = PBXFrameworksBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | 5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */, 263 | 146834051AC3E58100842450 /* libReact.a in Frameworks */, 264 | 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, 265 | 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, 266 | 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, 267 | 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, 268 | 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, 269 | 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, 270 | 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, 271 | 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, 272 | 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, 273 | 2782837A46484262943EB52A /* libRNWorkers.a in Frameworks */, 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | /* End PBXFrameworksBuildPhase section */ 278 | 279 | /* Begin PBXGroup section */ 280 | 00C302A81ABCB8CE00DB3ED1 /* Products */ = { 281 | isa = PBXGroup; 282 | children = ( 283 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, 284 | ); 285 | name = Products; 286 | sourceTree = ""; 287 | }; 288 | 00C302B61ABCB90400DB3ED1 /* Products */ = { 289 | isa = PBXGroup; 290 | children = ( 291 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, 292 | ); 293 | name = Products; 294 | sourceTree = ""; 295 | }; 296 | 00C302BC1ABCB91800DB3ED1 /* Products */ = { 297 | isa = PBXGroup; 298 | children = ( 299 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, 300 | 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */, 301 | ); 302 | name = Products; 303 | sourceTree = ""; 304 | }; 305 | 00C302D41ABCB9D200DB3ED1 /* Products */ = { 306 | isa = PBXGroup; 307 | children = ( 308 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, 309 | 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */, 310 | ); 311 | name = Products; 312 | sourceTree = ""; 313 | }; 314 | 00C302E01ABCB9EE00DB3ED1 /* Products */ = { 315 | isa = PBXGroup; 316 | children = ( 317 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, 318 | ); 319 | name = Products; 320 | sourceTree = ""; 321 | }; 322 | 00E356EF1AD99517003FC87E /* rnappTests */ = { 323 | isa = PBXGroup; 324 | children = ( 325 | 00E356F21AD99517003FC87E /* rnappTests.m */, 326 | 00E356F01AD99517003FC87E /* Supporting Files */, 327 | ); 328 | path = rnappTests; 329 | sourceTree = ""; 330 | }; 331 | 00E356F01AD99517003FC87E /* Supporting Files */ = { 332 | isa = PBXGroup; 333 | children = ( 334 | 00E356F11AD99517003FC87E /* Info.plist */, 335 | ); 336 | name = "Supporting Files"; 337 | sourceTree = ""; 338 | }; 339 | 139105B71AF99BAD00B5F7CC /* Products */ = { 340 | isa = PBXGroup; 341 | children = ( 342 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, 343 | 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */, 344 | ); 345 | name = Products; 346 | sourceTree = ""; 347 | }; 348 | 139FDEE71B06529A00C62182 /* Products */ = { 349 | isa = PBXGroup; 350 | children = ( 351 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, 352 | 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */, 353 | ); 354 | name = Products; 355 | sourceTree = ""; 356 | }; 357 | 13B07FAE1A68108700A75B9A /* rnapp */ = { 358 | isa = PBXGroup; 359 | children = ( 360 | BB31A6681E4BBC9D007365A3 /* worker.jsbundle */, 361 | BB9D0ABD1E2816B500CD2926 /* AppDelegate.swift */, 362 | BB9D0ABE1E2816B500CD2926 /* rnapp-Bridging-Header.h */, 363 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */, 364 | 13B07FB51A68108700A75B9A /* Images.xcassets */, 365 | 13B07FB61A68108700A75B9A /* Info.plist */, 366 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, 367 | ); 368 | name = rnapp; 369 | sourceTree = ""; 370 | }; 371 | 146834001AC3E56700842450 /* Products */ = { 372 | isa = PBXGroup; 373 | children = ( 374 | 146834041AC3E56700842450 /* libReact.a */, 375 | 3DAD3EA31DF850E9000B6D8A /* libReact.a */, 376 | 3DAD3EA51DF850E9000B6D8A /* libyoga.a */, 377 | 3DAD3EA71DF850E9000B6D8A /* libyoga.a */, 378 | 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */, 379 | 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */, 380 | 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */, 381 | 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */, 382 | ); 383 | name = Products; 384 | sourceTree = ""; 385 | }; 386 | 5E91572E1DD0AC6500FF2AA8 /* Products */ = { 387 | isa = PBXGroup; 388 | children = ( 389 | 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */, 390 | 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */, 391 | ); 392 | name = Products; 393 | sourceTree = ""; 394 | }; 395 | 78C398B11ACF4ADC00677621 /* Products */ = { 396 | isa = PBXGroup; 397 | children = ( 398 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, 399 | 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */, 400 | ); 401 | name = Products; 402 | sourceTree = ""; 403 | }; 404 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = { 405 | isa = PBXGroup; 406 | children = ( 407 | 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */, 408 | 146833FF1AC3E56700842450 /* React.xcodeproj */, 409 | 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, 410 | 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, 411 | 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, 412 | 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */, 413 | 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, 414 | 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */, 415 | 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, 416 | 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, 417 | 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, 418 | 73D77C5BBED547A89C0A913A /* RNWorkers.xcodeproj */, 419 | ); 420 | name = Libraries; 421 | sourceTree = ""; 422 | }; 423 | 832341B11AAA6A8300B99B32 /* Products */ = { 424 | isa = PBXGroup; 425 | children = ( 426 | 832341B51AAA6A8300B99B32 /* libRCTText.a */, 427 | 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */, 428 | ); 429 | name = Products; 430 | sourceTree = ""; 431 | }; 432 | 83CBB9F61A601CBA00E9B192 = { 433 | isa = PBXGroup; 434 | children = ( 435 | 13B07FAE1A68108700A75B9A /* rnapp */, 436 | 832341AE1AAA6A7D00B99B32 /* Libraries */, 437 | 00E356EF1AD99517003FC87E /* rnappTests */, 438 | 83CBBA001A601CBA00E9B192 /* Products */, 439 | ); 440 | indentWidth = 2; 441 | sourceTree = ""; 442 | tabWidth = 2; 443 | }; 444 | 83CBBA001A601CBA00E9B192 /* Products */ = { 445 | isa = PBXGroup; 446 | children = ( 447 | 13B07F961A680F5B00A75B9A /* rnapp.app */, 448 | 00E356EE1AD99517003FC87E /* rnappTests.xctest */, 449 | ); 450 | name = Products; 451 | sourceTree = ""; 452 | }; 453 | BB9AE8F21E32C6D50004E328 /* Products */ = { 454 | isa = PBXGroup; 455 | children = ( 456 | BB9AE90F1E32C6D50004E328 /* libRNWorkers.a */, 457 | ); 458 | name = Products; 459 | sourceTree = ""; 460 | }; 461 | /* End PBXGroup section */ 462 | 463 | /* Begin PBXNativeTarget section */ 464 | 00E356ED1AD99517003FC87E /* rnappTests */ = { 465 | isa = PBXNativeTarget; 466 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "rnappTests" */; 467 | buildPhases = ( 468 | 00E356EA1AD99517003FC87E /* Sources */, 469 | 00E356EB1AD99517003FC87E /* Frameworks */, 470 | 00E356EC1AD99517003FC87E /* Resources */, 471 | ); 472 | buildRules = ( 473 | ); 474 | dependencies = ( 475 | 00E356F51AD99517003FC87E /* PBXTargetDependency */, 476 | ); 477 | name = rnappTests; 478 | productName = rnappTests; 479 | productReference = 00E356EE1AD99517003FC87E /* rnappTests.xctest */; 480 | productType = "com.apple.product-type.bundle.unit-test"; 481 | }; 482 | 13B07F861A680F5B00A75B9A /* rnapp */ = { 483 | isa = PBXNativeTarget; 484 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "rnapp" */; 485 | buildPhases = ( 486 | 13B07F871A680F5B00A75B9A /* Sources */, 487 | 13B07F8C1A680F5B00A75B9A /* Frameworks */, 488 | 13B07F8E1A680F5B00A75B9A /* Resources */, 489 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 490 | ); 491 | buildRules = ( 492 | ); 493 | dependencies = ( 494 | ); 495 | name = rnapp; 496 | productName = "Hello World"; 497 | productReference = 13B07F961A680F5B00A75B9A /* rnapp.app */; 498 | productType = "com.apple.product-type.application"; 499 | }; 500 | /* End PBXNativeTarget section */ 501 | 502 | /* Begin PBXProject section */ 503 | 83CBB9F71A601CBA00E9B192 /* Project object */ = { 504 | isa = PBXProject; 505 | attributes = { 506 | LastUpgradeCheck = 610; 507 | ORGANIZATIONNAME = Facebook; 508 | TargetAttributes = { 509 | 00E356ED1AD99517003FC87E = { 510 | CreatedOnToolsVersion = 6.2; 511 | TestTargetID = 13B07F861A680F5B00A75B9A; 512 | }; 513 | 13B07F861A680F5B00A75B9A = { 514 | DevelopmentTeam = K9E42X52H2; 515 | LastSwiftMigration = 820; 516 | }; 517 | }; 518 | }; 519 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "rnapp" */; 520 | compatibilityVersion = "Xcode 3.2"; 521 | developmentRegion = English; 522 | hasScannedForEncodings = 0; 523 | knownRegions = ( 524 | en, 525 | Base, 526 | ); 527 | mainGroup = 83CBB9F61A601CBA00E9B192; 528 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; 529 | projectDirPath = ""; 530 | projectReferences = ( 531 | { 532 | ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; 533 | ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; 534 | }, 535 | { 536 | ProductGroup = 5E91572E1DD0AC6500FF2AA8 /* Products */; 537 | ProjectRef = 5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */; 538 | }, 539 | { 540 | ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; 541 | ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; 542 | }, 543 | { 544 | ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; 545 | ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; 546 | }, 547 | { 548 | ProductGroup = 78C398B11ACF4ADC00677621 /* Products */; 549 | ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; 550 | }, 551 | { 552 | ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; 553 | ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; 554 | }, 555 | { 556 | ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */; 557 | ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; 558 | }, 559 | { 560 | ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; 561 | ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; 562 | }, 563 | { 564 | ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; 565 | ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; 566 | }, 567 | { 568 | ProductGroup = 139FDEE71B06529A00C62182 /* Products */; 569 | ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; 570 | }, 571 | { 572 | ProductGroup = 146834001AC3E56700842450 /* Products */; 573 | ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; 574 | }, 575 | { 576 | ProductGroup = BB9AE8F21E32C6D50004E328 /* Products */; 577 | ProjectRef = 73D77C5BBED547A89C0A913A /* RNWorkers.xcodeproj */; 578 | }, 579 | ); 580 | projectRoot = ""; 581 | targets = ( 582 | 13B07F861A680F5B00A75B9A /* rnapp */, 583 | 00E356ED1AD99517003FC87E /* rnappTests */, 584 | ); 585 | }; 586 | /* End PBXProject section */ 587 | 588 | /* Begin PBXReferenceProxy section */ 589 | 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { 590 | isa = PBXReferenceProxy; 591 | fileType = archive.ar; 592 | path = libRCTActionSheet.a; 593 | remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; 594 | sourceTree = BUILT_PRODUCTS_DIR; 595 | }; 596 | 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { 597 | isa = PBXReferenceProxy; 598 | fileType = archive.ar; 599 | path = libRCTGeolocation.a; 600 | remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; 601 | sourceTree = BUILT_PRODUCTS_DIR; 602 | }; 603 | 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { 604 | isa = PBXReferenceProxy; 605 | fileType = archive.ar; 606 | path = libRCTImage.a; 607 | remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; 608 | sourceTree = BUILT_PRODUCTS_DIR; 609 | }; 610 | 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { 611 | isa = PBXReferenceProxy; 612 | fileType = archive.ar; 613 | path = libRCTNetwork.a; 614 | remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; 615 | sourceTree = BUILT_PRODUCTS_DIR; 616 | }; 617 | 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { 618 | isa = PBXReferenceProxy; 619 | fileType = archive.ar; 620 | path = libRCTVibration.a; 621 | remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; 622 | sourceTree = BUILT_PRODUCTS_DIR; 623 | }; 624 | 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = { 625 | isa = PBXReferenceProxy; 626 | fileType = archive.ar; 627 | path = libRCTSettings.a; 628 | remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */; 629 | sourceTree = BUILT_PRODUCTS_DIR; 630 | }; 631 | 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = { 632 | isa = PBXReferenceProxy; 633 | fileType = archive.ar; 634 | path = libRCTWebSocket.a; 635 | remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */; 636 | sourceTree = BUILT_PRODUCTS_DIR; 637 | }; 638 | 146834041AC3E56700842450 /* libReact.a */ = { 639 | isa = PBXReferenceProxy; 640 | fileType = archive.ar; 641 | path = libReact.a; 642 | remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; 643 | sourceTree = BUILT_PRODUCTS_DIR; 644 | }; 645 | 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */ = { 646 | isa = PBXReferenceProxy; 647 | fileType = archive.ar; 648 | path = "libRCTImage-tvOS.a"; 649 | remoteRef = 3DAD3E831DF850E9000B6D8A /* PBXContainerItemProxy */; 650 | sourceTree = BUILT_PRODUCTS_DIR; 651 | }; 652 | 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */ = { 653 | isa = PBXReferenceProxy; 654 | fileType = archive.ar; 655 | path = "libRCTLinking-tvOS.a"; 656 | remoteRef = 3DAD3E871DF850E9000B6D8A /* PBXContainerItemProxy */; 657 | sourceTree = BUILT_PRODUCTS_DIR; 658 | }; 659 | 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */ = { 660 | isa = PBXReferenceProxy; 661 | fileType = archive.ar; 662 | path = "libRCTNetwork-tvOS.a"; 663 | remoteRef = 3DAD3E8B1DF850E9000B6D8A /* PBXContainerItemProxy */; 664 | sourceTree = BUILT_PRODUCTS_DIR; 665 | }; 666 | 3DAD3E901DF850E9000B6D8A /* libRCTSettings-tvOS.a */ = { 667 | isa = PBXReferenceProxy; 668 | fileType = archive.ar; 669 | path = "libRCTSettings-tvOS.a"; 670 | remoteRef = 3DAD3E8F1DF850E9000B6D8A /* PBXContainerItemProxy */; 671 | sourceTree = BUILT_PRODUCTS_DIR; 672 | }; 673 | 3DAD3E941DF850E9000B6D8A /* libRCTText-tvOS.a */ = { 674 | isa = PBXReferenceProxy; 675 | fileType = archive.ar; 676 | path = "libRCTText-tvOS.a"; 677 | remoteRef = 3DAD3E931DF850E9000B6D8A /* PBXContainerItemProxy */; 678 | sourceTree = BUILT_PRODUCTS_DIR; 679 | }; 680 | 3DAD3E991DF850E9000B6D8A /* libRCTWebSocket-tvOS.a */ = { 681 | isa = PBXReferenceProxy; 682 | fileType = archive.ar; 683 | path = "libRCTWebSocket-tvOS.a"; 684 | remoteRef = 3DAD3E981DF850E9000B6D8A /* PBXContainerItemProxy */; 685 | sourceTree = BUILT_PRODUCTS_DIR; 686 | }; 687 | 3DAD3EA31DF850E9000B6D8A /* libReact.a */ = { 688 | isa = PBXReferenceProxy; 689 | fileType = archive.ar; 690 | path = libReact.a; 691 | remoteRef = 3DAD3EA21DF850E9000B6D8A /* PBXContainerItemProxy */; 692 | sourceTree = BUILT_PRODUCTS_DIR; 693 | }; 694 | 3DAD3EA51DF850E9000B6D8A /* libyoga.a */ = { 695 | isa = PBXReferenceProxy; 696 | fileType = archive.ar; 697 | path = libyoga.a; 698 | remoteRef = 3DAD3EA41DF850E9000B6D8A /* PBXContainerItemProxy */; 699 | sourceTree = BUILT_PRODUCTS_DIR; 700 | }; 701 | 3DAD3EA71DF850E9000B6D8A /* libyoga.a */ = { 702 | isa = PBXReferenceProxy; 703 | fileType = archive.ar; 704 | path = libyoga.a; 705 | remoteRef = 3DAD3EA61DF850E9000B6D8A /* PBXContainerItemProxy */; 706 | sourceTree = BUILT_PRODUCTS_DIR; 707 | }; 708 | 3DAD3EA91DF850E9000B6D8A /* libcxxreact.a */ = { 709 | isa = PBXReferenceProxy; 710 | fileType = archive.ar; 711 | path = libcxxreact.a; 712 | remoteRef = 3DAD3EA81DF850E9000B6D8A /* PBXContainerItemProxy */; 713 | sourceTree = BUILT_PRODUCTS_DIR; 714 | }; 715 | 3DAD3EAB1DF850E9000B6D8A /* libcxxreact.a */ = { 716 | isa = PBXReferenceProxy; 717 | fileType = archive.ar; 718 | path = libcxxreact.a; 719 | remoteRef = 3DAD3EAA1DF850E9000B6D8A /* PBXContainerItemProxy */; 720 | sourceTree = BUILT_PRODUCTS_DIR; 721 | }; 722 | 3DAD3EAD1DF850E9000B6D8A /* libjschelpers.a */ = { 723 | isa = PBXReferenceProxy; 724 | fileType = archive.ar; 725 | path = libjschelpers.a; 726 | remoteRef = 3DAD3EAC1DF850E9000B6D8A /* PBXContainerItemProxy */; 727 | sourceTree = BUILT_PRODUCTS_DIR; 728 | }; 729 | 3DAD3EAF1DF850E9000B6D8A /* libjschelpers.a */ = { 730 | isa = PBXReferenceProxy; 731 | fileType = archive.ar; 732 | path = libjschelpers.a; 733 | remoteRef = 3DAD3EAE1DF850E9000B6D8A /* PBXContainerItemProxy */; 734 | sourceTree = BUILT_PRODUCTS_DIR; 735 | }; 736 | 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */ = { 737 | isa = PBXReferenceProxy; 738 | fileType = archive.ar; 739 | path = libRCTAnimation.a; 740 | remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */; 741 | sourceTree = BUILT_PRODUCTS_DIR; 742 | }; 743 | 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = { 744 | isa = PBXReferenceProxy; 745 | fileType = archive.ar; 746 | path = "libRCTAnimation-tvOS.a"; 747 | remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */; 748 | sourceTree = BUILT_PRODUCTS_DIR; 749 | }; 750 | 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { 751 | isa = PBXReferenceProxy; 752 | fileType = archive.ar; 753 | path = libRCTLinking.a; 754 | remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */; 755 | sourceTree = BUILT_PRODUCTS_DIR; 756 | }; 757 | 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { 758 | isa = PBXReferenceProxy; 759 | fileType = archive.ar; 760 | path = libRCTText.a; 761 | remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; 762 | sourceTree = BUILT_PRODUCTS_DIR; 763 | }; 764 | BB9AE90F1E32C6D50004E328 /* libRNWorkers.a */ = { 765 | isa = PBXReferenceProxy; 766 | fileType = archive.ar; 767 | path = libRNWorkers.a; 768 | remoteRef = BB9AE90E1E32C6D50004E328 /* PBXContainerItemProxy */; 769 | sourceTree = BUILT_PRODUCTS_DIR; 770 | }; 771 | /* End PBXReferenceProxy section */ 772 | 773 | /* Begin PBXResourcesBuildPhase section */ 774 | 00E356EC1AD99517003FC87E /* Resources */ = { 775 | isa = PBXResourcesBuildPhase; 776 | buildActionMask = 2147483647; 777 | files = ( 778 | ); 779 | runOnlyForDeploymentPostprocessing = 0; 780 | }; 781 | 13B07F8E1A680F5B00A75B9A /* Resources */ = { 782 | isa = PBXResourcesBuildPhase; 783 | buildActionMask = 2147483647; 784 | files = ( 785 | BB31A6691E4BBC9D007365A3 /* worker.jsbundle in Resources */, 786 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 787 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, 788 | ); 789 | runOnlyForDeploymentPostprocessing = 0; 790 | }; 791 | /* End PBXResourcesBuildPhase section */ 792 | 793 | /* Begin PBXShellScriptBuildPhase section */ 794 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = { 795 | isa = PBXShellScriptBuildPhase; 796 | buildActionMask = 2147483647; 797 | files = ( 798 | ); 799 | inputPaths = ( 800 | ); 801 | name = "Bundle React Native code and images"; 802 | outputPaths = ( 803 | ); 804 | runOnlyForDeploymentPostprocessing = 0; 805 | shellPath = /bin/sh; 806 | shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; 807 | }; 808 | /* End PBXShellScriptBuildPhase section */ 809 | 810 | /* Begin PBXSourcesBuildPhase section */ 811 | 00E356EA1AD99517003FC87E /* Sources */ = { 812 | isa = PBXSourcesBuildPhase; 813 | buildActionMask = 2147483647; 814 | files = ( 815 | 00E356F31AD99517003FC87E /* rnappTests.m in Sources */, 816 | ); 817 | runOnlyForDeploymentPostprocessing = 0; 818 | }; 819 | 13B07F871A680F5B00A75B9A /* Sources */ = { 820 | isa = PBXSourcesBuildPhase; 821 | buildActionMask = 2147483647; 822 | files = ( 823 | BB9D0ABF1E2816B500CD2926 /* AppDelegate.swift in Sources */, 824 | ); 825 | runOnlyForDeploymentPostprocessing = 0; 826 | }; 827 | /* End PBXSourcesBuildPhase section */ 828 | 829 | /* Begin PBXTargetDependency section */ 830 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { 831 | isa = PBXTargetDependency; 832 | target = 13B07F861A680F5B00A75B9A /* rnapp */; 833 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; 834 | }; 835 | /* End PBXTargetDependency section */ 836 | 837 | /* Begin PBXVariantGroup section */ 838 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { 839 | isa = PBXVariantGroup; 840 | children = ( 841 | 13B07FB21A68108700A75B9A /* Base */, 842 | ); 843 | name = LaunchScreen.xib; 844 | path = rnapp; 845 | sourceTree = ""; 846 | }; 847 | /* End PBXVariantGroup section */ 848 | 849 | /* Begin XCBuildConfiguration section */ 850 | 00E356F61AD99517003FC87E /* Debug */ = { 851 | isa = XCBuildConfiguration; 852 | buildSettings = { 853 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 854 | BUNDLE_LOADER = "$(TEST_HOST)"; 855 | GCC_PREPROCESSOR_DEFINITIONS = ( 856 | "DEBUG=1", 857 | "$(inherited)", 858 | ); 859 | INFOPLIST_FILE = rnappTests/Info.plist; 860 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 861 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 862 | LIBRARY_SEARCH_PATHS = ( 863 | "$(inherited)", 864 | "\"$(SRCROOT)/$(TARGET_NAME)\"", 865 | ); 866 | PRODUCT_NAME = "$(TARGET_NAME)"; 867 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/rnapp.app/rnapp"; 868 | }; 869 | name = Debug; 870 | }; 871 | 00E356F71AD99517003FC87E /* Release */ = { 872 | isa = XCBuildConfiguration; 873 | buildSettings = { 874 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 875 | BUNDLE_LOADER = "$(TEST_HOST)"; 876 | COPY_PHASE_STRIP = NO; 877 | INFOPLIST_FILE = rnappTests/Info.plist; 878 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 879 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 880 | LIBRARY_SEARCH_PATHS = ( 881 | "$(inherited)", 882 | "\"$(SRCROOT)/$(TARGET_NAME)\"", 883 | ); 884 | PRODUCT_NAME = "$(TARGET_NAME)"; 885 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/rnapp.app/rnapp"; 886 | }; 887 | name = Release; 888 | }; 889 | 13B07F941A680F5B00A75B9A /* Debug */ = { 890 | isa = XCBuildConfiguration; 891 | buildSettings = { 892 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 893 | CLANG_ENABLE_MODULES = YES; 894 | CURRENT_PROJECT_VERSION = 1; 895 | DEAD_CODE_STRIPPING = NO; 896 | DEVELOPMENT_TEAM = K9E42X52H2; 897 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/rn-workers/ios/**"; 898 | INFOPLIST_FILE = rnapp/Info.plist; 899 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 900 | OTHER_LDFLAGS = ( 901 | "$(inherited)", 902 | "-ObjC", 903 | "-lc++", 904 | ); 905 | PRODUCT_BUNDLE_IDENTIFIER = com.fabricio.vergal.rnworker.example; 906 | PRODUCT_NAME = rnapp; 907 | SWIFT_OBJC_BRIDGING_HEADER = "rnapp/rnapp-Bridging-Header.h"; 908 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 909 | SWIFT_VERSION = 3.0; 910 | VERSIONING_SYSTEM = "apple-generic"; 911 | }; 912 | name = Debug; 913 | }; 914 | 13B07F951A680F5B00A75B9A /* Release */ = { 915 | isa = XCBuildConfiguration; 916 | buildSettings = { 917 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 918 | CLANG_ENABLE_MODULES = YES; 919 | CURRENT_PROJECT_VERSION = 1; 920 | DEVELOPMENT_TEAM = K9E42X52H2; 921 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../node_modules/rn-workers/ios/**"; 922 | INFOPLIST_FILE = rnapp/Info.plist; 923 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 924 | OTHER_LDFLAGS = ( 925 | "$(inherited)", 926 | "-ObjC", 927 | "-lc++", 928 | ); 929 | PRODUCT_BUNDLE_IDENTIFIER = com.fabricio.vergal.rnworker.example; 930 | PRODUCT_NAME = rnapp; 931 | SWIFT_OBJC_BRIDGING_HEADER = "rnapp/rnapp-Bridging-Header.h"; 932 | SWIFT_VERSION = 3.0; 933 | VERSIONING_SYSTEM = "apple-generic"; 934 | }; 935 | name = Release; 936 | }; 937 | 83CBBA201A601CBA00E9B192 /* Debug */ = { 938 | isa = XCBuildConfiguration; 939 | buildSettings = { 940 | ALWAYS_SEARCH_USER_PATHS = NO; 941 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 942 | CLANG_CXX_LIBRARY = "libc++"; 943 | CLANG_ENABLE_MODULES = YES; 944 | CLANG_ENABLE_OBJC_ARC = YES; 945 | CLANG_WARN_BOOL_CONVERSION = YES; 946 | CLANG_WARN_CONSTANT_CONVERSION = YES; 947 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 948 | CLANG_WARN_EMPTY_BODY = YES; 949 | CLANG_WARN_ENUM_CONVERSION = YES; 950 | CLANG_WARN_INT_CONVERSION = YES; 951 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 952 | CLANG_WARN_UNREACHABLE_CODE = YES; 953 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 954 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 955 | COPY_PHASE_STRIP = NO; 956 | ENABLE_STRICT_OBJC_MSGSEND = YES; 957 | GCC_C_LANGUAGE_STANDARD = gnu99; 958 | GCC_DYNAMIC_NO_PIC = NO; 959 | GCC_OPTIMIZATION_LEVEL = 0; 960 | GCC_PREPROCESSOR_DEFINITIONS = ( 961 | "DEBUG=1", 962 | "$(inherited)", 963 | ); 964 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 965 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 966 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 967 | GCC_WARN_UNDECLARED_SELECTOR = YES; 968 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 969 | GCC_WARN_UNUSED_FUNCTION = YES; 970 | GCC_WARN_UNUSED_VARIABLE = YES; 971 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 972 | MTL_ENABLE_DEBUG_INFO = YES; 973 | ONLY_ACTIVE_ARCH = YES; 974 | SDKROOT = iphoneos; 975 | }; 976 | name = Debug; 977 | }; 978 | 83CBBA211A601CBA00E9B192 /* Release */ = { 979 | isa = XCBuildConfiguration; 980 | buildSettings = { 981 | ALWAYS_SEARCH_USER_PATHS = NO; 982 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 983 | CLANG_CXX_LIBRARY = "libc++"; 984 | CLANG_ENABLE_MODULES = YES; 985 | CLANG_ENABLE_OBJC_ARC = YES; 986 | CLANG_WARN_BOOL_CONVERSION = YES; 987 | CLANG_WARN_CONSTANT_CONVERSION = YES; 988 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 989 | CLANG_WARN_EMPTY_BODY = YES; 990 | CLANG_WARN_ENUM_CONVERSION = YES; 991 | CLANG_WARN_INT_CONVERSION = YES; 992 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 993 | CLANG_WARN_UNREACHABLE_CODE = YES; 994 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 995 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 996 | COPY_PHASE_STRIP = YES; 997 | ENABLE_NS_ASSERTIONS = NO; 998 | ENABLE_STRICT_OBJC_MSGSEND = YES; 999 | GCC_C_LANGUAGE_STANDARD = gnu99; 1000 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 1001 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 1002 | GCC_WARN_UNDECLARED_SELECTOR = YES; 1003 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 1004 | GCC_WARN_UNUSED_FUNCTION = YES; 1005 | GCC_WARN_UNUSED_VARIABLE = YES; 1006 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 1007 | MTL_ENABLE_DEBUG_INFO = NO; 1008 | SDKROOT = iphoneos; 1009 | VALIDATE_PRODUCT = YES; 1010 | }; 1011 | name = Release; 1012 | }; 1013 | /* End XCBuildConfiguration section */ 1014 | 1015 | /* Begin XCConfigurationList section */ 1016 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "rnappTests" */ = { 1017 | isa = XCConfigurationList; 1018 | buildConfigurations = ( 1019 | 00E356F61AD99517003FC87E /* Debug */, 1020 | 00E356F71AD99517003FC87E /* Release */, 1021 | ); 1022 | defaultConfigurationIsVisible = 0; 1023 | defaultConfigurationName = Release; 1024 | }; 1025 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "rnapp" */ = { 1026 | isa = XCConfigurationList; 1027 | buildConfigurations = ( 1028 | 13B07F941A680F5B00A75B9A /* Debug */, 1029 | 13B07F951A680F5B00A75B9A /* Release */, 1030 | ); 1031 | defaultConfigurationIsVisible = 0; 1032 | defaultConfigurationName = Release; 1033 | }; 1034 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "rnapp" */ = { 1035 | isa = XCConfigurationList; 1036 | buildConfigurations = ( 1037 | 83CBBA201A601CBA00E9B192 /* Debug */, 1038 | 83CBBA211A601CBA00E9B192 /* Release */, 1039 | ); 1040 | defaultConfigurationIsVisible = 0; 1041 | defaultConfigurationName = Release; 1042 | }; 1043 | /* End XCConfigurationList section */ 1044 | }; 1045 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; 1046 | } 1047 | -------------------------------------------------------------------------------- /example/ios/rnapp.xcodeproj/xcshareddata/xcschemes/rnapp.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /example/ios/rnapp/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import UIKit 3 | 4 | @UIApplicationMain 5 | class AppDelegate: UIResponder, UIApplicationDelegate { 6 | 7 | var window: UIWindow? 8 | 9 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool{ 10 | 11 | //Create default worker on port 8082 12 | RNWorkersManager.sharedInstance().initWorker() 13 | 14 | let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index.ios", 15 | fallbackResource: "main") 16 | 17 | let rootView = RCTRootView.init(bundleURL: jsCodeLocation, moduleName: "rnapp", initialProperties: nil, launchOptions: launchOptions) 18 | rootView?.backgroundColor = UIColor.init(colorLiteralRed: 1, green: 1, blue: 1, alpha: 1) 19 | 20 | 21 | let rootViewController = UIViewController() 22 | rootViewController.view = rootView 23 | 24 | RNWorkersManager.sharedInstance().startWorkers(with: rootView) 25 | 26 | self.window = UIWindow.init(frame: UIScreen.main.bounds) 27 | self.window!.rootViewController = rootViewController 28 | self.window!.makeKeyAndVisible() 29 | 30 | return true 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /example/ios/rnapp/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /example/ios/rnapp/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /example/ios/rnapp/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSAllowsArbitraryLoads 28 | 29 | 30 | NSLocationWhenInUseUsageDescription 31 | 32 | UILaunchStoryboardName 33 | LaunchScreen 34 | UIRequiredDeviceCapabilities 35 | 36 | armv7 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/ios/rnapp/rnapp-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import 6 | #import 7 | #import 8 | #import 9 | #import 10 | 11 | #import "RNWorkersManager.h" 12 | -------------------------------------------------------------------------------- /example/ios/rnappTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/ios/rnappTests/rnappTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface rnappTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation rnappTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rnapp", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "babel-preset-react-native-stage-0": "^1.0.1", 11 | "react": "15.4.2", 12 | "react-native": "0.41.0", 13 | "rn-workers": "file:../" 14 | }, 15 | "devDependencies": { 16 | "babel-jest": "18.0.0", 17 | "babel-preset-react-native": "1.9.1", 18 | "jest": "18.1.0", 19 | "react-test-renderer": "15.4.2" 20 | }, 21 | "jest": { 22 | "preset": "react-native" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import { NativeModules } from 'react-native'; 2 | import creator from './src/createWorker'; 3 | 4 | const { RNWorkers } = NativeModules; 5 | 6 | export const isSimulationEnabled = RNWorkers.simulationEnabled; 7 | export const WorkerService = creator("RNWorkers", message => RNWorkers.sendMessageToApp(message)); 8 | export const Worker = creator("RNWorkersApp", (message, port) => RNWorkers.sendMessageToWorker(port, message)); 9 | export default Worker 10 | -------------------------------------------------------------------------------- /ios/RNWorkers.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | BB2E77121E2A69E9003CD6F3 /* RNWorkers.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2E770F1E2A69E9003CD6F3 /* RNWorkers.m */; }; 11 | BB2E77131E2A69E9003CD6F3 /* RNWorkersManager.m in Sources */ = {isa = PBXBuildFile; fileRef = BB2E77111E2A69E9003CD6F3 /* RNWorkersManager.m */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXCopyFilesBuildPhase section */ 15 | BB2E77001E2A695C003CD6F3 /* CopyFiles */ = { 16 | isa = PBXCopyFilesBuildPhase; 17 | buildActionMask = 2147483647; 18 | dstPath = "include/$(PRODUCT_NAME)"; 19 | dstSubfolderSpec = 16; 20 | files = ( 21 | ); 22 | runOnlyForDeploymentPostprocessing = 0; 23 | }; 24 | /* End PBXCopyFilesBuildPhase section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | BB2E77021E2A695C003CD6F3 /* libRNWorkers.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNWorkers.a; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | BB2E770E1E2A69E9003CD6F3 /* RNWorkers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNWorkers.h; sourceTree = ""; }; 29 | BB2E770F1E2A69E9003CD6F3 /* RNWorkers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNWorkers.m; sourceTree = ""; }; 30 | BB2E77101E2A69E9003CD6F3 /* RNWorkersManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNWorkersManager.h; sourceTree = ""; }; 31 | BB2E77111E2A69E9003CD6F3 /* RNWorkersManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNWorkersManager.m; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | BB2E76FF1E2A695C003CD6F3 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | BB2E76F91E2A695C003CD6F3 = { 46 | isa = PBXGroup; 47 | children = ( 48 | BB2E77041E2A695C003CD6F3 /* RNWorkers */, 49 | BB2E77031E2A695C003CD6F3 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | BB2E77031E2A695C003CD6F3 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | BB2E77021E2A695C003CD6F3 /* libRNWorkers.a */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | BB2E77041E2A695C003CD6F3 /* RNWorkers */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | BB2E770E1E2A69E9003CD6F3 /* RNWorkers.h */, 65 | BB2E770F1E2A69E9003CD6F3 /* RNWorkers.m */, 66 | BB2E77101E2A69E9003CD6F3 /* RNWorkersManager.h */, 67 | BB2E77111E2A69E9003CD6F3 /* RNWorkersManager.m */, 68 | ); 69 | path = RNWorkers; 70 | sourceTree = ""; 71 | }; 72 | /* End PBXGroup section */ 73 | 74 | /* Begin PBXNativeTarget section */ 75 | BB2E77011E2A695C003CD6F3 /* RNWorkers */ = { 76 | isa = PBXNativeTarget; 77 | buildConfigurationList = BB2E770B1E2A695C003CD6F3 /* Build configuration list for PBXNativeTarget "RNWorkers" */; 78 | buildPhases = ( 79 | BB2E76FE1E2A695C003CD6F3 /* Sources */, 80 | BB2E76FF1E2A695C003CD6F3 /* Frameworks */, 81 | BB2E77001E2A695C003CD6F3 /* CopyFiles */, 82 | ); 83 | buildRules = ( 84 | ); 85 | dependencies = ( 86 | ); 87 | name = RNWorkers; 88 | productName = RNWorkers; 89 | productReference = BB2E77021E2A695C003CD6F3 /* libRNWorkers.a */; 90 | productType = "com.apple.product-type.library.static"; 91 | }; 92 | /* End PBXNativeTarget section */ 93 | 94 | /* Begin PBXProject section */ 95 | BB2E76FA1E2A695C003CD6F3 /* Project object */ = { 96 | isa = PBXProject; 97 | attributes = { 98 | LastUpgradeCheck = 0820; 99 | ORGANIZATIONNAME = Fabriciovergal; 100 | TargetAttributes = { 101 | BB2E77011E2A695C003CD6F3 = { 102 | CreatedOnToolsVersion = 8.2.1; 103 | DevelopmentTeam = K9E42X52H2; 104 | ProvisioningStyle = Automatic; 105 | }; 106 | }; 107 | }; 108 | buildConfigurationList = BB2E76FD1E2A695C003CD6F3 /* Build configuration list for PBXProject "RNWorkers" */; 109 | compatibilityVersion = "Xcode 3.2"; 110 | developmentRegion = English; 111 | hasScannedForEncodings = 0; 112 | knownRegions = ( 113 | en, 114 | ); 115 | mainGroup = BB2E76F91E2A695C003CD6F3; 116 | productRefGroup = BB2E77031E2A695C003CD6F3 /* Products */; 117 | projectDirPath = ""; 118 | projectRoot = ""; 119 | targets = ( 120 | BB2E77011E2A695C003CD6F3 /* RNWorkers */, 121 | ); 122 | }; 123 | /* End PBXProject section */ 124 | 125 | /* Begin PBXSourcesBuildPhase section */ 126 | BB2E76FE1E2A695C003CD6F3 /* Sources */ = { 127 | isa = PBXSourcesBuildPhase; 128 | buildActionMask = 2147483647; 129 | files = ( 130 | BB2E77121E2A69E9003CD6F3 /* RNWorkers.m in Sources */, 131 | BB2E77131E2A69E9003CD6F3 /* RNWorkersManager.m in Sources */, 132 | ); 133 | runOnlyForDeploymentPostprocessing = 0; 134 | }; 135 | /* End PBXSourcesBuildPhase section */ 136 | 137 | /* Begin XCBuildConfiguration section */ 138 | BB2E77091E2A695C003CD6F3 /* Debug */ = { 139 | isa = XCBuildConfiguration; 140 | buildSettings = { 141 | ALWAYS_SEARCH_USER_PATHS = NO; 142 | CLANG_ANALYZER_NONNULL = YES; 143 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 144 | CLANG_CXX_LIBRARY = "libc++"; 145 | CLANG_ENABLE_MODULES = YES; 146 | CLANG_ENABLE_OBJC_ARC = YES; 147 | CLANG_WARN_BOOL_CONVERSION = YES; 148 | CLANG_WARN_CONSTANT_CONVERSION = YES; 149 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 150 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 151 | CLANG_WARN_EMPTY_BODY = YES; 152 | CLANG_WARN_ENUM_CONVERSION = YES; 153 | CLANG_WARN_INFINITE_RECURSION = YES; 154 | CLANG_WARN_INT_CONVERSION = YES; 155 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 156 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 157 | CLANG_WARN_UNREACHABLE_CODE = YES; 158 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 159 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 160 | COPY_PHASE_STRIP = NO; 161 | DEBUG_INFORMATION_FORMAT = dwarf; 162 | ENABLE_STRICT_OBJC_MSGSEND = YES; 163 | ENABLE_TESTABILITY = YES; 164 | GCC_C_LANGUAGE_STANDARD = gnu99; 165 | GCC_DYNAMIC_NO_PIC = NO; 166 | GCC_NO_COMMON_BLOCKS = YES; 167 | GCC_OPTIMIZATION_LEVEL = 0; 168 | GCC_PREPROCESSOR_DEFINITIONS = ( 169 | "DEBUG=1", 170 | "$(inherited)", 171 | ); 172 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 173 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 174 | GCC_WARN_UNDECLARED_SELECTOR = YES; 175 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 176 | GCC_WARN_UNUSED_FUNCTION = YES; 177 | GCC_WARN_UNUSED_VARIABLE = YES; 178 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 179 | MTL_ENABLE_DEBUG_INFO = YES; 180 | ONLY_ACTIVE_ARCH = YES; 181 | SDKROOT = iphoneos; 182 | }; 183 | name = Debug; 184 | }; 185 | BB2E770A1E2A695C003CD6F3 /* Release */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_ANALYZER_NONNULL = YES; 190 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 191 | CLANG_CXX_LIBRARY = "libc++"; 192 | CLANG_ENABLE_MODULES = YES; 193 | CLANG_ENABLE_OBJC_ARC = YES; 194 | CLANG_WARN_BOOL_CONVERSION = YES; 195 | CLANG_WARN_CONSTANT_CONVERSION = YES; 196 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 197 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 198 | CLANG_WARN_EMPTY_BODY = YES; 199 | CLANG_WARN_ENUM_CONVERSION = YES; 200 | CLANG_WARN_INFINITE_RECURSION = YES; 201 | CLANG_WARN_INT_CONVERSION = YES; 202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 203 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 204 | CLANG_WARN_UNREACHABLE_CODE = YES; 205 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 206 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 207 | COPY_PHASE_STRIP = NO; 208 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 209 | ENABLE_NS_ASSERTIONS = NO; 210 | ENABLE_STRICT_OBJC_MSGSEND = YES; 211 | GCC_C_LANGUAGE_STANDARD = gnu99; 212 | GCC_NO_COMMON_BLOCKS = YES; 213 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 214 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 215 | GCC_WARN_UNDECLARED_SELECTOR = YES; 216 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 217 | GCC_WARN_UNUSED_FUNCTION = YES; 218 | GCC_WARN_UNUSED_VARIABLE = YES; 219 | IPHONEOS_DEPLOYMENT_TARGET = 10.2; 220 | MTL_ENABLE_DEBUG_INFO = NO; 221 | SDKROOT = iphoneos; 222 | VALIDATE_PRODUCT = YES; 223 | }; 224 | name = Release; 225 | }; 226 | BB2E770C1E2A695C003CD6F3 /* Debug */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | DEVELOPMENT_TEAM = K9E42X52H2; 230 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React/**"; 231 | OTHER_LDFLAGS = "-ObjC"; 232 | PRODUCT_NAME = "$(TARGET_NAME)"; 233 | SKIP_INSTALL = YES; 234 | }; 235 | name = Debug; 236 | }; 237 | BB2E770D1E2A695C003CD6F3 /* Release */ = { 238 | isa = XCBuildConfiguration; 239 | buildSettings = { 240 | DEVELOPMENT_TEAM = K9E42X52H2; 241 | HEADER_SEARCH_PATHS = "$(SRCROOT)/../../react-native/React/**"; 242 | OTHER_LDFLAGS = "-ObjC"; 243 | PRODUCT_NAME = "$(TARGET_NAME)"; 244 | SKIP_INSTALL = YES; 245 | }; 246 | name = Release; 247 | }; 248 | /* End XCBuildConfiguration section */ 249 | 250 | /* Begin XCConfigurationList section */ 251 | BB2E76FD1E2A695C003CD6F3 /* Build configuration list for PBXProject "RNWorkers" */ = { 252 | isa = XCConfigurationList; 253 | buildConfigurations = ( 254 | BB2E77091E2A695C003CD6F3 /* Debug */, 255 | BB2E770A1E2A695C003CD6F3 /* Release */, 256 | ); 257 | defaultConfigurationIsVisible = 0; 258 | defaultConfigurationName = Release; 259 | }; 260 | BB2E770B1E2A695C003CD6F3 /* Build configuration list for PBXNativeTarget "RNWorkers" */ = { 261 | isa = XCConfigurationList; 262 | buildConfigurations = ( 263 | BB2E770C1E2A695C003CD6F3 /* Debug */, 264 | BB2E770D1E2A695C003CD6F3 /* Release */, 265 | ); 266 | defaultConfigurationIsVisible = 0; 267 | defaultConfigurationName = Release; 268 | }; 269 | /* End XCConfigurationList section */ 270 | }; 271 | rootObject = BB2E76FA1E2A695C003CD6F3 /* Project object */; 272 | } 273 | -------------------------------------------------------------------------------- /ios/RNWorkers.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/RNWorkers.xcodeproj/project.xcworkspace/xcuserdata/fabriciovergal.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fabriciovergara/react-native-workers/d9f1935d93e5721e7265e8aa424bc0272d6325db/ios/RNWorkers.xcodeproj/project.xcworkspace/xcuserdata/fabriciovergal.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ios/RNWorkers.xcodeproj/xcuserdata/fabriciovergal.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 8 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ios/RNWorkers.xcodeproj/xcuserdata/fabriciovergal.xcuserdatad/xcschemes/RNWorkers.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /ios/RNWorkers.xcodeproj/xcuserdata/fabriciovergal.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | RNWorkers.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | BB2E77011E2A695C003CD6F3 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ios/RNWorkers/RNWorkers.h: -------------------------------------------------------------------------------- 1 | #ifndef RNWorkers_h 2 | #define RNWorkers_h 3 | 4 | 5 | #import "RNWorkersManager.h" 6 | #import 7 | #import 8 | 9 | @interface RNWorkers : NSObject 10 | @end 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ios/RNWorkers/RNWorkers.m: -------------------------------------------------------------------------------- 1 | #import "RNWorkers.h" 2 | 3 | @implementation RNWorkers 4 | 5 | RCT_EXPORT_MODULE(); 6 | 7 | RCT_EXPORT_METHOD(sendMessageToWorker:(int)port message:(NSString *)message) 8 | { 9 | NSNumber *nsPort = [NSNumber numberWithInt:port]; 10 | NSMutableDictionary *dic = [RNWorkersManager sharedInstance].workerDictionary; 11 | RCTBridge *workerBridge = [dic objectForKey:nsPort]; 12 | if(workerBridge == nil){ 13 | return; 14 | } 15 | 16 | [workerBridge.eventDispatcher sendAppEventWithName:@"RNWorkers" body:message]; 17 | } 18 | 19 | RCT_EXPORT_METHOD(sendMessageToApp:(NSString *)message) 20 | { 21 | RCTBridge *mainBridge = [RNWorkersManager sharedInstance].mainBridge; 22 | if(mainBridge == nil){ 23 | return; 24 | } 25 | 26 | [mainBridge.eventDispatcher sendAppEventWithName:@"RNWorkersApp" body:message]; 27 | } 28 | 29 | - (NSDictionary *)constantsToExport 30 | { 31 | return @{ @"simulationEnabled": [RNWorkersManager sharedInstance].simulationEnabled }; 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ios/RNWorkers/RNWorkersManager.h: -------------------------------------------------------------------------------- 1 | #ifndef RNWorkersManager_h 2 | #define RNWorkersManager_h 3 | 4 | #import 5 | #import 6 | #import 7 | #import 8 | #import 9 | 10 | @interface RNWorkersManager : NSObject 11 | { 12 | NSMutableDictionary *workerDictionary; 13 | RCTBridge *mainBridge; 14 | } 15 | 16 | + (instancetype)sharedInstance; 17 | - (void) initWorker; 18 | - (void) initWorkerWithPort:(int) port bundleRoot:(NSString*) bundle fallbackResouce:(NSString*) resource; 19 | - (void) startWorkersWithRootView: (RCTRootView*) rootView; 20 | 21 | @property (nonatomic, strong, readonly) NSMutableDictionary *workerDictionary; 22 | @property (nonatomic, strong, readonly) RCTBridge *mainBridge; 23 | @property (nonatomic, assign) NSNumber *simulationEnabled; 24 | @property (nonatomic, assign) NSNumber *preferResourceEnabled; 25 | 26 | @end 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /ios/RNWorkers/RNWorkersManager.m: -------------------------------------------------------------------------------- 1 | #import "RNWorkersManager.h" 2 | 3 | @implementation RNWorkersManager 4 | 5 | @synthesize mainBridge; 6 | @synthesize workerDictionary; 7 | @synthesize simulationEnabled; 8 | @synthesize preferResourceEnabled; 9 | 10 | + (instancetype)sharedInstance 11 | { 12 | static RNWorkersManager *instance; 13 | static dispatch_once_t once_token; 14 | dispatch_once(&once_token, ^{ 15 | instance = [[RNWorkersManager alloc] init]; 16 | }); 17 | return instance; 18 | } 19 | 20 | - (id)init 21 | { 22 | self = [super init]; 23 | workerDictionary = [[NSMutableDictionary alloc] init]; 24 | simulationEnabled = [NSNumber numberWithBool: NO]; 25 | preferResourceEnabled = [NSNumber numberWithBool: NO]; 26 | return self; 27 | } 28 | 29 | - (void) initWorker 30 | { 31 | [self initWorkerWithPort:8082 bundleRoot:@"index.worker" fallbackResouce:@"worker"]; 32 | } 33 | 34 | - (void) initWorkerWithPort:(int) port 35 | bundleRoot:(NSString*) bundle 36 | fallbackResouce:(NSString*) resource 37 | { 38 | NSNumber *nsPort = [NSNumber numberWithInt:port]; 39 | NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:bundle fallbackResource:resource]; 40 | 41 | #if RCT_DEV 42 | 43 | if([preferResourceEnabled boolValue] == YES){ 44 | if(resource == nil){ 45 | [NSException raise:@"rn-worker" format:@"preferResourceEnabled is enabled but no resource was provided"]; 46 | } 47 | 48 | jsCodeLocation = [[NSBundle mainBundle] URLForResource:resource withExtension:@"jsbundle"]; 49 | 50 | if(jsCodeLocation == nil){ 51 | [NSException raise:@"rn-worker" format:@"JS bundle '%@.jsbundle' not found", resource]; 52 | } 53 | }else{ 54 | NSString *workerPort = [nsPort stringValue]; 55 | NSString *appPort = [jsCodeLocation.port stringValue]; 56 | NSString *path = [jsCodeLocation.absoluteString stringByReplacingOccurrencesOfString:appPort withString:workerPort]; 57 | jsCodeLocation = [[NSURL alloc] initWithString:path]; 58 | } 59 | 60 | #endif 61 | 62 | 63 | if([simulationEnabled boolValue] == NO){ 64 | RCTBridge *worker = [[RCTBridge alloc] initWithBundleURL:jsCodeLocation 65 | moduleProvider:nil 66 | launchOptions:nil]; 67 | [workerDictionary setObject:worker forKey:nsPort]; 68 | }else { 69 | [workerDictionary setObject:nsPort forKey:nsPort]; 70 | } 71 | 72 | 73 | 74 | } 75 | 76 | - (void) startWorkersWithRootView: (RCTRootView*) rootView 77 | { 78 | mainBridge = rootView.bridge; 79 | if([simulationEnabled boolValue] == YES){ 80 | [self fillDictionaryWithMainBridge]; 81 | } 82 | } 83 | 84 | - (void) fillDictionaryWithMainBridge 85 | { 86 | NSArray *keys = [workerDictionary allKeys]; 87 | if(keys != nil){ 88 | for (id key in keys) { 89 | [workerDictionary setObject:mainBridge forKey:key]; 90 | } 91 | } 92 | } 93 | 94 | @end 95 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "name": "rn-workers", 4 | "version": "0.1.7", 5 | "description": "JS workers for React Native", 6 | "license": "Apache 2.0", 7 | "author": "https://github.com/fabriciovergal", 8 | "homepage": "https://github.com/fabriciovergal/react-native-workers", 9 | "bugs": { 10 | "url": "https://github.com/fabriciovergal/react-native-workers/issues" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/fabriciovergal/react-native-workers" 15 | }, 16 | "main": "index.js", 17 | "keywords": [ 18 | "react-native", 19 | "react-component", 20 | "worker", 21 | "web worker", 22 | "WebWorker", 23 | "background", 24 | "ios", 25 | "android" 26 | ], 27 | "scripts": { 28 | "test": "echo \"Error: no test specified\" && exit 1" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/createWorker.js: -------------------------------------------------------------------------------- 1 | import { DeviceEventEmitter } from 'react-native'; 2 | 3 | export default (eventName, sendMessage) => { 4 | 5 | class Worker { 6 | 7 | constructor(port = 8082) { 8 | //Read only property 9 | Object.defineProperty(this, "port", { value: port, writable: false }); 10 | this.onmessage = null; 11 | this.subscription = DeviceEventEmitter.addListener(eventName, message => 12 | this.onmessage && typeof this.onmessage === 'function' && this.onmessage(message) 13 | ); 14 | } 15 | 16 | terminate(){ 17 | this.subscription.remove(); 18 | } 19 | 20 | postMessage(message){ 21 | if (typeof message !== 'string') { 22 | console.warn("Only strings is allowed"); 23 | return; 24 | } 25 | 26 | sendMessage(message, this.port); 27 | } 28 | } 29 | 30 | return Worker; 31 | } --------------------------------------------------------------------------------