electron

Type definitions for the electron framework
https://github.com/tong/hxelectron

To install, run:

haxelib install electron 45.2.3 

See using Haxelib in Haxelib documentation for more information.

README.md

HXElectron

Haxe type definitions (externs) for Electron, a framework for building cross-platform desktop applications with JavaScript, HTML and CSS.

test Haxelib Version

The library version follows the Electron version it was generated from.

Install

Release version:

haxelib install electron

Development version:

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

Requires Haxe 4.3.7 or newer and hxnodejs, which is installed automatically as a dependency.

Usage

Add the library to your build file and compile to JavaScript. Main and renderer process code are separate targets:

-lib electron
-main Main
-js main.js

Types are split by process: electron.main.* for the main process, electron.renderer.* for renderer processes. Types available in both live directly in electron.*.

import electron.main.App;
import electron.main.BrowserWindow;

class Main {
 static function main() {
  App.on('ready', () -> {
   var win = new BrowserWindow({width: 800, height: 600});
   win.loadFile('app.html');
  });
 }
}

See the demo for a complete application.

Demo application

git clone https://github.com/tong/hxelectron
cd hxelectron/
haxelib dev electron .
cd demo/
npm install       # Install electron
npm run build     # Build main.js and app.js
npm start         # Run the application

String enums

Parameters and properties which only accept specific strings use enum abstract types which are defined in the same module as the type they are used in, e.g. electron.main.App.AppGetPathName. They convert from String, so plain string literals (app.getPath("home")) keep working, and you get completion and typo checks through the enum values (AppGetPathName.home).

Metadata

The externs are annotated with the following metadata:

  • @:electron_platforms(["macOS"|"Windows"|"Linux"|"MAS"]) the supported platforms (only if platform specific).
  • @:deprecated for APIs Electron has deprecated.
  • @:electron_experimental for experimental APIs.

Updating to a new Electron version

All type definitions are generated from electron-api.json by ElectronAPI.hx.

To update to the latest release (requires the GitHub CLI and jq):

./update.sh          # latest release
./update.sh v44.5.1  # specific release

This downloads electron-api.json, regenerates src/, rebuilds haxedoc.xml and bumps the version in haxelib.json and demo/package.json.

To regenerate manually from a description file downloaded from the Electron releases:

haxe api.hxml        # regenerate src/ from electron-api.json
haxe haxedoc.hxml    # build haxedoc.xml to verify everything compiles

License

MIT

Contributors
fponticelli
tong
Version
45.2.3
Published
6 days ago
Dependencies
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂