create-react-native-library 0.44.2 → 0.45.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 (60) hide show
  1. package/lib/{utils → exampleApp}/addCodegenBuildScript.js +8 -2
  2. package/lib/exampleApp/addCodegenBuildScript.js.map +1 -0
  3. package/lib/exampleApp/dependencies.js +32 -0
  4. package/lib/exampleApp/dependencies.js.map +1 -0
  5. package/lib/{utils → exampleApp}/generateExampleApp.js +2 -2
  6. package/lib/exampleApp/generateExampleApp.js.map +1 -0
  7. package/lib/index.js +91 -624
  8. package/lib/index.js.map +1 -1
  9. package/lib/inform.js +91 -0
  10. package/lib/inform.js.map +1 -0
  11. package/lib/input.js +266 -0
  12. package/lib/input.js.map +1 -0
  13. package/lib/template.js +175 -0
  14. package/lib/template.js.map +1 -0
  15. package/lib/utils/assert.js +59 -0
  16. package/lib/utils/assert.js.map +1 -0
  17. package/lib/utils/initialCommit.js +34 -0
  18. package/lib/utils/initialCommit.js.map +1 -0
  19. package/lib/utils/promiseWithFallback.js +25 -0
  20. package/lib/utils/promiseWithFallback.js.map +1 -0
  21. package/package.json +2 -2
  22. package/templates/common/$package.json +2 -2
  23. package/templates/common/CONTRIBUTING.md +0 -25
  24. package/templates/common/babel.config.js +1 -3
  25. package/templates/common/tsconfig.json +1 -0
  26. package/templates/common-local/$package.json +1 -1
  27. package/templates/example-module-legacy/example/src/App.tsx +25 -0
  28. package/templates/example-module-new/example/src/App.tsx +20 -0
  29. package/templates/example-view/example/src/App.tsx +23 -0
  30. package/templates/js-library/src/index.tsx +2 -2
  31. package/templates/kotlin-library-new/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Package.kt +2 -2
  32. package/templates/native-common/android/build.gradle +3 -19
  33. package/templates/objc-library/ios/{%- project.name %}.h +4 -4
  34. package/templates/objc-library/ios/{%- project.name %}.mm +1 -6
  35. package/templates/objc-view-new/ios/{%- project.name %}View.h +0 -3
  36. package/templates/objc-view-new/ios/{%- project.name %}View.mm +6 -6
  37. package/lib/utils/addCodegenBuildScript.js.map +0 -1
  38. package/lib/utils/generateExampleApp.js.map +0 -1
  39. package/templates/common-example/example/src/App.tsx +0 -57
  40. package/templates/kotlin-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Module.kt +0 -24
  41. package/templates/kotlin-library-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Package.kt +0 -35
  42. package/templates/kotlin-library-mixed/android/src/newarch/{%- project.name %}Spec.kt +0 -7
  43. package/templates/kotlin-library-mixed/android/src/oldarch/{%- project.name %}Spec.kt +0 -11
  44. package/templates/kotlin-view-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}Package.kt +0 -19
  45. package/templates/kotlin-view-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}View.kt +0 -15
  46. package/templates/kotlin-view-mixed/android/src/main/java/com/{%- project.package_dir %}/{%- project.name %}ViewManager.kt +0 -28
  47. package/templates/kotlin-view-mixed/android/src/newarch/{%- project.name %}ViewManagerSpec.kt +0 -21
  48. package/templates/kotlin-view-mixed/android/src/oldarch/{%- project.name %}ViewManagerSpec.kt +0 -9
  49. package/templates/native-library-mixed/react-native.config.js +0 -16
  50. package/templates/native-library-mixed/src/Native{%- project.name %}.ts +0 -8
  51. package/templates/native-library-mixed/src/index.tsx +0 -29
  52. package/templates/native-view-mixed/react-native.config.js +0 -16
  53. package/templates/native-view-mixed/src/index.tsx +0 -2
  54. package/templates/native-view-mixed/src/{%- project.name %}ViewNativeComponent.ts +0 -8
  55. package/templates/objc-view-mixed/ios/Utils.h +0 -8
  56. package/templates/objc-view-mixed/ios/Utils.m +0 -26
  57. package/templates/objc-view-mixed/ios/{%- project.name %}View.h +0 -17
  58. package/templates/objc-view-mixed/ios/{%- project.name %}View.mm +0 -60
  59. package/templates/objc-view-mixed/ios/{%- project.name %}ViewManager.mm +0 -23
  60. /package/templates/{common-example → example-common}/example/metro.config.js +0 -0
@@ -1,5 +1,3 @@
1
- // This guard prevent this file to be compiled in the old architecture.
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
1
  #import <React/RCTViewComponentView.h>
4
2
  #import <UIKit/UIKit.h>
5
3
 
@@ -14,4 +12,3 @@ NS_ASSUME_NONNULL_BEGIN
14
12
  NS_ASSUME_NONNULL_END
15
13
 
16
14
  #endif /* <%- project.name -%>ViewNativeComponent_h */
17
- #endif /* RCT_NEW_ARCH_ENABLED */
@@ -1,9 +1,9 @@
1
1
  #import "<%- project.name -%>View.h"
2
2
 
3
- #import "ComponentDescriptors.h"
4
- #import "EventEmitters.h"
5
- #import "Props.h"
6
- #import "RCTComponentViewHelpers.h"
3
+ #import "generated/RN<%- project.name -%>ViewSpec/ComponentDescriptors.h"
4
+ #import "generated/RN<%- project.name -%>ViewSpec/EventEmitters.h"
5
+ #import "generated/RN<%- project.name -%>ViewSpec/Props.h"
6
+ #import "generated/RN<%- project.name -%>ViewSpec/RCTComponentViewHelpers.h"
7
7
 
8
8
  #import "RCTFabricComponentsPlugins.h"
9
9
 
@@ -58,13 +58,13 @@ Class<RCTComponentViewProtocol> <%- project.name -%>ViewCls(void)
58
58
  {
59
59
  NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
60
60
  NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
61
-
61
+
62
62
  unsigned hex;
63
63
  if (![stringScanner scanHexInt:&hex]) return nil;
64
64
  int r = (hex >> 16) & 0xFF;
65
65
  int g = (hex >> 8) & 0xFF;
66
66
  int b = (hex) & 0xFF;
67
-
67
+
68
68
  return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
69
69
  }
70
70
 
@@ -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/utils/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 = `\ndef isNewArchitectureEnabled() {\n return rootProject.hasProperty(\"newArchEnabled\") && rootProject.getProperty(\"newArchEnabled\") == \"true\"\n}\n\nif (isNewArchitectureEnabled()) {\n // Since our library doesn't invoke codegen automatically we need to do it here.\n tasks.register('invokeLibraryCodegen', Exec) {\n workingDir \"$rootDir/../../\"\n commandLine \"npx\", \"bob\", \"build\", \"--target\", \"codegen\"\n }\n preBuild.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 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(pod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AE,CAACG,SAAS,CAACL,WAAW,EAAEM,OAAO,CAACP,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generateExampleApp.js","names":["_fsExtra","_interopRequireDefault","require","_path","_https","_spawn","_sortObjectKeys","e","__esModule","default","FILES_TO_DELETE","PACKAGES_TO_REMOVE","PACKAGES_TO_ADD_WEB","generateExampleApp","type","dest","arch","project","bobVersion","reactNativeVersion","directory","path","join","testAppArgs","name","vanillaArgs","package","expoArgs","args","spawn","env","process","npm_config_yes","file","fs","remove","pkg","readJSON","slug","jest","scripts","dependencies","devDependencies","test","lint","SCRIPTS_TO_ADD","Object","assign","androidBuild","iosBuild","app","android","ios","bundleIdentifier","writeJSON","spaces","forEach","PACKAGES_TO_ADD_DEV","sdkVersion","expo","split","replace","bundledNativeModules","Promise","resolve","reject","https","get","res","data","on","chunk","JSON","parse","entries","version","web","field","sortObjectKeys","gradleProperties","readFile","podfile","writeFile","includes"],"sources":["../../src/utils/generateExampleApp.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport https from 'https';\nimport { spawn } from './spawn';\nimport sortObjectKeys from './sortObjectKeys';\n\nexport type ExampleType = 'vanilla' | 'test-app' | 'expo' | 'none';\n\nconst FILES_TO_DELETE = [\n '__tests__',\n '.buckconfig',\n '.eslintrc.js',\n '.flowconfig',\n '.git',\n '.gitignore',\n '.prettierrc.js',\n 'App.js',\n 'App.tsx',\n 'index.js',\n 'tsconfig.json',\n];\n\nconst PACKAGES_TO_REMOVE = [\n '@react-native/eslint-config',\n '@tsconfig/react-native',\n '@types/jest',\n '@types/react',\n '@types/react-test-renderer',\n '@typescript-eslint/eslint-plugin',\n '@typescript-eslint/parser',\n 'babel-jest',\n 'eslint',\n 'jest',\n 'prettier',\n 'react-test-renderer',\n 'typescript',\n];\n\nconst PACKAGES_TO_ADD_WEB = {\n '@expo/metro-runtime': '~3.2.1',\n 'react-dom': '18.2.0',\n 'react-native-web': '~0.18.10',\n};\n\nexport default async function generateExampleApp({\n type,\n dest,\n arch,\n project,\n bobVersion,\n reactNativeVersion = 'latest',\n}: {\n type: ExampleType;\n dest: string;\n arch: 'new' | 'mixed' | 'legacy';\n project: {\n slug: string;\n name: string;\n package: string;\n };\n bobVersion: string;\n reactNativeVersion?: string;\n}) {\n const directory = path.join(dest, 'example');\n\n // `npx --package react-native-test-app@latest init --name ${projectName}Example --destination example --version ${reactNativeVersion}`\n const testAppArgs = [\n '--package',\n `react-native-test-app@latest`,\n 'init',\n '--name',\n `${project.name}Example`,\n `--destination`,\n directory,\n ...(reactNativeVersion !== 'latest'\n ? ['--version', reactNativeVersion]\n : []),\n '--platform',\n 'ios',\n '--platform',\n 'android',\n ];\n\n // `npx @react-native-community/cli init <projectName> --directory example --skip-install`\n const vanillaArgs = [\n `@react-native-community/cli`,\n 'init',\n `${project.name}Example`,\n '--package-name',\n `${project.package}.example`,\n '--directory',\n directory,\n '--version',\n reactNativeVersion,\n '--skip-install',\n '--pm',\n 'npm',\n ];\n\n // `npx create-expo-app example --no-install --template blank`\n const expoArgs = [\n 'create-expo-app@latest',\n directory,\n '--no-install',\n '--template',\n 'blank',\n ];\n\n let args: string[] = [];\n\n switch (type) {\n case 'vanilla':\n args = vanillaArgs;\n break;\n case 'test-app':\n args = testAppArgs;\n break;\n case 'expo':\n args = expoArgs;\n break;\n }\n\n await spawn('npx', args, {\n env: { ...process.env, npm_config_yes: 'true' },\n });\n\n // Remove unnecessary files and folders\n for (const file of FILES_TO_DELETE) {\n await fs.remove(path.join(directory, file));\n }\n\n // Patch the example app's package.json\n const pkg = await fs.readJSON(path.join(directory, 'package.json'));\n\n pkg.name = `${project.slug}-example`;\n\n // Remove Jest config for now\n delete pkg.jest;\n\n const { scripts, dependencies, devDependencies } = pkg;\n\n delete scripts.test;\n delete scripts.lint;\n\n const SCRIPTS_TO_ADD = {\n 'build:android':\n 'react-native build-android --extra-params \"--no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a\"',\n 'build:ios': `react-native build-ios --scheme ${project.name}Example --mode Debug --extra-params \"-sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO\"`,\n };\n\n if (type === 'vanilla') {\n Object.assign(scripts, SCRIPTS_TO_ADD);\n } else if (type === 'test-app') {\n // `react-native-test-app` doesn't bundle application by default in 'Release' mode and also `bundle` command doesn't create a directory.\n // `mkdist` script should be removed after stable React Native major contains this fix: https://github.com/facebook/react-native/pull/45182.\n\n const androidBuild = [\n 'npm run mkdist',\n 'react-native bundle --entry-file index.js --platform android --dev true --bundle-output dist/main.android.jsbundle --assets-dest dist',\n SCRIPTS_TO_ADD['build:android'],\n ].join(' && ');\n\n const iosBuild = [\n 'npm run mkdist',\n 'react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist',\n SCRIPTS_TO_ADD['build:ios'],\n ].join(' && ');\n\n Object.assign(scripts, {\n 'build:android': androidBuild,\n 'build:ios': iosBuild,\n });\n\n const app = await fs.readJSON(path.join(directory, 'app.json'));\n\n app.android = app.android || {};\n app.android.package = `${project.package}.example`;\n app.ios = app.ios || {};\n app.ios.bundleIdentifier = `${project.package}.example`;\n\n await fs.writeJSON(path.join(directory, 'app.json'), app, {\n spaces: 2,\n });\n }\n\n PACKAGES_TO_REMOVE.forEach((name) => {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete devDependencies[name];\n });\n\n const PACKAGES_TO_ADD_DEV = {\n 'react-native-builder-bob': `^${bobVersion}`,\n };\n\n Object.assign(devDependencies, PACKAGES_TO_ADD_DEV);\n\n if (type === 'expo') {\n const sdkVersion = dependencies.expo.split('.')[0].replace(/[^\\d]/, '');\n\n let bundledNativeModules: Record<string, string>;\n\n try {\n bundledNativeModules = await new Promise((resolve, reject) => {\n https\n .get(\n `https://raw.githubusercontent.com/expo/expo/sdk-${sdkVersion}/packages/expo/bundledNativeModules.json`,\n (res) => {\n let data = '';\n\n res.on('data', (chunk) => (data += chunk));\n res.on('end', () => {\n try {\n resolve(JSON.parse(data));\n } catch (e) {\n reject(e);\n }\n });\n }\n )\n .on('error', reject);\n });\n } catch (e) {\n bundledNativeModules = {};\n }\n\n Object.entries(PACKAGES_TO_ADD_WEB).forEach(([name, version]) => {\n dependencies[name] = bundledNativeModules[name] || version;\n });\n\n scripts.web = 'expo start --web';\n\n const app = await fs.readJSON(path.join(directory, 'app.json'));\n\n app.expo.android = app.expo.android || {};\n app.expo.android.package = `${project.package}.example`;\n app.expo.ios = app.expo.ios || {};\n app.expo.ios.bundleIdentifier = `${project.package}.example`;\n\n await fs.writeJSON(path.join(directory, 'app.json'), app, {\n spaces: 2,\n });\n }\n\n for (const field of ['dependencies', 'devDependencies']) {\n if (pkg[field]) {\n pkg[field] = sortObjectKeys(pkg[field]);\n }\n }\n\n await fs.writeJSON(path.join(directory, 'package.json'), pkg, {\n spaces: 2,\n });\n\n if (type !== 'expo') {\n let gradleProperties = await fs.readFile(\n path.join(directory, 'android', 'gradle.properties'),\n 'utf8'\n );\n\n // Disable Jetifier.\n // Remove this when the app template is updated.\n gradleProperties = gradleProperties.replace(\n 'android.enableJetifier=true',\n 'android.enableJetifier=false'\n );\n\n // If the library is on new architecture, enable new arch for iOS and Android\n if (arch === 'new') {\n // iOS\n // Add ENV['RCT_NEW_ARCH_ENABLED'] = 1 on top of example/ios/Podfile\n const podfile = await fs.readFile(\n path.join(directory, 'ios', 'Podfile'),\n 'utf8'\n );\n\n await fs.writeFile(\n path.join(directory, 'ios', 'Podfile'),\n \"ENV['RCT_NEW_ARCH_ENABLED'] = '1'\\n\\n\" + podfile\n );\n\n // Android\n // Make sure newArchEnabled=true is present in android/gradle.properties\n if (gradleProperties.split('\\n').includes('#newArchEnabled=true')) {\n gradleProperties = gradleProperties.replace(\n '#newArchEnabled=true',\n 'newArchEnabled=true'\n );\n } else if (\n gradleProperties.split('\\n').includes('newArchEnabled=false')\n ) {\n gradleProperties = gradleProperties.replace(\n 'newArchEnabled=false',\n 'newArchEnabled=true'\n );\n } else {\n gradleProperties += '\\nnewArchEnabled=true';\n }\n }\n\n await fs.writeFile(\n path.join(directory, 'android', 'gradle.properties'),\n gradleProperties\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAL,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAI9C,MAAMG,eAAe,GAAG,CACtB,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,MAAM,EACN,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,UAAU,EACV,eAAe,CAChB;AAED,MAAMC,kBAAkB,GAAG,CACzB,6BAA6B,EAC7B,wBAAwB,EACxB,aAAa,EACb,cAAc,EACd,4BAA4B,EAC5B,kCAAkC,EAClC,2BAA2B,EAC3B,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,UAAU,EACV,qBAAqB,EACrB,YAAY,CACb;AAED,MAAMC,mBAAmB,GAAG;EAC1B,qBAAqB,EAAE,QAAQ;EAC/B,WAAW,EAAE,QAAQ;EACrB,kBAAkB,EAAE;AACtB,CAAC;AAEc,eAAeC,kBAAkBA,CAAC;EAC/CC,IAAI;EACJC,IAAI;EACJC,IAAI;EACJC,OAAO;EACPC,UAAU;EACVC,kBAAkB,GAAG;AAYvB,CAAC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,uBAAuB;MAC7C;IACF;IAEA,MAAM7C,gBAAE,CAACgD,SAAS,CAChB7D,aAAI,CAACC,IAAI,CAACF,SAAS,EAAE,SAAS,EAAE,mBAAmB,CAAC,EACpD2D,gBACF,CAAC;EACH;AACF","ignoreList":[]}
@@ -1,57 +0,0 @@
1
- <% if (project.view) { -%>
2
- import { StyleSheet, View } from 'react-native';
3
- import { <%- project.name -%>View } from '<%- project.slug -%>';
4
- <% } else { -%>
5
- <% if (project.arch !== 'new') { -%>
6
- import { useState, useEffect } from 'react';
7
- <% } -%>
8
- import { StyleSheet, View, Text } from 'react-native';
9
- import { multiply } from '<%- project.slug -%>';
10
- <% } -%>
11
-
12
- <% if (project.view) { -%>
13
- export default function App() {
14
- return (
15
- <View style={styles.container}>
16
- <<%- project.name -%>View color="#32a852" style={styles.box} />
17
- </View>
18
- );
19
- }
20
- <% } else if (project.arch === 'new' && project.module) { -%>
21
- const result = multiply(3, 7);
22
-
23
- export default function App() {
24
- return (
25
- <View style={styles.container}>
26
- <Text>Result: {result}</Text>
27
- </View>
28
- );
29
- }
30
- <% } else { -%>
31
- export default function App() {
32
- const [result, setResult] = useState<number | undefined>();
33
-
34
- useEffect(() => {
35
- multiply(3, 7).then(setResult);
36
- }, []);
37
-
38
- return (
39
- <View style={styles.container}>
40
- <Text>Result: {result}</Text>
41
- </View>
42
- );
43
- }
44
- <% } -%>
45
-
46
- const styles = StyleSheet.create({
47
- container: {
48
- flex: 1,
49
- alignItems: 'center',
50
- justifyContent: 'center',
51
- },
52
- box: {
53
- width: 60,
54
- height: 60,
55
- marginVertical: 20,
56
- },
57
- });
@@ -1,24 +0,0 @@
1
- package com.<%- project.package %>
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
- import com.facebook.react.bridge.ReactMethod
5
- import com.facebook.react.bridge.Promise
6
-
7
- class <%- project.name -%>Module internal constructor(context: ReactApplicationContext) :
8
- <%- project.name -%>Spec(context) {
9
-
10
- override fun getName(): String {
11
- return NAME
12
- }
13
-
14
- // Example method
15
- // See https://reactnative.dev/docs/native-modules-android
16
- @ReactMethod
17
- override fun multiply(a: Double, b: Double, promise: Promise) {
18
- promise.resolve(a * b)
19
- }
20
-
21
- companion object {
22
- const val NAME = "<%- project.name -%>"
23
- }
24
- }
@@ -1,35 +0,0 @@
1
- package com.<%- project.package %>
2
-
3
- import com.facebook.react.TurboReactPackage
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.facebook.react.bridge.NativeModule
6
- import com.facebook.react.module.model.ReactModuleInfoProvider
7
- import com.facebook.react.module.model.ReactModuleInfo
8
- import java.util.HashMap
9
-
10
- class <%- project.name -%>Package : TurboReactPackage() {
11
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
- return if (name == <%- project.name -%>Module.NAME) {
13
- <%- project.name -%>Module(reactContext)
14
- } else {
15
- null
16
- }
17
- }
18
-
19
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
- return ReactModuleInfoProvider {
21
- val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
22
- val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
23
- moduleInfos[<%- project.name -%>Module.NAME] = ReactModuleInfo(
24
- <%- project.name -%>Module.NAME,
25
- <%- project.name -%>Module.NAME,
26
- false, // canOverrideExistingModule
27
- false, // needsEagerInit
28
- true, // hasConstants
29
- false, // isCxxModule
30
- isTurboModule // isTurboModule
31
- )
32
- moduleInfos
33
- }
34
- }
35
- }
@@ -1,7 +0,0 @@
1
- package com.<%- project.package %>
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
-
5
- abstract class <%- project.name -%>Spec internal constructor(context: ReactApplicationContext) :
6
- Native<%- project.name -%>Spec(context) {
7
- }
@@ -1,11 +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.Promise
6
-
7
- abstract class <%- project.name -%>Spec internal constructor(context: ReactApplicationContext) :
8
- ReactContextBaseJavaModule(context) {
9
-
10
- abstract fun multiply(a: Double, b: Double, promise: Promise)
11
- }
@@ -1,19 +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
- import java.util.ArrayList
8
-
9
- class <%- project.name -%>ViewPackage : ReactPackage {
10
- override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
11
- val viewManagers: MutableList<ViewManager<*, *>> = ArrayList()
12
- viewManagers.add(<%- project.name -%>ViewManager())
13
- return viewManagers
14
- }
15
-
16
- override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
17
- return emptyList()
18
- }
19
- }
@@ -1,15 +0,0 @@
1
- package com.<%- project.package %>
2
-
3
- import android.content.Context
4
- import android.util.AttributeSet
5
- import android.view.View
6
-
7
- class <%- project.name -%>View : View {
8
- constructor(context: Context?) : super(context)
9
- constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
10
- constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
11
- context,
12
- attrs,
13
- defStyleAttr
14
- )
15
- }
@@ -1,28 +0,0 @@
1
- package com.<%- project.package %>
2
-
3
- import android.graphics.Color
4
- import com.facebook.react.module.annotations.ReactModule
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.ThemedReactContext
7
- import com.facebook.react.uimanager.annotations.ReactProp
8
-
9
- @ReactModule(name = <%- project.name -%>ViewManager.NAME)
10
- class <%- project.name -%>ViewManager :
11
- <%- project.name -%>ViewManagerSpec<<%- project.name -%>View>() {
12
- override fun getName(): String {
13
- return NAME
14
- }
15
-
16
- public override fun createViewInstance(context: ThemedReactContext): <%- project.name -%>View {
17
- return <%- project.name -%>View(context)
18
- }
19
-
20
- @ReactProp(name = "color")
21
- override fun setColor(view: <%- project.name -%>View?, color: String?) {
22
- view?.setBackgroundColor(Color.parseColor(color))
23
- }
24
-
25
- companion object {
26
- const val NAME = "<%- project.name -%>View"
27
- }
28
- }
@@ -1,21 +0,0 @@
1
- package com.<%- project.package %>
2
-
3
- import android.view.View
4
-
5
- import com.facebook.react.bridge.ReactApplicationContext
6
- import com.facebook.react.uimanager.SimpleViewManager
7
- import com.facebook.react.uimanager.ViewManagerDelegate
8
- import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerDelegate
9
- import com.facebook.react.viewmanagers.<%- project.name -%>ViewManagerInterface
10
-
11
- abstract class <%- project.name -%>ViewManagerSpec<T : View> : SimpleViewManager<T>(), <%- project.name -%>ViewManagerInterface<T> {
12
- private val mDelegate: ViewManagerDelegate<T>
13
-
14
- init {
15
- mDelegate = <%- project.name -%>ViewManagerDelegate(this)
16
- }
17
-
18
- override fun getDelegate(): ViewManagerDelegate<T>? {
19
- return mDelegate
20
- }
21
- }
@@ -1,9 +0,0 @@
1
- package com.<%- project.package %>
2
-
3
- import android.view.View
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.facebook.react.uimanager.SimpleViewManager
6
-
7
- abstract class <%- project.name -%>ViewManagerSpec<T : View> : SimpleViewManager<T>() {
8
- abstract fun setColor(view: T?, value: String?)
9
- }
@@ -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,8 +0,0 @@
1
- import type { TurboModule } from 'react-native';
2
- import { TurboModuleRegistry } from 'react-native';
3
-
4
- export interface Spec extends TurboModule {
5
- multiply(a: number, b: number): Promise<number>;
6
- }
7
-
8
- export default TurboModuleRegistry.getEnforcing<Spec>('<%- project.name -%>');
@@ -1,29 +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
- // @ts-expect-error
10
- const isTurboModuleEnabled = global.__turboModuleProxy != null;
11
-
12
- const <%- project.name -%>Module = isTurboModuleEnabled
13
- ? require('./Native<%- project.name -%>').default
14
- : NativeModules.<%- project.name -%>;
15
-
16
- const <%- project.name -%> = <%- project.name -%>Module
17
- ? <%- project.name -%>Module
18
- : new Proxy(
19
- {},
20
- {
21
- get() {
22
- throw new Error(LINKING_ERROR);
23
- },
24
- }
25
- );
26
-
27
- export function multiply(a: number, b: number): Promise<number> {
28
- return <%- project.name -%>.multiply(a, b);
29
- }
@@ -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,2 +0,0 @@
1
- export { default as <%- project.name -%>View } from './<%- project.name -%>ViewNativeComponent';
2
- export * from './<%- project.name -%>ViewNativeComponent';
@@ -1,8 +0,0 @@
1
- import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
- import type { ViewProps } from 'react-native';
3
-
4
- interface NativeProps extends ViewProps {
5
- color?: string;
6
- }
7
-
8
- export default codegenNativeComponent<NativeProps>('<%- project.name -%>View');
@@ -1,8 +0,0 @@
1
- #ifndef Utils_h
2
- #define Utils_h
3
-
4
- @interface Utils : NSObject
5
- + hexStringToColor:(NSString *)stringToConvert;
6
- @end
7
-
8
- #endif /* Utils_h */
@@ -1,26 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
- #import "Utils.h"
3
- #import <UIKit/UIKit.h>
4
-
5
- @implementation Utils
6
-
7
- + hexStringToColor:(NSString *)stringToConvert
8
- {
9
- NSString *noHashString = [stringToConvert stringByReplacingOccurrencesOfString:@"#" withString:@""];
10
- NSScanner *stringScanner = [NSScanner scannerWithString:noHashString];
11
-
12
- unsigned hex;
13
- if (![stringScanner scanHexInt:&hex]) return nil;
14
- int r = (hex >> 16) & 0xFF;
15
- int g = (hex >> 8) & 0xFF;
16
- int b = (hex) & 0xFF;
17
-
18
- return [UIColor colorWithRed:r / 255.0f green:g / 255.0f blue:b / 255.0f alpha:1.0f];
19
- }
20
-
21
- + (id)alloc {
22
- [NSException raise:@"Cannot be instantiated!" format:@"Static class 'Utils' cannot be instantiated!"];
23
- return nil;
24
- }
25
-
26
- @end
@@ -1,17 +0,0 @@
1
- // This guard prevent this file to be compiled in the old architecture.
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
- #import <React/RCTViewComponentView.h>
4
- #import <UIKit/UIKit.h>
5
-
6
- #ifndef <%- project.name -%>ViewNativeComponent_h
7
- #define <%- project.name -%>ViewNativeComponent_h
8
-
9
- NS_ASSUME_NONNULL_BEGIN
10
-
11
- @interface <%- project.name -%>View : RCTViewComponentView
12
- @end
13
-
14
- NS_ASSUME_NONNULL_END
15
-
16
- #endif /* <%- project.name -%>ViewNativeComponent_h */
17
- #endif /* RCT_NEW_ARCH_ENABLED */
@@ -1,60 +0,0 @@
1
- #ifdef RCT_NEW_ARCH_ENABLED
2
- #import "<%- project.name -%>View.h"
3
-
4
- #import "ComponentDescriptors.h"
5
- #import "EventEmitters.h"
6
- #import "Props.h"
7
- #import "RCTComponentViewHelpers.h"
8
-
9
- #import "RCTFabricComponentsPlugins.h"
10
- #import "Utils.h"
11
-
12
- using namespace facebook::react;
13
-
14
- @interface <%- project.name -%>View () <RCT<%- project.name -%>ViewViewProtocol>
15
-
16
- @end
17
-
18
- @implementation <%- project.name -%>View {
19
- UIView * _view;
20
- }
21
-
22
- + (ComponentDescriptorProvider)componentDescriptorProvider
23
- {
24
- return concreteComponentDescriptorProvider<<%- project.name -%>ViewComponentDescriptor>();
25
- }
26
-
27
- - (instancetype)initWithFrame:(CGRect)frame
28
- {
29
- if (self = [super initWithFrame:frame]) {
30
- static const auto defaultProps = std::make_shared<const <%- project.name -%>ViewProps>();
31
- _props = defaultProps;
32
-
33
- _view = [[UIView alloc] init];
34
-
35
- self.contentView = _view;
36
- }
37
-
38
- return self;
39
- }
40
-
41
- - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
42
- {
43
- const auto &oldViewProps = *std::static_pointer_cast<<%- project.name -%>ViewProps const>(_props);
44
- const auto &newViewProps = *std::static_pointer_cast<<%- project.name -%>ViewProps const>(props);
45
-
46
- if (oldViewProps.color != newViewProps.color) {
47
- NSString * colorToConvert = [[NSString alloc] initWithUTF8String: newViewProps.color.c_str()];
48
- [_view setBackgroundColor: [Utils hexStringToColor:colorToConvert]];
49
- }
50
-
51
- [super updateProps:props oldProps:oldProps];
52
- }
53
-
54
- Class<RCTComponentViewProtocol> <%- project.name -%>ViewCls(void)
55
- {
56
- return <%- project.name -%>View.class;
57
- }
58
-
59
- @end
60
- #endif
@@ -1,23 +0,0 @@
1
- #import <React/RCTViewManager.h>
2
- #import <React/RCTUIManager.h>
3
- #import "RCTBridge.h"
4
- #import "Utils.h"
5
-
6
- @interface <%- project.name -%>ViewManager : RCTViewManager
7
- @end
8
-
9
- @implementation <%- project.name -%>ViewManager
10
-
11
- RCT_EXPORT_MODULE(<%- project.name -%>View)
12
-
13
- - (UIView *)view
14
- {
15
- return [[UIView alloc] init];
16
- }
17
-
18
- RCT_CUSTOM_VIEW_PROPERTY(color, NSString, UIView)
19
- {
20
- [view setBackgroundColor: [Utils hexStringToColor:json]];
21
- }
22
-
23
- @end