brick-module 0.1.18 → 0.1.20

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.
@@ -241,13 +241,20 @@ target_include_directories(react_codegen_BrickModuleSpec PUBLIC ${CMAKE_CURRENT_
241
241
  def prepareTask = subproj.tasks.findByName('prepareBrickModuleAutolinkCMake') ?: subproj.tasks.create('prepareBrickModuleAutolinkCMake') {
242
242
  group = 'brick-module'
243
243
  description = 'Creates a dummy CMakeLists.txt so RN autolinking can add_subdirectory for brick-module without error.'
244
+
245
+ // Capture project reference for Configuration Cache compatibility
246
+ def buildDirProvider = subproj.layout.buildDirectory
247
+ def cmakeContent = dummyCMake
248
+
249
+ outputs.dir(buildDirProvider.dir('generated/source/codegen/jni'))
250
+
244
251
  doLast {
245
- def jniDir = new File(subproj.buildDir, 'generated/source/codegen/jni')
252
+ def jniDir = buildDirProvider.asFile.get().toPath().resolve('generated/source/codegen/jni').toFile()
246
253
  if (!jniDir.exists()) {
247
254
  jniDir.mkdirs()
248
255
  }
249
256
  def cmakeFile = new File(jniDir, 'CMakeLists.txt')
250
- cmakeFile.text = dummyCMake
257
+ cmakeFile.text = cmakeContent
251
258
  println("🧱 BrickModules: Prepared stub CMake at ${cmakeFile}")
252
259
  }
253
260
  }
@@ -304,15 +311,83 @@ def configureBrickModules(project) {
304
311
  def projectRoot = rootProject.ext.brickProjectRoot
305
312
 
306
313
  // Add source directory for generated code
307
- project.android.sourceSets.main.java.srcDir "${project.buildDir}/generated/source/brick-provider"
314
+ project.android.sourceSets.main.java.srcDir "${project.layout.buildDirectory.asFile.get()}/generated/source/brick-provider"
308
315
 
309
316
  // Create provider generation task
310
317
  project.tasks.create('generateBrickModulesList') {
311
318
  description = 'Generates BrickModulesList class for module injection in MainActivity'
312
319
  group = 'brick-module'
313
-
320
+
321
+ // Capture values for Configuration Cache compatibility
322
+ def modulesData = brickModulesData
323
+ def buildDirProvider = project.layout.buildDirectory
324
+
325
+ // Declare inputs and outputs for Configuration Cache compatibility
326
+ inputs.property('brickModulesData', modulesData)
327
+ outputs.dir(buildDirProvider.dir('generated/source/brick-provider'))
328
+
314
329
  doLast {
315
- generateProvider(project, brickModulesData)
330
+ // Inline generateProvider logic for Configuration Cache compatibility
331
+ def modules = modulesData.collect { name, data ->
332
+ [
333
+ moduleName: data.moduleName,
334
+ packageName: data.packageName
335
+ ]
336
+ }
337
+
338
+ def outputDir = buildDirProvider.asFile.get().toPath().resolve('generated/source/brick-provider').toFile()
339
+ outputDir.mkdirs()
340
+
341
+ def imports = modules.collect { "import ${it.packageName}.${it.moduleName}" }.join("\n")
342
+ def moduleInstances = modules.collect { " ${it.moduleName}(context)" }.join(",\n")
343
+ def moduleNames = modules.collect { " \"${it.moduleName}\"" }.join(",\n")
344
+
345
+ new File(outputDir, "BrickModulesList.kt").text = """
346
+ // Auto-generated by brick_modules.gradle
347
+ package com.brickmodule
348
+
349
+ import com.facebook.react.bridge.ReactContext
350
+ ${imports}
351
+
352
+ /**
353
+ * Auto-generated helper for brick modules
354
+ * Use this class to get auto-linked modules in your MainActivity
355
+ *
356
+ * Example usage:
357
+ * ```kotlin
358
+ * override fun getBrickModules(context: ReactContext): List<BrickModuleBase> {
359
+ * return BrickModulesList(context).modules
360
+ * }
361
+ * ```
362
+ */
363
+ class BrickModulesList(private val context: ReactContext) {
364
+
365
+ val modules: List<BrickModuleBase> by lazy {
366
+ listOf<BrickModuleBase>(
367
+ ${moduleInstances}
368
+ )
369
+ }
370
+
371
+ val availableModules: List<String> = listOf(
372
+ ${moduleNames}
373
+ )
374
+
375
+ companion object {
376
+ /**
377
+ * Legacy static method for backward compatibility
378
+ * @deprecated Use BrickModulesList(context).modules instead
379
+ */
380
+ @Deprecated(
381
+ message = "Use BrickModulesList(context).modules instead",
382
+ replaceWith = ReplaceWith("BrickModulesList(context).modules")
383
+ )
384
+ @JvmStatic
385
+ fun getAutolinkedModules(context: ReactContext): MutableList<Any> {
386
+ return BrickModulesList(context).modules.toMutableList() as MutableList<Any>
387
+ }
388
+ }
389
+ }
390
+ """
316
391
  }
317
392
  }
318
393
 
@@ -389,75 +464,3 @@ def configureBrickModules(project) {
389
464
  add('implementation', "com.google.code.gson:gson:2.8.9")
390
465
  }
391
466
  }
392
-
393
- // Generate BrickModulesList.kt
394
- def generateProvider(project, brickModulesData) {
395
- def modules = brickModulesData.collect { name, data ->
396
- [
397
- moduleName: data.moduleName,
398
- packageName: data.packageName
399
- ]
400
- }
401
-
402
- def outputDir = project.file("${project.buildDir}/generated/source/brick-provider/com/brickmodule")
403
- outputDir.mkdirs()
404
-
405
- def imports = modules.collect { "import ${it.packageName}.${it.moduleName}" }.join("\n")
406
- def moduleInstances = modules.collect { " ${it.moduleName}(context)" }.join(",\n")
407
- def moduleNames = modules.collect { " \"${it.moduleName}\"" }.join(",\n")
408
-
409
- new File(outputDir, "BrickModulesList.kt").text = """// Auto-generated by brick_modules.gradle
410
- package com.brickmodule
411
-
412
- import com.facebook.react.bridge.ReactContext
413
- ${imports}
414
-
415
- /**
416
- * Auto-generated helper for brick modules
417
- * Use this class to get auto-linked modules in your MainActivity
418
- *
419
- * Example usage:
420
- * ```kotlin
421
- * override fun getBrickModules(context: ReactContext): List<BrickModuleBase> {
422
- * return BrickModulesList(context).modules
423
- * }
424
- * ```
425
- */
426
- class BrickModulesList(private val context: ReactContext) {
427
- /**
428
- * Get all auto-linked brick modules
429
- *
430
- * @return List of auto-linked module instances
431
- */
432
- val modules: List<BrickModuleBase> by lazy {
433
- listOf<BrickModuleBase>(
434
- ${moduleInstances}
435
- )
436
- }
437
-
438
- /**
439
- * Get available module names (for debugging)
440
- *
441
- * @return List of module names
442
- */
443
- val availableModules: List<String> = listOf(
444
- ${moduleNames}
445
- )
446
-
447
- companion object {
448
- /**
449
- * Legacy static method for backward compatibility
450
- * @deprecated Use BrickModulesList(context).modules instead
451
- */
452
- @Deprecated(
453
- message = "Use BrickModulesList(context).modules instead",
454
- replaceWith = ReplaceWith("BrickModulesList(context).modules")
455
- )
456
- @JvmStatic
457
- fun getAutolinkedModules(context: ReactContext): MutableList<Any> {
458
- return BrickModulesList(context).modules.toMutableList() as MutableList<Any>
459
- }
460
- }
461
- }
462
- """
463
- }
@@ -20,7 +20,7 @@ open class BrickModuleBase: NSObject {
20
20
 
21
21
  /// Sends an event with the given name and data
22
22
  /// Automatically prefixes with module name and uses the registry's event emitter
23
- public func sendEvent(_ eventName: String, data: [String: Any]?) {
23
+ public func sendEvent(_ eventName: String, data: Any?) {
24
24
  // Format event name with module prefix
25
25
  let fullEventName = "\(moduleName)_\(eventName)"
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brick-module",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Better React Native native module development",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -62,7 +62,7 @@
62
62
  "brick-codegen": "./bin/brick-codegen.js"
63
63
  },
64
64
  "dependencies": {
65
- "brick-codegen": "0.1.18"
65
+ "brick-codegen": "0.1.20"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "react": ">=18.2.0",