@mcesystems/usb-device-listener 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,68 +1,76 @@
1
1
  {
2
- "name": "@mcesystems/usb-device-listener",
3
- "version": "1.0.11",
4
- "description": "Native Windows USB device listener using PnP notifications without custom drivers",
5
- "type": "module",
6
- "main": "src/index.ts",
7
- "types": "src/index.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./src/index.ts",
11
- "types": "./src/index.ts"
12
- }
13
- },
14
- "scripts": {
15
- "prebuild:gyp": "prebuildify --napi --strip --target 25.2.1",
16
- "build": "tsx esbuild.config.ts && tsc --emitDeclarationOnly",
17
- "rebuild": "node-gyp rebuild",
18
- "install": "node-gyp-build-optional",
19
- "clean": "node-gyp clean && rimraf dist",
20
- "check:types": "tsc --noEmit",
21
- "prepublishOnly": "npm run check:types",
22
- "pack": "npm pack",
23
- "test": "vitest run",
24
- "test:watch": "vitest",
25
- "listDevices": "cross-env DEBUG=* tsx ./src/examples/list-devices.ts",
26
- "example": "cross-env DEBUG=* tsx ./src/examples/example.ts"
27
- },
28
- "keywords": [
29
- "usb",
30
- "device",
31
- "listener",
32
- "monitor",
33
- "hotplug",
34
- "pnp",
35
- "windows",
36
- "native",
37
- "addon",
38
- "n-api",
39
- "typescript",
40
- "esm",
41
- "device-detection",
42
- "hardware"
43
- ],
44
- "author": "USB Device Listener Contributors",
45
- "license": "ISC",
46
- "dependencies": {
47
- "node-addon-api": "^8.2.1",
48
- "node-gyp-build": "^4.8.4"
49
- },
50
- "peerDependencies": {
51
- "typescript": ">=5.0.0"
52
- },
53
- "devDependencies": {
54
- "@types/node": "^24.10.1",
55
- "cross-env": "^10.1.0",
56
- "esbuild": "^0.27.0",
57
- "esbuild-plugin-copy": "^2.1.1",
58
- "node-gyp": "^10.3.1",
59
- "prebuildify": "^6.0.1",
60
- "rimraf": "^6.1.2",
61
- "tsx": "^4.21.0",
62
- "typescript": "^5.9.3",
63
- "vitest": "^2.1.8"
64
- },
65
- "files": ["src", "prebuilds", "native", "binding.gyp", "tsconfig.json", "README.md"],
66
- "gypfile": true,
67
- "os": ["win32"]
68
- }
2
+ "name": "@mcesystems/usb-device-listener",
3
+ "version": "1.0.13",
4
+ "description": "Native Windows USB device listener using PnP notifications without custom drivers",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./src/index.ts",
11
+ "types": "./src/index.ts"
12
+ }
13
+ },
14
+ "keywords": [
15
+ "usb",
16
+ "device",
17
+ "listener",
18
+ "monitor",
19
+ "hotplug",
20
+ "pnp",
21
+ "windows",
22
+ "native",
23
+ "addon",
24
+ "n-api",
25
+ "typescript",
26
+ "esm",
27
+ "device-detection",
28
+ "hardware"
29
+ ],
30
+ "author": "USB Device Listener Contributors",
31
+ "license": "ISC",
32
+ "dependencies": {
33
+ "node-addon-api": "^8.2.1",
34
+ "node-gyp-build": "^4.8.4"
35
+ },
36
+ "peerDependencies": {
37
+ "typescript": ">=5.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^24.10.1",
41
+ "cross-env": "^10.1.0",
42
+ "esbuild": "^0.27.0",
43
+ "esbuild-plugin-copy": "^2.1.1",
44
+ "node-gyp": "^10.3.1",
45
+ "prebuildify": "^6.0.1",
46
+ "rimraf": "^6.1.2",
47
+ "tsx": "^4.21.0",
48
+ "typescript": "^5.9.3",
49
+ "vitest": "^2.1.8"
50
+ },
51
+ "files": [
52
+ "src",
53
+ "prebuilds",
54
+ "native",
55
+ "binding.gyp",
56
+ "tsconfig.json",
57
+ "README.md"
58
+ ],
59
+ "gypfile": true,
60
+ "os": [
61
+ "win32"
62
+ ],
63
+ "scripts": {
64
+ "prebuild:gyp": "prebuildify --electron --strip --target 25.2.1",
65
+ "build": "tsx esbuild.config.ts && tsc --emitDeclarationOnly",
66
+ "rebuild": "node-gyp rebuild",
67
+ "install": "node-gyp-build",
68
+ "clean": "node-gyp clean && rimraf dist",
69
+ "check:types": "tsc --noEmit",
70
+ "pack": "npm pack",
71
+ "test": "vitest run",
72
+ "test:watch": "vitest",
73
+ "listDevices": "cross-env DEBUG=* tsx ./src/examples/list-devices.ts",
74
+ "example": "cross-env DEBUG=* tsx ./src/examples/example.ts"
75
+ }
76
+ }
package/src/index.ts CHANGED
@@ -39,7 +39,11 @@ function loadNativeAddon(): NativeAddon {
39
39
  }
40
40
  let addon: NativeAddon;
41
41
  try {
42
- addon = loadNativeAddon();
42
+ if (process.env.USB_DEVICE_LISTENER_ADDON_PATH) {
43
+ addon = require("node-gyp-build")(process.env.USB_DEVICE_LISTENER_ADDON_PATH);
44
+ } else {
45
+ addon = loadNativeAddon();
46
+ }
43
47
  } catch (_error) {
44
48
  throw new Error(
45
49
  `Failed to load native addon. Tried:\n 1. Direct path: ${packageRoot}\n 2. node-gyp-build search\nMake sure the addon is built with 'npm run rebuild' or 'npm run prebuild'`