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.
- package/Flir.podspec +31 -31
- package/README.md +1271 -1271
- package/android/Flir/build.gradle.kts +85 -80
- package/android/Flir/libs/flir-stubs.jar +0 -0
- package/android/Flir/src/main/AndroidManifest.xml +31 -31
- package/android/Flir/src/main/java/com/flir/thermalsdk/ErrorCode.java +13 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/ErrorCodeException.java +14 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/ThermalSdkAndroid.java +16 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/androidsdk/image/BitmapAndroid.java +20 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/ImageBuffer.java +11 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/JavaImageBuffer.java +35 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/Palette.java +15 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/PaletteManager.java +16 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/Point.java +11 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalImage.java +23 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/image/ThermalValue.java +9 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/Camera.java +26 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/CameraType.java +8 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/CommunicationInterface.java +16 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/ConnectParameters.java +16 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/Identity.java +23 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/IpSettings.java +9 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/RemoteControl.java +16 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/connectivity/ConnectionStatusListener.java +7 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/discovery/DiscoveryEventListener.java +14 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/discovery/DiscoveryFactory.java +33 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnReceived.java +5 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/remote/OnRemoteError.java +7 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/streaming/Stream.java +8 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/streaming/ThermalStreamer.java +28 -0
- package/android/Flir/src/main/java/com/flir/thermalsdk/live/streaming/VisualStreamer.java +18 -0
- package/android/Flir/src/main/java/flir/android/FlirCommands.java +136 -0
- package/android/Flir/src/main/java/flir/android/FlirDownloadManager.kt +76 -75
- package/android/Flir/src/main/java/flir/android/FlirDownloadPackage.kt +16 -16
- package/android/Flir/src/main/java/flir/android/FlirFrameCache.kt +6 -6
- package/android/Flir/src/main/java/flir/android/FlirManager.kt +477 -248
- package/android/Flir/src/main/java/flir/android/FlirModule.kt +74 -74
- package/android/Flir/src/main/java/flir/android/FlirPackage.kt +19 -19
- package/android/Flir/src/main/java/flir/android/FlirSDKLoader.kt +165 -117
- package/android/Flir/src/main/java/flir/android/FlirSdkManager.java +1511 -0
- package/android/Flir/src/main/java/flir/android/FlirStatus.kt +12 -12
- package/android/Flir/src/main/java/flir/android/FlirView.kt +48 -48
- package/android/Flir/src/main/java/flir/android/FlirViewManager.kt +13 -13
- package/app.plugin.js +264 -264
- package/expo-module.config.json +5 -5
- package/ios/Flir/Framework/ThermalSDK/FLIRBattery.h +76 -76
- package/ios/Flir/Framework/ThermalSDK/FLIRCalibration.h +108 -108
- package/ios/Flir/Framework/ThermalSDK/FLIRCamera.h +156 -156
- package/ios/Flir/Framework/ThermalSDK/FLIRCameraDeviceInfo.h +53 -53
- package/ios/Flir/Framework/ThermalSDK/FLIRCameraEvent.h +132 -132
- package/ios/Flir/Framework/ThermalSDK/FLIRCameraImport.h +204 -204
- package/ios/Flir/Framework/ThermalSDK/FLIRColorDistributionSettings.h +204 -204
- package/ios/Flir/Framework/ThermalSDK/FLIRColorizer.h +82 -82
- package/ios/Flir/Framework/ThermalSDK/FLIRDiscoveredCamera.h +44 -44
- package/ios/Flir/Framework/ThermalSDK/FLIRDiscovery.h +132 -132
- package/ios/Flir/Framework/ThermalSDK/FLIRDisplaySettings.h +29 -29
- package/ios/Flir/Framework/ThermalSDK/FLIRFocus.h +70 -70
- package/ios/Flir/Framework/ThermalSDK/FLIRFusion.h +192 -192
- package/ios/Flir/Framework/ThermalSDK/FLIRFusionController.h +136 -136
- package/ios/Flir/Framework/ThermalSDK/FLIRFusionTransformation.h +35 -35
- package/ios/Flir/Framework/ThermalSDK/FLIRIdentity.h +264 -264
- package/ios/Flir/Framework/ThermalSDK/FLIRImageBase.h +196 -196
- package/ios/Flir/Framework/ThermalSDK/FLIRImageColorizer.h +26 -26
- package/ios/Flir/Framework/ThermalSDK/FLIRImageStatistics.h +61 -61
- package/ios/Flir/Framework/ThermalSDK/FLIRIsotherms.h +208 -208
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementArea.h +38 -38
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementCollection.h +147 -147
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDelta.h +62 -62
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDimensions.h +33 -33
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementEllipse.h +49 -49
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementLine.h +66 -66
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementMarker.h +69 -69
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementParameters.h +41 -41
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementRectangle.h +36 -36
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementReference.h +27 -27
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementShape.h +46 -46
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementSpot.h +33 -33
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementsController.h +160 -160
- package/ios/Flir/Framework/ThermalSDK/FLIRMeterLinkSensorPoll.h +247 -247
- package/ios/Flir/Framework/ThermalSDK/FLIROverlayController.h +27 -27
- package/ios/Flir/Framework/ThermalSDK/FLIRPalette.h +60 -60
- package/ios/Flir/Framework/ThermalSDK/FLIRPaletteController.h +36 -36
- package/ios/Flir/Framework/ThermalSDK/FLIRPaletteManager.h +97 -97
- package/ios/Flir/Framework/ThermalSDK/FLIRQuantification.h +55 -55
- package/ios/Flir/Framework/ThermalSDK/FLIRRemoteControl.h +393 -393
- package/ios/Flir/Framework/ThermalSDK/FLIRRenderer.h +35 -35
- package/ios/Flir/Framework/ThermalSDK/FLIRRendererImpl.h +17 -17
- package/ios/Flir/Framework/ThermalSDK/FLIRScale.h +99 -99
- package/ios/Flir/Framework/ThermalSDK/FLIRScaleController.h +44 -44
- package/ios/Flir/Framework/ThermalSDK/FLIRStream.h +109 -109
- package/ios/Flir/Framework/ThermalSDK/FLIRStreamer.h +124 -124
- package/ios/Flir/Framework/ThermalSDK/FLIRSystem.h +40 -40
- package/ios/Flir/Framework/ThermalSDK/FLIRTemperatureRange.h +43 -43
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalDelta.h +77 -77
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalImage.h +331 -331
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalImageFile.h +56 -56
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalParameters.h +31 -31
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalValue.h +92 -92
- package/ios/Flir/Framework/ThermalSDK/FLIRWirelessCameraDetails.h +88 -88
- package/ios/Flir/Framework/ThermalSDK/ThermalSDK.h +73 -73
- package/ios/Flir/SDKLoader/FlirSDKLoader.m +13 -13
- package/ios/Flir/SDKLoader/FlirSDKLoader.swift +175 -175
- package/ios/Flir/src/FlirEventEmitter.h +12 -12
- package/ios/Flir/src/FlirEventEmitter.m +33 -33
- package/ios/Flir/src/FlirModule.h +10 -10
- package/ios/Flir/src/FlirModule.m +381 -381
- package/ios/Flir/src/FlirPreviewView.h +13 -13
- package/ios/Flir/src/FlirPreviewView.m +24 -24
- package/ios/Flir/src/FlirState.h +20 -20
- package/ios/Flir/src/FlirState.m +79 -79
- package/ios/Flir/src/FlirViewManager.h +9 -9
- package/ios/Flir/src/FlirViewManager.m +16 -16
- package/package.json +60 -60
- package/react-native.config.js +14 -14
- package/scripts/copy_ios_libs.sh +32 -32
- package/scripts/create_stubs.py +174 -174
- package/scripts/download-sdk.js +62 -62
- package/scripts/prepare-binaries.sh +171 -171
- package/sdk-manifest.json +37 -30
- package/src/FlirDownload.ts +78 -78
- package/src/index.d.ts +17 -17
- package/src/index.js +7 -7
- package/src/index.ts +7 -7
- package/android/Flir/src/main/java/flir/android/CameraHandler.java +0 -194
- package/android/Flir/src/main/java/flir/android/FlirController.kt +0 -11
- 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
|
+
);
|
package/expo-module.config.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
{
|
|
2
|
-
"platforms": [
|
|
3
|
-
"android",
|
|
4
|
-
"ios"
|
|
5
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"platforms": [
|
|
3
|
+
"android",
|
|
4
|
+
"ios"
|
|
5
|
+
]
|
|
6
6
|
}
|