Skip to content

RN Turbo/Fabric migration #88

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

Merged
merged 34 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ad63dd5
feat: init fabric view + full new architecture support
ian-wd Dec 9, 2024
2508005
chore: bump builder-bob to `v0.36.x`
ian-wd Feb 5, 2025
bd02adb
fix: android build failure
ian-wd Feb 5, 2025
bca8c2c
fix: android fontColor crash
ian-wd Feb 5, 2025
076baa0
chore: cleanup tsconfig copy
ian-wd Feb 5, 2025
564a87e
chore: fix lint errors on App.tsx
ian-wd Feb 5, 2025
0927006
refactor: introduce `eventType` to properly handle onChange event types
ian-wd Mar 6, 2025
0ce2cb1
fix: iOS `addPath` command crashing app and add local images
ian-wd Mar 6, 2025
efad6f0
chore: update tsc npm command to not emit
ian-wd Mar 12, 2025
8d0e006
fix: cleanup unused RNSketchCanvasManager file
ian-wd Mar 12, 2025
48e6478
chore: update workflow to yarn3
ian-wd Mar 12, 2025
af1a30c
chore: fix lint errors
ian-wd Mar 12, 2025
0e06082
chore: fix typescript workflow
ian-wd Mar 12, 2025
7cd2daa
chore: bump to RN v0.76.7
ian-wd Mar 12, 2025
ffd2ea1
chore: fix prepare build workflow
ian-wd Mar 12, 2025
7b83b99
fix: iOS view cleanup not properly working
ian-wd Mar 17, 2025
a93d0ba
chore: cleanup unnecessary logs and variables
ian-wd Mar 17, 2025
3e3534a
chore: bump ios pod to RN 0.76.7
ian-wd Mar 17, 2025
8c1e809
chore: migrate publish workflow to yarn3
ian-wd Mar 17, 2025
e25ffc9
chore: go back npm
ian-wd Mar 20, 2025
7de3dd4
chore: fix missing `typescript` npm command
ian-wd Mar 20, 2025
22621b9
feat: disable codegenConfig `includesGeneratedCode` flag
ian-wd Mar 24, 2025
717df3a
chore: remove "codegen" target from builder-bob
ian-wd Mar 24, 2025
e67a63f
fix: iOS not exporting view properties
ian-wd Mar 24, 2025
534ba8e
fix: fabric recycled view referencing stale values
ian-wd Mar 24, 2025
3e906d2
fix: iOS not sending base64 event
ian-wd Mar 26, 2025
ebcbed8
docs: update README and add `getBase64` to types
ian-wd Mar 26, 2025
5e9fd8e
fix: sketch canvas constants not working
ian-wd Mar 26, 2025
60d9cdd
chore: add types to package.json
ian-wd Mar 26, 2025
8d62c2a
test: properly mock turbo module and add instructions to README
ian-wd Mar 27, 2025
9eb9682
fix: iOS props not applied if same view is unmounted and remounted
ian-wd Apr 1, 2025
e2a5858
chore: remove .env.local
iBotPeaches Apr 1, 2025
c666918
chore: newline
iBotPeaches Apr 1, 2025
e9e211b
chore: newline
iBotPeaches Apr 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*]

indent_style = space
indent_size = 2

end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

19 changes: 0 additions & 19 deletions .eslintrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.pbxproj -text
# specific for windows script files
*.bat text eol=crlf
24 changes: 12 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ DerivedData
*.hmap
*.ipa
*.xcuserstate
example/ios/.xcode.env.local
project.xcworkspace
**/.xcode.env.local

# Android/IJ
#
Expand All @@ -54,27 +54,27 @@ node_modules/
npm-debug.log
yarn-debug.log
yarn-error.log
coverage/

# BUCK
buck-out/
\.buckd/
android/app/libs
android/keystores/debug.keystore

# Yarn
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Turborepo
.turbo/

# generated by bob
lib/

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
# React Native Codegen
ios/generated
android/generated
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
365 changes: 228 additions & 137 deletions README.md

Large diffs are not rendered by default.

53 changes: 40 additions & 13 deletions RNSketchCanvas.podspec
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
require 'json'
require "json"

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
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 = 'RNSketchCanvas'
s.version = package['version']
s.summary = package['description']
s.homepage = 'https://github.com/sourcetoad/react-native-sketch-canvas'
s.license = package['license']
s.authors = package['author']
s.source = { :git => package['repository']['url'] }
s.resource_bundles = { 'RNSketchCanvas_PrivacyInfo' => 'ios/RNSketchCanvas/PrivacyInfo.xcprivacy' }
s.platform = :ios, '8.0'
s.source_files = 'ios/**/*.{h,m}'
s.dependency 'React'
s.name = "RNSketchCanvas"
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/sourcetoad/react-native-sketch-canvas", :tag => "#{s.version}" }
s.resource_bundles = { 'RNSketchCanvas_PrivacyInfo' => 'ios/PrivacyInfo.xcprivacy' }

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

# 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-RCTFabric"
s.dependency "React-Codegen"
s.dependency "RCT-Folly"
s.dependency "RCTRequired"
s.dependency "RCTTypeSafety"
s.dependency "ReactCommon/turbomodule/core"
end
end
end

5 changes: 0 additions & 5 deletions android/.gitignore

This file was deleted.

122 changes: 108 additions & 14 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,29 +1,123 @@
apply plugin: 'com.android.library'
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["RNTSketchCanvas_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 reactNativeArchitectures() {
def value = rootProject.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

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 getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNTSketchCanvas_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNSketchCanvas_" + name]).toInteger()
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNTSketchCanvas_" + name]).toInteger()
}

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 {
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
if (supportsNamespace()) {
namespace "com.sourcetoad.reactnativesketchcanvas"

defaultConfig {
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
versionCode 1
versionName "1.0"
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
lintOptions {
abortOnError false
}

compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
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 += [
"generated/java",
"generated/jni"
]
}
}
}
}

repositories {
mavenCentral()
google()
mavenCentral()
google()
}

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
// 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:$kotlin_version"
implementation 'androidx.exifinterface:exifinterface:1.3.6'
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "RNTSketchCanvasView"
codegenJavaPackageName = "com.sourcetoad.reactnativesketchcanvas"
}
}
8 changes: 5 additions & 3 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
RNSketchCanvas_minSdkVersion=16
RNSketchCanvas_targetSdkVersion=27
RNSketchCanvas_compileSdkVersion=27
RNTSketchCanvas_kotlinVersion=1.7.0
RNTSketchCanvas_minSdkVersion=21
RNTSketchCanvas_targetSdkVersion=31
RNTSketchCanvas_compileSdkVersion=31
RNTSketchCanvas_ndkversion=21.4.7075529
5 changes: 2 additions & 3 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.terrylinla.rnsketchcanvas">

</manifest>
package="com.sourcetoad.reactnativesketchcanvas">
</manifest>
2 changes: 2 additions & 0 deletions 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>
Loading