@@ -44,6 +44,10 @@ const NATIVE_FILES = {
44
44
view_legacy : path . resolve ( __dirname , '../templates/native-view-legacy' ) ,
45
45
view_mixed : path . resolve ( __dirname , '../templates/native-view-mixed' ) ,
46
46
view_new : path . resolve ( __dirname , '../templates/native-view-new' ) ,
47
+ view_module_mixed : path . resolve (
48
+ __dirname ,
49
+ '../templates/native-view-library-mixed'
50
+ ) ,
47
51
} as const ;
48
52
49
53
const JAVA_FILES = {
@@ -60,6 +64,10 @@ const OBJC_FILES = {
60
64
view_legacy : path . resolve ( __dirname , '../templates/objc-view-legacy' ) ,
61
65
view_mixed : path . resolve ( __dirname , '../templates/objc-view-mixed' ) ,
62
66
view_new : path . resolve ( __dirname , '../templates/objc-view-new' ) ,
67
+ view_module_mixed : path . resolve (
68
+ __dirname ,
69
+ '../templates/objc-view-library-mixed'
70
+ ) ,
63
71
} as const ;
64
72
65
73
const KOTLIN_FILES = {
@@ -69,6 +77,10 @@ const KOTLIN_FILES = {
69
77
view_legacy : path . resolve ( __dirname , '../templates/kotlin-view-legacy' ) ,
70
78
view_mixed : path . resolve ( __dirname , '../templates/kotlin-view-mixed' ) ,
71
79
view_new : path . resolve ( __dirname , '../templates/kotlin-view-new' ) ,
80
+ view_module_mixed : path . resolve (
81
+ __dirname ,
82
+ '../templates/kotlin-view-library-mixed'
83
+ ) ,
72
84
} as const ;
73
85
74
86
const SWIFT_FILES = {
@@ -104,7 +116,8 @@ type ProjectType =
104
116
| 'view-mixed'
105
117
| 'view-new'
106
118
| 'view-legacy'
107
- | 'library' ;
119
+ | 'library'
120
+ | 'view-module-mixed' ;
108
121
109
122
type Answers = {
110
123
slug : string ;
@@ -134,6 +147,7 @@ const LANGUAGE_CHOICES: {
134
147
'view-mixed' ,
135
148
'view-new' ,
136
149
'view-legacy' ,
150
+ 'view-module-mixed' ,
137
151
] ,
138
152
} ,
139
153
{
@@ -178,6 +192,11 @@ const TYPE_CHOICES: {
178
192
value : ProjectType ;
179
193
description : string ;
180
194
} [ ] = [
195
+ {
196
+ title : 'Fabric view and Turbo module with backward compat' ,
197
+ value : 'view-module-mixed' ,
198
+ description : NEWARCH_DESCRIPTION ,
199
+ } ,
181
200
{
182
201
title : 'JavaScript library' ,
183
202
value : 'library' ,
@@ -210,7 +229,7 @@ const TYPE_CHOICES: {
210
229
} ,
211
230
{
212
231
title : 'Fabric view' ,
213
- value : 'view-new ' ,
232
+ value : 'view-module-mixed ' ,
214
233
description : NEWARCH_DESCRIPTION ,
215
234
} ,
216
235
] ;
@@ -561,11 +580,17 @@ async function create(argv: yargs.Arguments<any>) {
561
580
version = FALLBACK_BOB_VERSION ;
562
581
}
563
582
564
- const moduleType = type . startsWith ( 'view-' ) ? 'view' : 'module' ;
583
+ const moduleType = type . startsWith ( 'view-module' )
584
+ ? 'view_module'
585
+ : type . startsWith ( 'view' )
586
+ ? 'view'
587
+ : 'module' ;
565
588
const arch =
566
589
type === 'module-new' || type === 'view-new'
567
590
? 'new'
568
- : type === 'module-mixed' || type === 'view-mixed'
591
+ : type === 'module-mixed' ||
592
+ type === 'view-mixed' ||
593
+ type === 'view-module-mixed'
569
594
? 'mixed'
570
595
: 'legacy' ;
571
596
@@ -612,8 +637,8 @@ async function create(argv: yargs.Arguments<any>) {
612
637
cpp : languages === 'cpp' ,
613
638
kotlin : languages === 'kotlin-objc' || languages === 'kotlin-swift' ,
614
639
swift : languages === 'java-swift' || languages === 'kotlin-swift' ,
615
- view : moduleType === 'view' ,
616
- module : moduleType === 'module' ,
640
+ view : moduleType === 'view' || moduleType === 'view_module' ,
641
+ module : moduleType === 'module' || moduleType === 'view_module' ,
617
642
} ,
618
643
author : {
619
644
name : authorName ,
@@ -714,33 +739,36 @@ async function create(argv: yargs.Arguments<any>) {
714
739
await copyDir ( NATIVE_COMMON_EXAMPLE_FILES , folder ) ;
715
740
}
716
741
717
- if ( moduleType === 'module' ) {
718
- await copyDir ( NATIVE_FILES [ `${ moduleType } _${ arch } ` ] , folder ) ;
742
+ if ( moduleType === 'view_module' ) {
743
+ // View module doesn't have legacy or a new arch only version.
744
+ await copyDir ( NATIVE_FILES [ 'view_module_mixed' ] , folder ) ;
745
+ await copyDir ( OBJC_FILES [ 'view_module_mixed' ] , folder ) ;
746
+ await copyDir ( KOTLIN_FILES [ 'view_module_mixed' ] , folder ) ;
719
747
} else {
720
748
await copyDir ( NATIVE_FILES [ `${ moduleType } _${ arch } ` ] , folder ) ;
721
- }
722
749
723
- if ( options . project . swift ) {
724
- await copyDir ( SWIFT_FILES [ `${ moduleType } _legacy` ] , folder ) ;
725
- } else {
726
- if ( moduleType === 'module' ) {
727
- await copyDir ( OBJC_FILES [ `${ moduleType } _common` ] , folder ) ;
750
+ if ( options . project . swift ) {
751
+ await copyDir ( SWIFT_FILES [ `${ moduleType } _legacy` ] , folder ) ;
728
752
} else {
729
- await copyDir ( OBJC_FILES [ `view_${ arch } ` ] , folder ) ;
753
+ if ( moduleType === 'module' ) {
754
+ await copyDir ( OBJC_FILES [ `${ moduleType } _common` ] , folder ) ;
755
+ } else {
756
+ await copyDir ( OBJC_FILES [ `view_${ arch } ` ] , folder ) ;
757
+ }
730
758
}
731
- }
732
759
733
- const templateType = `${ moduleType } _${ arch } ` as const ;
760
+ const templateType = `${ moduleType } _${ arch } ` as const ;
734
761
735
- if ( options . project . kotlin ) {
736
- await copyDir ( KOTLIN_FILES [ templateType ] , folder ) ;
737
- } else {
738
- await copyDir ( JAVA_FILES [ templateType ] , folder ) ;
739
- }
762
+ if ( options . project . kotlin ) {
763
+ await copyDir ( KOTLIN_FILES [ templateType ] , folder ) ;
764
+ } else {
765
+ await copyDir ( JAVA_FILES [ templateType ] , folder ) ;
766
+ }
740
767
741
- if ( options . project . cpp ) {
742
- await copyDir ( CPP_FILES , folder ) ;
743
- await fs . remove ( path . join ( folder , 'ios' , `${ options . project . name } .m` ) ) ;
768
+ if ( options . project . cpp ) {
769
+ await copyDir ( CPP_FILES , folder ) ;
770
+ await fs . remove ( path . join ( folder , 'ios' , `${ options . project . name } .m` ) ) ;
771
+ }
744
772
}
745
773
}
746
774
0 commit comments