-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Unified API for Browser and Native ? #6
Comments
Hey gedw99! 👋 Yes, hackpadfs is definitely intended to be a unified API.
The implementations could be platform-specific, depending on which system APIs are present. For example, `indexeddb.FS` is supported anywhere an IndexedDB API exists, e.g. browsers. The `os.FS` provides the same abstraction and uses the standard library `os` package instead.
and Native ( mobile and desktop)
I'm open to supporting a new FS for native. Did you mean React Native here? I haven't tried them together before, though.
React Native's docs recommend <https://reactnative.dev/docs/security#async-storage> Async Storage or a platform-specific secure storage option. I found an IndexedDBShim with an open issue <indexeddbshim/IndexedDBShim#313> to support React Native, but it's not exactly simple.
Async Storage appears to support some kind of batching <https://react-native-async-storage.github.io/async-storage/docs/api#multiget>, possibly as transactions? It might even be a good candidate for a `keyvalue.TransactionStore`.
|
Sorry my Native I meant Desktop and Mobile. i am planning to use it with gioui. https://github.com/gioui/gio In terms of this project it would possible be interesting for you |
Got it, no worries. I think it should work natively on several of the gio supported platforms. Linux, macOS, and Windows for sure with the os.FS. WebAssembly in a browser with indexeddb.FS. I’m less sure about today’s support for the others, but maybe they could be supported too.
I think iOS, tvOS, and Android might work today. Go could theoretically target those platforms via CGO, just not sure what their os package support looks like.
|
Ok thanks. I think this is viable. In relation to CGO, GIOUI has some fragmented support for Reading and Writing to the File System when selecting a File to Open or Save : https://github.com/gioui/gio-x/blob/main/explorer/README.md i started to make a GIOUI based example using Hack-pad. I got WASM working easily. But got stuck on Native ( Desktop and Mobile ). The reason i got stuck was that i found it hard to see how to do it in the API. Is there any chance you could make a repo called "TestHarness" in Hack-pad that loads the required instance objects of the FS for WASM and Non Mobile, so i can get past this. Then I have a basis to keep working on getting things working with GIOUI. My aim it to make a fully working example that combines the GIOUI Explorer, and a FS. This would provide a pretty stable basis for how devs can integrate FS aspects into their Apps. Eventually getting it upstreamed into GIOUI repo. |
(I'm realizing now my email replies are quite poorly formatted, here's another attempt:)
Very cool, thanks for sharing!
Theoretically, running natively should be as easy as using the os.FS on its own. I'm not very familiar with direct file system access on mobile devices, but it should behave correctly on macOS, Linux, and Windows.
I do see what you mean, there's not many (or any?) examples using hackpadfs in our reference docs yet. I'll put some together to help make that clearer. 👍 |
Hey @JohnStarich thanks for the docs. it's clear how to do it. BTW thanks for responding to this so fast and making it happen ! But the docs looks pretty good. It's pretty much what i ended up doing in my code to kick the tires. I am adding @inkeliz and @whereswaldon as i think both may be interested to a degree in this, but can say for sure. |
Merged! Thanks for taking a peek @gedw99. Welcome all, let us know what's missing or not working for native mobile and we can work to close those gaps. I don't currently know a way to test mobile in CI, but maybe that can be done. |
@gedw99 Also, hope you'll feel better soon ❤️ We'll be here when you're well again, too 🙂 |
Wondering if this is designed to provide an unified API for both Browser and Native ( mobile and desktop).
I am attempting to use this with gioui.org.
https://github.com/gioui
I got some basic code working for Browser, but struggled to get it also working for Native.
The text was updated successfully, but these errors were encountered: