Comments (17)
mloader has never been tested with nodejs context so it may very well be incompatible. Though the error is really odd - does that happen with a "hello world" nodejs app?
from mloader.
Yes - the following project will throw the error in Electron. If you need the electron setup I can provide that too.
package;
import js.Lib;
import mloader.Loader.LoaderEvent;
import mloader.XmlLoader;
class Main
{
static function main()
{
var l = new LoadTest();
l.loadConfig();
}
}
class LoadTest
{
public function new()
{
}
public function loadConfig()
{
var pURL:String = "config.xml";
var l= new XmlLoader(pURL);
l.loaded.add( onXMLLoaded );
l.load();
}
function onXMLLoaded(e:LoaderEvent<Dynamic> ):Void
{
switch(e.type){
case Complete: {
trace("Load complete");
}
case Fail(er):
switch (er)
{
case Format(info): trace("Could not parse xml: " + info);
case IO(info): trace("Descriptor URL could not be reached: " + info);
default: trace(er);
}
default: trace(e.type);
}
}
}
from mloader.
Right, I see that the HttpLoader
base class doesn't know how to deal with local filesystem in nodejs context.
from mloader.
Can you try #28
It works when running under nodejs; not sure about Electron.
from mloader.
That no longer produces the original error but now mloader spits out -
Local file does not exist: config.xml
If I remove hxnodejs from the list of libs everything works normal.
from mloader.
What do you mean by removing hxnodejs from the libs? The loader works without?
Is that as part UI-side of an Electron app? Is there documentation describing how to load local files in vanilla JS?
from mloader.
Yes to clarify. If you use mloader in the Renderer (UI) side of Electron it works perfectly fine. We've been using it for a couple of years here. But we're trying to add hxelectron externs which rely on hxnodejs. Simply adding hxnodejs to the list of libs in the hxml produces the errors described above. Sorry about the confusion, hopefully this clarifies things.
from mloader.
Does using haxe.Http
work normally to load local files? Do you have a -D electron
?
from mloader.
Using - D electron makes no difference.
When hxnodejs is added to list of libraries haxe.Http produces the same error I originally reported
events.js:182 Uncaught Error: connect ECONNREFUSED 127.0.0.1:80
at Object.exports._errnoException (util.js:1024)
at exports._exceptionWithHostPort (util.js:1047)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1150)
exports._errnoException @ util.js:1024
exports._exceptionWithHostPort @ util.js:1047
afterConnect @ net.js:1150
events.js:182 Uncaught Error: socket hang up
at createHangUpError (_http_client.js:345)
at Socket.socketCloseListener (_http_client.js:377)
at emitOne (events.js:120)
at Socket.emit (events.js:210)
at TCP._handle.close [as _onclose] (net.js:549)
createHangUpError @ _http_client.js:345
socketCloseListener @ _http_client.js:377
emitOne @ events.js:120
emit @ events.js:210
_handle.close @ net.js:549
events.js:182 Uncaught Error: socket hang up
at createHangUpError (_http_client.js:345)
at Socket.socketCloseListener (_http_client.js:377)
at emitOne (events.js:120)
at Socket.emit (events.js:210)
at TCP._handle.close [as _onclose] (net.js:549)
When hxnodejs is removed from the list of libs then haxe.Http works perfectly fine. So I guess this is more related to hxnodejs than mloader. I'll raise an issue there. I'll probably just link to this one.
from mloader.
Yes that's what I suspected - Haxe's nodejs target is expected to be for cli/server side.
Does Electron really require adding -D hxnodejs
? This is meant to enable the full node API and shouldn't be needed for the client side, or is it?
For what it's work, js.Lib.require
or @:jsRequire
are available in the regular JS target.
from mloader.
Electron does not require it. It works just fine- just like the browser, but if you want the compiler checks you need the externs and simply adding that lib breaks electron for whatever reason. I'm getting around it right now with some ugly 'untyped' stuff. I figured that was better than rewriting the loading module since I like using mloader (and thus haxe.Http)
from mloader.
What compiler checks? Are you accessing some Node APIs?
from mloader.
No I'm not. That's the point. I'd like to but simply adding -lib hxnodejs to the project when using haxe.Http produces the error even if no Node APIs are called, just like the example code.
from mloader.
I'm sorry if I sound dumb or something :D but you probably shouldn't add -D hxnodejs
for the client side because I believe it's basically a browser with extra API, not a Node context.
Looking at https://github.com/fponticelli/hxelectron it seems that it should be compiled without this flag, and instead use Electron-specific externs, like this lib which provides externs for the specific APIs accessible in the client.
from mloader.
from mloader.
Oh dear you like not giving information...
Well I hope you give all this information at least in the Haxe issue. It is very important to give full details to reproduce the issue.
from mloader.
I'm sorry but I did give full details. You keep asking me about me about what I'm adding or not adding. It really does not matter. I've created a simple project that highlights the problem. Simply including the lib in the hxml is enough to produce the error.
https://drive.google.com/file/d/1aveFdtp7bZBosFJeirHoNSZhk8ZqStRX/view
from mloader.
Related Issues (13)
- Suggestion - Retry On Error HOT 1
- OpenFL: XmlLoader can't find files at runtime HOT 3
- Version mismatch
- Image JS Cross-Origin HOT 1
- Neko - exceptions thrown by http.request not handled like other platforms HOT 1
- Using xmlLoader.parseData property supresses errors in the browser
- xmlLoader throws loader error in nw.js (formerly node-webkit) HOT 3
- complete will case when load failed
- iterate through xml children? HOT 2
- HaxeLib upgrade "overflow" HOT 6
- mloader API doc missing. Autocompletion in FlashDevelop not working HOT 2
- LoaderQueue Complete event is dispatched before the last loaded item in the queue Complete event HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mloader.