
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
react-native-lua
Advanced tools
Native Lua in React Native Heavily based on React Native JSI 😅. Working in both iOS and Android.
Lots of inspiration from ObjC-Lua and ilua.
The Lua source version (as of February 2022) is 5.4.4
.
os_execute
from loslib.c
to prevent calls to system(cmd)
from occuring (unavailable on iOS).npm install react-native-lua
cd ios && pod install
You need NDK installed. That's it.
Methods can be seen in the types.
Almost all methods are simply the same as known C api methods of the pattern lua_${methodName}
, sans the lua_
prefix.
import { luaInterpreter } from "react-native-lua";
// Create a new interpreter
const interp = luaInterpreter();
// this is equivalent to lua_dostring
interp.dostring(`a = 2
b = a ^ 2
a = b * 20
`);
// Or asynchronously! Each Lua Interpreter spawns its own thread when executing async code, so this doesn't block any other processes.
interp.dostringasync(`i = 0
while(i < 8)
do
print(i)
sleep(100)
i = i + 1
end`)
// The rest is up to you!
Since Lua is a scripting language, it wouldn't be nice if our code suddenly got stuck in a forever loop and blocks the whole program.
This library handles this condition by leveraging Lua runtime's lua_sethook
function (which allows us to monitor the code execution every N commands).
The property executionLimit
defines the number of milliseconds the script should run until it is terminated. Default value is 10000 (10 seconds). You can set this value by calling setExecutionLimit(ms)
dostringasync
and dofileasync
work on Android
dostringasync
is working perfectly well, however, in Android it is only possible to use dostring
since CallInvoker crashes immediately when InvokeAsync() is called. Any help in getting this working would be very much appreciated.See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
If you appreciate my work, help buy me some soda 🥤 via the following routes.
Stellar Lumens (XLM) :
GCVKPZQUDXWVNPIIMF3FXR6KWAOHTEWPZZM2AQE4J3TXR6ZDHXQHP5BQ
Cardano (ADA) :
addr1q9datt8urnyuc2059tquh59sva0pja7jqg4nfhnje7xcy6zpndeesglqkxhjvcgdu820flcecjzunwp6qen4yr92gm6smssug8
FAQs
Native Lua in React Native
We found that react-native-lua demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.