cloudx-react-native 3.6.1 → 3.8.0

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.
Files changed (38) hide show
  1. package/android/build.gradle +92 -2
  2. package/android/src/main/java/com/cloudxreactnative/CloudXAdViewEvent.kt +2 -2
  3. package/android/src/main/java/com/cloudxreactnative/CloudXAdViewManagerImpl.kt +6 -6
  4. package/android/src/main/java/com/cloudxreactnative/CloudXModuleImpl.kt +208 -102
  5. package/android/src/test/java/com/cloudxreactnative/CloudXModuleImplArbiterBidsTest.kt +254 -0
  6. package/android/src/test/java/com/cloudxreactnative/CloudXModuleImplThreadingTest.kt +170 -0
  7. package/android/src/test/java/com/cloudxreactnative/FakeReadable.kt +101 -0
  8. package/cloudx-react-native.podspec +1 -1
  9. package/ios/CloudX.mm +62 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/types/Arbiter.js +27 -0
  12. package/lib/commonjs/types/Arbiter.js.map +1 -1
  13. package/lib/commonjs/types/RevenueData.js +1 -0
  14. package/lib/commonjs/types/RevenueData.js.map +1 -1
  15. package/lib/commonjs/types/index.js.map +1 -1
  16. package/lib/commonjs/version.js +1 -1
  17. package/lib/module/index.js.map +1 -1
  18. package/lib/module/types/Arbiter.js +27 -0
  19. package/lib/module/types/Arbiter.js.map +1 -1
  20. package/lib/module/types/RevenueData.js +1 -0
  21. package/lib/module/types/RevenueData.js.map +1 -1
  22. package/lib/module/types/index.js.map +1 -1
  23. package/lib/module/version.js +1 -1
  24. package/lib/typescript/src/index.d.ts +1 -1
  25. package/lib/typescript/src/index.d.ts.map +1 -1
  26. package/lib/typescript/src/types/Arbiter.d.ts +45 -2
  27. package/lib/typescript/src/types/Arbiter.d.ts.map +1 -1
  28. package/lib/typescript/src/types/RevenueData.d.ts +1 -0
  29. package/lib/typescript/src/types/RevenueData.d.ts.map +1 -1
  30. package/lib/typescript/src/types/index.d.ts +1 -1
  31. package/lib/typescript/src/types/index.d.ts.map +1 -1
  32. package/lib/typescript/src/version.d.ts +1 -1
  33. package/package.json +1 -1
  34. package/src/index.ts +2 -0
  35. package/src/types/Arbiter.ts +61 -2
  36. package/src/types/RevenueData.ts +1 -0
  37. package/src/types/index.ts +2 -0
  38. package/src/version.ts +1 -1
@@ -1,3 +1,5 @@
1
+ import groovy.json.JsonSlurper
2
+
1
3
  buildscript {
2
4
  repositories {
3
5
  google()
@@ -8,10 +10,87 @@ buildscript {
8
10
  }
9
11
  }
10
12
 
11
- def isNewArchitectureEnabled() {
13
+ def resolveReactNativePackageJsonWithNode() {
14
+ def stdout = new ByteArrayOutputStream()
15
+ def stderr = new ByteArrayOutputStream()
16
+
17
+ try {
18
+ def result = exec {
19
+ workingDir rootProject.projectDir
20
+ commandLine "node", "--print", "require.resolve('react-native/package.json', { paths: [process.cwd()] })"
21
+ standardOutput = stdout
22
+ errorOutput = stderr
23
+ ignoreExitValue = true
24
+ }
25
+
26
+ def resolvedPath = stdout.toString().trim()
27
+ if (result.exitValue == 0 && resolvedPath) {
28
+ def packageJson = file(resolvedPath)
29
+ if (packageJson.exists()) {
30
+ return packageJson
31
+ }
32
+ }
33
+ } catch (Exception ignored) {
34
+ return null
35
+ }
36
+
37
+ return null
38
+ }
39
+
40
+ def resolveReactNativePackageJson() {
41
+ def packageJson = resolveReactNativePackageJsonWithNode()
42
+ if (packageJson != null) {
43
+ return packageJson
44
+ }
45
+
46
+ packageJson = file("$rootProject.projectDir/../node_modules/react-native/package.json")
47
+ if (packageJson.exists()) {
48
+ return packageJson
49
+ }
50
+
51
+ logger.warn("CloudX React Native: could not find react-native/package.json; falling back to newArchEnabled.")
52
+ return null
53
+ }
54
+
55
+ def getReactNativeVersion() {
56
+ def packageJson = resolveReactNativePackageJson()
57
+ if (packageJson == null) {
58
+ return null
59
+ }
60
+
61
+ def parsedPackageJson = new JsonSlurper().parseText(packageJson.text)
62
+ return parsedPackageJson.version as String
63
+ }
64
+
65
+ def isReactNativeNewArchitectureOnly() {
66
+ def version = getReactNativeVersion()
67
+ if (version == null) {
68
+ return false
69
+ }
70
+
71
+ def matcher = version =~ /^(\d+)\.(\d+)\..*$/
72
+ if (!matcher.matches()) {
73
+ return false
74
+ }
75
+
76
+ def major = matcher[0][1].toInteger()
77
+ def minor = matcher[0][2].toInteger()
78
+ return major > 0 || (major == 0 && minor >= 82)
79
+ }
80
+
81
+ def isNewArchitectureEnabledByProperty() {
12
82
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
13
83
  }
14
84
 
85
+ def isNewArchitectureEnabled() {
86
+ /*
87
+ * React Native 0.82+ is New Architecture-only and ignores attempts to opt
88
+ * back into Legacy Architecture, so CloudX must build its codegen-backed
89
+ * Android sources for those host apps regardless of the app flag.
90
+ */
91
+ return isReactNativeNewArchitectureOnly() || isNewArchitectureEnabledByProperty()
92
+ }
93
+
15
94
  apply plugin: "com.android.library"
16
95
  apply plugin: "kotlin-android"
17
96
 
@@ -54,6 +133,13 @@ android {
54
133
  }
55
134
  }
56
135
 
136
+ testOptions {
137
+ unitTests {
138
+ // android.util.Log is a stub that throws in plain JVM unit tests.
139
+ returnDefaultValues = true
140
+ }
141
+ }
142
+
57
143
  compileOptions {
58
144
  sourceCompatibility JavaVersion.VERSION_17
59
145
  targetCompatibility JavaVersion.VERSION_17
@@ -72,5 +158,9 @@ repositories {
72
158
  dependencies {
73
159
  implementation "com.facebook.react:react-native:0.76.2"
74
160
 
75
- implementation "io.cloudx:sdk:4.4.0"
161
+ implementation "io.cloudx:sdk:4.6.0"
162
+
163
+ testImplementation "junit:junit:4.13.2"
164
+ testImplementation "io.mockk:mockk:1.13.10"
165
+ testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2"
76
166
  }
@@ -10,11 +10,11 @@ import com.facebook.react.uimanager.events.Event
10
10
  class CloudXAdViewEvent(
11
11
  surfaceId: Int,
12
12
  viewId: Int,
13
- private val eventName: String,
13
+ private val registrationName: String,
14
14
  private val payload: WritableMap,
15
15
  ) : Event<CloudXAdViewEvent>(surfaceId, viewId) {
16
16
 
17
- override fun getEventName(): String = eventName
17
+ override fun getEventName(): String = registrationName
18
18
 
19
19
  override fun getEventData(): WritableMap = payload
20
20
 
@@ -15,12 +15,12 @@ object CloudXAdViewManagerImpl {
15
15
  fun createViewInstance(reactContext: ThemedReactContext): CloudXAdView = CloudXAdView(reactContext)
16
16
 
17
17
  fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> =
18
- MapBuilder.builder<String, Any>()
19
- .put(CloudXAdEvents.ON_AD_VIEW_LOADED_EVENT, eventRegistration(CloudXAdEvents.ON_AD_VIEW_LOADED_EVENT))
20
- .put(CloudXAdEvents.ON_AD_VIEW_LOAD_FAILED_EVENT, eventRegistration(CloudXAdEvents.ON_AD_VIEW_LOAD_FAILED_EVENT))
21
- .put(CloudXAdEvents.ON_AD_VIEW_CLICKED_EVENT, eventRegistration(CloudXAdEvents.ON_AD_VIEW_CLICKED_EVENT))
22
- .put(CloudXAdEvents.ON_AD_VIEW_REVENUE_PAID_EVENT, eventRegistration(CloudXAdEvents.ON_AD_VIEW_REVENUE_PAID_EVENT))
23
- .build()
18
+ mutableMapOf(
19
+ CloudXAdEvents.ON_AD_VIEW_LOADED_EVENT to eventRegistration(CloudXAdEvents.ON_AD_VIEW_LOADED_EVENT),
20
+ CloudXAdEvents.ON_AD_VIEW_LOAD_FAILED_EVENT to eventRegistration(CloudXAdEvents.ON_AD_VIEW_LOAD_FAILED_EVENT),
21
+ CloudXAdEvents.ON_AD_VIEW_CLICKED_EVENT to eventRegistration(CloudXAdEvents.ON_AD_VIEW_CLICKED_EVENT),
22
+ CloudXAdEvents.ON_AD_VIEW_REVENUE_PAID_EVENT to eventRegistration(CloudXAdEvents.ON_AD_VIEW_REVENUE_PAID_EVENT),
23
+ )
24
24
 
25
25
  private fun eventRegistration(name: String): Map<String, String> = MapBuilder.of("registrationName", name)
26
26