Skip to content

Commit 5bc0402

Browse files
committed
Cleanup readme and docs
1 parent 6a20e4d commit 5bc0402

4 files changed

Lines changed: 193 additions & 107 deletions

File tree

‎extras/docs/README.md‎

Lines changed: 3 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -10,129 +10,25 @@
1010
- [Hello World](tutorial/first-app.md#Hello-World)
1111
- [NodeGui Development in a Nutshell](tutorial/first-app.md#NodeGui-development-in-a-nutshell)
1212
- [Running Your App](tutorial/first-app.md#running-your-app)
13-
14-
// BOOK MARK - TODO AFTER THIS
15-
1613
- [Application Architecture](tutorial/application-architecture.md)
17-
- [Main and Renderer Processes](tutorial/application-architecture.md#main-and-renderer-processes)
14+
- [Qode](tutorial/application-architecture.md#qode)
1815
- [Using NodeGui's APIs](tutorial/application-architecture.md#using-NodeGui-apis)
1916
- [Using Node.js APIs](tutorial/application-architecture.md#using-nodejs-apis)
2017
- [Using Native Node.js Modules](tutorial/using-native-node-modules.md)
21-
- Adding Features to Your App
22-
- [Notifications](tutorial/notifications.md)
23-
- [Recent Documents](tutorial/recent-documents.md)
24-
- [Application Progress](tutorial/progress-bar.md)
25-
- [Custom Dock Menu](tutorial/macos-dock.md)
26-
- [Custom Windows Taskbar](tutorial/windows-taskbar.md)
27-
- [Custom Linux Desktop Actions](tutorial/linux-desktop-actions.md)
28-
- [Keyboard Shortcuts](tutorial/keyboard-shortcuts.md)
29-
- [Offline/Online Detection](tutorial/online-offline-events.md)
30-
- [Represented File for macOS BrowserWindows](tutorial/represented-file.md)
31-
- [Native File Drag & Drop](tutorial/native-file-drag-drop.md)
32-
- [Offscreen Rendering](tutorial/offscreen-rendering.md)
33-
- [Supporting macOS Dark Mode](tutorial/mojave-dark-mode-guide.md)
18+
// BOOK MARK - TODO AFTER THIS
3419
- [Testing and Debugging](tutorial/application-debugging.md)
3520
- [Debugging the Main Process](tutorial/debugging-main-process.md)
3621
- [Debugging the Main Process with Visual Studio Code](tutorial/debugging-main-process-vscode.md)
37-
- [Using Selenium and WebDriver](tutorial/using-selenium-and-webdriver.md)
38-
- [Testing on Headless CI Systems (Travis, Jenkins)](tutorial/testing-on-headless-ci.md)
3922
- [DevTools Extension](tutorial/devtools-extension.md)
40-
- [Automated Testing with a Custom Driver](tutorial/automated-testing-with-a-custom-driver.md)
4123
- [Distribution](tutorial/application-distribution.md)
4224
- [Supported Platforms](tutorial/support.md#supported-platforms)
4325
- [Code Signing](tutorial/code-signing.md)
4426
- [Mac App Store](tutorial/mac-app-store-submission-guide.md)
4527
- [Windows Store](tutorial/windows-store-guide.md)
4628
- [Snapcraft](tutorial/snapcraft.md)
47-
- [Security](tutorial/security.md)
48-
- [Reporting Security Issues](tutorial/security.md#reporting-security-issues)
49-
- [Chromium Security Issues and Upgrades](tutorial/security.md#chromium-security-issues-and-upgrades)
50-
- [NodeGui Security Warnings](tutorial/security.md#NodeGui-security-warnings)
51-
- [Security Checklist](tutorial/security.md#checklist-security-recommendations)
52-
- [Updates](tutorial/updates.md)
53-
- [Deploying an Update Server](tutorial/updates.md#deploying-an-update-server)
54-
- [Implementing Updates in Your App](tutorial/updates.md#implementing-updates-in-your-app)
55-
- [Applying Updates](tutorial/updates.md#applying-updates)
29+
// Need to finish till here
5630
- [Getting Support](tutorial/support.md)
5731

58-
## Detailed Tutorials
59-
60-
These individual tutorials expand on topics discussed in the guide above.
61-
62-
- [Installing NodeGui](tutorial/installation.md)
63-
- [Proxies](tutorial/installation.md#proxies)
64-
- [Custom Mirrors and Caches](tutorial/installation.md#custom-mirrors-and-caches)
65-
- [Troubleshooting](tutorial/installation.md#troubleshooting)
66-
- NodeGui Releases & Developer Feedback
67-
- [Versioning Policy](tutorial/NodeGui-versioning.md)
68-
- [Release Timelines](tutorial/NodeGui-timelines.md)
69-
- [App Feedback Program](tutorial/app-feedback-program.md)
70-
- [Packaging App Source Code with asar](tutorial/application-packaging.md)
71-
- [Generating asar Archives](tutorial/application-packaging.md#generating-asar-archives)
72-
- [Using asar Archives](tutorial/application-packaging.md#using-asar-archives)
73-
- [Limitations](tutorial/application-packaging.md#limitations-of-the-node-api)
74-
- [Adding Unpacked Files to asar Archives](tutorial/application-packaging.md#adding-unpacked-files-to-asar-archives)
75-
- [Testing Widevine CDM](tutorial/testing-widevine-cdm.md)
76-
- [Using Pepper Flash Plugin](tutorial/using-pepper-flash-plugin.md)
77-
78-
---
79-
80-
- [Glossary of Terms](glossary.md)
81-
82-
## API References
83-
84-
- [Synopsis](api/synopsis.md)
85-
- [Process Object](api/process.md)
86-
- [Supported Chrome Command Line Switches](api/chrome-command-line-switches.md)
87-
- [Environment Variables](api/environment-variables.md)
88-
- [Breaking API Changes](api/breaking-changes.md)
89-
90-
### Custom DOM Elements:
91-
92-
- [`File` Object](api/file-object.md)
93-
- [`<webview>` Tag](api/webview-tag.md)
94-
- [`window.open` Function](api/window-open.md)
95-
- [`BrowserWindowProxy` Object](api/browser-window-proxy.md)
96-
97-
### Modules for the Main Process:
98-
99-
- [app](api/app.md)
100-
- [autoUpdater](api/auto-updater.md)
101-
- [BrowserView](api/browser-view.md)
102-
- [BrowserWindow](api/browser-window.md)
103-
- [contentTracing](api/content-tracing.md)
104-
- [dialog](api/dialog.md)
105-
- [globalShortcut](api/global-shortcut.md)
106-
- [inAppPurchase](api/in-app-purchase.md)
107-
- [ipcMain](api/ipc-main.md)
108-
- [Menu](api/menu.md)
109-
- [MenuItem](api/menu-item.md)
110-
- [net](api/net.md)
111-
- [netLog](api/net-log.md)
112-
- [powerMonitor](api/power-monitor.md)
113-
- [powerSaveBlocker](api/power-save-blocker.md)
114-
- [protocol](api/protocol.md)
115-
- [screen](api/screen.md)
116-
- [session](api/session.md)
117-
- [systemPreferences](api/system-preferences.md)
118-
- [TouchBar](api/touch-bar.md)
119-
- [Tray](api/tray.md)
120-
- [webContents](api/web-contents.md)
121-
122-
### Modules for the Renderer Process (Web Page):
123-
124-
- [desktopCapturer](api/desktop-capturer.md)
125-
- [ipcRenderer](api/ipc-renderer.md)
126-
- [remote](api/remote.md)
127-
- [webFrame](api/web-frame.md)
128-
129-
### Modules for Both Processes:
130-
131-
- [clipboard](api/clipboard.md)
132-
- [crashReporter](api/crash-reporter.md)
133-
- [nativeImage](api/native-image.md)
134-
- [shell](api/shell.md)
135-
13632
## Development
13733

13834
See [development/README.md](development/README.md)
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# NodeGui Application Architecture
2+
3+
Before we can dive into NodeGui's APIs, we need to discuss how NodeGui works internally. This would give a clear picture on why the APIs are the way they are.
4+
5+
## Qode
6+
7+
NodeGui uses Qt for creating Windows and other UI element. Hence it exports thin wrappers of native C++ widgets from Qt into Javascript world. Now, every Qt application needs to initialize an instance of `QApplication` before creating widgets. The way we do it in C++ Qt application is (dont worry if it doesnt make sense right now):
8+
9+
```cpp
10+
#include <QApplication>
11+
#include <QPushButton>
12+
13+
int main(int argc, char *argv[])
14+
{
15+
QApplication app(argc, argv); // Important
16+
17+
QPushButton hello("Hello world!");
18+
hello.resize(100, 30);
19+
hello.show();
20+
21+
return app.exec(); // Important
22+
}
23+
```
24+
25+
Like many Gui libraries Qt uses an event/message loop to handle events from widgets. Hence, when we call `app.exec()` Qt starts its message loop and blocks on that line. This is all good when there is only one message loop in the entire app. But since we want to use Qt with NodeJS and NodeJs has its own event loop, we cannot run both Qt and NodeJs on the same thread easily.
26+
27+
Then following questions arise:
28+
29+
- **What if we run Qt on a separate thread?** : No this is not possible since Qt has a requirement that it needs to run on the main thread.
30+
- **What if we run Node on a separate thread?** : This would mean we need to build a complex bridge between Node and Qt threads to make them communicate. A strict no no.
31+
32+
So inorder to make both NodeJs and Qt work together we need to find a way to merge these two event loop into one. This is achieved by a custom NodeJs binary we call as `Qode`.
33+
34+
Qode is a lightly modified fork of Node.js that merges Node's event loop with Qt's event loop. The idea of merging event loops is inspired by Electron and [other](https://github.com/yue) Gui libraries developed by [zcbenz (Cheng Zhao)](https://github.com/zcbenz). It has been detailed in a post here: [Electron internals](https://electronjs.org/blog/electron-internals-node-integration). Hence, we reused the logic from electron to achieve smooth integration between Qt and NodeJs.
35+
36+
The idea is to release a corresponding Qode binary for every NodeJs version that comes out after Node v12.6.
37+
The source code of Qode can be found [here](https://github.com/master-atul/qode).
38+
39+
_\*PS: Qode is a fork of [Yode](https://github.com/yue/yode)_
40+
41+
## Using NodeGui APIs
42+
43+
NodeGui offers a number of APIs that support the development of a desktop
44+
application. You'd access NodeGui's APIs by requiring its included module:
45+
46+
```javascript
47+
require("@nodegui/nodegui");
48+
```
49+
50+
A window in NodeGui is for instance created using the `QMainWindow`
51+
class.
52+
53+
```javascript
54+
const { QMainWindow } = require("@nodegui/nodegui");
55+
56+
const win = new QMainWindow();
57+
```
58+
59+
## Using Nodejs APIs
60+
61+
NodeGui exposes full access to Node.js. This has two important implications:
62+
63+
1. All APIs available in Node.js are available in NodeGui. Calling the
64+
following code from an NodeGui app works:
65+
66+
```javascript
67+
const fs = require("fs");
68+
69+
const root = fs.readdirSync("/");
70+
71+
// This will print all files at the root-level of the disk,
72+
// either '/' or 'C:\'.
73+
console.log(root);
74+
```
75+
76+
2. You can use Node.js modules in your application. Pick your favorite npm
77+
module. npm offers currently the world's biggest repository of open-source
78+
code – the ability to use well-maintained and tested code that used to be
79+
reserved for server applications is one of the key features of NodeGui.
80+
81+
As an example, to use the official AWS SDK in your application, you'd first
82+
install it as a dependency:
83+
84+
```sh
85+
npm install --save aws-sdk
86+
```
87+
88+
Then, in your NodeGui app, require and use the module as if you were
89+
building a Node.js application:
90+
91+
```javascript
92+
// A ready-to-use S3 Client
93+
const S3 = require("aws-sdk/clients/s3");
94+
```
95+
96+
There is one important caveat: Native Node.js modules (that is, modules that
97+
require compilation of native code before they can be used) will need to be
98+
compiled with Qode or a compatible Node version to be used with NodeGui.
99+
100+
The vast majority of Node.js modules are _not_ native. Only 400 out of the
101+
~650.000 modules are native. However, if you do need native modules, please
102+
consult [this guide on how to recompile them for NodeGui][native-node].
103+
104+
[native-node]: ./using-native-node-modules.md

‎extras/docs/tutorial/support.md‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# NodeGui Support
2+
3+
## Finding Support
4+
5+
If you're looking for programming help or for answers to questions please file an issue on the NodeGui's Github project issues and we will try our best to answer and help out.
6+
7+
## Supported Platforms
8+
9+
Following platforms are supported by NodeGui:
10+
11+
### macOS
12+
13+
Only 64bit binaries are provided for macOS, and the minimum macOS version
14+
supported is macOS 10.10 (Yosemite).
15+
16+
### Windows
17+
18+
Windows 7 and later are supported, older operating systems are not supported
19+
(and might not work).
20+
21+
Only `x64` (`amd64`) binaries are provided for Windows at this point of time.
22+
23+
### Linux
24+
25+
The prebuilt `x64` (`amd64`) binaries of NodeGui are built on Ubuntu 12.04.
26+
27+
Whether the prebuilt binary can run on a distribution depends on whether the
28+
distribution includes the libraries that NodeGui is linked to on the building
29+
platform, so only Ubuntu 12.04 is guaranteed to work, but following platforms
30+
are also verified to be able to run the prebuilt binaries of NodeGui:
31+
32+
- Ubuntu 12.04 and newer
33+
- Fedora 21
34+
- Debian 8
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Using Native Node Modules
2+
3+
Native Node modules are supported by NodeGui, but since NodeGui is very
4+
likely to use a different V8 version from the Node binary installed on your
5+
system, the modules you use will need to be recompiled for NodeGui's node/v8 version. Otherwise,
6+
you will get the following class of error when you try to run your app:
7+
8+
```sh
9+
Error: The module '/path/to/native/module.node'
10+
was compiled against a different Node.js version using
11+
NODE_MODULE_VERSION $XYZ. This version of Node.js requires
12+
NODE_MODULE_VERSION $ABC. Please try re-compiling or re-installing
13+
the module (for instance, using `npm rebuild` or `npm install`).
14+
```
15+
16+
## How to install native modules
17+
18+
To compile native Node modules against a build of NodeGui that doesn't
19+
match a public release, instruct `npm` to use the version of Qode (NodeJs) you have bundled
20+
with your custom build.
21+
22+
```sh
23+
npm rebuild --nodedir=/path/to/nodegui/vendor/qode
24+
```
25+
26+
or
27+
28+
```sh
29+
qode /path/to/npm rebuild
30+
```
31+
32+
## Troubleshooting
33+
34+
If you installed a native module and found it was not working, you need to check
35+
the following things:
36+
37+
- When in doubt, rebuild native modules with qode first.
38+
- Make sure the native module is compatible with the target platform and
39+
architecture for your NodeGui app.
40+
- After you upgrade NodeGui, you usually need to rebuild the modules.
41+
42+
## Modules that rely on `node-pre-gyp`
43+
44+
The [`node-pre-gyp` tool][node-pre-gyp] provides a way to deploy native Node
45+
modules with prebuilt binaries, and many popular modules are using it.
46+
47+
Usually those modules work fine under NodeGui, but sometimes when NodeGui uses
48+
a newer version of V8 than Node and/or there are ABI changes, bad things may
49+
happen. So in general, it is recommended to always build native modules from
50+
source code.
51+
52+
[node-pre-gyp]: https://github.com/mapbox/node-pre-gyp

0 commit comments

Comments
 (0)