Skip to content

Commit

Permalink
more documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Feb 27, 2024
1 parent 7a8200c commit 275de38
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 19 deletions.
88 changes: 71 additions & 17 deletions documentation/Anura-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,71 @@ This API provides access to Anura's x86 backend; Which is used to create PTYs, w

```js
anura.x86.emulator; // Get v86 emulator object
```

### anura.x86.openpty

This allows you to open a PTY and run commands inside of it. It returns the number of the PTY and is used in other interactions.

```js
const pty = await anura.x86.openpty(
"TERM=xterm DISPLAY=:0 bash",
screenSize.width,
screenSize.height,
(data) => {
// callback gets called every time the PTY returns data
},
);
```

### anura.x86.writepty

This allows you to send data to a PTY. This data should be a string or converted to one.

anura.x86.openpty; // Open a PTY terminal (see usage in sourcecode for terminal.app)
```js
const pty = await anura.x86.openpty(
"TERM=xterm DISPLAY=:0 bash",
screenSize.width,
screenSize.height,
(data) => {
console.log(data);
},
);
anura.x86.writepty(pty, "Hello World!");
```

### anura.x86.resizepty

This allows you to send resize a PTY.

```js
const pty = await anura.x86.openpty(
"TERM=xterm DISPLAY=:0 bash",
screenSize.width,
screenSize.height,
(data) => {
console.log(data);
},
);
anura.x86.resizepty(pty, screenSize.height, screenSize.width);
```

## anura.wm

### anura.wm.create

This api allows you to create a window that will be displayed in the DE.

Usage

```js
let win = anura.wm.create(instance, {
title: "Example Window",
width: "1280px",
height: "720px",
});

// do things with the window that gets returned
```

## anura.net
Expand All @@ -52,10 +115,6 @@ This API provides access to Anura's networking backend, for routing your request
anura.net.fetch; // Same functionality as built in fetch function

anura.net.WebSocket; // Same functionality as built in WebSocket constructor

anura.net.Socket; // Open a TCP Socket

anura.x86.TLSSocket; // Open a TCP socket but using TLS
```

## anura.fs
Expand All @@ -82,19 +141,14 @@ This API provides access to Anura's notification service, useful if you need to
**Usage:**

```js

anura.notifications.add({

title: "Test Notification",

description: `This is a test notification`,

callback: function() {console.log('hi')}

timeout: 2000

}) // Show a notification to the user, on click, it says hi in console, it lasts for 2 seconds.

title: "Test Notification",
description: `This is a test notification`,
callback: function () {
console.log("hi");
},
timeout: 2000,
}); // Show a notification to the user, on click, it says hi in console, it lasts for 2 seconds.
```

## anura.wsproxyURL
Expand Down
4 changes: 2 additions & 2 deletions documentation/appdevt.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ AnuraOS libraries are just like apps but contain utilities or functionality that
- `package` is the package name of the library.
- `versions` is a map of version numbers to entry points.
- `installHook` is a file that is run when the library is installed. It should have a default export that is a function that takes the anura instance as an argument.
- `currentVersion` is the current version of the library, which will be used as the default version when using the `anura.import` api.
- `currentVersion` is the current version of the library, which will be used as the default version when using the [`anura.import`](./Anura-API.md#anuraimport) api.

## Usage

- Libraries can be imported using the `anura.import` api. This api takes the package id of the library and an optional version number. The version number is specified by appending `@<version>` to the package id. If no version is specified, the current version of the library is used.
- Libraries can be imported using the [`anura.import`](./Anura-API.md#anuraimport) api. This api takes the package id of the library and an optional version number. The version number is specified by appending `@<version>` to the package id. If no version is specified, the current version of the library is used.

```js
anura.import("anura.examplelib@1.0.0").then((lib) => {
Expand Down

0 comments on commit 275de38

Please sign in to comment.