brick-module 0.5.0 โ 0.5.2
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.
|
@@ -255,6 +255,28 @@ ext.applyBrickModules = { settings, args ->
|
|
|
255
255
|
gradle.rootProject.ext.brickCodegenRanInBuild =
|
|
256
256
|
settings.ext.has("brickCodegenRan") ? settings.ext.brickCodegenRan : false
|
|
257
257
|
configureAppProject(gradle)
|
|
258
|
+
// The compileSdkVersion in brick-codegen's generated build.gradle may be lower
|
|
259
|
+
// than the host project's compileSdk, so override it to match.
|
|
260
|
+
gradle.rootProject.subprojects { subproj ->
|
|
261
|
+
if (subproj.name == 'brick-codegen') {
|
|
262
|
+
subproj.afterEvaluate {
|
|
263
|
+
try {
|
|
264
|
+
def hostCompileSdk = 35
|
|
265
|
+
// Try to read compileSdk from the host app project
|
|
266
|
+
try {
|
|
267
|
+
def appProj = gradle.rootProject.findProject(":${appProjectName}")
|
|
268
|
+
if (appProj?.hasProperty('android')) {
|
|
269
|
+
hostCompileSdk = appProj.android.compileSdk ?: 35
|
|
270
|
+
}
|
|
271
|
+
} catch (Exception ignored) {}
|
|
272
|
+
subproj.android.compileSdkVersion hostCompileSdk
|
|
273
|
+
} catch (Exception e) {
|
|
274
|
+
println("๐งฑ BrickModules: Failed to override brick-codegen compileSdk: ${e.message}")
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
258
280
|
// Inline: ensure RN autolinking doesn't fail due to missing codegen/jni for brick-module
|
|
259
281
|
gradle.rootProject.subprojects { subproj ->
|
|
260
282
|
if (subproj.name == 'brick-module') {
|
|
@@ -8,19 +8,20 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
8
8
|
import com.facebook.react.bridge.ReactContext
|
|
9
9
|
import com.facebook.react.module.model.ReactModuleInfo
|
|
10
10
|
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
11
|
+
import android.util.Log
|
|
11
12
|
import java.util.HashMap
|
|
12
13
|
|
|
13
14
|
class BrickModulePackage : TurboReactPackage() {
|
|
14
15
|
|
|
15
16
|
init {
|
|
16
|
-
|
|
17
|
+
Log.d(TAG, "BrickModulePackage initialized")
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
override fun getModule(
|
|
20
21
|
name: String,
|
|
21
22
|
reactContext: ReactApplicationContext,
|
|
22
23
|
): NativeModule? {
|
|
23
|
-
|
|
24
|
+
Log.d(TAG, "getModule called with name: $name")
|
|
24
25
|
return if (name == "BrickModule") {
|
|
25
26
|
// Try to find the generated BrickModule class
|
|
26
27
|
try {
|
|
@@ -30,8 +31,8 @@ class BrickModulePackage : TurboReactPackage() {
|
|
|
30
31
|
Class.forName("com.brickmodule.codegen.BrickModule", true, classLoader)
|
|
31
32
|
val constructor = generatedClass.getConstructor(ReactContext::class.java)
|
|
32
33
|
val instance = constructor.newInstance(reactContext) as NativeModule
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
Log.d(TAG, "BrickModule successfully created: ${instance.javaClass.name}")
|
|
35
|
+
Log.d(TAG, "BrickModule ${instance.javaClass.methods.map { it.name }}")
|
|
35
36
|
instance
|
|
36
37
|
} catch (e: ClassNotFoundException) {
|
|
37
38
|
// Try with current thread class loader as fallback
|
|
@@ -41,8 +42,9 @@ class BrickModulePackage : TurboReactPackage() {
|
|
|
41
42
|
Class.forName("com.brickmodule.BrickModule", true, currentClassLoader)
|
|
42
43
|
val constructor = generatedClass.getConstructor(ReactContext::class.java)
|
|
43
44
|
val instance = constructor.newInstance(reactContext) as NativeModule
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
Log.d(
|
|
46
|
+
TAG,
|
|
47
|
+
"BrickModule successfully created with thread classloader: ${instance.javaClass.name}"
|
|
46
48
|
)
|
|
47
49
|
instance
|
|
48
50
|
} catch (e2: Exception) {
|
|
@@ -64,7 +66,7 @@ class BrickModulePackage : TurboReactPackage() {
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
|
|
67
|
-
|
|
69
|
+
Log.d(TAG, "getReactModuleInfoProvider called")
|
|
68
70
|
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
69
71
|
// Force TurboModule to true since we're using NativeBrickModuleSpec
|
|
70
72
|
val isTurboModule: Boolean = true
|
|
@@ -82,6 +84,7 @@ class BrickModulePackage : TurboReactPackage() {
|
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
companion object {
|
|
87
|
+
private const val TAG = "BrickModulePackage"
|
|
85
88
|
const val NAME = "BrickModulePackage"
|
|
86
89
|
}
|
|
87
90
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.brickmodule
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
3
4
|
import com.facebook.react.bridge.ReactContext
|
|
4
5
|
import java.util.concurrent.ConcurrentHashMap
|
|
5
6
|
|
|
@@ -22,8 +23,9 @@ class BrickModuleRegistry {
|
|
|
22
23
|
fun register(modules: List<BrickModuleBase>) {
|
|
23
24
|
modules.forEach { module -> registerSingleModule(module) }
|
|
24
25
|
isRegistered = true
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
Log.d(
|
|
27
|
+
TAG,
|
|
28
|
+
"Successfully registered ${modules.size} modules (total: ${this.modules.size})"
|
|
27
29
|
)
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -36,13 +38,13 @@ class BrickModuleRegistry {
|
|
|
36
38
|
@Synchronized
|
|
37
39
|
fun push(module: BrickModuleBase) {
|
|
38
40
|
registerSingleModule(module)
|
|
39
|
-
|
|
41
|
+
Log.d(TAG, "Module pushed successfully (total: ${modules.size})")
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
private fun registerSingleModule(module: BrickModuleBase) {
|
|
43
45
|
val moduleName = module.moduleName
|
|
44
46
|
if (moduleName.isEmpty()) {
|
|
45
|
-
|
|
47
|
+
Log.e(TAG, "Module has empty moduleName")
|
|
46
48
|
return
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -51,9 +53,9 @@ class BrickModuleRegistry {
|
|
|
51
53
|
modules[moduleName] = module
|
|
52
54
|
|
|
53
55
|
if (isUpdate) {
|
|
54
|
-
|
|
56
|
+
Log.d(TAG, "Module '$moduleName' updated (replaced existing)")
|
|
55
57
|
} else {
|
|
56
|
-
|
|
58
|
+
Log.d(TAG, "Registered module '$moduleName'")
|
|
57
59
|
}
|
|
58
60
|
}
|
|
59
61
|
|
|
@@ -85,8 +87,10 @@ class BrickModuleRegistry {
|
|
|
85
87
|
// Get constants directly from BrickModuleBase
|
|
86
88
|
allConstants[moduleName] = module.getConstants()
|
|
87
89
|
} catch (e: Exception) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
Log.e(
|
|
91
|
+
TAG,
|
|
92
|
+
"Failed to get constants for $moduleName: ${e.message}",
|
|
93
|
+
e
|
|
90
94
|
)
|
|
91
95
|
}
|
|
92
96
|
}
|
|
@@ -106,7 +110,7 @@ class BrickModuleRegistry {
|
|
|
106
110
|
modules.clear()
|
|
107
111
|
isRegistered = false
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
Log.d(TAG, "Unregistered $count modules")
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/** Clears all registered modules (for testing purposes only) */
|
|
@@ -114,6 +118,10 @@ class BrickModuleRegistry {
|
|
|
114
118
|
fun clearRegistry() {
|
|
115
119
|
modules.clear()
|
|
116
120
|
isRegistered = false
|
|
117
|
-
|
|
121
|
+
Log.d(TAG, "Registry cleared")
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
companion object {
|
|
125
|
+
private const val TAG = "BrickModuleRegistry"
|
|
118
126
|
}
|
|
119
127
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.brickmodule
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
3
4
|
import com.facebook.react.bridge.*
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -8,6 +9,8 @@ import com.facebook.react.bridge.*
|
|
|
8
9
|
*/
|
|
9
10
|
object EventDataConverter {
|
|
10
11
|
|
|
12
|
+
private const val TAG = "EventDataConverter"
|
|
13
|
+
|
|
11
14
|
private fun isNullSentinel(value: Any?): Boolean {
|
|
12
15
|
return value is Null ||
|
|
13
16
|
(value != null && value.javaClass.name == "com.brickmodule.Null") ||
|
|
@@ -37,15 +40,16 @@ object EventDataConverter {
|
|
|
37
40
|
is List<*> -> convertList(data)
|
|
38
41
|
is Array<*> -> convertList(data.toList())
|
|
39
42
|
else -> {
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
Log.w(
|
|
44
|
+
TAG,
|
|
45
|
+
"Unsupported data type ${data.javaClass.simpleName}, converting to string"
|
|
42
46
|
)
|
|
43
47
|
data.toString()
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
} catch (e: Exception) {
|
|
48
|
-
|
|
52
|
+
Log.e(TAG, "Failed to convert data: ${e.message}", e)
|
|
49
53
|
null
|
|
50
54
|
}
|
|
51
55
|
}
|
|
@@ -78,7 +82,7 @@ object EventDataConverter {
|
|
|
78
82
|
|
|
79
83
|
writableMap
|
|
80
84
|
} catch (e: Exception) {
|
|
81
|
-
|
|
85
|
+
Log.e(TAG, "Failed to convert map: ${e.message}", e)
|
|
82
86
|
null
|
|
83
87
|
}
|
|
84
88
|
}
|
|
@@ -108,7 +112,7 @@ object EventDataConverter {
|
|
|
108
112
|
|
|
109
113
|
writableArray
|
|
110
114
|
} catch (e: Exception) {
|
|
111
|
-
|
|
115
|
+
Log.e(TAG, "Failed to convert list: ${e.message}", e)
|
|
112
116
|
null
|
|
113
117
|
}
|
|
114
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brick-module",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Better React Native native module development",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"brick-codegen": "./bin/brick-codegen.js"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"brick-codegen": "0.5.
|
|
61
|
+
"brick-codegen": "0.5.2"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"react": ">=18.2.0",
|