denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.41k stars 5.18k forks source link

[Feature Request] Add support for Origin Private File System (OPFS) #17833

Open okikio opened 1 year ago

okikio commented 1 year ago

OPFS seems to be the standard way for Web Apps to write to temp storage, files and folders they'd need to work with. It would be cool and convinient if Deno supported OPFS out of the box like it currently does for the Cache API. IMO, that would allow web apps to have ultimate compat with Deno.

It would also be pretty cool if you also supported the File System Access API, to keep web compat.

lino-levan commented 1 year ago

I believe this needs infrastructure from the web locks api (https://github.com/denoland/deno/issues/15905). @load1n9 has taken a few stabs at it (https://github.com/denoland/deno/pull/16566 and https://github.com/denoland/deno/pull/16346) but it definitely isn't trivial. I'm working on a polyfill at the moment and ran into this.

Ciantic commented 1 year ago

This would be nice.

SQLite's official WASM module is using OPFS.

import sqlite3InitModule from "npm:@sqlite.org/sqlite-wasm";
const sqlite3 = await sqlite3InitModule();
const db = new sqlite3.opfs.OpfsDb("my-db", "c");
// ...

Currently with Deno it's possible to use in-memory databases with official SQLite WASM module.

const db = new sqlite3.oo1.DB()
// ... this works, but one must then serialize database to store it
okikio commented 1 year ago

@Ciantic Yeah, this would be amazing.

tarasglek commented 1 week ago

opfs would be awesome, esp if i could implement it on deno kv or indexdb, or actual filesystem