-
Notifications
You must be signed in to change notification settings - Fork 0
Add a Module
Run the generator from the root of a Supernote plugin that already builds successfully.
The generator requires:
PluginConfig.json
package.json
android/
android/settings.gradle # or settings.gradle.kts
Check the generator and the backend you plan to use without changing files:
supernote-module doctor --type nativeUse --type jni or --type jsi for a C/C++ backend.
supernote-moduleChoose Add module, then Native Module:
| Prompt | Example | What it becomes |
|---|---|---|
| Package name | local-math |
local_modules/local-math/, dependency name, and import string |
| Description | leave empty | Optional local package metadata |
| JavaScript name | accept Math
|
Object imported by JavaScript or TypeScript |
| Android namespace | accept com.example.math
|
Kotlin/Java package and generated path |
| Package version | accept 0.1.0
|
Version of the local package |
| Install the local dependency now? | Yes | Links the package using your plugin's package manager |
Note: The package name, JavaScript name, and Android namespace must be unique. Update cannot rename a module or change its backend.
Non-interactive:
supernote-module add local-math --type native --yesEdit:
local_modules/local-math/android/src/main/java/com/example/math/Example.kt
package com.example.math
import com.example.math.nativemodule.annotation.SupernoteExport
class Example {
@SupernoteExport
fun add(left: Double, right: Double): Double = left + right
}Edit Example.kt; the other files in the package are generated. See
Files the Generator Creates before
customizing anything else.
The generated package has one default export:
import Math from 'local-math';
const total = await Math.add(20, 22);Native and JNI value-returning exports use Promises. JSI exports return synchronously. Export Functions lists the supported signatures and call models.
supernote-module validate local-math --buildValidate checks that the generated package is linked correctly. --build also
compiles it through your plugin's Android project. Add --verbose when
diagnosing a failed build.
If Add used --skip-install, run the normal npm install or yarn install
command for your plugin before validating.
Then build and test your plugin as usual. Use the official Supernote documentation for that workflow.
- JNI Modules uses editable C/C++ and Promise-based calls.
- JSI Modules uses editable C/C++ and synchronous calls, with additional host-runtime requirements.
Commit before Update or Remove, then read Managing Modules.