tong/hxelectron
关于
Haxe type definitions for electron
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文HXElectron
Haxe type definitions (externs) for Electron, a framework for building cross-platform desktop applications with JavaScript, HTML and CSS.
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).@:deprecatedfor APIs Electron has deprecated.@:electron_experimentalfor 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
探索相关项目
加载中…