react-native-rgb 0.2.0 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rgb",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React Native library for Bitcoin RGB Protocol",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -18,6 +18,7 @@
18
18
  "android",
19
19
  "ios",
20
20
  "cpp",
21
+ "scripts",
21
22
  "*.podspec",
22
23
  "react-native.config.js",
23
24
  "!ios/build",
@@ -0,0 +1,102 @@
1
+ const https = require('https');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { execSync } = require('child_process');
5
+
6
+ const URL =
7
+ 'https://github.com/RGB-Tools/rgb-lib-swift/releases/download/0.3.0-beta.4/rgb_libFFI.xcframework.zip';
8
+ const IOS_DIR = path.join(__dirname, '..', 'ios');
9
+ const ZIP_FILE = path.join(IOS_DIR, 'rgb_libFFI.xcframework.zip');
10
+ const XCFRAMEWORK_DIR = path.join(IOS_DIR, 'rgb_libFFI.xcframework');
11
+
12
+ if (process.platform !== 'darwin') {
13
+ console.log('Skipping iOS framework download: not running on macOS');
14
+ process.exit(0);
15
+ }
16
+
17
+ if (fs.existsSync(XCFRAMEWORK_DIR)) {
18
+ console.log('rgb_libFFI.xcframework already exists, skipping download');
19
+ process.exit(0);
20
+ }
21
+
22
+ console.log('Downloading rgb_libFFI.xcframework...');
23
+
24
+ if (!fs.existsSync(IOS_DIR)) {
25
+ fs.mkdirSync(IOS_DIR, { recursive: true });
26
+ }
27
+
28
+ function downloadFile(url, dest) {
29
+ return new Promise((resolve, reject) => {
30
+ const file = fs.createWriteStream(dest);
31
+
32
+ https
33
+ .get(url, (response) => {
34
+ if (response.statusCode === 301 || response.statusCode === 302) {
35
+ return downloadFile(response.headers.location, dest)
36
+ .then(resolve)
37
+ .catch(reject);
38
+ }
39
+
40
+ if (response.statusCode !== 200) {
41
+ reject(
42
+ new Error(
43
+ `Failed to download: ${response.statusCode} ${response.statusMessage}`
44
+ )
45
+ );
46
+ return;
47
+ }
48
+
49
+ response.pipe(file);
50
+
51
+ file.on('finish', () => {
52
+ file.close();
53
+ resolve();
54
+ });
55
+ })
56
+ .on('error', (err) => {
57
+ fs.unlinkSync(dest);
58
+ reject(err);
59
+ });
60
+ });
61
+ }
62
+
63
+ function extractZip(zipPath, extractDir) {
64
+ try {
65
+ execSync(`unzip -q -o "${zipPath}" -d "${extractDir}"`, {
66
+ stdio: 'inherit',
67
+ });
68
+ } catch (error) {
69
+ throw new Error(`Failed to extract zip: ${error.message}`);
70
+ }
71
+ }
72
+
73
+ (async () => {
74
+ try {
75
+ // Download the zip file
76
+ await downloadFile(URL, ZIP_FILE);
77
+ console.log('Download complete');
78
+
79
+ // Extract the zip file
80
+ console.log('Extracting rgb_libFFI.xcframework...');
81
+ extractZip(ZIP_FILE, IOS_DIR);
82
+
83
+ // Remove the zip file after extraction
84
+ fs.unlinkSync(ZIP_FILE);
85
+ console.log('Extraction complete');
86
+
87
+ // Verify the xcframework exists
88
+ if (fs.existsSync(XCFRAMEWORK_DIR)) {
89
+ console.log(
90
+ 'rgb_libFFI.xcframework successfully downloaded and extracted'
91
+ );
92
+ } else {
93
+ throw new Error('xcframework not found after extraction');
94
+ }
95
+ } catch (error) {
96
+ console.error(
97
+ 'Error downloading or extracting rgb_libFFI.xcframework:',
98
+ error.message
99
+ );
100
+ process.exit(1);
101
+ }
102
+ })();