diff --git a/templates/electron/haxe/ElectronSetup.hx b/templates/electron/haxe/ElectronSetup.hx index 69eaeb166..4334e6929 100644 --- a/templates/electron/haxe/ElectronSetup.hx +++ b/templates/electron/haxe/ElectronSetup.hx @@ -1,13 +1,12 @@ -import electron.main.App; -import electron.main.BrowserWindow; +package; class ElectronSetup { - public static var window:BrowserWindow; + public static var window:ElectronBrowserWindow; static function main() { - electron.main.App.commandLine.appendSwitch('ignore-gpu-blacklist', 'true'); + ElectronApp.commandLine.appendSwitch('ignore-gpu-blacklist', 'true'); var windows:Array = [ ::foreach windows:: @@ -46,9 +45,9 @@ class ElectronSetup if (height == 0) height = 600; var frame:Bool = window.borderless == false; - electron.main.App.commandLine.appendSwitch('--autoplay-policy', 'no-user-gesture-required'); + ElectronApp.commandLine.appendSwitch('--autoplay-policy', 'no-user-gesture-required'); - electron.main.App.on('ready', function(e) + ElectronApp.on('ready', function(e) { var config:Dynamic = { @@ -60,13 +59,13 @@ class ElectronSetup height: height, webgl: window.hardware }; - ElectronSetup.window = new BrowserWindow(config); + ElectronSetup.window = new ElectronBrowserWindow(config); - ElectronSetup.window.on(closed, function() + ElectronSetup.window.on('closed', function() { if (js.Node.process.platform != 'darwin') { - electron.main.App.quit(); + ElectronApp.quit(); } }); @@ -104,3 +103,20 @@ typedef OpenFLWindow = x:Int, y:Int } + +// Externs to compile without requiring hxelectron + +@:jsRequire("electron", "app") extern class ElectronApp +{ + public static var commandLine:Dynamic; + public static function on(type:Dynamic, callback:Dynamic):Dynamic; + public static function quit():Void; +} + +@:jsRequire("electron", "BrowserWindow") extern class ElectronBrowserWindow +{ + public var webContents:Dynamic; + public function new(?options:Dynamic); + public function loadURL(url:String, ?options:Dynamic):Dynamic; + public function on(type:Dynamic, callback:Dynamic):Dynamic; +} diff --git a/templates/electron/hxml/debug.hxml b/templates/electron/hxml/debug.hxml index a52f9f877..053cb7299 100644 --- a/templates/electron/hxml/debug.hxml +++ b/templates/electron/hxml/debug.hxml @@ -12,7 +12,6 @@ --next -js ::OUTPUT_DIR::/bin/ElectronSetup.js -cp ::OUTPUT_DIR::/haxe --lib electron -main ElectronSetup -dce full diff --git a/templates/electron/hxml/final.hxml b/templates/electron/hxml/final.hxml index fd0555284..aa35108b6 100644 --- a/templates/electron/hxml/final.hxml +++ b/templates/electron/hxml/final.hxml @@ -11,7 +11,6 @@ --next -js ::OUTPUT_DIR::/bin/ElectronSetup.js -cp ::OUTPUT_DIR::/haxe --lib electron -main ElectronSetup -dce full diff --git a/templates/electron/hxml/release.hxml b/templates/electron/hxml/release.hxml index ed219e174..402010fc1 100644 --- a/templates/electron/hxml/release.hxml +++ b/templates/electron/hxml/release.hxml @@ -11,7 +11,6 @@ --next -js ::OUTPUT_DIR::/bin/ElectronSetup.js -cp ::OUTPUT_DIR::/haxe --lib electron -main ElectronSetup -dce full