diff --git a/.dockerignore b/.dockerignore --- a/.dockerignore +++ b/.dockerignore @@ -19,6 +19,7 @@ !native/cpp/CommonCpp/grpc !native/expo-modules/android-lifecycle/package.json !native/expo-modules/aes-crypto/package.json +!native/expo-modules/comm-expo-package/package.json !native/expo-modules/thumbhash/package.json web/node_modules diff --git a/keyserver/Dockerfile b/keyserver/Dockerfile --- a/keyserver/Dockerfile +++ b/keyserver/Dockerfile @@ -126,6 +126,8 @@ native/expo-modules/android-lifecycle/ COPY --chown=comm native/expo-modules/aes-crypto/package.json \ native/expo-modules/aes-crypto/ +COPY --chown=comm native/expo-modules/comm-expo-package/package.json \ + native/expo-modules/comm-expo-package/ COPY --chown=comm native/expo-modules/thumbhash/package.json \ native/expo-modules/thumbhash/ COPY --chown=comm services/electron-update-server/package.json \ diff --git a/native/expo-modules/comm-expo-package/android/build.gradle b/native/expo-modules/comm-expo-package/android/build.gradle new file mode 100644 --- /dev/null +++ b/native/expo-modules/comm-expo-package/android/build.gradle @@ -0,0 +1,92 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'maven-publish' + +group = 'app.comm.android.expo' +version = '0.0.1' + +buildscript { + def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle") + if (expoModulesCorePlugin.exists()) { + apply from: expoModulesCorePlugin + applyKotlinExpoModulesCorePlugin() + } + + // Simple helper that allows the root project to override versions declared by this library. + ext.safeExtGet = { prop, fallback -> + rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback + } + + // Ensures backward compatibility + ext.getKotlinVersion = { + if (ext.has("kotlinVersion")) { + ext.kotlinVersion() + } else { + ext.safeExtGet("kotlinVersion", "1.6.10") + } + } + + repositories { + mavenCentral() + } + + dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}") + } +} + +// Creating sources with comments +task androidSourcesJar(type: Jar) { + classifier = 'sources' + from android.sourceSets.main.java.srcDirs +} + +afterEvaluate { + publishing { + publications { + release(MavenPublication) { + from components.release + // Add additional sourcesJar to artifacts + artifact(androidSourcesJar) + } + } + repositories { + maven { + url = mavenLocal().url + } + } + } +} + +android { + compileSdkVersion safeExtGet("compileSdkVersion", 33) + + compileOptions { + sourceCompatibility JavaVersion.VERSION_11 + targetCompatibility JavaVersion.VERSION_11 + } + + kotlinOptions { + jvmTarget = JavaVersion.VERSION_11.majorVersion + } + + defaultConfig { + minSdkVersion safeExtGet("minSdkVersion", 21) + targetSdkVersion safeExtGet("targetSdkVersion", 33) + versionCode 1 + versionName "0.1.0" + } + lintOptions { + abortOnError false + } +} + +repositories { + mavenCentral() +} + +dependencies { + implementation project(':expo-modules-core') + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}" + implementation 'com.facebook.react:react-native:+' +} diff --git a/native/expo-modules/comm-expo-package/android/src/main/AndroidManifest.xml b/native/expo-modules/comm-expo-package/android/src/main/AndroidManifest.xml new file mode 100644 --- /dev/null +++ b/native/expo-modules/comm-expo-package/android/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/expo/HelloWorldModule.kt b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/expo/HelloWorldModule.kt new file mode 100644 --- /dev/null +++ b/native/expo-modules/comm-expo-package/android/src/main/java/app/comm/android/expo/HelloWorldModule.kt @@ -0,0 +1,15 @@ +package app.comm.android.expo + +import expo.modules.kotlin.modules.Module +import expo.modules.kotlin.modules.ModuleDefinition + +class HelloWorldModule : Module() { + override fun definition() = ModuleDefinition { + Name("HelloWorld") + + Function("sayHello") { + "hello" + } + } +} + diff --git a/native/expo-modules/comm-expo-package/expo-module.config.json b/native/expo-modules/comm-expo-package/expo-module.config.json new file mode 100644 --- /dev/null +++ b/native/expo-modules/comm-expo-package/expo-module.config.json @@ -0,0 +1,9 @@ +{ + "platforms": ["ios", "android"], + "ios": { + "modules": ["HelloWorldModule"] + }, + "android": { + "modules": ["app.comm.android.expo.HelloWorldModule"] + } +} diff --git a/native/expo-modules/comm-expo-package/ios/CommExpoPackage.podspec b/native/expo-modules/comm-expo-package/ios/CommExpoPackage.podspec new file mode 100644 --- /dev/null +++ b/native/expo-modules/comm-expo-package/ios/CommExpoPackage.podspec @@ -0,0 +1,27 @@ +require 'json' + +package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json'))) + +Pod::Spec.new do |s| + s.name = 'CommExpoPackage' + s.version = package['version'] + s.summary = package['description'] + s.description = package['description'] + s.license = package['license'] + s.author = 'Comm' + s.homepage = 'https://comm.app' + s.platform = :ios, '13.0' + s.swift_version = '5.4' + s.source = { git: 'https://github.com/CommE2E/comm' } + s.static_framework = true + + s.dependency 'ExpoModulesCore' + + # Swift/Objective-C compatibility + s.pod_target_xcconfig = { + 'DEFINES_MODULE' => 'YES', + 'SWIFT_COMPILATION_MODE' => 'wholemodule' + } + + s.source_files = "**/*.{h,m,swift}" +end diff --git a/native/expo-modules/comm-expo-package/ios/HelloWorldModule.swift b/native/expo-modules/comm-expo-package/ios/HelloWorldModule.swift new file mode 100644 --- /dev/null +++ b/native/expo-modules/comm-expo-package/ios/HelloWorldModule.swift @@ -0,0 +1,12 @@ +import ExpoModulesCore + +public class HelloWorldModule: Module { + public func definition() -> ModuleDefinition { + Name("HelloWorld") + + Function("sayHello") { () -> String in + "Hello" + } + } +} + diff --git a/native/expo-modules/comm-expo-package/package.json b/native/expo-modules/comm-expo-package/package.json new file mode 100644 --- /dev/null +++ b/native/expo-modules/comm-expo-package/package.json @@ -0,0 +1,17 @@ +{ + "name": "@commapp/expo-package", + "version": "0.0.1", + "private": true, + "license": "BSD-3-Clause", + "description": "Expo modules for Comm App", + "dependencies": {}, + "devDependencies": { + "expo-module-scripts": "^3.0.3", + "expo-modules-core": "1.1.1" + }, + "peerDependencies": { + "expo": "*", + "react": "*", + "react-native": "*" + } +} diff --git a/native/ios/Podfile.lock b/native/ios/Podfile.lock --- a/native/ios/Podfile.lock +++ b/native/ios/Podfile.lock @@ -2,6 +2,8 @@ - AESCrypto (0.0.1): - ExpoModulesCore - boost (1.76.0) + - CommExpoPackage (0.0.1): + - ExpoModulesCore - DoubleConversion (1.1.6) - DVAssetLoaderDelegate (0.3.3) - EXApplication (5.1.1): @@ -568,6 +570,7 @@ DEPENDENCIES: - AESCrypto (from `../expo-modules/aes-crypto/ios`) - boost (from `../../node_modules/react-native/third-party-podspecs/boost.podspec`) + - CommExpoPackage (from `../expo-modules/comm-expo-package/ios`) - DoubleConversion (from `../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`) - EXApplication (from `../../node_modules/expo-application/ios`) - EXConstants (from `../../node_modules/expo-constants/ios`) @@ -676,6 +679,8 @@ :path: "../expo-modules/aes-crypto/ios" boost: :podspec: "../../node_modules/react-native/third-party-podspecs/boost.podspec" + CommExpoPackage: + :path: "../expo-modules/comm-expo-package/ios" DoubleConversion: :podspec: "../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec" EXApplication: @@ -844,6 +849,7 @@ SPEC CHECKSUMS: AESCrypto: 3f397599b6b8e66c3b8a16e09bed17e6ad03482d boost: a7c83b31436843459a1961bfd74b96033dc77234 + CommExpoPackage: 3f9d8a25537fb9d80f79a63fd1e73c51f55b87e9 DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 DVAssetLoaderDelegate: 0caec20e4e08b8560b691131539e9180024d4bce EXApplication: d8f53a7eee90a870a75656280e8d4b85726ea903 diff --git a/native/package.json b/native/package.json --- a/native/package.json +++ b/native/package.json @@ -51,6 +51,7 @@ "dependencies": { "@commapp/android-lifecycle": "0.0.1", "@commapp/aes-crypto": "0.0.1", + "@commapp/expo-package": "0.0.1", "@commapp/sqlcipher-amalgamation": "^4.4.3-a", "@commapp/thumbhash": "0.0.1", "@ethersproject/shims": "^5.7.0", diff --git a/package.json b/package.json --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "keyserver/addons/rust-node-addon", "native/expo-modules/android-lifecycle", "native/expo-modules/aes-crypto", + "native/expo-modules/comm-expo-package", "native/expo-modules/thumbhash", "services/electron-update-server", "web/opaque-ke-wasm"