node-libcec 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -28,7 +28,7 @@ npm install node-libcec
28
28
  ## Quick Start
29
29
 
30
30
  ```javascript
31
- const { CECAdapter, LogicalAddress, DeviceType } = require('node-libcec');
31
+ import { CECAdapter, LogicalAddress, DeviceType } from 'node-libcec';
32
32
 
33
33
  // Create adapter
34
34
  const cec = new CECAdapter({
@@ -88,13 +88,19 @@ new CECAdapter({
88
88
  - `open(port?, timeout?)` - Connect to adapter (auto-detects if no port)
89
89
  - `close()` - Disconnect
90
90
  - `pingAdapter()` - Check if adapter is responsive
91
+ - `getAdapterVendorId()` - Get USB vendor ID
92
+ - `getAdapterProductId()` - Get USB product ID
93
+ - `getLibInfo()` - Get libcec version info
91
94
 
92
95
  #### Device Discovery
93
96
 
94
97
  - `getActiveDevices()` - Get array of active logical addresses
95
98
  - `pollDevice(address)` - Check if device exists
96
99
  - `isActiveDevice(address)` - Check if device is active
100
+ - `isActiveDeviceType(type)` - Check if device type is active
97
101
  - `getActiveSource()` - Get current active source address
102
+ - `isActiveSource(address)` - Check if device is active source
103
+ - `isLibCECActiveSource()` - Check if this adapter is active source
98
104
 
99
105
  #### Device Information
100
106
 
@@ -130,6 +136,20 @@ new CECAdapter({
130
136
  - `sendKeyRelease(destination, wait?)` - Send key release
131
137
  - `setOSDString(address, duration, message)` - Display message on device
132
138
 
139
+ #### Address Configuration
140
+
141
+ - `setLogicalAddress(address?)` - Set logical address
142
+ - `setPhysicalAddress(address)` - Set physical address
143
+ - `setHDMIPort(baseDevice, port)` - Set HDMI port
144
+ - `getLogicalAddresses()` - Get controlled logical addresses
145
+
146
+ #### Configuration
147
+
148
+ - `getCurrentConfiguration()` - Get current config object
149
+ - `setConfiguration(config)` - Update configuration
150
+ - `rescanActiveDevices()` - Rescan CEC bus for devices
151
+ - `disableCallbacks()` - Disable event callbacks
152
+
133
153
  ### Events
134
154
 
135
155
  ```javascript
@@ -144,15 +164,17 @@ cec.on('configurationChanged', (config) => { }); // Config changes
144
164
  ### Constants
145
165
 
146
166
  ```javascript
147
- const {
167
+ import {
148
168
  LogicalAddress, // TV, RECORDING_DEVICE_1, PLAYBACK_DEVICE_1, etc.
149
169
  DeviceType, // TV, RECORDING_DEVICE, PLAYBACK_DEVICE, etc.
150
170
  PowerStatus, // ON, STANDBY, IN_TRANSITION_*, UNKNOWN
151
171
  Opcode, // STANDBY, ACTIVE_SOURCE, USER_CONTROL_PRESSED, etc.
152
172
  UserControlCode, // SELECT, UP, DOWN, PLAY, PAUSE, etc.
153
173
  LogLevel, // ERROR, WARNING, NOTICE, TRAFFIC, DEBUG
174
+ DisplayControl, // DISPLAY_FOR_DEFAULT_TIME, DISPLAY_UNTIL_CLEARED, etc.
175
+ Version, // V1_2, V1_3, V1_4, V2_0, etc.
154
176
  AlertType // SERVICE_DEVICE, CONNECTION_LOST, etc.
155
- } = require('node-libcec');
177
+ } from 'node-libcec';
156
178
  ```
157
179
 
158
180
  ## Examples
package/lib/constants.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * CEC Logical Addresses
3
3
  */
4
- const LogicalAddress = {
4
+ export const LogicalAddress = {
5
5
  TV: 0,
6
6
  RECORDING_DEVICE_1: 1,
7
7
  RECORDING_DEVICE_2: 2,
@@ -24,7 +24,7 @@ const LogicalAddress = {
24
24
  /**
25
25
  * CEC Device Types
26
26
  */
27
- const DeviceType = {
27
+ export const DeviceType = {
28
28
  TV: 0,
29
29
  RECORDING_DEVICE: 1,
30
30
  RESERVED: 2,
@@ -36,7 +36,7 @@ const DeviceType = {
36
36
  /**
37
37
  * CEC Power Status
38
38
  */
39
- const PowerStatus = {
39
+ export const PowerStatus = {
40
40
  ON: 0x00,
41
41
  STANDBY: 0x01,
42
42
  IN_TRANSITION_STANDBY_TO_ON: 0x02,
@@ -47,7 +47,7 @@ const PowerStatus = {
47
47
  /**
48
48
  * CEC Opcodes
49
49
  */
50
- const Opcode = {
50
+ export const Opcode = {
51
51
  ACTIVE_SOURCE: 0x82,
52
52
  IMAGE_VIEW_ON: 0x04,
53
53
  TEXT_VIEW_ON: 0x0D,
@@ -125,7 +125,7 @@ const Opcode = {
125
125
  /**
126
126
  * CEC User Control Codes (Remote buttons)
127
127
  */
128
- const UserControlCode = {
128
+ export const UserControlCode = {
129
129
  SELECT: 0x00,
130
130
  UP: 0x01,
131
131
  DOWN: 0x02,
@@ -219,7 +219,7 @@ const UserControlCode = {
219
219
  /**
220
220
  * CEC Log Level
221
221
  */
222
- const LogLevel = {
222
+ export const LogLevel = {
223
223
  ERROR: 1,
224
224
  WARNING: 2,
225
225
  NOTICE: 4,
@@ -231,7 +231,7 @@ const LogLevel = {
231
231
  /**
232
232
  * CEC Display Control (for OSD strings)
233
233
  */
234
- const DisplayControl = {
234
+ export const DisplayControl = {
235
235
  DISPLAY_FOR_DEFAULT_TIME: 0x00,
236
236
  DISPLAY_UNTIL_CLEARED: 0x40,
237
237
  CLEAR_PREVIOUS_MESSAGE: 0x80,
@@ -241,7 +241,7 @@ const DisplayControl = {
241
241
  /**
242
242
  * CEC Version
243
243
  */
244
- const Version = {
244
+ export const Version = {
245
245
  UNKNOWN: 0x00,
246
246
  V1_2: 0x01,
247
247
  V1_2A: 0x02,
@@ -254,7 +254,7 @@ const Version = {
254
254
  /**
255
255
  * Alert Types
256
256
  */
257
- const AlertType = {
257
+ export const AlertType = {
258
258
  SERVICE_DEVICE: 1,
259
259
  CONNECTION_LOST: 2,
260
260
  PERMISSION_ERROR: 3,
@@ -262,14 +262,3 @@ const AlertType = {
262
262
  PHYSICAL_ADDRESS_ERROR: 5
263
263
  };
264
264
 
265
- module.exports = {
266
- LogicalAddress,
267
- DeviceType,
268
- PowerStatus,
269
- Opcode,
270
- UserControlCode,
271
- LogLevel,
272
- DisplayControl,
273
- Version,
274
- AlertType
275
- };
package/lib/index.js CHANGED
@@ -1,18 +1,24 @@
1
- const EventEmitter = require('events');
1
+ import { EventEmitter } from 'events';
2
+ import { createRequire } from 'module';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+
6
+ const require = createRequire(import.meta.url);
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
2
8
 
3
9
  // Load native addon
4
10
  let native;
5
11
  try {
6
- native = require('../build/Release/cec.node');
12
+ native = require(join(__dirname, '../build/Release/cec.node'));
7
13
  } catch (e) {
8
14
  try {
9
- native = require('../build/Debug/cec.node');
15
+ native = require(join(__dirname, '../build/Debug/cec.node'));
10
16
  } catch (e2) {
11
17
  throw new Error('Failed to load native cec module. Did you run npm run build?');
12
18
  }
13
19
  }
14
20
 
15
- const constants = require('./constants');
21
+ import * as constants from './constants.js';
16
22
 
17
23
  /**
18
24
  * CEC Adapter class - provides high-level interface to libcec
@@ -427,7 +433,5 @@ class CECAdapter extends EventEmitter {
427
433
  }
428
434
 
429
435
  // Export everything
430
- module.exports = {
431
- CECAdapter,
432
- ...constants
433
- };
436
+ export { CECAdapter };
437
+ export * from './constants.js';
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "node-libcec",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Node.js bindings for libcec - control CEC devices over HDMI",
5
+ "type": "module",
5
6
  "main": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js"
9
+ },
6
10
  "scripts": {
7
11
  "build": "node-gyp rebuild",
8
12
  "clean": "node-gyp clean",
9
13
  "prepare": "npm run build",
10
- "test": "node --test test/"
14
+ "test": "node --test test/",
15
+ "release:patch": "npm version patch && npm publish",
16
+ "release:minor": "npm version minor && npm publish",
17
+ "release:major": "npm version major && npm publish"
11
18
  },
12
19
  "keywords": [
13
20
  "cec",
@@ -43,4 +50,4 @@
43
50
  "node-gyp": "^10.0.0"
44
51
  },
45
52
  "gypfile": true
46
- }
53
+ }