Skip to content

Commit

Permalink
Update README.md and desktop/README.md (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx authored Apr 3, 2024
1 parent 79e219b commit bbcdf1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,20 @@ stlite.mount(
);
```

### Data persistence
## File system

You can mount the IndexedDB-based file system ([`IDBFS`](https://emscripten.org/docs/api_reference/Filesystem-API.html#filesystem-api-idbfs)) to the specified directories by passing the `idbfsMountpoints` option as below. The mounted file system is persistent across the page reloads and the browser sessions, while the default file system ([`MEMFS`](https://emscripten.org/docs/api_reference/Filesystem-API.html#memfs)) is ephemeral.
_stlite_ executes your Python code on [Pyodide](https://pyodide.org/) in a browser, and Pyodide has its own Linux-like file system isolated from the host OS (see [Pyodide's](https://pyodide.org/en/stable/usage/file-system.html) or [Emscripten's](https://emscripten.org/docs/api_reference/Filesystem-API.html) documents about the FS for details).
The source code and data files are mounted on the file system, and the Python code can access it. So, for example, what `open("path/to/file")` reads or writes is the file on the file system virtually existing in the browser, not a file on the host OS.

The default file system ([`MEMFS`](https://emscripten.org/docs/api_reference/Filesystem-API.html#memfs)) is ephemeral, so the files saved in the directories are lost when the page is reloaded.
The root `/` and some directories including home are mounted as `MEMFS`, the ephemeral file system, by default.

### File persistence with IndexedDB backend

To persist the files across the app restarts, you can use the IndexedDB-based file system ([`IDBFS`](https://emscripten.org/docs/api_reference/Filesystem-API.html#filesystem-api-idbfs)). The files saved in the directories mounted with `IDBFS` are stored in the browser's IndexedDB, so they are persistent across the app restarts.

In the case of `@stlite/mountable`, you can mount the IndexedDB-based file system, `IDBFS` to the specified directories in the virtual file system, by passing the `idbfsMountpoints` option as below.
The mounted file system is persistent across the page reloads and the browser sessions.

```js
stlite.mount(
Expand Down
4 changes: 2 additions & 2 deletions packages/desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Convert your [Streamlit](https://streamlit.io/) application into a desktop app w
To make your app secure, be sure to use the latest version of Electron.
This is [announced](https://www.electronjs.org/docs/latest/tutorial/security#16-use-a-current-version-of-electron) as one of the security best practices in the Electron document too.

## Configure app
## Configure the app

### Hide the toolbar, hamburger menu, and the footer

Expand Down Expand Up @@ -125,7 +125,7 @@ In the example below, `"."` on the host OS file system is mounted to the `/mnt`
}
```

#### NodeJS worker mode
### NodeJS worker mode

`@stlite/desktop` runs your app on [Electron](https://www.electronjs.org/) as a desktop app.
Electron apps have two processes: the main process which is a Node.js process running in the background, and the renderer process which is a Chromium (browser) process running the app's UI.
Expand Down

0 comments on commit bbcdf1c

Please sign in to comment.