@react-native/codegen 0.74.2 → 0.75.0-main
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.
|
@@ -153,7 +153,6 @@ function serializeArg(moduleName, arg, index, resolveAlias, enumMap) {
|
|
|
153
153
|
_unwrapNullable2 = _slicedToArray(_unwrapNullable, 2),
|
|
154
154
|
typeAnnotation = _unwrapNullable2[0],
|
|
155
155
|
nullable = _unwrapNullable2[1];
|
|
156
|
-
const isRequired = !optional && !nullable;
|
|
157
156
|
let realTypeAnnotation = typeAnnotation;
|
|
158
157
|
if (realTypeAnnotation.type === 'TypeAliasTypeAnnotation') {
|
|
159
158
|
realTypeAnnotation = resolveAlias(realTypeAnnotation.name);
|
|
@@ -161,21 +160,27 @@ function serializeArg(moduleName, arg, index, resolveAlias, enumMap) {
|
|
|
161
160
|
function wrap(callback) {
|
|
162
161
|
const val = `args[${index}]`;
|
|
163
162
|
const expression = callback(val);
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
|
|
164
|
+
// param?: T
|
|
165
|
+
if (optional && !nullable) {
|
|
166
|
+
// throw new Error('are we hitting this case? ' + moduleName);
|
|
167
|
+
return `count <= ${index} || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// param: ?T
|
|
171
|
+
// param?: ?T
|
|
172
|
+
if (nullable || optional) {
|
|
173
|
+
return `count <= ${index} || ${val}.isNull() || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`;
|
|
172
174
|
}
|
|
175
|
+
|
|
176
|
+
// param: T
|
|
177
|
+
return `count <= ${index} ? throw jsi::JSError(rt, "Expected argument in position ${index} to be passed") : ${expression}`;
|
|
173
178
|
}
|
|
174
179
|
switch (realTypeAnnotation.type) {
|
|
175
180
|
case 'ReservedTypeAnnotation':
|
|
176
181
|
switch (realTypeAnnotation.name) {
|
|
177
182
|
case 'RootTag':
|
|
178
|
-
return wrap(val => `${val}.
|
|
183
|
+
return wrap(val => `${val}.asNumber()`);
|
|
179
184
|
default:
|
|
180
185
|
realTypeAnnotation.name;
|
|
181
186
|
throw new Error(
|
|
@@ -122,7 +122,6 @@ function serializeArg(
|
|
|
122
122
|
const {typeAnnotation: nullableTypeAnnotation, optional} = arg;
|
|
123
123
|
const [typeAnnotation, nullable] =
|
|
124
124
|
unwrapNullable<NativeModuleParamTypeAnnotation>(nullableTypeAnnotation);
|
|
125
|
-
const isRequired = !optional && !nullable;
|
|
126
125
|
|
|
127
126
|
let realTypeAnnotation = typeAnnotation;
|
|
128
127
|
if (realTypeAnnotation.type === 'TypeAliasTypeAnnotation') {
|
|
@@ -132,22 +131,28 @@ function serializeArg(
|
|
|
132
131
|
function wrap(callback: (val: string) => string) {
|
|
133
132
|
const val = `args[${index}]`;
|
|
134
133
|
const expression = callback(val);
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
134
|
+
|
|
135
|
+
// param?: T
|
|
136
|
+
if (optional && !nullable) {
|
|
137
|
+
// throw new Error('are we hitting this case? ' + moduleName);
|
|
138
|
+
return `count <= ${index} || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// param: ?T
|
|
142
|
+
// param?: ?T
|
|
143
|
+
if (nullable || optional) {
|
|
144
|
+
return `count <= ${index} || ${val}.isNull() || ${val}.isUndefined() ? std::nullopt : std::make_optional(${expression})`;
|
|
143
145
|
}
|
|
146
|
+
|
|
147
|
+
// param: T
|
|
148
|
+
return `count <= ${index} ? throw jsi::JSError(rt, "Expected argument in position ${index} to be passed") : ${expression}`;
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
switch (realTypeAnnotation.type) {
|
|
147
152
|
case 'ReservedTypeAnnotation':
|
|
148
153
|
switch (realTypeAnnotation.name) {
|
|
149
154
|
case 'RootTag':
|
|
150
|
-
return wrap(val => `${val}.
|
|
155
|
+
return wrap(val => `${val}.asNumber()`);
|
|
151
156
|
default:
|
|
152
157
|
(realTypeAnnotation.name: empty);
|
|
153
158
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native/codegen",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.0-main",
|
|
4
4
|
"description": "Code generation tools for React Native",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/parser": "^7.20.0",
|
|
33
33
|
"glob": "^7.1.1",
|
|
34
|
-
"hermes-parser": "0.
|
|
34
|
+
"hermes-parser": "0.20.1",
|
|
35
35
|
"invariant": "^2.2.4",
|
|
36
36
|
"jscodeshift": "^0.14.0",
|
|
37
37
|
"mkdirp": "^0.5.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@babel/plugin-transform-flow-strip-types": "^7.20.0",
|
|
50
50
|
"@babel/preset-env": "^7.20.0",
|
|
51
51
|
"chalk": "^4.0.0",
|
|
52
|
-
"hermes-estree": "0.
|
|
52
|
+
"hermes-estree": "0.20.1",
|
|
53
53
|
"micromatch": "^4.0.4",
|
|
54
54
|
"prettier": "2.8.8",
|
|
55
55
|
"rimraf": "^3.0.2",
|