brick-module 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/brick_modules.gradle +20 -11
- package/dist/BrickModule.js +3 -5
- package/dist/index.d.ts +2 -1
- package/dist/types.d.ts +4 -0
- package/package.json +2 -2
- package/podfile_helper.rb +24 -26
- package/src/index.ts +1 -0
- package/src/types.ts +1 -0
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Usage: Add to settings.gradle only:
|
|
6
6
|
* apply from: file("../node_modules/brick-module/android/brick_modules.gradle")
|
|
7
|
-
* applyBrickModules(settings)
|
|
7
|
+
* applyBrickModules(settings, [projectRoot: "../", appProject: "app"])
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import groovy.json.JsonSlurper
|
|
@@ -107,19 +107,26 @@ ext.runBrickCodegen = { workingDir ->
|
|
|
107
107
|
// Main Configuration
|
|
108
108
|
// =============================================================================
|
|
109
109
|
|
|
110
|
-
ext.applyBrickModules = { settings, args
|
|
111
|
-
def
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
ext.applyBrickModules = { settings, args ->
|
|
111
|
+
def projectRootPath = args.projectRoot
|
|
112
|
+
def appProjectName = args.appProject
|
|
113
|
+
|
|
114
|
+
if (!projectRootPath) {
|
|
115
|
+
throw new GradleException("Brick: projectRoot is required. Call applyBrickModules(settings, [projectRoot: '../', appProject: 'app'])")
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!appProjectName) {
|
|
119
|
+
throw new GradleException("Brick: appProject is required. Call applyBrickModules(settings, [projectRoot: '../', appProject: 'app'])")
|
|
114
120
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
def
|
|
121
|
+
|
|
122
|
+
// Support relative projectRoot (relative to settings.rootDir)
|
|
123
|
+
def projectRootFile = new File(projectRootPath.toString())
|
|
124
|
+
def projectRoot = (projectRootFile.isAbsolute() ? projectRootFile : new File(settings.rootDir, projectRootFile.path)).canonicalFile
|
|
118
125
|
|
|
119
|
-
// Validate package.json exists in
|
|
126
|
+
// Validate package.json exists in projectRoot
|
|
120
127
|
def packageJsonFile = new File(projectRoot, 'package.json')
|
|
121
128
|
if (!packageJsonFile.exists()) {
|
|
122
|
-
throw new GradleException("Brick: package.json not found at ${projectRoot}. Please pass a valid
|
|
129
|
+
throw new GradleException("Brick: package.json not found at ${projectRoot}. Please pass a valid projectRoot.")
|
|
123
130
|
}
|
|
124
131
|
|
|
125
132
|
def foundModules = []
|
|
@@ -208,14 +215,16 @@ ext.applyBrickModules = { settings, args = [:] ->
|
|
|
208
215
|
gradle.rootProject.ext.brickModulesData = brickModulesData
|
|
209
216
|
gradle.rootProject.ext.brickModulesList = foundModules
|
|
210
217
|
gradle.rootProject.ext.brickProjectRoot = projectRoot
|
|
218
|
+
gradle.rootProject.ext.brickAppProjectName = appProjectName
|
|
211
219
|
configureAppProject(gradle)
|
|
212
220
|
}
|
|
213
221
|
}
|
|
214
222
|
|
|
215
223
|
// Configure the app project
|
|
216
224
|
def configureAppProject(gradle) {
|
|
225
|
+
def appProjectName = gradle.rootProject.ext.brickAppProjectName
|
|
217
226
|
gradle.rootProject.subprojects { project ->
|
|
218
|
-
if (project.name ==
|
|
227
|
+
if (project.name == appProjectName) {
|
|
219
228
|
project.afterEvaluate {
|
|
220
229
|
configureBrickModules(project)
|
|
221
230
|
}
|
package/dist/BrickModule.js
CHANGED
|
@@ -31,10 +31,9 @@ function get(moduleName) {
|
|
|
31
31
|
const nativeModuleInstance = getNativeModule();
|
|
32
32
|
const moduleProxy = new Proxy({}, {
|
|
33
33
|
get: (_target, property) => {
|
|
34
|
-
if (typeof property !== "string") return
|
|
34
|
+
if (typeof property !== "string") return;
|
|
35
35
|
if (property === "addEventListener") return (eventName, listener) => {
|
|
36
|
-
const
|
|
37
|
-
const subscription = emitter.addListener(`${moduleName}_${eventName}`, listener);
|
|
36
|
+
const subscription = getEventEmitter().addListener(`${moduleName}_${eventName}`, listener);
|
|
38
37
|
return () => {
|
|
39
38
|
subscription.remove();
|
|
40
39
|
};
|
|
@@ -63,8 +62,7 @@ function get(moduleName) {
|
|
|
63
62
|
* @returns Promise resolving to array of module names
|
|
64
63
|
*/
|
|
65
64
|
function getRegisteredModules() {
|
|
66
|
-
|
|
67
|
-
return nativeModuleInstance?.getRegisteredModules() ?? [];
|
|
65
|
+
return getNativeModule()?.getRegisteredModules() ?? [];
|
|
68
66
|
}
|
|
69
67
|
/**
|
|
70
68
|
* Clears the module cache (useful for testing or hot reloading)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BrickModule, BrickModuleInterface, BrickModuleSpec } from "./BrickModule.js";
|
|
2
|
+
import { AnyObject } from "./types.js";
|
|
2
3
|
|
|
3
4
|
//#region src/index.d.ts
|
|
4
5
|
|
|
@@ -28,4 +29,4 @@ interface BrickCodegenConfig {
|
|
|
28
29
|
dev?: boolean;
|
|
29
30
|
}
|
|
30
31
|
//#endregion
|
|
31
|
-
export { BrickCodegenConfig, BrickModule, BrickModuleError, type BrickModuleInterface, type BrickModuleSpec };
|
|
32
|
+
export { AnyObject, BrickCodegenConfig, BrickModule, BrickModuleError, type BrickModuleInterface, type BrickModuleSpec };
|
package/dist/types.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brick-module",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
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.
|
|
65
|
+
"brick-codegen": "0.1.11"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"react": ">=18.2.0",
|
package/podfile_helper.rb
CHANGED
|
@@ -20,35 +20,33 @@ def use_brick_modules!(app_path: nil)
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
begin
|
|
23
|
+
# Determine output path first
|
|
24
|
+
ios_brick_path = get_brick_ios_path(brick_root)
|
|
25
|
+
brick_codegen_pod_path = if Pathname.new(ios_brick_path).absolute?
|
|
26
|
+
ios_brick_path
|
|
27
|
+
else
|
|
28
|
+
File.expand_path(File.join(brick_root, ios_brick_path))
|
|
29
|
+
end
|
|
30
|
+
brick_codegen_podspec_path = File.join(brick_codegen_pod_path, 'BrickCodegen.podspec')
|
|
31
|
+
|
|
23
32
|
# Run brick-codegen with real-time output and colors (iOS only)
|
|
24
33
|
exit_status = system("cd #{brick_root} && FORCE_COLOR=1 npx brick-codegen --platform ios --projectRoot \"#{brick_root}\"")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
else
|
|
34
|
-
brick_codegen_pod_path = File.expand_path(File.join(brick_root, ios_brick_path))
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# Add generated BrickCodegen pod if it exists
|
|
38
|
-
brick_codegen_podspec_path = File.join(brick_codegen_pod_path, "BrickCodegen.podspec")
|
|
39
|
-
|
|
40
|
-
if File.exist?(brick_codegen_podspec_path)
|
|
41
|
-
begin
|
|
42
|
-
pod 'BrickCodegen', :path => brick_codegen_pod_path
|
|
43
|
-
rescue => pod_error
|
|
44
|
-
Pod::UI.warn "[Brick] Failed to add BrickCodegen pod: #{pod_error.message}"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
else
|
|
48
|
-
Pod::UI.warn "[Brick] brick-codegen failed to run. Please make sure it's installed: npm install brick-codegen"
|
|
34
|
+
|
|
35
|
+
unless exit_status
|
|
36
|
+
raise "[Brick] brick-codegen failed. Aborting pod install. Try: (cd #{brick_root} && npx brick-codegen --platform ios --debug)"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Require podspec to exist after successful codegen
|
|
40
|
+
unless File.exist?(brick_codegen_podspec_path)
|
|
41
|
+
raise "[Brick] BrickCodegen.podspec not found at #{brick_codegen_pod_path} after codegen"
|
|
49
42
|
end
|
|
43
|
+
|
|
44
|
+
# Link generated BrickCodegen pod
|
|
45
|
+
pod 'BrickCodegen', :path => brick_codegen_pod_path
|
|
46
|
+
Pod::UI.puts "[Brick] Linked BrickCodegen from #{brick_codegen_pod_path}"
|
|
50
47
|
rescue => e
|
|
51
|
-
|
|
48
|
+
# Re-raise so CocoaPods fails the install
|
|
49
|
+
raise e
|
|
52
50
|
end
|
|
53
51
|
end
|
|
54
52
|
|
|
@@ -75,4 +73,4 @@ def get_brick_ios_path(project_root)
|
|
|
75
73
|
end
|
|
76
74
|
|
|
77
75
|
return File.expand_path(File.join(project_root, 'ios/.brick'))
|
|
78
|
-
end
|
|
76
|
+
end
|
package/src/index.ts
CHANGED
package/src/types.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type AnyObject = Record<string, any>;
|