Remove hxelectron dependency

This commit is contained in:
Joshua Granick
2019-10-05 17:46:13 -07:00
parent 4edb4b413a
commit 21d64f9c1c
4 changed files with 25 additions and 12 deletions

View File

@@ -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<OpenFLWindow> = [
::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;
}

View File

@@ -12,7 +12,6 @@
--next
-js ::OUTPUT_DIR::/bin/ElectronSetup.js
-cp ::OUTPUT_DIR::/haxe
-lib electron
-main ElectronSetup
-dce full

View File

@@ -11,7 +11,6 @@
--next
-js ::OUTPUT_DIR::/bin/ElectronSetup.js
-cp ::OUTPUT_DIR::/haxe
-lib electron
-main ElectronSetup
-dce full

View File

@@ -11,7 +11,6 @@
--next
-js ::OUTPUT_DIR::/bin/ElectronSetup.js
-cp ::OUTPUT_DIR::/haxe
-lib electron
-main ElectronSetup
-dce full