New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-native-win-utils

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-native-win-utils - npm Package Compare versions

Comparing version
2.1.0
to
2.1.1
+39
-3
dist/index.cjs

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.OpenCV = exports.KeyboardListener = exports.textRecognition = exports.KeyCodeHelper = exports.rawPressKey = exports.typeString = exports.mouseDrag = exports.mouseClick = exports.mouseMove = exports.captureWindowN = exports.getWindowData = void 0;
exports.OpenCV = exports.KeyboardListener = exports.captureScreenAsync = exports.textRecognition = exports.KeyCodeHelper = exports.rawPressKey = exports.typeString = exports.mouseDrag = exports.mouseClick = exports.mouseMove = exports.captureWindowN = exports.getWindowData = void 0;
exports.captureWindow = captureWindow;

@@ -24,2 +24,3 @@ exports.keyPress = keyPress;

exports.captureWindowN = captureWindowN;
exports.captureScreenAsync = captureScreenAsync;
exports.mouseMove = mouseMove;

@@ -61,10 +62,22 @@ exports.mouseClick = mouseClick;

/**
* Represents a class to listen to keyboard events.
* Class that implements a private keyboard listener.
* This class leverages native C++ bindings to hook into system keyboard events.
* The C++ layer uses global ThreadSafeFunction objects to safely dispatch events
* (using a dedicated monitoring thread, mutexes, and atomic flags) to JavaScript.
* @extends EventEmitter
*/
class KeyboardListenerPrivate extends events_1.default {
/**
* Constructs the keyboard listener and sets up native callbacks.
* The callbacks (set via setKeyDownCallback and setKeyUpCallback) are defined in the
* C++ binding layer. They are responsible for invoking these JavaScript callbacks
* in a thread-safe manner once a key event is detected.
*/
constructor() {
super();
// Set the callback for key down events.
setKeyDownCallback((keyCode) => {
// Look up the human-readable key name from a mapping.
const keyName = keyCodes_cjs_1.keyCodes.get(keyCode.toString());
// Emit the 'keyDown' event to all registered JavaScript listeners.
this.emit("keyDown", {

@@ -75,4 +88,7 @@ keyCode,

});
// Set the callback for key up events.
setKeyUpCallback((keyCode) => {
// Look up the human-readable key name from a mapping.
const keyName = keyCodes_cjs_1.keyCodes.get(keyCode.toString());
// Emit the 'keyUp' event to all registered JavaScript listeners.
this.emit("keyUp", {

@@ -85,9 +101,29 @@ keyCode,

}
/**
* A singleton manager for the KeyboardListenerPrivate instance.
* This class ensures that only one native keyboard listener is active at any time.
* When the listener is destroyed, it calls unsetKeyDownCallback and unsetKeyUpCallback
* to clean up native resources, mirroring the cleanup logic in the C++ bindings.
*/
class KeyboardListener {
/**
* Holds the singleton instance of KeyboardListenerPrivate.
*/
static listenerInstance = null;
/**
* Returns the singleton instance of KeyboardListenerPrivate. If not already created,
* it instantiates a new instance and sets up the native callbacks.
* @returns The active KeyboardListenerPrivate instance.
*/
static listener() {
if (!this.listenerInstance)
if (!this.listenerInstance) {
this.listenerInstance = new KeyboardListenerPrivate();
}
return this.listenerInstance;
}
/**
* Destroys the current KeyboardListenerPrivate instance and cleans up native callbacks.
* This method calls unsetKeyDownCallback and unsetKeyUpCallback to release any
* native resources (such as the global ThreadSafeFunctions) and stops the monitoring thread.
*/
static destroy() {

@@ -94,0 +130,0 @@ this.listenerInstance = null;

@@ -85,3 +85,3 @@ import EventEmitter from 'events';

export type CaptureScreenAsync = () => Promise<Buffer>;
declare const getWindowData: GetWindowData, captureWindowN: CaptureWindow, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString, textRecognition: TextRecognition;
declare const getWindowData: GetWindowData, captureWindowN: CaptureWindow, captureScreenAsync: CaptureScreenAsync, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString, textRecognition: TextRecognition;
declare const rawPressKey: PressKey;

@@ -101,7 +101,15 @@ /**

declare function captureScreenToFile(path: string): Promise<boolean>;
/**
* Interface representing a private keyboard listener that extends EventEmitter.
* It declares event handlers for native keyboard events, which are forwarded from
* the C++ bindings using thread-safe callbacks.
*/
interface KeyboardListenerPrivate extends EventEmitter {
/**
* Event: Fires when a key is pressed down.
* Registers an event handler for the 'keyDown' event.
* This event is fired when a key is pressed down. The C++ native binding calls
* this callback using a thread-safe mechanism (via Napi::ThreadSafeFunction).
* @param event - The event name ('keyDown').
* @param callback - The callback function to handle the event.
* @param callback - Function invoked with an object containing the keyCode and keyName.
* @returns The current instance for method chaining.
*/

@@ -113,5 +121,8 @@ on(event: "keyDown", callback: (data: {

/**
* Event: Fires when a key is released.
* Registers an event handler for the 'keyUp' event.
* This event is fired when a key is released. The underlying C++ code safely
* invokes this callback from a background thread using a thread-safe function.
* @param event - The event name ('keyUp').
* @param callback - The callback function to handle the event.
* @param callback - Function invoked with an object containing the keyCode and keyName.
* @returns The current instance for method chaining.
*/

@@ -124,11 +135,39 @@ on(event: "keyUp", callback: (data: {

/**
* Represents a class to listen to keyboard events.
* Class that implements a private keyboard listener.
* This class leverages native C++ bindings to hook into system keyboard events.
* The C++ layer uses global ThreadSafeFunction objects to safely dispatch events
* (using a dedicated monitoring thread, mutexes, and atomic flags) to JavaScript.
* @extends EventEmitter
*/
declare class KeyboardListenerPrivate extends EventEmitter {
/**
* Constructs the keyboard listener and sets up native callbacks.
* The callbacks (set via setKeyDownCallback and setKeyUpCallback) are defined in the
* C++ binding layer. They are responsible for invoking these JavaScript callbacks
* in a thread-safe manner once a key event is detected.
*/
constructor();
}
/**
* A singleton manager for the KeyboardListenerPrivate instance.
* This class ensures that only one native keyboard listener is active at any time.
* When the listener is destroyed, it calls unsetKeyDownCallback and unsetKeyUpCallback
* to clean up native resources, mirroring the cleanup logic in the C++ bindings.
*/
declare class KeyboardListener {
/**
* Holds the singleton instance of KeyboardListenerPrivate.
*/
private static listenerInstance;
/**
* Returns the singleton instance of KeyboardListenerPrivate. If not already created,
* it instantiates a new instance and sets up the native callbacks.
* @returns The active KeyboardListenerPrivate instance.
*/
static listener(): KeyboardListenerPrivate;
/**
* Destroys the current KeyboardListenerPrivate instance and cleans up native callbacks.
* This method calls unsetKeyDownCallback and unsetKeyUpCallback to release any
* native resources (such as the global ThreadSafeFunctions) and stops the monitoring thread.
*/
static destroy(): void;

@@ -195,2 +234,2 @@ }

declare function keyPress(keyCode: number, repeat?: number): Promise<boolean>;
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, KeyboardListener, OpenCV };
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, captureScreenAsync, KeyboardListener, OpenCV };

@@ -85,3 +85,3 @@ import EventEmitter from 'events';

export type CaptureScreenAsync = () => Promise<Buffer>;
declare const getWindowData: GetWindowData, captureWindowN: CaptureWindow, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString, textRecognition: TextRecognition;
declare const getWindowData: GetWindowData, captureWindowN: CaptureWindow, captureScreenAsync: CaptureScreenAsync, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString, textRecognition: TextRecognition;
declare const rawPressKey: PressKey;

@@ -101,7 +101,15 @@ /**

declare function captureScreenToFile(path: string): Promise<boolean>;
/**
* Interface representing a private keyboard listener that extends EventEmitter.
* It declares event handlers for native keyboard events, which are forwarded from
* the C++ bindings using thread-safe callbacks.
*/
interface KeyboardListenerPrivate extends EventEmitter {
/**
* Event: Fires when a key is pressed down.
* Registers an event handler for the 'keyDown' event.
* This event is fired when a key is pressed down. The C++ native binding calls
* this callback using a thread-safe mechanism (via Napi::ThreadSafeFunction).
* @param event - The event name ('keyDown').
* @param callback - The callback function to handle the event.
* @param callback - Function invoked with an object containing the keyCode and keyName.
* @returns The current instance for method chaining.
*/

@@ -113,5 +121,8 @@ on(event: "keyDown", callback: (data: {

/**
* Event: Fires when a key is released.
* Registers an event handler for the 'keyUp' event.
* This event is fired when a key is released. The underlying C++ code safely
* invokes this callback from a background thread using a thread-safe function.
* @param event - The event name ('keyUp').
* @param callback - The callback function to handle the event.
* @param callback - Function invoked with an object containing the keyCode and keyName.
* @returns The current instance for method chaining.
*/

@@ -124,11 +135,39 @@ on(event: "keyUp", callback: (data: {

/**
* Represents a class to listen to keyboard events.
* Class that implements a private keyboard listener.
* This class leverages native C++ bindings to hook into system keyboard events.
* The C++ layer uses global ThreadSafeFunction objects to safely dispatch events
* (using a dedicated monitoring thread, mutexes, and atomic flags) to JavaScript.
* @extends EventEmitter
*/
declare class KeyboardListenerPrivate extends EventEmitter {
/**
* Constructs the keyboard listener and sets up native callbacks.
* The callbacks (set via setKeyDownCallback and setKeyUpCallback) are defined in the
* C++ binding layer. They are responsible for invoking these JavaScript callbacks
* in a thread-safe manner once a key event is detected.
*/
constructor();
}
/**
* A singleton manager for the KeyboardListenerPrivate instance.
* This class ensures that only one native keyboard listener is active at any time.
* When the listener is destroyed, it calls unsetKeyDownCallback and unsetKeyUpCallback
* to clean up native resources, mirroring the cleanup logic in the C++ bindings.
*/
declare class KeyboardListener {
/**
* Holds the singleton instance of KeyboardListenerPrivate.
*/
private static listenerInstance;
/**
* Returns the singleton instance of KeyboardListenerPrivate. If not already created,
* it instantiates a new instance and sets up the native callbacks.
* @returns The active KeyboardListenerPrivate instance.
*/
static listener(): KeyboardListenerPrivate;
/**
* Destroys the current KeyboardListenerPrivate instance and cleans up native callbacks.
* This method calls unsetKeyDownCallback and unsetKeyUpCallback to release any
* native resources (such as the global ThreadSafeFunctions) and stops the monitoring thread.
*/
static destroy(): void;

@@ -195,2 +234,2 @@ }

declare function keyPress(keyCode: number, repeat?: number): Promise<boolean>;
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, KeyboardListener, OpenCV };
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, captureScreenAsync, KeyboardListener, OpenCV };

@@ -42,10 +42,22 @@ import { createRequire as _createRequire } from "module";

/**
* Represents a class to listen to keyboard events.
* Class that implements a private keyboard listener.
* This class leverages native C++ bindings to hook into system keyboard events.
* The C++ layer uses global ThreadSafeFunction objects to safely dispatch events
* (using a dedicated monitoring thread, mutexes, and atomic flags) to JavaScript.
* @extends EventEmitter
*/
class KeyboardListenerPrivate extends EventEmitter {
/**
* Constructs the keyboard listener and sets up native callbacks.
* The callbacks (set via setKeyDownCallback and setKeyUpCallback) are defined in the
* C++ binding layer. They are responsible for invoking these JavaScript callbacks
* in a thread-safe manner once a key event is detected.
*/
constructor() {
super();
// Set the callback for key down events.
setKeyDownCallback((keyCode) => {
// Look up the human-readable key name from a mapping.
const keyName = keyCodes.get(keyCode.toString());
// Emit the 'keyDown' event to all registered JavaScript listeners.
this.emit("keyDown", {

@@ -56,4 +68,7 @@ keyCode,

});
// Set the callback for key up events.
setKeyUpCallback((keyCode) => {
// Look up the human-readable key name from a mapping.
const keyName = keyCodes.get(keyCode.toString());
// Emit the 'keyUp' event to all registered JavaScript listeners.
this.emit("keyUp", {

@@ -66,9 +81,29 @@ keyCode,

}
/**
* A singleton manager for the KeyboardListenerPrivate instance.
* This class ensures that only one native keyboard listener is active at any time.
* When the listener is destroyed, it calls unsetKeyDownCallback and unsetKeyUpCallback
* to clean up native resources, mirroring the cleanup logic in the C++ bindings.
*/
class KeyboardListener {
/**
* Holds the singleton instance of KeyboardListenerPrivate.
*/
static listenerInstance = null;
/**
* Returns the singleton instance of KeyboardListenerPrivate. If not already created,
* it instantiates a new instance and sets up the native callbacks.
* @returns The active KeyboardListenerPrivate instance.
*/
static listener() {
if (!this.listenerInstance)
if (!this.listenerInstance) {
this.listenerInstance = new KeyboardListenerPrivate();
}
return this.listenerInstance;
}
/**
* Destroys the current KeyboardListenerPrivate instance and cleans up native callbacks.
* This method calls unsetKeyDownCallback and unsetKeyUpCallback to release any
* native resources (such as the global ThreadSafeFunctions) and stops the monitoring thread.
*/
static destroy() {

@@ -180,2 +215,2 @@ this.listenerInstance = null;

}
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, KeyboardListener, OpenCV };
export { getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper, textRecognition, captureScreenToFile, captureScreenAsync, KeyboardListener, OpenCV };
+1
-1
{
"name": "node-native-win-utils",
"version": "2.1.0",
"version": "2.1.1",
"author": "Andrew K.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -452,4 +452,5 @@ import EventEmitter from 'events'

captureScreenToFile,
captureScreenAsync,
KeyboardListener,
OpenCV
};