Coder Social home page Coder Social logo

zhutony / qode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nodegui/qode

0.0 2.0 0.0 1.3 MB

Qode is a lightly modified fork of Node.js that merges Node's event loop with Qt's event loop. It is designed to be used together with @nodegui/nodegui.

Home Page: https://nodegui.github.io/nodegui/#/tutorial/application-architecture?id=qode

JavaScript 0.69% Python 1.24% C++ 97.73% Objective-C++ 0.20% Shell 0.15%

qode's Introduction

Qode

Qode is a lightly modified fork of Node.js that allows Node's event loop to be merged with Qt's or any other Gui event loop. It is designed to be used together with @nodegui/nodegui. Qode achieves this by allowing message loop injection via a NodeJS addon.

logo

Changes in v2.0

In version 2.0, Qode no longer depends on Qt as a dependency.

This makes it easier to upgrade Qt and also allows devs to use their own version of Qt. Technically this means its possible to integrate with another Gui system (not Qt) aswell.

Another benefit is that it helps in avoiding issues with 3rd party plugin development because of qt version mismatch.

Now, Qode essentially becomes nodejs + <some code changes to allow message loop injection via an addon>

Note:

Qode is published as a NPM module as @nodegui/qode. For more details on the npm module visit: npm/README.md The changes to node are visible in the qode-v12.x branches in https://github.com/nodegui/node

Changes to Node.js

  • The event loop remains the same as that of NodeJs until a new Gui message loop is injected via the qode api. See below for details on the api.
  • When a Gui message loop is injected, qode will use it as the primary event loop and will process NodeJs requests on the main thread as an when it arrives by listening to the libuv's events.
  • Note: Make sure to use a binary compatible version of nodejs when using alongside qode. For example is qode has node version of 12.x then use Node version 12.x when developing apps with qode.

Currently only 64bit OS's are supported.

Steps for Windows

====================

Use Powershell in windows (possibly with git bash or similar installed)

  1. Do a git clone for this repo

  2. Install Visual Studio Community 2017. Download the Visual studio Installer and install Visual Studio Community 2017/2019. Make sure to choose "Desktop development with C++ " workload and install it.

  3. Building Qode. Run node build.js

Steps for Linux

==================

  1. Do a git clone for this repo

  2. Install GTK headers and patchelf:

sudo apt install libgtk-3-dev patchelf
  1. Building Qode. Run node build.js

Steps for MacOS

==================

  1. Do a git clone for this repo

  2. Building Qode. Run node build.js

Common build errors:

  1. if you get an error similar to:

     fatal error: gtk/gtk.h: No such file or directory
     #include <gtk/gtk.h>
    

    Make sure you have installed gtk headers as mentioned above.

  2. If you get an error similar to: ./qode: error while loading shared libraries: cannot open shared object file: No such file or directory.

    Check the shared libraries used by qode by running ldd ./qode. Then you can provide the path where qode could find the libraries like this:

    LD_LIBRARY_PATH=<path_to_lib>:$LD_LIBRARY_PATH ./qode

And make sure you have installed gtk3 headers also for time being.

  1. Yoga crashes when using with Qode. Make sure that node version you are using to compile nodegui is binary compatible with node version of Qode. or make sure you compile addons with Qode instead of Node.

Usage

The prebuilt binaries can be found in the Releases page, modules installed by npm can be used directly in qode. Qode can also be installed via npm.

Note that it is strong recommended to install the official Node.js with the same version of qode, otherwise native modules installed by npm may not work correctly in qode.

Build

TARGET_ARCH=[x64|ia32] HOST_ARCH=[x64|ia32] node ./build.js

or

`cmd /C "set TARGET_ARCH=[x64|ia32] && set HOST_ARCH=[x64|ia32] && node build.js"`

PS: I havent tested ia32 builds

The output of the build will be present at node/out/Release/qode

Configurations (Available from qode v1.0.3)

Additional configurations can be done via a qode.json file in the same directory as that of the qode binary.

qode.json

{
  distPath: "./dist/index.js" // This will try to load the index.js inside dist folder when qode.exe is run.
}

Troubleshooting

  • If you face python cant open file 'configure' - This means the git submodules have not been synced. So either manually sync your git submodules or set the environment variable SYNC_GIT_SUBMODULE=true before running build. See nodegui#7

Message Loop injection api

The NodeGui core addon uses the following api exposed by qode binary to inject Qt's event loop into nodejs

https://github.com/nodegui/node/blob/43e31129fc27f738b171dca3d744a0e4245dcc6d/src/qode_shared.h#L12

#pragma once
// From Qode headers
namespace qode {
    extern int qode_argc;
    extern char **qode_argv;
    typedef int (*QodeCustomRunLoopFunc)();
    extern void InjectCustomRunLoop(QodeCustomRunLoopFunc customRunLoop);
}  // namespace qode

License

The MIT license.

Thanks

The idea of Qode is derived from yode and electron. Infact Qode is a heavily modified fork of yode. I thank Cheng Zhao for yode and many of the ideas behind integration of GUI based libraries with NodeJS.

Checklist before publishing

  • Make sure to build on all platforms.
  • Make sure to update Qode version in qode.cc
  • Create github release
  • publish on npm

qode's People

Contributors

zcbenz avatar a7ul avatar azure-pipelines[bot] avatar dym-sh avatar markrocket avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.