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
@@ -4,8 +4,9 @@
4
4
  * Creates BleManager instances with full react-native-ble-plx compatibility
5
5
  * by wrapping the Nitro implementation with compatibility shims
6
6
  */
7
- import type { BleManagerOptions, UUID, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, ScanOptions, NativeService, NativeCharacteristic, NativeDescriptor, LogLevel, Subscription } from './specs/types';
8
- import { DeviceWrapper } from './compatibility/deviceWrapper';
7
+ import type { BleManagerOptions, UUID, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, ScanOptions, NativeService, NativeCharacteristic, NativeDescriptor, LogLevel, Subscription } from './specs/types.js';
8
+ import { DeviceWrapper } from './compatibility/deviceWrapper.js';
9
+ import { State as PlxState, LogLevel as PlxLogLevel } from './compatibility/enums.js';
9
10
  /**
10
11
  * BleManager wrapper that provides react-native-ble-plx compatibility
11
12
  */
@@ -13,13 +14,13 @@ export declare class BleManagerCompat {
13
14
  private bleManager;
14
15
  constructor(options?: BleManagerOptions);
15
16
  destroy(): Promise<void>;
16
- setLogLevel(logLevel: LogLevel | string): Promise<string>;
17
- logLevel(): Promise<string>;
17
+ setLogLevel(logLevel: LogLevel | string): Promise<PlxLogLevel>;
18
+ logLevel(): Promise<PlxLogLevel>;
18
19
  cancelTransaction(transactionId: TransactionId): Promise<void>;
19
20
  enable(transactionId?: TransactionId): Promise<BleManagerCompat>;
20
21
  disable(transactionId?: TransactionId): Promise<BleManagerCompat>;
21
- state(): Promise<string>;
22
- onStateChange(listener: (newState: string) => void, emitCurrentState?: boolean): Subscription;
22
+ state(): Promise<PlxState>;
23
+ onStateChange(listener: (newState: PlxState) => void, emitCurrentState?: boolean): Subscription;
23
24
  startDeviceScan(uuids: UUID[] | null, options: ScanOptions | null, listener: (error: any | null, scannedDevice: DeviceWrapper | null) => void): Promise<void>;
24
25
  stopDeviceScan(): Promise<void>;
25
26
  connectToDevice(deviceIdentifier: DeviceId, options?: Partial<ConnectionOptions>): Promise<DeviceWrapper>;
@@ -4,9 +4,9 @@
4
4
  * Creates BleManager instances with full react-native-ble-plx compatibility
5
5
  * by wrapping the Nitro implementation with compatibility shims
6
6
  */
7
- import { createBleManager } from './BleManagerFactory';
8
- import { DeviceWrapper } from './compatibility/deviceWrapper';
9
- import { stateToString, logLevelToString, normalizeLogLevel, normalizeCharacteristicSubscriptionType } from './compatibility/enums';
7
+ import { createBleManager } from './BleManagerFactory.js';
8
+ import { DeviceWrapper } from './compatibility/deviceWrapper.js';
9
+ import { stateToString, logLevelToString, normalizeLogLevel, normalizeCharacteristicSubscriptionType } from './compatibility/enums.js';
10
10
  /**
11
11
  * BleManager wrapper that provides react-native-ble-plx compatibility
12
12
  */
@@ -1,5 +1,5 @@
1
- import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro';
2
- import type { BleManagerOptions } from './specs/types';
1
+ import type { BleManager as BleManagerInterface } from './specs/BleManager.nitro.js';
2
+ import type { BleManagerOptions } from './specs/types.js';
3
3
  /**
4
4
  * Creates a BleManager instance using Nitro Modules
5
5
  * This function maintains compatibility with react-native-ble-plx's BleManager constructor
@@ -46,4 +46,4 @@ export declare const ConnectionPriority: {
46
46
  readonly High: 1;
47
47
  readonly LowPower: 2;
48
48
  };
49
- export { BleErrorCode, BleATTErrorCode, BleIOSErrorCode, BleAndroidErrorCode } from '../specs/types';
49
+ export { BleErrorCode, BleATTErrorCode, BleIOSErrorCode, BleAndroidErrorCode } from '../specs/types.js';
@@ -47,4 +47,4 @@ export const ConnectionPriority = {
47
47
  LowPower: 2,
48
48
  };
49
49
  // Re-export all BLE error codes
50
- export { BleErrorCode, BleATTErrorCode, BleIOSErrorCode, BleAndroidErrorCode } from '../specs/types';
50
+ export { BleErrorCode, BleATTErrorCode, BleIOSErrorCode, BleAndroidErrorCode } from '../specs/types.js';
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * Wraps Nitro Device objects to provide the original react-native-ble-plx API
5
5
  */
6
- import type { Device as NitroDevice } from '../specs/Device.nitro';
7
- import type { UUID, Base64, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, NativeService, NativeCharacteristic, NativeDescriptor, Subscription } from '../specs/types';
6
+ import type { Device as NitroDevice } from '../specs/Device.nitro.js';
7
+ import type { UUID, Base64, DeviceId, TransactionId, ConnectionPriority, ConnectionOptions, NativeService, NativeCharacteristic, NativeDescriptor, Subscription } from '../specs/types.js';
8
8
  /**
9
9
  * Device wrapper that provides react-native-ble-plx compatibility
10
10
  * Maps Nitro device properties to the expected API surface
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * Wraps Nitro Device objects to provide the original react-native-ble-plx API
5
5
  */
6
- import { serviceDataArrayToMap } from './serviceData';
7
- import { normalizeCharacteristicSubscriptionType } from './enums';
6
+ import { serviceDataArrayToMap } from './serviceData.js';
7
+ import { normalizeCharacteristicSubscriptionType } from './enums.js';
8
8
  /**
9
9
  * Device wrapper that provides react-native-ble-plx compatibility
10
10
  * Maps Nitro device properties to the expected API surface
@@ -1,43 +1,38 @@
1
1
  /**
2
- * Enum compatibility layer
2
+ * React Native BLE Plx Compatible Enums and Types
3
3
  *
4
- * Provides conversion between Nitro's numeric enums and the original
5
- * string-based enums from react-native-ble-plx
4
+ * These match the exact types from react-native-ble-plx for drop-in compatibility.
5
+ * This module provides conversion between Nitro's numeric enums and react-native-ble-plx types.
6
6
  */
7
- import { State, LogLevel, CharacteristicSubscriptionType, RefreshGattMoment } from '../specs/types';
8
- export declare const StateString: {
9
- readonly 0: "Unknown";
10
- readonly 1: "Resetting";
11
- readonly 2: "Unsupported";
12
- readonly 3: "Unauthorized";
13
- readonly 4: "PoweredOff";
14
- readonly 5: "PoweredOn";
15
- };
16
- export declare const LogLevelString: {
17
- readonly 0: "None";
18
- readonly 1: "Verbose";
19
- readonly 2: "Debug";
20
- readonly 3: "Info";
21
- readonly 4: "Warning";
22
- readonly 5: "Error";
23
- };
24
- export declare const CharacteristicSubscriptionTypeString: {
25
- readonly 0: "notification";
26
- readonly 1: "indication";
27
- };
28
- export declare const RefreshGattMomentString: {
29
- readonly 0: "OnConnected";
30
- };
31
- export declare function stateToString(state: State): string;
32
- export declare function stringToState(stateString: string): State;
33
- export declare function logLevelToString(logLevel: LogLevel): string;
34
- export declare function stringToLogLevel(logLevelString: string): LogLevel;
35
- export declare function characteristicSubscriptionTypeToString(type: CharacteristicSubscriptionType): string;
36
- export declare function stringToCharacteristicSubscriptionType(typeString: string): CharacteristicSubscriptionType;
37
- export declare function refreshGattMomentToString(moment: RefreshGattMoment): 'OnConnected';
38
- export declare function stringToRefreshGattMoment(momentString: 'OnConnected'): RefreshGattMoment;
7
+ import { State as NitroState, LogLevel as NitroLogLevel, CharacteristicSubscriptionType as NitroCharacteristicSubscriptionType, RefreshGattMoment as NitroRefreshGattMoment } from '../specs/types.js';
8
+ export declare enum State {
9
+ Unknown = "Unknown",
10
+ Resetting = "Resetting",
11
+ Unsupported = "Unsupported",
12
+ Unauthorized = "Unauthorized",
13
+ PoweredOff = "PoweredOff",
14
+ PoweredOn = "PoweredOn"
15
+ }
16
+ export declare enum LogLevel {
17
+ None = "None",
18
+ Verbose = "Verbose",
19
+ Debug = "Debug",
20
+ Info = "Info",
21
+ Warning = "Warning",
22
+ Error = "Error"
23
+ }
24
+ export type CharacteristicSubscriptionType = 'notification' | 'indication';
25
+ export type RefreshGattMoment = 'OnConnected';
26
+ export declare function stateToString(state: NitroState): State;
27
+ export declare function logLevelToString(logLevel: NitroLogLevel): LogLevel;
28
+ export declare function characteristicSubscriptionTypeToString(type: NitroCharacteristicSubscriptionType): CharacteristicSubscriptionType;
29
+ export declare function refreshGattMomentToString(_moment: NitroRefreshGattMoment): RefreshGattMoment;
30
+ export declare function stringToState(stateString: State | string): NitroState;
31
+ export declare function stringToLogLevel(logLevelString: LogLevel | string): NitroLogLevel;
32
+ export declare function stringToCharacteristicSubscriptionType(typeString: CharacteristicSubscriptionType | string): NitroCharacteristicSubscriptionType;
33
+ export declare function stringToRefreshGattMoment(_momentString: RefreshGattMoment): NitroRefreshGattMoment;
34
+ export declare function normalizeState(state: NitroState | State | string): NitroState;
35
+ export declare function normalizeLogLevel(logLevel: NitroLogLevel | LogLevel | string): NitroLogLevel;
36
+ export declare function normalizeCharacteristicSubscriptionType(type: NitroCharacteristicSubscriptionType | CharacteristicSubscriptionType | string): NitroCharacteristicSubscriptionType;
37
+ export declare function normalizeRefreshGattMoment(_moment: NitroRefreshGattMoment | RefreshGattMoment | string): NitroRefreshGattMoment;
39
38
  export declare function isStringEnumValue(value: any): boolean;
40
- export declare function normalizeState(state: State | string): State;
41
- export declare function normalizeLogLevel(logLevel: LogLevel | string): LogLevel;
42
- export declare function normalizeCharacteristicSubscriptionType(type: CharacteristicSubscriptionType | 'notification' | 'indication'): CharacteristicSubscriptionType;
43
- export declare function normalizeRefreshGattMoment(moment: RefreshGattMoment | 'OnConnected'): RefreshGattMoment;
@@ -1,124 +1,159 @@
1
1
  /**
2
- * Enum compatibility layer
2
+ * React Native BLE Plx Compatible Enums and Types
3
3
  *
4
- * Provides conversion between Nitro's numeric enums and the original
5
- * string-based enums from react-native-ble-plx
4
+ * These match the exact types from react-native-ble-plx for drop-in compatibility.
5
+ * This module provides conversion between Nitro's numeric enums and react-native-ble-plx types.
6
6
  */
7
- import { State, LogLevel, CharacteristicSubscriptionType, RefreshGattMoment, } from '../specs/types';
8
- // String mappings for backward compatibility
9
- export const StateString = {
10
- [State.Unknown]: 'Unknown',
11
- [State.Resetting]: 'Resetting',
12
- [State.Unsupported]: 'Unsupported',
13
- [State.Unauthorized]: 'Unauthorized',
14
- [State.PoweredOff]: 'PoweredOff',
15
- [State.PoweredOn]: 'PoweredOn',
16
- };
17
- export const LogLevelString = {
18
- [LogLevel.None]: 'None',
19
- [LogLevel.Verbose]: 'Verbose',
20
- [LogLevel.Debug]: 'Debug',
21
- [LogLevel.Info]: 'Info',
22
- [LogLevel.Warning]: 'Warning',
23
- [LogLevel.Error]: 'Error',
24
- };
25
- export const CharacteristicSubscriptionTypeString = {
26
- [CharacteristicSubscriptionType.Notification]: 'notification',
27
- [CharacteristicSubscriptionType.Indication]: 'indication',
28
- };
29
- export const RefreshGattMomentString = {
30
- [RefreshGattMoment.OnConnected]: 'OnConnected',
31
- };
32
- // Reverse mappings for converting strings back to numeric enums
33
- const StringToState = {};
34
- const StringToLogLevel = {};
35
- const StringToCharacteristicSubscriptionType = {};
36
- const StringToRefreshGattMoment = {};
37
- // Build reverse mappings
38
- Object.entries(StateString).forEach(([num, str]) => {
39
- StringToState[str] = parseInt(num);
40
- });
41
- Object.entries(LogLevelString).forEach(([num, str]) => {
42
- StringToLogLevel[str] = parseInt(num);
43
- });
44
- Object.entries(CharacteristicSubscriptionTypeString).forEach(([num, str]) => {
45
- StringToCharacteristicSubscriptionType[str] = parseInt(num);
46
- });
47
- Object.entries(RefreshGattMomentString).forEach(([num, str]) => {
48
- StringToRefreshGattMoment[str] = parseInt(num);
49
- });
50
- // Conversion functions
7
+ // Import Nitro's numeric enums with aliases to avoid naming conflicts
8
+ import { State as NitroState, LogLevel as NitroLogLevel, CharacteristicSubscriptionType as NitroCharacteristicSubscriptionType, RefreshGattMoment as NitroRefreshGattMoment, } from '../specs/types.js';
9
+ // Define exact string enums and types matching react-native-ble-plx
10
+ export var State;
11
+ (function (State) {
12
+ State["Unknown"] = "Unknown";
13
+ State["Resetting"] = "Resetting";
14
+ State["Unsupported"] = "Unsupported";
15
+ State["Unauthorized"] = "Unauthorized";
16
+ State["PoweredOff"] = "PoweredOff";
17
+ State["PoweredOn"] = "PoweredOn";
18
+ })(State || (State = {}));
19
+ export var LogLevel;
20
+ (function (LogLevel) {
21
+ LogLevel["None"] = "None";
22
+ LogLevel["Verbose"] = "Verbose";
23
+ LogLevel["Debug"] = "Debug";
24
+ LogLevel["Info"] = "Info";
25
+ LogLevel["Warning"] = "Warning";
26
+ LogLevel["Error"] = "Error";
27
+ })(LogLevel || (LogLevel = {}));
28
+ // Conversion functions from Nitro numeric enums to react-native-ble-plx string enums/types
51
29
  export function stateToString(state) {
52
- return StateString[state] ?? 'Unknown';
30
+ const mapping = {
31
+ [NitroState.Unknown]: State.Unknown,
32
+ [NitroState.Resetting]: State.Resetting,
33
+ [NitroState.Unsupported]: State.Unsupported,
34
+ [NitroState.Unauthorized]: State.Unauthorized,
35
+ [NitroState.PoweredOff]: State.PoweredOff,
36
+ [NitroState.PoweredOn]: State.PoweredOn,
37
+ };
38
+ return mapping[state] ?? State.Unknown;
53
39
  }
40
+ export function logLevelToString(logLevel) {
41
+ const mapping = {
42
+ [NitroLogLevel.None]: LogLevel.None,
43
+ [NitroLogLevel.Verbose]: LogLevel.Verbose,
44
+ [NitroLogLevel.Debug]: LogLevel.Debug,
45
+ [NitroLogLevel.Info]: LogLevel.Info,
46
+ [NitroLogLevel.Warning]: LogLevel.Warning,
47
+ [NitroLogLevel.Error]: LogLevel.Error,
48
+ };
49
+ return mapping[logLevel] ?? LogLevel.None;
50
+ }
51
+ export function characteristicSubscriptionTypeToString(type) {
52
+ const mapping = {
53
+ [NitroCharacteristicSubscriptionType.Notification]: 'notification',
54
+ [NitroCharacteristicSubscriptionType.Indication]: 'indication',
55
+ };
56
+ return mapping[type] ?? 'notification';
57
+ }
58
+ export function refreshGattMomentToString(_moment) {
59
+ return 'OnConnected'; // Only one value exists
60
+ }
61
+ // Conversion functions from react-native-ble-plx string enums/types to Nitro numeric enums
54
62
  export function stringToState(stateString) {
55
- // Handle case insensitive lookup
56
- const lowerString = stateString.toLowerCase();
57
- for (const [key, value] of Object.entries(StringToState)) {
58
- if (key.toLowerCase() === lowerString) {
59
- return value;
60
- }
63
+ switch (stateString) {
64
+ case State.Unknown:
65
+ case 'Unknown':
66
+ return NitroState.Unknown;
67
+ case State.Resetting:
68
+ case 'Resetting':
69
+ return NitroState.Resetting;
70
+ case State.Unsupported:
71
+ case 'Unsupported':
72
+ return NitroState.Unsupported;
73
+ case State.Unauthorized:
74
+ case 'Unauthorized':
75
+ return NitroState.Unauthorized;
76
+ case State.PoweredOff:
77
+ case 'PoweredOff':
78
+ return NitroState.PoweredOff;
79
+ case State.PoweredOn:
80
+ case 'PoweredOn':
81
+ return NitroState.PoweredOn;
82
+ default:
83
+ return NitroState.Unknown;
61
84
  }
62
- return State.Unknown;
63
- }
64
- export function logLevelToString(logLevel) {
65
- return LogLevelString[logLevel] ?? 'None';
66
85
  }
67
86
  export function stringToLogLevel(logLevelString) {
68
- // Handle case insensitive lookup
69
- const lowerString = logLevelString.toLowerCase();
70
- for (const [key, value] of Object.entries(StringToLogLevel)) {
71
- if (key.toLowerCase() === lowerString) {
72
- return value;
73
- }
87
+ switch (logLevelString) {
88
+ case LogLevel.None:
89
+ case 'None':
90
+ return NitroLogLevel.None;
91
+ case LogLevel.Verbose:
92
+ case 'Verbose':
93
+ return NitroLogLevel.Verbose;
94
+ case LogLevel.Debug:
95
+ case 'Debug':
96
+ return NitroLogLevel.Debug;
97
+ case LogLevel.Info:
98
+ case 'Info':
99
+ return NitroLogLevel.Info;
100
+ case LogLevel.Warning:
101
+ case 'Warning':
102
+ return NitroLogLevel.Warning;
103
+ case LogLevel.Error:
104
+ case 'Error':
105
+ return NitroLogLevel.Error;
106
+ default:
107
+ return NitroLogLevel.None;
74
108
  }
75
- return LogLevel.None;
76
- }
77
- export function characteristicSubscriptionTypeToString(type) {
78
- return CharacteristicSubscriptionTypeString[type] ?? 'notification';
79
109
  }
80
110
  export function stringToCharacteristicSubscriptionType(typeString) {
81
- // Handle case insensitive lookup
82
- const lowerString = typeString.toLowerCase();
83
- for (const [key, value] of Object.entries(StringToCharacteristicSubscriptionType)) {
84
- if (key.toLowerCase() === lowerString) {
85
- return value;
86
- }
111
+ switch (typeString) {
112
+ case 'notification':
113
+ return NitroCharacteristicSubscriptionType.Notification;
114
+ case 'indication':
115
+ return NitroCharacteristicSubscriptionType.Indication;
116
+ default:
117
+ return NitroCharacteristicSubscriptionType.Notification;
87
118
  }
88
- return CharacteristicSubscriptionType.Notification;
89
119
  }
90
- export function refreshGattMomentToString(moment) {
91
- return RefreshGattMomentString[moment];
92
- }
93
- export function stringToRefreshGattMoment(momentString) {
94
- return StringToRefreshGattMoment[momentString] ?? RefreshGattMoment.OnConnected;
95
- }
96
- // Helper function to detect if a value is a string enum vs numeric enum
97
- export function isStringEnumValue(value) {
98
- return typeof value === 'string';
120
+ export function stringToRefreshGattMoment(_momentString) {
121
+ return NitroRefreshGattMoment.OnConnected;
99
122
  }
100
123
  // Generic converter that handles both string and numeric enum values
101
124
  export function normalizeState(state) {
102
125
  if (typeof state === 'string') {
103
126
  return stringToState(state);
104
127
  }
105
- return state;
128
+ // If it's already a NitroState (numeric), return as-is
129
+ if (typeof state === 'number') {
130
+ return state;
131
+ }
132
+ // If it's a string State enum value, convert it
133
+ return stringToState(state);
106
134
  }
107
135
  export function normalizeLogLevel(logLevel) {
108
136
  if (typeof logLevel === 'string') {
109
137
  return stringToLogLevel(logLevel);
110
138
  }
111
- return logLevel;
139
+ // If it's already a NitroLogLevel (numeric), return as-is
140
+ if (typeof logLevel === 'number') {
141
+ return logLevel;
142
+ }
143
+ // If it's a string LogLevel enum value, convert it
144
+ return stringToLogLevel(logLevel);
112
145
  }
113
146
  export function normalizeCharacteristicSubscriptionType(type) {
114
147
  if (typeof type === 'string') {
115
148
  return stringToCharacteristicSubscriptionType(type);
116
149
  }
150
+ // If it's already a NitroCharacteristicSubscriptionType (numeric), return as-is
117
151
  return type;
118
152
  }
119
- export function normalizeRefreshGattMoment(moment) {
120
- if (typeof moment === 'string') {
121
- return stringToRefreshGattMoment(moment);
122
- }
123
- return moment;
153
+ export function normalizeRefreshGattMoment(_moment) {
154
+ return NitroRefreshGattMoment.OnConnected; // Only one value exists
155
+ }
156
+ // Helper function to detect if a value is a string enum vs numeric enum
157
+ export function isStringEnumValue(value) {
158
+ return typeof value === 'string';
124
159
  }
@@ -5,7 +5,8 @@
5
5
  * 100% API compatibility with react-native-ble-plx while working with
6
6
  * Nitro's type system constraints.
7
7
  */
8
- export * from './serviceData';
9
- export * from './deviceWrapper';
10
- export * from './constants';
11
- export { stateToString, stringToState, logLevelToString, stringToLogLevel, characteristicSubscriptionTypeToString, stringToCharacteristicSubscriptionType, normalizeState, normalizeLogLevel, normalizeCharacteristicSubscriptionType, } from './enums';
8
+ export * from './serviceData.js';
9
+ export * from './deviceWrapper.js';
10
+ export * from './constants.js';
11
+ export { stateToString, stringToState, logLevelToString, stringToLogLevel, characteristicSubscriptionTypeToString, stringToCharacteristicSubscriptionType, normalizeState, normalizeLogLevel, normalizeCharacteristicSubscriptionType, State, LogLevel } from './enums.js';
12
+ export type { CharacteristicSubscriptionType, RefreshGattMoment } from './enums.js';
@@ -5,8 +5,8 @@
5
5
  * 100% API compatibility with react-native-ble-plx while working with
6
6
  * Nitro's type system constraints.
7
7
  */
8
- export * from './serviceData';
9
- export * from './deviceWrapper';
10
- export * from './constants';
11
- // Explicitly export enum utilities to avoid conflicts
12
- export { stateToString, stringToState, logLevelToString, stringToLogLevel, characteristicSubscriptionTypeToString, stringToCharacteristicSubscriptionType, normalizeState, normalizeLogLevel, normalizeCharacteristicSubscriptionType, } from './enums';
8
+ export * from './serviceData.js';
9
+ export * from './deviceWrapper.js';
10
+ export * from './constants.js';
11
+ // Explicitly export enum utilities and enums to avoid conflicts
12
+ export { stateToString, stringToState, logLevelToString, stringToLogLevel, characteristicSubscriptionTypeToString, stringToCharacteristicSubscriptionType, normalizeState, normalizeLogLevel, normalizeCharacteristicSubscriptionType, State, LogLevel } from './enums.js';
@@ -4,7 +4,7 @@
4
4
  * Provides conversion between Nitro's structured ServiceDataEntry[] format
5
5
  * and the original { [uuid: string]: Base64 } format from react-native-ble-plx
6
6
  */
7
- import type { ServiceDataEntry, UUID, Base64 } from '../specs/types';
7
+ import type { ServiceDataEntry, UUID, Base64 } from '../specs/types.js';
8
8
  /**
9
9
  * Convert ServiceDataEntry array to the original index signature format
10
10
  */
@@ -1,5 +1,5 @@
1
- import { BleErrorCode, BleATTErrorCode, BleIOSErrorCode, BleAndroidErrorCode } from '../specs/types';
2
- import type { NativeBleError, BleErrorCodeMessageMapping } from '../specs/types';
1
+ import { BleErrorCode, BleATTErrorCode, BleIOSErrorCode, BleAndroidErrorCode } from '../specs/types.js';
2
+ import type { NativeBleError, BleErrorCodeMessageMapping } from '../specs/types.js';
3
3
  /**
4
4
  * Default error messages for BLE error codes
5
5
  * Maintains compatibility with react-native-ble-plx error messages
@@ -1,4 +1,4 @@
1
- import { BleErrorCode } from '../specs/types';
1
+ import { BleErrorCode } from '../specs/types.js';
2
2
  /**
3
3
  * Default error messages for BLE error codes
4
4
  * Maintains compatibility with react-native-ble-plx error messages
package/lib/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- export * from './compatibility/constants';
2
- export * from './utils';
3
- export { BleManagerCompat as BleManager, createBleManagerCompat as createBleManager } from './BleManagerCompatFactory';
4
- export * from './errors/BleError';
5
- export { DeviceWrapper as Device } from './compatibility/deviceWrapper';
6
- export type { BleManagerOptions, ScanOptions, ConnectionOptions, NativeBleError, NativeDevice, NativeService, NativeCharacteristic, NativeDescriptor, Subscription } from './specs/types';
7
- export { fullUUID } from './utils/uuid';
1
+ export * from './compatibility/constants.js';
2
+ export * from './utils/index.js';
3
+ export { BleManagerCompat as BleManager, createBleManagerCompat as createBleManager } from './BleManagerCompatFactory.js';
4
+ export * from './errors/BleError.js';
5
+ export { DeviceWrapper as Device } from './compatibility/deviceWrapper.js';
6
+ export type { BleManagerOptions, ScanOptions, ConnectionOptions, NativeBleError, NativeDevice, NativeService, NativeCharacteristic, NativeDescriptor, Subscription } from './specs/types.js';
7
+ export { State, LogLevel } from './compatibility/enums.js';
8
+ export type { CharacteristicSubscriptionType, RefreshGattMoment } from './compatibility/enums.js';
9
+ export { fullUUID } from './utils/uuid.js';
package/lib/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  // Export compatibility layer types and constants
2
- export * from './compatibility/constants';
2
+ export * from './compatibility/constants.js';
3
3
  // Export utility functions
4
- export * from './utils';
4
+ export * from './utils/index.js';
5
5
  // Export the main BleManager instance with compatibility wrapper
6
- export { BleManagerCompat as BleManager, createBleManagerCompat as createBleManager } from './BleManagerCompatFactory';
6
+ export { BleManagerCompat as BleManager, createBleManagerCompat as createBleManager } from './BleManagerCompatFactory.js';
7
7
  // Export error handling utilities
8
- export * from './errors/BleError';
8
+ export * from './errors/BleError.js';
9
9
  // Export device wrapper for compatibility
10
- export { DeviceWrapper as Device } from './compatibility/deviceWrapper';
10
+ export { DeviceWrapper as Device } from './compatibility/deviceWrapper.js';
11
+ // Export react-native-ble-plx compatible enum types (drop-in replacement)
12
+ export { State, LogLevel } from './compatibility/enums.js';
11
13
  // Re-export react-native-ble-plx compatible API
12
- export { fullUUID } from './utils/uuid';
14
+ export { fullUUID } from './utils/uuid.js';
@@ -1,5 +1,5 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { State, LogLevel, UUID, DeviceId, TransactionId, ConnectionPriority, ScanOptions, ConnectionOptions, StateListener, DeviceScanListener, DeviceDisconnectedListener, CharacteristicMonitorListener, CharacteristicSubscriptionType, NativeDevice, NativeService, NativeCharacteristic, NativeDescriptor, Base64, Subscription } from './types';
2
+ import type { State, LogLevel, UUID, DeviceId, TransactionId, ConnectionPriority, ScanOptions, ConnectionOptions, StateListener, DeviceScanListener, DeviceDisconnectedListener, CharacteristicMonitorListener, CharacteristicSubscriptionType, NativeDevice, NativeService, NativeCharacteristic, NativeDescriptor, Base64, Subscription } from './types.js';
3
3
  export interface BleManager extends HybridObject<{
4
4
  ios: 'swift';
5
5
  android: 'kotlin';
@@ -1,5 +1,5 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { Identifier, UUID, DeviceId, Base64, TransactionId, CharacteristicSubscriptionType, NativeDescriptor, CharacteristicMonitorListener, Subscription } from './types';
2
+ import type { Identifier, UUID, DeviceId, Base64, TransactionId, CharacteristicSubscriptionType, NativeDescriptor, CharacteristicMonitorListener, Subscription } from './types.js';
3
3
  export interface Characteristic extends HybridObject<{
4
4
  ios: 'swift';
5
5
  android: 'kotlin';
@@ -1,5 +1,5 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { Identifier, UUID, DeviceId, Base64, TransactionId } from './types';
2
+ import type { Identifier, UUID, DeviceId, Base64, TransactionId } from './types.js';
3
3
  export interface Descriptor extends HybridObject<{
4
4
  ios: 'swift';
5
5
  android: 'kotlin';
@@ -1,5 +1,5 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { DeviceId, UUID, Base64, TransactionId, ConnectionPriority, ConnectionOptions, CharacteristicSubscriptionType, ServiceDataEntry, NativeDevice, NativeService, NativeCharacteristic, NativeDescriptor, DeviceDisconnectedListener, CharacteristicMonitorListener, Subscription } from './types';
2
+ import type { DeviceId, UUID, Base64, TransactionId, ConnectionPriority, ConnectionOptions, CharacteristicSubscriptionType, ServiceDataEntry, NativeDevice, NativeService, NativeCharacteristic, NativeDescriptor, DeviceDisconnectedListener, CharacteristicMonitorListener, Subscription } from './types.js';
3
3
  export interface Device extends HybridObject<{
4
4
  ios: 'swift';
5
5
  android: 'kotlin';
@@ -1,5 +1,5 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules';
2
- import type { Identifier, UUID, DeviceId, Base64, TransactionId, CharacteristicSubscriptionType, NativeCharacteristic, NativeDescriptor, CharacteristicMonitorListener, Subscription } from './types';
2
+ import type { Identifier, UUID, DeviceId, Base64, TransactionId, CharacteristicSubscriptionType, NativeCharacteristic, NativeDescriptor, CharacteristicMonitorListener, Subscription } from './types.js';
3
3
  export interface Service extends HybridObject<{
4
4
  ios: 'swift';
5
5
  android: 'kotlin';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ble-nitro",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-beta.0",
4
4
  "description": "High-performance React Native BLE library built on Nitro Modules - drop-in replacement for react-native-ble-plx",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -9,10 +9,11 @@
9
9
  "exports": {
10
10
  ".": {
11
11
  "react-native": "./src/index.ts",
12
+ "typescript": "./src/index.ts",
12
13
  "import": "./lib/index.js",
13
14
  "require": "./lib/index.js",
14
15
  "types": "./lib/index.d.ts",
15
- "default": "./lib/index.js"
16
+ "default": "./src/index.ts"
16
17
  },
17
18
  "./plugin": {
18
19
  "import": "./plugin/build/index.js",