├── test ├── typings │ ├── types │ │ └── gui │ │ │ ├── index.d.ts │ │ │ └── package.json │ ├── tsconfig.json │ ├── tslint.json │ └── smoke.ts └── smoke.js ├── README ├── .gitignore ├── lib ├── index.js └── install.js ├── package.json ├── .github └── workflows │ └── main.yml ├── LICENSE.txt └── binding.gyp /test/typings/types/gui/index.d.ts: -------------------------------------------------------------------------------- 1 | ../../../../index.d.ts -------------------------------------------------------------------------------- /test/typings/types/gui/package.json: -------------------------------------------------------------------------------- 1 | ../../../../package.json -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Node.js bindings to the Yue library. 2 | 3 | For documentation please visit http://libyue.com. 4 | -------------------------------------------------------------------------------- /test/smoke.js: -------------------------------------------------------------------------------- 1 | const gui = require('..') 2 | 3 | const win = gui.Window.create({}) 4 | 5 | gui.MessageLoop.postTask(() => gui.MessageLoop.quit()) 6 | gui.MessageLoop.run() 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # npm generated files 2 | /node_modules 3 | /yarn.lock 4 | /package-lock.json 5 | 6 | # generated files 7 | /build 8 | /test/typings/out 9 | *.tgz 10 | *.log 11 | *.swp 12 | 13 | # downloaded files 14 | /LICENSE 15 | /gui.node 16 | /index.d.ts 17 | -------------------------------------------------------------------------------- /test/typings/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "smoke.ts" 4 | ], 5 | "compilerOptions": { 6 | "module": "commonjs", 7 | "outDir": "out", 8 | "noImplicitAny": true, 9 | "typeRoots": [ 10 | "../node_modules/@types", 11 | "types" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | if (!process.versions.electron && !process.versions.yode && !process.env.YODE_DISABLE_NODE_WARNING) { 2 | console.warn("Using node-gui in upstream Node.js is experimental.") 3 | } 4 | 5 | const path = require('path') 6 | 7 | module.exports = require(path.resolve(__dirname, '..', 'gui.node')) 8 | -------------------------------------------------------------------------------- /test/typings/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "env": { 4 | "es6": true, 5 | "node": true 6 | }, 7 | "parser": "@typescript-eslint/parser", 8 | "parserOptions": { 9 | "project": [ 10 | "test/typings/tsconfig.json" 11 | ], 12 | "sourceType": "module" 13 | }, 14 | "plugins": [ 15 | "@typescript-eslint" 16 | ], 17 | "extends": [ 18 | "plugin:@typescript-eslint/eslint-recommended", 19 | "plugin:@typescript-eslint/recommended", 20 | "plugin:@typescript-eslint/recommended-requiring-type-checking" 21 | ], 22 | "rules": { 23 | "@typescript-eslint/ban-types": "off", 24 | "@typescript-eslint/no-explicit-any": "off" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /test/typings/smoke.ts: -------------------------------------------------------------------------------- 1 | import * as gui from 'gui' 2 | 3 | { 4 | // Event handler. 5 | const win = gui.Window.create({}) 6 | win.onClose = () => {} 7 | const id = win.onClose.connect(() => {}) 8 | win.onClose.disconnect(id) 9 | win.onClose.disconnectAll() 10 | win.shouldClose = () => false 11 | } 12 | 13 | { 14 | // File dialogs. 15 | const dialog = gui.FileOpenDialog.create() 16 | dialog.setFilters([ 17 | {description: 'image', extensions: ['.jpg', '.png']}, 18 | {description: 'text', extensions: ['.txt']}, 19 | ]) 20 | dialog.run() 21 | dialog.getResults() 22 | } 23 | 24 | { 25 | // Singletons. 26 | gui.screen.getPrimaryDisplay().scaleFactor 27 | gui.app.activate(true) 28 | } 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gui", 3 | "version": "0.15.6", 4 | "description": "Bindings to Yue's GUI library", 5 | "repository": "https://github.com/yue/node-gui", 6 | "license": "MIT", 7 | "main": "lib/index.js", 8 | "types": "index.d.ts", 9 | "scripts": { 10 | "install": "node lib/install.js", 11 | "test": "npm run lint && npm run test-smoke && npm run test-typings", 12 | "lint": "eslint -c test/typings/tslint.json index.d.ts", 13 | "test-smoke": "node test/smoke.js", 14 | "test-typings": "tsc --project test/typings/ --outDir test/typings/out" 15 | }, 16 | "dependencies": { 17 | "download-yue": "2.1.x" 18 | }, 19 | "devDependencies": { 20 | "@types/node": "18.13.0", 21 | "@typescript-eslint/eslint-plugin": "5.51.0", 22 | "@typescript-eslint/parser": "5.51.0", 23 | "eslint": "8.34.0", 24 | "typescript": "4.9.5" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: node-gui 2 | 3 | on: push 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | continue-on-error: false 9 | 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | os: [ubuntu-22.04, windows-2022, macos-15] 14 | 15 | steps: 16 | - name: Install Linux Dependencies 17 | if: startsWith(matrix.os, 'ubuntu') 18 | run: | 19 | sudo apt update 20 | sudo apt install -y libgtk-3-dev libwebkit2gtk-4.0-dev 21 | /usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & 22 | 23 | - name: Checkout 24 | uses: actions/checkout@v3 25 | 26 | - name: Build and test 27 | shell: bash 28 | env: 29 | DISPLAY: ':99.0' 30 | run: | 31 | set -e 32 | npm install 33 | npm test 34 | npm publish --dry-run 35 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2020 Cheng Zhao 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /lib/install.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const path = require('path') 4 | const downloadYue = require('download-yue') 5 | 6 | // Version to download. 7 | let version = 'v' + require('../package.json').version 8 | 9 | // Ignore -x suffix. 10 | const index = version.indexOf('-') 11 | if (index > -1) 12 | version = version.substr(0, index) 13 | 14 | // npm configs. 15 | let platform = process.platform 16 | if (process.env.npm_config_platform) 17 | platform = process.env.npm_config_platform 18 | let targetCpu = process.env.npm_config_arch 19 | if (!targetCpu) 20 | targetCpu = process.arch 21 | if (targetCpu == 'ia32') 22 | targetCpu = 'x86' 23 | const targetOs = { 24 | win32: 'win', 25 | linux: 'linux', 26 | darwin: 'mac', 27 | }[platform] 28 | 29 | main() 30 | 31 | async function main() { 32 | const rootDir = path.resolve(__dirname, '..') 33 | try { 34 | await Promise.all([ 35 | await downloadYue('yue', version, 36 | `yue_typescript_declarations_${version}.zip`, 37 | rootDir), 38 | await downloadYue('yue', version, 39 | `napi_yue_${version}_${targetOs}_${targetCpu}.zip`, 40 | rootDir), 41 | ]) 42 | } catch (e) { 43 | console.error('Failed to download prebuilt binary:', e) 44 | process.exit(1) 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'includes': [ 3 | 'filenames_libyue.gypi', 4 | 'filenames_src.gypi', 5 | ], 6 | 'targets': [ 7 | { 8 | 'target_name': 'gui', 9 | 'win_delay_load_hook': 'false', 10 | 'includes': [ 'deps/filename_rules.gypi' ], 11 | 'include_dirs': [ 12 | '.', 13 | 'src', 14 | 'src/third_party/kizunapi', 15 | 'deps/libyue/include', 16 | 'deps/libyue/src/<(OS)', 17 | ], 18 | 'sources': [ 19 | '<@(libyue_sources)', 20 | '<@(napi_yue_sources)', 21 | ], 22 | 23 | 'conditions': [ 24 | ['OS=="mac"', { 25 | 'defines': [ 26 | 'SYSTEM_NATIVE_UTF8', 27 | ], 28 | 29 | 'link_settings': { 30 | 'libraries': [ 31 | '$(SDKROOT)/System/Library/Frameworks/AppKit.framework', 32 | '$(SDKROOT)/System/Library/Frameworks/IOKit.framework', 33 | '$(SDKROOT)/System/Library/Frameworks/Security.framework', 34 | '$(SDKROOT)/System/Library/Frameworks/WebKit.framework', 35 | '$(SDKROOT)/System/Library/Frameworks/OpenDirectory.framework', 36 | ], 37 | }, 38 | 'xcode_settings': { 39 | 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', # required by yoga 40 | 'CLANG_CXX_LANGUAGE_STANDARD': 'c++20', 41 | 'MACOSX_DEPLOYMENT_TARGET': '10.13', 42 | 'DEAD_CODE_STRIPPING': 'YES', 43 | 'WARNING_CFLAGS': [ 44 | '-Wno-deprecated-declarations', 45 | '-Wno-missing-field-initializers', 46 | ], 47 | }, 48 | }], 49 | 50 | ['OS=="linux"', { 51 | 'variables': { 52 | 'pkg_libs': 'fontconfig pangoft2 gtk+-3.0 x11 webkit2gtk-4.0', 53 | }, 54 | 'cflags_cc': [ 55 | '-std=c++20', 56 | '-fexceptions', # required by yoga 57 | '-fdata-sections', 58 | '-ffunction-sections', 59 | '-Wno-deprecated-declarations', 60 | '