-
Notifications
You must be signed in to change notification settings - Fork 0
Export Functions
The generator discovers marked Kotlin/Java methods or C++ functions and creates the bridge, registration, and TypeScript declaration needed by the existing plugin.
| Name | Controls |
|---|---|
| Package name |
local_modules/ path, local dependency, import string, and metadata identity |
| JavaScript name | Generated Native/JSI object and declarations |
| Android namespace | Kotlin/Java package and generated source path |
| Export name | Function property exposed on the generated object |
For package local-math, the generator derives JavaScript name Math and
namespace com.example.math. Explicit CLI options override those suggestions.
Write .kt or .java below the generated implementation path:
local_modules/<package>/android/src/main/java/<namespace-path>/
Use the annotation generated for that module:
import com.example.math.nativemodule.annotation.SupernoteExport
class Example {
@SupernoteExport
fun add(left: Double, right: Double): Double = left + right
@SupernoteExport(name = "greet")
fun makeGreeting(name: String): String = "Hello, $name"
}The processor accepts:
- public instance methods on concrete public classes;
- unique export names;
- a public constructor taking
ReactApplicationContext, AndroidContext, or no arguments, in that preference order.
It rejects suspend, inline, operator, static, generic, extension, and vararg exports.
| Kotlin/Java boundary | Generated TypeScript | Call behavior |
|---|---|---|
Boolean / boolean
|
boolean |
Promise when returned |
Double / double
|
number |
Promise when returned |
String |
string |
Promise when returned |
Unit / void return |
void |
Fire-and-forget |
Nullable values, collections, arrays, objects, integer-specific types, floats, callbacks, and arbitrary Android objects are not supported by this generator.
import Math from 'local-math';
const total = await Math.add(20, 22);
Math.setEnabled(true); // Unit/void exportWrite JNI or JSI implementation below:
local_modules/<package>/android/src/main/cpp/
Place the marker immediately before a top-level C++ definition:
// @SupernoteExport
double add(double left, double right) {
return left + right;
}
// @SupernoteExport(name = "greet")
std::string makeGreeting(std::string name) {
return "Hello, " + name;
}Supported boundary types are exactly bool, double, and UTF-8 std::string
by value, plus void returns. noexcept is supported.
The generator rejects overloaded, namespaced, templated, static, inline,
constexpr, extern "C", variadic, pointer, reference, default-argument, and
decorated export signatures. Parameters and export names must be unique and
explicitly named.
.cc, .cpp, and .cxx files may export. .c files compile as C23 and may
provide internal helpers, but cannot contain export markers. Generated bindings
and C++ sources compile as C++23.
JNI value returns use Promises:
import MathJni from 'local-math-jni';
const total = await MathJni.add(20, 22);JSI returns and errors are synchronous:
import MathJsi from 'local-math-jsi';
const total = MathJsi.add(20, 22);The implementation files above are user-owned and preserved by Update. Generated annotations, processors, bridges, bindings, declarations, registration, Gradle, and CMake are generator-owned and replaceable. Remove deletes the complete generated module, including implementation source.