TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

SQLite Wasm in the browser backed by the Origin Private File System

372 点作者 bubblehack3r超过 2 年前

22 条评论

mckravchyk超过 2 年前
I think this will be great for extensions. Currently the only solid choice is to use the dead simple storage.local which only allows to retrieve things by ID.<p>There&#x27;s one problem though, this new API is for the web, so the nature of this storage is temporary - obviously the user must be able to clear it when clearing site data and this what makes it currently an unviable solution for a persistent extensions data storage. <a href="https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;chromium&#x2F;issues&#x2F;detail?id=1383216" rel="nofollow">https:&#x2F;&#x2F;bugs.chromium.org&#x2F;p&#x2F;chromium&#x2F;issues&#x2F;detail?id=138321...</a>
评论 #34359618 未加载
评论 #34363088 未加载
评论 #34363735 未加载
评论 #34362628 未加载
评论 #34358436 未加载
DylanSp超过 2 年前
Does anyone have hands-on experience with how well different browsers support this? This blog post and caniuse both say Chrome support is currently somewhat limited (though being improved); caniuse also mentions that Safari (both desktop and iOS) only support the Origin Private File System part of the File System API, and that Firefox doesn&#x27;t support it all. I&#x27;m curious how all that actually shakes out in practice.
评论 #34356016 未加载
评论 #34355596 未加载
评论 #34357164 未加载
评论 #34355481 未加载
samwillis超过 2 年前
This is a nice overview!<p>Discussion from back when the SQLite project announced this last year: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33374402" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33374402</a><p>There isn&#x27;t an &quot;official&quot; NPM package or ES6 model yet, but I believe they are working on it. It&#x27;s also very much designed for the browser currently, but again I believe they are intending to support server WASM environments too eventually.
评论 #34357650 未加载
评论 #34355130 未加载
est超过 2 年前
TIL OPFS.<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;File_System_Access_API#origin_private_file_system" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;API&#x2F;File_System...</a><p>What&#x27;s next, mmap() for javascript?
评论 #34354706 未加载
评论 #34354747 未加载
评论 #34361169 未加载
评论 #34358203 未加载
评论 #34362856 未加载
评论 #34354537 未加载
Zuiii超过 2 年前
The custom header requirement will make this version of sqlite unusable for many usecases. Can SQLite fallback to using slower persistant APIs if neither Cross-Origin-Opener-Policy or Origin-Embedder-Policy are set? If not, does the SQLite project intend to provide a version that would?<p>Devs who don&#x27;t need the high performance but want wider compatibility will probably continue to use the &quot;unofficial&quot; versions.<p>Also, last I checked, you could definitely load web assembly in a page that has a File:&#x2F;&#x2F;&#x2F; origin.
smallerfish超过 2 年前
Very nice. I hope Firefox end up supporting OPFS.<p>My use case is an entirely offline webapp that I&#x27;m building as a side project, partly just to see what is possible. I&#x27;ve tried indexeddb, pouchdb, absurd-sql, and various others, and have ended up back at localstorage, which is plain but low on edge cases.<p>The other big pain point I am hacking around is cross device sync; I&#x27;m leaning towards simple chrome and firefox extensions that&#x27;ll slurp data into your profile in order to sync, which&#x27;ll work for cross computer sync for my needs. However, chrome on android doesn&#x27;t support extensions, and there&#x27;s no other good way that I&#x27;ve found to sync between a user&#x27;s chrome profile and android, so that is still a hole in the story. Some kind of webrtc based thing is imaginable, but it&#x27;s clunky.
评论 #34356239 未加载
Kelteseth超过 2 年前
Fun fact: The headline image is the Stadtbibliothek Stuttgart, the nicest library I ever visited: <a href="https:&#x2F;&#x2F;www.archdaily.com&#x2F;193568&#x2F;stuttgart-city-library-yi-architects" rel="nofollow">https:&#x2F;&#x2F;www.archdaily.com&#x2F;193568&#x2F;stuttgart-city-library-yi-a...</a>
评论 #34356082 未加载
gfodor超过 2 年前
Ironically I was just about to drop in absurd-sql [1] to a project, which uses indexeddb to back SQLite. This seems better.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql">https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql</a>
评论 #34355258 未加载
评论 #34354512 未加载
评论 #34354996 未加载
throwaway284534超过 2 年前
This is honestly very cool. VS Code uses a similar approach to their local file system provider, albeit with a wrapper around IndexDB instead of SQLite. There’s some interesting trade offs too, since IndexDB can store the browser’s native file handlers in a flat map — so there’s no need for a schema.<p>IMO, the Chrome team is being a bit deceptive with their phrasing on synchronous file handles. The problem is that the entire API is wrapped up in an asynchronous ceremony. `createSyncAccessHandle` is only available in a worker context. So you can only communicate with the worker using an asynchronous postMesssage event dispatcher. And even when you’re in the worker, file handles can only be accessed through methods that return a promise.<p>I understand the need for such boundaries when working with a single threaded language, but limiting the synchronous APIs to just workers seems like one too many layers of indirection. I recently attempted to write a POSIX-style BusyBox library and this sort of thing was a total show stopper.
评论 #34356558 未加载
rektide超过 2 年前
I have yet to see whether implementations allow users direct access via the filesystem to these contents. The idea of each origin having some files sounds fine. But if I genuinely want to help &amp; empower my users, give them the most user agency, I&#x27;d want them to be able to access the sqlite sb themselves directly, with whatever hazards they thereby assume.
评论 #34354814 未加载
typingmonkey超过 2 年前
Using SQLite in the browser is great until you have users that open your app in more then one browser tab.
评论 #34355315 未加载
评论 #34355149 未加载
评论 #34355603 未加载
评论 #34355557 未加载
评论 #34359281 未加载
评论 #34355323 未加载
msie超过 2 年前
I was so disappointed when sqlite&#x2F;websql was ditched in favour of IndexedDB. What were they thinking? Too smart for their own good?
评论 #34364096 未加载
tristanho超过 2 年前
Does anyone have a good idea of when OPFS will be broadly available in all major browsers? And what&#x27;s best to use as a pseudo-polyfill in the mean time?<p>Something relevant is absurd-sql, but unfortunately that&#x27;s not even close to production ready :&#x2F;<p><a href="https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql">https:&#x2F;&#x2F;github.com&#x2F;jlongster&#x2F;absurd-sql</a>
tarasglek超过 2 年前
I wanted to use it in a chrome extension worker, but sync version of OPFS isn&#x27;t available in that context. Hope this gets fixed.
justinclift超过 2 年前
Interesting. Looks like the data persisted to disk should be available for opening via traditional SQLite GUI tools too (eg sqlitebrowser.org), though Chrome&#x2F;Chromium would probably need to be not running at the same time for safety.
Existenceblinks超过 2 年前
The sqlite.wasm is 683kB and the sqlite.js is 300kB. So is it supposed to be used in PWA context where these files are cached? Why no one is talking about CAP here. Is it real-production-ready?
评论 #34355284 未加载
rasz超过 2 年前
we could call it WebSQL
systems超过 2 年前
what is exactly the use case for this?
评论 #34354238 未加载
评论 #34354203 未加载
评论 #34356495 未加载
评论 #34355783 未加载
评论 #34355428 未加载
评论 #34354556 未加载
评论 #34355728 未加载
评论 #34354337 未加载
mg超过 2 年前
Let&#x27;s hope Firefox starts to support the File System Access API soon.<p>For me, it is the last missing piece to make web apps as comfortable as native apps.<p>I use a lot of web apps I fine-tuned exactly to my liking. I do all my writing in this web app for example: <a href="https:&#x2F;&#x2F;www.gibney.org&#x2F;writer" rel="nofollow">https:&#x2F;&#x2F;www.gibney.org&#x2F;writer</a> - I hit F11 and boom! I am in distraction free writing heaven :)<p>If Firefox would support the File System Access API, it would be much more comfortable to load and save my writings.
评论 #34355777 未加载
评论 #34356224 未加载
评论 #34359768 未加载
yyyk超过 2 年前
The Web SQL standard was deprecated (by Mozilla) on the grounds of a single implementation.<p>The result today: A single SQL implementation with no standard (beyond SQLite) and therefore no easy way for anyone to create a compatible alternate implementation.
评论 #34355255 未加载
评论 #34355133 未加载
评论 #34355546 未加载
评论 #34355241 未加载
评论 #34355240 未加载
评论 #34359812 未加载
pfoof超过 2 年前
Cybersec is like &quot;here we go again&quot;
评论 #34359946 未加载
helf超过 2 年前
Yay. More ways for people to force webapps upon us.<p>I miss when the web was essentially a document viewer.
评论 #34355534 未加载
评论 #34355967 未加载
评论 #34355339 未加载
评论 #34359823 未加载