Skip to content

Commit

Permalink
chore(channel): create package dir
Browse files Browse the repository at this point in the history
  • Loading branch information
mym0404 committed Apr 28, 2024
1 parent 1b3a8e3 commit 7659622
Show file tree
Hide file tree
Showing 21 changed files with 482 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{ "path": "../packages/user" },
{ "path": "../packages/navi" },
{ "path": "../packages/social" },
{ "path": "../packages/channel" },
],
"compilerOptions": {
// Avoid expo-cli auto-generating a tsconfig
Expand Down
20 changes: 20 additions & 0 deletions packages/channel/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2024 MJ Studio
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Empty file added packages/channel/README.md
Empty file.
56 changes: 56 additions & 0 deletions packages/channel/RNCKakaoChannel.podspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
require "json"

package = JSON.parse(File.read(File.join(__dir__, "package.json")))
corePackage = JSON.parse(File.read(File.join(__dir__, "..", "core", "package.json")))
talk_sdk_version = corePackage['sdkVersions']['ios']['talk']

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

Pod::Spec.new do |s|
s.name = "RNCKakaoNavi"
s.version = package["version"]
s.summary = package["description"]
s.homepage = package["homepage"]
s.license = package["license"]
s.authors = package["author"]

s.platforms = { :ios => min_ios_version_supported }
s.source = { :git => "https://github.com/mym0404/react-native-kakao.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,swift}"

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
if respond_to?(:install_modules_dependencies, true)
install_modules_dependencies(s)
else
s.dependency "React-Core"

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
}
s.dependency "React-Codegen"
s.dependency "RCT-Folly"
s.dependency "RCTRequired"
s.dependency "RCTTypeSafety"
s.dependency "ReactCommon/turbomodule/core"
end
end

# Override Version by User
if defined?($KakaoTalkSDKVersion)
Pod::UI.puts "#{s.name}: Using user specified Kakao SDK version '#{$KakaoTalkSDKVersion}'"
talk_sdk_version = $KakaoTalkSDKVersion
end

s.dependency 'RNCKakaoCore'
s.dependency 'RNCKakaoUser'

# Kakao dependencies
s.dependency 'KakaoSDKTalk', talk_sdk_version
end
11 changes: 11 additions & 0 deletions packages/channel/android/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# editorconfig
root = true

[*.{kt,kts}]
ktlint_code_style = ktlint_official
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
119 changes: 119 additions & 0 deletions packages/channel/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
apply from: file('./../../core/android/package-json.gradle')
def Versions = project.ext.RNCKakaoSdkVersions
Project coreProject = project.ext.getWorkspaceProject("core")
Project userProject = project.ext.getWorkspaceProject("user")

buildscript {
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Kakao_kotlinVersion"]

repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.1"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: "com.android.library"
apply plugin: "kotlin-android"

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
return (major == 7 && minor >= 3) || major >= 8
}

android {
if (supportsNamespace()) {
namespace "net.mjstudio.rnkakao.channel"

sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
}

compileSdkVersion Versions.compileSdk

defaultConfig {
minSdkVersion Versions.minSdk
targetSdkVersion Versions.targetSdk
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}

buildFeatures {
buildConfig true
}

buildTypes {
release {
minifyEnabled false
}
}

lintOptions {
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}


sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += [
"src/newarch",
// This is needed to build Kotlin project with NewArch enabled
"${project.buildDir}/generated/source/codegen/java"
]
} else {
java.srcDirs += ["src/oldarch"]
}
}
}
}

repositories {
mavenCentral()
google()
}

dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}"

api coreProject
api userProject
implementation "com.kakao.sdk:v2-talk:${Versions.talk}"
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "RNCKakaoChannel"
codegenJavaPackageName = "net.mjstudio.rnkakao.channel"
}
}
1 change: 1 addition & 0 deletions packages/channel/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Kakao_kotlinVersion=1.7.0
1 change: 1 addition & 0 deletions packages/channel/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<manifest package="net.mjstudio.rnkakao.channel"></manifest>
2 changes: 2 additions & 0 deletions packages/channel/android/src/main/AndroidManifestNew.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package net.mjstudio.rnkakao.channel

import com.facebook.react.bridge.ReactApplicationContext

class RNCKakaoChannelModule internal constructor(context: ReactApplicationContext) :
KakaoChannelSpec(context) {
override fun getName(): String {
return NAME
}

companion object {
const val NAME = "RNCKakaoChannel"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package net.mjstudio.rnkakao.channel

import com.facebook.react.TurboReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.module.model.ReactModuleInfo
import com.facebook.react.module.model.ReactModuleInfoProvider

class RNCKakaoChannelPackage : TurboReactPackage() {
override fun getModule(
name: String,
reactContext: ReactApplicationContext,
): NativeModule? {
return if (name == RNCKakaoChannelModule.NAME) {
RNCKakaoChannelModule(reactContext)
} else {
null
}
}

override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
return ReactModuleInfoProvider {
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
moduleInfos[RNCKakaoChannelModule.NAME] =
ReactModuleInfo(
RNCKakaoChannelModule.NAME,
RNCKakaoChannelModule.NAME,
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
false, // isCxxModule
isTurboModule, // isTurboModule
)
moduleInfos
}
}
}
6 changes: 6 additions & 0 deletions packages/channel/android/src/newarch/KakaoChannelSpec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.mjstudio.rnkakao.channel

import com.facebook.react.bridge.ReactApplicationContext

abstract class KakaoChannelSpec internal constructor(context: ReactApplicationContext) :
NativeKakaoChannelSpec(context)
7 changes: 7 additions & 0 deletions packages/channel/android/src/oldarch/KakaoChannelSpec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package net.mjstudio.rnkakao.channel

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule

abstract class KakaoChannelSpec internal constructor(context: ReactApplicationContext) :
ReactContextBaseJavaModule(context)
11 changes: 11 additions & 0 deletions packages/channel/ios/RNCKakaoChannel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifdef RCT_NEW_ARCH_ENABLED
#import "RNCKakaoChannelSpec.h"

@interface RNCKakaoChannel : NSObject <NativeKakaoChannelSpec>
#else
#import <React/RCTBridgeModule.h>

@interface RNCKakaoChannel : NSObject <RCTBridgeModule>
#endif

@end
20 changes: 20 additions & 0 deletions packages/channel/ios/RNCKakaoChannel.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#import "RNCKakaoChannel.h"
#import "RNCKakaoChannel-Swift.h"

@implementation RNCKakaoChannel

- (RNCKakaoChannelManager*)manager {
return [RNCKakaoChannelManager shared];
}

RCT_EXPORT_MODULE()

// Don't compile this code when we build for the old architecture.
#ifdef RCT_NEW_ARCH_ENABLED
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams&)params {
return std::make_shared<facebook::react::NativeKakaoChannelSpecJSI>(params);
}
#endif

@end
7 changes: 7 additions & 0 deletions packages/channel/ios/RNCKakaoChannelManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Foundation
import React
import RNCKakaoCore

@objc public class RNCKakaoChannelManager: NSObject {
@objc public static let shared = RNCKakaoChannelManager()
}
Loading

0 comments on commit 7659622

Please sign in to comment.