@react-native/codegen 0.73.0-nightly-20230622-0201e51bb → 0.73.0-nightly-20230731-b0a8d45e2

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.
@@ -117,9 +117,11 @@ public:
117
117
  return delegate_.get(rt, propName);
118
118
  }
119
119
 
120
+ static constexpr std::string_view kModuleName = "${moduleName}";
121
+
120
122
  protected:
121
123
  ${hasteModuleName}CxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
122
- : TurboModule("${moduleName}", jsInvoker),
124
+ : TurboModule(std::string{${hasteModuleName}CxxSpec::kModuleName}, jsInvoker),
123
125
  delegate_(static_cast<T*>(this), jsInvoker) {}
124
126
 
125
127
  private:
@@ -74,9 +74,11 @@ public:
74
74
  return delegate_.get(rt, propName);
75
75
  }
76
76
 
77
+ static constexpr std::string_view kModuleName = "${moduleName}";
78
+
77
79
  protected:
78
80
  ${hasteModuleName}CxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
79
- : TurboModule("${moduleName}", jsInvoker),
81
+ : TurboModule(std::string{${hasteModuleName}CxxSpec::kModuleName}, jsInvoker),
80
82
  delegate_(static_cast<T*>(this), jsInvoker) {}
81
83
 
82
84
  private:
@@ -66,7 +66,9 @@ function getPropertyType(
66
66
  optional,
67
67
  typeAnnotation: {
68
68
  type: 'StringEnumTypeAnnotation',
69
- options: typeAnnotation.types.map(option => option.value),
69
+ options: typeAnnotation.types.map(option =>
70
+ parser.getLiteralValue(option),
71
+ ),
70
72
  },
71
73
  };
72
74
  case 'UnsafeMixed':
@@ -109,7 +111,9 @@ function extractArrayElementType(typeAnnotation, name, parser) {
109
111
  case 'UnionTypeAnnotation':
110
112
  return {
111
113
  type: 'StringEnumTypeAnnotation',
112
- options: typeAnnotation.types.map(option => option.value),
114
+ options: typeAnnotation.types.map(option =>
115
+ parser.getLiteralValue(option),
116
+ ),
113
117
  };
114
118
  case 'UnsafeMixed':
115
119
  return {
@@ -175,9 +179,7 @@ function findEventArgumentsAndType(
175
179
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
176
180
  const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
177
181
  const paperTopLevelNameDeprecated =
178
- typeAnnotation.typeParameters.params.length > 1
179
- ? typeAnnotation.typeParameters.params[1].value
180
- : null;
182
+ parser.getPaperTopLevelNameDeprecated(typeAnnotation);
181
183
  if (
182
184
  typeAnnotation.typeParameters.params[0].type ===
183
185
  parser.nullLiteralTypeAnnotation
@@ -78,7 +78,9 @@ function getPropertyType(
78
78
  optional,
79
79
  typeAnnotation: {
80
80
  type: 'StringEnumTypeAnnotation',
81
- options: typeAnnotation.types.map(option => option.value),
81
+ options: typeAnnotation.types.map(option =>
82
+ parser.getLiteralValue(option),
83
+ ),
82
84
  },
83
85
  };
84
86
  case 'UnsafeMixed':
@@ -119,7 +121,9 @@ function extractArrayElementType(
119
121
  case 'UnionTypeAnnotation':
120
122
  return {
121
123
  type: 'StringEnumTypeAnnotation',
122
- options: typeAnnotation.types.map(option => option.value),
124
+ options: typeAnnotation.types.map(option =>
125
+ parser.getLiteralValue(option),
126
+ ),
123
127
  };
124
128
  case 'UnsafeMixed':
125
129
  return {type: 'MixedTypeAnnotation'};
@@ -189,9 +193,7 @@ function findEventArgumentsAndType(
189
193
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
190
194
  const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
191
195
  const paperTopLevelNameDeprecated =
192
- typeAnnotation.typeParameters.params.length > 1
193
- ? typeAnnotation.typeParameters.params[1].value
194
- : null;
196
+ parser.getPaperTopLevelNameDeprecated(typeAnnotation);
195
197
  if (
196
198
  typeAnnotation.typeParameters.params[0].type ===
197
199
  parser.nullLiteralTypeAnnotation
@@ -468,6 +468,14 @@ class FlowParser {
468
468
  getObjectProperties(typeAnnotation) {
469
469
  return typeAnnotation.properties;
470
470
  }
471
+ getLiteralValue(option) {
472
+ return option.value;
473
+ }
474
+ getPaperTopLevelNameDeprecated(typeAnnotation) {
475
+ return typeAnnotation.typeParameters.params.length > 1
476
+ ? typeAnnotation.typeParameters.params[1].value
477
+ : null;
478
+ }
471
479
  }
472
480
  module.exports = {
473
481
  FlowParser,
@@ -543,6 +543,16 @@ class FlowParser implements Parser {
543
543
  getObjectProperties(typeAnnotation: $FlowFixMe): $FlowFixMe {
544
544
  return typeAnnotation.properties;
545
545
  }
546
+
547
+ getLiteralValue(option: $FlowFixMe): $FlowFixMe {
548
+ return option.value;
549
+ }
550
+
551
+ getPaperTopLevelNameDeprecated(typeAnnotation: $FlowFixMe): $FlowFixMe {
552
+ return typeAnnotation.typeParameters.params.length > 1
553
+ ? typeAnnotation.typeParameters.params[1].value
554
+ : null;
555
+ }
546
556
  }
547
557
 
548
558
  module.exports = {
@@ -414,4 +414,18 @@ export interface Parser {
414
414
  * @returns: the properties of an object represented by a type annotation.
415
415
  */
416
416
  getObjectProperties(typeAnnotation: $FlowFixMe): $FlowFixMe;
417
+
418
+ /**
419
+ * Given a option return the literal value.
420
+ * @parameter option
421
+ * @returns: the literal value of an union represented.
422
+ */
423
+ getLiteralValue(option: $FlowFixMe): $FlowFixMe;
424
+
425
+ /**
426
+ * Given a type annotation, it returns top level name in the AST if it exists else returns null.
427
+ * @parameter typeAnnotation: the annotation for a type in the AST.
428
+ * @returns: the top level name properties in the AST if it exists else null.
429
+ */
430
+ getPaperTopLevelNameDeprecated(typeAnnotation: $FlowFixMe): $FlowFixMe;
417
431
  }
@@ -401,4 +401,12 @@ export class MockedParser {
401
401
  getObjectProperties(typeAnnotation) {
402
402
  return typeAnnotation.properties;
403
403
  }
404
+ getLiteralValue(option) {
405
+ return option.value;
406
+ }
407
+ getPaperTopLevelNameDeprecated(typeAnnotation) {
408
+ return typeAnnotation.typeParameters.params.length > 1
409
+ ? typeAnnotation.typeParameters.params[1].value
410
+ : null;
411
+ }
404
412
  }
@@ -482,4 +482,14 @@ export class MockedParser implements Parser {
482
482
  getObjectProperties(typeAnnotation: $FlowFixMe): $FlowFixMe {
483
483
  return typeAnnotation.properties;
484
484
  }
485
+
486
+ getLiteralValue(option: $FlowFixMe): $FlowFixMe {
487
+ return option.value;
488
+ }
489
+
490
+ getPaperTopLevelNameDeprecated(typeAnnotation: $FlowFixMe): $FlowFixMe {
491
+ return typeAnnotation.typeParameters.params.length > 1
492
+ ? typeAnnotation.typeParameters.params[1].value
493
+ : null;
494
+ }
485
495
  }
@@ -68,7 +68,9 @@ function getPropertyType(
68
68
  optional,
69
69
  typeAnnotation: {
70
70
  type: 'StringEnumTypeAnnotation',
71
- options: typeAnnotation.types.map(option => option.literal.value),
71
+ options: typeAnnotation.types.map(option =>
72
+ parser.getLiteralValue(option),
73
+ ),
72
74
  },
73
75
  };
74
76
  case 'UnsafeMixed':
@@ -116,7 +118,9 @@ function extractArrayElementType(typeAnnotation, name, parser) {
116
118
  case 'TSUnionType':
117
119
  return {
118
120
  type: 'StringEnumTypeAnnotation',
119
- options: typeAnnotation.types.map(option => option.literal.value),
121
+ options: typeAnnotation.types.map(option =>
122
+ parser.getLiteralValue(option),
123
+ ),
120
124
  };
121
125
  case 'TSTypeLiteral':
122
126
  return {
@@ -180,9 +184,7 @@ function findEventArgumentsAndType(
180
184
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
181
185
  const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
182
186
  const paperTopLevelNameDeprecated =
183
- typeAnnotation.typeParameters.params.length > 1
184
- ? typeAnnotation.typeParameters.params[1].literal.value
185
- : null;
187
+ parser.getPaperTopLevelNameDeprecated(typeAnnotation);
186
188
  switch (typeAnnotation.typeParameters.params[0].type) {
187
189
  case parser.nullLiteralTypeAnnotation:
188
190
  case parser.undefinedLiteralTypeAnnotation:
@@ -77,7 +77,9 @@ function getPropertyType(
77
77
  optional,
78
78
  typeAnnotation: {
79
79
  type: 'StringEnumTypeAnnotation',
80
- options: typeAnnotation.types.map(option => option.literal.value),
80
+ options: typeAnnotation.types.map(option =>
81
+ parser.getLiteralValue(option),
82
+ ),
81
83
  },
82
84
  };
83
85
  case 'UnsafeMixed':
@@ -127,7 +129,9 @@ function extractArrayElementType(
127
129
  case 'TSUnionType':
128
130
  return {
129
131
  type: 'StringEnumTypeAnnotation',
130
- options: typeAnnotation.types.map(option => option.literal.value),
132
+ options: typeAnnotation.types.map(option =>
133
+ parser.getLiteralValue(option),
134
+ ),
131
135
  };
132
136
  case 'TSTypeLiteral':
133
137
  return {
@@ -198,9 +202,7 @@ function findEventArgumentsAndType(
198
202
  } else if (name === 'BubblingEventHandler' || name === 'DirectEventHandler') {
199
203
  const eventType = name === 'BubblingEventHandler' ? 'bubble' : 'direct';
200
204
  const paperTopLevelNameDeprecated =
201
- typeAnnotation.typeParameters.params.length > 1
202
- ? typeAnnotation.typeParameters.params[1].literal.value
203
- : null;
205
+ parser.getPaperTopLevelNameDeprecated(typeAnnotation);
204
206
 
205
207
  switch (typeAnnotation.typeParameters.params[0].type) {
206
208
  case parser.nullLiteralTypeAnnotation:
@@ -519,6 +519,14 @@ class TypeScriptParser {
519
519
  getObjectProperties(typeAnnotation) {
520
520
  return typeAnnotation.members;
521
521
  }
522
+ getLiteralValue(option) {
523
+ return option.literal.value;
524
+ }
525
+ getPaperTopLevelNameDeprecated(typeAnnotation) {
526
+ return typeAnnotation.typeParameters.params.length > 1
527
+ ? typeAnnotation.typeParameters.params[1].literal.value
528
+ : null;
529
+ }
522
530
  }
523
531
  module.exports = {
524
532
  TypeScriptParser,
@@ -557,6 +557,16 @@ class TypeScriptParser implements Parser {
557
557
  getObjectProperties(typeAnnotation: $FlowFixMe): $FlowFixMe {
558
558
  return typeAnnotation.members;
559
559
  }
560
+
561
+ getLiteralValue(option: $FlowFixMe): $FlowFixMe {
562
+ return option.literal.value;
563
+ }
564
+
565
+ getPaperTopLevelNameDeprecated(typeAnnotation: $FlowFixMe): $FlowFixMe {
566
+ return typeAnnotation.typeParameters.params.length > 1
567
+ ? typeAnnotation.typeParameters.params[1].literal.value
568
+ : null;
569
+ }
560
570
  }
561
571
 
562
572
  module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/codegen",
3
- "version": "0.73.0-nightly-20230622-0201e51bb",
3
+ "version": "0.73.0-nightly-20230731-b0a8d45e2",
4
4
  "description": "Code generation tools for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {