Skip to content

Commit ba232d2

Browse files
feat: add nitro view to template creation
1 parent ce5ed31 commit ba232d2

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

packages/create-react-native-library/src/exampleApp/generateExampleApp.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,10 @@ export default async function generateExampleApp({
181181
'react-native-builder-bob': `^${config.versions.bob}`,
182182
};
183183

184-
if (config.project.moduleConfig === 'nitro-modules') {
184+
if (
185+
config.project.moduleConfig === 'nitro-modules' ||
186+
config.project.viewConfig === 'nitro-view'
187+
) {
185188
const packagesToAddNitro = {
186189
'react-native-nitro-modules': `^${config.versions.nitroModules}`,
187190
};

packages/create-react-native-library/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ async function create(_argv: yargs.Arguments<Args>) {
7474
assertUserInput(questions, answers);
7575

7676
const bobVersion = await bobVersionPromise;
77-
7877
const nitroModulesVersion =
79-
answers.type === 'nitro-module'
78+
answers.type === 'nitro-module' || answers.type === 'nitro-view'
8079
? await nitroModulesVersionPromise
8180
: undefined;
8281

packages/create-react-native-library/src/input.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type ProjectType =
2626
| 'legacy-module'
2727
| 'legacy-view'
2828
| 'nitro-module'
29+
| 'nitro-view'
2930
| 'library';
3031

3132
const LANGUAGE_CHOICES: {
@@ -36,7 +37,7 @@ const LANGUAGE_CHOICES: {
3637
{
3738
title: 'Kotlin & Swift',
3839
value: 'kotlin-swift',
39-
types: ['nitro-module', 'legacy-module', 'legacy-view'],
40+
types: ['nitro-view', 'nitro-module', 'legacy-module', 'legacy-view'],
4041
},
4142
{
4243
title: 'Kotlin & Objective-C',
@@ -96,6 +97,12 @@ const TYPE_CHOICES: {
9697
description:
9798
'type-safe, fast integration for native APIs to JS (experimental)',
9899
},
100+
{
101+
title: 'Nitro View',
102+
value: 'nitro-view',
103+
description:
104+
'integration for native views to JS using nitro for prop parsing (experimental)',
105+
},
99106
{
100107
title: 'Fabric view',
101108
value: 'fabric-view',

packages/create-react-native-library/src/template.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export type ModuleConfig =
2020
| 'nitro-modules'
2121
| null;
2222

23-
export type ViewConfig = 'paper-view' | 'fabric-view' | null;
23+
export type ViewConfig = 'paper-view' | 'fabric-view' | 'nitro-view' | null;
2424

2525
// Please think at least 5 times before introducing a new config key
2626
// You can just reuse the existing ones most of the time
@@ -90,6 +90,7 @@ const NATIVE_FILES = {
9090
view_legacy: path.resolve(__dirname, '../templates/native-view-legacy'),
9191
view_new: path.resolve(__dirname, '../templates/native-view-new'),
9292
module_nitro: path.resolve(__dirname, '../templates/nitro-module'),
93+
view_nitro: path.resolve(__dirname, '../templates/nitro-view'),
9394
} as const;
9495

9596
const OBJC_FILES = {
@@ -195,6 +196,8 @@ function getViewConfig(projectType: ProjectType): ViewConfig {
195196
return 'paper-view';
196197
case 'fabric-view':
197198
return 'fabric-view';
199+
case 'nitro-view':
200+
return 'nitro-view';
198201
default:
199202
return null;
200203
}
@@ -241,6 +244,11 @@ export async function applyTemplates(
241244
return;
242245
}
243246

247+
if (config.project.viewConfig === 'nitro-view') {
248+
await applyTemplate(config, NATIVE_FILES['view_nitro'], folder);
249+
return;
250+
}
251+
244252
if (config.project.moduleConfig !== null) {
245253
await applyTemplate(
246254
config,

0 commit comments

Comments
 (0)