node-gtk 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,8 +19,8 @@ Node-Gtk is a [gobject-introspection](https://gi.readthedocs.io/en/latest) libra
19
19
  use any introspected library, such as Gtk+, usable. It is similar in essence to [GJS](https://wiki.gnome.org/action/show/Projects/Gjs) or [PyGObject](https://pygobject.readthedocs.io). Please note this project is currently in a _beta_ state and is being developed. Any contributors willing to help
20
20
  will be welcomed.
21
21
 
22
- Supported Node.js versions: **12**, **14**, **15**, **16** (other versions should work but are untested)
23
- Pre-built binaries available for: **Linux**, **macOS**
22
+ Supported Node.js versions: **16**, **18** (other versions should work but are untested)<br>
23
+ Pre-built binaries available for: **Linux**, **macOS** (all supported versions except 18)
24
24
 
25
25
  ### Table of contents
26
26
 
@@ -32,8 +32,8 @@ Pre-built binaries available for: **Linux**, **macOS**
32
32
  - [How to build on Ubuntu](#how-to-build-on-ubuntu)
33
33
  - [How to build on Fedora](#how-to-build-on-fedora)
34
34
  - [How to build on ArchLinux](#how-to-build-on-archlinux)
35
- - [How to build on macOS](#how-to-build-on-osx)
36
- - [Experimental platforms](#experimental-platforms)
35
+ - [How to build on macOS](#how-to-build-on-macos)
36
+ - [How to build on Windows](#how-to-build-on-windows)
37
37
  - [Testing the project](#testing-the-project)
38
38
  - [Browser demo](#browser-demo)
39
39
  - [Contributing](#contributing)
@@ -88,17 +88,15 @@ Note that prebuilt binaries are available for common systems, in those cases bui
88
88
 
89
89
  - **Linux**: prebuilt binaries available
90
90
  - **macOS**: prebuilt binaries available
91
- - **Windows**: unsupported for now ([#241](https://github.com/romgrk/node-gtk/issues/241))
91
+ - **Windows**: no prebuilt binaries
92
92
 
93
93
  ### Requirements
94
94
 
95
95
  - `git`
96
96
  - `nodejs@10` or higher
97
- - `python2` (for `node-gyp`)
97
+ - `python3` (for `node-gyp`)
98
98
  - C compiler (`gcc@8` or higher, or `clang`)
99
99
 
100
- In the _not-working-yet_ Windows platform, all dependencies must be available under [MSYS2 shell](https://msys2.github.io).
101
-
102
100
  ### How to build on Ubuntu
103
101
 
104
102
  Install basic dependencies.
@@ -155,48 +153,11 @@ brew install git node gobject-introspection gtk+3 cairo
155
153
 
156
154
  At this point `npm install node-gtk` should already install, fallback and build `node-gtk` without problems.
157
155
 
158
- ### Testing the project
159
-
160
- If you'd like to test everything builds and work properly, after installing and building you can run any of the
161
- examples:
162
-
163
- ```sh
164
- node ./examples/hello-gtk.js
165
- ```
166
-
167
- If you'll see a little window saying hello that's it: it works!
168
-
169
- Please note in macOS the window doesn't automatically open above other windows.
170
- Try <kbd>Cmd</kbd> + <kbd>Tab</kbd> if you don't see it.
171
-
172
- #### Browser demo
173
-
174
- If you'd like to test `./examples/browser.js` you'll need [WebKit2 GTK+](http://webkitgtk.org/) libary.
175
-
176
- - in **Ubuntu**, you can `apt-get install libwebkit2gtk-3.0` (`4.0` works too) and try it out.
177
- - in **Fedora**, you should run `sudo dnf install webkit2gtk3`
178
- - in **ArchLinux**, you can `pacman -S --needed webkitgtk` and try it out.
179
- - in **macOS**, there is no way to run it right now because `webkitgtk` was removed from homebrew
180
-
181
- Once installed, you can `./examples/browser.js google.com` or any other page, and you might try the _dark theme_ out too:
182
-
183
- ```sh
184
- # macOS needs to have the Adwaita theme installed
185
- # brew install adwaita-icon-theme
186
-
187
- # Usage: ./examples/browser.js <url> [theme]
188
- ./examples/browser.js google.com dark
189
- ```
190
-
191
- ### Experimental platforms
156
+ ### How to build on Windows
192
157
 
193
- Following how to setup the configuration to at least try building this project.
158
+ Mandatory dependency is Visual C++ Build Environment: Visual Studio Build Tools (using "Visual C++ build tools" workload) or Visual Studio Community (using the "Desktop development with C++" workload).
194
159
 
195
- #### How to build on Windows (experimental)
196
-
197
- Mandatory dependency is _[Visual Studio Community](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx)_ or _Express_ with a C++ compiler (open a new C++ project and install it via IDE if necessary).
198
-
199
- The easiest/tested way to at least try building this repository is within a _MinGW shell_ provided by the [MSYS2 installer](https://msys2.github.io/).
160
+ The easiest/tested way to build this repository is within a _MinGW shell_ provided by the [MSYS2 installer](https://msys2.github.io/).
200
161
 
201
162
  Once VS and its C++ compiler is available and MSYS2 installed, launch the MinGW shell.
202
163
 
@@ -226,12 +187,18 @@ cd node-gtk
226
187
  export MINGW_WINDOWS_PATH=$(./windows/mingw_windows_path.sh)
227
188
 
228
189
  # first run might take a while
229
- GYP_MSVS_VERSION=2015 npm install
190
+ GYP_MSVS_VERSION=2017 npm install
230
191
  ```
231
192
 
232
- The `GYP_MSVS_VERSION` could be 2010, 2012, 2013 or 2015.
193
+ The `GYP_MSVS_VERSION` could be 2017 or above.
233
194
  Please verify [which version you should use](https://github.com/nodejs/node-gyp#installation)
234
195
 
196
+ The below blog post series will help you get started:
197
+
198
+ 1. [Node.js GTK Hello World on Windows](https://ten0s.github.io/blog/2022/07/22/nodejs-gtk-hello-world-on-windows)
199
+ 2. [Find DLLs and Typelibs dependencies for Node.js GTK Application on Windows](https://ten0s.github.io/blog/2022/07/25/find-dlls-and-typelibs-dependencies-for-nodejs-gtk-application-on-windows)
200
+ 3. [Package Node.js GTK Application on Windows](https://ten0s.github.io/blog/2022/07/27/package-nodejs-gtk-application-on-windows)
201
+
235
202
  #### Possible issue on MinGW shell
236
203
 
237
204
  In case you are launching the general executable without knowing the correct platform,
@@ -249,11 +216,38 @@ npm run install
249
216
 
250
217
  This should do the trick. You can also check if there is any python at all via `pacman -Qs python`.
251
218
 
252
- Please remember `python2` is the one needed.
219
+ ### Testing the project
220
+
221
+ If you'd like to test everything builds and work properly, after installing and building you can run any of the
222
+ examples:
223
+
224
+ ```sh
225
+ node ./examples/hello-gtk.js
226
+ ```
227
+
228
+ If you'll see a little window saying hello that's it: it works!
229
+
230
+ Please note in macOS the window doesn't automatically open above other windows.
231
+ Try <kbd>Cmd</kbd> + <kbd>Tab</kbd> if you don't see it.
232
+
233
+ #### Browser demo
253
234
 
254
- #### Known issues building on Windows
235
+ If you'd like to test `./examples/browser.js` you'll need [WebKit2 GTK+](http://webkitgtk.org/) libary.
255
236
 
256
- Right now there are few gotchas and the build will most likely fail. Please help with a PR if you know how to solve the issue, thank you!
237
+ - in **Ubuntu**, you can `apt-get install libwebkit2gtk-3.0` (`4.0` works too) and try it out.
238
+ - in **Fedora**, you should run `sudo dnf install webkit2gtk3`
239
+ - in **ArchLinux**, you can `pacman -S --needed webkitgtk` and try it out.
240
+ - in **macOS**, there is no way to run it right now because `webkitgtk` was removed from homebrew
241
+
242
+ Once installed, you can `./examples/browser.js google.com` or any other page, and you might try the _dark theme_ out too:
243
+
244
+ ```sh
245
+ # macOS needs to have the Adwaita theme installed
246
+ # brew install adwaita-icon-theme
247
+
248
+ # Usage: ./examples/browser.js <url> [theme]
249
+ ./examples/browser.js google.com dark
250
+ ```
257
251
 
258
252
  ## Contributing
259
253
 
package/binding.gyp CHANGED
@@ -56,7 +56,6 @@
56
56
  }],
57
57
  ['OS == "mac"', {
58
58
  "defines": [
59
- "ulong=unsigned long",
60
59
  "PLATFORM_MAC=1",
61
60
  ],
62
61
  "xcode_settings": {
@@ -32,6 +32,14 @@ exports.apply = (Gtk) => {
32
32
  process._tickCallback()
33
33
 
34
34
  const loopStack = internal.GetLoopStack()
35
+
36
+ /*
37
+ * To keep the nodejs event loop alive, we need to have something running.
38
+ */
39
+ if (placeholderIntervalID === undefined) {
40
+ placeholderIntervalID = setInterval(() => { /* noop */ }, 60 * 60 * 1000)
41
+ }
42
+
35
43
  loopStack.push(originalQuit)
36
44
 
37
45
  originalMain()
@@ -11,6 +11,22 @@ exports.apply = (Gtk) => {
11
11
  Gtk.EVENT_CONTINUE = false
12
12
  Gtk.EVENT_STOP = true
13
13
 
14
+ /**
15
+ * Gtk.Widget.prototype.containsChild
16
+ * @param {Gtk.Widget} child
17
+ * @returns {bool}
18
+ */
19
+ Gtk.Widget.prototype.containsChild = function containsChild(child) {
20
+ let current = child
21
+ while (current) {
22
+ if (current === this)
23
+ return true
24
+ current = current.getParent()
25
+ }
26
+ return false
27
+ }
28
+
29
+
14
30
  Gtk.Widget.prototype._addCssClass = Gtk.Widget.prototype.addCssClass
15
31
  Gtk.Widget.prototype._removeCssClass = Gtk.Widget.prototype.removeCssClass
16
32
 
package/package.json CHANGED
@@ -1,8 +1,15 @@
1
1
  {
2
2
  "name": "node-gtk",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "GNOME Gtk+ bindings for NodeJS",
5
5
  "main": "lib/index.js",
6
+ "scripts": {
7
+ "install": "npx node-pre-gyp install --fallback-to-build",
8
+ "test": "mocha tests/__run__.js",
9
+ "build": "npx node-pre-gyp build",
10
+ "build:full": "npx node-pre-gyp rebuild",
11
+ "configure": "npx node-pre-gyp configure --debug"
12
+ },
6
13
  "repository": {
7
14
  "type": "git",
8
15
  "url": "git+https://github.com/romgrk/node-gtk.git"
@@ -25,12 +32,12 @@
25
32
  },
26
33
  "homepage": "https://github.com/romgrk/node-gtk#readme",
27
34
  "dependencies": {
28
- "@mapbox/node-pre-gyp": "^1.0.0",
35
+ "@mapbox/node-pre-gyp": "^1.0.10",
29
36
  "lodash.camelcase": "4.3.0",
30
37
  "lodash.isequal": "4.5.0",
31
38
  "lodash.snakecase": "^4.1.1",
32
- "nan": "2.14.2",
33
- "node-gyp": "^7.1.2",
39
+ "nan": "^2.17.0",
40
+ "node-gyp": "^9.3.1",
34
41
  "remove-trailing-spaces": "^1.0.7",
35
42
  "unindent": "^2.0.0"
36
43
  },
@@ -55,12 +62,5 @@
55
62
  "remote_path": "./{module_name}/v{version}/",
56
63
  "package_name": "{module_name}-{node_abi}-{platform}-{arch}.tar.gz",
57
64
  "host": "https://node-gtk-1.s3.amazonaws.com"
58
- },
59
- "scripts": {
60
- "install": "npx node-pre-gyp install --fallback-to-build",
61
- "test": "mocha tests/__run__.js",
62
- "build": "npx node-pre-gyp build",
63
- "build:full": "npx node-pre-gyp rebuild",
64
- "configure": "npx node-pre-gyp configure --debug"
65
65
  }
66
- }
66
+ }
package/scripts/ci.sh CHANGED
@@ -41,7 +41,11 @@ function npm_test() {
41
41
  echo "### Running tests ###";
42
42
 
43
43
  if [[ $(uname -s) == 'Darwin' ]]; then
44
- npm test;
44
+ export GST_PLUGIN_SYSTEM_PATH=/usr/local/lib/gstreamer-1.0;
45
+ npx mocha \
46
+ --skip=callback \
47
+ --skip=error \
48
+ tests/__run__.js
45
49
  else
46
50
  xvfb-run -a npm test;
47
51
  fi;
package/src/callback.cc CHANGED
@@ -18,7 +18,6 @@ using v8::Isolate;
18
18
  using v8::Local;
19
19
  using v8::Object;
20
20
  using v8::Value;
21
- using Nan::TryCatch;
22
21
 
23
22
  namespace GNodeJS {
24
23
 
@@ -33,13 +32,13 @@ static Local<Object> GetSelfInstance(GIArgument **args) {
33
32
  Callback::Callback(Local<Function> fn, GICallableInfo* callback_info, GIScopeType scope_type_) {
34
33
  persistent.Reset(fn);
35
34
  info = g_base_info_ref (callback_info);
36
- closure = g_callable_info_prepare_closure(info, &cif, Callback::Call, this);
35
+ closure = g_callable_info_create_closure(info, &cif, Callback::Call, this);
37
36
  scope_type = scope_type_;
38
37
  }
39
38
 
40
39
  Callback::~Callback() {
41
40
  persistent.Reset();
42
- g_callable_info_free_closure (this->info, this->closure);
41
+ g_callable_info_destroy_closure (this->info, this->closure);
43
42
  g_base_info_unref (this->info);
44
43
  }
45
44
 
package/src/util.h CHANGED
@@ -55,9 +55,7 @@ inline void SetProtoAccessor(
55
55
  setter,
56
56
  v8::Local<v8::Value>(),
57
57
  v8::DEFAULT,
58
- v8::None,
59
- v8::AccessorSignature::New(v8::Isolate::GetCurrent(), ctor)
60
- );
58
+ v8::None);
61
59
  }
62
60
 
63
61
  namespace Util
package/src/value.cc CHANGED
@@ -877,8 +877,6 @@ bool V8ToOutGIArgument(GITypeInfo *type_info, GIArgument *arg, Local<Value> valu
877
877
  */
878
878
  GITypeTag type_tag = g_type_info_get_tag (type_info);
879
879
 
880
- memset(arg, 0, sizeof(GIArgument));
881
-
882
880
  if (value->IsUndefined () || value->IsNull ()) {
883
881
  arg->v_pointer = NULL;
884
882