From 659e1a59d215ec05470605f24bc762321f097e24 Mon Sep 17 00:00:00 2001 From: Janealter Date: Thu, 26 Sep 2019 20:33:23 +0300 Subject: [PATCH] Fix Node.js 12 compatibility (#58) --- .travis.yml | 1 + lib/windows.js | 8 ++++---- package.json | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index dc8a9ed..2008f11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ dist: bionic services: - xvfb node_js: + - '12' - '10' - '8' before_install: diff --git a/lib/windows.js b/lib/windows.js index c756ba9..03b6492 100644 --- a/lib/windows.js +++ b/lib/windows.js @@ -2,9 +2,9 @@ 'use strict'; const path = require('path'); const ffi = require('ffi-napi'); -const wchar = require('ref-wchar'); -const ref = require('ref'); -const struct = require('ref-struct'); +const wchar = require('ref-wchar-napi'); +const ref = require('ref-napi'); +const struct = require('ref-struct-napi'); // Create the struct required to save the window bounds const Rect = struct({ @@ -82,7 +82,7 @@ function windows() { const windowId = ref.address(activeWindowHandle); // Get the window text length in "characters" to create the buffer const windowTextLength = user32.GetWindowTextLengthW(activeWindowHandle); - // Allocate a buffer large enough to hold the window text as "Unicode" (UTF-16) characters (using ref-wchar) + // Allocate a buffer large enough to hold the window text as "Unicode" (UTF-16) characters (using ref-wchar-napi) // This assumes using the "Basic Multilingual Plane" of Unicode, only 2 characters per Unicode code point // Include some extra bytes for possible null characters const windowTextBuffer = Buffer.alloc((windowTextLength * 2) + 4); diff --git a/package.json b/package.json index d23d1b7..f59aac0 100644 --- a/package.json +++ b/package.json @@ -53,8 +53,8 @@ }, "optionalDependencies": { "ffi-napi": "^2.4.5", - "ref": "^1.3.5", - "ref-wchar": "^1.0.2", - "ref-struct": "^1.1.0" + "ref-napi": "^1.4.2", + "ref-wchar-napi": "^1.0.2", + "ref-struct-napi": "^1.1.0" } }