Code Monkey home page Code Monkey logo

hxelectron's Introduction

HXElectron

Haxe type definitions for electron, a framework for building cross-platform desktop applications with JavaScript, HTML, and CSS.

test Haxelib Version

Install

Release version

haxelib install electron

Development version

haxelib git electron https://github.com/tong/hxelectron.git

Generate Type Definitions

All type definitions are generated from electron-api.json by ElectronAPI.hx.
To (re)generate for another electron version download the description file from https://github.com/electron/electron/releases and run:

haxe --macro ElectronAPI.generate("optional/path/to/electron-api.json")

Build haxedoc.xml to insure everything is fine:

haxe haxedoc.hxml

By default hxelectron/electron-api.json is used if you ommit the path argument to your custom description file.


Metadata

The haxe externs are attributed with following metadata:

  • @:electron_platforms(["Linux"|"macOS"|"Windows"]) the supporting platforms (only if specific).

Usage

Demo Application

Clone this repository and setup:

git clone https://github.com/tong/hxelectron
cd hxelectron/
haxelib dev electron .

Build and Run:

cd demo/
npm install # Install electron
npm run build # Build main.js, app.js
npm start # Run application

hxelectron's People

Contributors

axgord avatar davisdevelopment avatar deepnight avatar dependabot[bot] avatar fponticelli avatar kevinresol avatar matthijskamstra avatar nykkolas avatar skial avatar tong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hxelectron's Issues

Typed access to remote modules like Menu or Dialog?

Hi! I'm working on my first electron app using hxelectron and sometimes struggle with the proper usage of the existing externs. I didn't figure out how to use the Menu extern via the Remote module with support for IDE autocompletion, so I decided to extend the externs with a RemoteMenu variation:

package electron.renderer;
import electron.main.Menu;
@:jsRequire("electron", "remote.Menu") extern class RemoteMenu extends Menu {
  static function setApplicationMenu(menu:haxe.extern.EitherType<Dynamic, Dynamic>):Void;
  static function getApplicationMenu():haxe.extern.EitherType<Dynamic, Dynamic>;
  static function sendActionToFirstResponder(action:String):Void;
  static function buildFromTemplate(template:Array<haxe.extern.EitherType<Dynamic, Dynamic>>):electron.main.Menu;
}

Now I can simply use RemoteMenu.buildFromTemplate() in a fully typed way.

This seems to work for me, but I wonder if there is a better way then copying all static methods manually? Or maybe this already exists in the current externs but I didn't find the correct syntax to use it.

If my approach seems to be a good idea I'd like to contribute these externs any time soon. But I think I might simply misunderstand something?

Cannot use `App.commandLine` static reference

The App.commandLine field appears to be static in the original library, for setting command-line launch arguments before the App is ready. Should it (or other?) fields be changed to static in the externs?

Is there a simple way to package?

Really nice :)
Only have short time to rebuild something via this approach for kiosk video app, but not sure on creating a version to show designers. Any guidence welcome.

Dialog example?

Hi, and thanks for your great work with these externs!

Trying to get the grips on how to use the Dialog methods.
I was expecting something like this would work:

	window.onload = function() {
		var files = Dialog.showOpenDialog({properties: ['openFile', 'multiSelections']});
	}

...but that gives an error: Cannot read property 'showOpenDialog' of undefined at App_main.window.onload (App.hx:27)

Any clue on this?

Unable to create new BrowserWindow

I'm trying to create a new (second) window using new BrowserWindow( { width: 400, height: 400 } ); but I'm getting an error:

Uncaught TypeError: electron_main_BrowserWindow is not a constructor

Trying to find answers online, people suggest using electron.remote.BrowserWindow which doesn't exist in this library. Do I need to go about this differently?

Uncaught TypeError: Cannot read property 'TouchBarButton' of undefined

Hey there

after upgrading the latest version of hxelectron I'm getting the following error:
Science.js:7539 Uncaught TypeError: Cannot read property 'TouchBarButton' of undefined

It seems to be a result of electron.main.TouchBar, in particular where jsRequire is being used with the second param being TouchBar.TouchBarButton
eg:

@:jsRequire("electron", "TouchBar.TouchBarButton") extern class TouchBarButton {

and as seem once compiled to js

var electron_main_TouchBarButton = require("electron").TouchBar.TouchBarButton;

Deleting the TouchBar extern resolves the issue, but it would be good to have an official.. Any ideas on how to resolve?

class methods vs. instance methods

Hi,

currently am trying to set up a connection between the renderer and main process, in particular sending an async event from renderer to main process. Calling Ipc.send seems to work fine, but how to add the listener to that class for the callback since 'on' and 'addListener' are instance methods?
Trying to add a constructor function to the ipc class and instantiate the ipcrender results in an error.

Thanks in advance!

Best
Chris

All fields from WebPreferences and BrowserWindowConstructorOptions should be @:optional

The new types introduced in v26.0 upgrade should all be marked as @:optional

Current version no longer builds at all and require some hacky cast to validate the BrowserWindow constructor arg :)

typedef BrowserWindowConstructorOptions = {
	/**
		Window's width in pixels. Default is `800`.
	**/
	@:optional 
	var width : Int;
	/**
		Window's height in pixels. Default is `600`.
	**/
	@:optional
	var height : Int;

	....
}

Class<electron.main.InAppPurchase> has no STATIC field on

I came across a missing static definition in InAppPurchase.hx. But since I know everything is generated based on the electron-api.json I don't know if it makes sense to add these kind of definitions manually?

If you try to implement the example code on https://www.electronjs.org/docs/tutorial/in-app-purchases:

InAppPurchase.on( InAppPurchaseEvent.transactions_updated, _onTransactionsUpdated );

But this won't compile since InAppPurchase does extend EventEmitters and therefore inherits it's instance method on - but does NOT define a static on method needed in this case.

I'd love to contribute these kind of changes (and #49 as well) - but I'd like to discuss the best attempt to do that future proof first. Maybe @tong or @fponticelli could give me just a quick feedback before I do anything? THANKS! :)

Code generated is different then what is committed to repo.

When I build this project by running haxe build.hxml the contents of /bin/main.js are not what was committed to this repo. I have listed below my haxe version and installed libraries as well as the current committed main.js vs the one that gets built.

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 

Original main.js

// 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(){}});

main.js after running haxe build.hxml

(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);

Can't access App class (undefined)

The demo works for for me, but when I access Electron APIs (instead of just Node ones) I get errors.
For example if I use electron.main.App.getPath('documents'), the App class is undefined.

In DevTools, I have found that using this JS does work:
require('electron').remote.app.getPath('documents')

In using:
Haxe 4.0.0 preview 5
Node 10.2
Electron 3.0.10
Windows 64

Dialog.showOpenDialog is undefined

The error thrown in the Javascript console:
Uncaught TypeError: Cannot read property 'showOpenDialog' of undefined

Source:

Dialog.showOpenDialog(Remote.getCurrentWindow(), {}, function(d){
            trace(d);
});

Is it possible that I am using it incorrectly? I am trying to port it over from my original Javascript source as well as I can. This has been the only issue so far regarding the externs.

Trace Window?

Currently when running electron I trace to the screen but that's kind of annoying as it tends to mess up the view.
It seems you can quite easily create a secondary window, I was wondering if ipc could be setup so that messages could be transfered between apps, seems there is an extern here but not sure on setup?
https://github.com/ciscoheat/haxe-js-kit/blob/master/js/atomshell/browserandwebpage/Ipc.hx
The concept is here:
electron/electron#991
I presume if I understood setting up the externs I could create a Tracer js something like...

import js.Browser.console;
import js.Browser.document;
import js.Browser.window;
import js.html.*;
import js.node.Ipc;
class Tracer {
    static var div: DivElement;
    static function main() {
        window.onload = function(){ 
            div = cast document.getElementById( 'traceInfo' );
            Ipc.on('my-msg', function(event, arg) {
                screenLog( arg );
                });
        }
    }
    public static function screenLog( d: Dynamic ){
        div.textContent += d;
    }
}

so my main class might change to something like.

import electron.main.*;
class Main {
    static function main() {
        electron.CrashReporter.start({
            companyName : "(not a company)",
            submitURL : "https://github.com/justinfront/hxelectron/issues"
        });
        electron.main.App.on( 'ready', function(e) {
            #if fullScreen
                var win: BrowserWindow = new BrowserWindow( { width: 800, height: 600, frame: false } );
                win.setFullScreen( true );
            #else
    			var win: BrowserWindow = new BrowserWindow( { width: 800, height: 600 } );
            #end
            win.on( BrowserWindowEvent.closed, function(e) {
                if( js.Node.process.platform != 'darwin' ) App.quit();
            });
            
            var win2: BrowserWindow = new BrowserWindow( { width: 300, height: 500, x: 0, y: 0 });
            win2.on( BrowserWindowEvent.closed, function(e) {
                if( js.Node.process.platform != 'darwin' ) App.quit();
            });
            win3.loadURL('file://' + js.Node.__dirname + '/tracer.html' );
            win.loadURL( 'file://' + js.Node.__dirname + '/app.html' );
        });
    }
}

Then in your app code

static inline function tracer( d: Dynamic ){
    Ipc.send('my-msg', d );
}

I managed to get Neko to run from my electron app perhaps this is also something to explore, perhaps if HL worked more easily on mac it might be interesting to try or python!
https://www.fyears.org/2015/06/electron-as-gui-of-python-apps.html

Might be nice to have a optional trace window out of the box, and optional wrapper for running HL/Neko/Python code? What do you think Franco is it beyond the scope of this github?

Event not found

When importing BrowserWindow i get:

../../hxelectron/src/electron/main/BrowserWindow.hx:7: lines 7-26 : Type not found : Event

Am I missing something?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.