Generate and build Node-API bindings for MoonBit.
Dependencies
moon install unmbt/napi-mbt/cmd/napi-mbt-cli
napi-mbt-cli --helpmoon install ./cmd/napi-mbt-cli
moon install ./cmd/napi-mbt-cli --bin ~/.unmbtmoon build --target native --release cmd/napi-mbt-clicurl -fsSL https://raw.githubusercontent.com/unmbt/napi-mbt/master/scripts/install.sh | bashirm https://raw.githubusercontent.com/unmbt/napi-mbt/master/scripts/install.ps1 | iexmkdir my-napi-addon
cd my-napi-addon
npm init -y
npm install --save-dev @unmbt/napi-mbt-cli
npm install node-api-headersmoon new lib#export_name("mbt_add")
pub fn add(a : Int, b : Int) -> Int {
a + b
}napi-mbt-cli buildconst addon = require('./artifacts/win32-x64-msvc/napi_mbt.node');
console.log(addon.mbt_add(2, 3)); // Output: 5npm run publish:prepare
npm run publish:allfn napi_threadsafe_function_call(func : NapiThreadsafeFunction, data : UnmanagedBuffer, mode : Int) -> Unitfn napi_threadsafe_function_create(env : NapiEnv, func : NapiValue, async_resource : NapiValue, async_resource_name : NapiValue, max_queue_size : Int, initial_thread_count : Int, finalize_data : UnmanagedBuffer, finalize_cb : UnmanagedBuffer, context : UnmanagedBuffer, call_js_cb : UnmanagedBuffer) -> NapiThreadsafeFunctionInstall
Download zipGenerate and build Node-API bindings for MoonBit.
Dependencies