ilabs-flir 1.0.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/Flir.podspec +31 -0
- package/README.md +1271 -0
- package/android/Flir/build.gradle.kts +80 -0
- package/android/Flir/libs/flir-stubs.jar +0 -0
- package/android/Flir/src/main/AndroidManifest.xml +31 -0
- package/android/Flir/src/main/java/flir/android/CameraHandler.java +194 -0
- package/android/Flir/src/main/java/flir/android/FlirController.kt +11 -0
- package/android/Flir/src/main/java/flir/android/FlirDownloadManager.kt +75 -0
- package/android/Flir/src/main/java/flir/android/FlirDownloadPackage.kt +16 -0
- package/android/Flir/src/main/java/flir/android/FlirFrameCache.kt +6 -0
- package/android/Flir/src/main/java/flir/android/FlirManager.kt +248 -0
- package/android/Flir/src/main/java/flir/android/FlirModule.kt +74 -0
- package/android/Flir/src/main/java/flir/android/FlirPackage.kt +16 -0
- package/android/Flir/src/main/java/flir/android/FlirSDKLoader.kt +191 -0
- package/android/Flir/src/main/java/flir/android/FlirStatus.kt +12 -0
- package/android/Flir/src/main/java/flir/android/FlirView.kt +48 -0
- package/android/Flir/src/main/java/flir/android/FlirViewManager.kt +13 -0
- package/android/Flir/src/main/java/flir/android/FrameDataHolder.java +14 -0
- package/app.plugin.js +264 -0
- package/expo-module.config.json +6 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRBattery.h +76 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRCalibration.h +108 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRCamera.h +156 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRCameraDeviceInfo.h +53 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRCameraEvent.h +132 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRCameraImport.h +204 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRColorDistributionSettings.h +204 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRColorizer.h +82 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRDiscoveredCamera.h +44 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRDiscovery.h +132 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRDisplaySettings.h +29 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRFocus.h +70 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRFusion.h +192 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRFusionController.h +136 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRFusionTransformation.h +35 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRIdentity.h +264 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRImageBase.h +196 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRImageColorizer.h +26 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRImageStatistics.h +61 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRIsotherms.h +208 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementArea.h +38 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementCollection.h +147 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDelta.h +62 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementDimensions.h +33 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementEllipse.h +49 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementLine.h +66 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementMarker.h +69 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementParameters.h +41 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementRectangle.h +36 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementReference.h +27 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementShape.h +46 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementSpot.h +33 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeasurementsController.h +160 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRMeterLinkSensorPoll.h +247 -0
- package/ios/Flir/Framework/ThermalSDK/FLIROverlayController.h +27 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRPalette.h +60 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRPaletteController.h +36 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRPaletteManager.h +97 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRQuantification.h +55 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRRemoteControl.h +393 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRRenderer.h +35 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRRendererImpl.h +17 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRScale.h +99 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRScaleController.h +44 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRStream.h +109 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRStreamer.h +124 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRSystem.h +40 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRTemperatureRange.h +43 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalDelta.h +77 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalImage.h +331 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalImageFile.h +56 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalParameters.h +31 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRThermalValue.h +92 -0
- package/ios/Flir/Framework/ThermalSDK/FLIRWirelessCameraDetails.h +88 -0
- package/ios/Flir/Framework/ThermalSDK/ThermalSDK.h +73 -0
- package/ios/Flir/SDKLoader/FlirSDKLoader.m +13 -0
- package/ios/Flir/SDKLoader/FlirSDKLoader.swift +175 -0
- package/ios/Flir/src/FlirEventEmitter.h +12 -0
- package/ios/Flir/src/FlirEventEmitter.m +33 -0
- package/ios/Flir/src/FlirModule.h +10 -0
- package/ios/Flir/src/FlirModule.m +381 -0
- package/ios/Flir/src/FlirPreviewView.h +13 -0
- package/ios/Flir/src/FlirPreviewView.m +24 -0
- package/ios/Flir/src/FlirState.h +20 -0
- package/ios/Flir/src/FlirState.m +79 -0
- package/ios/Flir/src/FlirViewManager.h +9 -0
- package/ios/Flir/src/FlirViewManager.m +16 -0
- package/package.json +61 -0
- package/react-native.config.js +14 -0
- package/scripts/copy_ios_libs.sh +32 -0
- package/scripts/download-sdk.js +62 -0
- package/scripts/prepare-binaries.sh +171 -0
- package/sdk-manifest.json +30 -0
- package/src/FlirDownload.ts +78 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +7 -0
- package/src/index.ts +7 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const https = require('https');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
const crypto = require('crypto');
|
|
7
|
+
|
|
8
|
+
const manifest = require('../sdk-manifest.json');
|
|
9
|
+
const platform = process.argv[2] || (process.platform === 'darwin' ? 'ios' : 'android');
|
|
10
|
+
|
|
11
|
+
const config = manifest[platform];
|
|
12
|
+
if (!config) {
|
|
13
|
+
console.error(`Unknown platform: ${platform}`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const downloadUrl = platform === 'ios' ? config.downloadUrl : config.directDownload.downloadUrl;
|
|
18
|
+
const expectedHash = platform === 'ios' ? config.sha256 : config.directDownload.sha256;
|
|
19
|
+
const destDir = platform === 'ios' ? 'ios/Flir/libs' : 'android/Flir/libs';
|
|
20
|
+
|
|
21
|
+
console.log(`Downloading ${platform} SDK...`);
|
|
22
|
+
|
|
23
|
+
const zipPath = path.join(__dirname, '..', `${platform}-sdk.zip`);
|
|
24
|
+
const file = fs.createWriteStream(zipPath);
|
|
25
|
+
|
|
26
|
+
https.get(downloadUrl, (response) => {
|
|
27
|
+
const total = parseInt(response.headers['content-length'], 10);
|
|
28
|
+
let downloaded = 0;
|
|
29
|
+
|
|
30
|
+
response.on('data', (chunk) => {
|
|
31
|
+
downloaded += chunk.length;
|
|
32
|
+
const pct = ((downloaded / total) * 100).toFixed(1);
|
|
33
|
+
process.stdout.write(`\rProgress: ${pct}%`);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
response.pipe(file);
|
|
37
|
+
|
|
38
|
+
file.on('finish', () => {
|
|
39
|
+
console.log('\nVerifying checksum...');
|
|
40
|
+
|
|
41
|
+
const hash = crypto.createHash('sha256');
|
|
42
|
+
const data = fs.readFileSync(zipPath);
|
|
43
|
+
hash.update(data);
|
|
44
|
+
const actualHash = hash.digest('hex');
|
|
45
|
+
|
|
46
|
+
if (actualHash !== expectedHash) {
|
|
47
|
+
console.error('Checksum mismatch!');
|
|
48
|
+
fs.unlinkSync(zipPath);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
console.log('Extracting...');
|
|
53
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
54
|
+
execSync(`unzip -o "${zipPath}" -d "${destDir}"`);
|
|
55
|
+
fs.unlinkSync(zipPath);
|
|
56
|
+
|
|
57
|
+
console.log(`Done! SDK installed to ${destDir}`);
|
|
58
|
+
});
|
|
59
|
+
}).on('error', (err) => {
|
|
60
|
+
console.error('Download failed:', err.message);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
});
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# FLIR SDK Binaries Preparation Script
|
|
4
|
+
# This script prepares SDK binaries for upload to the flir-sdk-binaries repository
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
echo "🔧 FLIR SDK Binaries Preparation"
|
|
9
|
+
echo "=================================="
|
|
10
|
+
echo ""
|
|
11
|
+
|
|
12
|
+
# Colors for output
|
|
13
|
+
RED='\033[0;31m'
|
|
14
|
+
GREEN='\033[0;32m'
|
|
15
|
+
YELLOW='\033[1;33m'
|
|
16
|
+
NC='\033[0m' # No Color
|
|
17
|
+
|
|
18
|
+
# Create temporary directory for binaries
|
|
19
|
+
TEMP_DIR="$(pwd)/temp-sdk-binaries"
|
|
20
|
+
mkdir -p "$TEMP_DIR"
|
|
21
|
+
|
|
22
|
+
echo "📦 Step 1: Creating iOS SDK archive..."
|
|
23
|
+
cd ios/Flir/libs
|
|
24
|
+
zip -r "$TEMP_DIR/ios-sdk.zip" *.framework -x "*.gitkeep"
|
|
25
|
+
cd ../../..
|
|
26
|
+
|
|
27
|
+
echo "✅ iOS SDK archive created"
|
|
28
|
+
echo ""
|
|
29
|
+
|
|
30
|
+
echo "📦 Step 2: Creating Android SDK archive..."
|
|
31
|
+
cd android/Flir/libs
|
|
32
|
+
zip -r "$TEMP_DIR/android-sdk.zip" *.aar -x "*.gitkeep"
|
|
33
|
+
cd ../../..
|
|
34
|
+
|
|
35
|
+
echo "✅ Android SDK archive created"
|
|
36
|
+
echo ""
|
|
37
|
+
|
|
38
|
+
echo "🔐 Step 3: Calculating SHA256 checksums..."
|
|
39
|
+
echo ""
|
|
40
|
+
|
|
41
|
+
IOS_HASH=$(shasum -a 256 "$TEMP_DIR/ios-sdk.zip" | awk '{print $1}')
|
|
42
|
+
ANDROID_HASH=$(shasum -a 256 "$TEMP_DIR/android-sdk.zip" | awk '{print $1}')
|
|
43
|
+
|
|
44
|
+
IOS_SIZE=$(stat -f%z "$TEMP_DIR/ios-sdk.zip" 2>/dev/null || stat -c%s "$TEMP_DIR/ios-sdk.zip")
|
|
45
|
+
ANDROID_SIZE=$(stat -f%z "$TEMP_DIR/android-sdk.zip" 2>/dev/null || stat -c%s "$TEMP_DIR/android-sdk.zip")
|
|
46
|
+
|
|
47
|
+
echo -e "${GREEN}iOS SDK:${NC}"
|
|
48
|
+
echo " File: $TEMP_DIR/ios-sdk.zip"
|
|
49
|
+
echo " Size: $(numfmt --to=iec-i --suffix=B $IOS_SIZE 2>/dev/null || echo "$IOS_SIZE bytes")"
|
|
50
|
+
echo " SHA256: $IOS_HASH"
|
|
51
|
+
echo ""
|
|
52
|
+
|
|
53
|
+
echo -e "${GREEN}Android SDK:${NC}"
|
|
54
|
+
echo " File: $TEMP_DIR/android-sdk.zip"
|
|
55
|
+
echo " Size: $(numfmt --to=iec-i --suffix=B $ANDROID_SIZE 2>/dev/null || echo "$ANDROID_SIZE bytes")"
|
|
56
|
+
echo " SHA256: $ANDROID_HASH"
|
|
57
|
+
echo ""
|
|
58
|
+
|
|
59
|
+
echo "📝 Step 4: Creating updated sdk-manifest.json..."
|
|
60
|
+
cat > "$TEMP_DIR/sdk-manifest.json" << EOF
|
|
61
|
+
{
|
|
62
|
+
"version": "1.0.0",
|
|
63
|
+
"sdkVersion": "4.16.0",
|
|
64
|
+
"ios": {
|
|
65
|
+
"downloadUrl": "https://github.com/PraveenOjha/flir-sdk-binaries/releases/download/v1.0.0/ios-sdk.zip",
|
|
66
|
+
"sha256": "$IOS_HASH",
|
|
67
|
+
"sizeBytes": $IOS_SIZE,
|
|
68
|
+
"frameworks": [
|
|
69
|
+
"ThermalSDK.framework",
|
|
70
|
+
"MeterLink.framework",
|
|
71
|
+
"libavcodec.58.dylib.framework",
|
|
72
|
+
"libavformat.58.dylib.framework",
|
|
73
|
+
"libavutil.56.dylib.framework",
|
|
74
|
+
"libswscale.5.dylib.framework",
|
|
75
|
+
"libswresample.3.dylib.framework",
|
|
76
|
+
"libavfilter.7.dylib.framework",
|
|
77
|
+
"libavdevice.58.dylib.framework",
|
|
78
|
+
"liblive666.dylib.framework"
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"android": {
|
|
82
|
+
"playFeatureModule": "flir_sdk",
|
|
83
|
+
"directDownload": {
|
|
84
|
+
"downloadUrl": "https://github.com/PraveenOjha/flir-sdk-binaries/releases/download/v1.0.0/android-sdk.zip",
|
|
85
|
+
"sha256": "$ANDROID_HASH",
|
|
86
|
+
"sizeBytes": $ANDROID_SIZE,
|
|
87
|
+
"files": ["thermalsdk-release.aar", "androidsdk-release.aar"]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
EOF
|
|
92
|
+
|
|
93
|
+
echo "✅ Updated manifest created at: $TEMP_DIR/sdk-manifest.json"
|
|
94
|
+
echo ""
|
|
95
|
+
|
|
96
|
+
echo "📋 Step 5: Creating GitHub release instructions..."
|
|
97
|
+
cat > "$TEMP_DIR/RELEASE_INSTRUCTIONS.md" << 'EOF'
|
|
98
|
+
# FLIR SDK Binaries Release Instructions
|
|
99
|
+
|
|
100
|
+
## 1. Create the Repository
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Create new repository on GitHub
|
|
104
|
+
gh repo create PraveenOjha/flir-sdk-binaries --public --description "FLIR SDK binaries for on-demand download"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## 2. Create GitHub Release
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
cd temp-sdk-binaries
|
|
111
|
+
|
|
112
|
+
# Create release
|
|
113
|
+
gh release create v1.0.0 \
|
|
114
|
+
--repo PraveenOjha/flir-sdk-binaries \
|
|
115
|
+
--title "FLIR SDK Binaries v1.0.0" \
|
|
116
|
+
--notes "Initial release of FLIR SDK binaries for React Native wrapper on-demand download"
|
|
117
|
+
|
|
118
|
+
# Upload iOS SDK
|
|
119
|
+
gh release upload v1.0.0 ios-sdk.zip \
|
|
120
|
+
--repo PraveenOjha/flir-sdk-binaries
|
|
121
|
+
|
|
122
|
+
# Upload Android SDK
|
|
123
|
+
gh release upload v1.0.0 android-sdk.zip \
|
|
124
|
+
--repo PraveenOjha/flir-sdk-binaries
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 3. Update Main Repository
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Copy updated manifest to main repository
|
|
131
|
+
cp sdk-manifest.json ../sdk-manifest.json
|
|
132
|
+
|
|
133
|
+
# Commit and push
|
|
134
|
+
cd ..
|
|
135
|
+
git add sdk-manifest.json
|
|
136
|
+
git commit -m "Update sdk-manifest.json with actual SHA256 checksums"
|
|
137
|
+
git push
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## 4. Verify Downloads
|
|
141
|
+
|
|
142
|
+
Test the download URLs:
|
|
143
|
+
- https://github.com/PraveenOjha/flir-sdk-binaries/releases/download/v1.0.0/ios-sdk.zip
|
|
144
|
+
- https://github.com/PraveenOjha/flir-sdk-binaries/releases/download/v1.0.0/android-sdk.zip
|
|
145
|
+
|
|
146
|
+
## 5. Publish to npm
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npm publish
|
|
150
|
+
```
|
|
151
|
+
EOF
|
|
152
|
+
|
|
153
|
+
echo "✅ Release instructions created at: $TEMP_DIR/RELEASE_INSTRUCTIONS.md"
|
|
154
|
+
echo ""
|
|
155
|
+
|
|
156
|
+
echo -e "${GREEN}✨ All Done!${NC}"
|
|
157
|
+
echo ""
|
|
158
|
+
echo "📁 Files created in: $TEMP_DIR"
|
|
159
|
+
echo " - ios-sdk.zip"
|
|
160
|
+
echo " - android-sdk.zip"
|
|
161
|
+
echo " - sdk-manifest.json (with real checksums)"
|
|
162
|
+
echo " - RELEASE_INSTRUCTIONS.md"
|
|
163
|
+
echo ""
|
|
164
|
+
echo -e "${YELLOW}Next steps:${NC}"
|
|
165
|
+
echo "1. Review the files in $TEMP_DIR"
|
|
166
|
+
echo "2. Follow instructions in RELEASE_INSTRUCTIONS.md"
|
|
167
|
+
echo "3. Create GitHub repository and release"
|
|
168
|
+
echo "4. Update main repository with new sdk-manifest.json"
|
|
169
|
+
echo "5. Test the download functionality"
|
|
170
|
+
echo "6. Publish to npm"
|
|
171
|
+
echo ""
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"sdkVersion": "4.16.0",
|
|
4
|
+
"ios": {
|
|
5
|
+
"downloadUrl": "https://github.com/PraveenOjha/flir-sdk-binaries/releases/download/v1.0.0/ios-sdk.zip",
|
|
6
|
+
"sha256": "3a349e5ea7d5868256d7f2e3da818909a6ed6f098e114bf435aac4ada1d7855b",
|
|
7
|
+
"sizeBytes": 28106299,
|
|
8
|
+
"frameworks": [
|
|
9
|
+
"ThermalSDK.framework",
|
|
10
|
+
"MeterLink.framework",
|
|
11
|
+
"libavcodec.58.dylib.framework",
|
|
12
|
+
"libavformat.58.dylib.framework",
|
|
13
|
+
"libavutil.56.dylib.framework",
|
|
14
|
+
"libswscale.5.dylib.framework",
|
|
15
|
+
"libswresample.3.dylib.framework",
|
|
16
|
+
"libavfilter.7.dylib.framework",
|
|
17
|
+
"libavdevice.58.dylib.framework",
|
|
18
|
+
"liblive666.dylib.framework"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"android": {
|
|
22
|
+
"playFeatureModule": "flir_sdk",
|
|
23
|
+
"directDownload": {
|
|
24
|
+
"downloadUrl": "https://github.com/PraveenOjha/flir-sdk-binaries/releases/download/v1.0.0/android-sdk.zip",
|
|
25
|
+
"sha256": "d4901615e39e396126bde0dbccd4a234e64cda1d6f9464a30e317e1c5cb9c5e9",
|
|
26
|
+
"sizeBytes": 103912094,
|
|
27
|
+
"files": ["thermalsdk-release.aar", "androidsdk-release.aar"]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const FlirDownloadNative = NativeModules.FlirDownloadManager;
|
|
4
|
+
const FlirEmitter = FlirDownloadNative ? new NativeEventEmitter(FlirDownloadNative) : null;
|
|
5
|
+
|
|
6
|
+
export interface DownloadProgress {
|
|
7
|
+
bytesDownloaded: number;
|
|
8
|
+
totalBytes: number;
|
|
9
|
+
percent: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface FlirDownloadAPI {
|
|
13
|
+
isAvailable(): Promise<boolean>;
|
|
14
|
+
getDownloadSize(): Promise<number>;
|
|
15
|
+
getDownloadSizeFormatted(): Promise<string>;
|
|
16
|
+
download(onProgress?: (progress: DownloadProgress) => void): Promise<void>;
|
|
17
|
+
cancel(): void;
|
|
18
|
+
delete(): Promise<boolean>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class FlirDownloadManager implements FlirDownloadAPI {
|
|
22
|
+
private subscriptions: any[] = [];
|
|
23
|
+
|
|
24
|
+
async isAvailable(): Promise<boolean> {
|
|
25
|
+
if (!FlirDownloadNative) return false;
|
|
26
|
+
return FlirDownloadNative.isFlirAvailable();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async getDownloadSize(): Promise<number> {
|
|
30
|
+
if (!FlirDownloadNative) return 0;
|
|
31
|
+
return FlirDownloadNative.getDownloadSize();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async getDownloadSizeFormatted(): Promise<string> {
|
|
35
|
+
const bytes = await this.getDownloadSize();
|
|
36
|
+
const mb = bytes / (1024 * 1024);
|
|
37
|
+
return mb >= 1000 ? `${(mb / 1024).toFixed(1)} GB` : `${mb.toFixed(0)} MB`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async download(onProgress?: (progress: DownloadProgress) => void): Promise<void> {
|
|
41
|
+
if (!FlirDownloadNative || !FlirEmitter) {
|
|
42
|
+
throw new Error('FlirDownloadManager not available');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (await this.isAvailable()) return;
|
|
46
|
+
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
this.cleanup();
|
|
49
|
+
|
|
50
|
+
this.subscriptions.push(
|
|
51
|
+
FlirEmitter!.addListener('FlirDownloadProgress', (e: DownloadProgress) => onProgress?.(e)),
|
|
52
|
+
FlirEmitter!.addListener('FlirDownloadComplete', () => { this.cleanup(); resolve(); }),
|
|
53
|
+
FlirEmitter!.addListener('FlirDownloadError', (e: { error: string }) => { this.cleanup(); reject(new Error(e.error)); })
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
FlirDownloadNative.downloadFlirSDK()
|
|
57
|
+
.then(() => { this.cleanup(); resolve(); })
|
|
58
|
+
.catch((e: Error) => { this.cleanup(); reject(e); });
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
cancel(): void {
|
|
63
|
+
FlirDownloadNative?.cancelDownload();
|
|
64
|
+
this.cleanup();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async delete(): Promise<boolean> {
|
|
68
|
+
if (!FlirDownloadNative) return false;
|
|
69
|
+
return FlirDownloadNative.deleteSDK();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private cleanup(): void {
|
|
73
|
+
this.subscriptions.forEach(s => s.remove());
|
|
74
|
+
this.subscriptions = [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const FlirDownload = new FlirDownloadManager();
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface DownloadProgress {
|
|
2
|
+
bytesDownloaded: number;
|
|
3
|
+
totalBytes: number;
|
|
4
|
+
percent: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface FlirDownloadAPI {
|
|
8
|
+
isAvailable(): Promise<boolean>;
|
|
9
|
+
getDownloadSize(): Promise<number>;
|
|
10
|
+
getDownloadSizeFormatted(): Promise<string>;
|
|
11
|
+
download(onProgress?: (progress: DownloadProgress) => void): Promise<void>;
|
|
12
|
+
cancel(): void;
|
|
13
|
+
delete(): Promise<boolean>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare const FlirDownload: FlirDownloadAPI;
|
|
17
|
+
export declare const FlirModule: any;
|
package/src/index.js
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { FlirDownload } from './FlirDownload';
|
|
2
|
+
export type { DownloadProgress, FlirDownloadAPI } from './FlirDownload';
|
|
3
|
+
|
|
4
|
+
// Re-export existing FlirModule functionality
|
|
5
|
+
// Note: FlirModule should be imported from the native module
|
|
6
|
+
import { NativeModules } from 'react-native';
|
|
7
|
+
export const FlirModule = NativeModules.FlirModule;
|