Skip to content

Commit

Permalink
release 1.0.0-alpha.36
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Jun 5, 2023
1 parent 2b9524f commit 179f124
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
24 changes: 12 additions & 12 deletions packages/core/hooks/android/extractors/module-param-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export function extractMethodParamTypes(
// but just in case the implementation changes in future.
const splitBeforeGeneric = javaType.split('<')[0];

if (splitBeforeGeneric.includes('@Nullable String')) {
return RNJavaSerialisableType.string;
if (splitBeforeGeneric.includes('@NonNull String')) {
return RNJavaSerialisableType.nonnullString;
}
if (splitBeforeGeneric.includes('String')) {
return RNJavaSerialisableType.nonnullString;
return RNJavaSerialisableType.string;
}
if (splitBeforeGeneric.includes('Integer')) {
return RNJavaSerialisableType.int;
Expand All @@ -37,23 +37,23 @@ export function extractMethodParamTypes(
if (splitBeforeGeneric.includes('float')) {
return RNJavaSerialisableType.nonnullFloat;
}
if (splitBeforeGeneric.includes('@Nullable ReadableMap')) {
return RNJavaSerialisableType.object;
if (splitBeforeGeneric.includes('@NonNull ReadableMap')) {
return RNJavaSerialisableType.nonnullObject;
}
if (splitBeforeGeneric.includes('ReadableMap')) {
return RNJavaSerialisableType.nonnullObject;
return RNJavaSerialisableType.object;
}
if (splitBeforeGeneric.includes('@Nullable ReadableArray')) {
return RNJavaSerialisableType.array;
if (splitBeforeGeneric.includes('@NonNull ReadableArray')) {
return RNJavaSerialisableType.nonnullArray;
}
if (splitBeforeGeneric.includes('ReadableArray')) {
return RNJavaSerialisableType.nonnullArray;
return RNJavaSerialisableType.array;
}
if (splitBeforeGeneric.includes('@Nullable Callback')) {
return RNJavaSerialisableType.Callback;
if (splitBeforeGeneric.includes('@NonNull Callback')) {
return RNJavaSerialisableType.nonnullCallback;
}
if (splitBeforeGeneric.includes('Callback')) {
return RNJavaSerialisableType.nonnullCallback;
return RNJavaSerialisableType.Callback;
}
if (splitBeforeGeneric.includes('Promise')) {
return RNJavaSerialisableType.Promise;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package-for-npm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@open-native/core",
"version": "1.0.0-alpha.35",
"version": "1.0.0-alpha.36",
"description": "Open Native helps cross platform communities work better together.",
"main": "index",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@open-native/core",
"version": "1.0.0-alpha.34",
"version": "1.0.0-alpha.36",
"description": "Open Native helps cross platform communities work better together.",
"main": "index",
"types": "index.d.ts",
Expand Down
34 changes: 20 additions & 14 deletions packages/core/src/android/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export function toNativeArguments(

case RNJavaSerialisableType.boolean:
if (isNullOrUndefined(data)) {
nativeArguments.push(null);
nativeArguments.push(false);
break;
}
// nullable booleans are java.lang.Booleans
Expand All @@ -286,12 +286,14 @@ export function toNativeArguments(
break;
case RNJavaSerialisableType.nonnullBoolean:
assert(
typeof data === 'boolean',
typeof data === 'boolean' || isNullOrUndefined(data),
`Argument at index ${i} expected a boolean, but got ${data}`
);

// booleans are auto-marshalled to BOOL.
nativeArguments.push(data);
nativeArguments.push(
isNullOrUndefined(data) ? false : (data as boolean)
);
break;

case RNJavaSerialisableType.string:
Expand All @@ -311,18 +313,18 @@ export function toNativeArguments(
break;

case RNJavaSerialisableType.int:
assert(
typeof data === 'number',
`Argument at index ${i} expected a number, but got ${data}`
);
nativeArguments.push(new java.lang.Integer(data));
if (isNullOrUndefined(data)) {
nativeArguments.push(new java.lang.Integer(0));
break;
}
nativeArguments.push(new java.lang.Integer(data as number));
break;
case RNJavaSerialisableType.nonnullInt:
assert(
typeof data === 'number',
typeof data === 'number' || isNullOrUndefined(data),
`Argument at index ${i} expected a number, but got ${data}`
);
nativeArguments.push(data);
nativeArguments.push(isNullOrUndefined(data) ? 0 : (data as number));
break;
case RNJavaSerialisableType.float:
if (isNullOrUndefined(data)) {
Expand All @@ -332,10 +334,12 @@ export function toNativeArguments(
// eslint-disable-next-line no-fallthrough
case RNJavaSerialisableType.nonnullFloat:
assert(
typeof data === 'number',
typeof data === 'number' || isNullOrUndefined(data),
`Argument at index ${i} expected a number, but got ${data}`
);
nativeArguments.push(float(data));
nativeArguments.push(
isNullOrUndefined(data) ? float(0) : float(data as number)
);
break;
case RNJavaSerialisableType.double:
if (isNullOrUndefined(data)) {
Expand All @@ -345,10 +349,12 @@ export function toNativeArguments(
// eslint-disable-next-line no-fallthrough
case RNJavaSerialisableType.nonnullDouble:
assert(
typeof data === 'number',
typeof data === 'number' || isNullOrUndefined(data),
`Argument at index ${i} expected a number, but got ${data}`
);
nativeArguments.push(double(data));
nativeArguments.push(
isNullOrUndefined(data) ? double(0) : double(data as number)
);
break;
case RNJavaSerialisableType.Callback:
if (isNullOrUndefined(data)) {
Expand Down

0 comments on commit 179f124

Please sign in to comment.