-
Notifications
You must be signed in to change notification settings - Fork 272
support to Expo #486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support to Expo #486
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 18 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 18 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,4 +52,4 @@ | |
| "detox", | ||
| "dtrace-provider" | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -223,4 +223,4 @@ export default function Root() { | |
| </PaperProvider> | ||
| </UpdateProvider> | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,4 @@ | |
| "appId": 27509, | ||
| "appKey": "aQz3Uc2pA7gt_prDaQ4rbWRY" | ||
| } | ||
| } | ||
| } | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,14 +22,42 @@ def supportsNamespace() { | |
| return major >= 8 | ||
| } | ||
|
|
||
| def isExpoProject() { | ||
| def hasExpoModulesCore = rootProject.subprojects.any { it.name == 'expo-modules-core' } | ||
|
|
||
| def packageJsonFile = new File(rootProject.projectDir.parentFile, 'package.json') | ||
| def hasExpoDependency = false | ||
| if (packageJsonFile.exists()) { | ||
| def packageJson = new groovy.json.JsonSlurper().parseText(packageJsonFile.text) | ||
| hasExpoDependency = (packageJson.dependencies?.expo != null) || | ||
| (packageJson.devDependencies?.expo != null) | ||
| } | ||
|
|
||
| return hasExpoModulesCore || hasExpoDependency | ||
| } | ||
|
|
||
| def expoProject = isExpoProject() | ||
|
|
||
| apply plugin: 'com.android.library' | ||
| if (isNewArchitectureEnabled()) { | ||
| apply plugin: 'com.facebook.react' | ||
| } | ||
|
|
||
| if (expoProject) { | ||
| group = 'expo.modules.pushy' | ||
| version = '1.0.0' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个version应该可以从package.json中读取吧 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expo.modules.pushy属于native代码,不应该读取package.json里面的版本号吧,这里的逻辑借鉴的是 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 应该统一版本号,不过不是很重要,以后再说吧 |
||
|
|
||
| android { | ||
| def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle") | ||
| apply from: expoModulesCorePlugin | ||
| applyKotlinExpoModulesCorePlugin() | ||
| useCoreDependencies() | ||
| useExpoPublishing() | ||
| } else { | ||
| group = 'cn.reactnative.modules.update' | ||
| version = '1.0.0' | ||
| } | ||
|
|
||
| android { | ||
| if (supportsNamespace()) { | ||
| namespace "cn.reactnative.modules.update" | ||
|
|
||
|
|
@@ -41,7 +69,6 @@ android { | |
| } | ||
| compileSdkVersion safeExtGet('compileSdkVersion', 28) | ||
| buildToolsVersion safeExtGet('buildToolsVersion', '28.0.3') | ||
|
|
||
| defaultConfig { | ||
| minSdkVersion safeExtGet('minSdkVersion', 16) | ||
| targetSdkVersion safeExtGet('targetSdkVersion', 27) | ||
|
|
@@ -50,6 +77,7 @@ android { | |
| consumerProguardFiles "proguard.pro" | ||
| buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() | ||
| } | ||
|
|
||
| sourceSets { | ||
| main { | ||
| // let gradle pack the shared library into apk | ||
|
|
@@ -59,6 +87,12 @@ android { | |
| } else { | ||
| java.srcDirs += ['src/oldarch'] | ||
| } | ||
|
|
||
| if (expoProject) { | ||
| java.srcDirs += ['java/expo/modules/pushy'] | ||
| } else { | ||
| java.exclude 'expo/modules/pushy/**' | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -70,6 +104,10 @@ android { | |
| resValue("string", "pushy_build_time", "0") | ||
| } | ||
| } | ||
|
|
||
| lintOptions { | ||
| abortOnError false | ||
| } | ||
| } | ||
|
|
||
| repositories { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package cn.reactnative.modules.update; | ||
|
|
||
| import androidx.annotation.Nullable; | ||
|
|
||
| public interface ReactNativeHostHandler { | ||
| @Nullable | ||
| String getJSBundleFile(boolean useDeveloperSupport); | ||
|
|
||
| @Nullable | ||
| String getBundleAssetName(boolean useDeveloperSupport); | ||
|
|
||
| void onWillCreateReactInstance(boolean useDeveloperSupport); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package expo.modules.pushy | ||
|
|
||
| import expo.modules.kotlin.modules.Module | ||
| import expo.modules.kotlin.modules.ModuleDefinition | ||
|
|
||
| class ExpoPushyModule : Module() { | ||
| override fun definition() = ModuleDefinition { | ||
| Name("ExpoPushy") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package expo.modules.pushy; | ||
|
|
||
| import android.content.Context; | ||
| import android.util.Log; | ||
| import androidx.annotation.Nullable; | ||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import cn.reactnative.modules.update.UpdateContext; | ||
| import expo.modules.core.interfaces.Package; | ||
| import expo.modules.core.interfaces.ReactNativeHostHandler; | ||
|
|
||
| public class ExpoPushyPackage implements Package { | ||
| @Override | ||
| public List<ReactNativeHostHandler> createReactNativeHostHandlers(Context context) { | ||
| List<ReactNativeHostHandler> handlers = new ArrayList<>(); | ||
| handlers.add(new ReactNativeHostHandler() { | ||
| @Nullable | ||
| @Override | ||
| public String getJSBundleFile(boolean useDeveloperSupport) { | ||
| return UpdateContext.getBundleUrl(context); | ||
| } | ||
| }); | ||
| return handlers; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "platforms": ["apple", "android"], | ||
| "apple": { | ||
| "modules": ["ExpoPushyModule"], | ||
| "reactDelegateHandlers": ["ExpoPushyReactDelegateHandler"], | ||
| "podspecPath":"react-native-update.podspec" | ||
| }, | ||
| "android": { | ||
| "modules": [ | ||
| "expo.modules.pushy.ExpoPushyModule" | ||
| ] | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import ExpoModulesCore | ||
|
|
||
| public class ExpoPushyModule: Module { | ||
| public func definition() -> ModuleDefinition { | ||
| Name("ExpoPushy") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import ExpoModulesCore | ||
| import react_native_update | ||
|
|
||
| public final class ExpoPushyReactDelegateHandler: ExpoReactDelegateHandler { | ||
| private weak var reactDelegate: ExpoReactDelegate? | ||
|
|
||
| public override func bundleURL(reactDelegate: ExpoReactDelegate) -> URL? { | ||
| return RCTPushy.bundleURL() | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这两个nvmrc文件去掉吧