Skip to content

Repository files navigation

Supernote Module Generator

A code generator that adds Native, JNI, and JSI modules to an existing Supernote plugin.

It creates a local module package and connects it to your plugin. You write the Kotlin, Java, C, or C++ function; the generator creates the bridge, build configuration, TypeScript declarations, and React Native linking.

Before using this tool

You need a working Supernote plugin that already builds successfully. Creating, packaging, installing, and debugging that plugin are outside this project's scope; use the official Supernote documentation for that workflow.

Run this generator when the existing plugin needs native functionality.

Install

Python 3.9 or newer is required:

python3 -m pip install supernote-module-generator

Run it from the root of the existing plugin:

supernote-module

To check requirements first, run supernote-module doctor --type native, supernote-module doctor --type jni, or supernote-module doctor --type jsi.

Add native functionality

For example, choose Add module, Native Module, and package name local-math. Accept the derived JavaScript name Math and Android namespace com.example.math.

Then edit the generated implementation file:

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
}

Call it from the existing plugin:

import Math from 'local-math';

const answer = await Math.add(20, 22);

For building, installing, and debugging the plugin itself, continue with the official Supernote documentation.

Choose a backend

Type Write Call model Use it for
native Kotlin or Java Promise for returned values Android APIs and Kotlin/Java libraries
jni C or C++ behind JNI Promise for returned values C/C++ work that can be asynchronous
jsi C or C++ through JSI Synchronous Short JavaScript-thread work on a tested PluginHost

JSI is a supported generator backend. Runtime execution still depends on the target PluginHost, firmware, linker namespace, and SELinux policy.

Documentation

The Wiki documents only the native-module generator:

For exact options in the installed version:

supernote-module help add

Contributing

See CONTRIBUTING.md when changing the generator itself.

License

MIT. See LICENSE.

About

Generate Kotlin/Java, JNI C/C++, and JSI modules for Supernote plugins

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages