On another note I don't quite understand how to use the built code since if you run it using node main.js
(using the committed main.js
or the main.js
that is built when I run haxe build.hxml
I get the error:
-> % node --version
v4.1.0
-> % node main.js
module.js:338
throw err;
^
Error: Cannot find module 'app'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at console.undefined.log (hxelectron/bin/main.js:18:25)
at Object.<anonymous> (hxelectron/bin/main.js:22:3)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
^ I tried adding electron to the package.json and installing it, but that didn't seem to work either.
-> % haxe -version
3.2.1
-> % haxelib list
buddy: [0.18.1]
hxnodejs: [4.0.1]
lime: [2.8.2]
npm: [0.4.0]
openfl-samples: [3.3.1]
openfl: [3.5.3]
promhx: [1.0.21]
-> % haxe build.hxml
// Generated by Haxe
(function (console) { "use strict";
var Main = function() { };
Main.main = function() {
electron_main_CrashReporter.start();
electron_main_App.on("window-all-closed",function() {
electron_main_App.quit();
});
var mainWindow = null;
electron_main_App.on("ready",function() {
mainWindow = new electron_main_BrowserWindow({ width : 800, height : 600});
mainWindow.loadUrl("file://" + __dirname + "/index.html");
mainWindow.on("closed",function() {
mainWindow = null;
});
});
};
var electron_main_App = require("app");
var electron_main_BrowserWindow = require("browser-window");
var electron_main_CrashReporter = require("crash-reporter");
Main.main();
})(typeof console != "undefined" ? console : {log:function(){}});
(function (console, $global) { "use strict";
var $estr = function() { return js_Boot.__string_rec(this,''); };
function $extend(from, fields) {
function Inherit() {} Inherit.prototype = from; var proto = new Inherit();
for (var name in fields) proto[name] = fields[name];
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
return proto;
}
var Main = function() { };
Main.__name__ = true;
Main.main = function() {
electron_main_CrashReporter.start();
electron_main_App.on("window-all-closed",function() {
electron_main_App.quit();
});
var mainWindow = null;
electron_main_App.on("ready",function() {
mainWindow = new electron_main_BrowserWindow({ width : 800, height : 600});
mainWindow.loadUrl("file://" + __dirname + "/index.html");
mainWindow.on("closed",function() {
mainWindow = null;
});
});
};
Math.__name__ = true;
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
return js_Boot.__string_rec(s,"");
};
var electron_main_App = require("app");
var electron_main_BrowserWindow = require("browser-window");
var electron_main_CrashReporter = require("crash-reporter");
var haxe__$Int64__$_$_$Int64 = function(high,low) {
this.high = high;
this.low = low;
};
haxe__$Int64__$_$_$Int64.__name__ = true;
haxe__$Int64__$_$_$Int64.prototype = {
__class__: haxe__$Int64__$_$_$Int64
};
var haxe_io_Error = { __ename__ : true, __constructs__ : ["Blocked","Overflow","OutsideBounds","Custom"] };
haxe_io_Error.Blocked = ["Blocked",0];
haxe_io_Error.Blocked.toString = $estr;
haxe_io_Error.Blocked.__enum__ = haxe_io_Error;
haxe_io_Error.Overflow = ["Overflow",1];
haxe_io_Error.Overflow.toString = $estr;
haxe_io_Error.Overflow.__enum__ = haxe_io_Error;
haxe_io_Error.OutsideBounds = ["OutsideBounds",2];
haxe_io_Error.OutsideBounds.toString = $estr;
haxe_io_Error.OutsideBounds.__enum__ = haxe_io_Error;
haxe_io_Error.Custom = function(e) { var $x = ["Custom",3,e]; $x.__enum__ = haxe_io_Error; $x.toString = $estr; return $x; };
var haxe_io_FPHelper = function() { };
haxe_io_FPHelper.__name__ = true;
haxe_io_FPHelper.i32ToFloat = function(i) {
var sign = 1 - (i >>> 31 << 1);
var exp = i >>> 23 & 255;
var sig = i & 8388607;
if(sig == 0 && exp == 0) return 0.0;
return sign * (1 + Math.pow(2,-23) * sig) * Math.pow(2,exp - 127);
};
haxe_io_FPHelper.floatToI32 = function(f) {
if(f == 0) return 0;
var af = f < 0?-f:f;
var exp = Math.floor(Math.log(af) / 0.6931471805599453);
if(exp < -127) exp = -127; else if(exp > 128) exp = 128;
var sig = Math.round((af / Math.pow(2,exp) - 1) * 8388608) & 8388607;
return (f < 0?-2147483648:0) | exp + 127 << 23 | sig;
};
haxe_io_FPHelper.i64ToDouble = function(low,high) {
var sign = 1 - (high >>> 31 << 1);
var exp = (high >> 20 & 2047) - 1023;
var sig = (high & 1048575) * 4294967296. + (low >>> 31) * 2147483648. + (low & 2147483647);
if(sig == 0 && exp == -1023) return 0.0;
return sign * (1.0 + Math.pow(2,-52) * sig) * Math.pow(2,exp);
};
haxe_io_FPHelper.doubleToI64 = function(v) {
var i64 = haxe_io_FPHelper.i64tmp;
if(v == 0) {
i64.low = 0;
i64.high = 0;
} else {
var av = v < 0?-v:v;
var exp = Math.floor(Math.log(av) / 0.6931471805599453);
var tmp;
var v1 = (av / Math.pow(2,exp) - 1) * 4503599627370496.;
tmp = Math.round(v1);
var sig = tmp;
var sig_l = sig | 0;
var sig_h = sig / 4294967296.0 | 0;
i64.low = sig_l;
i64.high = (v < 0?-2147483648:0) | exp + 1023 << 20 | sig_h;
}
return i64;
};
var js__$Boot_HaxeError = function(val) {
Error.call(this);
this.val = val;
this.message = String(val);
if(Error.captureStackTrace) Error.captureStackTrace(this,js__$Boot_HaxeError);
};
js__$Boot_HaxeError.__name__ = true;
js__$Boot_HaxeError.__super__ = Error;
js__$Boot_HaxeError.prototype = $extend(Error.prototype,{
__class__: js__$Boot_HaxeError
});
var js_Boot = function() { };
js_Boot.__name__ = true;
js_Boot.getClass = function(o) {
if((o instanceof Array) && o.__enum__ == null) return Array; else {
var cl = o.__class__;
if(cl != null) return cl;
var name = js_Boot.__nativeClassName(o);
if(name != null) return js_Boot.__resolveNativeClass(name);
return null;
}
};
js_Boot.__string_rec = function(o,s) {
if(o == null) return "null";
if(s.length >= 5) return "<...>";
var t = typeof(o);
if(t == "function" && (o.__name__ || o.__ename__)) t = "object";
switch(t) {
case "object":
if(o instanceof Array) {
if(o.__enum__) {
if(o.length == 2) return o[0];
var str2 = o[0] + "(";
s += "\t";
var _g1 = 2;
var _g = o.length;
while(_g1 < _g) {
var i1 = _g1++;
if(i1 != 2) str2 += "," + js_Boot.__string_rec(o[i1],s); else str2 += js_Boot.__string_rec(o[i1],s);
}
return str2 + ")";
}
var l = o.length;
var i;
var str1 = "[";
s += "\t";
var _g2 = 0;
while(_g2 < l) {
var i2 = _g2++;
str1 += (i2 > 0?",":"") + js_Boot.__string_rec(o[i2],s);
}
str1 += "]";
return str1;
}
var tostr;
try {
tostr = o.toString;
} catch( e ) {
if (e instanceof js__$Boot_HaxeError) e = e.val;
return "???";
}
if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") {
var s2 = o.toString();
if(s2 != "[object Object]") return s2;
}
var k = null;
var str = "{\n";
s += "\t";
var hasp = o.hasOwnProperty != null;
for( var k in o ) {
if(hasp && !o.hasOwnProperty(k)) {
continue;
}
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") {
continue;
}
if(str.length != 2) str += ", \n";
str += s + k + " : " + js_Boot.__string_rec(o[k],s);
}
s = s.substring(1);
str += "\n" + s + "}";
return str;
case "function":
return "<function>";
case "string":
return o;
default:
return String(o);
}
};
js_Boot.__interfLoop = function(cc,cl) {
if(cc == null) return false;
if(cc == cl) return true;
var intf = cc.__interfaces__;
if(intf != null) {
var _g1 = 0;
var _g = intf.length;
while(_g1 < _g) {
var i = _g1++;
var i1 = intf[i];
if(i1 == cl || js_Boot.__interfLoop(i1,cl)) return true;
}
}
return js_Boot.__interfLoop(cc.__super__,cl);
};
js_Boot.__instanceof = function(o,cl) {
if(cl == null) return false;
switch(cl) {
case Int:
return (o|0) === o;
case Float:
return typeof(o) == "number";
case Bool:
return typeof(o) == "boolean";
case String:
return typeof(o) == "string";
case Array:
return (o instanceof Array) && o.__enum__ == null;
case Dynamic:
return true;
default:
if(o != null) {
if(typeof(cl) == "function") {
if(o instanceof cl) return true;
if(js_Boot.__interfLoop(js_Boot.getClass(o),cl)) return true;
} else if(typeof(cl) == "object" && js_Boot.__isNativeObj(cl)) {
if(o instanceof cl) return true;
}
} else return false;
if(cl == Class && o.__name__ != null) return true;
if(cl == Enum && o.__ename__ != null) return true;
return o.__enum__ == cl;
}
};
js_Boot.__nativeClassName = function(o) {
var name = js_Boot.__toStr.call(o).slice(8,-1);
if(name == "Object" || name == "Function" || name == "Math" || name == "JSON") return null;
return name;
};
js_Boot.__isNativeObj = function(o) {
return js_Boot.__nativeClassName(o) != null;
};
js_Boot.__resolveNativeClass = function(name) {
return $global[name];
};
var js_html_compat_ArrayBuffer = function(a) {
if((a instanceof Array) && a.__enum__ == null) {
this.a = a;
this.byteLength = a.length;
} else {
var len = a;
this.a = [];
var _g = 0;
while(_g < len) {
var i = _g++;
this.a[i] = 0;
}
this.byteLength = len;
}
};
js_html_compat_ArrayBuffer.__name__ = true;
js_html_compat_ArrayBuffer.sliceImpl = function(begin,end) {
var u = new Uint8Array(this,begin,end == null?null:end - begin);
var result = new ArrayBuffer(u.byteLength);
var resultArray = new Uint8Array(result);
resultArray.set(u);
return result;
};
js_html_compat_ArrayBuffer.prototype = {
slice: function(begin,end) {
return new js_html_compat_ArrayBuffer(this.a.slice(begin,end));
}
,__class__: js_html_compat_ArrayBuffer
};
var js_html_compat_DataView = function(buffer,byteOffset,byteLength) {
this.buf = buffer;
this.offset = byteOffset == null?0:byteOffset;
this.length = byteLength == null?buffer.byteLength - this.offset:byteLength;
if(this.offset < 0 || this.length < 0 || this.offset + this.length > buffer.byteLength) throw new js__$Boot_HaxeError(haxe_io_Error.OutsideBounds);
};
js_html_compat_DataView.__name__ = true;
js_html_compat_DataView.prototype = {
getInt8: function(byteOffset) {
var v = this.buf.a[this.offset + byteOffset];
return v >= 128?v - 256:v;
}
,getUint8: function(byteOffset) {
return this.buf.a[this.offset + byteOffset];
}
,getInt16: function(byteOffset,littleEndian) {
var v = this.getUint16(byteOffset,littleEndian);
return v >= 32768?v - 65536:v;
}
,getUint16: function(byteOffset,littleEndian) {
return littleEndian?this.buf.a[this.offset + byteOffset] | this.buf.a[this.offset + byteOffset + 1] << 8:this.buf.a[this.offset + byteOffset] << 8 | this.buf.a[this.offset + byteOffset + 1];
}
,getInt32: function(byteOffset,littleEndian) {
var p = this.offset + byteOffset;
var a = this.buf.a[p++];
var b = this.buf.a[p++];
var c = this.buf.a[p++];
var d = this.buf.a[p++];
return littleEndian?a | b << 8 | c << 16 | d << 24:d | c << 8 | b << 16 | a << 24;
}
,getUint32: function(byteOffset,littleEndian) {
var v = this.getInt32(byteOffset,littleEndian);
return v < 0?v + 4294967296.:v;
}
,getFloat32: function(byteOffset,littleEndian) {
return haxe_io_FPHelper.i32ToFloat(this.getInt32(byteOffset,littleEndian));
}
,getFloat64: function(byteOffset,littleEndian) {
var a = this.getInt32(byteOffset,littleEndian);
var b = this.getInt32(byteOffset + 4,littleEndian);
return haxe_io_FPHelper.i64ToDouble(littleEndian?a:b,littleEndian?b:a);
}
,setInt8: function(byteOffset,value) {
this.buf.a[byteOffset + this.offset] = value < 0?value + 128 & 255:value & 255;
}
,setUint8: function(byteOffset,value) {
this.buf.a[byteOffset + this.offset] = value & 255;
}
,setInt16: function(byteOffset,value,littleEndian) {
this.setUint16(byteOffset,value < 0?value + 65536:value,littleEndian);
}
,setUint16: function(byteOffset,value,littleEndian) {
var p = byteOffset + this.offset;
if(littleEndian) {
this.buf.a[p] = value & 255;
this.buf.a[p++] = value >> 8 & 255;
} else {
this.buf.a[p++] = value >> 8 & 255;
this.buf.a[p] = value & 255;
}
}
,setInt32: function(byteOffset,value,littleEndian) {
this.setUint32(byteOffset,value,littleEndian);
}
,setUint32: function(byteOffset,value,littleEndian) {
var p = byteOffset + this.offset;
if(littleEndian) {
this.buf.a[p++] = value & 255;
this.buf.a[p++] = value >> 8 & 255;
this.buf.a[p++] = value >> 16 & 255;
this.buf.a[p++] = value >>> 24;
} else {
this.buf.a[p++] = value >>> 24;
this.buf.a[p++] = value >> 16 & 255;
this.buf.a[p++] = value >> 8 & 255;
this.buf.a[p++] = value & 255;
}
}
,setFloat32: function(byteOffset,value,littleEndian) {
this.setUint32(byteOffset,haxe_io_FPHelper.floatToI32(value),littleEndian);
}
,setFloat64: function(byteOffset,value,littleEndian) {
var i64 = haxe_io_FPHelper.doubleToI64(value);
if(littleEndian) {
this.setUint32(byteOffset,i64.low);
this.setUint32(byteOffset,i64.high);
} else {
this.setUint32(byteOffset,i64.high);
this.setUint32(byteOffset,i64.low);
}
}
,__class__: js_html_compat_DataView
};
var js_html_compat_Uint8Array = function() { };
js_html_compat_Uint8Array.__name__ = true;
js_html_compat_Uint8Array._new = function(arg1,offset,length) {
var arr;
if(typeof(arg1) == "number") {
arr = [];
var _g = 0;
while(_g < arg1) {
var i = _g++;
arr[i] = 0;
}
arr.byteLength = arr.length;
arr.byteOffset = 0;
arr.buffer = new js_html_compat_ArrayBuffer(arr);
} else if(js_Boot.__instanceof(arg1,js_html_compat_ArrayBuffer)) {
var buffer = arg1;
if(offset == null) offset = 0;
if(length == null) length = buffer.byteLength - offset;
if(offset == 0) arr = buffer.a; else arr = buffer.a.slice(offset,offset + length);
arr.byteLength = arr.length;
arr.byteOffset = offset;
arr.buffer = buffer;
} else if((arg1 instanceof Array) && arg1.__enum__ == null) {
arr = arg1.slice();
arr.byteLength = arr.length;
arr.byteOffset = 0;
arr.buffer = new js_html_compat_ArrayBuffer(arr);
} else throw new js__$Boot_HaxeError("TODO " + Std.string(arg1));
arr.subarray = js_html_compat_Uint8Array._subarray;
arr.set = js_html_compat_Uint8Array._set;
return arr;
};
js_html_compat_Uint8Array._set = function(arg,offset) {
var t = this;
if(js_Boot.__instanceof(arg.buffer,js_html_compat_ArrayBuffer)) {
var a = arg;
if(arg.byteLength + offset > t.byteLength) throw new js__$Boot_HaxeError("set() outside of range");
var _g1 = 0;
var _g = arg.byteLength;
while(_g1 < _g) {
var i = _g1++;
t[i + offset] = a[i];
}
} else if((arg instanceof Array) && arg.__enum__ == null) {
var a1 = arg;
if(a1.length + offset > t.byteLength) throw new js__$Boot_HaxeError("set() outside of range");
var _g11 = 0;
var _g2 = a1.length;
while(_g11 < _g2) {
var i1 = _g11++;
t[i1 + offset] = a1[i1];
}
} else throw new js__$Boot_HaxeError("TODO");
};
js_html_compat_Uint8Array._subarray = function(start,end) {
var t = this;
var a = js_html_compat_Uint8Array._new(t.slice(start,end));
a.byteOffset = start;
return a;
};
String.prototype.__class__ = String;
String.__name__ = true;
Array.__name__ = true;
var Int = { __name__ : ["Int"]};
var Dynamic = { __name__ : ["Dynamic"]};
var Float = Number;
Float.__name__ = ["Float"];
var Bool = Boolean;
Bool.__ename__ = ["Bool"];
var Class = { __name__ : ["Class"]};
var Enum = { };
var ArrayBuffer = $global.ArrayBuffer || js_html_compat_ArrayBuffer;
if(ArrayBuffer.prototype.slice == null) ArrayBuffer.prototype.slice = js_html_compat_ArrayBuffer.sliceImpl;
var DataView = $global.DataView || js_html_compat_DataView;
var Uint8Array = $global.Uint8Array || js_html_compat_Uint8Array._new;
haxe_io_FPHelper.i64tmp = (function($this) {
var $r;
var x = new haxe__$Int64__$_$_$Int64(0,0);
$r = x;
return $r;
}(this));
js_Boot.__toStr = {}.toString;
js_html_compat_Uint8Array.BYTES_PER_ELEMENT = 1;
Main.main();
})(typeof console != "undefined" ? console : {log:function(){}}, typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this);