create-react-native-library 0.49.7 → 0.49.9
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/lib/exampleApp/dependencies.js +2 -7
- package/lib/exampleApp/dependencies.js.map +1 -1
- package/lib/exampleApp/generateExampleApp.js +23 -17
- package/lib/exampleApp/generateExampleApp.js.map +1 -1
- package/lib/index.js +23 -28
- package/lib/index.js.map +1 -1
- package/lib/inform.js +37 -47
- package/lib/inform.js.map +1 -1
- package/lib/input.js +2 -14
- package/lib/input.js.map +1 -1
- package/lib/template.js +28 -42
- package/lib/template.js.map +1 -1
- package/lib/utils/local.js +76 -0
- package/lib/utils/local.js.map +1 -0
- package/lib/utils/packageManager.js +13 -0
- package/lib/utils/packageManager.js.map +1 -0
- package/package.json +2 -2
- package/templates/common/$.gitignore +1 -1
- package/templates/common/$package.json +2 -11
- package/templates/common/CONTRIBUTING.md +16 -3
- package/templates/common/babel.config.js +10 -1
- package/templates/common-local/$package.json +1 -3
- package/templates/example-common/example/metro.config.js +0 -2
- package/templates/expo-library/example/metro.config.js +0 -2
- package/templates/native-common/android/build.gradle +5 -31
- package/templates/native-common/android/src/main/AndroidManifest.xml +1 -2
- package/templates/native-common/{%- project.name %}.podspec +3 -13
- package/templates/objc-library/ios/{%- project.name %}.h +1 -13
- package/templates/objc-library/ios/{%- project.name %}.mm +0 -24
- package/templates/objc-view-new/ios/{%- project.name %}View.mm +4 -4
- package/lib/exampleApp/addCodegenBuildScript.js +0 -55
- package/lib/exampleApp/addCodegenBuildScript.js.map +0 -1
- package/templates/cpp-library/android/CMakeLists.txt +0 -16
- package/templates/cpp-library/android/cpp-adapter.cpp +0 -8
- package/templates/cpp-library/cpp/{%- project.identifier %}.cpp +0 -7
- package/templates/cpp-library/cpp/{%- project.identifier %}.h +0 -8
- package/templates/example-module-legacy/example/src/App.tsx +0 -32
- package/templates/kotlin-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.kt +0 -25
- package/templates/kotlin-library-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Package.kt +0 -17
- package/templates/kotlin-view-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Package.kt +0 -17
- package/templates/kotlin-view-legacy/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}ViewManager.kt +0 -20
- package/templates/native-common/android/src/main/AndroidManifestNew.xml +0 -2
- package/templates/native-library-legacy/src/index.tsx +0 -22
- package/templates/native-library-new/react-native.config.js +0 -16
- package/templates/native-view-legacy/src/index.tsx +0 -26
- package/templates/native-view-new/react-native.config.js +0 -16
- package/templates/objc-view-legacy/ios/{%- project.name %}ViewManager.m +0 -34
- package/templates/swift-library-legacy/ios/{%- project.name %}-Bridging-Header.h +0 -2
- package/templates/swift-library-legacy/ios/{%- project.name %}.mm +0 -14
- package/templates/swift-library-legacy/ios/{%- project.name %}.swift +0 -8
- package/templates/swift-view-legacy/ios/{%- project.name %}-Bridging-Header.h +0 -1
- package/templates/swift-view-legacy/ios/{%- project.name %}ViewManager.m +0 -7
- package/templates/swift-view-legacy/ios/{%- project.name %}ViewManager.swift +0 -36
|
@@ -15,7 +15,7 @@ buildscript {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
<% if (project.
|
|
18
|
+
<% if (project.moduleConfig === 'nitro-modules') { -%>
|
|
19
19
|
def reactNativeArchitectures() {
|
|
20
20
|
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
21
21
|
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
@@ -28,47 +28,25 @@ apply plugin: "kotlin-android"
|
|
|
28
28
|
apply from: '../nitrogen/generated/android/<%- project.package_cpp -%>+autolinking.gradle'
|
|
29
29
|
<% } -%>
|
|
30
30
|
|
|
31
|
-
<% if (project.arch === "new") { -%>
|
|
32
31
|
apply plugin: "com.facebook.react"
|
|
33
|
-
<% } -%>
|
|
34
32
|
|
|
35
33
|
def getExtOrIntegerDefault(name) {
|
|
36
34
|
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["<%- project.name -%>_" + name]).toInteger()
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
def supportsNamespace() {
|
|
40
|
-
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
41
|
-
def major = parsed[0].toInteger()
|
|
42
|
-
def minor = parsed[1].toInteger()
|
|
43
|
-
|
|
44
|
-
// Namespace support was added in 7.3.0
|
|
45
|
-
return (major == 7 && minor >= 3) || major >= 8
|
|
46
|
-
}
|
|
47
|
-
|
|
48
37
|
android {
|
|
49
|
-
if (supportsNamespace()) {
|
|
50
38
|
<% if (project.moduleConfig === 'nitro-modules') { -%>
|
|
51
|
-
|
|
39
|
+
namespace "com.margelo.nitro.<%- project.package -%>"
|
|
52
40
|
<% } else { -%>
|
|
53
|
-
|
|
41
|
+
namespace "com.<%- project.package -%>"
|
|
54
42
|
<% } -%>
|
|
55
43
|
|
|
56
|
-
sourceSets {
|
|
57
|
-
main {
|
|
58
|
-
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
<% if (project.cpp) { -%>
|
|
64
|
-
ndkVersion getExtOrDefault("ndkVersion")
|
|
65
|
-
<% } -%>
|
|
66
44
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
67
45
|
|
|
68
46
|
defaultConfig {
|
|
69
47
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
70
48
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
71
|
-
<% if (project.
|
|
49
|
+
<% if (project.moduleConfig === 'nitro-modules') { -%>
|
|
72
50
|
|
|
73
51
|
externalNativeBuild {
|
|
74
52
|
cmake {
|
|
@@ -88,7 +66,7 @@ android {
|
|
|
88
66
|
}
|
|
89
67
|
<% } -%>
|
|
90
68
|
}
|
|
91
|
-
<% if (project.
|
|
69
|
+
<% if (project.moduleConfig === 'nitro-modules') { -%>
|
|
92
70
|
|
|
93
71
|
externalNativeBuild {
|
|
94
72
|
cmake {
|
|
@@ -119,7 +97,6 @@ android {
|
|
|
119
97
|
]
|
|
120
98
|
}
|
|
121
99
|
<% } -%>
|
|
122
|
-
<% if (project.arch === "new") { -%>
|
|
123
100
|
|
|
124
101
|
buildFeatures {
|
|
125
102
|
buildConfig true
|
|
@@ -127,7 +104,6 @@ android {
|
|
|
127
104
|
prefab true
|
|
128
105
|
<% } -%>
|
|
129
106
|
}
|
|
130
|
-
<% } -%>
|
|
131
107
|
|
|
132
108
|
buildTypes {
|
|
133
109
|
release {
|
|
@@ -143,7 +119,6 @@ android {
|
|
|
143
119
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
144
120
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
145
121
|
}
|
|
146
|
-
<% if (project.arch === "new") { -%>
|
|
147
122
|
|
|
148
123
|
sourceSets {
|
|
149
124
|
main {
|
|
@@ -153,7 +128,6 @@ android {
|
|
|
153
128
|
]
|
|
154
129
|
}
|
|
155
130
|
}
|
|
156
|
-
<% } -%>
|
|
157
131
|
}
|
|
158
132
|
|
|
159
133
|
repositories {
|
|
@@ -13,15 +13,11 @@ Pod::Spec.new do |s|
|
|
|
13
13
|
s.platforms = { :ios => min_ios_version_supported }
|
|
14
14
|
s.source = { :git => "<%- repo -%>.git", :tag => "#{s.version}" }
|
|
15
15
|
|
|
16
|
-
<% if (project.
|
|
17
|
-
s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}"
|
|
18
|
-
<% } else if (project.swift) { -%>
|
|
16
|
+
<% if (project.swift) { -%>
|
|
19
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
20
|
-
<% } else
|
|
18
|
+
<% } else { -%>
|
|
21
19
|
s.source_files = "ios/**/*.{h,m,mm,cpp}"
|
|
22
20
|
s.private_header_files = "ios/**/*.h"
|
|
23
|
-
<% } else { -%>
|
|
24
|
-
s.source_files = "ios/**/*.{h,m,mm}"
|
|
25
21
|
<% } -%>
|
|
26
22
|
<% if (project.moduleConfig === "nitro-modules") { -%>
|
|
27
23
|
|
|
@@ -29,11 +25,5 @@ Pod::Spec.new do |s|
|
|
|
29
25
|
add_nitrogen_files(s)
|
|
30
26
|
<% } -%>
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
34
|
-
if respond_to?(:install_modules_dependencies, true)
|
|
35
|
-
install_modules_dependencies(s)
|
|
36
|
-
else
|
|
37
|
-
s.dependency "React-Core"
|
|
38
|
-
end
|
|
28
|
+
install_modules_dependencies(s)
|
|
39
29
|
end
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
#ifdef __cplusplus
|
|
3
|
-
#import "<%- project.identifier -%>.h"
|
|
4
|
-
#endif
|
|
5
|
-
<% } -%>
|
|
6
|
-
|
|
7
|
-
<% if (project.arch === 'new') { -%>
|
|
8
|
-
#import <<%- project.name -%>/RN<%- project.name -%>Spec.h>
|
|
1
|
+
#import <<%- project.name -%>Spec/<%- project.name -%>Spec.h>
|
|
9
2
|
|
|
10
3
|
@interface <%- project.name -%> : NSObject <Native<%- project.name -%>Spec>
|
|
11
|
-
<% } else { -%>
|
|
12
|
-
#import <React/RCTBridgeModule.h>
|
|
13
|
-
|
|
14
|
-
@interface <%- project.name -%> : NSObject <RCTBridgeModule>
|
|
15
|
-
<% } -%>
|
|
16
4
|
|
|
17
5
|
@end
|
|
@@ -4,31 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
RCT_EXPORT_MODULE()
|
|
6
6
|
|
|
7
|
-
<% if (project.arch === 'legacy') { -%>
|
|
8
|
-
// Example method
|
|
9
|
-
// See // https://reactnative.dev/docs/native-modules-ios
|
|
10
|
-
RCT_EXPORT_METHOD(multiply:(double)a
|
|
11
|
-
b:(double)b
|
|
12
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
13
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
14
|
-
{
|
|
15
|
-
<% if (project.cpp) { -%>
|
|
16
|
-
NSNumber *result = @(<%- project.package_cpp -%>::multiply(a, b));
|
|
17
|
-
<% } else { -%>
|
|
18
|
-
NSNumber *result = @(a * b);
|
|
19
|
-
<% } -%>
|
|
20
|
-
|
|
21
|
-
resolve(result);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
<% } -%>
|
|
25
|
-
<% if (project.arch === 'new') { -%>
|
|
26
7
|
- (NSNumber *)multiply:(double)a b:(double)b {
|
|
27
|
-
<% if (project.cpp) { -%>
|
|
28
|
-
NSNumber *result = @(<%- project.package_cpp -%>::multiply(a, b));
|
|
29
|
-
<% } else { -%>
|
|
30
8
|
NSNumber *result = @(a * b);
|
|
31
|
-
<% } -%>
|
|
32
9
|
|
|
33
10
|
return result;
|
|
34
11
|
}
|
|
@@ -38,6 +15,5 @@ RCT_EXPORT_METHOD(multiply:(double)a
|
|
|
38
15
|
{
|
|
39
16
|
return std::make_shared<facebook::react::Native<%- project.name -%>SpecJSI>(params);
|
|
40
17
|
}
|
|
41
|
-
<% } -%>
|
|
42
18
|
|
|
43
19
|
@end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#import "<%- project.name -%>View.h"
|
|
2
2
|
|
|
3
|
-
#import
|
|
4
|
-
#import
|
|
5
|
-
#import
|
|
6
|
-
#import
|
|
3
|
+
#import <react/renderer/components/<%- project.name -%>ViewSpec/ComponentDescriptors.h>
|
|
4
|
+
#import <react/renderer/components/<%- project.name -%>ViewSpec/EventEmitters.h>
|
|
5
|
+
#import <react/renderer/components/<%- project.name -%>ViewSpec/Props.h>
|
|
6
|
+
#import <react/renderer/components/<%- project.name -%>ViewSpec/RCTComponentViewHelpers.h>
|
|
7
7
|
|
|
8
8
|
#import "RCTFabricComponentsPlugins.h"
|
|
9
9
|
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.addCodegenBuildScript = addCodegenBuildScript;
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
// This is added to the example app's build.gradle file to invoke codegen before every build
|
|
11
|
-
const GRADLE_INVOKE_CODEGEN_TASK = `
|
|
12
|
-
// Run Codegen during development for the example app.
|
|
13
|
-
tasks.register('invokeLibraryCodegen', Exec) {
|
|
14
|
-
workingDir "$rootDir/../../"
|
|
15
|
-
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
|
|
16
|
-
|
|
17
|
-
if (isWindows) {
|
|
18
|
-
commandLine 'cmd', '/c', 'npx bob build --target codegen'
|
|
19
|
-
} else {
|
|
20
|
-
commandLine 'sh', '-c', 'npx bob build --target codegen'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
preBuild.dependsOn invokeLibraryCodegen
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
// You need to have the files before calling pod install otherwise they won't be registered in your pod.
|
|
28
|
-
// So we add a pre_install hook to the podfile that invokes codegen
|
|
29
|
-
const PODSPEC_INVOKE_CODEGEN_SCRIPT = `
|
|
30
|
-
# Run Codegen during development for the example app.
|
|
31
|
-
pre_install do |installer|
|
|
32
|
-
system("cd ../../ && npx bob build --target codegen")
|
|
33
|
-
end
|
|
34
|
-
`;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Codegen isn't invoked for libraries with `includesGeneratedCode` set to `true`.
|
|
38
|
-
* This patches the example app to invoke library codegen on every app build.
|
|
39
|
-
*/
|
|
40
|
-
async function addCodegenBuildScript(libraryPath) {
|
|
41
|
-
const appBuildGradlePath = _path.default.join(libraryPath, 'example', 'android', 'app', 'build.gradle');
|
|
42
|
-
const podfilePath = _path.default.join(libraryPath, 'example', 'ios', 'Podfile');
|
|
43
|
-
|
|
44
|
-
// Add a gradle task that runs before every build
|
|
45
|
-
let appBuildGradle = (await _fsExtra.default.readFile(appBuildGradlePath)).toString();
|
|
46
|
-
appBuildGradle += GRADLE_INVOKE_CODEGEN_TASK;
|
|
47
|
-
await _fsExtra.default.writeFile(appBuildGradlePath, appBuildGradle);
|
|
48
|
-
|
|
49
|
-
// Add a preinstall action to the podfile that invokes codegen
|
|
50
|
-
const podfile = (await _fsExtra.default.readFile(podfilePath)).toString().split('\n');
|
|
51
|
-
const podfilePostInstallIndex = podfile.findIndex(line => line.includes('post_install do |installer|'));
|
|
52
|
-
podfile.splice(podfilePostInstallIndex, 0, PODSPEC_INVOKE_CODEGEN_SCRIPT);
|
|
53
|
-
await _fsExtra.default.writeFile(podfilePath, podfile.join('\n'));
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=addCodegenBuildScript.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addCodegenBuildScript.js","names":["_path","_interopRequireDefault","require","_fsExtra","e","__esModule","default","GRADLE_INVOKE_CODEGEN_TASK","PODSPEC_INVOKE_CODEGEN_SCRIPT","addCodegenBuildScript","libraryPath","appBuildGradlePath","path","join","podfilePath","appBuildGradle","fs","readFile","toString","writeFile","podfile","split","podfilePostInstallIndex","findIndex","line","includes","splice"],"sources":["../../src/exampleApp/addCodegenBuildScript.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\n\n// This is added to the example app's build.gradle file to invoke codegen before every build\nconst GRADLE_INVOKE_CODEGEN_TASK = `\n// Run Codegen during development for the example app.\ntasks.register('invokeLibraryCodegen', Exec) {\n workingDir \"$rootDir/../../\"\n def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')\n\n if (isWindows) {\n commandLine 'cmd', '/c', 'npx bob build --target codegen'\n } else {\n commandLine 'sh', '-c', 'npx bob build --target codegen'\n }\n}\n\npreBuild.dependsOn invokeLibraryCodegen\n`;\n\n// You need to have the files before calling pod install otherwise they won't be registered in your pod.\n// So we add a pre_install hook to the podfile that invokes codegen\nconst PODSPEC_INVOKE_CODEGEN_SCRIPT = `\n # Run Codegen during development for the example app.\n pre_install do |installer|\n system(\"cd ../../ && npx bob build --target codegen\")\n end\n`;\n\n/**\n * Codegen isn't invoked for libraries with `includesGeneratedCode` set to `true`.\n * This patches the example app to invoke library codegen on every app build.\n */\nexport async function addCodegenBuildScript(libraryPath: string) {\n const appBuildGradlePath = path.join(\n libraryPath,\n 'example',\n 'android',\n 'app',\n 'build.gradle'\n );\n const podfilePath = path.join(libraryPath, 'example', 'ios', 'Podfile');\n\n // Add a gradle task that runs before every build\n let appBuildGradle = (await fs.readFile(appBuildGradlePath)).toString();\n appBuildGradle += GRADLE_INVOKE_CODEGEN_TASK;\n\n await fs.writeFile(appBuildGradlePath, appBuildGradle);\n\n // Add a preinstall action to the podfile that invokes codegen\n const podfile = (await fs.readFile(podfilePath)).toString().split('\\n');\n const podfilePostInstallIndex = podfile.findIndex((line) =>\n line.includes('post_install do |installer|')\n );\n podfile.splice(podfilePostInstallIndex, 0, PODSPEC_INVOKE_CODEGEN_SCRIPT);\n\n await fs.writeFile(podfilePath, podfile.join('\\n'));\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1B;AACA,MAAMG,0BAA0B,GAAG;AACnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA,MAAMC,6BAA6B,GAAG;AACtC;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;AACO,eAAeC,qBAAqBA,CAACC,WAAmB,EAAE;EAC/D,MAAMC,kBAAkB,GAAGC,aAAI,CAACC,IAAI,CAClCH,WAAW,EACX,SAAS,EACT,SAAS,EACT,KAAK,EACL,cACF,CAAC;EACD,MAAMI,WAAW,GAAGF,aAAI,CAACC,IAAI,CAACH,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,CAAC;;EAEvE;EACA,IAAIK,cAAc,GAAG,CAAC,MAAMC,gBAAE,CAACC,QAAQ,CAACN,kBAAkB,CAAC,EAAEO,QAAQ,CAAC,CAAC;EACvEH,cAAc,IAAIR,0BAA0B;EAE5C,MAAMS,gBAAE,CAACG,SAAS,CAACR,kBAAkB,EAAEI,cAAc,CAAC;;EAEtD;EACA,MAAMK,OAAO,GAAG,CAAC,MAAMJ,gBAAE,CAACC,QAAQ,CAACH,WAAW,CAAC,EAAEI,QAAQ,CAAC,CAAC,CAACG,KAAK,CAAC,IAAI,CAAC;EACvE,MAAMC,uBAAuB,GAAGF,OAAO,CAACG,SAAS,CAAEC,IAAI,IACrDA,IAAI,CAACC,QAAQ,CAAC,6BAA6B,CAC7C,CAAC;EACDL,OAAO,CAACM,MAAM,CAACJ,uBAAuB,EAAE,CAAC,EAAEd,6BAA6B,CAAC;EAEzE,MAAMQ,gBAAE,CAACG,SAAS,CAACL,WAAW,EAAEM,OAAO,CAACP,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.4.1)
|
|
2
|
-
project(<%- project.name -%>)
|
|
3
|
-
|
|
4
|
-
set (CMAKE_VERBOSE_MAKEFILE ON)
|
|
5
|
-
set (CMAKE_CXX_STANDARD 14)
|
|
6
|
-
|
|
7
|
-
add_library(<%- project.identifier -%>
|
|
8
|
-
SHARED
|
|
9
|
-
../cpp/<%- project.identifier -%>.cpp
|
|
10
|
-
cpp-adapter.cpp
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
# Specifies a path to native header files.
|
|
14
|
-
include_directories(
|
|
15
|
-
../cpp
|
|
16
|
-
)
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#include <jni.h>
|
|
2
|
-
#include "<%- project.identifier -%>.h"
|
|
3
|
-
|
|
4
|
-
extern "C"
|
|
5
|
-
JNIEXPORT jdouble JNICALL
|
|
6
|
-
Java_com_<%- project.package_cpp -%>_<%- project.name -%>Module_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
|
|
7
|
-
return <%- project.package_cpp -%>::multiply(a, b);
|
|
8
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { multiply } from '<%- project.slug -%>';
|
|
2
|
-
import { Text, View, StyleSheet } from 'react-native';
|
|
3
|
-
<% if (project.native) { -%>
|
|
4
|
-
import { useState, useEffect } from 'react';
|
|
5
|
-
|
|
6
|
-
export default function App() {
|
|
7
|
-
const [result, setResult] = useState<number | undefined>();
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
multiply(3, 7).then(setResult);
|
|
11
|
-
}, []);
|
|
12
|
-
|
|
13
|
-
<% } else { -%>
|
|
14
|
-
|
|
15
|
-
const result = multiply(3, 7);
|
|
16
|
-
|
|
17
|
-
export default function App() {
|
|
18
|
-
<% } -%>
|
|
19
|
-
return (
|
|
20
|
-
<View style={styles.container}>
|
|
21
|
-
<Text>Result: {result}</Text>
|
|
22
|
-
</View>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const styles = StyleSheet.create({
|
|
27
|
-
container: {
|
|
28
|
-
flex: 1,
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
justifyContent: 'center',
|
|
31
|
-
},
|
|
32
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package com.<%- project.package %>
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
-
import com.facebook.react.bridge.ReactMethod
|
|
6
|
-
import com.facebook.react.bridge.Promise
|
|
7
|
-
|
|
8
|
-
class <%- project.name -%>Module(reactContext: ReactApplicationContext) :
|
|
9
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
10
|
-
|
|
11
|
-
override fun getName(): String {
|
|
12
|
-
return NAME
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Example method
|
|
16
|
-
// See https://reactnative.dev/docs/native-modules-android
|
|
17
|
-
@ReactMethod
|
|
18
|
-
fun multiply(a: Double, b: Double, promise: Promise) {
|
|
19
|
-
promise.resolve(a * b)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
companion object {
|
|
23
|
-
const val NAME = "<%- project.name -%>"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package com.<%- project.package %>
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage
|
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.uimanager.ViewManager
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class <%- project.name -%>Package : ReactPackage {
|
|
10
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
-
return listOf(<%- project.name -%>Module(reactContext))
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
-
return emptyList()
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
package com.<%- project.package %>
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage
|
|
4
|
-
import com.facebook.react.bridge.NativeModule
|
|
5
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
-
import com.facebook.react.uimanager.ViewManager
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class <%- project.name -%>Package : ReactPackage {
|
|
10
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
11
|
-
return emptyList()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
15
|
-
return listOf(<%- project.name -%>ViewManager())
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
package com.<%- project.package %>
|
|
2
|
-
|
|
3
|
-
import android.graphics.Color
|
|
4
|
-
import android.view.View
|
|
5
|
-
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
7
|
-
import com.facebook.react.uimanager.annotations.ReactProp
|
|
8
|
-
|
|
9
|
-
class <%- project.name -%>ViewManager : SimpleViewManager<View>() {
|
|
10
|
-
override fun getName() = "<%- project.name -%>View"
|
|
11
|
-
|
|
12
|
-
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
13
|
-
return View(reactContext)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@ReactProp(name = "color")
|
|
17
|
-
fun setColor(view: View, color: String) {
|
|
18
|
-
view.setBackgroundColor(Color.parseColor(color))
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { NativeModules, Platform } from 'react-native';
|
|
2
|
-
|
|
3
|
-
const LINKING_ERROR =
|
|
4
|
-
`The package '<%- project.slug -%>' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
-
'- You rebuilt the app after installing the package\n' +
|
|
7
|
-
'- You are not using Expo Go\n';
|
|
8
|
-
|
|
9
|
-
const <%- project.name -%> = NativeModules.<%- project.name %>
|
|
10
|
-
? NativeModules.<%- project.name %>
|
|
11
|
-
: new Proxy(
|
|
12
|
-
{},
|
|
13
|
-
{
|
|
14
|
-
get() {
|
|
15
|
-
throw new Error(LINKING_ERROR);
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export function multiply(a: number, b: number): Promise<number> {
|
|
21
|
-
return <%- project.name -%>.multiply(a, b);
|
|
22
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @type {import('@react-native-community/cli-types').UserDependencyConfig}
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
dependency: {
|
|
6
|
-
platforms: {
|
|
7
|
-
android: {
|
|
8
|
-
<%_ if (example === 'vanilla') { -%>
|
|
9
|
-
cmakeListsPath: 'generated/jni/CMakeLists.txt',
|
|
10
|
-
<%_ } else { -%>
|
|
11
|
-
cmakeListsPath: 'build/generated/source/codegen/jni/CMakeLists.txt',
|
|
12
|
-
<%_ } -%>
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
requireNativeComponent,
|
|
3
|
-
UIManager,
|
|
4
|
-
Platform,
|
|
5
|
-
type ViewStyle,
|
|
6
|
-
} from 'react-native';
|
|
7
|
-
|
|
8
|
-
const LINKING_ERROR =
|
|
9
|
-
`The package '<%- project.slug -%>' doesn't seem to be linked. Make sure: \n\n` +
|
|
10
|
-
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
11
|
-
'- You rebuilt the app after installing the package\n' +
|
|
12
|
-
'- You are not using Expo Go\n';
|
|
13
|
-
|
|
14
|
-
type <%- project.name -%>Props = {
|
|
15
|
-
color: string;
|
|
16
|
-
style: ViewStyle;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const ComponentName = '<%- project.name -%>View';
|
|
20
|
-
|
|
21
|
-
export const <%- project.name -%>View =
|
|
22
|
-
UIManager.getViewManagerConfig(ComponentName) != null
|
|
23
|
-
? requireNativeComponent<<%- project.name -%>Props>(ComponentName)
|
|
24
|
-
: () => {
|
|
25
|
-
throw new Error(LINKING_ERROR);
|
|
26
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @type {import('@react-native-community/cli-types').UserDependencyConfig}
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
dependency: {
|
|
6
|
-
platforms: {
|
|
7
|
-
android: {
|
|
8
|
-
<%_ if (example === 'vanilla') { -%>
|
|
9
|
-
cmakeListsPath: 'generated/jni/CMakeLists.txt',
|
|
10
|
-
<%_ } else { -%>
|
|
11
|
-
cmakeListsPath: 'build/generated/source/codegen/jni/CMakeLists.txt',
|
|
12
|
-
<%_ } -%>
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#import <React/RCTViewManager.h>
|
|
2
|
-
|
|
3
|
-
@interface <%- project.name -%>ViewManager : RCTViewManager
|
|
4
|
-
@end
|
|
5
|
-
|
|
6
|
-
@implementation <%- project.name -%>ViewManager
|
|
7
|
-
|
|
8
|
-
RCT_EXPORT_MODULE(<%- project.name -%>View)
|
|
9
|
-
|
|
10
|
-
- (UIView *)view
|
|
11
|
-
{
|
|
12
|
-
return [[UIView alloc] init];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
RCT_CUSTOM_VIEW_PROPERTY(color, NSString, UIView)
|
|
16
|
-
{
|
|
17
|
-
[view setBackgroundColor:[self hexStringToColor:json]];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
- hexStringToColor:(NSString *)stringToConvert
|
|
21
|
-
{
|
|
22
|
-
NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
|
|
23
|
-
NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
|
|
24
|
-
|
|
25
|
-
unsigned hex;
|
|
26
|
-
if (![stringScanner scanHexInt:&hex]) return nil;
|
|
27
|
-
int r = (hex >> 16) & 0xFF;
|
|
28
|
-
int g = (hex >> 8) & 0xFF;
|
|
29
|
-
int b = (hex) & 0xFF;
|
|
30
|
-
|
|
31
|
-
return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#import <React/RCTBridgeModule.h>
|
|
2
|
-
|
|
3
|
-
@interface RCT_EXTERN_MODULE(<%- project.name -%>, NSObject)
|
|
4
|
-
|
|
5
|
-
RCT_EXTERN_METHOD(multiply:(float)a withB:(float)b
|
|
6
|
-
withResolver:(RCTPromiseResolveBlock)resolve
|
|
7
|
-
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
8
|
-
|
|
9
|
-
+ (BOOL)requiresMainQueueSetup
|
|
10
|
-
{
|
|
11
|
-
return NO;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#import <React/RCTViewManager.h>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
@objc(<%- project.name -%>ViewManager)
|
|
2
|
-
class <%- project.name -%>ViewManager: RCTViewManager {
|
|
3
|
-
|
|
4
|
-
override func view() -> (<%- project.name -%>View) {
|
|
5
|
-
return <%- project.name -%>View()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
@objc override static func requiresMainQueueSetup() -> Bool {
|
|
9
|
-
return false
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class <%- project.name -%>View : UIView {
|
|
14
|
-
|
|
15
|
-
@objc var color: String = "" {
|
|
16
|
-
didSet {
|
|
17
|
-
self.backgroundColor = hexStringToUIColor(hexColor: color)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
func hexStringToUIColor(hexColor: String) -> UIColor {
|
|
22
|
-
let stringScanner = Scanner(string: hexColor)
|
|
23
|
-
|
|
24
|
-
if(hexColor.hasPrefix("#")) {
|
|
25
|
-
stringScanner.scanLocation = 1
|
|
26
|
-
}
|
|
27
|
-
var color: UInt32 = 0
|
|
28
|
-
stringScanner.scanHexInt32(&color)
|
|
29
|
-
|
|
30
|
-
let r = CGFloat(Int(color >> 16) & 0x000000FF)
|
|
31
|
-
let g = CGFloat(Int(color >> 8) & 0x000000FF)
|
|
32
|
-
let b = CGFloat(Int(color) & 0x000000FF)
|
|
33
|
-
|
|
34
|
-
return UIColor(red: r / 255.0, green: g / 255.0, blue: b / 255.0, alpha: 1)
|
|
35
|
-
}
|
|
36
|
-
}
|