I’ve been spinning my tires for a couple days now. I cannot seem to get any existing project to work as a web site app, and perhaps that’s the fundamental issue I’m missing. I upload everything I work on as an website using Web Hosting Manager, and maybe this cannot work with the DOM API? Must everything be a stand-alone App or run via localhost://p:3xxx?
First, I should mention I’m using SAFE Browser alpha-2 and Web Hosting Manager alpha-2 in 64-bit Linux (Mint specifically, a fork of Ubuntu). Both are built from the master branches of the respective repos with
NODE_ENV=dev to use mocknet. My Browser is using commit bf21e5eb. I don’t have the safe_examples commit readily available, but I can find it out if relevant. I can confirm mocknet works for the SAFE Browser because I’m able to create a login while offline using any arbitrary invite code. When I upload files using Web Hosting Manager (again, offline), I can navigate to them using
safe:// URLs, which I assume means that is all set for mocknet.
Second, I have to note that I cannot debug. My console and inspector are tied weirdly to the SAFE Browser, but not to any actual page I have loaded. Someone else already reported that problem here:
I began writing code from scratch, referencing the 0.3.0 Beaker Plugin API, into a fairly simple HTML+JS website. I don’t get errors (which I log as HTML elements, since I cannot use the Browser debug). I get handles everywhere I expect. But it seems like no data is getting stored or retrieved. I assumed I’m writing my API calls wrong or screwing up Promises (they can be fickle).
So I switch over to using code written by @loziniak. I basically get the same problem described in the following thread, wherein I can
safeMutableDataEntries.insert without error, but I get empty lists from
safeMutableData.getEntries, or I assume they are empty because the function passed into
safeMutableDataEntries.forEach is never called. Again, no errors from catching Promises.
Then I decided I should find a working example that is simple and should do what I need. I found the Markdown Editor in the examples (https://github.com/maidsafe/safe_examples/tree/master/markdown_editor). It seems to be built in React, whereas I just want a simple webpage. So I stole
store.js and tried to go from there. The page wouldn’t load when the files were sourced; without being able to see errors in SAFE Browser, I had to resort to other measures. I fired it up in Firefox and got complaints about
export being in places it ought not be. I removed all export and import notation from the two files and rely on them being available through the sort of global scope of the web page. It’s a minor change and got the calls up and running.
In my test using code from the markdown editor, I make a call to
saveFile('filename', 'some basic\n\ntext'); with no errors and get a handle back. Then I make a call to
getFileVersions('filename') and literally things break down. At first I got some really weird Promise error about
null has no property emulateAs, yet the only calls to
emulateAs were from
window.safeMutableData which was tested and shown to be not-null on lines 15-19 of store.js (https://github.com/maidsafe/safe_examples/blob/master/markdown_editor/src/store.js#L15-L22). I nuke everything and start over. Now, same code, I get
-103: Core error: Routing client error -> Requested data not found from a Promise catch in response to
Can someone point out a very simple DOM API example that successfully uploads a file or changes MutableData using 0.3.0 API calls, which can be uploaded with Web Hosting Manager, which can work in SAFE Browser 0.6.0 alpha-2 in mocknet? Is this fundamentally not possible? I’d like a simple example, not something built on top of React or setup as a standalone App, but maybe that is not an option and why I cannot make any progress.