@mukea/uiohook-napi 1.5.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/binding.gyp +85 -0
  4. package/dist/index.d.ts +194 -0
  5. package/dist/index.js +206 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/prebuild-test-noop.d.ts +0 -0
  8. package/dist/prebuild-test-noop.js +3 -0
  9. package/dist/prebuild-test-noop.js.map +1 -0
  10. package/libuiohook/include/uiohook.h +457 -0
  11. package/libuiohook/src/darwin/input_helper.c +535 -0
  12. package/libuiohook/src/darwin/input_helper.h +203 -0
  13. package/libuiohook/src/darwin/input_hook.c +1436 -0
  14. package/libuiohook/src/darwin/post_event.c +303 -0
  15. package/libuiohook/src/darwin/system_properties.c +479 -0
  16. package/libuiohook/src/logger.c +40 -0
  17. package/libuiohook/src/logger.h +32 -0
  18. package/libuiohook/src/windows/input_helper.c +913 -0
  19. package/libuiohook/src/windows/input_helper.h +146 -0
  20. package/libuiohook/src/windows/input_hook.c +722 -0
  21. package/libuiohook/src/windows/post_event.c +248 -0
  22. package/libuiohook/src/windows/system_properties.c +231 -0
  23. package/libuiohook/src/x11/input_helper.c +1846 -0
  24. package/libuiohook/src/x11/input_helper.h +108 -0
  25. package/libuiohook/src/x11/input_hook.c +1116 -0
  26. package/libuiohook/src/x11/post_event.c +427 -0
  27. package/libuiohook/src/x11/system_properties.c +494 -0
  28. package/package.json +60 -0
  29. package/prebuilds/darwin/darwin-arm64/@mukea+uiohook-napi.node +0 -0
  30. package/prebuilds/darwin/darwin-x64/@mukea+uiohook-napi.node +0 -0
  31. package/prebuilds/linux/linux-arm64/@mukea+uiohook-napi.node +0 -0
  32. package/prebuilds/linux/linux-x64/@mukea+uiohook-napi.node +0 -0
  33. package/prebuilds/windows/win32-x64/@mukea+uiohook-napi.node +0 -0
  34. package/src/lib/addon.c +337 -0
  35. package/src/lib/napi_helpers.c +51 -0
  36. package/src/lib/napi_helpers.h +53 -0
  37. package/src/lib/uiohook_worker.c +200 -0
  38. package/src/lib/uiohook_worker.h +12 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Alexander Drozdov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # uiohook-napi
2
+
3
+ [![](https://img.shields.io/npm/v/uiohook-napi/latest?color=CC3534&label=uiohook-napi&logo=npm&labelColor=212121)](https://www.npmjs.com/package/uiohook-napi)
4
+
5
+ N-API C-bindings for [libuiohook](https://github.com/kwhat/libuiohook).
6
+
7
+
8
+ ### Usage example
9
+
10
+ ```typescript
11
+ import { uIOhook, UiohookKey } from 'uiohook-napi'
12
+
13
+ uIOhook.on('keydown', (e) => {
14
+ if (e.keycode === UiohookKey.Q) {
15
+ console.log('Hello!')
16
+ }
17
+
18
+ if (e.keycode === UiohookKey.Escape) {
19
+ process.exit(0)
20
+ }
21
+ })
22
+
23
+ uIOhook.start()
24
+ ```
25
+
26
+ ### API
27
+
28
+ ```typescript
29
+ interface UiohookNapi {
30
+ on(event: 'input', listener: (e: UiohookKeyboardEvent | UiohookMouseEvent | UiohookWheelEvent) => void): this
31
+
32
+ on(event: 'keydown', listener: (e: UiohookKeyboardEvent) => void): this
33
+ on(event: 'keyup', listener: (e: UiohookKeyboardEvent) => void): this
34
+
35
+ on(event: 'mousedown', listener: (e: UiohookMouseEvent) => void): this
36
+ on(event: 'mouseup', listener: (e: UiohookMouseEvent) => void): this
37
+ on(event: 'mousemove', listener: (e: UiohookMouseEvent) => void): this
38
+ on(event: 'click', listener: (e: UiohookMouseEvent) => void): this
39
+
40
+ on(event: 'wheel', listener: (e: UiohookWheelEvent) => void): this
41
+
42
+ keyTap(key: keycode, modifiers?: keycode[])
43
+ keyToggle(key: keycode, toggle: 'down' | 'up')
44
+ }
45
+
46
+ export interface UiohookKeyboardEvent {
47
+ altKey: boolean
48
+ ctrlKey: boolean
49
+ metaKey: boolean
50
+ shiftKey: boolean
51
+ keycode: number
52
+ }
53
+
54
+ export interface UiohookMouseEvent {
55
+ altKey: boolean
56
+ ctrlKey: boolean
57
+ metaKey: boolean
58
+ shiftKey: boolean
59
+ x: number
60
+ y: number
61
+ button: unknown
62
+ clicks: number
63
+ }
64
+
65
+ export interface UiohookWheelEvent {
66
+ altKey: boolean
67
+ ctrlKey: boolean
68
+ metaKey: boolean
69
+ shiftKey: boolean
70
+ x: number
71
+ y: number
72
+ clicks: number
73
+ amount: number
74
+ direction: WheelDirection
75
+ rotation: number
76
+ }
77
+ ```
package/binding.gyp ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ 'targets': [
3
+ {
4
+ 'target_name': 'uiohook_napi',
5
+ 'dependencies': ['libuiohook'],
6
+ 'sources': [
7
+ 'src/lib/addon.c',
8
+ 'src/lib/napi_helpers.c',
9
+ 'src/lib/uiohook_worker.c',
10
+ ],
11
+ 'include_dirs': [
12
+ 'libuiohook/include',
13
+ 'src/lib',
14
+ ]
15
+ },
16
+ {
17
+ 'target_name': 'libuiohook',
18
+ 'type': 'static_library',
19
+ 'sources': [
20
+ 'libuiohook/src/logger.c',
21
+ ],
22
+ 'include_dirs': [
23
+ 'libuiohook/include',
24
+ 'libuiohook/src',
25
+ ],
26
+ "conditions": [
27
+ ['OS=="win"', {
28
+ 'sources': [
29
+ 'libuiohook/src/windows/input_helper.c',
30
+ 'libuiohook/src/windows/input_hook.c',
31
+ 'libuiohook/src/windows/post_event.c',
32
+ 'libuiohook/src/windows/system_properties.c'
33
+ ],
34
+ 'include_dirs': [
35
+ 'libuiohook/src/windows'
36
+ ]
37
+ }],
38
+ ['OS=="linux"', {
39
+ 'defines': [
40
+ 'USE_XRANDR', 'USE_EVDEV', 'USE_XT'
41
+ ],
42
+ 'link_settings': {
43
+ 'libraries': [
44
+ '-lX11', '-lXrandr', '-lXtst', '-lpthread', '-lXt'
45
+ ],
46
+ },
47
+ 'cflags': ['-std=c99', '-pedantic', '-Wall', '-pthread'],
48
+ 'sources': [
49
+ 'libuiohook/src/x11/input_helper.c',
50
+ 'libuiohook/src/x11/input_hook.c',
51
+ 'libuiohook/src/x11/post_event.c',
52
+ 'libuiohook/src/x11/system_properties.c'
53
+ ],
54
+ 'include_dirs': [
55
+ 'libuiohook/src/x11'
56
+ ]
57
+ }],
58
+ ['OS=="mac"', {
59
+ "defines":[
60
+ "__MACOSX_CORE__","USE_IOKIT","USE_APPLICATION_SERVICES","USE_OBJC"
61
+ ],
62
+ "link_settings": {
63
+ "libraries": [
64
+ "-framework IOKit",
65
+ "-framework Carbon",
66
+ "-framework ApplicationServices",
67
+ "-framework AppKit",
68
+ "-framework CoreFoundation"
69
+ ],
70
+ },
71
+ 'cflags': ['-std=c99', '-pedantic', '-Wall', '-pthread'],
72
+ 'sources': [
73
+ "libuiohook/src/darwin/input_helper.c",
74
+ "libuiohook/src/darwin/input_hook.c",
75
+ "libuiohook/src/darwin/post_event.c",
76
+ "libuiohook/src/darwin/system_properties.c"
77
+ ],
78
+ 'include_dirs': [
79
+ 'libuiohook/src/darwin'
80
+ ]
81
+ }]
82
+ ]
83
+ }
84
+ ]
85
+ }
@@ -0,0 +1,194 @@
1
+ import { EventEmitter } from 'events';
2
+ export declare enum EventType {
3
+ EVENT_KEY_PRESSED = 4,
4
+ EVENT_KEY_RELEASED = 5,
5
+ EVENT_MOUSE_CLICKED = 6,
6
+ EVENT_MOUSE_PRESSED = 7,
7
+ EVENT_MOUSE_RELEASED = 8,
8
+ EVENT_MOUSE_MOVED = 9,
9
+ EVENT_MOUSE_WHEEL = 11
10
+ }
11
+ export interface UiohookKeyboardEvent {
12
+ type: EventType.EVENT_KEY_PRESSED | EventType.EVENT_KEY_RELEASED;
13
+ time: number;
14
+ altKey: boolean;
15
+ ctrlKey: boolean;
16
+ metaKey: boolean;
17
+ shiftKey: boolean;
18
+ keycode: number;
19
+ }
20
+ export interface UiohookMouseEvent {
21
+ type: EventType.EVENT_MOUSE_CLICKED | EventType.EVENT_MOUSE_MOVED | EventType.EVENT_MOUSE_PRESSED | EventType.EVENT_MOUSE_RELEASED;
22
+ time: number;
23
+ altKey: boolean;
24
+ ctrlKey: boolean;
25
+ metaKey: boolean;
26
+ shiftKey: boolean;
27
+ x: number;
28
+ y: number;
29
+ button: unknown;
30
+ clicks: number;
31
+ }
32
+ export interface UiohookWheelEvent {
33
+ type: EventType.EVENT_MOUSE_WHEEL;
34
+ time: number;
35
+ altKey: boolean;
36
+ ctrlKey: boolean;
37
+ metaKey: boolean;
38
+ shiftKey: boolean;
39
+ x: number;
40
+ y: number;
41
+ clicks: number;
42
+ amount: number;
43
+ direction: WheelDirection;
44
+ rotation: number;
45
+ }
46
+ export declare enum WheelDirection {
47
+ VERTICAL = 3,
48
+ HORIZONTAL = 4
49
+ }
50
+ export declare const UiohookKey: {
51
+ readonly Backspace: 14;
52
+ readonly Tab: 15;
53
+ readonly Enter: 28;
54
+ readonly CapsLock: 58;
55
+ readonly Escape: 1;
56
+ readonly Space: 57;
57
+ readonly PageUp: 3657;
58
+ readonly PageDown: 3665;
59
+ readonly End: 3663;
60
+ readonly Home: 3655;
61
+ readonly ArrowLeft: 57419;
62
+ readonly ArrowUp: 57416;
63
+ readonly ArrowRight: 57421;
64
+ readonly ArrowDown: 57424;
65
+ readonly Insert: 3666;
66
+ readonly Delete: 3667;
67
+ readonly 0: 11;
68
+ readonly 1: 2;
69
+ readonly 2: 3;
70
+ readonly 3: 4;
71
+ readonly 4: 5;
72
+ readonly 5: 6;
73
+ readonly 6: 7;
74
+ readonly 7: 8;
75
+ readonly 8: 9;
76
+ readonly 9: 10;
77
+ readonly A: 30;
78
+ readonly B: 48;
79
+ readonly C: 46;
80
+ readonly D: 32;
81
+ readonly E: 18;
82
+ readonly F: 33;
83
+ readonly G: 34;
84
+ readonly H: 35;
85
+ readonly I: 23;
86
+ readonly J: 36;
87
+ readonly K: 37;
88
+ readonly L: 38;
89
+ readonly M: 50;
90
+ readonly N: 49;
91
+ readonly O: 24;
92
+ readonly P: 25;
93
+ readonly Q: 16;
94
+ readonly R: 19;
95
+ readonly S: 31;
96
+ readonly T: 20;
97
+ readonly U: 22;
98
+ readonly V: 47;
99
+ readonly W: 17;
100
+ readonly X: 45;
101
+ readonly Y: 21;
102
+ readonly Z: 44;
103
+ readonly Numpad0: 82;
104
+ readonly Numpad1: 79;
105
+ readonly Numpad2: 80;
106
+ readonly Numpad3: 81;
107
+ readonly Numpad4: 75;
108
+ readonly Numpad5: 76;
109
+ readonly Numpad6: 77;
110
+ readonly Numpad7: 71;
111
+ readonly Numpad8: 72;
112
+ readonly Numpad9: 73;
113
+ readonly NumpadMultiply: 55;
114
+ readonly NumpadAdd: 78;
115
+ readonly NumpadSubtract: 74;
116
+ readonly NumpadDecimal: 83;
117
+ readonly NumpadDivide: 3637;
118
+ readonly NumpadEnter: number;
119
+ readonly NumpadEnd: number;
120
+ readonly NumpadArrowDown: number;
121
+ readonly NumpadPageDown: number;
122
+ readonly NumpadArrowLeft: number;
123
+ readonly NumpadArrowRight: number;
124
+ readonly NumpadHome: number;
125
+ readonly NumpadArrowUp: number;
126
+ readonly NumpadPageUp: number;
127
+ readonly NumpadInsert: number;
128
+ readonly NumpadDelete: number;
129
+ readonly F1: 59;
130
+ readonly F2: 60;
131
+ readonly F3: 61;
132
+ readonly F4: 62;
133
+ readonly F5: 63;
134
+ readonly F6: 64;
135
+ readonly F7: 65;
136
+ readonly F8: 66;
137
+ readonly F9: 67;
138
+ readonly F10: 68;
139
+ readonly F11: 87;
140
+ readonly F12: 88;
141
+ readonly F13: 91;
142
+ readonly F14: 92;
143
+ readonly F15: 93;
144
+ readonly F16: 99;
145
+ readonly F17: 100;
146
+ readonly F18: 101;
147
+ readonly F19: 102;
148
+ readonly F20: 103;
149
+ readonly F21: 104;
150
+ readonly F22: 105;
151
+ readonly F23: 106;
152
+ readonly F24: 107;
153
+ readonly Semicolon: 39;
154
+ readonly Equal: 13;
155
+ readonly Comma: 51;
156
+ readonly Minus: 12;
157
+ readonly Period: 52;
158
+ readonly Slash: 53;
159
+ readonly Backquote: 41;
160
+ readonly BracketLeft: 26;
161
+ readonly Backslash: 43;
162
+ readonly BracketRight: 27;
163
+ readonly Quote: 40;
164
+ readonly Ctrl: 29;
165
+ readonly CtrlRight: 3613;
166
+ readonly Alt: 56;
167
+ readonly AltRight: 3640;
168
+ readonly Shift: 42;
169
+ readonly ShiftRight: 54;
170
+ readonly Meta: 3675;
171
+ readonly MetaRight: 3676;
172
+ readonly NumLock: 69;
173
+ readonly ScrollLock: 70;
174
+ readonly PrintScreen: 3639;
175
+ };
176
+ declare interface UiohookNapi {
177
+ on(event: 'input', listener: (e: UiohookKeyboardEvent | UiohookMouseEvent | UiohookWheelEvent) => void): this;
178
+ on(event: 'keydown', listener: (e: UiohookKeyboardEvent) => void): this;
179
+ on(event: 'keyup', listener: (e: UiohookKeyboardEvent) => void): this;
180
+ on(event: 'mousedown', listener: (e: UiohookMouseEvent) => void): this;
181
+ on(event: 'mouseup', listener: (e: UiohookMouseEvent) => void): this;
182
+ on(event: 'mousemove', listener: (e: UiohookMouseEvent) => void): this;
183
+ on(event: 'click', listener: (e: UiohookMouseEvent) => void): this;
184
+ on(event: 'wheel', listener: (e: UiohookWheelEvent) => void): this;
185
+ }
186
+ declare class UiohookNapi extends EventEmitter {
187
+ private handler;
188
+ start(): void;
189
+ stop(): void;
190
+ keyTap(key: number, modifiers?: number[]): void;
191
+ keyToggle(key: number, toggle: 'down' | 'up'): void;
192
+ }
193
+ export declare const uIOhook: UiohookNapi;
194
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uIOhook = exports.UiohookKey = exports.WheelDirection = exports.EventType = void 0;
4
+ const events_1 = require("events");
5
+ const path_1 = require("path");
6
+ const lib = require('node-gyp-build')((0, path_1.join)(__dirname, '..'));
7
+ var KeyToggle;
8
+ (function (KeyToggle) {
9
+ KeyToggle[KeyToggle["Tap"] = 0] = "Tap";
10
+ KeyToggle[KeyToggle["Down"] = 1] = "Down";
11
+ KeyToggle[KeyToggle["Up"] = 2] = "Up";
12
+ })(KeyToggle || (KeyToggle = {}));
13
+ var EventType;
14
+ (function (EventType) {
15
+ EventType[EventType["EVENT_KEY_PRESSED"] = 4] = "EVENT_KEY_PRESSED";
16
+ EventType[EventType["EVENT_KEY_RELEASED"] = 5] = "EVENT_KEY_RELEASED";
17
+ EventType[EventType["EVENT_MOUSE_CLICKED"] = 6] = "EVENT_MOUSE_CLICKED";
18
+ EventType[EventType["EVENT_MOUSE_PRESSED"] = 7] = "EVENT_MOUSE_PRESSED";
19
+ EventType[EventType["EVENT_MOUSE_RELEASED"] = 8] = "EVENT_MOUSE_RELEASED";
20
+ EventType[EventType["EVENT_MOUSE_MOVED"] = 9] = "EVENT_MOUSE_MOVED";
21
+ EventType[EventType["EVENT_MOUSE_WHEEL"] = 11] = "EVENT_MOUSE_WHEEL";
22
+ })(EventType || (exports.EventType = EventType = {}));
23
+ var WheelDirection;
24
+ (function (WheelDirection) {
25
+ WheelDirection[WheelDirection["VERTICAL"] = 3] = "VERTICAL";
26
+ WheelDirection[WheelDirection["HORIZONTAL"] = 4] = "HORIZONTAL";
27
+ })(WheelDirection || (exports.WheelDirection = WheelDirection = {}));
28
+ exports.UiohookKey = {
29
+ Backspace: 0x000E,
30
+ Tab: 0x000F,
31
+ Enter: 0x001C,
32
+ CapsLock: 0x003A,
33
+ Escape: 0x0001,
34
+ Space: 0x0039,
35
+ PageUp: 0x0E49,
36
+ PageDown: 0x0E51,
37
+ End: 0x0E4F,
38
+ Home: 0x0E47,
39
+ ArrowLeft: 0xE04B,
40
+ ArrowUp: 0xE048,
41
+ ArrowRight: 0xE04D,
42
+ ArrowDown: 0xE050,
43
+ Insert: 0x0E52,
44
+ Delete: 0x0E53,
45
+ 0: 0x000B,
46
+ 1: 0x0002,
47
+ 2: 0x0003,
48
+ 3: 0x0004,
49
+ 4: 0x0005,
50
+ 5: 0x0006,
51
+ 6: 0x0007,
52
+ 7: 0x0008,
53
+ 8: 0x0009,
54
+ 9: 0x000A,
55
+ A: 0x001E,
56
+ B: 0x0030,
57
+ C: 0x002E,
58
+ D: 0x0020,
59
+ E: 0x0012,
60
+ F: 0x0021,
61
+ G: 0x0022,
62
+ H: 0x0023,
63
+ I: 0x0017,
64
+ J: 0x0024,
65
+ K: 0x0025,
66
+ L: 0x0026,
67
+ M: 0x0032,
68
+ N: 0x0031,
69
+ O: 0x0018,
70
+ P: 0x0019,
71
+ Q: 0x0010,
72
+ R: 0x0013,
73
+ S: 0x001F,
74
+ T: 0x0014,
75
+ U: 0x0016,
76
+ V: 0x002F,
77
+ W: 0x0011,
78
+ X: 0x002D,
79
+ Y: 0x0015,
80
+ Z: 0x002C,
81
+ Numpad0: 0x0052,
82
+ Numpad1: 0x004F,
83
+ Numpad2: 0x0050,
84
+ Numpad3: 0x0051,
85
+ Numpad4: 0x004B,
86
+ Numpad5: 0x004C,
87
+ Numpad6: 0x004D,
88
+ Numpad7: 0x0047,
89
+ Numpad8: 0x0048,
90
+ Numpad9: 0x0049,
91
+ NumpadMultiply: 0x0037,
92
+ NumpadAdd: 0x004E,
93
+ NumpadSubtract: 0x004A,
94
+ NumpadDecimal: 0x0053,
95
+ NumpadDivide: 0x0E35,
96
+ NumpadEnter: 0x0E00 | 0x001C,
97
+ NumpadEnd: 0xEE00 | 0x004F,
98
+ NumpadArrowDown: 0xEE00 | 0x0050,
99
+ NumpadPageDown: 0xEE00 | 0x0051,
100
+ NumpadArrowLeft: 0xEE00 | 0x004B,
101
+ NumpadArrowRight: 0xEE00 | 0x004D,
102
+ NumpadHome: 0xEE00 | 0x0047,
103
+ NumpadArrowUp: 0xEE00 | 0x0048,
104
+ NumpadPageUp: 0xEE00 | 0x0049,
105
+ NumpadInsert: 0xEE00 | 0x0052,
106
+ NumpadDelete: 0xEE00 | 0x0053,
107
+ F1: 0x003B,
108
+ F2: 0x003C,
109
+ F3: 0x003D,
110
+ F4: 0x003E,
111
+ F5: 0x003F,
112
+ F6: 0x0040,
113
+ F7: 0x0041,
114
+ F8: 0x0042,
115
+ F9: 0x0043,
116
+ F10: 0x0044,
117
+ F11: 0x0057,
118
+ F12: 0x0058,
119
+ F13: 0x005B,
120
+ F14: 0x005C,
121
+ F15: 0x005D,
122
+ F16: 0x0063,
123
+ F17: 0x0064,
124
+ F18: 0x0065,
125
+ F19: 0x0066,
126
+ F20: 0x0067,
127
+ F21: 0x0068,
128
+ F22: 0x0069,
129
+ F23: 0x006A,
130
+ F24: 0x006B,
131
+ Semicolon: 0x0027,
132
+ Equal: 0x000D,
133
+ Comma: 0x0033,
134
+ Minus: 0x000C,
135
+ Period: 0x0034,
136
+ Slash: 0x0035,
137
+ Backquote: 0x0029,
138
+ BracketLeft: 0x001A,
139
+ Backslash: 0x002B,
140
+ BracketRight: 0x001B,
141
+ Quote: 0x0028,
142
+ Ctrl: 0x001D, // Left
143
+ CtrlRight: 0x0E1D,
144
+ Alt: 0x0038, // Left
145
+ AltRight: 0x0E38,
146
+ Shift: 0x002A, // Left
147
+ ShiftRight: 0x0036,
148
+ Meta: 0x0E5B,
149
+ MetaRight: 0x0E5C,
150
+ NumLock: 0x0045,
151
+ ScrollLock: 0x0046,
152
+ PrintScreen: 0x0E37,
153
+ };
154
+ class UiohookNapi extends events_1.EventEmitter {
155
+ handler(e) {
156
+ this.emit('input', e);
157
+ switch (e.type) {
158
+ case EventType.EVENT_KEY_PRESSED:
159
+ this.emit('keydown', e);
160
+ break;
161
+ case EventType.EVENT_KEY_RELEASED:
162
+ this.emit('keyup', e);
163
+ break;
164
+ case EventType.EVENT_MOUSE_CLICKED:
165
+ this.emit('click', e);
166
+ break;
167
+ case EventType.EVENT_MOUSE_MOVED:
168
+ this.emit('mousemove', e);
169
+ break;
170
+ case EventType.EVENT_MOUSE_PRESSED:
171
+ this.emit('mousedown', e);
172
+ break;
173
+ case EventType.EVENT_MOUSE_RELEASED:
174
+ this.emit('mouseup', e);
175
+ break;
176
+ case EventType.EVENT_MOUSE_WHEEL:
177
+ this.emit('wheel', e);
178
+ break;
179
+ }
180
+ }
181
+ start() {
182
+ lib.start(this.handler.bind(this));
183
+ }
184
+ stop() {
185
+ lib.stop();
186
+ }
187
+ keyTap(key, modifiers = []) {
188
+ if (!modifiers.length) {
189
+ lib.keyTap(key, KeyToggle.Tap);
190
+ return;
191
+ }
192
+ for (const modKey of modifiers) {
193
+ lib.keyTap(modKey, KeyToggle.Down);
194
+ }
195
+ lib.keyTap(key, KeyToggle.Tap);
196
+ let i = modifiers.length;
197
+ while (i--) {
198
+ lib.keyTap(modifiers[i], KeyToggle.Up);
199
+ }
200
+ }
201
+ keyToggle(key, toggle) {
202
+ lib.keyTap(key, (toggle === 'down' ? KeyToggle.Down : KeyToggle.Up));
203
+ }
204
+ }
205
+ exports.uIOhook = new UiohookNapi();
206
+ //# source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AAE,GAAW,EAAE,YAAsB,EAAE;QAC3C,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YACtB,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;YAC9B,OAAM;QACR,CAAC;QAED,KAAK,MAAM,MAAM,IAAI,SAAS,EAAE,CAAC;YAC/B,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QACpC,CAAC;QACD,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;QAC9B,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAA;QACxB,OAAO,CAAC,EAAE,EAAE,CAAC;YACX,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;IAED,SAAS,CAAE,GAAW,EAAE,MAAqB;QAC3C,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;IACtE,CAAC;CACF;AAEY,QAAA,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA"}
File without changes
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // see https://github.com/prebuild/node-gyp-build/issues/29
3
+ //# sourceMappingURL=prebuild-test-noop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prebuild-test-noop.js","sourceRoot":"","sources":["../src/prebuild-test-noop.ts"],"names":[],"mappings":";AAAA,2DAA2D"}