js: Add more API and README

This commit is contained in:
weishu
2024-02-22 22:09:13 +08:00
parent 811c68cac0
commit b904680f13
3 changed files with 53 additions and 2 deletions

43
js/README.md Normal file
View File

@@ -0,0 +1,43 @@
# Library for KernelSU's module WebUI
## Install
```sh
yarn add kernelsu
```
## API
### exec
Execute a command in the **root** shell.
options:
- `cwd` - Current working directory of the child process
- `env` - Environment key-value pairs
```javascript
import { exec } from 'kernelsu';
const { stdout, stderr } = await exec('ls -l', { cwd: '/tmp'});
console.log(stdout);
```
### fullScreen
Request the WebView enter/exit full screen.
```javascript
import { fullScreen } from 'kernelsu';
fullScreen(true);
```
### toast
Show a toast message.
```javascript
import { toast } from 'kernelsu';
toast('Hello, world!');
```