3 ms·
I'm not familiar with the server-side stuff (Flask, C code generator - sounds interesting!) but had a couple thoughts on the web/client side. JSON file(s) can
by lioeters 9y ago
I'm not familiar with the server-side stuff (Flask, C code generator - sounds interesting!) but had a couple thoughts on the web/client side.
JSON file(s) can be stored in the user's browser local storage, with IndexedDB [0].
The "open file" dialog can use `<input type="file">` [1] or the File API directly [2].
Using React router, history API and optionally Redux, application state can be maintained even when the user hits the back button [3]. It's somewhat time-consuming to figure out, but can be forgotten about once it's set up.
It seems all or most functions you need could be achieved in-browser.
As for Electron, the app size starts from around 120MB~. I'm also thinking about how to do minimal updates with a bundle of HTML/CSS/JS, or better yet, incremental diffs. I have a feeling that there are existing libraries that enable this, just need to figure out how to put them together, or find a project where someone has solved it already..
---
[0] https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_A...
[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file https://developer.mozilla.org/en-US/docs/Web/HTML/Element/in...
[2] https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications https://developer.mozilla.org/en-US/docs/Web/API/File/Using_...
[3] https://reacttraining.com/react-router/web/api/BrowserRouter https://reacttraining.com/react-router/web/api/BrowserRouter
- nuclx 9y agoThanks for the pointers! Great to see someone actually understands my requirements. I'm already using the <input type="file"> method to load a file into the app. For the saving/download part I tried dynamically generating the output JSON and putting it in the DOM [0], but I don't like that this method doesn't allow to open a Save As dialog with right click. Always rendering the link to the DOM as in [1] crippled the performance of my app, since the link got rerendered on each keypress. Offline browser applications are definitely appealing, since they're so trivial to update. I think I will dig into LocalStorage, React Router - not sure if I really need IndexedDB, but it definitely sounds interesting too. What I'm missing is comprehensive literature or articles concerning this type of applications. They came to my attention through cryptocurrency websites like MyEtherwallet and EtherDelta. [0] https://stackoverflow.com/a/18197341 https://stackoverflow.com/a/18197341 [1] https://stackoverflow.com/a/3665147 https://stackoverflow.com/a/3665147
- lioeters 9y agoI've used a similar solution/workaround to create a data URL blob for saving files from a web app. I agree it's not ideal and quite limited. If it were an Electron app, there's an API for opening native file dialogs [0]. As for rendering an updated download link on every keypress - I remember I had to solve it by using a "dummy" download button: when it's clicked, it generates a fresh URL blob to replace the link href, then trigger another click event to start the download. I forget exactly how/if that worked. A couple of months ago I came across remoteStorage, "an open protocol for per-user storage on the Web" [1]. I have not implemented it, but the main idea seems to be "offline-first" apps that keep the user's data local, then sync if/when online. There's also "progressive web apps" [2], to promote this kind of offline-first approach and leveraging local storage. [0] https://electronjs.org/docs/api/dialog https://electronjs.org/docs/api/dialog [1] https://remotestorage.io/ https://remotestorage.io/ [2] https://developers.google.com/web/progressive-web-apps/ https://developers.google.com/web/progressive-web-apps/
- nuclx 9y agoI would love to see Chrome/Firefox embrace the unhosted approach a bit more, but security concerns are certainly a hindrance when it comes to empowering web apps.