Skip to content

Commit 66c1880

Browse files
ian-wdiBotPeaches
andauthored
React Native Turbo/Fabric migration (#88)
* feat: init fabric view + full new architecture support * chore: bump builder-bob to `v0.36.x` * fix: android build failure * fix: android fontColor crash * chore: cleanup tsconfig copy * chore: fix lint errors on App.tsx * refactor: introduce `eventType` to properly handle onChange event types * fix: iOS `addPath` command crashing app and add local images * chore: update tsc npm command to not emit * fix: cleanup unused RNSketchCanvasManager file * chore: update workflow to yarn3 * chore: fix lint errors * chore: fix typescript workflow * chore: bump to RN v0.76.7 * chore: fix prepare build workflow * fix: iOS view cleanup not properly working * chore: cleanup unnecessary logs and variables * chore: bump ios pod to RN 0.76.7 * chore: migrate publish workflow to yarn3 * chore: go back npm * chore: fix missing `typescript` npm command * feat: disable codegenConfig `includesGeneratedCode` flag * chore: remove "codegen" target from builder-bob * fix: iOS not exporting view properties * fix: fabric recycled view referencing stale values * fix: iOS not sending base64 event * docs: update README and add `getBase64` to types * fix: sketch canvas constants not working * chore: add types to package.json * test: properly mock turbo module and add instructions to README * fix: iOS props not applied if same view is unmounted and remounted * chore: remove .env.local * chore: newline * chore: newline --------- Co-authored-by: Connor Tumbleson <[email protected]>
1 parent 5605d93 commit 66c1880

File tree

128 files changed

+15665
-27298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+15665
-27298
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
indent_style = space
10+
indent_size = 2
11+
12+
end_of_line = lf
13+
charset = utf-8
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true

.eslintignore

-3
This file was deleted.

.eslintrc.js

-19
This file was deleted.

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pbxproj -text
2+
# specific for windows script files
3+
*.bat text eol=crlf

.gitignore

+12-12
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ DerivedData
2727
*.hmap
2828
*.ipa
2929
*.xcuserstate
30-
example/ios/.xcode.env.local
3130
project.xcworkspace
31+
**/.xcode.env.local
3232

3333
# Android/IJ
3434
#
@@ -54,27 +54,27 @@ node_modules/
5454
npm-debug.log
5555
yarn-debug.log
5656
yarn-error.log
57-
coverage/
5857

5958
# BUCK
6059
buck-out/
6160
\.buckd/
6261
android/app/libs
6362
android/keystores/debug.keystore
6463

64+
# Yarn
65+
.yarn/*
66+
!.yarn/patches
67+
!.yarn/plugins
68+
!.yarn/releases
69+
!.yarn/sdks
70+
!.yarn/versions
71+
6572
# Turborepo
6673
.turbo/
6774

6875
# generated by bob
6976
lib/
7077

71-
# fastlane
72-
#
73-
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
74-
# screenshots whenever they are needed.
75-
# For more information about the recommended setup visit:
76-
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
77-
78-
fastlane/report.xml
79-
fastlane/Preview.html
80-
fastlane/screenshots
78+
# React Native Codegen
79+
ios/generated
80+
android/generated

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18

.prettierrc.js

-7
This file was deleted.

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

+228-137
Large diffs are not rendered by default.

RNSketchCanvas.podspec

+40-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,44 @@
1-
require 'json'
1+
require "json"
22

3-
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
3+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
45

56
Pod::Spec.new do |s|
6-
s.name = 'RNSketchCanvas'
7-
s.version = package['version']
8-
s.summary = package['description']
9-
s.homepage = 'https://github.com/sourcetoad/react-native-sketch-canvas'
10-
s.license = package['license']
11-
s.authors = package['author']
12-
s.source = { :git => package['repository']['url'] }
13-
s.resource_bundles = { 'RNSketchCanvas_PrivacyInfo' => 'ios/RNSketchCanvas/PrivacyInfo.xcprivacy' }
14-
s.platform = :ios, '8.0'
15-
s.source_files = 'ios/**/*.{h,m}'
16-
s.dependency 'React'
7+
s.name = "RNSketchCanvas"
8+
s.version = package["version"]
9+
s.summary = package["description"]
10+
s.homepage = package["homepage"]
11+
s.license = package["license"]
12+
s.authors = package["author"]
13+
14+
s.platforms = { :ios => min_ios_version_supported }
15+
s.source = { :git => "https://github.com/sourcetoad/react-native-sketch-canvas", :tag => "#{s.version}" }
16+
s.resource_bundles = { 'RNSketchCanvas_PrivacyInfo' => 'ios/PrivacyInfo.xcprivacy' }
17+
18+
s.source_files = "ios/**/*.{h,m,mm,cpp}"
19+
20+
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
21+
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
22+
if respond_to?(:install_modules_dependencies, true)
23+
install_modules_dependencies(s)
24+
else
25+
s.dependency "React-Core"
26+
27+
# Don't install the dependencies when we run `pod install` in the old architecture.
28+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
29+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
30+
s.pod_target_xcconfig = {
31+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
32+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
33+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
34+
}
35+
s.dependency "React-RCTFabric"
36+
s.dependency "React-Codegen"
37+
s.dependency "RCT-Folly"
38+
s.dependency "RCTRequired"
39+
s.dependency "RCTTypeSafety"
40+
s.dependency "ReactCommon/turbomodule/core"
41+
end
42+
end
1743
end
44+

android/.gitignore

-5
This file was deleted.

android/build.gradle

+108-14
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,123 @@
1-
apply plugin: 'com.android.library'
1+
buildscript {
2+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["RNTSketchCanvas_kotlinVersion"]
4+
5+
repositories {
6+
google()
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
classpath "com.android.tools.build:gradle:7.2.1"
12+
// noinspection DifferentKotlinGradleVersion
13+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14+
}
15+
}
16+
17+
def reactNativeArchitectures() {
18+
def value = rootProject.getProperties().get("reactNativeArchitectures")
19+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20+
}
21+
22+
def isNewArchitectureEnabled() {
23+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
24+
}
25+
26+
apply plugin: "com.android.library"
27+
apply plugin: "kotlin-android"
28+
29+
if (isNewArchitectureEnabled()) {
30+
apply plugin: "com.facebook.react"
31+
}
32+
33+
def getExtOrDefault(name) {
34+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["RNTSketchCanvas_" + name]
35+
}
236

337
def getExtOrIntegerDefault(name) {
4-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNSketchCanvas_" + name]).toInteger()
38+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["RNTSketchCanvas_" + name]).toInteger()
39+
}
40+
41+
def supportsNamespace() {
42+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
43+
def major = parsed[0].toInteger()
44+
def minor = parsed[1].toInteger()
45+
46+
// Namespace support was added in 7.3.0
47+
return (major == 7 && minor >= 3) || major >= 8
548
}
649

750
android {
8-
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
51+
if (supportsNamespace()) {
52+
namespace "com.sourcetoad.reactnativesketchcanvas"
953

10-
defaultConfig {
11-
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
12-
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
13-
versionCode 1
14-
versionName "1.0"
54+
sourceSets {
55+
main {
56+
manifest.srcFile "src/main/AndroidManifestNew.xml"
57+
}
1558
}
16-
lintOptions {
17-
abortOnError false
59+
}
60+
61+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
62+
63+
defaultConfig {
64+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
65+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
66+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
67+
68+
}
69+
70+
buildFeatures {
71+
buildConfig true
72+
}
73+
74+
buildTypes {
75+
release {
76+
minifyEnabled false
1877
}
78+
}
79+
80+
lintOptions {
81+
disable "GradleCompatible"
82+
}
83+
84+
compileOptions {
85+
sourceCompatibility JavaVersion.VERSION_1_8
86+
targetCompatibility JavaVersion.VERSION_1_8
87+
}
88+
89+
sourceSets {
90+
main {
91+
if (isNewArchitectureEnabled()) {
92+
java.srcDirs += [
93+
"generated/java",
94+
"generated/jni"
95+
]
96+
}
97+
}
98+
}
1999
}
20100

21101
repositories {
22-
mavenCentral()
23-
google()
102+
mavenCentral()
103+
google()
24104
}
25105

106+
def kotlin_version = getExtOrDefault("kotlinVersion")
107+
26108
dependencies {
27-
//noinspection GradleDynamicVersion
28-
implementation "com.facebook.react:react-native:+"
109+
// For < 0.71, this will be from the local maven repo
110+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
111+
//noinspection GradleDynamicVersion
112+
implementation "com.facebook.react:react-native:+"
113+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
114+
implementation 'androidx.exifinterface:exifinterface:1.3.6'
115+
}
116+
117+
if (isNewArchitectureEnabled()) {
118+
react {
119+
jsRootDir = file("../src/")
120+
libraryName = "RNTSketchCanvasView"
121+
codegenJavaPackageName = "com.sourcetoad.reactnativesketchcanvas"
122+
}
29123
}

android/gradle.properties

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
RNSketchCanvas_minSdkVersion=16
2-
RNSketchCanvas_targetSdkVersion=27
3-
RNSketchCanvas_compileSdkVersion=27
1+
RNTSketchCanvas_kotlinVersion=1.7.0
2+
RNTSketchCanvas_minSdkVersion=21
3+
RNTSketchCanvas_targetSdkVersion=31
4+
RNTSketchCanvas_compileSdkVersion=31
5+
RNTSketchCanvas_ndkversion=21.4.7075529

android/src/main/AndroidManifest.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="com.terrylinla.rnsketchcanvas">
3-
4-
</manifest>
2+
package="com.sourcetoad.reactnativesketchcanvas">
3+
</manifest>
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
</manifest>

0 commit comments

Comments
 (0)