Skip to content

Commit

Permalink
add initial documentation for system libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Feb 27, 2024
1 parent 65efca0 commit 92bd9c8
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
2 changes: 0 additions & 2 deletions documentation/Anura-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ browser.openTab("https://google.com/");

AnuraOS provides some preinstalled libraries to help streamline the development experience. This includes the browser library as shown above, along with the anura persistence library and the file picker.

<!-- TODO: Document some preinstalled libraries here -->

## anura.x86

This API provides access to Anura's x86 backend; Which is used to create PTYs, write directly to serial terminals (not recommended) or access v86 itself.
Expand Down
32 changes: 32 additions & 0 deletions documentation/appdevt.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,35 @@ anura.import("anura.examplelib@1.0.0").then((lib) => {
let lib = await anura.import("anura.examplelib");
// Do stuff with the library.
```

# System Libraries

Anura has a assortment of preinstalled system libraries to streamline the developer experience. This part of the documentation outlines how to use them in your application using the [`anura.import`](./Anura-API.md#anuraimport) api.

## libbrowser

This library allows you to interact with Anura's browser. Instead of using `window.open` in your anura apps, using this API will ensure that the webpage will open up in the Anura Browser.

Usage:

```js
const browser = await anura.import("anura.libbrowser");

browser.openTab("https://google.com/");
```

## libfilepicker

This library allows you to select files from inside of anura's filesystem. It returns a path and supports both files and folders.

```js
let picker = await anura.import("anura.filepicker");
// select file of any type
let file = await picker.selectFile();
// regex supported
let fileWithFilter = await picker.selectFile(
"(png|jpe?g|gif|bmp|webp|tiff|svg|ico)",
);
// select folder
let folder = await picker.selectFolder();
```
5 changes: 4 additions & 1 deletion public/anura-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ workbox.routing.registerRoute(
url.pathname = "/index.html";
}
if (url.password)
return new Response("<script>window.location.href = window.location.href</script>", {headers: {"content-type": "text/html"}});
return new Response(
"<script>window.location.href = window.location.href</script>",
{ headers: { "content-type": "text/html" } },
);
const basepath = "/anura_files";
let sh = new fs.Shell();
// this is more annoying than it needs to be because this uses an old-ass compiler which doesn't like promises
Expand Down

0 comments on commit 92bd9c8

Please sign in to comment.