diff --git a/android/build.gradle b/android/build.gradle index 016d0340..9abcc007 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,3 @@ -import groovy.json.JsonSlurper - // android/build.gradle // based on: // @@ -10,7 +8,7 @@ import groovy.json.JsonSlurper // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle // original location: // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle -def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2' +def DEFAULT_BUILD_TOOLS_VERSION = '34.0.0' def safeExtGet(prop, fallback) { rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback } @@ -18,7 +16,7 @@ apply plugin: 'com.android.library' // apply plugin: 'maven' apply plugin: "kotlin-android" buildscript { - ext.kotlin_version = '1.6.10' + ext.kotlin_version = '1.8.20' // The Android Gradle plugin is only required when opening the android folder stand-alone. // This avoids unnecessary downloads and potential conflicts when the library is included as a // module dependency in an application project. @@ -29,13 +27,13 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.4' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } } android { - compileSdkVersion 33 + compileSdkVersion 34 buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) defaultConfig { minSdkVersion 22 @@ -44,28 +42,32 @@ android { versionName "1.0" } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 coreLibraryDesugaringEnabled true } lintOptions { abortOnError false } - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() - } - dexOptions { - javaMaxHeapSize "4g" - } buildFeatures { viewBinding true } + + flavorDimensions "store" + productFlavors { + amazon { + dimension "store" + } + + play { + dimension "store" + } + } } repositories { mavenCentral() // ref: https://www.baeldung.com/maven-local-repository mavenLocal() maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } + maven { url("https://packages.namiml.com/NamiSDK/Android/") } maven { url 'https://jitpack.io' } maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm @@ -83,35 +85,12 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'com.github.jeziellago:compose-markdown:0.3.0' - compileOnly "com.namiml:sdk-amazon:3.2.0-beta.01" + playImplementation "com.namiml:sdk-android:3.2.1-beta.02" + amazonImplementation "com.namiml:sdk-amazon:3.2.1-beta.02" - implementation 'com.facebook.react:react-native:+' // From node_modules + implementation "com.facebook.react:react-native:+" // From node_modules coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" -} -def configureReactNativePom(def pom) { - def packageJson = new JsonSlurper().parseText(file('../package.json').text) - pom.project { - name packageJson.title - artifactId packageJson.name - version = packageJson.version - group = "com.nami.reactlibrary" - description packageJson.description - url packageJson.repository.baseUrl - licenses { - license { - name packageJson.license - url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename - distribution 'repo' - } - } - developers { - developer { - id packageJson.author.username - name packageJson.author.name - } - } - } + } configurations { @@ -121,22 +100,6 @@ configurations { afterEvaluate { project -> // some Gradle build hooks ref: // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html - task androidJavadoc(type: Javadoc) { - source = android.sourceSets.main.java.srcDirs - classpath += files(android.bootClasspath) -// classpath += files(project.getConfigurations().getByName('compile').asList()) -// classpath += files(project.getConfigurations().getByName('customConfig').asList()) - include '**/*.java' - } - task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) { - classifier = 'javadoc' - from androidJavadoc.destinationDir - } - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.srcDirs - include '**/*.java' - } android.libraryVariants.all { variant -> def name = variant.name.capitalize() def javaCompileTask = variant.javaCompileProvider.get() @@ -144,16 +107,8 @@ afterEvaluate { project -> from javaCompileTask.destinationDir } } - artifacts { - archives androidSourcesJar - archives androidJavadocJar - } + task installArchives(type: Upload) { configuration = configurations.archives - // repositories.mavenDeployer { - // // Deploy to react-native-event-bridge/maven, ready to publish to npm - // repository url: "file://${projectDir}/../android/maven" - // configureReactNativePom pom - // } } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index c21f511c..47d110b9 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Wed May 26 17:12:26 EDT 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt index fd34ecab..a232b101 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt @@ -106,7 +106,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) : } else { Arguments.createArray() } - val settingsList = mutableListOf("extendedClientInfo:react-native:3.2.0") + val settingsList = mutableListOf("extendedClientInfo:react-native:3.2.1-beta.2") namiCommandsReact?.toArrayList()?.filterIsInstance()?.let { commandsFromReact -> settingsList.addAll(commandsFromReact) } diff --git a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt index a7ec426f..f13b5df6 100644 --- a/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +++ b/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt @@ -227,7 +227,7 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) : @ReactMethod fun setAppSuppliedVideoDetails(url: String, name: String?) { - // To be implemented + NamiPaywallManager.setAppSuppliedVideoDetails(url = url, name = name) } @ReactMethod diff --git a/examples/Basic/android/app/build.gradle b/examples/Basic/android/app/build.gradle index 4c5ad0a3..2638f040 100644 --- a/examples/Basic/android/app/build.gradle +++ b/examples/Basic/android/app/build.gradle @@ -1,95 +1,55 @@ apply plugin: "com.android.application" - -import com.android.build.OutputFile +apply plugin: "org.jetbrains.kotlin.android" +apply plugin: "com.facebook.react" /** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation - * entryFile: "index.android.js", - * - * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format - * bundleCommand: "ram-bundle", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] + * This is the configuration block to customize your React Native Android app. + * By default you don't need to apply any configuration, just uncomment the lines you need. */ - -project.ext.react = [ - enableHermes: false, // clean and rebuild if changing -] - -apply from: "../../node_modules/react-native/react.gradle" - -/** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. - */ -def enableSeparateBuildPerCPUArchitecture = false +react { + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '..' + // root = file("../") + // The folder where the react-native NPM package is. Default is ../node_modules/react-native + // reactNativeDir = file("../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js + // cliFile = file("../node_modules/react-native/cli.js") + + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + // + // The command to run when bundling. By default is 'bundle' + // bundleCommand = "ram-bundle" + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] +} /** * Run Proguard to shrink the Java bytecode in release builds. @@ -109,66 +69,25 @@ def enableProguardInReleaseBuilds = false */ def jscFlavor = 'org.webkit:android-jsc:+' -/** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and mirrored here. If it is not set - * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode - * and the benefits of using Hermes will therefore be sharply reduced. - */ -def enableHermes = project.ext.react.get("enableHermes", false); - android { - compileSdkVersion 33 + compileSdk rootProject.ext.compileSdkVersion - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + namespace = "com.namiml.demo.basic" - lintOptions { - checkReleaseBuilds false + compileOptions { + coreLibraryDesugaringEnabled true } defaultConfig { applicationId "com.namiml.stg.testreactnative" - minSdkVersion 26 - targetSdkVersion 33 versionCode 1 versionName "1.0" testBuildType System.getProperty('testBuildType', 'debug') testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' missingDimensionStrategy 'store', 'play' - } - flavorDimensions "default" - productFlavors { - production { - applicationId "com.namiml.testreact.prod" - minSdkVersion 26 - targetSdkVersion 33 - manifestPlaceholders.app_name = "TestRNProd" - manifestPlaceholders.app_icon = "@mipmap/ic_launcher_prod" - manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round_prod" - } - staging { - applicationId "com.namiml.stg.testreactnative" - minSdkVersion 26 - targetSdkVersion 33 - manifestPlaceholders.app_name = "TestRNStg" - manifestPlaceholders.app_icon = "@mipmap/ic_launcher" - manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" - } - } - dexOptions { - javaMaxHeapSize "4g" - } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" - } + multiDexEnabled true + targetSdk rootProject.ext.targetSdkVersion + minSdkVersion rootProject.ext.minSdkVersion } signingConfigs { debug { @@ -185,64 +104,48 @@ android { v2SigningEnabled true } } + flavorDimensions += "environment" + productFlavors { + production { + applicationId "com.namiml.testreact.prod" + manifestPlaceholders.app_name = "TestRNProd" + manifestPlaceholders.app_icon = "@mipmap/ic_launcher_prod" + manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round_prod" + dimension = "environment" + } + staging { + applicationId "com.namiml.stg.testreactnative" + manifestPlaceholders.app_name = "TestRNStg" + manifestPlaceholders.app_icon = "@mipmap/ic_launcher" + manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" + dimension = "environment" + } + } + buildTypes { debug { signingConfig signingConfigs.debug } release { - // Caution! In production, you need to generate your own keystore file. - // see https://facebook.github.io/react-native/docs/signed-apk-android. - signingConfig null - minifyEnabled true - shrinkResources = true - proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" - proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro" - } - } - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // https://developer.android.com/studio/build/configure-apk-splits.html - // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. - def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - defaultConfig.versionCode * 1000 + versionCodes.get(abi) - } + signingConfig signingConfigs.release + minifyEnabled enableProguardInReleaseBuilds } } } dependencies { androidTestImplementation('com.wix:detox:+') - implementation ("androidx.appcompat:appcompat:1.3.1") { - version { - strictly '1.3.1' - } - } - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "com.facebook.react:react-native:+" // From node_modules - implementation 'com.github.jeziellago:compose-markdown:0.3.0' - implementation "com.namiml:sdk-android:3.2.0-beta.01" - implementation project(':react-native-screens') + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") - if (enableHermes) { - def hermesPath = "../../node_modules/hermes-engine/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } -} -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.implementation - into 'libs' + coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/examples/Basic/android/app/proguard-rules.pro b/examples/Basic/android/app/proguard-rules.pro index 11b02572..5ae6b4be 100644 --- a/examples/Basic/android/app/proguard-rules.pro +++ b/examples/Basic/android/app/proguard-rules.pro @@ -8,3 +8,8 @@ # http://developer.android.com/guide/developing/tools/proguard.html # Add any project specific keep options here: + +#ParametrizedType ClassCastException error fix +-keep,allowobfuscation,allowshrinking interface retrofit2.Call +-keep,allowobfuscation,allowshrinking class retrofit2.Response +-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation diff --git a/examples/Basic/android/app/src/main/AndroidManifest.xml b/examples/Basic/android/app/src/main/AndroidManifest.xml index e1e00f48..0d0b78f1 100644 --- a/examples/Basic/android/app/src/main/AndroidManifest.xml +++ b/examples/Basic/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + getPackages() { List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); - packages.add(new com.swmansion.rnscreens.RNScreensPackage()); +// packages.add(new com.swmansion.rnscreens.RNScreensPackage()); packages.add(new RNConfigPackage()); return packages; } @@ -46,32 +44,5 @@ public ReactNativeHost getReactNativeHost() { public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this); // Remove this line if you don't want Flipper enabled - } - - /** - * Loads Flipper in React Native templates. - * - * @param context - */ - private static void initializeFlipper(Context context) { - if (BuildConfig.DEBUG) { - try { - /* - We use reflection here to pick up the class that initializes Flipper, - since Flipper library is not available in release mode - */ - Class aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper"); - aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } } } diff --git a/examples/Basic/android/build.gradle b/examples/Basic/android/build.gradle index 99eb18c0..7448bf8d 100644 --- a/examples/Basic/android/build.gradle +++ b/examples/Basic/android/build.gradle @@ -2,12 +2,11 @@ buildscript { ext { - buildToolsVersion = "29.0.3" + buildToolsVersion = "34.0.0" minSdkVersion = 22 - compileSdkVersion = 33 + compileSdkVersion = 34 targetSdkVersion = 33 - //1.7.20 kotlin if need - kotlin_version = '1.6.10' + kotlin_version = '1.8.20' } repositories { @@ -15,40 +14,21 @@ buildscript { jcenter() } dependencies { - classpath('com.android.tools.build:gradle:7.0.4') - - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath("com.android.tools.build:gradle:7.4.2") + classpath("com.facebook.react:react-native-gradle-plugin") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } } -def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) - allprojects { - configurations.all { - resolutionStrategy { - // Remove this override in 0.65+, as a proper fix is included in react-native itself. - force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION - } - } repositories { mavenLocal() - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url("$rootDir/../node_modules/react-native/android") - } - maven { - // Android JSC is installed from npm - url("$rootDir/../node_modules/jsc-android/dist") - } - google() - jcenter() - maven { - url("$rootDir/../node_modules/detox/Detox-android") - } + mavenCentral() maven { url 'https://jitpack.io' } + maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } maven { url("https://packages.namiml.com/NamiSDK/Android/") } } } + +apply plugin: "com.facebook.react.rootproject" diff --git a/examples/Basic/android/gradle.properties b/examples/Basic/android/gradle.properties index 06ec55ed..54d339c2 100644 --- a/examples/Basic/android/gradle.properties +++ b/examples/Basic/android/gradle.properties @@ -19,8 +19,23 @@ android.useAndroidX=true android.enableJetifier=true -android.enableDexingArtifactTransform=false -org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=8192m -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx8192m -XX:MaxMetaspaceSize=8192m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureondemand=true + +# Use this property to specify which architecture you want to build. +# You can also override it from the CLI using +# ./gradlew -PreactNativeArchitectures=x86_64 +reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 + +# Use this property to enable support to the new architecture. +# This will allow you to use TurboModules and the Fabric render in +# your application. You should enable this flag either if you want +# to write custom TurboModules/Fabric components OR use libraries that +# are providing them. +newArchEnabled=false + +# Use this property to enable or disable the Hermes JS engine. +# If set to false, you will be using JSC instead. +hermesEnabled=true diff --git a/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties b/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties index 7366f09c..b3cf94ac 100644 --- a/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties +++ b/examples/Basic/android/gradle/wrapper/gradle-wrapper.properties @@ -1,10 +1,10 @@ -#Sun Nov 15 18:57:56 EST 2020 +#Thu Jul 18 13:46:29 MDT 2024 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip -org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true +zipStoreBase=GRADLE_USER_HOME +org.gradle.jvmargs=-Xmx4096m -XX\:MaxPermSize\=4096m -XX\:+HeapDumpOnOutOfMemoryError org.gradle.configureondemand=true diff --git a/examples/Basic/android/gradlew b/examples/Basic/android/gradlew index b0d6d0ab..0adc8e1a 100755 --- a/examples/Basic/android/gradlew +++ b/examples/Basic/android/gradlew @@ -1,13 +1,13 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -17,78 +17,111 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/examples/Basic/android/settings.gradle b/examples/Basic/android/settings.gradle index 455241e1..e88fa424 100644 --- a/examples/Basic/android/settings.gradle +++ b/examples/Basic/android/settings.gradle @@ -1,5 +1,4 @@ rootProject.name = 'Basic' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' -include ':react-native-screens' -project(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android') +includeBuild('../node_modules/@react-native/gradle-plugin') diff --git a/examples/Basic/config/index.ts b/examples/Basic/config/index.ts index 65c31506..d022a9d2 100644 --- a/examples/Basic/config/index.ts +++ b/examples/Basic/config/index.ts @@ -7,8 +7,8 @@ export function getConfigObject() { switch (flavor) { case 'staging': return { - 'appPlatformID-apple': 'APPLE_STG_APP_PLATFORM_ID', - 'appPlatformID-android': 'ANDROID_STG_APP_PLATFORM_ID', + 'appPlatformID-apple': '4a2f6dbf-e684-4d65-a4df-0488771c577d', + 'appPlatformID-android': 'b7232eba-ff1d-4b7f-b8d0-55593b66c1d5', logLevel: 'DEBUG', namiCommands: ['useStagingAPI', 'useNamiWindow'], initialConfig: getInitialConfig(), diff --git a/examples/Basic/containers/CampaignScreen.tsx b/examples/Basic/containers/CampaignScreen.tsx index 216ea2f2..bf5eb68d 100644 --- a/examples/Basic/containers/CampaignScreen.tsx +++ b/examples/Basic/containers/CampaignScreen.tsx @@ -26,6 +26,7 @@ import { ViewerTabProps } from '../App'; import theme from '../theme'; import { SafeAreaView } from 'react-native-safe-area-context'; import { handleDeepLink } from '../services/deeplinking'; +import customLaunchObject from '../nami_launch_context_custom_object.json'; type CampaignScreenProps = ViewerTabProps<'Campaign'> @@ -90,7 +91,6 @@ const CampaignScreen: FC = ({ navigation }) => { }, []); useEffect(() => { - getAllCampaigns(); const subscriptionSignInRemover = NamiPaywallManager.registerSignInHandler( async () => { console.log('sign in'); @@ -137,6 +137,9 @@ const CampaignScreen: FC = ({ navigation }) => { setCampaigns(availableCampaigns); }, ); + + getAllCampaigns(); + return () => { subscriptionRemover(); subscriptionSignInRemover(); @@ -157,10 +160,12 @@ const CampaignScreen: FC = ({ navigation }) => { const triggerLaunch = (label?: any, url?: any) => { checkIfPaywallOpen(); + NamiPaywallManager.setAppSuppliedVideoDetails('https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', 'app-supplied-video'); + return NamiCampaignManager.launch( label, url, - { customAttributes: {}, customObject: { 'items' : [{ 'name' : 'item1' }] } }, + { customAttributes: {}, customObject: customLaunchObject }, (successAction, error) => { console.log('successAction', successAction); console.log('error', error); @@ -190,9 +195,6 @@ const CampaignScreen: FC = ({ navigation }) => { ? triggerLaunch(item.value, null) : triggerLaunch(null, item.value); } - - NamiPaywallManager.setAppSuppliedVideoDetails('https://storage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', 'app-supplied-video'); - }, []); const onItemPressDefault = useCallback(() => triggerLaunch(null, null), []); diff --git a/examples/Basic/metro.config.js b/examples/Basic/metro.config.js index 40b1ea1e..ad8f87b6 100644 --- a/examples/Basic/metro.config.js +++ b/examples/Basic/metro.config.js @@ -1,16 +1,11 @@ -/* Metro configuration for React Native - * https://github.com/facebook/react-native +const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); + +/** + * Metro configuration + * https://facebook.github.io/metro/docs/configuration * - * @format + * @type {import('metro-config').MetroConfig} */ +const config = {}; -module.exports = { - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: true, - }, - }), - }, -}; +module.exports = mergeConfig(getDefaultConfig(__dirname), config); diff --git a/examples/Basic/nami_launch_context_custom_object.json b/examples/Basic/nami_launch_context_custom_object.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/examples/Basic/nami_launch_context_custom_object.json @@ -0,0 +1 @@ +{} diff --git a/examples/Basic/package.json b/examples/Basic/package.json index 588bde69..4c98814f 100644 --- a/examples/Basic/package.json +++ b/examples/Basic/package.json @@ -19,42 +19,36 @@ "d": "./scripts/detox.sh" }, "dependencies": { - "@react-native-community/cli-platform-android": "^11.3.1", - "@react-native-community/masked-view": "^0.1.11", - "@react-navigation/bottom-tabs": "^6.5.7", - "@react-navigation/native": "^6.1.6", - "@react-navigation/native-stack": "^6.9.12", - "react": "17.0.2", - "react-native": "0.65.2", - "react-native-gesture-handler": "^1.8.0", + "@react-native-community/cli-platform-android": "^12.3.6", + "@react-native-masked-view/masked-view": "^0.3.1", + "@react-navigation/bottom-tabs": "^6.6.1", + "@react-navigation/native": "^6.1.18", + "@react-navigation/native-stack": "^6.10.1", + "react": "18.2.0", + "react-native": "npm:react-native-tvos@0.73.7-1", "react-native-nami-sdk": "file:../../", - "react-native-reanimated": "^2.14.4", - "react-native-safe-area-context": "^3.3.2", - "react-native-screens": "3.18.2", + "react-native-reanimated": "^3.8.1", + "react-native-safe-area-context": "^4.10.7", + "react-native-screens": "3.30.0", "react-native-iap": "10.1.3" }, "devDependencies": { - "@babel/core": "^7.16.5", - "@babel/runtime": "^7.16.5", - "@react-native-community/eslint-config": "^3.2.0", - "@tsconfig/react-native": "^2.0.3", - "@types/jest": "^29.5.2", - "@types/react": "^18.2.14", - "@types/react-native": "^0.72.2", + "@babel/core": "^7.20.0", + "@babel/preset-env": "^7.20.0", + "@babel/runtime": "^7.20.0", + "@react-native/babel-preset": "^0.73.18", + "@react-native/eslint-config": "^0.73.1", + "@react-native/metro-config": "^0.73.2", + "@react-native/typescript-config": "^0.73.1", + "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.57.1", - "@typescript-eslint/parser": "^5.57.1", - "babel-jest": "^27.4.5", - "detox": "20.9.1", - "eslint": "^8.37.0", - "eslint-plugin-react": "^7.32.2", - "eslint-plugin-react-native": "^4.0.0", - "jest": "^29.5.0", - "metro-react-native-babel-preset": "^0.66.2", - "prettier": "^2.8.7", - "react-native-codegen": "^0.0.12", - "react-test-renderer": "17.0.2", - "typescript": "^5.1.6" + "babel-jest": "^29.6.3", + "eslint": "^8.19.0", + "jest": "^29.6.3", + "prettier": "2.8.8", + "react-test-renderer": "18.2.0", + "typescript": "5.0.4", + "detox": "20.9.1" }, "jest": { "preset": "react-native" diff --git a/examples/TestNamiTV/android/app/build.gradle b/examples/TestNamiTV/android/app/build.gradle index acd9a629..cc65c649 100644 --- a/examples/TestNamiTV/android/app/build.gradle +++ b/examples/TestNamiTV/android/app/build.gradle @@ -1,95 +1,55 @@ apply plugin: "com.android.application" - -import com.android.build.OutputFile +apply plugin: "org.jetbrains.kotlin.android" +apply plugin: "com.facebook.react" /** - * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets - * and bundleReleaseJsAndAssets). - * These basically call `react-native bundle` with the correct arguments during the Android build - * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the - * bundle directly from the development server. Below you can see all the possible configurations - * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "../../node_modules/react-native/react.gradle"` line. - * - * project.ext.react = [ - * // the name of the generated asset file containing your JS bundle - * bundleAssetName: "index.android.bundle", - * - * // the entry file for bundle generation - * entryFile: "index.android.js", - * - * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format - * bundleCommand: "ram-bundle", - * - * // whether to bundle JS and assets in debug mode - * bundleInDebug: false, - * - * // whether to bundle JS and assets in release mode - * bundleInRelease: true, - * - * // whether to bundle JS and assets in another build variant (if configured). - * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants - * // The configuration property can be in the following formats - * // 'bundleIn${productFlavor}${buildType}' - * // 'bundleIn${buildType}' - * // bundleInFreeDebug: true, - * // bundleInPaidRelease: true, - * // bundleInBeta: true, - * - * // whether to disable dev mode in custom build variants (by default only disabled in release) - * // for example: to disable dev mode in the staging build type (if configured) - * devDisabledInStaging: true, - * // The configuration property can be in the following formats - * // 'devDisabledIn${productFlavor}${buildType}' - * // 'devDisabledIn${buildType}' - * - * // the root of your project, i.e. where "package.json" lives - * root: "../../", - * - * // where to put the JS bundle asset in debug mode - * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", - * - * // where to put the JS bundle asset in release mode - * jsBundleDirRelease: "$buildDir/intermediates/assets/release", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in debug mode - * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", - * - * // where to put drawable resources / React Native assets, e.g. the ones you use via - * // require('./image.png')), in release mode - * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", - * - * // by default the gradle tasks are skipped if none of the JS files or assets change; this means - * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to - * // date; if you have any other folders that you want to ignore for performance reasons (gradle - * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ - * // for example, you might want to remove it from here. - * inputExcludes: ["android/**", "ios/**"], - * - * // override which node gets called and with what additional arguments - * nodeExecutableAndArgs: ["node"], - * - * // supply additional arguments to the packager - * extraPackagerArgs: [] - * ] + * This is the configuration block to customize your React Native Android app. + * By default you don't need to apply any configuration, just uncomment the lines you need. */ - -project.ext.react = [ - enableHermes: false, // clean and rebuild if changing -] - -apply from: "../../node_modules/react-native/react.gradle" - -/** - * Set this to true to create two separate APKs instead of one: - * - An APK that only works on ARM devices - * - An APK that only works on x86 devices - * The advantage is the size of the APK is reduced by about 4MB. - * Upload all the APKs to the Play Store and people will download - * the correct one based on the CPU architecture of their device. - */ -def enableSeparateBuildPerCPUArchitecture = false +react { + /* Folders */ + // The root of your project, i.e. where "package.json" lives. Default is '..' + // root = file("../") + // The folder where the react-native NPM package is. Default is ../node_modules/react-native + // reactNativeDir = file("../node_modules/react-native") + // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen + // codegenDir = file("../node_modules/@react-native/codegen") + // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js + // cliFile = file("../node_modules/react-native/cli.js") + + /* Variants */ + // The list of variants to that are debuggable. For those we're going to + // skip the bundling of the JS bundle and the assets. By default is just 'debug'. + // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants. + // debuggableVariants = ["liteDebug", "prodDebug"] + + /* Bundling */ + // A list containing the node command and its flags. Default is just 'node'. + // nodeExecutableAndArgs = ["node"] + // + // The command to run when bundling. By default is 'bundle' + // bundleCommand = "ram-bundle" + // + // The path to the CLI configuration file. Default is empty. + // bundleConfig = file(../rn-cli.config.js) + // + // The name of the generated asset file containing your JS bundle + // bundleAssetName = "MyApplication.android.bundle" + // + // The entry file for bundle generation. Default is 'index.android.js' or 'index.js' + // entryFile = file("../js/MyApplication.android.js") + // + // A list of extra flags to pass to the 'bundle' commands. + // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle + // extraPackagerArgs = [] + + /* Hermes Commands */ + // The hermes compiler command to run. By default it is 'hermesc' + // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc" + // + // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map" + // hermesFlags = ["-O", "-output-source-map"] +} /** * Run Proguard to shrink the Java bytecode in release builds. @@ -109,40 +69,32 @@ def enableProguardInReleaseBuilds = false */ def jscFlavor = 'org.webkit:android-jsc:+' -/** - * Whether to enable the Hermes VM. - * - * This should be set on project.ext.react and mirrored here. If it is not set - * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode - * and the benefits of using Hermes will therefore be sharply reduced. - */ -def enableHermes = project.ext.react.get("enableHermes", false); - android { - compileSdkVersion 33 + compileSdk rootProject.ext.compileSdkVersion + + namespace = "com.namiml.demo.basic" compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 coreLibraryDesugaringEnabled true } + buildFeatures { + flavorDimensions = ["default", "store"] + } defaultConfig { applicationId "com.namiml.stg.testreactnative" - minSdkVersion 22 - targetSdkVersion 33 versionCode 1 versionName "1.0" manifestPlaceholders.app_name = "TestRNTV" manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" manifestPlaceholders.app_icon = "@mipmap/ic_launcher" + multiDexEnabled true + targetSdk rootProject.ext.targetSdkVersion + minSdkVersion rootProject.ext.minSdkVersion } - flavorDimensions "default", "store" productFlavors { production { applicationId "com.namiml.testreact.prod" - minSdkVersion 22 - targetSdkVersion 33 dimension "default" manifestPlaceholders.app_name = "RNTVProd" manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round_prod" @@ -150,8 +102,6 @@ android { } staging { applicationId "com.namiml.stg.testreactnative" - minSdkVersion 22 - targetSdkVersion 33 dimension "default" manifestPlaceholders.app_name = "RNTVStg" manifestPlaceholders.app_icon_round = "@mipmap/ic_launcher_round" @@ -159,17 +109,6 @@ android { } } - dexOptions { - javaMaxHeapSize "4g" - } - splits { - abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" - } - } signingConfigs { debug { storeFile file('debug.keystore') @@ -205,35 +144,14 @@ android { dimension "store" } } - - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // https://developer.android.com/studio/build/configure-apk-splits.html - // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. - def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - defaultConfig.versionCode * 1000 + versionCodes.get(abi) - } - } - } } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation "com.facebook.react:react-native:+" // From node_modules - implementation 'com.github.jeziellago:compose-markdown:0.3.0' - - amazonImplementation "com.namiml:sdk-amazon:3.2.0-beta.01" - playImplementation "com.namiml:sdk-android:3.2.0-beta.01" + // The version of react-native is set by the React Native Gradle Plugin + implementation("com.facebook.react:react-android") - if (enableHermes) { - def hermesPath = "../../node_modules/hermes-engine/android/"; - debugImplementation files(hermesPath + "hermes-debug.aar") - releaseImplementation files(hermesPath + "hermes-release.aar") + if (hermesEnabled.toBoolean()) { + implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor } @@ -241,11 +159,4 @@ dependencies { coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5" } -// Run this once to be able to run the application with BUCK -// puts all compile dependencies into folder libs for BUCK to use -task copyDownloadableDepsToLibs(type: Copy) { - from configurations.implementation - into 'libs' -} - apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml b/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml index 0127605c..099e55be 100644 --- a/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml +++ b/examples/TestNamiTV/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java b/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java index 3a4c6080..03d94408 100644 --- a/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java +++ b/examples/TestNamiTV/android/app/src/main/java/com/namiml/demo/basic/MainApplication.java @@ -1,13 +1,11 @@ package com.namiml.demo.basic; import android.app.Application; -import android.content.Context; import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.soloader.SoLoader; -import java.lang.reflect.InvocationTargetException; import java.util.List; import com.namiml.demo.basic.RNConfigPackage; @@ -45,32 +43,5 @@ public ReactNativeHost getReactNativeHost() { public void onCreate() { super.onCreate(); SoLoader.init(this, /* native exopackage */ false); - initializeFlipper(this); // Remove this line if you don't want Flipper enabled - } - - /** - * Loads Flipper in React Native templates. - * - * @param context - */ - private static void initializeFlipper(Context context) { - if (BuildConfig.DEBUG) { - try { - /* - We use reflection here to pick up the class that initializes Flipper, - since Flipper library is not available in release mode - */ - Class aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper"); - aClass.getMethod("initializeFlipper", Context.class).invoke(null, context); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } } } diff --git a/examples/TestNamiTV/android/build.gradle b/examples/TestNamiTV/android/build.gradle index cffd3d70..b616262d 100644 --- a/examples/TestNamiTV/android/build.gradle +++ b/examples/TestNamiTV/android/build.gradle @@ -2,52 +2,34 @@ buildscript { ext { - buildToolsVersion = "29.0.3" + buildToolsVersion = "34.0.0" minSdkVersion = 22 - compileSdkVersion = 33 + compileSdkVersion = 34 +// ndkVersion = "25.1.8937393" + kotlin_version = '1.8.20' targetSdkVersion = 33 - kotlin_version = '1.6.10' } repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath('com.android.tools.build:gradle:7.0.4') - - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath("com.android.tools.build:gradle:7.4.2") + classpath("com.facebook.react:react-native-gradle-plugin") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin") } } -def REACT_NATIVE_VERSION = new File(['node', '--print',"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version"].execute(null, rootDir).text.trim()) - allprojects { - configurations.all { - resolutionStrategy { - // Remove this override in 0.65+, as a proper fix is included in react-native itself. - force "com.facebook.react:react-native:" + REACT_NATIVE_VERSION - } - } repositories { mavenLocal() - maven { - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm - url("$rootDir/../node_modules/react-native/android") - } - maven { - // Android JSC is installed from npm - url("$rootDir/../node_modules/jsc-android/dist") - } - google() - jcenter() + mavenCentral() maven { url 'https://jitpack.io' } - maven { url "https://packages.namiml.com/NamiSDK/Amazon/"} - maven { url "https://packages.namiml.com/NamiSDK/Android/"} - + maven { url("https://packages.namiml.com/NamiSDK/Amazon/") } + maven { url("https://packages.namiml.com/NamiSDK/Android/") } } } + +apply plugin: "com.facebook.react.rootproject" diff --git a/examples/TestNamiTV/android/gradle.properties b/examples/TestNamiTV/android/gradle.properties index c2028f83..54d339c2 100644 --- a/examples/TestNamiTV/android/gradle.properties +++ b/examples/TestNamiTV/android/gradle.properties @@ -19,7 +19,23 @@ android.useAndroidX=true android.enableJetifier=true -org.gradle.jvmargs=-Xmx8192m -XX:MaxPermSize=8192m -XX:+HeapDumpOnOutOfMemoryError +org.gradle.jvmargs=-Xmx8192m -XX:MaxMetaspaceSize=8192m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true org.gradle.configureondemand=true + +# Use this property to specify which architecture you want to build. +# You can also override it from the CLI using +# ./gradlew -PreactNativeArchitectures=x86_64 +reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 + +# Use this property to enable support to the new architecture. +# This will allow you to use TurboModules and the Fabric render in +# your application. You should enable this flag either if you want +# to write custom TurboModules/Fabric components OR use libraries that +# are providing them. +newArchEnabled=false + +# Use this property to enable or disable the Hermes JS engine. +# If set to false, you will be using JSC instead. +hermesEnabled=true diff --git a/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties b/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties index 7366f09c..b3cf94ac 100644 --- a/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties +++ b/examples/TestNamiTV/android/gradle/wrapper/gradle-wrapper.properties @@ -1,10 +1,10 @@ -#Sun Nov 15 18:57:56 EST 2020 +#Thu Jul 18 13:46:29 MDT 2024 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip -org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError org.gradle.daemon=true org.gradle.parallel=true +zipStoreBase=GRADLE_USER_HOME +org.gradle.jvmargs=-Xmx4096m -XX\:MaxPermSize\=4096m -XX\:+HeapDumpOnOutOfMemoryError org.gradle.configureondemand=true diff --git a/examples/TestNamiTV/android/gradlew b/examples/TestNamiTV/android/gradlew index b0d6d0ab..0adc8e1a 100755 --- a/examples/TestNamiTV/android/gradlew +++ b/examples/TestNamiTV/android/gradlew @@ -1,13 +1,13 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -17,78 +17,111 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/examples/TestNamiTV/android/settings.gradle b/examples/TestNamiTV/android/settings.gradle index d8012004..bb2dc9a9 100644 --- a/examples/TestNamiTV/android/settings.gradle +++ b/examples/TestNamiTV/android/settings.gradle @@ -1,3 +1,4 @@ rootProject.name = 'TestNamiTV' apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' +includeBuild('../node_modules/@react-native/gradle-plugin') diff --git a/examples/TestNamiTV/metro.config.js b/examples/TestNamiTV/metro.config.js index 40b1ea1e..ad8f87b6 100644 --- a/examples/TestNamiTV/metro.config.js +++ b/examples/TestNamiTV/metro.config.js @@ -1,16 +1,11 @@ -/* Metro configuration for React Native - * https://github.com/facebook/react-native +const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config'); + +/** + * Metro configuration + * https://facebook.github.io/metro/docs/configuration * - * @format + * @type {import('metro-config').MetroConfig} */ +const config = {}; -module.exports = { - transformer: { - getTransformOptions: async () => ({ - transform: { - experimentalImportSupport: false, - inlineRequires: true, - }, - }), - }, -}; +module.exports = mergeConfig(getDefaultConfig(__dirname), config); diff --git a/examples/TestNamiTV/package.json b/examples/TestNamiTV/package.json index c2f830fe..f5ae2c80 100644 --- a/examples/TestNamiTV/package.json +++ b/examples/TestNamiTV/package.json @@ -15,40 +15,34 @@ "lint": "eslint . --ext .js,.jsx,.ts,.tsx" }, "dependencies": { - "@react-native-community/cli-platform-android": "^11.3.1", - "@react-native-community/masked-view": "^0.1.11", - "@react-navigation/bottom-tabs": "^6.5.7", - "@react-navigation/native": "^6.1.6", - "@react-navigation/native-stack": "^6.9.12", - "react": "18.0.0", - "react-native": "npm:react-native-tvos@0.69.8-2", + "@react-native-community/cli-platform-android": "^12.3.6", + "@react-native-masked-view/masked-view": "^0.3.1", + "@react-navigation/bottom-tabs": "^6.6.1", + "@react-navigation/native": "^6.1.18", + "@react-navigation/native-stack": "^6.10.1", + "react": "18.2.0", + "react-native": "0.73.7-1", "react-native-nami-sdk": "file:../../", - "react-native-reanimated": "^2.3.1", - "react-native-safe-area-context": "^3.3.2", - "react-native-screens": "3.25.0" + "react-native-reanimated": "^3.8.1", + "react-native-safe-area-context": "^4.10.7", + "react-native-screens": "3.30.0" }, "devDependencies": { - "@babel/core": "^7.16.5", - "@babel/runtime": "^7.16.5", - "@react-native-community/eslint-config": "^3.2.0", - "@tsconfig/react-native": "^2.0.3", - "@types/jest": "^29.5.0", - "@types/react": "^18.0.31", - "@types/react-native": "^0.71.5", + "@babel/core": "^7.20.0", + "@babel/preset-env": "^7.20.0", + "@babel/runtime": "^7.20.0", + "@react-native/babel-preset": "^0.73.18", + "@react-native/eslint-config": "^0.73.1", + "@react-native/metro-config": "^0.73.2", + "@react-native/typescript-config": "^0.73.1", + "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", - "@typescript-eslint/eslint-plugin": "^5.57.1", - "@typescript-eslint/parser": "^5.57.1", - "babel-jest": "^27.4.5", - "detox": "20.9.1", - "eslint": "^8.37.0", - "eslint-plugin-react": "^7.32.2", - "eslint-plugin-react-native": "^4.0.0", - "jest": "^29.5.0", - "metro-react-native-babel-preset": "^0.66.2", - "prettier": "^2.8.7", - "react-native-codegen": "^0.0.12", - "react-test-renderer": "17.0.2", - "typescript": "^5.0.2" + "babel-jest": "^29.6.3", + "eslint": "^8.19.0", + "jest": "^29.6.3", + "prettier": "2.8.8", + "react-test-renderer": "18.2.0", + "typescript": "5.0.4" }, "jest": { "preset": "react-native" diff --git a/examples/TestNamiTV/patches/hash-unary-function.patch b/examples/TestNamiTV/patches/hash-unary-function.patch index 2198be0a..3f33c68f 100644 --- a/examples/TestNamiTV/patches/hash-unary-function.patch +++ b/examples/TestNamiTV/patches/hash-unary-function.patch @@ -7,5 +7,5 @@ - struct hash_base : std::unary_function {}; + struct hash_base : std::__unary_function {}; #endif - + struct enable_hash_value { typedef std::size_t type; }; diff --git a/ios/Nami.m b/ios/Nami.m index fe6de961..84e381de 100644 --- a/ios/Nami.m +++ b/ios/Nami.m @@ -50,7 +50,7 @@ @implementation NamiBridge (RCTExternModule) } // Start commands with header iformation for Nami to let them know this is a React client. - NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.2.0"]]; + NSMutableArray *namiCommandStrings = [NSMutableArray arrayWithArray:@[@"extendedClientInfo:react-native:3.2.1-beta.2"]]; // Add additional namiCommands app may have sent in. NSObject *appCommandStrings = configDict[@"namiCommands"]; diff --git a/ios/NamiPaywallManagerBridge.swift b/ios/NamiPaywallManagerBridge.swift index 51146acc..e358650e 100644 --- a/ios/NamiPaywallManagerBridge.swift +++ b/ios/NamiPaywallManagerBridge.swift @@ -159,7 +159,7 @@ class RNNamiPaywallManager: RCTEventEmitter { } @objc(setAppSuppliedVideoDetails:name:) - func setAppSuppliedVideoDetails(url _: String, name _: String?) { - // To be implemented + func setAppSuppliedVideoDetails(url: String, name: String?) { + NamiPaywallManager.setAppSuppliedVideoDetails(url, name) } } diff --git a/package.json b/package.json index a390c4c5..390ed4ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nami-sdk", - "version": "3.2.0", + "version": "3.2.1-beta.2", "description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.", "main": "index.ts", "types": "index.d.ts", @@ -50,11 +50,11 @@ }, "peerDependencies": { "react": ">=17", - "react-native": ">=0.65" + "react-native": ">=0.73" }, "devDependencies": { "@react-native-community/eslint-config": "^3.2.0", - "@types/react-native": "^0.72.2", + "@types/react-native": "^0.73.0", "@typescript-eslint/eslint-plugin": "^5.59.7", "eslint": "^8.41.0", "eslint-plugin-jest": "^27.2.2", diff --git a/react-native-nami-sdk.podspec b/react-native-nami-sdk.podspec index bfd8d697..fd890ecc 100644 --- a/react-native-nami-sdk.podspec +++ b/react-native-nami-sdk.podspec @@ -20,7 +20,7 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,swift}" s.requires_arc = true - s.dependency 'Nami', '3.2.0' + s.dependency 'Nami', '3.2.1-beta.02' s.dependency 'React' end