js: Add more API and README
This commit is contained in:
43
js/README.md
Normal file
43
js/README.md
Normal 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!');
|
||||||
|
```
|
||||||
10
js/index.js
10
js/index.js
@@ -3,7 +3,7 @@ function getUniqueCallbackName() {
|
|||||||
return `_callback_${Date.now()}_${callbackCounter++}`;
|
return `_callback_${Date.now()}_${callbackCounter++}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function exec(command, options) {
|
export function exec(command, options) {
|
||||||
if (typeof options === "undefined") {
|
if (typeof options === "undefined") {
|
||||||
options = {};
|
options = {};
|
||||||
}
|
}
|
||||||
@@ -46,3 +46,11 @@ function exec(command, options) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fullScreen(isFullScreen) {
|
||||||
|
ksu.fullScreen(isFullScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function toast(message) {
|
||||||
|
ksu.toast(message);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "kernelsu",
|
"name": "kernelsu",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"description": "Library for KernelSU's module WebUI",
|
"description": "Library for KernelSU's module WebUI",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user