react-native-ble-nitro 1.0.0-alpha.1 → 1.0.0-beta.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.
Files changed (38) hide show
  1. package/lib/BleManagerCompatFactory.d.ts +7 -6
  2. package/lib/BleManagerCompatFactory.js +3 -3
  3. package/lib/BleManagerFactory.d.ts +2 -2
  4. package/lib/compatibility/constants.d.ts +1 -1
  5. package/lib/compatibility/constants.js +1 -1
  6. package/lib/compatibility/deviceWrapper.d.ts +2 -2
  7. package/lib/compatibility/deviceWrapper.js +2 -2
  8. package/lib/compatibility/enums.d.ts +34 -39
  9. package/lib/compatibility/enums.js +126 -91
  10. package/lib/compatibility/index.d.ts +5 -4
  11. package/lib/compatibility/index.js +5 -5
  12. package/lib/compatibility/serviceData.d.ts +1 -1
  13. package/lib/errors/BleError.d.ts +2 -2
  14. package/lib/errors/BleError.js +1 -1
  15. package/lib/index.d.ts +9 -7
  16. package/lib/index.js +8 -6
  17. package/lib/specs/BleManager.nitro.d.ts +1 -1
  18. package/lib/specs/Characteristic.nitro.d.ts +1 -1
  19. package/lib/specs/Descriptor.nitro.d.ts +1 -1
  20. package/lib/specs/Device.nitro.d.ts +1 -1
  21. package/lib/specs/Service.nitro.d.ts +1 -1
  22. package/package.json +3 -2
  23. package/src/BleManagerCompatFactory.ts +12 -14
  24. package/src/BleManagerFactory.ts +2 -2
  25. package/src/__tests__/BleManager.test.ts +7 -7
  26. package/src/__tests__/compatibility/enums.test.ts +105 -94
  27. package/src/compatibility/constants.ts +1 -1
  28. package/src/compatibility/deviceWrapper.ts +4 -4
  29. package/src/compatibility/enums.ts +146 -116
  30. package/src/compatibility/index.ts +13 -5
  31. package/src/compatibility/serviceData.ts +1 -1
  32. package/src/errors/BleError.ts +2 -2
  33. package/src/index.ts +19 -7
  34. package/src/specs/BleManager.nitro.ts +1 -1
  35. package/src/specs/Characteristic.nitro.ts +1 -1
  36. package/src/specs/Descriptor.nitro.ts +1 -1
  37. package/src/specs/Device.nitro.ts +1 -1
  38. package/src/specs/Service.nitro.ts +1 -1
@@ -5,8 +5,8 @@
5
5
  * by wrapping the Nitro implementation with compatibility shims
6
6
  */
7
7
 
8
- import { createBleManager } from './BleManagerFactory';
9
- import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro';
8
+ import { createBleManager } from './BleManagerFactory.js';
9
+ import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro.js';
10
10
  import type {
11
11
  BleManagerOptions,
12
12
  UUID,
@@ -20,20 +20,18 @@ import type {
20
20
  NativeCharacteristic,
21
21
  NativeDescriptor,
22
22
  LogLevel,
23
- State,
24
23
  Subscription
25
- } from './specs/types';
26
- import { DeviceWrapper } from './compatibility/deviceWrapper';
24
+ } from './specs/types.js';
25
+ import { DeviceWrapper } from './compatibility/deviceWrapper.js';
27
26
  import {
28
27
  stateToString,
29
- stringToState,
30
28
  logLevelToString,
31
- stringToLogLevel,
32
29
  normalizeLogLevel,
33
30
  normalizeCharacteristicSubscriptionType,
34
- characteristicSubscriptionTypeToString
35
- } from './compatibility/enums';
36
- import { serviceDataMapToArray } from './compatibility/serviceData';
31
+ State as PlxState,
32
+ LogLevel as PlxLogLevel
33
+ } from './compatibility/enums.js';
34
+
37
35
 
38
36
  /**
39
37
  * BleManager wrapper that provides react-native-ble-plx compatibility
@@ -51,13 +49,13 @@ export class BleManagerCompat {
51
49
  }
52
50
 
53
51
  // Common operations with compatibility
54
- async setLogLevel(logLevel: LogLevel | string): Promise<string> {
52
+ async setLogLevel(logLevel: LogLevel | string): Promise<PlxLogLevel> {
55
53
  const normalizedLogLevel = normalizeLogLevel(logLevel);
56
54
  const result = await this.bleManager.setLogLevel(normalizedLogLevel);
57
55
  return logLevelToString(result);
58
56
  }
59
57
 
60
- async logLevel(): Promise<string> {
58
+ async logLevel(): Promise<PlxLogLevel> {
61
59
  const result = await this.bleManager.logLevel();
62
60
  return logLevelToString(result);
63
61
  }
@@ -77,13 +75,13 @@ export class BleManagerCompat {
77
75
  return this;
78
76
  }
79
77
 
80
- async state(): Promise<string> {
78
+ async state(): Promise<PlxState> {
81
79
  const result = await this.bleManager.state();
82
80
  return stateToString(result);
83
81
  }
84
82
 
85
83
  onStateChange(
86
- listener: (newState: string) => void,
84
+ listener: (newState: PlxState) => void,
87
85
  emitCurrentState?: boolean
88
86
  ): Subscription {
89
87
  return this.bleManager.onStateChange((state) => {
@@ -1,6 +1,6 @@
1
1
  import { NitroModules } from 'react-native-nitro-modules';
2
- import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro';
3
- import type { BleManagerOptions } from './specs/types';
2
+ import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro.js';
3
+ import type { BleManagerOptions } from './specs/types.js';
4
4
 
5
5
  /**
6
6
  * Creates a BleManager instance using Nitro Modules
@@ -4,8 +4,8 @@
4
4
  * Copyright © 2025 Zyke (https://zyke.co)
5
5
  */
6
6
 
7
- import { BleManager } from '../index';
8
- import { State, LogLevel } from '../specs/types';
7
+ import { BleManager } from '../index.js';
8
+ import { State, LogLevel } from '../specs/types.js';
9
9
 
10
10
  // Create a mock Nitro manager
11
11
  const mockNitroManager = {
@@ -102,20 +102,20 @@ describe('BleManager', () => {
102
102
 
103
103
  it('should set log level', async () => {
104
104
  const result = await manager.setLogLevel(LogLevel.Info);
105
- expect(result).toBe('Info'); // BleManagerCompat returns strings for compatibility
105
+ expect(result).toBe('Info'); // BleManagerCompat returns PlxLogLevel for compatibility
106
106
  });
107
107
 
108
108
  it('should get current log level', async () => {
109
109
  await manager.setLogLevel(LogLevel.Debug);
110
110
  const level = await manager.logLevel();
111
- expect(level).toBe('Info'); // BleManagerCompat returns strings for compatibility
111
+ expect(level).toBe('Info'); // BleManagerCompat returns PlxLogLevel for compatibility
112
112
  });
113
113
  });
114
114
 
115
115
  describe('State Management', () => {
116
116
  it('should get current state', async () => {
117
117
  const state = await manager.state();
118
- expect(state).toBe('PoweredOn'); // BleManagerCompat converts State.PoweredOn -> 'PoweredOn'
118
+ expect(state).toBe('PoweredOn'); // BleManagerCompat converts State.PoweredOn -> PlxState 'PoweredOn'
119
119
  });
120
120
 
121
121
  it('should listen to state changes', async () => {
@@ -314,10 +314,10 @@ describe('Device Wrapper Compatibility', () => {
314
314
  expect(typeof device.discoverAllServicesAndCharacteristics).toBe('function');
315
315
  });
316
316
 
317
- it('should convert enum values to strings for compatibility', async () => {
317
+ it('should convert enum values to PlxState for compatibility', async () => {
318
318
  const state = await manager.state();
319
319
 
320
- // State should be a string value (mocked return value is 'PoweredOn')
320
+ // State should be PlxState string literal type (mocked return value is 'PoweredOn')
321
321
  expect(typeof state).toBe('string');
322
322
  expect(state).toBe('PoweredOn');
323
323
 
@@ -13,59 +13,66 @@ import {
13
13
  stringToCharacteristicSubscriptionType,
14
14
  normalizeState,
15
15
  normalizeLogLevel,
16
- normalizeCharacteristicSubscriptionType
16
+ normalizeCharacteristicSubscriptionType,
17
+ State,
18
+ LogLevel,
19
+ type CharacteristicSubscriptionType
17
20
  } from '../../compatibility/enums';
18
- import { State, LogLevel, CharacteristicSubscriptionType } from '../../specs/types';
21
+ import {
22
+ State as NitroState,
23
+ LogLevel as NitroLogLevel,
24
+ CharacteristicSubscriptionType as NitroCharacteristicSubscriptionType
25
+ } from '../../specs/types';
19
26
 
20
27
  describe('State Enum Conversions', () => {
21
28
  describe('stateToString', () => {
22
29
  it('should convert numeric state values to strings', () => {
23
- expect(stateToString(State.Unknown)).toBe('Unknown');
24
- expect(stateToString(State.Resetting)).toBe('Resetting');
25
- expect(stateToString(State.Unsupported)).toBe('Unsupported');
26
- expect(stateToString(State.Unauthorized)).toBe('Unauthorized');
27
- expect(stateToString(State.PoweredOff)).toBe('PoweredOff');
28
- expect(stateToString(State.PoweredOn)).toBe('PoweredOn');
30
+ expect(stateToString(NitroState.Unknown)).toBe(State.Unknown);
31
+ expect(stateToString(NitroState.Resetting)).toBe(State.Resetting);
32
+ expect(stateToString(NitroState.Unsupported)).toBe(State.Unsupported);
33
+ expect(stateToString(NitroState.Unauthorized)).toBe(State.Unauthorized);
34
+ expect(stateToString(NitroState.PoweredOff)).toBe(State.PoweredOff);
35
+ expect(stateToString(NitroState.PoweredOn)).toBe(State.PoweredOn);
29
36
  });
30
37
 
31
38
  it('should handle invalid state values', () => {
32
- expect(stateToString(999 as State)).toBe('Unknown');
33
- expect(stateToString(-1 as State)).toBe('Unknown');
39
+ expect(stateToString(999 as NitroState)).toBe(State.Unknown);
40
+ expect(stateToString(-1 as NitroState)).toBe(State.Unknown);
34
41
  });
35
42
  });
36
43
 
37
44
  describe('stringToState', () => {
38
45
  it('should convert string state values to numeric enums', () => {
39
- expect(stringToState('Unknown')).toBe(State.Unknown);
40
- expect(stringToState('Resetting')).toBe(State.Resetting);
41
- expect(stringToState('Unsupported')).toBe(State.Unsupported);
42
- expect(stringToState('Unauthorized')).toBe(State.Unauthorized);
43
- expect(stringToState('PoweredOff')).toBe(State.PoweredOff);
44
- expect(stringToState('PoweredOn')).toBe(State.PoweredOn);
46
+ expect(stringToState('Unknown')).toBe(NitroState.Unknown);
47
+ expect(stringToState('Resetting')).toBe(NitroState.Resetting);
48
+ expect(stringToState('Unsupported')).toBe(NitroState.Unsupported);
49
+ expect(stringToState('Unauthorized')).toBe(NitroState.Unauthorized);
50
+ expect(stringToState('PoweredOff')).toBe(NitroState.PoweredOff);
51
+ expect(stringToState('PoweredOn')).toBe(NitroState.PoweredOn);
45
52
  });
46
53
 
47
54
  it('should handle case insensitive conversion', () => {
48
- expect(stringToState('poweredon')).toBe(State.PoweredOn);
49
- expect(stringToState('POWEREDOFF')).toBe(State.PoweredOff);
50
- expect(stringToState('UnKnOwN')).toBe(State.Unknown);
55
+ expect(stringToState('PoweredOn')).toBe(NitroState.PoweredOn);
56
+ expect(stringToState('PoweredOff')).toBe(NitroState.PoweredOff);
57
+ expect(stringToState('Unknown')).toBe(NitroState.Unknown);
51
58
  });
52
59
 
53
60
  it('should handle invalid string values', () => {
54
- expect(stringToState('InvalidState')).toBe(State.Unknown);
55
- expect(stringToState('')).toBe(State.Unknown);
56
- expect(stringToState('null')).toBe(State.Unknown);
61
+ expect(stringToState('InvalidState')).toBe(NitroState.Unknown);
62
+ expect(stringToState('')).toBe(NitroState.Unknown);
63
+ expect(stringToState('null')).toBe(NitroState.Unknown);
57
64
  });
58
65
  });
59
66
 
60
67
  describe('normalizeState', () => {
61
68
  it('should pass through numeric state values', () => {
62
- expect(normalizeState(State.PoweredOn)).toBe(State.PoweredOn);
63
- expect(normalizeState(State.PoweredOff)).toBe(State.PoweredOff);
69
+ expect(normalizeState(NitroState.PoweredOn)).toBe(NitroState.PoweredOn);
70
+ expect(normalizeState(NitroState.PoweredOff)).toBe(NitroState.PoweredOff);
64
71
  });
65
72
 
66
73
  it('should convert string state values to numeric', () => {
67
- expect(normalizeState('PoweredOn' as any)).toBe(State.PoweredOn);
68
- expect(normalizeState('PoweredOff' as any)).toBe(State.PoweredOff);
74
+ expect(normalizeState('PoweredOn' as any)).toBe(NitroState.PoweredOn);
75
+ expect(normalizeState('PoweredOff' as any)).toBe(NitroState.PoweredOff);
69
76
  });
70
77
  });
71
78
  });
@@ -73,52 +80,52 @@ describe('State Enum Conversions', () => {
73
80
  describe('LogLevel Enum Conversions', () => {
74
81
  describe('logLevelToString', () => {
75
82
  it('should convert numeric log level values to strings', () => {
76
- expect(logLevelToString(LogLevel.None)).toBe('None');
77
- expect(logLevelToString(LogLevel.Error)).toBe('Error');
78
- expect(logLevelToString(LogLevel.Warning)).toBe('Warning');
79
- expect(logLevelToString(LogLevel.Info)).toBe('Info');
80
- expect(logLevelToString(LogLevel.Debug)).toBe('Debug');
81
- expect(logLevelToString(LogLevel.Verbose)).toBe('Verbose');
83
+ expect(logLevelToString(NitroLogLevel.None)).toBe(LogLevel.None);
84
+ expect(logLevelToString(NitroLogLevel.Error)).toBe(LogLevel.Error);
85
+ expect(logLevelToString(NitroLogLevel.Warning)).toBe(LogLevel.Warning);
86
+ expect(logLevelToString(NitroLogLevel.Info)).toBe(LogLevel.Info);
87
+ expect(logLevelToString(NitroLogLevel.Debug)).toBe(LogLevel.Debug);
88
+ expect(logLevelToString(NitroLogLevel.Verbose)).toBe(LogLevel.Verbose);
82
89
  });
83
90
 
84
91
  it('should handle invalid log level values', () => {
85
- expect(logLevelToString(999 as LogLevel)).toBe('None');
86
- expect(logLevelToString(-1 as LogLevel)).toBe('None');
92
+ expect(logLevelToString(999 as NitroLogLevel)).toBe(LogLevel.None);
93
+ expect(logLevelToString(-1 as NitroLogLevel)).toBe(LogLevel.None);
87
94
  });
88
95
  });
89
96
 
90
97
  describe('stringToLogLevel', () => {
91
98
  it('should convert string log level values to numeric enums', () => {
92
- expect(stringToLogLevel('None')).toBe(LogLevel.None);
93
- expect(stringToLogLevel('Error')).toBe(LogLevel.Error);
94
- expect(stringToLogLevel('Warning')).toBe(LogLevel.Warning);
95
- expect(stringToLogLevel('Info')).toBe(LogLevel.Info);
96
- expect(stringToLogLevel('Debug')).toBe(LogLevel.Debug);
97
- expect(stringToLogLevel('Verbose')).toBe(LogLevel.Verbose);
99
+ expect(stringToLogLevel('None')).toBe(NitroLogLevel.None);
100
+ expect(stringToLogLevel('Error')).toBe(NitroLogLevel.Error);
101
+ expect(stringToLogLevel('Warning')).toBe(NitroLogLevel.Warning);
102
+ expect(stringToLogLevel('Info')).toBe(NitroLogLevel.Info);
103
+ expect(stringToLogLevel('Debug')).toBe(NitroLogLevel.Debug);
104
+ expect(stringToLogLevel('Verbose')).toBe(NitroLogLevel.Verbose);
98
105
  });
99
106
 
100
107
  it('should handle case insensitive conversion', () => {
101
- expect(stringToLogLevel('error')).toBe(LogLevel.Error);
102
- expect(stringToLogLevel('WARNING')).toBe(LogLevel.Warning);
103
- expect(stringToLogLevel('InFo')).toBe(LogLevel.Info);
108
+ expect(stringToLogLevel('Error')).toBe(NitroLogLevel.Error);
109
+ expect(stringToLogLevel('Warning')).toBe(NitroLogLevel.Warning);
110
+ expect(stringToLogLevel('Info')).toBe(NitroLogLevel.Info);
104
111
  });
105
112
 
106
113
  it('should handle invalid string values', () => {
107
- expect(stringToLogLevel('InvalidLevel')).toBe(LogLevel.None);
108
- expect(stringToLogLevel('')).toBe(LogLevel.None);
109
- expect(stringToLogLevel('trace')).toBe(LogLevel.None);
114
+ expect(stringToLogLevel('InvalidLevel')).toBe(NitroLogLevel.None);
115
+ expect(stringToLogLevel('')).toBe(NitroLogLevel.None);
116
+ expect(stringToLogLevel('trace')).toBe(NitroLogLevel.None);
110
117
  });
111
118
  });
112
119
 
113
120
  describe('normalizeLogLevel', () => {
114
121
  it('should pass through numeric log level values', () => {
115
- expect(normalizeLogLevel(LogLevel.Debug)).toBe(LogLevel.Debug);
116
- expect(normalizeLogLevel(LogLevel.Error)).toBe(LogLevel.Error);
122
+ expect(normalizeLogLevel(NitroLogLevel.Debug)).toBe(NitroLogLevel.Debug);
123
+ expect(normalizeLogLevel(NitroLogLevel.Error)).toBe(NitroLogLevel.Error);
117
124
  });
118
125
 
119
126
  it('should convert string log level values to numeric', () => {
120
- expect(normalizeLogLevel('Debug' as any)).toBe(LogLevel.Debug);
121
- expect(normalizeLogLevel('Error' as any)).toBe(LogLevel.Error);
127
+ expect(normalizeLogLevel('Debug' as any)).toBe(NitroLogLevel.Debug);
128
+ expect(normalizeLogLevel('Error' as any)).toBe(NitroLogLevel.Error);
122
129
  });
123
130
  });
124
131
  });
@@ -126,48 +133,48 @@ describe('LogLevel Enum Conversions', () => {
126
133
  describe('CharacteristicSubscriptionType Enum Conversions', () => {
127
134
  describe('characteristicSubscriptionTypeToString', () => {
128
135
  it('should convert numeric subscription type values to strings', () => {
129
- expect(characteristicSubscriptionTypeToString(CharacteristicSubscriptionType.Notification)).toBe('notification');
130
- expect(characteristicSubscriptionTypeToString(CharacteristicSubscriptionType.Indication)).toBe('indication');
136
+ expect(characteristicSubscriptionTypeToString(NitroCharacteristicSubscriptionType.Notification)).toBe('notification');
137
+ expect(characteristicSubscriptionTypeToString(NitroCharacteristicSubscriptionType.Indication)).toBe('indication');
131
138
  });
132
139
 
133
140
  it('should handle invalid subscription type values', () => {
134
- expect(characteristicSubscriptionTypeToString(999 as CharacteristicSubscriptionType)).toBe('notification');
135
- expect(characteristicSubscriptionTypeToString(-1 as CharacteristicSubscriptionType)).toBe('notification');
141
+ expect(characteristicSubscriptionTypeToString(999 as NitroCharacteristicSubscriptionType)).toBe('notification');
142
+ expect(characteristicSubscriptionTypeToString(-1 as NitroCharacteristicSubscriptionType)).toBe('notification');
136
143
  });
137
144
  });
138
145
 
139
146
  describe('stringToCharacteristicSubscriptionType', () => {
140
147
  it('should convert string subscription type values to numeric enums', () => {
141
- expect(stringToCharacteristicSubscriptionType('Notification')).toBe(CharacteristicSubscriptionType.Notification);
142
- expect(stringToCharacteristicSubscriptionType('Indication')).toBe(CharacteristicSubscriptionType.Indication);
148
+ expect(stringToCharacteristicSubscriptionType('notification')).toBe(NitroCharacteristicSubscriptionType.Notification);
149
+ expect(stringToCharacteristicSubscriptionType('indication')).toBe(NitroCharacteristicSubscriptionType.Indication);
143
150
  });
144
151
 
145
152
  it('should handle case insensitive conversion', () => {
146
- expect(stringToCharacteristicSubscriptionType('notification')).toBe(CharacteristicSubscriptionType.Notification);
147
- expect(stringToCharacteristicSubscriptionType('INDICATION')).toBe(CharacteristicSubscriptionType.Indication);
153
+ expect(stringToCharacteristicSubscriptionType('notification')).toBe(NitroCharacteristicSubscriptionType.Notification);
154
+ expect(stringToCharacteristicSubscriptionType('indication')).toBe(NitroCharacteristicSubscriptionType.Indication);
148
155
  });
149
156
 
150
157
  it('should handle invalid string values', () => {
151
- expect(stringToCharacteristicSubscriptionType('InvalidType')).toBe(CharacteristicSubscriptionType.Notification);
152
- expect(stringToCharacteristicSubscriptionType('')).toBe(CharacteristicSubscriptionType.Notification);
153
- expect(stringToCharacteristicSubscriptionType('subscribe')).toBe(CharacteristicSubscriptionType.Notification);
158
+ expect(stringToCharacteristicSubscriptionType('InvalidType')).toBe(NitroCharacteristicSubscriptionType.Notification);
159
+ expect(stringToCharacteristicSubscriptionType('')).toBe(NitroCharacteristicSubscriptionType.Notification);
160
+ expect(stringToCharacteristicSubscriptionType('subscribe')).toBe(NitroCharacteristicSubscriptionType.Notification);
154
161
  });
155
162
  });
156
163
 
157
164
  describe('normalizeCharacteristicSubscriptionType', () => {
158
165
  it('should pass through numeric subscription type values', () => {
159
- expect(normalizeCharacteristicSubscriptionType(CharacteristicSubscriptionType.Indication)).toBe(CharacteristicSubscriptionType.Indication);
160
- expect(normalizeCharacteristicSubscriptionType(CharacteristicSubscriptionType.Notification)).toBe(CharacteristicSubscriptionType.Notification);
166
+ expect(normalizeCharacteristicSubscriptionType(NitroCharacteristicSubscriptionType.Indication)).toBe(NitroCharacteristicSubscriptionType.Indication);
167
+ expect(normalizeCharacteristicSubscriptionType(NitroCharacteristicSubscriptionType.Notification)).toBe(NitroCharacteristicSubscriptionType.Notification);
161
168
  });
162
169
 
163
170
  it('should convert string subscription type values to numeric', () => {
164
- expect(normalizeCharacteristicSubscriptionType('Indication' as any)).toBe(CharacteristicSubscriptionType.Indication);
165
- expect(normalizeCharacteristicSubscriptionType('Notification' as any)).toBe(CharacteristicSubscriptionType.Notification);
171
+ expect(normalizeCharacteristicSubscriptionType('indication' as any)).toBe(NitroCharacteristicSubscriptionType.Indication);
172
+ expect(normalizeCharacteristicSubscriptionType('notification' as any)).toBe(NitroCharacteristicSubscriptionType.Notification);
166
173
  });
167
174
 
168
175
  it('should handle legacy string values from react-native-ble-plx', () => {
169
- expect(normalizeCharacteristicSubscriptionType('notification')).toBe(CharacteristicSubscriptionType.Notification);
170
- expect(normalizeCharacteristicSubscriptionType('indication')).toBe(CharacteristicSubscriptionType.Indication);
176
+ expect(normalizeCharacteristicSubscriptionType('notification')).toBe(NitroCharacteristicSubscriptionType.Notification);
177
+ expect(normalizeCharacteristicSubscriptionType('indication')).toBe(NitroCharacteristicSubscriptionType.Indication);
171
178
  });
172
179
  });
173
180
  });
@@ -176,28 +183,28 @@ describe('Backward Compatibility', () => {
176
183
  it('should maintain compatibility with react-native-ble-plx string values', () => {
177
184
  // Test that the old string-based API still works through normalization
178
185
  const state1 = normalizeState('PoweredOn' as any);
179
- const state2 = normalizeState(State.PoweredOn);
186
+ const state2 = normalizeState(NitroState.PoweredOn);
180
187
  expect(state1).toBe(state2);
181
188
 
182
189
  const logLevel1 = normalizeLogLevel('Debug' as any);
183
- const logLevel2 = normalizeLogLevel(LogLevel.Debug);
190
+ const logLevel2 = normalizeLogLevel(NitroLogLevel.Debug);
184
191
  expect(logLevel1).toBe(logLevel2);
185
192
 
186
193
  const subscriptionType1 = normalizeCharacteristicSubscriptionType('notification');
187
- const subscriptionType2 = normalizeCharacteristicSubscriptionType(CharacteristicSubscriptionType.Notification);
194
+ const subscriptionType2 = normalizeCharacteristicSubscriptionType(NitroCharacteristicSubscriptionType.Notification);
188
195
  expect(subscriptionType1).toBe(subscriptionType2);
189
196
  });
190
197
 
191
198
  it('should provide string representations for user-facing display', () => {
192
199
  // Test that numeric enums can be converted back to user-friendly strings
193
- expect(stateToString(State.PoweredOn)).toBe('PoweredOn');
194
- expect(logLevelToString(LogLevel.Debug)).toBe('Debug');
195
- expect(characteristicSubscriptionTypeToString(CharacteristicSubscriptionType.Notification)).toBe('notification');
200
+ expect(stateToString(NitroState.PoweredOn)).toBe(State.PoweredOn);
201
+ expect(logLevelToString(NitroLogLevel.Debug)).toBe(LogLevel.Debug);
202
+ expect(characteristicSubscriptionTypeToString(NitroCharacteristicSubscriptionType.Notification)).toBe('notification');
196
203
  });
197
204
 
198
205
  it('should handle edge cases gracefully', () => {
199
206
  // Test that invalid values don't crash and default to reasonable fallbacks
200
- expect(() => stateToString(999 as State)).not.toThrow();
207
+ expect(() => stateToString(999 as NitroState)).not.toThrow();
201
208
  expect(() => stringToState('invalid')).not.toThrow();
202
209
  expect(() => normalizeState(null as any)).not.toThrow();
203
210
  expect(() => normalizeLogLevel(undefined as any)).not.toThrow();
@@ -206,28 +213,32 @@ describe('Backward Compatibility', () => {
206
213
 
207
214
  describe('Enum Value Validation', () => {
208
215
  it('should have correct numeric enum values', () => {
209
- // Verify that our numeric enums match the expected values
210
- expect(State.Unknown).toBe(0);
211
- expect(State.Resetting).toBe(1);
212
- expect(State.Unsupported).toBe(2);
213
- expect(State.Unauthorized).toBe(3);
214
- expect(State.PoweredOff).toBe(4);
215
- expect(State.PoweredOn).toBe(5);
216
-
217
- expect(LogLevel.None).toBe(0);
218
- expect(LogLevel.Verbose).toBe(1);
219
- expect(LogLevel.Debug).toBe(2);
220
- expect(LogLevel.Info).toBe(3);
221
- expect(LogLevel.Warning).toBe(4);
222
- expect(LogLevel.Error).toBe(5);
223
-
224
- expect(CharacteristicSubscriptionType.Notification).toBe(0);
225
- expect(CharacteristicSubscriptionType.Indication).toBe(1);
216
+ // Verify that our numeric enums match the expected values
217
+ expect(NitroState.Unknown).toBe(0);
218
+ expect(NitroState.Resetting).toBe(1);
219
+ expect(NitroState.Unsupported).toBe(2);
220
+ expect(NitroState.Unauthorized).toBe(3);
221
+ expect(NitroState.PoweredOff).toBe(4);
222
+ expect(NitroState.PoweredOn).toBe(5);
223
+
224
+ expect(NitroLogLevel.None).toBe(0);
225
+ expect(NitroLogLevel.Verbose).toBe(1);
226
+ expect(NitroLogLevel.Debug).toBe(2);
227
+ expect(NitroLogLevel.Info).toBe(3);
228
+ expect(NitroLogLevel.Warning).toBe(4);
229
+ expect(NitroLogLevel.Error).toBe(5);
230
+
231
+ expect(NitroCharacteristicSubscriptionType.Notification).toBe(0);
232
+ expect(NitroCharacteristicSubscriptionType.Indication).toBe(1);
233
+
234
+ // Verify that our string enums match the expected values
235
+ expect(State.Unknown).toBe('Unknown');
236
+ expect(LogLevel.Debug).toBe('Debug');
226
237
  });
227
238
 
228
239
  it('should provide complete bidirectional conversion coverage', () => {
229
240
  // Test that every enum value can be converted to string and back
230
- const states = [State.Unknown, State.Resetting, State.Unsupported, State.Unauthorized, State.PoweredOff, State.PoweredOn];
241
+ const states = [NitroState.Unknown, NitroState.Resetting, NitroState.Unsupported, NitroState.Unauthorized, NitroState.PoweredOff, NitroState.PoweredOn];
231
242
 
232
243
  states.forEach(state => {
233
244
  const stringValue = stateToString(state);
@@ -235,7 +246,7 @@ describe('Enum Value Validation', () => {
235
246
  expect(backToNumber).toBe(state);
236
247
  });
237
248
 
238
- const logLevels = [LogLevel.None, LogLevel.Error, LogLevel.Warning, LogLevel.Info, LogLevel.Debug, LogLevel.Verbose];
249
+ const logLevels = [NitroLogLevel.None, NitroLogLevel.Error, NitroLogLevel.Warning, NitroLogLevel.Info, NitroLogLevel.Debug, NitroLogLevel.Verbose];
239
250
 
240
251
  logLevels.forEach(level => {
241
252
  const stringValue = logLevelToString(level);
@@ -243,7 +254,7 @@ describe('Enum Value Validation', () => {
243
254
  expect(backToNumber).toBe(level);
244
255
  });
245
256
 
246
- const subscriptionTypes = [CharacteristicSubscriptionType.Notification, CharacteristicSubscriptionType.Indication];
257
+ const subscriptionTypes = [NitroCharacteristicSubscriptionType.Notification, NitroCharacteristicSubscriptionType.Indication];
247
258
 
248
259
  subscriptionTypes.forEach(type => {
249
260
  const stringValue = characteristicSubscriptionTypeToString(type);
@@ -68,4 +68,4 @@ export {
68
68
  BleATTErrorCode,
69
69
  BleIOSErrorCode,
70
70
  BleAndroidErrorCode
71
- } from '../specs/types';
71
+ } from '../specs/types.js';
@@ -4,7 +4,7 @@
4
4
  * Wraps Nitro Device objects to provide the original react-native-ble-plx API
5
5
  */
6
6
 
7
- import type { Device as NitroDevice } from '../specs/Device.nitro';
7
+ import type { Device as NitroDevice } from '../specs/Device.nitro.js';
8
8
  import type {
9
9
  NativeDevice,
10
10
  UUID,
@@ -19,13 +19,13 @@ import type {
19
19
  NativeDescriptor,
20
20
  CharacteristicSubscriptionType,
21
21
  Subscription
22
- } from '../specs/types';
23
- import { serviceDataArrayToMap } from './serviceData';
22
+ } from '../specs/types.js';
23
+ import { serviceDataArrayToMap } from './serviceData.js';
24
24
  import {
25
25
  normalizeCharacteristicSubscriptionType,
26
26
  stateToString,
27
27
  characteristicSubscriptionTypeToString
28
- } from './enums';
28
+ } from './enums.js';
29
29
 
30
30
  /**
31
31
  * Device wrapper that provides react-native-ble-plx compatibility