@hot-updater/react-native 0.7.0 → 0.8.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/android/build.gradle +1 -1
- package/android/proguard-rules.pro +15 -0
- package/ios/HotUpdater/HotUpdater.mm +35 -39
- package/package.json +3 -3
package/android/build.gradle
CHANGED
|
@@ -65,7 +65,7 @@ android {
|
|
|
65
65
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
66
66
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
67
67
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
68
|
-
|
|
68
|
+
consumerProguardFiles 'proguard-rules.pro'
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
buildFeatures {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Old Architecture
|
|
2
|
+
# Invoked via reflection, when setting js bundle.
|
|
3
|
+
-keepclassmembers class com.facebook.react.ReactInstanceManager {
|
|
4
|
+
private final ** mBundleLoader;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
# New Architecture
|
|
8
|
+
# Keep fields accessed via reflection in ReactHost
|
|
9
|
+
-keepclassmembers class com.facebook.react.runtime.ReactHostImpl {
|
|
10
|
+
private final ** mReactHostDelegate;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
-keepclassmembers class * implements com.facebook.react.runtime.ReactHostDelegate {
|
|
14
|
+
** jsBundleLoader;
|
|
15
|
+
}
|
|
@@ -71,71 +71,66 @@ RCT_EXPORT_MODULE();
|
|
|
71
71
|
return success;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
- (
|
|
74
|
+
- (void)updateBundle:(NSString *)bundleId zipUrl:(NSURL *)zipUrl completion:(void (^)(BOOL success))completion {
|
|
75
75
|
if (!zipUrl) {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
77
|
+
[self setBundleURL:nil];
|
|
78
|
+
if (completion) completion(YES);
|
|
79
|
+
});
|
|
80
|
+
return;
|
|
78
81
|
}
|
|
79
|
-
|
|
82
|
+
|
|
80
83
|
NSString *basePath = [self stripPrefixFromPath:bundleId path:[zipUrl path]];
|
|
81
84
|
NSString *path = [self convertFileSystemPathFromBasePath:basePath];
|
|
82
|
-
|
|
85
|
+
|
|
83
86
|
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
|
|
84
87
|
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
|
|
85
|
-
|
|
86
|
-
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
87
|
-
__block BOOL success = NO;
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
NSURLSessionDownloadTask *downloadTask = [session downloadTaskWithURL:zipUrl
|
|
90
90
|
completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
|
|
91
91
|
if (error) {
|
|
92
92
|
NSLog(@"Failed to download data from URL: %@, error: %@", zipUrl, error);
|
|
93
|
-
|
|
94
|
-
dispatch_semaphore_signal(semaphore);
|
|
93
|
+
if (completion) completion(NO);
|
|
95
94
|
return;
|
|
96
95
|
}
|
|
97
|
-
|
|
96
|
+
|
|
98
97
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
99
98
|
NSError *folderError;
|
|
100
|
-
|
|
99
|
+
|
|
101
100
|
// Ensure directory exists
|
|
102
101
|
if (![fileManager createDirectoryAtPath:[path stringByDeletingLastPathComponent]
|
|
103
102
|
withIntermediateDirectories:YES
|
|
104
103
|
attributes:nil
|
|
105
104
|
error:&folderError]) {
|
|
106
105
|
NSLog(@"Failed to create folder: %@", folderError);
|
|
107
|
-
|
|
108
|
-
dispatch_semaphore_signal(semaphore);
|
|
106
|
+
if (completion) completion(NO);
|
|
109
107
|
return;
|
|
110
108
|
}
|
|
111
|
-
|
|
109
|
+
|
|
112
110
|
// Check if file already exists and remove it
|
|
113
111
|
if ([fileManager fileExistsAtPath:path]) {
|
|
114
112
|
NSError *removeError;
|
|
115
113
|
if (![fileManager removeItemAtPath:path error:&removeError]) {
|
|
116
114
|
NSLog(@"Failed to remove existing file: %@", removeError);
|
|
117
|
-
|
|
118
|
-
dispatch_semaphore_signal(semaphore);
|
|
115
|
+
if (completion) completion(NO);
|
|
119
116
|
return;
|
|
120
117
|
}
|
|
121
118
|
}
|
|
122
|
-
|
|
119
|
+
|
|
123
120
|
NSError *moveError;
|
|
124
121
|
if (![fileManager moveItemAtURL:location toURL:[NSURL fileURLWithPath:path] error:&moveError]) {
|
|
125
122
|
NSLog(@"Failed to save data: %@", moveError);
|
|
126
|
-
|
|
127
|
-
dispatch_semaphore_signal(semaphore);
|
|
123
|
+
if (completion) completion(NO);
|
|
128
124
|
return;
|
|
129
125
|
}
|
|
130
|
-
|
|
126
|
+
|
|
131
127
|
NSString *extractedPath = [path stringByDeletingLastPathComponent];
|
|
132
128
|
if (![self extractZipFileAtPath:path toDestination:extractedPath]) {
|
|
133
129
|
NSLog(@"Failed to extract zip file.");
|
|
134
|
-
|
|
135
|
-
dispatch_semaphore_signal(semaphore);
|
|
130
|
+
if (completion) completion(NO);
|
|
136
131
|
return;
|
|
137
132
|
}
|
|
138
|
-
|
|
133
|
+
|
|
139
134
|
NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtPath:extractedPath];
|
|
140
135
|
NSString *filename = nil;
|
|
141
136
|
for (NSString *file in enumerator) {
|
|
@@ -144,20 +139,21 @@ RCT_EXPORT_MODULE();
|
|
|
144
139
|
break;
|
|
145
140
|
}
|
|
146
141
|
}
|
|
147
|
-
|
|
142
|
+
|
|
148
143
|
if (filename) {
|
|
149
144
|
NSString *bundlePath = [extractedPath stringByAppendingPathComponent:filename];
|
|
150
145
|
NSLog(@"Setting bundle URL: %@", bundlePath);
|
|
151
|
-
|
|
152
|
-
|
|
146
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
147
|
+
[self setBundleURL:bundlePath];
|
|
148
|
+
if (completion) completion(YES);
|
|
149
|
+
});
|
|
153
150
|
} else {
|
|
154
151
|
NSLog(@"index.ios.bundle not found.");
|
|
155
|
-
|
|
152
|
+
if (completion) completion(NO);
|
|
156
153
|
}
|
|
157
|
-
|
|
158
|
-
dispatch_semaphore_signal(semaphore);
|
|
159
154
|
}];
|
|
160
|
-
|
|
155
|
+
|
|
156
|
+
|
|
161
157
|
// Add observer for progress updates
|
|
162
158
|
[downloadTask addObserver:self
|
|
163
159
|
forKeyPath:@"countOfBytesReceived"
|
|
@@ -167,11 +163,8 @@ RCT_EXPORT_MODULE();
|
|
|
167
163
|
forKeyPath:@"countOfBytesExpectedToReceive"
|
|
168
164
|
options:NSKeyValueObservingOptionNew
|
|
169
165
|
context:nil];
|
|
170
|
-
|
|
166
|
+
|
|
171
167
|
[downloadTask resume];
|
|
172
|
-
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
|
173
|
-
|
|
174
|
-
return success;
|
|
175
168
|
}
|
|
176
169
|
|
|
177
170
|
#pragma mark - Progress Updates
|
|
@@ -234,9 +227,12 @@ RCT_EXPORT_METHOD(updateBundle:(NSString *)bundleId zipUrl:(NSString *)zipUrlStr
|
|
|
234
227
|
if (![zipUrlString isEqualToString:@""]) {
|
|
235
228
|
zipUrl = [NSURL URLWithString:zipUrlString];
|
|
236
229
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
230
|
+
|
|
231
|
+
[self updateBundle:bundleId zipUrl:zipUrl completion:^(BOOL success) {
|
|
232
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
233
|
+
resolve(@[@(success)]);
|
|
234
|
+
});
|
|
235
|
+
}];
|
|
240
236
|
}
|
|
241
237
|
|
|
242
238
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React Native OTA solution for self-hosted",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"react-native-builder-bob": "^0.33.1"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@hot-updater/js": "0.
|
|
82
|
-
"@hot-updater/core": "0.
|
|
81
|
+
"@hot-updater/js": "0.8.0",
|
|
82
|
+
"@hot-updater/core": "0.8.0"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"build": "rslib build",
|