hackpadfs
hackpadfs copied to clipboard
Unified API for Browser and Native ?
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.
@JohnStarich ?
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 https://github.com/indexeddbshim/IndexedDBShim/issues/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://gioui.org/
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 No IOS of MAC support yet, but the others are done: https://github.com/gioui/gio-x/blob/main/explorer/explorer_unsupported.go
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:)
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 https://github.com/gioui/gio-x/blob/main/explorer/README.md No IOS of MAC support yet, the the others are done: https://github.com/gioui/gio-x/blob/main/explorer/explorer_unsupported.go https://github.com/gioui/gio-x/blob/main/explorer/explorer_unsupported.go
Very cool, thanks for sharing!
i sarted to make a GIO 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.
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.
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 GIO.
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. 👍
@gedw99 I've opened a first draft for the new docs. Let me know if you have any feedback or further questions we could answer in there.
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. The interfaces are clean and its obvious. Just a matter of trying it out from GIO and see what things are hit.
I am adding @Inkeliz and @whereswaldon as i think both may be interested to a degree in this, but can say for sure. Also I have to take a break on coding for a while, as i pulled a back muscle when fixing my kids roof, so need to chill for a while.
https://github.com/Inkeliz/giostorage/issues/1
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 🙂