node-native-win-utils 1.3.2 → 1.3.4

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/binding.gyp CHANGED
@@ -1,46 +1,46 @@
1
- {
2
- "targets": [
3
- {
4
- "target_name": "node-native-win-utils",
5
- "sources": ["src/cpp/main.cpp"],
6
- "openssl_flips": "",
7
- "include_dirs": [
8
- "<!@(node -p \"require('node-addon-api').include\")",
9
- "src/cpp",
10
- "libs",
11
- "include",
12
- "dll"
13
- ],
14
- "dependencies": [
15
- "<!(node -p \"require('node-addon-api').gyp\")"
16
- ],
17
- "libraries": [
18
- "dwmapi.lib",
19
- "windowsapp.lib",
20
- "<!(node -p \"require('path').resolve('libs/libjpeg-turbo.lib')\")",
21
- "<!(node -p \"require('path').resolve('libs/libpng.lib')\")",
22
- "<!(node -p \"require('path').resolve('libs/zlib.lib')\")",
23
- "<!(node -p \"require('path').resolve('libs/opencv_core470.lib')\")",
24
- "<!(node -p \"require('path').resolve('libs/opencv_imgcodecs470.lib')\")",
25
- "<!(node -p \"require('path').resolve('libs/opencv_imgproc470.lib')\")",
26
-
27
- ],
28
- "conditions": [
29
- ["OS=='win'", {
30
- "defines": [
31
- "_CRT_SECURE_NO_WARNINGS"
32
- ],
33
- "msvs_settings": {
34
- "VCCLCompilerTool": {
35
- "AdditionalOptions": ["/EHsc"]
36
- }
37
- }
38
- }]
39
- ],
40
- "defines": ["NAPI_CPP_EXCEPTIONS"],
41
- "cflags!": ["-fno-exceptions"],
42
- "cflags_cc!": ["-fno-rtti"],
43
- "cflags": ["/std:c++17"]
44
- }
45
- ]
46
- }
1
+ {
2
+ "targets": [
3
+ {
4
+ "target_name": "node-native-win-utils",
5
+ "sources": ["src/cpp/main.cpp"],
6
+ "openssl_flips": "",
7
+ "include_dirs": [
8
+ "<!@(node -p \"require('node-addon-api').include\")",
9
+ "src/cpp",
10
+ "libs",
11
+ "include",
12
+ "dll"
13
+ ],
14
+ "dependencies": [
15
+ "<!(node -p \"require('node-addon-api').gyp\")"
16
+ ],
17
+ "libraries": [
18
+ "dwmapi.lib",
19
+ "windowsapp.lib",
20
+ "<!(node -p \"require('path').resolve('libs/libjpeg-turbo.lib')\")",
21
+ "<!(node -p \"require('path').resolve('libs/libpng.lib')\")",
22
+ "<!(node -p \"require('path').resolve('libs/zlib.lib')\")",
23
+ "<!(node -p \"require('path').resolve('libs/opencv_core470.lib')\")",
24
+ "<!(node -p \"require('path').resolve('libs/opencv_imgcodecs470.lib')\")",
25
+ "<!(node -p \"require('path').resolve('libs/opencv_imgproc470.lib')\")",
26
+
27
+ ],
28
+ "conditions": [
29
+ ["OS=='win'", {
30
+ "defines": [
31
+ "_CRT_SECURE_NO_WARNINGS"
32
+ ],
33
+ "msvs_settings": {
34
+ "VCCLCompilerTool": {
35
+ "AdditionalOptions": ["/EHsc"]
36
+ }
37
+ }
38
+ }]
39
+ ],
40
+ "defines": ["NAPI_CPP_EXCEPTIONS"],
41
+ "cflags!": ["-fno-exceptions"],
42
+ "cflags_cc!": ["-fno-rtti"],
43
+ "cflags": ["/std:c++21"]
44
+ }
45
+ ]
46
+ }
package/dist/index.d.ts CHANGED
@@ -1,173 +1,178 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import EventEmitter = require("events");
4
- /**
5
- * Represents the data of a window.
6
- */
7
- export type WindowData = {
8
- width: number;
9
- height: number;
10
- x: number;
11
- y: number;
12
- };
13
- /**
14
- * Represents the data of an image.
15
- */
16
- export type ImageData = {
17
- width: number;
18
- height: number;
19
- data: Uint8Array;
20
- };
21
- /**
22
- * Represents the result of a template matching operation.
23
- */
24
- export type MatchData = {
25
- minValue: number;
26
- maxValue: number;
27
- minLocation: {
28
- x: number;
29
- y: number;
30
- };
31
- maxLocation: {
32
- x: number;
33
- y: number;
34
- };
35
- };
36
- export type GetWindowData = (windowName: string) => WindowData;
37
- export type CaptureWindow = (windowName: string) => Buffer;
38
- /**
39
- * The handler to listen to key-down events.
40
- * @param callback - The callback function to handle key-down events.
41
- */
42
- export type KeyDownHandler = (callback: (keyCode: number) => void) => void;
43
- /**
44
- * The handler to listen to key-up events.
45
- * @param callback - The callback function to handle key-up events.
46
- */
47
- export type KeyUpHandler = (callback: (keyCode: number) => void) => void;
48
- /**
49
- * Function type for moving the mouse.
50
- */
51
- export type MouseMove = (posX: number, posY: number) => boolean;
52
- /**
53
- * Function type for simulating a mouse click.
54
- */
55
- export type MouseClick = (button?: "left" | "middle" | "right") => boolean;
56
- /**
57
- * Function type for simulating typing.
58
- */
59
- export type TypeString = (stringToType: string, delay?: number) => boolean;
60
- /**
61
- * Function type for simulating a mouse drag operation.
62
- */
63
- export type MouseDrag = (starX: number, startY: number, endX: Number, endY: number, speed?: number) => boolean;
64
- /**
65
- * Represents a point in a two-dimensional space.
66
- */
67
- export type Point = [x: number, y: number];
68
- export type Color = [r: number, g: number, b: number];
69
- /**
70
- * Represents a region of interest in an image.
71
- */
72
- export type ROI = [x: number, y: number, width: number, height: number];
73
- export type Imread = (path: string) => ImageData;
74
- export type Imwrite = (image: ImageData) => Buffer;
75
- export type MatchTemplate = (image: ImageData, template: ImageData, method?: number | null, mask?: ImageData) => MatchData;
76
- export type Blur = (image: ImageData, sizeX: number, sizeY: number) => ImageData;
77
- export type BgrToGray = (image: ImageData) => ImageData;
78
- export type DrawRectangle = (image: ImageData, start: Point, end: Point, rgb: Color, thickness: number) => ImageData;
79
- export type GetRegion = (image: ImageData, region: ROI) => ImageData;
80
- declare const keyDownHandler: KeyDownHandler, keyUpHandler: KeyUpHandler, getWindowData: GetWindowData, captureWindowN: CaptureWindow, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString;
81
- /**
82
- * Captures a window and saves it to a file.
83
- * @param windowName - The name of the window to capture.
84
- * @param path - The file path to save the captured image.
85
- * @returns True if the capture and save operation is successful, otherwise false.
86
- */
87
- declare function captureWindow(windowName: string, path: string): boolean;
88
- export interface KeyListener extends EventEmitter {
89
- /**
90
- * Event: Fires when a key is pressed down.
91
- * @param event - The event name ('keyDown').
92
- * @param callback - The callback function to handle the event.
93
- */
94
- on(event: "keyDown", callback: (data: {
95
- keyCode: number;
96
- keyName: string;
97
- }) => void): this;
98
- /**
99
- * Event: Fires when a key is released.
100
- * @param event - The event name ('keyUp').
101
- * @param callback - The callback function to handle the event.
102
- */
103
- on(event: "keyUp", callback: (data: {
104
- keyCode: number;
105
- keyName: string;
106
- }) => void): this;
107
- }
108
- /**
109
- * Represents a class to listen to keyboard events.
110
- * @extends EventEmitter
111
- */
112
- export declare class KeyListener extends EventEmitter {
113
- constructor();
114
- }
115
- /**
116
- * Represents the OpenCV class that provides image processing functionality.
117
- */
118
- export declare class OpenCV {
119
- imageData: ImageData;
120
- /**
121
- * Represents the OpenCV class that provides image processing functionality.
122
- */
123
- constructor(image: string | ImageData);
124
- /**
125
- * The width of the image.
126
- */
127
- get width(): number;
128
- /**
129
- * The height of the image.
130
- */
131
- get height(): number;
132
- /**
133
- * Matches a template image within the current image.
134
- * @param template - The template image data to search for.
135
- * @param method - The template matching method (optional).
136
- * @param mask - The optional mask image data to apply the operation (optional).
137
- * @returns The result of the template matching operation.
138
- */
139
- matchTemplate(template: ImageData, method?: number | null, mask?: ImageData): MatchData;
140
- /**
141
- * Applies a blur filter to the image.
142
- * @param sizeX - The horizontal size of the blur filter.
143
- * @param sizeY - The vertical size of the blur filter.
144
- * @returns A new OpenCV instance with the blurred image data.
145
- */
146
- blur(sizeX: number, sizeY: number): OpenCV;
147
- /**
148
- * Converts the image from BGR to grayscale.
149
- * @returns A new OpenCV instance with the grayscale image data.
150
- */
151
- bgrToGray(): OpenCV;
152
- /**
153
- * Draws a rectangle on the image.
154
- * @param start - The starting point of the rectangle.
155
- * @param end - The ending point of the rectangle.
156
- * @param rgb - The color (RGB) of the rectangle.
157
- * @param thickness - The thickness of the rectangle's border.
158
- * @returns A new OpenCV instance with the image containing the drawn rectangle.
159
- */
160
- drawRectangle(start: Point, end: Point, rgb: Color, thickness: number): OpenCV;
161
- /**
162
- * Extracts a region of interest (ROI) from the image.
163
- * @param region - The region of interest defined as [x, y, width, height].
164
- * @returns A new OpenCV instance with the extracted region of interest.
165
- */
166
- getRegion(region: ROI): OpenCV;
167
- /**
168
- * Writes the image data to a file.
169
- * @param path - The file path to save the image.
170
- */
171
- imwrite(path: string): void;
172
- }
173
- export { keyDownHandler, keyUpHandler, getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, };
1
+ import EventEmitter = require("events");
2
+ import { KeyCodeHelper } from "./keyCodes";
3
+ /**
4
+ * Represents the data of a window.
5
+ */
6
+ export type WindowData = {
7
+ width: number;
8
+ height: number;
9
+ x: number;
10
+ y: number;
11
+ };
12
+ /**
13
+ * Represents the data of an image.
14
+ */
15
+ export type ImageData = {
16
+ width: number;
17
+ height: number;
18
+ data: Uint8Array;
19
+ };
20
+ /**
21
+ * Represents the result of a template matching operation.
22
+ */
23
+ export type MatchData = {
24
+ minValue: number;
25
+ maxValue: number;
26
+ minLocation: {
27
+ x: number;
28
+ y: number;
29
+ };
30
+ maxLocation: {
31
+ x: number;
32
+ y: number;
33
+ };
34
+ };
35
+ export type GetWindowData = (windowName: string) => WindowData;
36
+ export type CaptureWindow = (windowName: string) => Buffer;
37
+ /**
38
+ * The handler to listen to key-down events.
39
+ * @param callback - The callback function to handle key-down events.
40
+ */
41
+ export type KeyDownHandler = (callback: (keyCode: number) => void) => void;
42
+ /**
43
+ * The handler to listen to key-up events.
44
+ * @param callback - The callback function to handle key-up events.
45
+ */
46
+ export type KeyUpHandler = (callback: (keyCode: number) => void) => void;
47
+ /**
48
+ * Function type for moving the mouse.
49
+ */
50
+ export type MouseMove = (posX: number, posY: number) => boolean;
51
+ /**
52
+ * Function type for simulating a mouse click.
53
+ */
54
+ export type MouseClick = (button?: "left" | "middle" | "right") => boolean;
55
+ /**
56
+ * Function type for simulating typing.
57
+ */
58
+ export type TypeString = (stringToType: string, delay?: number) => boolean;
59
+ /**
60
+ * Function type for simulating key press and release.
61
+ */
62
+ export type PressKey = (keyCode: number) => boolean;
63
+ /**
64
+ * Function type for simulating a mouse drag operation.
65
+ */
66
+ export type MouseDrag = (starX: number, startY: number, endX: Number, endY: number, speed?: number) => boolean;
67
+ /**
68
+ * Represents a point in a two-dimensional space.
69
+ */
70
+ export type Point = [x: number, y: number];
71
+ export type Color = [r: number, g: number, b: number];
72
+ /**
73
+ * Represents a region of interest in an image.
74
+ */
75
+ export type ROI = [x: number, y: number, width: number, height: number];
76
+ export type Imread = (path: string) => ImageData;
77
+ export type Imwrite = (image: ImageData) => Buffer;
78
+ export type MatchTemplate = (image: ImageData, template: ImageData, method?: number | null, mask?: ImageData) => MatchData;
79
+ export type Blur = (image: ImageData, sizeX: number, sizeY: number) => ImageData;
80
+ export type BgrToGray = (image: ImageData) => ImageData;
81
+ export type DrawRectangle = (image: ImageData, start: Point, end: Point, rgb: Color, thickness: number) => ImageData;
82
+ export type GetRegion = (image: ImageData, region: ROI) => ImageData;
83
+ declare const keyDownHandler: KeyDownHandler, keyUpHandler: KeyUpHandler, getWindowData: GetWindowData, captureWindowN: CaptureWindow, mouseMove: MouseMove, mouseClick: MouseClick, mouseDrag: MouseDrag, typeString: TypeString;
84
+ declare const rawPressKey: PressKey;
85
+ /**
86
+ * Captures a window and saves it to a file.
87
+ * @param windowName - The name of the window to capture.
88
+ * @param path - The file path to save the captured image.
89
+ * @returns True if the capture and save operation is successful, otherwise false.
90
+ */
91
+ declare function captureWindow(windowName: string, path: string): boolean;
92
+ export interface KeyListener extends EventEmitter {
93
+ /**
94
+ * Event: Fires when a key is pressed down.
95
+ * @param event - The event name ('keyDown').
96
+ * @param callback - The callback function to handle the event.
97
+ */
98
+ on(event: "keyDown", callback: (data: {
99
+ keyCode: number;
100
+ keyName: string;
101
+ }) => void): this;
102
+ /**
103
+ * Event: Fires when a key is released.
104
+ * @param event - The event name ('keyUp').
105
+ * @param callback - The callback function to handle the event.
106
+ */
107
+ on(event: "keyUp", callback: (data: {
108
+ keyCode: number;
109
+ keyName: string;
110
+ }) => void): this;
111
+ }
112
+ /**
113
+ * Represents a class to listen to keyboard events.
114
+ * @extends EventEmitter
115
+ */
116
+ export declare class KeyListener extends EventEmitter {
117
+ constructor();
118
+ }
119
+ /**
120
+ * Represents the OpenCV class that provides image processing functionality.
121
+ */
122
+ export declare class OpenCV {
123
+ imageData: ImageData;
124
+ /**
125
+ * Represents the OpenCV class that provides image processing functionality.
126
+ */
127
+ constructor(image: string | ImageData);
128
+ /**
129
+ * The width of the image.
130
+ */
131
+ get width(): number;
132
+ /**
133
+ * The height of the image.
134
+ */
135
+ get height(): number;
136
+ /**
137
+ * Matches a template image within the current image.
138
+ * @param template - The template image data to search for.
139
+ * @param method - The template matching method (optional).
140
+ * @param mask - The optional mask image data to apply the operation (optional).
141
+ * @returns The result of the template matching operation.
142
+ */
143
+ matchTemplate(template: ImageData, method?: number | null, mask?: ImageData): MatchData;
144
+ /**
145
+ * Applies a blur filter to the image.
146
+ * @param sizeX - The horizontal size of the blur filter.
147
+ * @param sizeY - The vertical size of the blur filter.
148
+ * @returns A new OpenCV instance with the blurred image data.
149
+ */
150
+ blur(sizeX: number, sizeY: number): OpenCV;
151
+ /**
152
+ * Converts the image from BGR to grayscale.
153
+ * @returns A new OpenCV instance with the grayscale image data.
154
+ */
155
+ bgrToGray(): OpenCV;
156
+ /**
157
+ * Draws a rectangle on the image.
158
+ * @param start - The starting point of the rectangle.
159
+ * @param end - The ending point of the rectangle.
160
+ * @param rgb - The color (RGB) of the rectangle.
161
+ * @param thickness - The thickness of the rectangle's border.
162
+ * @returns A new OpenCV instance with the image containing the drawn rectangle.
163
+ */
164
+ drawRectangle(start: Point, end: Point, rgb: Color, thickness: number): OpenCV;
165
+ /**
166
+ * Extracts a region of interest (ROI) from the image.
167
+ * @param region - The region of interest defined as [x, y, width, height].
168
+ * @returns A new OpenCV instance with the extracted region of interest.
169
+ */
170
+ getRegion(region: ROI): OpenCV;
171
+ /**
172
+ * Writes the image data to a file.
173
+ * @param path - The file path to save the image.
174
+ */
175
+ imwrite(path: string): void;
176
+ }
177
+ declare function keyPress(keyCode: number, repeat?: number): Promise<boolean>;
178
+ export { keyDownHandler, keyUpHandler, getWindowData, captureWindow, captureWindowN, mouseMove, mouseClick, mouseDrag, typeString, keyPress, rawPressKey, KeyCodeHelper };