ilabs-flir 1.0.2 → 1.0.4

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 (126) hide show
  1. package/Flir.podspec +31 -31
  2. package/README.md +1271 -1271
  3. package/android/Flir/build.gradle.kts +85 -80
  4. package/android/Flir/libs/flir-stubs.jar +0 -0
  5. package/android/Flir/src/main/AndroidManifest.xml +31 -31
  6. package/android/Flir/src/main/java/com/flir/thermalsdk/ErrorCode.java +13 -0
  7. package/android/Flir/src/main/java/com/flir/thermalsdk/ErrorCodeException.java +14 -0
  8. package/android/Flir/src/main/java/com/flir/thermalsdk/ThermalSdkAndroid.java +16 -0
  9. package/android/Flir/src/main/java/com/flir/thermalsdk/androidsdk/image/BitmapAndroid.java +20 -0
  10. package/android/Flir/src/main/java/com/flir/thermalsdk/image/ImageBuffer.java +11 -0
  11. package/android/Flir/src/main/java/com/flir/thermalsdk/image/JavaImageBuffer.java +35 -0
  12. package/android/Flir/src/main/java/com/flir/thermalsdk/image/Palette.java +15 -0
  13. package/android/Flir/src/main/java/com/flir/thermalsdk/image/PaletteManager.java +16 -0
  14. package/android/Flir/src/main/java/com/flir/thermalsdk/image/Point.java +11 -0
  15. package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalImage.java +23 -0
  16. package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalValue.java +9 -0
  17. package/android/Flir/src/main/java/com/flir/thermalsdk/live/Camera.java +26 -0
  18. package/android/Flir/src/main/java/com/flir/thermalsdk/live/CameraType.java +8 -0
  19. package/android/Flir/src/main/java/com/flir/thermalsdk/live/CommunicationInterface.java +16 -0
  20. package/android/Flir/src/main/java/com/flir/thermalsdk/live/ConnectParameters.java +16 -0
  21. package/android/Flir/src/main/java/com/flir/thermalsdk/live/Identity.java +23 -0
  22. package/android/Flir/src/main/java/com/flir/thermalsdk/live/IpSettings.java +9 -0
  23. package/android/Flir/src/main/java/com/flir/thermalsdk/live/RemoteControl.java +16 -0
  24. package/android/Flir/src/main/java/com/flir/thermalsdk/live/connectivity/ConnectionStatusListener.java +7 -0
  25. package/android/Flir/src/main/java/com/flir/thermalsdk/live/discovery/DiscoveryEventListener.java +14 -0
  26. package/android/Flir/src/main/java/com/flir/thermalsdk/live/discovery/DiscoveryFactory.java +33 -0
  27. package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnReceived.java +5 -0
  28. package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnRemoteError.java +7 -0
  29. package/android/Flir/src/main/java/com/flir/thermalsdk/live/streaming/Stream.java +8 -0
  30. package/android/Flir/src/main/java/com/flir/thermalsdk/live/streaming/ThermalStreamer.java +28 -0
  31. package/android/Flir/src/main/java/com/flir/thermalsdk/live/streaming/VisualStreamer.java +18 -0
  32. package/android/Flir/src/main/java/flir/android/FlirCommands.java +136 -0
  33. package/android/Flir/src/main/java/flir/android/FlirDownloadManager.kt +76 -75
  34. package/android/Flir/src/main/java/flir/android/FlirDownloadPackage.kt +16 -16
  35. package/android/Flir/src/main/java/flir/android/FlirFrameCache.kt +6 -6
  36. package/android/Flir/src/main/java/flir/android/FlirManager.kt +477 -248
  37. package/android/Flir/src/main/java/flir/android/FlirModule.kt +74 -74
  38. package/android/Flir/src/main/java/flir/android/FlirPackage.kt +19 -19
  39. package/android/Flir/src/main/java/flir/android/FlirSDKLoader.kt +165 -117
  40. package/android/Flir/src/main/java/flir/android/FlirSdkManager.java +1511 -0
  41. package/android/Flir/src/main/java/flir/android/FlirStatus.kt +12 -12
  42. package/android/Flir/src/main/java/flir/android/FlirView.kt +48 -48
  43. package/android/Flir/src/main/java/flir/android/FlirViewManager.kt +13 -13
  44. package/app.plugin.js +264 -264
  45. package/expo-module.config.json +5 -5
  46. package/ios/Flir/Framework/ThermalSDK/FLIRBattery.h +76 -76
  47. package/ios/Flir/Framework/ThermalSDK/FLIRCalibration.h +108 -108
  48. package/ios/Flir/Framework/ThermalSDK/FLIRCamera.h +156 -156
  49. package/ios/Flir/Framework/ThermalSDK/FLIRCameraDeviceInfo.h +53 -53
  50. package/ios/Flir/Framework/ThermalSDK/FLIRCameraEvent.h +132 -132
  51. package/ios/Flir/Framework/ThermalSDK/FLIRCameraImport.h +204 -204
  52. package/ios/Flir/Framework/ThermalSDK/FLIRColorDistributionSettings.h +204 -204
  53. package/ios/Flir/Framework/ThermalSDK/FLIRColorizer.h +82 -82
  54. package/ios/Flir/Framework/ThermalSDK/FLIRDiscoveredCamera.h +44 -44
  55. package/ios/Flir/Framework/ThermalSDK/FLIRDiscovery.h +132 -132
  56. package/ios/Flir/Framework/ThermalSDK/FLIRDisplaySettings.h +29 -29
  57. package/ios/Flir/Framework/ThermalSDK/FLIRFocus.h +70 -70
  58. package/ios/Flir/Framework/ThermalSDK/FLIRFusion.h +192 -192
  59. package/ios/Flir/Framework/ThermalSDK/FLIRFusionController.h +136 -136
  60. package/ios/Flir/Framework/ThermalSDK/FLIRFusionTransformation.h +35 -35
  61. package/ios/Flir/Framework/ThermalSDK/FLIRIdentity.h +264 -264
  62. package/ios/Flir/Framework/ThermalSDK/FLIRImageBase.h +196 -196
  63. package/ios/Flir/Framework/ThermalSDK/FLIRImageColorizer.h +26 -26
  64. package/ios/Flir/Framework/ThermalSDK/FLIRImageStatistics.h +61 -61
  65. package/ios/Flir/Framework/ThermalSDK/FLIRIsotherms.h +208 -208
  66. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementArea.h +38 -38
  67. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementCollection.h +147 -147
  68. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDelta.h +62 -62
  69. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDimensions.h +33 -33
  70. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementEllipse.h +49 -49
  71. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementLine.h +66 -66
  72. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementMarker.h +69 -69
  73. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementParameters.h +41 -41
  74. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementRectangle.h +36 -36
  75. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementReference.h +27 -27
  76. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementShape.h +46 -46
  77. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementSpot.h +33 -33
  78. package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementsController.h +160 -160
  79. package/ios/Flir/Framework/ThermalSDK/FLIRMeterLinkSensorPoll.h +247 -247
  80. package/ios/Flir/Framework/ThermalSDK/FLIROverlayController.h +27 -27
  81. package/ios/Flir/Framework/ThermalSDK/FLIRPalette.h +60 -60
  82. package/ios/Flir/Framework/ThermalSDK/FLIRPaletteController.h +36 -36
  83. package/ios/Flir/Framework/ThermalSDK/FLIRPaletteManager.h +97 -97
  84. package/ios/Flir/Framework/ThermalSDK/FLIRQuantification.h +55 -55
  85. package/ios/Flir/Framework/ThermalSDK/FLIRRemoteControl.h +393 -393
  86. package/ios/Flir/Framework/ThermalSDK/FLIRRenderer.h +35 -35
  87. package/ios/Flir/Framework/ThermalSDK/FLIRRendererImpl.h +17 -17
  88. package/ios/Flir/Framework/ThermalSDK/FLIRScale.h +99 -99
  89. package/ios/Flir/Framework/ThermalSDK/FLIRScaleController.h +44 -44
  90. package/ios/Flir/Framework/ThermalSDK/FLIRStream.h +109 -109
  91. package/ios/Flir/Framework/ThermalSDK/FLIRStreamer.h +124 -124
  92. package/ios/Flir/Framework/ThermalSDK/FLIRSystem.h +40 -40
  93. package/ios/Flir/Framework/ThermalSDK/FLIRTemperatureRange.h +43 -43
  94. package/ios/Flir/Framework/ThermalSDK/FLIRThermalDelta.h +77 -77
  95. package/ios/Flir/Framework/ThermalSDK/FLIRThermalImage.h +331 -331
  96. package/ios/Flir/Framework/ThermalSDK/FLIRThermalImageFile.h +56 -56
  97. package/ios/Flir/Framework/ThermalSDK/FLIRThermalParameters.h +31 -31
  98. package/ios/Flir/Framework/ThermalSDK/FLIRThermalValue.h +92 -92
  99. package/ios/Flir/Framework/ThermalSDK/FLIRWirelessCameraDetails.h +88 -88
  100. package/ios/Flir/Framework/ThermalSDK/ThermalSDK.h +73 -73
  101. package/ios/Flir/SDKLoader/FlirSDKLoader.m +13 -13
  102. package/ios/Flir/SDKLoader/FlirSDKLoader.swift +175 -175
  103. package/ios/Flir/src/FlirEventEmitter.h +12 -12
  104. package/ios/Flir/src/FlirEventEmitter.m +33 -33
  105. package/ios/Flir/src/FlirModule.h +10 -10
  106. package/ios/Flir/src/FlirModule.m +381 -381
  107. package/ios/Flir/src/FlirPreviewView.h +13 -13
  108. package/ios/Flir/src/FlirPreviewView.m +24 -24
  109. package/ios/Flir/src/FlirState.h +20 -20
  110. package/ios/Flir/src/FlirState.m +79 -79
  111. package/ios/Flir/src/FlirViewManager.h +9 -9
  112. package/ios/Flir/src/FlirViewManager.m +16 -16
  113. package/package.json +60 -60
  114. package/react-native.config.js +14 -14
  115. package/scripts/copy_ios_libs.sh +32 -32
  116. package/scripts/create_stubs.py +174 -174
  117. package/scripts/download-sdk.js +62 -62
  118. package/scripts/prepare-binaries.sh +171 -171
  119. package/sdk-manifest.json +37 -30
  120. package/src/FlirDownload.ts +78 -78
  121. package/src/index.d.ts +17 -17
  122. package/src/index.js +7 -7
  123. package/src/index.ts +7 -7
  124. package/android/Flir/src/main/java/flir/android/CameraHandler.java +0 -194
  125. package/android/Flir/src/main/java/flir/android/FlirController.kt +0 -11
  126. package/android/Flir/src/main/java/flir/android/FrameDataHolder.java +0 -14
package/app.plugin.js CHANGED
@@ -1,264 +1,264 @@
1
- const {
2
- withInfoPlist,
3
- withAndroidManifest,
4
- withDangerousMod,
5
- createRunOncePlugin,
6
- } = require('@expo/config-plugins');
7
- const fs = require('fs');
8
- const path = require('path');
9
-
10
- /**
11
- * FLIR Thermal SDK Config Plugin
12
- *
13
- * Automatically adds required iOS Info.plist and Android AndroidManifest.xml
14
- * entries for FLIR device support. This eliminates the need for manual editing.
15
- *
16
- * Usage in app.json:
17
- * {
18
- * "plugins": ["ilabs-flir"]
19
- * }
20
- *
21
- * Or with custom descriptions:
22
- * {
23
- * "plugins": [
24
- * ["ilabs-flir", {
25
- * "bluetoothAlwaysUsageDescription": "Custom description here",
26
- * "bluetoothPeripheralUsageDescription": "Custom description here"
27
- * }]
28
- * ]
29
- * }
30
- */
31
-
32
- const EXTERNAL_ACCESSORY_PROTOCOLS = [
33
- 'com.flir.rosebud.config',
34
- 'com.flir.rosebud.frame',
35
- 'com.flir.rosebud.fileio',
36
- ];
37
-
38
- const DEFAULT_BLUETOOTH_ALWAYS_DESCRIPTION =
39
- 'This app requires Bluetooth to connect to FLIR thermal cameras via Bluetooth Low Energy';
40
-
41
- const DEFAULT_BLUETOOTH_PERIPHERAL_DESCRIPTION =
42
- 'This app uses Bluetooth to communicate with FLIR thermal imaging devices';
43
-
44
- /**
45
- * Adds FLIR-specific Info.plist entries for iOS
46
- */
47
- const withFlirInfoPlist = (config, props = {}) => {
48
- return withInfoPlist(config, (config) => {
49
- const infoPlist = config.modResults;
50
-
51
- // Add External Accessory Protocols for FLIR ONE devices
52
- // These protocols enable Lightning interface communication (FLIR ONE Classic)
53
- // and prepare for Bluetooth LE devices (FLIR ONE Edge/Pro)
54
- if (!infoPlist.UISupportedExternalAccessoryProtocols) {
55
- infoPlist.UISupportedExternalAccessoryProtocols = [];
56
- }
57
-
58
- // Merge protocols without duplicates
59
- const existingProtocols = infoPlist.UISupportedExternalAccessoryProtocols;
60
- EXTERNAL_ACCESSORY_PROTOCOLS.forEach((protocol) => {
61
- if (!existingProtocols.includes(protocol)) {
62
- existingProtocols.push(protocol);
63
- }
64
- });
65
-
66
- // Add Bluetooth permissions for FLIR ONE Edge/Pro (BLE devices)
67
- // iOS 13+ requires NSBluetoothAlwaysUsageDescription
68
- if (!infoPlist.NSBluetoothAlwaysUsageDescription) {
69
- infoPlist.NSBluetoothAlwaysUsageDescription =
70
- props.bluetoothAlwaysUsageDescription ||
71
- DEFAULT_BLUETOOTH_ALWAYS_DESCRIPTION;
72
- }
73
-
74
- // Older iOS versions (pre-13) require NSBluetoothPeripheralUsageDescription
75
- if (!infoPlist.NSBluetoothPeripheralUsageDescription) {
76
- infoPlist.NSBluetoothPeripheralUsageDescription =
77
- props.bluetoothPeripheralUsageDescription ||
78
- DEFAULT_BLUETOOTH_PERIPHERAL_DESCRIPTION;
79
- }
80
-
81
- return config;
82
- });
83
- };
84
-
85
- /**
86
- * Adds FLIR-specific AndroidManifest.xml entries for Android
87
- */
88
- const withFlirAndroidManifest = (config) => {
89
- return withAndroidManifest(config, (config) => {
90
- const androidManifest = config.modResults;
91
- const mainApplication = androidManifest.manifest;
92
-
93
- // Ensure uses-feature array exists
94
- if (!mainApplication['uses-feature']) {
95
- mainApplication['uses-feature'] = [];
96
- }
97
-
98
- // Ensure uses-permission array exists
99
- if (!mainApplication['uses-permission']) {
100
- mainApplication['uses-permission'] = [];
101
- }
102
-
103
- // Add USB host feature for FLIR ONE USB devices
104
- const usbHostFeature = {
105
- $: {
106
- 'android:name': 'android.hardware.usb.host',
107
- 'android:required': 'false',
108
- },
109
- };
110
-
111
- // Check if USB host feature already exists
112
- const hasUsbHost = mainApplication['uses-feature'].some(
113
- (feature) => feature.$?.['android:name'] === 'android.hardware.usb.host'
114
- );
115
-
116
- if (!hasUsbHost) {
117
- mainApplication['uses-feature'].push(usbHostFeature);
118
- }
119
-
120
- // Add camera permission for FLIR cameras
121
- const cameraPermission = {
122
- $: {
123
- 'android:name': 'android.permission.CAMERA',
124
- },
125
- };
126
-
127
- // Check if camera permission already exists
128
- const hasCameraPermission = mainApplication['uses-permission'].some(
129
- (permission) => permission.$?.['android:name'] === 'android.permission.CAMERA'
130
- );
131
-
132
- if (!hasCameraPermission) {
133
- mainApplication['uses-permission'].push(cameraPermission);
134
- }
135
-
136
- return config;
137
- });
138
- };
139
-
140
- /**
141
- * Copies sdk-manifest.json to iOS project
142
- */
143
- const withFlirManifest = (config) => {
144
- return withDangerousMod(config, [
145
- 'ios',
146
- async (config) => {
147
- const src = path.join(__dirname, 'sdk-manifest.json');
148
- const dst = path.join(config.modRequest.platformProjectRoot, 'sdk-manifest.json');
149
- fs.copyFileSync(src, dst);
150
- return config;
151
- },
152
- ]);
153
- };
154
-
155
- /**
156
- * Copies sdk-manifest.json to Android assets
157
- */
158
- const withFlirAndroidAssets = (config) => {
159
- return withDangerousMod(config, [
160
- 'android',
161
- async (config) => {
162
- const src = path.join(__dirname, 'sdk-manifest.json');
163
- const dst = path.join(config.modRequest.platformProjectRoot, 'app/src/main/assets/sdk-manifest.json');
164
- fs.mkdirSync(path.dirname(dst), { recursive: true });
165
- fs.copyFileSync(src, dst);
166
- return config;
167
- },
168
- ]);
169
- };
170
-
171
- /**
172
- * Ensure the Flir Android Gradle module is included in generated projects.
173
- *
174
- * Some workflows (Expo prebuild) won't add node_modules subprojects to
175
- * settings.gradle automatically unless the package exposes autolinking or
176
- * the plugin performs the edit. When a consumer installs the package and
177
- * runs prebuild, include the Flir module and wire an app dependency so the
178
- * native bridge (FlirDownloadManager) is compiled into the app.
179
- */
180
- const withFlirAndroidGradle = (config) => {
181
- return withDangerousMod(config, [
182
- 'android',
183
- async (config) => {
184
- try {
185
- const projectRoot = config.modRequest.platformProjectRoot;
186
- const settingsGradlePath = path.join(projectRoot, 'settings.gradle');
187
- const appBuildGradlePath = path.join(projectRoot, 'app', 'build.gradle');
188
-
189
- const moduleRelPath = '../node_modules/ilabs-flir/android/Flir';
190
- const includeSnippet = `\n// ilabs-flir: include Flir module\nif (new File(rootProject.projectDir, '${moduleRelPath}').exists()) {\n include ':Flir'\n project(':Flir').projectDir = new File(rootProject.projectDir, '${moduleRelPath}')\n}\n`;
191
-
192
- if (fs.existsSync(settingsGradlePath)) {
193
- let settingsTxt = fs.readFileSync(settingsGradlePath, 'utf8');
194
- if (!/include\s*':Flir'/.test(settingsTxt)) {
195
- fs.appendFileSync(settingsGradlePath, includeSnippet, 'utf8');
196
- }
197
- }
198
-
199
- if (fs.existsSync(appBuildGradlePath)) {
200
- let buildTxt = fs.readFileSync(appBuildGradlePath, 'utf8');
201
- // Only add implementation project(':Flir') if it's not already present
202
- if (!/project\('\:Flir'\)/.test(buildTxt)) {
203
- const depSnippet = `\n // ilabs-flir: include :Flir when available\n if (new File(rootDir.getParent(), '${moduleRelPath}').exists()) {\n implementation project(':Flir')\n }\n`;
204
-
205
- // Find the first 'dependencies {' occurrence and find its matching closing brace
206
- const depIndex = buildTxt.search(/\bdependencies\s*\{/);
207
- if (depIndex !== -1) {
208
- // Walk forward to find the matching closing brace for the dependencies block
209
- let depth = 0;
210
- let insertPos = -1;
211
- for (let i = depIndex; i < buildTxt.length; i++) {
212
- const ch = buildTxt[i];
213
- if (ch === '{') depth++;
214
- else if (ch === '}') {
215
- depth--;
216
- if (depth === 0) { insertPos = i; break; }
217
- }
218
- }
219
-
220
- if (insertPos !== -1) {
221
- // Insert snippet just before the closing '}' of the dependencies block
222
- buildTxt = buildTxt.slice(0, insertPos) + depSnippet + buildTxt.slice(insertPos);
223
- fs.writeFileSync(appBuildGradlePath, buildTxt, 'utf8');
224
- } else {
225
- // Fallback: append to the file
226
- fs.appendFileSync(appBuildGradlePath, '\n' + depSnippet, 'utf8');
227
- }
228
- } else {
229
- // No dependencies block found! Append a new one with the snippet.
230
- fs.appendFileSync(appBuildGradlePath, '\n' + 'dependencies {' + depSnippet + '\n}\n', 'utf8');
231
- }
232
- }
233
- }
234
- } catch (err) {
235
- console.warn('[flir-config-plugin] Failed to patch Android Gradle files:', err && err.message);
236
- }
237
-
238
- return config;
239
- },
240
- ]);
241
- };
242
-
243
- /**
244
- * Main plugin that combines iOS and Android configurations
245
- */
246
- const withFlirThermalSDK = (config, props = {}) => {
247
- // Apply iOS modifications
248
- config = withFlirInfoPlist(config, props);
249
- config = withFlirManifest(config);
250
-
251
- // Apply Android modifications
252
- config = withFlirAndroidManifest(config);
253
- config = withFlirAndroidAssets(config);
254
- // Ensure the Flir Gradle module is included in generated native projects
255
- config = withFlirAndroidGradle(config);
256
-
257
- return config;
258
- };
259
-
260
- module.exports = createRunOncePlugin(
261
- withFlirThermalSDK,
262
- 'ilabs-flir',
263
- '2.0.2'
264
- );
1
+ const {
2
+ withInfoPlist,
3
+ withAndroidManifest,
4
+ withDangerousMod,
5
+ createRunOncePlugin,
6
+ } = require('@expo/config-plugins');
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+
10
+ /**
11
+ * FLIR Thermal SDK Config Plugin
12
+ *
13
+ * Automatically adds required iOS Info.plist and Android AndroidManifest.xml
14
+ * entries for FLIR device support. This eliminates the need for manual editing.
15
+ *
16
+ * Usage in app.json:
17
+ * {
18
+ * "plugins": ["ilabs-flir"]
19
+ * }
20
+ *
21
+ * Or with custom descriptions:
22
+ * {
23
+ * "plugins": [
24
+ * ["ilabs-flir", {
25
+ * "bluetoothAlwaysUsageDescription": "Custom description here",
26
+ * "bluetoothPeripheralUsageDescription": "Custom description here"
27
+ * }]
28
+ * ]
29
+ * }
30
+ */
31
+
32
+ const EXTERNAL_ACCESSORY_PROTOCOLS = [
33
+ 'com.flir.rosebud.config',
34
+ 'com.flir.rosebud.frame',
35
+ 'com.flir.rosebud.fileio',
36
+ ];
37
+
38
+ const DEFAULT_BLUETOOTH_ALWAYS_DESCRIPTION =
39
+ 'This app requires Bluetooth to connect to FLIR thermal cameras via Bluetooth Low Energy';
40
+
41
+ const DEFAULT_BLUETOOTH_PERIPHERAL_DESCRIPTION =
42
+ 'This app uses Bluetooth to communicate with FLIR thermal imaging devices';
43
+
44
+ /**
45
+ * Adds FLIR-specific Info.plist entries for iOS
46
+ */
47
+ const withFlirInfoPlist = (config, props = {}) => {
48
+ return withInfoPlist(config, (config) => {
49
+ const infoPlist = config.modResults;
50
+
51
+ // Add External Accessory Protocols for FLIR ONE devices
52
+ // These protocols enable Lightning interface communication (FLIR ONE Classic)
53
+ // and prepare for Bluetooth LE devices (FLIR ONE Edge/Pro)
54
+ if (!infoPlist.UISupportedExternalAccessoryProtocols) {
55
+ infoPlist.UISupportedExternalAccessoryProtocols = [];
56
+ }
57
+
58
+ // Merge protocols without duplicates
59
+ const existingProtocols = infoPlist.UISupportedExternalAccessoryProtocols;
60
+ EXTERNAL_ACCESSORY_PROTOCOLS.forEach((protocol) => {
61
+ if (!existingProtocols.includes(protocol)) {
62
+ existingProtocols.push(protocol);
63
+ }
64
+ });
65
+
66
+ // Add Bluetooth permissions for FLIR ONE Edge/Pro (BLE devices)
67
+ // iOS 13+ requires NSBluetoothAlwaysUsageDescription
68
+ if (!infoPlist.NSBluetoothAlwaysUsageDescription) {
69
+ infoPlist.NSBluetoothAlwaysUsageDescription =
70
+ props.bluetoothAlwaysUsageDescription ||
71
+ DEFAULT_BLUETOOTH_ALWAYS_DESCRIPTION;
72
+ }
73
+
74
+ // Older iOS versions (pre-13) require NSBluetoothPeripheralUsageDescription
75
+ if (!infoPlist.NSBluetoothPeripheralUsageDescription) {
76
+ infoPlist.NSBluetoothPeripheralUsageDescription =
77
+ props.bluetoothPeripheralUsageDescription ||
78
+ DEFAULT_BLUETOOTH_PERIPHERAL_DESCRIPTION;
79
+ }
80
+
81
+ return config;
82
+ });
83
+ };
84
+
85
+ /**
86
+ * Adds FLIR-specific AndroidManifest.xml entries for Android
87
+ */
88
+ const withFlirAndroidManifest = (config) => {
89
+ return withAndroidManifest(config, (config) => {
90
+ const androidManifest = config.modResults;
91
+ const mainApplication = androidManifest.manifest;
92
+
93
+ // Ensure uses-feature array exists
94
+ if (!mainApplication['uses-feature']) {
95
+ mainApplication['uses-feature'] = [];
96
+ }
97
+
98
+ // Ensure uses-permission array exists
99
+ if (!mainApplication['uses-permission']) {
100
+ mainApplication['uses-permission'] = [];
101
+ }
102
+
103
+ // Add USB host feature for FLIR ONE USB devices
104
+ const usbHostFeature = {
105
+ $: {
106
+ 'android:name': 'android.hardware.usb.host',
107
+ 'android:required': 'false',
108
+ },
109
+ };
110
+
111
+ // Check if USB host feature already exists
112
+ const hasUsbHost = mainApplication['uses-feature'].some(
113
+ (feature) => feature.$?.['android:name'] === 'android.hardware.usb.host'
114
+ );
115
+
116
+ if (!hasUsbHost) {
117
+ mainApplication['uses-feature'].push(usbHostFeature);
118
+ }
119
+
120
+ // Add camera permission for FLIR cameras
121
+ const cameraPermission = {
122
+ $: {
123
+ 'android:name': 'android.permission.CAMERA',
124
+ },
125
+ };
126
+
127
+ // Check if camera permission already exists
128
+ const hasCameraPermission = mainApplication['uses-permission'].some(
129
+ (permission) => permission.$?.['android:name'] === 'android.permission.CAMERA'
130
+ );
131
+
132
+ if (!hasCameraPermission) {
133
+ mainApplication['uses-permission'].push(cameraPermission);
134
+ }
135
+
136
+ return config;
137
+ });
138
+ };
139
+
140
+ /**
141
+ * Copies sdk-manifest.json to iOS project
142
+ */
143
+ const withFlirManifest = (config) => {
144
+ return withDangerousMod(config, [
145
+ 'ios',
146
+ async (config) => {
147
+ const src = path.join(__dirname, 'sdk-manifest.json');
148
+ const dst = path.join(config.modRequest.platformProjectRoot, 'sdk-manifest.json');
149
+ fs.copyFileSync(src, dst);
150
+ return config;
151
+ },
152
+ ]);
153
+ };
154
+
155
+ /**
156
+ * Copies sdk-manifest.json to Android assets
157
+ */
158
+ const withFlirAndroidAssets = (config) => {
159
+ return withDangerousMod(config, [
160
+ 'android',
161
+ async (config) => {
162
+ const src = path.join(__dirname, 'sdk-manifest.json');
163
+ const dst = path.join(config.modRequest.platformProjectRoot, 'app/src/main/assets/sdk-manifest.json');
164
+ fs.mkdirSync(path.dirname(dst), { recursive: true });
165
+ fs.copyFileSync(src, dst);
166
+ return config;
167
+ },
168
+ ]);
169
+ };
170
+
171
+ /**
172
+ * Ensure the Flir Android Gradle module is included in generated projects.
173
+ *
174
+ * Some workflows (Expo prebuild) won't add node_modules subprojects to
175
+ * settings.gradle automatically unless the package exposes autolinking or
176
+ * the plugin performs the edit. When a consumer installs the package and
177
+ * runs prebuild, include the Flir module and wire an app dependency so the
178
+ * native bridge (FlirDownloadManager) is compiled into the app.
179
+ */
180
+ const withFlirAndroidGradle = (config) => {
181
+ return withDangerousMod(config, [
182
+ 'android',
183
+ async (config) => {
184
+ try {
185
+ const projectRoot = config.modRequest.platformProjectRoot;
186
+ const settingsGradlePath = path.join(projectRoot, 'settings.gradle');
187
+ const appBuildGradlePath = path.join(projectRoot, 'app', 'build.gradle');
188
+
189
+ const moduleRelPath = '../node_modules/ilabs-flir/android/Flir';
190
+ const includeSnippet = `\n// ilabs-flir: include Flir module\nif (new File(rootProject.projectDir, '${moduleRelPath}').exists()) {\n include ':Flir'\n project(':Flir').projectDir = new File(rootProject.projectDir, '${moduleRelPath}')\n}\n`;
191
+
192
+ if (fs.existsSync(settingsGradlePath)) {
193
+ let settingsTxt = fs.readFileSync(settingsGradlePath, 'utf8');
194
+ if (!/include\s*':Flir'/.test(settingsTxt)) {
195
+ fs.appendFileSync(settingsGradlePath, includeSnippet, 'utf8');
196
+ }
197
+ }
198
+
199
+ if (fs.existsSync(appBuildGradlePath)) {
200
+ let buildTxt = fs.readFileSync(appBuildGradlePath, 'utf8');
201
+ // Only add implementation project(':Flir') if it's not already present
202
+ if (!/project\('\:Flir'\)/.test(buildTxt)) {
203
+ const depSnippet = `\n // ilabs-flir: include :Flir when available\n if (new File(rootDir.getParent(), '${moduleRelPath}').exists()) {\n implementation project(':Flir')\n }\n`;
204
+
205
+ // Find the first 'dependencies {' occurrence and find its matching closing brace
206
+ const depIndex = buildTxt.search(/\bdependencies\s*\{/);
207
+ if (depIndex !== -1) {
208
+ // Walk forward to find the matching closing brace for the dependencies block
209
+ let depth = 0;
210
+ let insertPos = -1;
211
+ for (let i = depIndex; i < buildTxt.length; i++) {
212
+ const ch = buildTxt[i];
213
+ if (ch === '{') depth++;
214
+ else if (ch === '}') {
215
+ depth--;
216
+ if (depth === 0) { insertPos = i; break; }
217
+ }
218
+ }
219
+
220
+ if (insertPos !== -1) {
221
+ // Insert snippet just before the closing '}' of the dependencies block
222
+ buildTxt = buildTxt.slice(0, insertPos) + depSnippet + buildTxt.slice(insertPos);
223
+ fs.writeFileSync(appBuildGradlePath, buildTxt, 'utf8');
224
+ } else {
225
+ // Fallback: append to the file
226
+ fs.appendFileSync(appBuildGradlePath, '\n' + depSnippet, 'utf8');
227
+ }
228
+ } else {
229
+ // No dependencies block found! Append a new one with the snippet.
230
+ fs.appendFileSync(appBuildGradlePath, '\n' + 'dependencies {' + depSnippet + '\n}\n', 'utf8');
231
+ }
232
+ }
233
+ }
234
+ } catch (err) {
235
+ console.warn('[flir-config-plugin] Failed to patch Android Gradle files:', err && err.message);
236
+ }
237
+
238
+ return config;
239
+ },
240
+ ]);
241
+ };
242
+
243
+ /**
244
+ * Main plugin that combines iOS and Android configurations
245
+ */
246
+ const withFlirThermalSDK = (config, props = {}) => {
247
+ // Apply iOS modifications
248
+ config = withFlirInfoPlist(config, props);
249
+ config = withFlirManifest(config);
250
+
251
+ // Apply Android modifications
252
+ config = withFlirAndroidManifest(config);
253
+ config = withFlirAndroidAssets(config);
254
+ // Ensure the Flir Gradle module is included in generated native projects
255
+ config = withFlirAndroidGradle(config);
256
+
257
+ return config;
258
+ };
259
+
260
+ module.exports = createRunOncePlugin(
261
+ withFlirThermalSDK,
262
+ 'ilabs-flir',
263
+ '2.0.2'
264
+ );
@@ -1,6 +1,6 @@
1
- {
2
- "platforms": [
3
- "android",
4
- "ios"
5
- ]
1
+ {
2
+ "platforms": [
3
+ "android",
4
+ "ios"
5
+ ]
6
6
  }