solijs
Version:
Tool that can link shared object (.so) files to your JavaScript project and expose symbols dynamically.
168 lines (103 loc) • 3.81 kB
Markdown
# solijs
[](https://www.npmjs.com/package/sljs)
[](https://github.com/JeckAsChristopher/solijs/releases)
[](LICENSE)
[](https://github.com/JeckAsChristopher/solijs/issues)
[](https://github.com/JeckAsChristopher/solijs/actions/workflows/build.yml)
**solijs** is a prebuilt native Node.js module that links and interacts with Linux `.so` (shared object) files directly from JavaScript using the N-API interface.
This tool allows you to:
- Run functions inside `.so` files (both `void` and `int` returning)
- Capture their output (text or return values)
- Inspect dynamic symbols defined inside the `.so`
## Update Logs
**Deprecated packges**
1. *1.8.0-prerelease* — due to large size thr deps remove and add something better
2. *2.4.0* — Corrupted packages(has a lot of errors)
**Release packages**
1. *1.9.0-alpha* — removes the deps folder(a big size folder)
2. *2.0.0* — added new features such as outputting arrays, buffers and more!
3. *2.3.1* — **Now Suppport stdout prompting, and like chatbot!**
4. *2.4.5* — **Binding gyp support are now release!** **Prebuilt is still supported.**
5. *2.5.6* — **Added functions such as args and machine code output, enhances the system and fix bugs**
6. *2.6.2* — **Supports Game Logics But with limit**
> updates coming soon!
## Installation
### 1. Install the module
```bash
npm install sljs
```
> The native `node` is precompiled in Pb dir
## Usage
### Load the module
```js
const sljs = require('sljs');
```
### `runText(path, symbol)`
Runs a `void` function from `.so` and captures `stdout`.
```cpp
// C source example (text.c)
#include <stdio.h>
void say_hello() {
printf("Hello from C shared object!\n");
}
```
**Compile:**
```bash
gcc -fPIC -shared -o libtext.so text.c
```
**Call from JS:**
```js
const output = sljs.runText('./libtext.so', 'say_hello');
console.log(output); // "Hello from C shared object!"
```
### `runValue(path, symbol)`
Runs an `int`-returning function and returns the result.
```cpp
// C source example (value.c)
int give_number() {
return 69420;
}
```
**Compile:**
```bash
gcc -fPIC -shared -o libvalue.so value.c
```
**Call from JS:**
```js
const num = sljs.runValue('./libvalue.so', 'give_number');
console.log(num); // 69420
```
### `inspect(path)`
Inspects available dynamic symbols from `.so` using `nm`.
```js
const symbols = sljs.inspect('./libvalue.so');
console.log(symbols); // List of symbol lines (like from `nm -D`)
```
## Use Cases
- Custom algorithms written in C/C++ (like hashing or compression)
- Wrapping performant native logic for JS access
- Interfacing low-level Linux `.so` modules
- Fast native extensions without recompiling every install
## License
MIT
Author: Jeck Christopher Anog
## Disclaimer
This module does **not** decompile `.so` files. It **exposes and interacts** with dynamic symbols using safe, flexible bindings.
## Warning
**DO NOT INSTALL ANY DEPRECATED PACKAGES AS IF DECLARED VULNERABLE TO ANY THREATS!**
## How to install prebuilt binaries
1. Go to my Github Repository(Link in the bottom)
2. Find the Pb folder
3. After that download it raw and download all the files except binding.gyp
4. test it and if it works, congrats u've install the npmjs package without thr node-gyp!
>Note: The Prebuilt is only for device that doesn't support node-gyp.