cerc-io / watcher-ts

GNU Affero General Public License v3.0
12 stars 3 forks source link

Watcher stack in the browser ideas #189

Open dboreham opened 2 years ago

dboreham commented 2 years ago

Watcher code should run in the browser since it's written in TypeScript/JS. However, the watcher databases are currently hosted in PostgreSQL servers. In order to host the entire watcher stack in the browser, some way to host the databases in-browser is required.

This is not trivial because browsers don't natively support sql databases but there appear to be some plausible options:

https://github.com/sql-js/sql.js/ is a wasm compilation of SQLite. As-is it does not have persistence (data is loaded into memory and vanishes on browser tab close / power off). But, this project is an implementation of a virtual filesystem for sql.js using IndexedDB: https://github.com/kikko-land/better-absurd-sql

This note details the current browser storage limits for IndexedDB: https://stackoverflow.com/a/63019999

dboreham commented 2 years ago

Info on a new browser feature that (finally) allow filesystem access from WASM, being used under sql.js: https://twitter.com/geoffreylitt/status/1573693207640244229

dboreham commented 1 year ago

https://sqlite.org/wasm/doc/tip/about.md