rdev-node 1.0.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/LICENSE +21 -0
- package/README.md +77 -0
- package/index.d.ts +198 -0
- package/index.js +743 -0
- package/node-rdev.darwin-arm64.node +0 -0
- package/node-rdev.darwin-x64.node +0 -0
- package/node-rdev.linux-arm-gnueabihf.node +0 -0
- package/node-rdev.linux-arm64-gnu.node +0 -0
- package/node-rdev.linux-x64-gnu.node +0 -0
- package/node-rdev.linux-x64-musl.node +0 -0
- package/node-rdev.win32-arm64-msvc.node +0 -0
- package/node-rdev.win32-ia32-msvc.node +0 -0
- package/node-rdev.win32-x64-msvc.node +0 -0
- package/package.json +92 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 N-API for Rust
|
|
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
|
+
# rdev-node
|
|
2
|
+
|
|
3
|
+
A high-performance Node.js native addon for listening to system-wide keyboard and mouse events. Built with Rust.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install rdev-node
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
const { startListener } = require('rdev-node');
|
|
15
|
+
|
|
16
|
+
startListener((event) => {
|
|
17
|
+
console.log(event);
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
|
|
23
|
+
- Node.js >= 10
|
|
24
|
+
- **Rust** (required to build from source) - Install from [rustup.rs](https://rustup.rs/)
|
|
25
|
+
- Linux: `libgtk-3-dev libxtst-dev`
|
|
26
|
+
|
|
27
|
+
## Build
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install
|
|
31
|
+
npm run build
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## API
|
|
35
|
+
|
|
36
|
+
### startListener(callback)
|
|
37
|
+
|
|
38
|
+
Listen to keyboard and mouse events.
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
startListener((event) => {
|
|
42
|
+
console.log('Type:', event.eventType);
|
|
43
|
+
if (event.keyPress) console.log('Key:', event.keyPress.key);
|
|
44
|
+
if (event.mouseMove) console.log('Position:', event.mouseMove.x, event.mouseMove.y);
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### simulateEvent(event)
|
|
49
|
+
|
|
50
|
+
Simulate keyboard/mouse events.
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
simulateEvent({
|
|
54
|
+
eventType: 'KeyPress',
|
|
55
|
+
keyPress: { key: 'KeyA' },
|
|
56
|
+
time: Date.now()
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### getDisplaySize()
|
|
61
|
+
|
|
62
|
+
Get main display dimensions.
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
const { width, height } = getDisplaySize();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Supported Platforms
|
|
69
|
+
|
|
70
|
+
- macOS (x64, arm64)
|
|
71
|
+
- Windows (x64, ia32, arm64)
|
|
72
|
+
- Linux (x64, arm64, armv7)
|
|
73
|
+
- Android (arm64, armv7)
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/** Represents a button press event */
|
|
4
|
+
export interface ButtonPressEvent {
|
|
5
|
+
button: ButtonType
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/** Represents a button release event */
|
|
9
|
+
export interface ButtonReleaseEvent {
|
|
10
|
+
button: ButtonType
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Represents the type of button event */
|
|
14
|
+
export declare const enum ButtonType {
|
|
15
|
+
Left = 'Left',
|
|
16
|
+
Right = 'Right',
|
|
17
|
+
Middle = 'Middle',
|
|
18
|
+
Unknown = 'Unknown',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Display size information */
|
|
22
|
+
export interface DisplaySize {
|
|
23
|
+
width: number
|
|
24
|
+
height: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Represents the type of event */
|
|
28
|
+
export declare const enum EventTypeValue {
|
|
29
|
+
KeyPress = 'KeyPress',
|
|
30
|
+
KeyRelease = 'KeyRelease',
|
|
31
|
+
MouseMove = 'MouseMove',
|
|
32
|
+
ButtonPress = 'ButtonPress',
|
|
33
|
+
ButtonRelease = 'ButtonRelease',
|
|
34
|
+
Wheel = 'Wheel',
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Get the size of the main display */
|
|
38
|
+
export declare function getDisplaySize(): DisplaySize
|
|
39
|
+
|
|
40
|
+
/** Represents an input event */
|
|
41
|
+
export interface InputEvent {
|
|
42
|
+
/** The type of event */
|
|
43
|
+
eventType: EventTypeValue
|
|
44
|
+
/** Key press data (only present for KeyPress events) */
|
|
45
|
+
keyPress?: KeyPressEvent
|
|
46
|
+
/** Key release data (only present for KeyRelease events) */
|
|
47
|
+
keyRelease?: KeyReleaseEvent
|
|
48
|
+
/** Mouse move data (only present for MouseMove events) */
|
|
49
|
+
mouseMove?: MouseMoveEvent
|
|
50
|
+
/** Button press data (only present for ButtonPress events) */
|
|
51
|
+
buttonPress?: ButtonPressEvent
|
|
52
|
+
/** Button release data (only present for ButtonRelease events) */
|
|
53
|
+
buttonRelease?: ButtonReleaseEvent
|
|
54
|
+
/** Wheel data (only present for Wheel events) */
|
|
55
|
+
wheel?: WheelEvent
|
|
56
|
+
/** Optional name of window (platform-dependent) */
|
|
57
|
+
name?: string
|
|
58
|
+
/** Timestamp of the event */
|
|
59
|
+
time: number
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Represents keyboard keys */
|
|
63
|
+
export declare const enum KeyCode {
|
|
64
|
+
Alt = 'Alt',
|
|
65
|
+
AltGr = 'AltGr',
|
|
66
|
+
Backspace = 'Backspace',
|
|
67
|
+
CapsLock = 'CapsLock',
|
|
68
|
+
ControlLeft = 'ControlLeft',
|
|
69
|
+
ControlRight = 'ControlRight',
|
|
70
|
+
Delete = 'Delete',
|
|
71
|
+
DownArrow = 'DownArrow',
|
|
72
|
+
End = 'End',
|
|
73
|
+
Escape = 'Escape',
|
|
74
|
+
F1 = 'F1',
|
|
75
|
+
F2 = 'F2',
|
|
76
|
+
F3 = 'F3',
|
|
77
|
+
F4 = 'F4',
|
|
78
|
+
F5 = 'F5',
|
|
79
|
+
F6 = 'F6',
|
|
80
|
+
F7 = 'F7',
|
|
81
|
+
F8 = 'F8',
|
|
82
|
+
F9 = 'F9',
|
|
83
|
+
F10 = 'F10',
|
|
84
|
+
F11 = 'F11',
|
|
85
|
+
F12 = 'F12',
|
|
86
|
+
Home = 'Home',
|
|
87
|
+
LeftArrow = 'LeftArrow',
|
|
88
|
+
MetaLeft = 'MetaLeft',
|
|
89
|
+
MetaRight = 'MetaRight',
|
|
90
|
+
NumLock = 'NumLock',
|
|
91
|
+
PageDown = 'PageDown',
|
|
92
|
+
PageUp = 'PageUp',
|
|
93
|
+
Return = 'Return',
|
|
94
|
+
RightArrow = 'RightArrow',
|
|
95
|
+
ShiftLeft = 'ShiftLeft',
|
|
96
|
+
ShiftRight = 'ShiftRight',
|
|
97
|
+
Space = 'Space',
|
|
98
|
+
Tab = 'Tab',
|
|
99
|
+
UpArrow = 'UpArrow',
|
|
100
|
+
PrintScreen = 'PrintScreen',
|
|
101
|
+
ScrollLock = 'ScrollLock',
|
|
102
|
+
Pause = 'Pause',
|
|
103
|
+
Insert = 'Insert',
|
|
104
|
+
BackQuote = 'BackQuote',
|
|
105
|
+
Num1 = 'Num1',
|
|
106
|
+
Num2 = 'Num2',
|
|
107
|
+
Num3 = 'Num3',
|
|
108
|
+
Num4 = 'Num4',
|
|
109
|
+
Num5 = 'Num5',
|
|
110
|
+
Num6 = 'Num6',
|
|
111
|
+
Num7 = 'Num7',
|
|
112
|
+
Num8 = 'Num8',
|
|
113
|
+
Num9 = 'Num9',
|
|
114
|
+
Num0 = 'Num0',
|
|
115
|
+
Minus = 'Minus',
|
|
116
|
+
Equal = 'Equal',
|
|
117
|
+
KeyQ = 'KeyQ',
|
|
118
|
+
KeyW = 'KeyW',
|
|
119
|
+
KeyE = 'KeyE',
|
|
120
|
+
KeyR = 'KeyR',
|
|
121
|
+
KeyT = 'KeyT',
|
|
122
|
+
KeyY = 'KeyY',
|
|
123
|
+
KeyU = 'KeyU',
|
|
124
|
+
KeyI = 'KeyI',
|
|
125
|
+
KeyO = 'KeyO',
|
|
126
|
+
KeyP = 'KeyP',
|
|
127
|
+
LeftBracket = 'LeftBracket',
|
|
128
|
+
RightBracket = 'RightBracket',
|
|
129
|
+
KeyA = 'KeyA',
|
|
130
|
+
KeyS = 'KeyS',
|
|
131
|
+
KeyD = 'KeyD',
|
|
132
|
+
KeyF = 'KeyF',
|
|
133
|
+
KeyG = 'KeyG',
|
|
134
|
+
KeyH = 'KeyH',
|
|
135
|
+
KeyJ = 'KeyJ',
|
|
136
|
+
KeyK = 'KeyK',
|
|
137
|
+
KeyL = 'KeyL',
|
|
138
|
+
SemiColon = 'SemiColon',
|
|
139
|
+
Quote = 'Quote',
|
|
140
|
+
BackSlash = 'BackSlash',
|
|
141
|
+
IntlBackslash = 'IntlBackslash',
|
|
142
|
+
KeyZ = 'KeyZ',
|
|
143
|
+
KeyX = 'KeyX',
|
|
144
|
+
KeyC = 'KeyC',
|
|
145
|
+
KeyV = 'KeyV',
|
|
146
|
+
KeyB = 'KeyB',
|
|
147
|
+
KeyN = 'KeyN',
|
|
148
|
+
KeyM = 'KeyM',
|
|
149
|
+
Comma = 'Comma',
|
|
150
|
+
Dot = 'Dot',
|
|
151
|
+
Slash = 'Slash',
|
|
152
|
+
KpReturn = 'KpReturn',
|
|
153
|
+
KpMinus = 'KpMinus',
|
|
154
|
+
KpPlus = 'KpPlus',
|
|
155
|
+
KpMultiply = 'KpMultiply',
|
|
156
|
+
KpDivide = 'KpDivide',
|
|
157
|
+
Kp0 = 'Kp0',
|
|
158
|
+
Kp1 = 'Kp1',
|
|
159
|
+
Kp2 = 'Kp2',
|
|
160
|
+
Kp3 = 'Kp3',
|
|
161
|
+
Kp4 = 'Kp4',
|
|
162
|
+
Kp5 = 'Kp5',
|
|
163
|
+
Kp6 = 'Kp6',
|
|
164
|
+
Kp7 = 'Kp7',
|
|
165
|
+
Kp8 = 'Kp8',
|
|
166
|
+
Kp9 = 'Kp9',
|
|
167
|
+
KpDelete = 'KpDelete',
|
|
168
|
+
Function = 'Function',
|
|
169
|
+
Unknown = 'Unknown',
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** Represents a key press event */
|
|
173
|
+
export interface KeyPressEvent {
|
|
174
|
+
key: KeyCode
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Represents a key release event */
|
|
178
|
+
export interface KeyReleaseEvent {
|
|
179
|
+
key: KeyCode
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Represents a mouse move event */
|
|
183
|
+
export interface MouseMoveEvent {
|
|
184
|
+
x: number
|
|
185
|
+
y: number
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Simulate an input event */
|
|
189
|
+
export declare function simulateEvent(event: InputEvent): void
|
|
190
|
+
|
|
191
|
+
/** Start listening for input events */
|
|
192
|
+
export declare function startListener(callback: (arg: InputEvent) => InputEvent): void
|
|
193
|
+
|
|
194
|
+
/** Represents a wheel event */
|
|
195
|
+
export interface WheelEvent {
|
|
196
|
+
deltaX: number
|
|
197
|
+
deltaY: number
|
|
198
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
// prettier-ignore
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const { readFileSync } = require('node:fs')
|
|
7
|
+
let nativeBinding = null
|
|
8
|
+
const loadErrors = []
|
|
9
|
+
|
|
10
|
+
const isMusl = () => {
|
|
11
|
+
let musl = false
|
|
12
|
+
if (process.platform === 'linux') {
|
|
13
|
+
musl = isMuslFromFilesystem()
|
|
14
|
+
if (musl === null) {
|
|
15
|
+
musl = isMuslFromReport()
|
|
16
|
+
}
|
|
17
|
+
if (musl === null) {
|
|
18
|
+
musl = isMuslFromChildProcess()
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return musl
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
|
25
|
+
|
|
26
|
+
const isMuslFromFilesystem = () => {
|
|
27
|
+
try {
|
|
28
|
+
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
|
29
|
+
} catch {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const isMuslFromReport = () => {
|
|
35
|
+
let report = null
|
|
36
|
+
if (typeof process.report?.getReport === 'function') {
|
|
37
|
+
process.report.excludeNetwork = true
|
|
38
|
+
report = process.report.getReport()
|
|
39
|
+
}
|
|
40
|
+
if (!report) {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
if (report.header && report.header.glibcVersionRuntime) {
|
|
44
|
+
return false
|
|
45
|
+
}
|
|
46
|
+
if (Array.isArray(report.sharedObjects)) {
|
|
47
|
+
if (report.sharedObjects.some(isFileMusl)) {
|
|
48
|
+
return true
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const isMuslFromChildProcess = () => {
|
|
55
|
+
try {
|
|
56
|
+
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
|
57
|
+
} catch (e) {
|
|
58
|
+
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function requireNative() {
|
|
64
|
+
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
|
65
|
+
try {
|
|
66
|
+
return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH)
|
|
67
|
+
} catch (err) {
|
|
68
|
+
loadErrors.push(err)
|
|
69
|
+
}
|
|
70
|
+
} else if (process.platform === 'android') {
|
|
71
|
+
if (process.arch === 'arm64') {
|
|
72
|
+
try {
|
|
73
|
+
return require('./node-rdev.android-arm64.node')
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadErrors.push(e)
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const binding = require('node-rdev-android-arm64')
|
|
79
|
+
const bindingPackageVersion = require('node-rdev-android-arm64/package.json').version
|
|
80
|
+
if (
|
|
81
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
82
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
83
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
84
|
+
) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
return binding
|
|
90
|
+
} catch (e) {
|
|
91
|
+
loadErrors.push(e)
|
|
92
|
+
}
|
|
93
|
+
} else if (process.arch === 'arm') {
|
|
94
|
+
try {
|
|
95
|
+
return require('./node-rdev.android-arm-eabi.node')
|
|
96
|
+
} catch (e) {
|
|
97
|
+
loadErrors.push(e)
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const binding = require('node-rdev-android-arm-eabi')
|
|
101
|
+
const bindingPackageVersion = require('node-rdev-android-arm-eabi/package.json').version
|
|
102
|
+
if (
|
|
103
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
104
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
105
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
106
|
+
) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
return binding
|
|
112
|
+
} catch (e) {
|
|
113
|
+
loadErrors.push(e)
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
|
117
|
+
}
|
|
118
|
+
} else if (process.platform === 'win32') {
|
|
119
|
+
if (process.arch === 'x64') {
|
|
120
|
+
if (
|
|
121
|
+
process.config?.variables?.shlib_suffix === 'dll.a' ||
|
|
122
|
+
process.config?.variables?.node_target_type === 'shared_library'
|
|
123
|
+
) {
|
|
124
|
+
try {
|
|
125
|
+
return require('./node-rdev.win32-x64-gnu.node')
|
|
126
|
+
} catch (e) {
|
|
127
|
+
loadErrors.push(e)
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
const binding = require('node-rdev-win32-x64-gnu')
|
|
131
|
+
const bindingPackageVersion = require('node-rdev-win32-x64-gnu/package.json').version
|
|
132
|
+
if (
|
|
133
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
134
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
135
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
136
|
+
) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
return binding
|
|
142
|
+
} catch (e) {
|
|
143
|
+
loadErrors.push(e)
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
try {
|
|
147
|
+
return require('./node-rdev.win32-x64-msvc.node')
|
|
148
|
+
} catch (e) {
|
|
149
|
+
loadErrors.push(e)
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
const binding = require('node-rdev-win32-x64-msvc')
|
|
153
|
+
const bindingPackageVersion = require('node-rdev-win32-x64-msvc/package.json').version
|
|
154
|
+
if (
|
|
155
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
156
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
157
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
158
|
+
) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
return binding
|
|
164
|
+
} catch (e) {
|
|
165
|
+
loadErrors.push(e)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
} else if (process.arch === 'ia32') {
|
|
169
|
+
try {
|
|
170
|
+
return require('./node-rdev.win32-ia32-msvc.node')
|
|
171
|
+
} catch (e) {
|
|
172
|
+
loadErrors.push(e)
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
const binding = require('node-rdev-win32-ia32-msvc')
|
|
176
|
+
const bindingPackageVersion = require('node-rdev-win32-ia32-msvc/package.json').version
|
|
177
|
+
if (
|
|
178
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
179
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
180
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
181
|
+
) {
|
|
182
|
+
throw new Error(
|
|
183
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
return binding
|
|
187
|
+
} catch (e) {
|
|
188
|
+
loadErrors.push(e)
|
|
189
|
+
}
|
|
190
|
+
} else if (process.arch === 'arm64') {
|
|
191
|
+
try {
|
|
192
|
+
return require('./node-rdev.win32-arm64-msvc.node')
|
|
193
|
+
} catch (e) {
|
|
194
|
+
loadErrors.push(e)
|
|
195
|
+
}
|
|
196
|
+
try {
|
|
197
|
+
const binding = require('node-rdev-win32-arm64-msvc')
|
|
198
|
+
const bindingPackageVersion = require('node-rdev-win32-arm64-msvc/package.json').version
|
|
199
|
+
if (
|
|
200
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
201
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
202
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
203
|
+
) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
return binding
|
|
209
|
+
} catch (e) {
|
|
210
|
+
loadErrors.push(e)
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
|
214
|
+
}
|
|
215
|
+
} else if (process.platform === 'darwin') {
|
|
216
|
+
try {
|
|
217
|
+
return require('./node-rdev.darwin-universal.node')
|
|
218
|
+
} catch (e) {
|
|
219
|
+
loadErrors.push(e)
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const binding = require('node-rdev-darwin-universal')
|
|
223
|
+
const bindingPackageVersion = require('node-rdev-darwin-universal/package.json').version
|
|
224
|
+
if (
|
|
225
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
226
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
227
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
228
|
+
) {
|
|
229
|
+
throw new Error(
|
|
230
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
return binding
|
|
234
|
+
} catch (e) {
|
|
235
|
+
loadErrors.push(e)
|
|
236
|
+
}
|
|
237
|
+
if (process.arch === 'x64') {
|
|
238
|
+
try {
|
|
239
|
+
return require('./node-rdev.darwin-x64.node')
|
|
240
|
+
} catch (e) {
|
|
241
|
+
loadErrors.push(e)
|
|
242
|
+
}
|
|
243
|
+
try {
|
|
244
|
+
const binding = require('node-rdev-darwin-x64')
|
|
245
|
+
const bindingPackageVersion = require('node-rdev-darwin-x64/package.json').version
|
|
246
|
+
if (
|
|
247
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
248
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
249
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
250
|
+
) {
|
|
251
|
+
throw new Error(
|
|
252
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
return binding
|
|
256
|
+
} catch (e) {
|
|
257
|
+
loadErrors.push(e)
|
|
258
|
+
}
|
|
259
|
+
} else if (process.arch === 'arm64') {
|
|
260
|
+
try {
|
|
261
|
+
return require('./node-rdev.darwin-arm64.node')
|
|
262
|
+
} catch (e) {
|
|
263
|
+
loadErrors.push(e)
|
|
264
|
+
}
|
|
265
|
+
try {
|
|
266
|
+
const binding = require('node-rdev-darwin-arm64')
|
|
267
|
+
const bindingPackageVersion = require('node-rdev-darwin-arm64/package.json').version
|
|
268
|
+
if (
|
|
269
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
270
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
271
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
272
|
+
) {
|
|
273
|
+
throw new Error(
|
|
274
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
return binding
|
|
278
|
+
} catch (e) {
|
|
279
|
+
loadErrors.push(e)
|
|
280
|
+
}
|
|
281
|
+
} else {
|
|
282
|
+
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
|
283
|
+
}
|
|
284
|
+
} else if (process.platform === 'freebsd') {
|
|
285
|
+
if (process.arch === 'x64') {
|
|
286
|
+
try {
|
|
287
|
+
return require('./node-rdev.freebsd-x64.node')
|
|
288
|
+
} catch (e) {
|
|
289
|
+
loadErrors.push(e)
|
|
290
|
+
}
|
|
291
|
+
try {
|
|
292
|
+
const binding = require('node-rdev-freebsd-x64')
|
|
293
|
+
const bindingPackageVersion = require('node-rdev-freebsd-x64/package.json').version
|
|
294
|
+
if (
|
|
295
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
296
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
297
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
298
|
+
) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
return binding
|
|
304
|
+
} catch (e) {
|
|
305
|
+
loadErrors.push(e)
|
|
306
|
+
}
|
|
307
|
+
} else if (process.arch === 'arm64') {
|
|
308
|
+
try {
|
|
309
|
+
return require('./node-rdev.freebsd-arm64.node')
|
|
310
|
+
} catch (e) {
|
|
311
|
+
loadErrors.push(e)
|
|
312
|
+
}
|
|
313
|
+
try {
|
|
314
|
+
const binding = require('node-rdev-freebsd-arm64')
|
|
315
|
+
const bindingPackageVersion = require('node-rdev-freebsd-arm64/package.json').version
|
|
316
|
+
if (
|
|
317
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
318
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
319
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
320
|
+
) {
|
|
321
|
+
throw new Error(
|
|
322
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
323
|
+
)
|
|
324
|
+
}
|
|
325
|
+
return binding
|
|
326
|
+
} catch (e) {
|
|
327
|
+
loadErrors.push(e)
|
|
328
|
+
}
|
|
329
|
+
} else {
|
|
330
|
+
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
|
331
|
+
}
|
|
332
|
+
} else if (process.platform === 'linux') {
|
|
333
|
+
if (process.arch === 'x64') {
|
|
334
|
+
if (isMusl()) {
|
|
335
|
+
try {
|
|
336
|
+
return require('./node-rdev.linux-x64-musl.node')
|
|
337
|
+
} catch (e) {
|
|
338
|
+
loadErrors.push(e)
|
|
339
|
+
}
|
|
340
|
+
try {
|
|
341
|
+
const binding = require('node-rdev-linux-x64-musl')
|
|
342
|
+
const bindingPackageVersion = require('node-rdev-linux-x64-musl/package.json').version
|
|
343
|
+
if (
|
|
344
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
345
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
346
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
347
|
+
) {
|
|
348
|
+
throw new Error(
|
|
349
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
350
|
+
)
|
|
351
|
+
}
|
|
352
|
+
return binding
|
|
353
|
+
} catch (e) {
|
|
354
|
+
loadErrors.push(e)
|
|
355
|
+
}
|
|
356
|
+
} else {
|
|
357
|
+
try {
|
|
358
|
+
return require('./node-rdev.linux-x64-gnu.node')
|
|
359
|
+
} catch (e) {
|
|
360
|
+
loadErrors.push(e)
|
|
361
|
+
}
|
|
362
|
+
try {
|
|
363
|
+
const binding = require('node-rdev-linux-x64-gnu')
|
|
364
|
+
const bindingPackageVersion = require('node-rdev-linux-x64-gnu/package.json').version
|
|
365
|
+
if (
|
|
366
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
367
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
368
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
369
|
+
) {
|
|
370
|
+
throw new Error(
|
|
371
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
return binding
|
|
375
|
+
} catch (e) {
|
|
376
|
+
loadErrors.push(e)
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
} else if (process.arch === 'arm64') {
|
|
380
|
+
if (isMusl()) {
|
|
381
|
+
try {
|
|
382
|
+
return require('./node-rdev.linux-arm64-musl.node')
|
|
383
|
+
} catch (e) {
|
|
384
|
+
loadErrors.push(e)
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
const binding = require('node-rdev-linux-arm64-musl')
|
|
388
|
+
const bindingPackageVersion = require('node-rdev-linux-arm64-musl/package.json').version
|
|
389
|
+
if (
|
|
390
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
391
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
392
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
393
|
+
) {
|
|
394
|
+
throw new Error(
|
|
395
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
return binding
|
|
399
|
+
} catch (e) {
|
|
400
|
+
loadErrors.push(e)
|
|
401
|
+
}
|
|
402
|
+
} else {
|
|
403
|
+
try {
|
|
404
|
+
return require('./node-rdev.linux-arm64-gnu.node')
|
|
405
|
+
} catch (e) {
|
|
406
|
+
loadErrors.push(e)
|
|
407
|
+
}
|
|
408
|
+
try {
|
|
409
|
+
const binding = require('node-rdev-linux-arm64-gnu')
|
|
410
|
+
const bindingPackageVersion = require('node-rdev-linux-arm64-gnu/package.json').version
|
|
411
|
+
if (
|
|
412
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
413
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
414
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
415
|
+
) {
|
|
416
|
+
throw new Error(
|
|
417
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
418
|
+
)
|
|
419
|
+
}
|
|
420
|
+
return binding
|
|
421
|
+
} catch (e) {
|
|
422
|
+
loadErrors.push(e)
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
} else if (process.arch === 'arm') {
|
|
426
|
+
if (isMusl()) {
|
|
427
|
+
try {
|
|
428
|
+
return require('./node-rdev.linux-arm-musleabihf.node')
|
|
429
|
+
} catch (e) {
|
|
430
|
+
loadErrors.push(e)
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
const binding = require('node-rdev-linux-arm-musleabihf')
|
|
434
|
+
const bindingPackageVersion = require('node-rdev-linux-arm-musleabihf/package.json').version
|
|
435
|
+
if (
|
|
436
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
437
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
438
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
439
|
+
) {
|
|
440
|
+
throw new Error(
|
|
441
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
442
|
+
)
|
|
443
|
+
}
|
|
444
|
+
return binding
|
|
445
|
+
} catch (e) {
|
|
446
|
+
loadErrors.push(e)
|
|
447
|
+
}
|
|
448
|
+
} else {
|
|
449
|
+
try {
|
|
450
|
+
return require('./node-rdev.linux-arm-gnueabihf.node')
|
|
451
|
+
} catch (e) {
|
|
452
|
+
loadErrors.push(e)
|
|
453
|
+
}
|
|
454
|
+
try {
|
|
455
|
+
const binding = require('node-rdev-linux-arm-gnueabihf')
|
|
456
|
+
const bindingPackageVersion = require('node-rdev-linux-arm-gnueabihf/package.json').version
|
|
457
|
+
if (
|
|
458
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
459
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
460
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
461
|
+
) {
|
|
462
|
+
throw new Error(
|
|
463
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
464
|
+
)
|
|
465
|
+
}
|
|
466
|
+
return binding
|
|
467
|
+
} catch (e) {
|
|
468
|
+
loadErrors.push(e)
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
} else if (process.arch === 'loong64') {
|
|
472
|
+
if (isMusl()) {
|
|
473
|
+
try {
|
|
474
|
+
return require('./node-rdev.linux-loong64-musl.node')
|
|
475
|
+
} catch (e) {
|
|
476
|
+
loadErrors.push(e)
|
|
477
|
+
}
|
|
478
|
+
try {
|
|
479
|
+
const binding = require('node-rdev-linux-loong64-musl')
|
|
480
|
+
const bindingPackageVersion = require('node-rdev-linux-loong64-musl/package.json').version
|
|
481
|
+
if (
|
|
482
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
483
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
484
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
485
|
+
) {
|
|
486
|
+
throw new Error(
|
|
487
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
488
|
+
)
|
|
489
|
+
}
|
|
490
|
+
return binding
|
|
491
|
+
} catch (e) {
|
|
492
|
+
loadErrors.push(e)
|
|
493
|
+
}
|
|
494
|
+
} else {
|
|
495
|
+
try {
|
|
496
|
+
return require('./node-rdev.linux-loong64-gnu.node')
|
|
497
|
+
} catch (e) {
|
|
498
|
+
loadErrors.push(e)
|
|
499
|
+
}
|
|
500
|
+
try {
|
|
501
|
+
const binding = require('node-rdev-linux-loong64-gnu')
|
|
502
|
+
const bindingPackageVersion = require('node-rdev-linux-loong64-gnu/package.json').version
|
|
503
|
+
if (
|
|
504
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
505
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
506
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
507
|
+
) {
|
|
508
|
+
throw new Error(
|
|
509
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
510
|
+
)
|
|
511
|
+
}
|
|
512
|
+
return binding
|
|
513
|
+
} catch (e) {
|
|
514
|
+
loadErrors.push(e)
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
} else if (process.arch === 'riscv64') {
|
|
518
|
+
if (isMusl()) {
|
|
519
|
+
try {
|
|
520
|
+
return require('./node-rdev.linux-riscv64-musl.node')
|
|
521
|
+
} catch (e) {
|
|
522
|
+
loadErrors.push(e)
|
|
523
|
+
}
|
|
524
|
+
try {
|
|
525
|
+
const binding = require('node-rdev-linux-riscv64-musl')
|
|
526
|
+
const bindingPackageVersion = require('node-rdev-linux-riscv64-musl/package.json').version
|
|
527
|
+
if (
|
|
528
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
529
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
530
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
531
|
+
) {
|
|
532
|
+
throw new Error(
|
|
533
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
534
|
+
)
|
|
535
|
+
}
|
|
536
|
+
return binding
|
|
537
|
+
} catch (e) {
|
|
538
|
+
loadErrors.push(e)
|
|
539
|
+
}
|
|
540
|
+
} else {
|
|
541
|
+
try {
|
|
542
|
+
return require('./node-rdev.linux-riscv64-gnu.node')
|
|
543
|
+
} catch (e) {
|
|
544
|
+
loadErrors.push(e)
|
|
545
|
+
}
|
|
546
|
+
try {
|
|
547
|
+
const binding = require('node-rdev-linux-riscv64-gnu')
|
|
548
|
+
const bindingPackageVersion = require('node-rdev-linux-riscv64-gnu/package.json').version
|
|
549
|
+
if (
|
|
550
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
551
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
552
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
553
|
+
) {
|
|
554
|
+
throw new Error(
|
|
555
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
556
|
+
)
|
|
557
|
+
}
|
|
558
|
+
return binding
|
|
559
|
+
} catch (e) {
|
|
560
|
+
loadErrors.push(e)
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
} else if (process.arch === 'ppc64') {
|
|
564
|
+
try {
|
|
565
|
+
return require('./node-rdev.linux-ppc64-gnu.node')
|
|
566
|
+
} catch (e) {
|
|
567
|
+
loadErrors.push(e)
|
|
568
|
+
}
|
|
569
|
+
try {
|
|
570
|
+
const binding = require('node-rdev-linux-ppc64-gnu')
|
|
571
|
+
const bindingPackageVersion = require('node-rdev-linux-ppc64-gnu/package.json').version
|
|
572
|
+
if (
|
|
573
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
574
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
575
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
576
|
+
) {
|
|
577
|
+
throw new Error(
|
|
578
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
return binding
|
|
582
|
+
} catch (e) {
|
|
583
|
+
loadErrors.push(e)
|
|
584
|
+
}
|
|
585
|
+
} else if (process.arch === 's390x') {
|
|
586
|
+
try {
|
|
587
|
+
return require('./node-rdev.linux-s390x-gnu.node')
|
|
588
|
+
} catch (e) {
|
|
589
|
+
loadErrors.push(e)
|
|
590
|
+
}
|
|
591
|
+
try {
|
|
592
|
+
const binding = require('node-rdev-linux-s390x-gnu')
|
|
593
|
+
const bindingPackageVersion = require('node-rdev-linux-s390x-gnu/package.json').version
|
|
594
|
+
if (
|
|
595
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
596
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
597
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
598
|
+
) {
|
|
599
|
+
throw new Error(
|
|
600
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
601
|
+
)
|
|
602
|
+
}
|
|
603
|
+
return binding
|
|
604
|
+
} catch (e) {
|
|
605
|
+
loadErrors.push(e)
|
|
606
|
+
}
|
|
607
|
+
} else {
|
|
608
|
+
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
|
609
|
+
}
|
|
610
|
+
} else if (process.platform === 'openharmony') {
|
|
611
|
+
if (process.arch === 'arm64') {
|
|
612
|
+
try {
|
|
613
|
+
return require('./node-rdev.openharmony-arm64.node')
|
|
614
|
+
} catch (e) {
|
|
615
|
+
loadErrors.push(e)
|
|
616
|
+
}
|
|
617
|
+
try {
|
|
618
|
+
const binding = require('node-rdev-openharmony-arm64')
|
|
619
|
+
const bindingPackageVersion = require('node-rdev-openharmony-arm64/package.json').version
|
|
620
|
+
if (
|
|
621
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
622
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
623
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
624
|
+
) {
|
|
625
|
+
throw new Error(
|
|
626
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
627
|
+
)
|
|
628
|
+
}
|
|
629
|
+
return binding
|
|
630
|
+
} catch (e) {
|
|
631
|
+
loadErrors.push(e)
|
|
632
|
+
}
|
|
633
|
+
} else if (process.arch === 'x64') {
|
|
634
|
+
try {
|
|
635
|
+
return require('./node-rdev.openharmony-x64.node')
|
|
636
|
+
} catch (e) {
|
|
637
|
+
loadErrors.push(e)
|
|
638
|
+
}
|
|
639
|
+
try {
|
|
640
|
+
const binding = require('node-rdev-openharmony-x64')
|
|
641
|
+
const bindingPackageVersion = require('node-rdev-openharmony-x64/package.json').version
|
|
642
|
+
if (
|
|
643
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
644
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
645
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
646
|
+
) {
|
|
647
|
+
throw new Error(
|
|
648
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
649
|
+
)
|
|
650
|
+
}
|
|
651
|
+
return binding
|
|
652
|
+
} catch (e) {
|
|
653
|
+
loadErrors.push(e)
|
|
654
|
+
}
|
|
655
|
+
} else if (process.arch === 'arm') {
|
|
656
|
+
try {
|
|
657
|
+
return require('./node-rdev.openharmony-arm.node')
|
|
658
|
+
} catch (e) {
|
|
659
|
+
loadErrors.push(e)
|
|
660
|
+
}
|
|
661
|
+
try {
|
|
662
|
+
const binding = require('node-rdev-openharmony-arm')
|
|
663
|
+
const bindingPackageVersion = require('node-rdev-openharmony-arm/package.json').version
|
|
664
|
+
if (
|
|
665
|
+
bindingPackageVersion !== '1.0.0' &&
|
|
666
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK &&
|
|
667
|
+
process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0'
|
|
668
|
+
) {
|
|
669
|
+
throw new Error(
|
|
670
|
+
`Native binding package version mismatch, expected 1.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`,
|
|
671
|
+
)
|
|
672
|
+
}
|
|
673
|
+
return binding
|
|
674
|
+
} catch (e) {
|
|
675
|
+
loadErrors.push(e)
|
|
676
|
+
}
|
|
677
|
+
} else {
|
|
678
|
+
loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
|
|
679
|
+
}
|
|
680
|
+
} else {
|
|
681
|
+
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
nativeBinding = requireNative()
|
|
686
|
+
|
|
687
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
688
|
+
let wasiBinding = null
|
|
689
|
+
let wasiBindingError = null
|
|
690
|
+
try {
|
|
691
|
+
wasiBinding = require('./node-rdev.wasi.cjs')
|
|
692
|
+
nativeBinding = wasiBinding
|
|
693
|
+
} catch (err) {
|
|
694
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
695
|
+
wasiBindingError = err
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
699
|
+
try {
|
|
700
|
+
wasiBinding = require('node-rdev-wasm32-wasi')
|
|
701
|
+
nativeBinding = wasiBinding
|
|
702
|
+
} catch (err) {
|
|
703
|
+
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
704
|
+
if (!wasiBindingError) {
|
|
705
|
+
wasiBindingError = err
|
|
706
|
+
} else {
|
|
707
|
+
wasiBindingError.cause = err
|
|
708
|
+
}
|
|
709
|
+
loadErrors.push(err)
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
|
|
714
|
+
const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
|
|
715
|
+
error.cause = wasiBindingError
|
|
716
|
+
throw error
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
if (!nativeBinding) {
|
|
721
|
+
if (loadErrors.length > 0) {
|
|
722
|
+
throw new Error(
|
|
723
|
+
`Cannot find native binding. ` +
|
|
724
|
+
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
|
|
725
|
+
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
|
|
726
|
+
{
|
|
727
|
+
cause: loadErrors.reduce((err, cur) => {
|
|
728
|
+
cur.cause = err
|
|
729
|
+
return cur
|
|
730
|
+
}),
|
|
731
|
+
},
|
|
732
|
+
)
|
|
733
|
+
}
|
|
734
|
+
throw new Error(`Failed to load native binding`)
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
module.exports = nativeBinding
|
|
738
|
+
module.exports.ButtonType = nativeBinding.ButtonType
|
|
739
|
+
module.exports.EventTypeValue = nativeBinding.EventTypeValue
|
|
740
|
+
module.exports.getDisplaySize = nativeBinding.getDisplaySize
|
|
741
|
+
module.exports.KeyCode = nativeBinding.KeyCode
|
|
742
|
+
module.exports.simulateEvent = nativeBinding.simulateEvent
|
|
743
|
+
module.exports.startListener = nativeBinding.startListener
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rdev-node",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "node version of rdev",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": "https://github.com/nglmercer/rdev-node",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"napi-rs",
|
|
10
|
+
"NAPI",
|
|
11
|
+
"N-API",
|
|
12
|
+
"Rust",
|
|
13
|
+
"node-addon",
|
|
14
|
+
"node-addon-api",
|
|
15
|
+
"node-rdev",
|
|
16
|
+
"rdev"
|
|
17
|
+
],
|
|
18
|
+
"files": [
|
|
19
|
+
"index.d.ts",
|
|
20
|
+
"index.js",
|
|
21
|
+
"*.node"
|
|
22
|
+
],
|
|
23
|
+
"napi": {
|
|
24
|
+
"binaryName": "node-rdev",
|
|
25
|
+
"targets": [
|
|
26
|
+
"x86_64-apple-darwin",
|
|
27
|
+
"x86_64-unknown-linux-gnu",
|
|
28
|
+
"x86_64-pc-windows-msvc",
|
|
29
|
+
"x86_64-unknown-linux-musl",
|
|
30
|
+
"aarch64-unknown-linux-gnu",
|
|
31
|
+
"i686-pc-windows-msvc",
|
|
32
|
+
"armv7-unknown-linux-gnueabihf",
|
|
33
|
+
"aarch64-apple-darwin",
|
|
34
|
+
"aarch64-linux-android",
|
|
35
|
+
"aarch64-pc-windows-msvc",
|
|
36
|
+
"armv7-linux-androideabi"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">= 10"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"registry": "https://registry.npmjs.org/",
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"artifacts": "napi artifacts",
|
|
48
|
+
"build": "napi build --platform --release --pipe \"prettier -w\"",
|
|
49
|
+
"build:debug": "napi build --platform --pipe \"prettier -w\"",
|
|
50
|
+
"format": "run-p format:prettier format:rs format:toml",
|
|
51
|
+
"format:prettier": "prettier . -w",
|
|
52
|
+
"format:toml": "taplo format",
|
|
53
|
+
"format:rs": "cargo fmt",
|
|
54
|
+
"lint": "eslint .",
|
|
55
|
+
"test": "bun test",
|
|
56
|
+
"test:node": "node --test tests/node-test.cjs",
|
|
57
|
+
"test:binding": "node --test tests/binding.test.cjs",
|
|
58
|
+
"version": "napi version"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@napi-rs/cli": "^3.5.1",
|
|
62
|
+
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
63
|
+
"@typescript-eslint/parser": "^8.18.0",
|
|
64
|
+
"@types/bun": "^1.1.5",
|
|
65
|
+
"@types/node": "^22.10.5",
|
|
66
|
+
"chalk": "^5.4.1",
|
|
67
|
+
"eslint": "^9.17.0",
|
|
68
|
+
"eslint-config-prettier": "^9.1.0",
|
|
69
|
+
"eslint-plugin-import": "^2.31.0",
|
|
70
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
71
|
+
"prettier": "^3.4.2",
|
|
72
|
+
"typescript": "^5.7.2"
|
|
73
|
+
},
|
|
74
|
+
"lint-staged": {
|
|
75
|
+
"*.@(js|ts|tsx)": [
|
|
76
|
+
"eslint --fix"
|
|
77
|
+
],
|
|
78
|
+
"*.@(js|ts|tsx|yml|yaml|md|json)": [
|
|
79
|
+
"prettier --write"
|
|
80
|
+
],
|
|
81
|
+
"*.toml": [
|
|
82
|
+
"taplo format"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"prettier": {
|
|
86
|
+
"printWidth": 120,
|
|
87
|
+
"semi": false,
|
|
88
|
+
"trailingComma": "all",
|
|
89
|
+
"singleQuote": true,
|
|
90
|
+
"arrowParens": "always"
|
|
91
|
+
}
|
|
92
|
+
}
|