-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add WebTorrent VFS #21
Conversation
That's cool! This seems like something that belongs in its own repo. I'd like to limit the scope of this project to enabling extensions like yours, and not so much to be their home. I'm just not prepared to support contributed code that I may not completely understand, and I haven't figured out what I want to do about CLAs. I would definitely like to link to your VFS, though. If that's okay with you then can you give me a sentence or two of accompanying description and where you want the link to go? They can be updated later if necessary, e.g. I'd be happy to link to your fork now and a standalone repo later. |
I totally understand that. It is not really desirable to add a webtorrent dependency to wa-sqlite. Do you think it is possible/feasible to create a wa-sqlite-base package that basically only contains VFS.js (the abstract base vfs and consts). That way vfs implementations could easily depend on it to get a typed interface they need to implement. The full wa-sqlite is then only required for tests or the actual user of the vfs. Since the vfs api is very stable this package probably will rarely change (or require maintenance). I will try to setup a wa-sqlite-webtorrent package in the next days or on the weekend. Or do you have a better name suggestion? P.S. I also noticed some sqlite constants are duplicated between VFS.js and sqlite-api.js. This could also be resolved by having all consts in wa-sqlite-base. |
Javascript is not my primary language either, which is why I'm not great with the tooling. 😀 The project is not on npm, so you'll need to use a git dependency. I would recommend using a "buildless" branch or tag instead of the master branch. I haven't been good about versioning and tagging; I'll try to be better going forward. Originally VFS.js was considered example code, and it really still is just a convenience to help with implementing a VFS. There's no requirement to subclass from it; any object that has the appropriate properties will work. If you would rather bypass subclassing or copy VFS.js into your own tree, those are also options. I'm not clear on the advantages of a standalone VFS base class package - it seems to me that you would need the wrapper API at least as a devDependency for testing, and users will need the API to incorporate it. Your repo/package name is totally up to you. The duplication of constant definitions is indeed annoying. I'll see about changing that. |
Hi @rhashimoto, I have created 3 repos: I still think that wa-sqlite-base could be useful for other vfs implementations. Especially since I added an abstract name function and a close function to the SQLiteVFS interface. My intention for that was, that a name function is much more obvious than requiring that a name property exists. But for that to work properly, it would be nice if you could switch The idea behind A bit offtopic, have you considered switching to typescript? I found it easier to write typescript and have the Regarding this PR I will close it now. |
Re Typescript, I like to develop without a build step as much as I can get away with. There was a time when Typescript's advantages could overcome that, but modern Javascript and its browser support (along with Microsoft's willingness to adapt VSCode Typescript tooling to Javascript projects, like supporting JSDoc typing) have advanced to the point that I prefer working with plain Javascript. |
@rhashimoto You can use Deno to develop in TypeScript and deno bundle to make a bundle for browsers. The advantage of Deno is all batteries are included. Tests, Docs, etc. And you don't have to public to npm :-) |
@steida That said, I really love the ideas behind deno. I was holding off because of WebCrypto but I see it's there now so I'll have to check again whether there's any remaining reason not to migrate. |
Hi @rhashimoto and thanks for your awesome work,
I have implemented a WebTorrent based read only VFS. Do you want to add it to the examples?
It will probably never be really fast but being able to "serverless" host a database is very interesting. In combination with a webseed this is also very similar to sql.js-httpvfs (Thanks @phiresky by the way for introducing me into this topic).
To make sure the demo always works it also uses a webseed (the GOOG.db file). To truly test the torrenting you have to open a new tab at https://instant.io/ and add the GOOG.db, which then acts as another peer. Also the adding of the webseed url has to be removed in demo/index.js:L64. When using a magnetUri you may have to increase the torrent ready timeout option of WebTorrentVFS, because loading the meta information from peers is rather slow.