Skip to content

Commit 179f124

Browse files
committed
release 1.0.0-alpha.36
1 parent 2b9524f commit 179f124

4 files changed

Lines changed: 34 additions & 28 deletions

File tree

packages/core/hooks/android/extractors/module-param-types.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ export function extractMethodParamTypes(
77
// but just in case the implementation changes in future.
88
const splitBeforeGeneric = javaType.split('<')[0];
99

10-
if (splitBeforeGeneric.includes('@Nullable String')) {
11-
return RNJavaSerialisableType.string;
10+
if (splitBeforeGeneric.includes('@NonNull String')) {
11+
return RNJavaSerialisableType.nonnullString;
1212
}
1313
if (splitBeforeGeneric.includes('String')) {
14-
return RNJavaSerialisableType.nonnullString;
14+
return RNJavaSerialisableType.string;
1515
}
1616
if (splitBeforeGeneric.includes('Integer')) {
1717
return RNJavaSerialisableType.int;
@@ -37,23 +37,23 @@ export function extractMethodParamTypes(
3737
if (splitBeforeGeneric.includes('float')) {
3838
return RNJavaSerialisableType.nonnullFloat;
3939
}
40-
if (splitBeforeGeneric.includes('@Nullable ReadableMap')) {
41-
return RNJavaSerialisableType.object;
40+
if (splitBeforeGeneric.includes('@NonNull ReadableMap')) {
41+
return RNJavaSerialisableType.nonnullObject;
4242
}
4343
if (splitBeforeGeneric.includes('ReadableMap')) {
44-
return RNJavaSerialisableType.nonnullObject;
44+
return RNJavaSerialisableType.object;
4545
}
46-
if (splitBeforeGeneric.includes('@Nullable ReadableArray')) {
47-
return RNJavaSerialisableType.array;
46+
if (splitBeforeGeneric.includes('@NonNull ReadableArray')) {
47+
return RNJavaSerialisableType.nonnullArray;
4848
}
4949
if (splitBeforeGeneric.includes('ReadableArray')) {
50-
return RNJavaSerialisableType.nonnullArray;
50+
return RNJavaSerialisableType.array;
5151
}
52-
if (splitBeforeGeneric.includes('@Nullable Callback')) {
53-
return RNJavaSerialisableType.Callback;
52+
if (splitBeforeGeneric.includes('@NonNull Callback')) {
53+
return RNJavaSerialisableType.nonnullCallback;
5454
}
5555
if (splitBeforeGeneric.includes('Callback')) {
56-
return RNJavaSerialisableType.nonnullCallback;
56+
return RNJavaSerialisableType.Callback;
5757
}
5858
if (splitBeforeGeneric.includes('Promise')) {
5959
return RNJavaSerialisableType.Promise;

packages/core/package-for-npm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@open-native/core",
3-
"version": "1.0.0-alpha.35",
3+
"version": "1.0.0-alpha.36",
44
"description": "Open Native helps cross platform communities work better together.",
55
"main": "index",
66
"types": "index.d.ts",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@open-native/core",
3-
"version": "1.0.0-alpha.34",
3+
"version": "1.0.0-alpha.36",
44
"description": "Open Native helps cross platform communities work better together.",
55
"main": "index",
66
"types": "index.d.ts",

packages/core/src/android/converter.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export function toNativeArguments(
277277

278278
case RNJavaSerialisableType.boolean:
279279
if (isNullOrUndefined(data)) {
280-
nativeArguments.push(null);
280+
nativeArguments.push(false);
281281
break;
282282
}
283283
// nullable booleans are java.lang.Booleans
@@ -286,12 +286,14 @@ export function toNativeArguments(
286286
break;
287287
case RNJavaSerialisableType.nonnullBoolean:
288288
assert(
289-
typeof data === 'boolean',
289+
typeof data === 'boolean' || isNullOrUndefined(data),
290290
`Argument at index ${i} expected a boolean, but got ${data}`
291291
);
292292

293293
// booleans are auto-marshalled to BOOL.
294-
nativeArguments.push(data);
294+
nativeArguments.push(
295+
isNullOrUndefined(data) ? false : (data as boolean)
296+
);
295297
break;
296298

297299
case RNJavaSerialisableType.string:
@@ -311,18 +313,18 @@ export function toNativeArguments(
311313
break;
312314

313315
case RNJavaSerialisableType.int:
314-
assert(
315-
typeof data === 'number',
316-
`Argument at index ${i} expected a number, but got ${data}`
317-
);
318-
nativeArguments.push(new java.lang.Integer(data));
316+
if (isNullOrUndefined(data)) {
317+
nativeArguments.push(new java.lang.Integer(0));
318+
break;
319+
}
320+
nativeArguments.push(new java.lang.Integer(data as number));
319321
break;
320322
case RNJavaSerialisableType.nonnullInt:
321323
assert(
322-
typeof data === 'number',
324+
typeof data === 'number' || isNullOrUndefined(data),
323325
`Argument at index ${i} expected a number, but got ${data}`
324326
);
325-
nativeArguments.push(data);
327+
nativeArguments.push(isNullOrUndefined(data) ? 0 : (data as number));
326328
break;
327329
case RNJavaSerialisableType.float:
328330
if (isNullOrUndefined(data)) {
@@ -332,10 +334,12 @@ export function toNativeArguments(
332334
// eslint-disable-next-line no-fallthrough
333335
case RNJavaSerialisableType.nonnullFloat:
334336
assert(
335-
typeof data === 'number',
337+
typeof data === 'number' || isNullOrUndefined(data),
336338
`Argument at index ${i} expected a number, but got ${data}`
337339
);
338-
nativeArguments.push(float(data));
340+
nativeArguments.push(
341+
isNullOrUndefined(data) ? float(0) : float(data as number)
342+
);
339343
break;
340344
case RNJavaSerialisableType.double:
341345
if (isNullOrUndefined(data)) {
@@ -345,10 +349,12 @@ export function toNativeArguments(
345349
// eslint-disable-next-line no-fallthrough
346350
case RNJavaSerialisableType.nonnullDouble:
347351
assert(
348-
typeof data === 'number',
352+
typeof data === 'number' || isNullOrUndefined(data),
349353
`Argument at index ${i} expected a number, but got ${data}`
350354
);
351-
nativeArguments.push(double(data));
355+
nativeArguments.push(
356+
isNullOrUndefined(data) ? double(0) : double(data as number)
357+
);
352358
break;
353359
case RNJavaSerialisableType.Callback:
354360
if (isNullOrUndefined(data)) {

0 commit comments

Comments
 (0)