react-native-sdk-ble-middleware-v2 0.1.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 +20 -0
- package/Middleware.podspec +21 -0
- package/README.md +187 -0
- package/android/build.gradle +77 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/middleware/MiddlewareModule.kt +23 -0
- package/android/src/main/java/com/middleware/MiddlewarePackage.kt +33 -0
- package/ios/Middleware.h +5 -0
- package/ios/Middleware.mm +21 -0
- package/lib/module/NativeMiddleware.js +3 -0
- package/lib/module/NativeMiddleware.js.map +1 -0
- package/lib/module/context/BLEContext.js +390 -0
- package/lib/module/context/BLEContext.js.map +1 -0
- package/lib/module/hooks/index.js +2 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useBLE.js +167 -0
- package/lib/module/hooks/useBLE.js.map +1 -0
- package/lib/module/index.js +12 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/services/BLEMiddleware.js +252 -0
- package/lib/module/services/BLEMiddleware.js.map +1 -0
- package/lib/module/services/MockBLEManager.js +94 -0
- package/lib/module/services/MockBLEManager.js.map +1 -0
- package/lib/module/services/index.js +2 -0
- package/lib/module/services/index.js.map +1 -0
- package/lib/module/types/index.js +44 -0
- package/lib/module/types/index.js.map +1 -0
- package/package.json +179 -0
- package/react-native.config.js +8 -0
- package/src/NativeMiddleware.ts +7 -0
- package/src/context/BLEContext.tsx +487 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useBLE.ts +190 -0
- package/src/index.tsx +21 -0
- package/src/services/BLEMiddleware.ts +291 -0
- package/src/services/MockBLEManager.ts +96 -0
- package/src/services/index.ts +1 -0
- package/src/types/index.ts +97 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
import { Platform, PermissionsAndroid } from 'react-native';
|
|
5
|
+
/**
|
|
6
|
+
* BLEMiddleware - Wrapper class for react-native-sdk-ble
|
|
7
|
+
* Handles all BLE operations and event management
|
|
8
|
+
*/
|
|
9
|
+
class BLEMiddleware {
|
|
10
|
+
// Default role
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
_defineProperty(this, "bleManager", null);
|
|
14
|
+
_defineProperty(this, "isInitialized", false);
|
|
15
|
+
_defineProperty(this, "initializationPromise", null);
|
|
16
|
+
_defineProperty(this, "currentUserRole", 'patient');
|
|
17
|
+
// Start initialization immediately
|
|
18
|
+
this.initializationPromise = this.initializeBLEManager();
|
|
19
|
+
}
|
|
20
|
+
async initializeBLEManager() {
|
|
21
|
+
if (this.isInitialized) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
// Import the real BLE SDK
|
|
26
|
+
const BleModule = require('react-native-sdk-ble');
|
|
27
|
+
this.bleManager = BleModule.default || BleModule;
|
|
28
|
+
this.isInitialized = true;
|
|
29
|
+
console.log('✅ BLE Manager initialized successfully');
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error('❌ Failed to initialize BLE Manager:', error);
|
|
32
|
+
console.error('Make sure react-native-sdk-ble is installed in your app as a peer dependency');
|
|
33
|
+
console.error('Run: npm install react-native-sdk-ble');
|
|
34
|
+
this.isInitialized = false;
|
|
35
|
+
throw new Error('react-native-sdk-ble is required but not installed. Please install it in your app: npm install react-native-sdk-ble');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async ensureInitialized() {
|
|
39
|
+
// Wait for initialization to complete
|
|
40
|
+
if (this.initializationPromise) {
|
|
41
|
+
await this.initializationPromise;
|
|
42
|
+
}
|
|
43
|
+
if (!this.isInitialized || !this.bleManager) {
|
|
44
|
+
throw new Error('BLE Manager is not initialized. Please ensure react-native-sdk-ble is installed: npm install react-native-sdk-ble');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Check if Bluetooth is enabled on the device
|
|
50
|
+
*/
|
|
51
|
+
async isBluetoothEnabled() {
|
|
52
|
+
await this.ensureInitialized();
|
|
53
|
+
return await this.bleManager.isBluetoothEnabled();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Request necessary permissions for BLE operations
|
|
58
|
+
*/
|
|
59
|
+
async requestPermissions() {
|
|
60
|
+
if (Platform.OS === 'android') {
|
|
61
|
+
const granted = await PermissionsAndroid.requestMultiple([PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN, PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT, PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION]);
|
|
62
|
+
const allGranted = Object.values(granted).every(status => status === PermissionsAndroid.RESULTS.GRANTED);
|
|
63
|
+
if (!allGranted) {
|
|
64
|
+
console.warn('Not all BLE permissions were granted');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
await this.ensureInitialized();
|
|
68
|
+
await this.bleManager.requestPermissions();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Start scanning for BLE devices
|
|
73
|
+
*/
|
|
74
|
+
async startScan(options = {}) {
|
|
75
|
+
await this.ensureInitialized();
|
|
76
|
+
const defaultOptions = {
|
|
77
|
+
timeout: 10000,
|
|
78
|
+
allowDuplicates: false,
|
|
79
|
+
...options
|
|
80
|
+
};
|
|
81
|
+
await this.bleManager.startScan(defaultOptions);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Stop scanning for BLE devices
|
|
86
|
+
*/
|
|
87
|
+
async stopScan() {
|
|
88
|
+
await this.ensureInitialized();
|
|
89
|
+
await this.bleManager.stopScan();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Connect to a BLE device
|
|
94
|
+
*/
|
|
95
|
+
async connect(deviceId) {
|
|
96
|
+
await this.ensureInitialized();
|
|
97
|
+
await this.bleManager.connect(deviceId);
|
|
98
|
+
|
|
99
|
+
// Automatically send user role command after connection
|
|
100
|
+
await this.sendUserRoleCommand();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Send user role command to device
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
async sendUserRoleCommand() {
|
|
108
|
+
try {
|
|
109
|
+
await this.ensureInitialized();
|
|
110
|
+
if (this.bleManager && this.bleManager.setUserRole) {
|
|
111
|
+
await this.bleManager.setUserRole(this.currentUserRole);
|
|
112
|
+
console.log(`✅ User role '${this.currentUserRole}' sent to device`);
|
|
113
|
+
} else {
|
|
114
|
+
console.warn('⚠️ setUserRole method not available in BLE SDK');
|
|
115
|
+
}
|
|
116
|
+
} catch (error) {
|
|
117
|
+
console.warn(`⚠️ Failed to send user role:`, error);
|
|
118
|
+
// Don't throw - allow connection to proceed even if role command fails
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Disconnect from a BLE device
|
|
124
|
+
*/
|
|
125
|
+
async disconnect(deviceId) {
|
|
126
|
+
await this.ensureInitialized();
|
|
127
|
+
await this.bleManager.disconnect(deviceId);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Register event listener
|
|
132
|
+
*/
|
|
133
|
+
on(event, callback) {
|
|
134
|
+
// For event listeners, we check synchronously but warn if not ready
|
|
135
|
+
if (!this.isInitialized || !this.bleManager) {
|
|
136
|
+
var _this$initializationP;
|
|
137
|
+
console.warn(`BLE Manager not ready yet. Event listener for '${event}' will be registered once initialization completes.`);
|
|
138
|
+
// Queue the event listener to be registered after initialization
|
|
139
|
+
(_this$initializationP = this.initializationPromise) === null || _this$initializationP === void 0 || _this$initializationP.then(() => {
|
|
140
|
+
if (this.isInitialized && this.bleManager) {
|
|
141
|
+
this.bleManager.on(event, callback);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.bleManager.on(event, callback);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Remove all event listeners
|
|
151
|
+
*/
|
|
152
|
+
removeAllListeners() {
|
|
153
|
+
if (this.isInitialized && this.bleManager) {
|
|
154
|
+
this.bleManager.removeAllListeners();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Get the underlying BLE manager instance
|
|
160
|
+
* Use with caution - prefer using the wrapper methods
|
|
161
|
+
*/
|
|
162
|
+
async getRawManager() {
|
|
163
|
+
await this.ensureInitialized();
|
|
164
|
+
return this.bleManager;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Check if the BLE manager is ready
|
|
169
|
+
*/
|
|
170
|
+
isReady() {
|
|
171
|
+
return this.isInitialized && this.bleManager !== null;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Wait for initialization to complete
|
|
176
|
+
*/
|
|
177
|
+
async waitForInitialization() {
|
|
178
|
+
if (this.initializationPromise) {
|
|
179
|
+
await this.initializationPromise;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Read characteristic value
|
|
185
|
+
*/
|
|
186
|
+
async readCharacteristic(deviceId, serviceUuid, characteristicUuid) {
|
|
187
|
+
await this.ensureInitialized();
|
|
188
|
+
return await this.bleManager.readCharacteristic(deviceId, serviceUuid, characteristicUuid);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Write characteristic value
|
|
193
|
+
*/
|
|
194
|
+
async writeCharacteristic(deviceId, serviceUuid, characteristicUuid, data, options) {
|
|
195
|
+
await this.ensureInitialized();
|
|
196
|
+
await this.bleManager.writeCharacteristic(deviceId, serviceUuid, characteristicUuid, data, options);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Start infusion - Sends command A4 01 01
|
|
201
|
+
*/
|
|
202
|
+
async startInfusion(deviceId) {
|
|
203
|
+
await this.ensureInitialized();
|
|
204
|
+
await this.bleManager.startInfusion(deviceId);
|
|
205
|
+
console.log('✅ Infusion started - Command A4 01 01 sent');
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Stop infusion - Sends command A4 01 00
|
|
210
|
+
*/
|
|
211
|
+
async stopInfusion(deviceId) {
|
|
212
|
+
await this.ensureInitialized();
|
|
213
|
+
await this.bleManager.stopInfusion(deviceId);
|
|
214
|
+
console.log('✅ Infusion stopped - Command A4 01 00 sent');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Set infusion level - Sends command A5 01 0{level}
|
|
219
|
+
* @param deviceId - The device ID to send the command to
|
|
220
|
+
* @param level - Infusion level (1-9)
|
|
221
|
+
*/
|
|
222
|
+
async setInfusionLevel(deviceId, level) {
|
|
223
|
+
await this.ensureInitialized();
|
|
224
|
+
if (level < 1 || level > 5) {
|
|
225
|
+
throw new Error('Infusion level must be between 1 and 5');
|
|
226
|
+
}
|
|
227
|
+
await this.bleManager.setInfusionLevel(deviceId, level);
|
|
228
|
+
console.log(`✅ Infusion level set to ${level} - Command A5 01 0${level} sent`);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Set user role
|
|
233
|
+
* @param role - The user role to set ('patient', 'nurse', or 'engineer')
|
|
234
|
+
*/
|
|
235
|
+
setUserRole(role) {
|
|
236
|
+
this.currentUserRole = role;
|
|
237
|
+
console.log(`✅ User role set to: ${role}`);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Get current user role
|
|
242
|
+
* @returns The current user role
|
|
243
|
+
*/
|
|
244
|
+
getUserRole() {
|
|
245
|
+
return this.currentUserRole;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// Export singleton instance
|
|
250
|
+
export const bleMiddleware = new BLEMiddleware();
|
|
251
|
+
export default bleMiddleware;
|
|
252
|
+
//# sourceMappingURL=BLEMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","PermissionsAndroid","BLEMiddleware","constructor","_defineProperty","initializationPromise","initializeBLEManager","isInitialized","BleModule","require","bleManager","default","console","log","error","Error","ensureInitialized","isBluetoothEnabled","requestPermissions","OS","granted","requestMultiple","PERMISSIONS","BLUETOOTH_SCAN","BLUETOOTH_CONNECT","ACCESS_FINE_LOCATION","allGranted","Object","values","every","status","RESULTS","GRANTED","warn","startScan","options","defaultOptions","timeout","allowDuplicates","stopScan","connect","deviceId","sendUserRoleCommand","setUserRole","currentUserRole","disconnect","on","event","callback","_this$initializationP","then","removeAllListeners","getRawManager","isReady","waitForInitialization","readCharacteristic","serviceUuid","characteristicUuid","writeCharacteristic","data","startInfusion","stopInfusion","setInfusionLevel","level","role","getUserRole","bleMiddleware"],"sources":["BLEMiddleware.ts"],"sourcesContent":["import { Platform, PermissionsAndroid } from 'react-native';\nimport type { ScanOptions, BLEEventType, UserRole } from '../types';\n\n/**\n * BLEMiddleware - Wrapper class for react-native-sdk-ble\n * Handles all BLE operations and event management\n */\nclass BLEMiddleware {\n private bleManager: any = null;\n private isInitialized: boolean = false;\n private initializationPromise: Promise<void> | null = null;\n private currentUserRole: UserRole = 'patient'; // Default role\n\n constructor() {\n // Start initialization immediately\n this.initializationPromise = this.initializeBLEManager();\n }\n\n private async initializeBLEManager(): Promise<void> {\n if (this.isInitialized) {\n return;\n }\n\n try {\n // Import the real BLE SDK\n const BleModule = require('react-native-sdk-ble');\n this.bleManager = BleModule.default || BleModule;\n this.isInitialized = true;\n console.log('✅ BLE Manager initialized successfully');\n } catch (error) {\n console.error('❌ Failed to initialize BLE Manager:', error);\n console.error(\n 'Make sure react-native-sdk-ble is installed in your app as a peer dependency'\n );\n console.error('Run: npm install react-native-sdk-ble');\n this.isInitialized = false;\n throw new Error(\n 'react-native-sdk-ble is required but not installed. Please install it in your app: npm install react-native-sdk-ble'\n );\n }\n }\n\n private async ensureInitialized(): Promise<void> {\n // Wait for initialization to complete\n if (this.initializationPromise) {\n await this.initializationPromise;\n }\n\n if (!this.isInitialized || !this.bleManager) {\n throw new Error(\n 'BLE Manager is not initialized. Please ensure react-native-sdk-ble is installed: npm install react-native-sdk-ble'\n );\n }\n }\n\n /**\n * Check if Bluetooth is enabled on the device\n */\n async isBluetoothEnabled(): Promise<boolean> {\n await this.ensureInitialized();\n return await this.bleManager.isBluetoothEnabled();\n }\n\n /**\n * Request necessary permissions for BLE operations\n */\n async requestPermissions(): Promise<void> {\n if (Platform.OS === 'android') {\n const granted = await PermissionsAndroid.requestMultiple([\n PermissionsAndroid.PERMISSIONS.BLUETOOTH_SCAN,\n PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,\n PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,\n ]);\n\n const allGranted = Object.values(granted).every(\n (status) => status === PermissionsAndroid.RESULTS.GRANTED\n );\n\n if (!allGranted) {\n console.warn('Not all BLE permissions were granted');\n }\n }\n\n await this.ensureInitialized();\n await this.bleManager.requestPermissions();\n }\n\n /**\n * Start scanning for BLE devices\n */\n async startScan(options: ScanOptions = {}): Promise<void> {\n await this.ensureInitialized();\n const defaultOptions = {\n timeout: 10000,\n allowDuplicates: false,\n ...options,\n };\n await this.bleManager.startScan(defaultOptions);\n }\n\n /**\n * Stop scanning for BLE devices\n */\n async stopScan(): Promise<void> {\n await this.ensureInitialized();\n await this.bleManager.stopScan();\n }\n\n /**\n * Connect to a BLE device\n */\n async connect(deviceId: string): Promise<void> {\n await this.ensureInitialized();\n await this.bleManager.connect(deviceId);\n\n // Automatically send user role command after connection\n await this.sendUserRoleCommand();\n }\n\n /**\n * Send user role command to device\n * @private\n */\n private async sendUserRoleCommand(): Promise<void> {\n try {\n await this.ensureInitialized();\n if (this.bleManager && this.bleManager.setUserRole) {\n await this.bleManager.setUserRole(this.currentUserRole);\n console.log(`✅ User role '${this.currentUserRole}' sent to device`);\n } else {\n console.warn('⚠️ setUserRole method not available in BLE SDK');\n }\n } catch (error) {\n console.warn(`⚠️ Failed to send user role:`, error);\n // Don't throw - allow connection to proceed even if role command fails\n }\n }\n\n /**\n * Disconnect from a BLE device\n */\n async disconnect(deviceId: string): Promise<void> {\n await this.ensureInitialized();\n await this.bleManager.disconnect(deviceId);\n }\n\n /**\n * Register event listener\n */\n on(event: BLEEventType, callback: (data: any) => void): void {\n // For event listeners, we check synchronously but warn if not ready\n if (!this.isInitialized || !this.bleManager) {\n console.warn(\n `BLE Manager not ready yet. Event listener for '${event}' will be registered once initialization completes.`\n );\n // Queue the event listener to be registered after initialization\n this.initializationPromise?.then(() => {\n if (this.isInitialized && this.bleManager) {\n this.bleManager.on(event, callback);\n }\n });\n return;\n }\n this.bleManager.on(event, callback);\n }\n\n /**\n * Remove all event listeners\n */\n removeAllListeners(): void {\n if (this.isInitialized && this.bleManager) {\n this.bleManager.removeAllListeners();\n }\n }\n\n /**\n * Get the underlying BLE manager instance\n * Use with caution - prefer using the wrapper methods\n */\n async getRawManager(): Promise<any> {\n await this.ensureInitialized();\n return this.bleManager;\n }\n\n /**\n * Check if the BLE manager is ready\n */\n isReady(): boolean {\n return this.isInitialized && this.bleManager !== null;\n }\n\n /**\n * Wait for initialization to complete\n */\n async waitForInitialization(): Promise<void> {\n if (this.initializationPromise) {\n await this.initializationPromise;\n }\n }\n\n /**\n * Read characteristic value\n */\n async readCharacteristic(\n deviceId: string,\n serviceUuid: string,\n characteristicUuid: string\n ): Promise<any> {\n await this.ensureInitialized();\n return await this.bleManager.readCharacteristic(\n deviceId,\n serviceUuid,\n characteristicUuid\n );\n }\n\n /**\n * Write characteristic value\n */\n async writeCharacteristic(\n deviceId: string,\n serviceUuid: string,\n characteristicUuid: string,\n data: string,\n options?: { withResponse?: boolean }\n ): Promise<void> {\n await this.ensureInitialized();\n await this.bleManager.writeCharacteristic(\n deviceId,\n serviceUuid,\n characteristicUuid,\n data,\n options\n );\n }\n\n /**\n * Start infusion - Sends command A4 01 01\n */\n async startInfusion(deviceId: string): Promise<void> {\n await this.ensureInitialized();\n await this.bleManager.startInfusion(deviceId);\n console.log('✅ Infusion started - Command A4 01 01 sent');\n }\n\n /**\n * Stop infusion - Sends command A4 01 00\n */\n async stopInfusion(deviceId: string): Promise<void> {\n await this.ensureInitialized();\n await this.bleManager.stopInfusion(deviceId);\n console.log('✅ Infusion stopped - Command A4 01 00 sent');\n }\n\n /**\n * Set infusion level - Sends command A5 01 0{level}\n * @param deviceId - The device ID to send the command to\n * @param level - Infusion level (1-9)\n */\n async setInfusionLevel(deviceId: string, level: number): Promise<void> {\n await this.ensureInitialized();\n if (level < 1 || level > 5) {\n throw new Error('Infusion level must be between 1 and 5');\n }\n await this.bleManager.setInfusionLevel(deviceId, level);\n console.log(\n `✅ Infusion level set to ${level} - Command A5 01 0${level} sent`\n );\n }\n\n /**\n * Set user role\n * @param role - The user role to set ('patient', 'nurse', or 'engineer')\n */\n setUserRole(role: UserRole): void {\n this.currentUserRole = role;\n console.log(`✅ User role set to: ${role}`);\n }\n\n /**\n * Get current user role\n * @returns The current user role\n */\n getUserRole(): UserRole {\n return this.currentUserRole;\n }\n}\n\n// Export singleton instance\nexport const bleMiddleware = new BLEMiddleware();\nexport default bleMiddleware;\n"],"mappings":";;;AAAA,SAASA,QAAQ,EAAEC,kBAAkB,QAAQ,cAAc;A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}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
/**
|
|
5
|
+
* Mock BLE Manager for development/testing
|
|
6
|
+
* Replace this with the actual react-native-sdk-ble package
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
class MockBLEManager {
|
|
10
|
+
constructor() {
|
|
11
|
+
_defineProperty(this, "listeners", new Map());
|
|
12
|
+
}
|
|
13
|
+
async isBluetoothEnabled() {
|
|
14
|
+
console.log('📱 Mock: Checking Bluetooth status...');
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
async requestPermissions() {
|
|
18
|
+
console.log('📱 Mock: Requesting permissions...');
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
async startScan(options) {
|
|
22
|
+
console.log('📱 Mock: Starting scan with options:', options);
|
|
23
|
+
|
|
24
|
+
// Simulate finding devices
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
this.emit('scanResult', {
|
|
27
|
+
device: {
|
|
28
|
+
id: 'mock-device-1',
|
|
29
|
+
name: 'Mock BLE Device 1',
|
|
30
|
+
rssi: -65
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}, 1000);
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
this.emit('scanResult', {
|
|
36
|
+
device: {
|
|
37
|
+
id: 'mock-device-2',
|
|
38
|
+
name: 'Mock BLE Device 2',
|
|
39
|
+
rssi: -75
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}, 2000);
|
|
43
|
+
return Promise.resolve();
|
|
44
|
+
}
|
|
45
|
+
async stopScan() {
|
|
46
|
+
console.log('📱 Mock: Stopping scan...');
|
|
47
|
+
return Promise.resolve();
|
|
48
|
+
}
|
|
49
|
+
async connect(deviceId) {
|
|
50
|
+
console.log('📱 Mock: Connecting to device:', deviceId);
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
this.emit('connected', {
|
|
53
|
+
deviceId
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Simulate characteristic notifications
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
this.emit('characteristicChanged', {
|
|
59
|
+
deviceId,
|
|
60
|
+
serviceUuid: '0000FF00-0000-1000-8000-00805F9B34FB',
|
|
61
|
+
characteristicUuid: '0000FF21-0000-1000-8000-00805F9B34FB',
|
|
62
|
+
value: [1, 2, 3, 4]
|
|
63
|
+
});
|
|
64
|
+
}, 2000);
|
|
65
|
+
}, 500);
|
|
66
|
+
return Promise.resolve();
|
|
67
|
+
}
|
|
68
|
+
async disconnect(deviceId) {
|
|
69
|
+
console.log('📱 Mock: Disconnecting from device:', deviceId);
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
this.emit('disconnected', {
|
|
72
|
+
deviceId
|
|
73
|
+
});
|
|
74
|
+
}, 500);
|
|
75
|
+
return Promise.resolve();
|
|
76
|
+
}
|
|
77
|
+
on(event, callback) {
|
|
78
|
+
if (!this.listeners.has(event)) {
|
|
79
|
+
this.listeners.set(event, []);
|
|
80
|
+
}
|
|
81
|
+
this.listeners.get(event).push(callback);
|
|
82
|
+
console.log(`📱 Mock: Registered listener for '${event}'`);
|
|
83
|
+
}
|
|
84
|
+
removeAllListeners() {
|
|
85
|
+
console.log('📱 Mock: Removing all listeners');
|
|
86
|
+
this.listeners.clear();
|
|
87
|
+
}
|
|
88
|
+
emit(event, data) {
|
|
89
|
+
const callbacks = this.listeners.get(event) || [];
|
|
90
|
+
callbacks.forEach(callback => callback(data));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export default new MockBLEManager();
|
|
94
|
+
//# sourceMappingURL=MockBLEManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MockBLEManager","constructor","_defineProperty","Map","isBluetoothEnabled","console","log","requestPermissions","Promise","resolve","startScan","options","setTimeout","emit","device","id","name","rssi","stopScan","connect","deviceId","serviceUuid","characteristicUuid","value","disconnect","on","event","callback","listeners","has","set","get","push","removeAllListeners","clear","data","callbacks","forEach"],"sources":["MockBLEManager.ts"],"sourcesContent":["/**\n * Mock BLE Manager for development/testing\n * Replace this with the actual react-native-sdk-ble package\n */\n\nclass MockBLEManager {\n private listeners: Map<string, Function[]> = new Map();\n\n async isBluetoothEnabled(): Promise<boolean> {\n console.log('📱 Mock: Checking Bluetooth status...');\n return true;\n }\n\n async requestPermissions(): Promise<void> {\n console.log('📱 Mock: Requesting permissions...');\n return Promise.resolve();\n }\n\n async startScan(options: any): Promise<void> {\n console.log('📱 Mock: Starting scan with options:', options);\n\n // Simulate finding devices\n setTimeout(() => {\n this.emit('scanResult', {\n device: {\n id: 'mock-device-1',\n name: 'Mock BLE Device 1',\n rssi: -65,\n },\n });\n }, 1000);\n\n setTimeout(() => {\n this.emit('scanResult', {\n device: {\n id: 'mock-device-2',\n name: 'Mock BLE Device 2',\n rssi: -75,\n },\n });\n }, 2000);\n\n return Promise.resolve();\n }\n\n async stopScan(): Promise<void> {\n console.log('📱 Mock: Stopping scan...');\n return Promise.resolve();\n }\n\n async connect(deviceId: string): Promise<void> {\n console.log('📱 Mock: Connecting to device:', deviceId);\n setTimeout(() => {\n this.emit('connected', { deviceId });\n\n // Simulate characteristic notifications\n setTimeout(() => {\n this.emit('characteristicChanged', {\n deviceId,\n serviceUuid: '0000FF00-0000-1000-8000-00805F9B34FB',\n characteristicUuid: '0000FF21-0000-1000-8000-00805F9B34FB',\n value: [1, 2, 3, 4],\n });\n }, 2000);\n }, 500);\n return Promise.resolve();\n }\n\n async disconnect(deviceId: string): Promise<void> {\n console.log('📱 Mock: Disconnecting from device:', deviceId);\n setTimeout(() => {\n this.emit('disconnected', { deviceId });\n }, 500);\n return Promise.resolve();\n }\n\n on(event: string, callback: Function): void {\n if (!this.listeners.has(event)) {\n this.listeners.set(event, []);\n }\n this.listeners.get(event)!.push(callback);\n console.log(`📱 Mock: Registered listener for '${event}'`);\n }\n\n removeAllListeners(): void {\n console.log('📱 Mock: Removing all listeners');\n this.listeners.clear();\n }\n\n private emit(event: string, data: any): void {\n const callbacks = this.listeners.get(event) || [];\n callbacks.forEach((callback) => callback(data));\n }\n}\n\nexport default new MockBLEManager();\n"],"mappings":";;;AAAA;AACA;AACA;AACA;;AAEA,MAAMA,cAAc,CAAC;EAAAC,YAAA;IAAAC,eAAA,oBAC0B,IAAIC,GAAG,CAAC,CAAC;EAAA;EAEtD,MAAMC,kBAAkBA,CAAA,EAAqB;IAC3CC,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;IACpD,OAAO,IAAI;EACb;EAEA,MAAMC,kBAAkBA,CAAA,EAAkB;IACxCF,OAAO,CAACC,GAAG,CAAC,oCAAoC,CAAC;IACjD,OAAOE,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B;EAEA,MAAMC,SAASA,CAACC,OAAY,EAAiB;IAC3CN,OAAO,CAACC,GAAG,CAAC,sCAAsC,EAAEK,OAAO,CAAC;;IAE5D;IACAC,UAAU,CAAC,MAAM;MACf,IAAI,CAACC,IAAI,CAAC,YAAY,EAAE;QACtBC,MAAM,EAAE;UACNC,EAAE,EAAE,eAAe;UACnBC,IAAI,EAAE,mBAAmB;UACzBC,IAAI,EAAE,CAAC;QACT;MACF,CAAC,CAAC;IACJ,CAAC,EAAE,IAAI,CAAC;IAERL,UAAU,CAAC,MAAM;MACf,IAAI,CAACC,IAAI,CAAC,YAAY,EAAE;QACtBC,MAAM,EAAE;UACNC,EAAE,EAAE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9B,IAAI,CAACE,SAAS,CAACE,GAAG,CAACJ,KAAK,EAAE,EAAE,CAAC;IAC/B;IACA,IAAI,CAACE,SAAS,CAACG,GAAG,CAACL,KAAK,CAAC,CAAEM,IAAI,CAACL,QAAQ,CAAC;IACzCtB,OAAO,CAACC,GAAG,CAAC,qCAAqCoB,KAAK,GAAG,CAAC;EAC5D;EAEAO,kBAAkBA,CAAA,EAAS;IACzB5B,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;IAC9C,IAAI,CAACsB,SAAS,CAACM,KAAK,CAAC,CAAC;EACxB;EAEQrB,IAAIA,CAACa,KAAa,EAAES,IAAS,EAAQ;IAC3C,MAAMC,SAAS,GAAG,IAAI,CAACR,SAAS,CAACG,GAAG,CAACL,KAAK,CAAC,IAAI,EAAE;IACjDU,SAAS,CAACC,OAAO,CAAEV,QAAQ,IAAKA,QAAQ,CAACQ,IAAI,CAAC,CAAC;EACjD;AACF;AAEA,eAAe,IAAInC,cAAc,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["default","bleMiddleware"],"sources":["index.ts"],"sourcesContent":["export { default as bleMiddleware } from './BLEMiddleware';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,aAAa,QAAQ,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BLE Device interface
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Scan configuration options
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* User role types
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Characteristic notification event
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Device connection state
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* BLE event types
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* BLE event payloads
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Characteristic UUIDs for notifications
|
|
31
|
+
*/
|
|
32
|
+
export let CharacteristicUUID = /*#__PURE__*/function (CharacteristicUUID) {
|
|
33
|
+
CharacteristicUUID["FF01"] = "0000FF01-0000-1000-8000-00805F9B34FB";
|
|
34
|
+
CharacteristicUUID["FF21"] = "0000FF21-0000-1000-8000-00805F9B34FB";
|
|
35
|
+
CharacteristicUUID["FF31"] = "0000FF31-0000-1000-8000-00805F9B34FB";
|
|
36
|
+
CharacteristicUUID["FF41"] = "0000FF41-0000-1000-8000-00805F9B34FB";
|
|
37
|
+
CharacteristicUUID["FF02"] = "0000FF02-0000-1000-8000-00805F9B34FB";
|
|
38
|
+
return CharacteristicUUID;
|
|
39
|
+
}({});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* BLE Manager interface
|
|
43
|
+
*/
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CharacteristicUUID"],"sources":["index.ts"],"sourcesContent":["/**\n * BLE Device interface\n */\nexport interface BLEDevice {\n id: string;\n name?: string;\n rssi?: number;\n [key: string]: any;\n}\n\n/**\n * Scan configuration options\n */\nexport interface ScanOptions {\n timeout?: number;\n allowDuplicates?: boolean;\n}\n\n/**\n * User role types\n */\nexport type UserRole = 'patient' | 'nurse' | 'engineer';\n\n/**\n * Characteristic notification event\n */\nexport interface CharacteristicNotification {\n deviceId: string;\n serviceUuid: string;\n characteristicUuid: string;\n value: any;\n}\n\n/**\n * Device connection state\n */\nexport interface DeviceConnectionState {\n deviceId: string;\n isConnected: boolean;\n isInfusionRunning: boolean;\n infusionLevel: number | null;\n notifications: {\n ff01: CharacteristicNotification | null;\n ff21: CharacteristicNotification | null;\n ff31: CharacteristicNotification | null;\n ff41: CharacteristicNotification | null;\n ff02: CharacteristicNotification | null;\n };\n}\n\n/**\n * BLE event types\n */\nexport type BLEEventType =\n | 'scanResult'\n | 'connected'\n | 'disconnected'\n | 'BleManagerScanFailed'\n | 'bluetoothStateChanged'\n | 'characteristicChanged';\n\n/**\n * BLE event payloads\n */\nexport interface BLEEvents {\n scanResult: { device: BLEDevice };\n connected: { deviceId: string };\n disconnected: { deviceId: string };\n BleManagerScanFailed: { error: string };\n bluetoothStateChanged: { state: string };\n characteristicChanged: CharacteristicNotification;\n}\n\n/**\n * Characteristic UUIDs for notifications\n */\nexport enum CharacteristicUUID {\n FF01 = '0000FF01-0000-1000-8000-00805F9B34FB',\n FF21 = '0000FF21-0000-1000-8000-00805F9B34FB',\n FF31 = '0000FF31-0000-1000-8000-00805F9B34FB',\n FF41 = '0000FF41-0000-1000-8000-00805F9B34FB',\n FF02 = '0000FF02-0000-1000-8000-00805F9B34FB',\n}\n\n/**\n * BLE Manager interface\n */\nexport interface IBLEManager {\n isBluetoothEnabled(): Promise<boolean>;\n requestPermissions(): Promise<void>;\n startScan(options?: ScanOptions): Promise<void>;\n stopScan(): Promise<void>;\n connect(deviceId: string): Promise<void>;\n disconnect(deviceId: string): Promise<void>;\n on(event: BLEEventType, callback: (data: any) => void): void;\n removeAllListeners(): void;\n}\n"],"mappings":"AAAA;AACA;AACA;;AAQA;AACA;AACA;;AAMA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAeA;AACA;AACA;;AASA;AACA;AACA;;AAUA;AACA;AACA;AACA,WAAYA,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;;AAQ9B;AACA;AACA","ignoreList":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-sdk-ble-middleware-v2",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A React Native middleware library for simplified BLE (Bluetooth Low Energy) operations with context-based API",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./src/index.tsx",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./src/index.tsx",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn workspace react-native-middleware-example",
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"typecheck": "tsc",
|
|
38
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
39
|
+
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
40
|
+
"prepare": "bob build",
|
|
41
|
+
"release": "release-it --only-version",
|
|
42
|
+
"setup": "bash setup.sh"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"react-native",
|
|
46
|
+
"ble",
|
|
47
|
+
"bluetooth",
|
|
48
|
+
"bluetooth-low-energy",
|
|
49
|
+
"bluetooth-le",
|
|
50
|
+
"middleware",
|
|
51
|
+
"react-hooks",
|
|
52
|
+
"ios",
|
|
53
|
+
"android",
|
|
54
|
+
"sdk-ble",
|
|
55
|
+
"bluetooth-devices"
|
|
56
|
+
],
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/ananthu07/react-native-middleware.git"
|
|
60
|
+
},
|
|
61
|
+
"author": "ananthu07 <121997433+ananthu07@users.noreply.github.com> (https://github.com/ananthu07)",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://github.com/ananthu07/react-native-middleware/issues"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://github.com/ananthu07/react-native-middleware#readme",
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"registry": "https://registry.npmjs.org/"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@commitlint/config-conventional": "^19.8.1",
|
|
72
|
+
"@eslint/compat": "^1.3.2",
|
|
73
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
74
|
+
"@eslint/js": "^9.35.0",
|
|
75
|
+
"@evilmartians/lefthook": "^1.12.3",
|
|
76
|
+
"@react-native-community/cli": "20.0.1",
|
|
77
|
+
"@react-native/babel-preset": "0.81.1",
|
|
78
|
+
"@react-native/eslint-config": "^0.81.1",
|
|
79
|
+
"@release-it/conventional-changelog": "^10.0.1",
|
|
80
|
+
"@types/jest": "^29.5.14",
|
|
81
|
+
"@types/react": "^19.1.0",
|
|
82
|
+
"commitlint": "^19.8.1",
|
|
83
|
+
"del-cli": "^6.0.0",
|
|
84
|
+
"eslint": "^9.35.0",
|
|
85
|
+
"eslint-config-prettier": "^10.1.8",
|
|
86
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
87
|
+
"jest": "^29.7.0",
|
|
88
|
+
"prettier": "^3.6.2",
|
|
89
|
+
"react": "19.1.0",
|
|
90
|
+
"react-native": "0.81.1",
|
|
91
|
+
"react-native-builder-bob": "0.18.3",
|
|
92
|
+
"release-it": "^19.0.4",
|
|
93
|
+
"turbo": "^2.5.6",
|
|
94
|
+
"typescript": "^5.9.2"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"@salmabeevika/react-native-sdk-ble-v2": ">=0.1.0",
|
|
98
|
+
"react": "*",
|
|
99
|
+
"react-native": "*"
|
|
100
|
+
},
|
|
101
|
+
"peerDependenciesMeta": {
|
|
102
|
+
"@salmabeevika/react-native-sdk-ble-v2": {
|
|
103
|
+
"optional": false
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"workspaces": [
|
|
107
|
+
"example"
|
|
108
|
+
],
|
|
109
|
+
"packageManager": "yarn@3.6.1",
|
|
110
|
+
"jest": {
|
|
111
|
+
"preset": "react-native",
|
|
112
|
+
"modulePathIgnorePatterns": [
|
|
113
|
+
"<rootDir>/example/node_modules",
|
|
114
|
+
"<rootDir>/lib/"
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
"commitlint": {
|
|
118
|
+
"extends": [
|
|
119
|
+
"@commitlint/config-conventional"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"release-it": {
|
|
123
|
+
"git": {
|
|
124
|
+
"commitMessage": "chore: release ${version}",
|
|
125
|
+
"tagName": "v${version}"
|
|
126
|
+
},
|
|
127
|
+
"npm": {
|
|
128
|
+
"publish": true
|
|
129
|
+
},
|
|
130
|
+
"github": {
|
|
131
|
+
"release": true
|
|
132
|
+
},
|
|
133
|
+
"plugins": {
|
|
134
|
+
"@release-it/conventional-changelog": {
|
|
135
|
+
"preset": {
|
|
136
|
+
"name": "angular"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"prettier": {
|
|
142
|
+
"quoteProps": "consistent",
|
|
143
|
+
"singleQuote": true,
|
|
144
|
+
"tabWidth": 2,
|
|
145
|
+
"trailingComma": "es5",
|
|
146
|
+
"useTabs": false
|
|
147
|
+
},
|
|
148
|
+
"react-native-builder-bob": {
|
|
149
|
+
"source": "src",
|
|
150
|
+
"output": "lib",
|
|
151
|
+
"targets": [
|
|
152
|
+
[
|
|
153
|
+
"module",
|
|
154
|
+
{
|
|
155
|
+
"esm": true
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
"typescript",
|
|
160
|
+
{
|
|
161
|
+
"project": "tsconfig.build.json"
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
"codegenConfig": {
|
|
167
|
+
"name": "MiddlewareSpec",
|
|
168
|
+
"type": "modules",
|
|
169
|
+
"jsSrcsDir": "src",
|
|
170
|
+
"android": {
|
|
171
|
+
"javaPackageName": "com.middleware"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"create-react-native-library": {
|
|
175
|
+
"languages": "kotlin-objc",
|
|
176
|
+
"type": "turbo-module",
|
|
177
|
+
"version": "0.54.7"
|
|
178
|
+
}
|
|
179
|
+
}
|