@shopify/react-native-skia 0.1.120 → 0.1.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
    
        package/android/CMakeLists.txt
    CHANGED
    
    | @@ -10,12 +10,20 @@ set (SKIA_SVG_LIB "svg") | |
| 10 10 | 
             
            set (SKIA_SKSHAPER_LIB "skshaper")
         | 
| 11 11 |  | 
| 12 12 | 
             
            set(build_DIR ${CMAKE_SOURCE_DIR}/build)
         | 
| 13 | 
            -
            file | 
| 13 | 
            +
            file(GLOB LIBRN_DIR "${PREBUILT_DIR}/${ANDROID_ABI}")
         | 
| 14 14 | 
             
            file(GLOB libfbjni_link_DIRS "${build_DIR}/fbjni*.aar/jni/${ANDROID_ABI}")
         | 
| 15 15 | 
             
            file(GLOB libfbjni_include_DIRS "${build_DIR}/fbjni-*-headers.jar/")
         | 
| 16 16 |  | 
| 17 17 | 
             
            link_directories(../libs/android/${ANDROID_ABI}/)
         | 
| 18 18 |  | 
| 19 | 
            +
            if(${REACT_NATIVE_VERSION} LESS 66)
         | 
| 20 | 
            +
                    file(
         | 
| 21 | 
            +
                            TO_CMAKE_PATH 
         | 
| 22 | 
            +
                            "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi/jsi/jsi.cpp"
         | 
| 23 | 
            +
                            INCLUDE_JSI_CPP
         | 
| 24 | 
            +
                    )
         | 
| 25 | 
            +
            endif()
         | 
| 26 | 
            +
             | 
| 19 27 | 
             
            add_library(
         | 
| 20 28 | 
             
                    ${PACKAGE_NAME}
         | 
| 21 29 | 
             
                    SHARED
         | 
| @@ -39,16 +47,10 @@ target_include_directories( | |
| 39 47 | 
             
                    PRIVATE
         | 
| 40 48 |  | 
| 41 49 | 
             
                    # When installed in the development environment
         | 
| 42 | 
            -
                    " | 
| 43 | 
            -
                    " | 
| 44 | 
            -
                    " | 
| 45 | 
            -
                    " | 
| 46 | 
            -
             | 
| 47 | 
            -
                    # When installed as a package the paths are a bit different
         | 
| 48 | 
            -
                    "../../../react-native/ReactCommon/callinvoker"
         | 
| 49 | 
            -
                    "../../../react-native/ReactCommon/jsi"
         | 
| 50 | 
            -
                    "../../../react-native/ReactCommon/react/nativemodule/core"
         | 
| 51 | 
            -
                    "../../../react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
         | 
| 50 | 
            +
                    "${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
         | 
| 51 | 
            +
                    "${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
         | 
| 52 | 
            +
                    "${NODE_MODULES_DIR}/react-native/ReactCommon/react/nativemodule/core"
         | 
| 53 | 
            +
                    "${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni"
         | 
| 52 54 |  | 
| 53 55 | 
             
                    cpp/skia/include/config/
         | 
| 54 56 | 
             
                    cpp/skia/include/core/
         | 
| @@ -87,11 +89,23 @@ find_library( | |
| 87 89 | 
             
            )
         | 
| 88 90 |  | 
| 89 91 | 
             
            find_library(
         | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
            )
         | 
| 92 | 
            +
                     JSI_LIB
         | 
| 93 | 
            +
                     jsi
         | 
| 94 | 
            +
                     PATHS ${LIBRN_DIR}
         | 
| 95 | 
            +
                     NO_CMAKE_FIND_ROOT_PATH
         | 
| 96 | 
            +
             )
         | 
| 97 | 
            +
             if(${REACT_NATIVE_VERSION} LESS 66)
         | 
| 98 | 
            +
                     # JSI lib didn't exist on RN 0.65 and before. Simply omit it.
         | 
| 99 | 
            +
                     set (JSI_LIB "")
         | 
| 100 | 
            +
             else()
         | 
| 101 | 
            +
                     # RN 0.66 distributes libjsi.so, can be used instead of compiling jsi.cpp manually.
         | 
| 102 | 
            +
                     find_library(
         | 
| 103 | 
            +
                             JSI_LIB
         | 
| 104 | 
            +
                             jsi
         | 
| 105 | 
            +
                             PATHS ${LIBRN_DIR}
         | 
| 106 | 
            +
                             NO_CMAKE_FIND_ROOT_PATH
         | 
| 107 | 
            +
                     )
         | 
| 108 | 
            +
             endif()
         | 
| 95 109 |  | 
| 96 110 | 
             
            find_library(
         | 
| 97 111 | 
             
                    REACT_LIB
         | 
    
        package/android/build.gradle
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            import java.nio.file.Paths
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            // android/build.gradle
         | 
| 2 4 |  | 
| 3 5 | 
             
            // based on:
         | 
| @@ -26,6 +28,60 @@ def safeExtGet(prop, fallback) { | |
| 26 28 |  | 
| 27 29 | 
             
            apply plugin: 'com.android.library'
         | 
| 28 30 |  | 
| 31 | 
            +
            static def findNodeModules(baseDir) {
         | 
| 32 | 
            +
              def basePath = baseDir.toPath().normalize()
         | 
| 33 | 
            +
              // Node's module resolution algorithm searches up to the root directory,
         | 
| 34 | 
            +
              // after which the base path will be null
         | 
| 35 | 
            +
              while (basePath) {
         | 
| 36 | 
            +
                def nodeModulesPath = Paths.get(basePath.toString(), "node_modules")
         | 
| 37 | 
            +
                def reactNativePath = Paths.get(nodeModulesPath.toString(), "react-native")
         | 
| 38 | 
            +
                if (nodeModulesPath.toFile().exists() && reactNativePath.toFile().exists()) {
         | 
| 39 | 
            +
                  return nodeModulesPath.toString()
         | 
| 40 | 
            +
                }
         | 
| 41 | 
            +
                basePath = basePath.getParent()
         | 
| 42 | 
            +
              }
         | 
| 43 | 
            +
              throw new GradleException("React-Native-Skia: Failed to find node_modules/ path!")
         | 
| 44 | 
            +
            }
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            def nodeModules = findNodeModules(projectDir)
         | 
| 47 | 
            +
            logger.warn("react-native-skia: node_modules/ found at: ${nodeModules}")
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            def sourceBuild = false
         | 
| 50 | 
            +
            def defaultDir = null
         | 
| 51 | 
            +
            def androidSourcesDir = null
         | 
| 52 | 
            +
            def androidSourcesName = 'React Native sources'
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            if (rootProject.ext.has('reactNativeAndroidRoot')) {
         | 
| 55 | 
            +
              defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
         | 
| 56 | 
            +
              androidSourcesDir = defaultDir.parentFile.toString()
         | 
| 57 | 
            +
            } else if (findProject(':ReactAndroid') != null) {
         | 
| 58 | 
            +
                sourceBuild = true
         | 
| 59 | 
            +
                defaultDir = project(':ReactAndroid').projectDir
         | 
| 60 | 
            +
                androidSourcesDir = defaultDir.parentFile.toString()
         | 
| 61 | 
            +
            } else {
         | 
| 62 | 
            +
              defaultDir = file("$nodeModules/react-native/android")
         | 
| 63 | 
            +
              androidSourcesDir = defaultDir.parentFile.toString()
         | 
| 64 | 
            +
            }
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            if (!defaultDir.exists()) {
         | 
| 67 | 
            +
                throw new GradleException(
         | 
| 68 | 
            +
                  "${project.name}: React Native android directory (node_modules/react-native/android) does not exist! Resolved node_modules to: ${nodeModules}"
         | 
| 69 | 
            +
                )
         | 
| 70 | 
            +
            }
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            def prebuiltDir = sourceBuild
         | 
| 73 | 
            +
                ? "$nodeModules/react-native/ReactAndroid/src/main/jni/prebuilt/lib"
         | 
| 74 | 
            +
                : "$buildDir/react-native-0*/jni"
         | 
| 75 | 
            +
             | 
| 76 | 
            +
             | 
| 77 | 
            +
            def reactProperties = new Properties()
         | 
| 78 | 
            +
            file("$nodeModules/react-native/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }
         | 
| 79 | 
            +
            def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME").split("\\.")[1].toInteger()
         | 
| 80 | 
            +
             | 
| 81 | 
            +
            logger.warn("react-native-skia: React Native version: ${REACT_NATIVE_VERSION}")
         | 
| 82 | 
            +
            logger.warn("react-native-skia: Is Source build: ${sourceBuild}")
         | 
| 83 | 
            +
            logger.warn("react-native-skia: Prebuilt dir: ${prebuiltDir}")
         | 
| 84 | 
            +
             | 
| 29 85 | 
             
            buildscript {
         | 
| 30 86 | 
             
                // The Android Gradle plugin is only required when opening the android folder stand-alone.
         | 
| 31 87 | 
             
                // This avoids unnecessary downloads and potential conflicts when the library is included as a
         | 
| @@ -56,7 +112,10 @@ android { | |
| 56 112 | 
             
                        cmake {
         | 
| 57 113 | 
             
                            cppFlags "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID"
         | 
| 58 114 | 
             
                            abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
         | 
| 59 | 
            -
                            arguments '-DANDROID_STL=c++_shared'
         | 
| 115 | 
            +
                            arguments '-DANDROID_STL=c++_shared',
         | 
| 116 | 
            +
                                      "-DREACT_NATIVE_VERSION=${REACT_NATIVE_VERSION}",
         | 
| 117 | 
            +
                                      "-DNODE_MODULES_DIR=${nodeModules}",
         | 
| 118 | 
            +
                                      "-DPREBUILT_DIR=${prebuiltDir}"
         | 
| 60 119 | 
             
                        }
         | 
| 61 120 | 
             
                    }
         | 
| 62 121 | 
             
                }
         | 
| @@ -72,7 +131,13 @@ android { | |
| 72 131 | 
             
                }
         | 
| 73 132 |  | 
| 74 133 | 
             
                packagingOptions {
         | 
| 75 | 
            -
                    excludes = [ | 
| 134 | 
            +
                    excludes = [
         | 
| 135 | 
            +
                         "**/libc++_shared.so",
         | 
| 136 | 
            +
                         "**/libfbjni.so",
         | 
| 137 | 
            +
                         "**/libjsi.so",
         | 
| 138 | 
            +
                         "**/libreact_nativemodule_core.so",
         | 
| 139 | 
            +
                         "**/libturbomodulejsijni.so"
         | 
| 140 | 
            +
                    ]
         | 
| 76 141 | 
             
                }
         | 
| 77 142 |  | 
| 78 143 |  | 
| @@ -114,33 +179,6 @@ dependencies { | |
| 114 179 | 
             
                extractJNI(files(rnAAR))
         | 
| 115 180 | 
             
            }
         | 
| 116 181 |  | 
| 117 | 
            -
            def configureReactNativePom(def pom) {
         | 
| 118 | 
            -
                def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
         | 
| 119 | 
            -
             | 
| 120 | 
            -
                pom.project {
         | 
| 121 | 
            -
                    name packageJson.title
         | 
| 122 | 
            -
                    artifactId packageJson.name
         | 
| 123 | 
            -
                    version = packageJson.version
         | 
| 124 | 
            -
                    group = "com.shopify.reactnative.skia"
         | 
| 125 | 
            -
                    description packageJson.description
         | 
| 126 | 
            -
                    url packageJson.repository.baseUrl
         | 
| 127 | 
            -
             | 
| 128 | 
            -
                    licenses {
         | 
| 129 | 
            -
                        license {
         | 
| 130 | 
            -
                            name packageJson.license
         | 
| 131 | 
            -
                            url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
         | 
| 132 | 
            -
                            distribution 'repo'
         | 
| 133 | 
            -
                        }
         | 
| 134 | 
            -
                    }
         | 
| 135 | 
            -
             | 
| 136 | 
            -
                    developers {
         | 
| 137 | 
            -
                        developer {
         | 
| 138 | 
            -
                            name packageJson.author
         | 
| 139 | 
            -
                        }
         | 
| 140 | 
            -
                    }
         | 
| 141 | 
            -
                }
         | 
| 142 | 
            -
            }
         | 
| 143 | 
            -
             | 
| 144 182 | 
             
            afterEvaluate { project ->
         | 
| 145 183 | 
             
                task androidSourcesJar(type: Jar) {
         | 
| 146 184 | 
             
                    classifier = 'sources'
         | 
| @@ -188,9 +226,18 @@ task extractJNIFiles { | |
| 188 226 | 
             
                }
         | 
| 189 227 | 
             
            }
         | 
| 190 228 |  | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 229 | 
            +
            extractJNIFiles.mustRunAfter extractAARHeaders
         | 
| 230 | 
            +
             | 
| 231 | 
            +
            def nativeBuildDependsOn(dependsOnTask, variant) {
         | 
| 232 | 
            +
              def buildTasks = tasks.findAll({ task ->
         | 
| 233 | 
            +
                  !task.name.contains("Clean") && (task.name.contains("externalNative") || task.name.contains("CMake")) })
         | 
| 234 | 
            +
              if (variant != null) {
         | 
| 235 | 
            +
                buildTasks = buildTasks.findAll({ task -> task.name.contains(variant) })
         | 
| 236 | 
            +
              }
         | 
| 237 | 
            +
              buildTasks.forEach { task -> task.dependsOn(dependsOnTask) }
         | 
| 196 238 | 
             
            }
         | 
| 239 | 
            +
             | 
| 240 | 
            +
            afterEvaluate {
         | 
| 241 | 
            +
              nativeBuildDependsOn(extractAARHeaders, null)
         | 
| 242 | 
            +
              nativeBuildDependsOn(extractJNIFiles, null)  
         | 
| 243 | 
            +
            }
         | 
| @@ -66,7 +66,7 @@ public class PlatformContext { | |
| 66 66 | 
             
                    Choreographer.getInstance().postFrameCallback(frameCallback);
         | 
| 67 67 | 
             
                }
         | 
| 68 68 |  | 
| 69 | 
            -
                public void raise(String message) {
         | 
| 69 | 
            +
                public void raise(final String message) {
         | 
| 70 70 | 
             
                    new Handler(Looper.getMainLooper()).post(new Runnable() {
         | 
| 71 71 | 
             
                        @Override
         | 
| 72 72 | 
             
                        public void run() {
         |