cordova-plugin-hot-updates 2.1.2 → 2.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/README.md +87 -42
- package/package.json +2 -2
- package/plugin.xml +5 -1
- package/src/ios/HotUpdates+Helpers.h +23 -0
- package/src/ios/HotUpdates+Helpers.m +24 -0
- package/src/ios/HotUpdates.h +6 -31
- package/src/ios/HotUpdates.m +128 -250
- package/src/ios/HotUpdatesConstants.h +51 -0
- package/src/ios/HotUpdatesConstants.m +46 -0
- package/www/HotUpdates.js +109 -116
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Cordova Hot Updates Plugin v2.1
|
|
1
|
+
# Cordova Hot Updates Plugin v2.2.1
|
|
2
2
|
|
|
3
3
|
Frontend-controlled manual hot updates for Cordova iOS applications using WebView Reload approach.
|
|
4
4
|
|
|
@@ -85,6 +85,66 @@ function downloadAndInstall(url, version) {
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
## Error Handling
|
|
89
|
+
|
|
90
|
+
All errors are returned in a unified format for programmatic handling:
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
// Error format
|
|
94
|
+
callback({
|
|
95
|
+
error: {
|
|
96
|
+
code: "ERROR_CODE", // Code for programmatic handling
|
|
97
|
+
message: "Detailed message" // Detailed message for logs
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
// Success result
|
|
102
|
+
callback(null)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Error Codes
|
|
106
|
+
|
|
107
|
+
#### getUpdate() errors:
|
|
108
|
+
- `UPDATE_DATA_REQUIRED` - Missing updateData parameter
|
|
109
|
+
- `URL_REQUIRED` - Missing url parameter
|
|
110
|
+
- `DOWNLOAD_IN_PROGRESS` - Download already in progress
|
|
111
|
+
- `DOWNLOAD_FAILED` - Network download error (message contains details)
|
|
112
|
+
- `HTTP_ERROR` - HTTP status != 200 (message contains status code)
|
|
113
|
+
- `TEMP_DIR_ERROR` - Error creating temporary directory
|
|
114
|
+
- `EXTRACTION_FAILED` - Error extracting ZIP archive
|
|
115
|
+
- `WWW_NOT_FOUND` - www folder not found in archive
|
|
116
|
+
|
|
117
|
+
#### forceUpdate() errors:
|
|
118
|
+
- `NO_UPDATE_READY` - getUpdate() not called first
|
|
119
|
+
- `UPDATE_FILES_NOT_FOUND` - Downloaded update files not found
|
|
120
|
+
- `INSTALL_FAILED` - Error copying files (message contains details)
|
|
121
|
+
|
|
122
|
+
#### canary() errors:
|
|
123
|
+
- `VERSION_REQUIRED` - Missing version parameter
|
|
124
|
+
|
|
125
|
+
### Error Handling Example
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
window.hotUpdate.getUpdate({url: 'http://...'}, function(result) {
|
|
129
|
+
if (result && result.error) {
|
|
130
|
+
console.error('[HotUpdates]', result.error.code, ':', result.error.message);
|
|
131
|
+
|
|
132
|
+
switch(result.error.code) {
|
|
133
|
+
case 'HTTP_ERROR':
|
|
134
|
+
// Handle HTTP errors
|
|
135
|
+
break;
|
|
136
|
+
case 'DOWNLOAD_FAILED':
|
|
137
|
+
// Handle network errors
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
console.error('Unknown error:', result.error);
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
console.log('Update downloaded successfully');
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
88
148
|
## API Reference
|
|
89
149
|
|
|
90
150
|
All API methods are available via `window.hotUpdate` after the `deviceready` event.
|
|
@@ -208,6 +268,32 @@ window.hotUpdate.getIgnoreList(function(result) {
|
|
|
208
268
|
|
|
209
269
|
---
|
|
210
270
|
|
|
271
|
+
### window.hotUpdate.getVersionInfo(callback)
|
|
272
|
+
|
|
273
|
+
Returns version information (debug method).
|
|
274
|
+
|
|
275
|
+
**Parameters:**
|
|
276
|
+
- `callback` (Function) - `callback(info)`
|
|
277
|
+
- `info.appBundleVersion` (string) - Native app version from Info.plist
|
|
278
|
+
- `info.installedVersion` (string|null) - Current hot update version
|
|
279
|
+
- `info.previousVersion` (string|null) - Last working version (for rollback)
|
|
280
|
+
- `info.canaryVersion` (string|null) - Version confirmed by canary
|
|
281
|
+
- `info.pendingVersion` (string|null) - Version pending installation
|
|
282
|
+
- `info.hasPendingUpdate` (boolean) - Whether pending update exists
|
|
283
|
+
- `info.ignoreList` (string[]) - Array of problematic versions
|
|
284
|
+
|
|
285
|
+
**Example:**
|
|
286
|
+
```javascript
|
|
287
|
+
window.hotUpdate.getVersionInfo(function(info) {
|
|
288
|
+
console.log('App version:', info.appBundleVersion);
|
|
289
|
+
console.log('Installed:', info.installedVersion);
|
|
290
|
+
console.log('Previous:', info.previousVersion);
|
|
291
|
+
console.log('Pending:', info.hasPendingUpdate ? info.pendingVersion : 'none');
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
211
297
|
## Complete Update Flow
|
|
212
298
|
|
|
213
299
|
```javascript
|
|
@@ -402,47 +488,6 @@ document.addEventListener('deviceready', function() {
|
|
|
402
488
|
}, false);
|
|
403
489
|
```
|
|
404
490
|
|
|
405
|
-
## Migration from v1.0.0
|
|
406
|
-
|
|
407
|
-
**Removed methods:**
|
|
408
|
-
- `getCurrentVersion()` - Manage in JS
|
|
409
|
-
- `getPendingUpdateInfo()` - Not needed
|
|
410
|
-
- `checkForUpdates()` - Frontend controls
|
|
411
|
-
- `downloadUpdate()` - Use `getUpdate()`
|
|
412
|
-
- `installUpdate()` - Use `forceUpdate()`
|
|
413
|
-
|
|
414
|
-
**New API:**
|
|
415
|
-
- `window.hotUpdate.getUpdate({url, version?}, callback)`
|
|
416
|
-
- `window.hotUpdate.forceUpdate(callback)`
|
|
417
|
-
- `window.hotUpdate.canary(version, callback)`
|
|
418
|
-
- `window.hotUpdate.getIgnoreList(callback)`
|
|
419
|
-
|
|
420
|
-
**Changes:**
|
|
421
|
-
- API via `window.hotUpdate` (not `window.HotUpdates`)
|
|
422
|
-
- Callback signature: `callback(error)` pattern
|
|
423
|
-
- No automatic background checking
|
|
424
|
-
|
|
425
|
-
## Changelog
|
|
426
|
-
|
|
427
|
-
### v2.1.2 (2025-11-13)
|
|
428
|
-
|
|
429
|
-
**Breaking Changes:**
|
|
430
|
-
- Changed API from `window.HotUpdates` to `window.hotUpdate`
|
|
431
|
-
- Removed automatic update checking
|
|
432
|
-
- Simplified to 4 methods: `getUpdate`, `forceUpdate`, `canary`, `getIgnoreList`
|
|
433
|
-
|
|
434
|
-
**New Features:**
|
|
435
|
-
- Frontend-controlled manual updates
|
|
436
|
-
- Two-step update flow
|
|
437
|
-
- 20-second canary timer
|
|
438
|
-
- IgnoreList system
|
|
439
|
-
- Auto-install on next launch
|
|
440
|
-
- WebView cache clearing
|
|
441
|
-
|
|
442
|
-
### v1.0.0
|
|
443
|
-
|
|
444
|
-
- Initial release
|
|
445
|
-
|
|
446
491
|
## License
|
|
447
492
|
|
|
448
493
|
Custom Non-Commercial License - See [LICENSE](LICENSE) file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cordova-plugin-hot-updates",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Frontend-controlled manual hot updates for Cordova iOS apps using WebView Reload approach. Manual updates only, JavaScript controls all decisions.",
|
|
5
5
|
"main": "www/HotUpdates.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
8
|
"prepublishOnly": "npm run verify",
|
|
9
|
-
"verify": "node -e \"console.log('Verifying package structure...'); const fs = require('fs'); ['www/HotUpdates.js', 'src/ios/HotUpdates.h', 'src/ios/HotUpdates.m', 'plugin.xml', 'LICENSE', 'README.md'].forEach(f => { if (!fs.existsSync(f)) throw new Error('Missing required file: ' + f); }); console.log('✓ All required files present');\"",
|
|
9
|
+
"verify": "node -e \"console.log('Verifying package structure...'); const fs = require('fs'); ['www/HotUpdates.js', 'src/ios/HotUpdates.h', 'src/ios/HotUpdates.m', 'src/ios/HotUpdatesConstants.h', 'src/ios/HotUpdatesConstants.m', 'src/ios/HotUpdates+Helpers.h', 'src/ios/HotUpdates+Helpers.m', 'plugin.xml', 'LICENSE', 'README.md'].forEach(f => { if (!fs.existsSync(f)) throw new Error('Missing required file: ' + f); }); console.log('✓ All required files present');\"",
|
|
10
10
|
"pack-test": "npm pack && echo '\n✓ Package created. Test installation with: cordova plugin add ./cordova-plugin-hot-updates-*.tgz'",
|
|
11
11
|
"preversion": "npm run verify",
|
|
12
12
|
"postversion": "git push && git push --tags"
|
package/plugin.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
2
|
<plugin id="cordova-plugin-hot-updates"
|
|
3
|
-
version="2.1
|
|
3
|
+
version="2.2.1"
|
|
4
4
|
xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
5
5
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
|
6
6
|
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
<!-- Native iOS files -->
|
|
41
41
|
<source-file src="src/ios/HotUpdates.h" />
|
|
42
42
|
<source-file src="src/ios/HotUpdates.m" />
|
|
43
|
+
<source-file src="src/ios/HotUpdatesConstants.h" />
|
|
44
|
+
<source-file src="src/ios/HotUpdatesConstants.m" />
|
|
45
|
+
<source-file src="src/ios/HotUpdates+Helpers.h" />
|
|
46
|
+
<source-file src="src/ios/HotUpdates+Helpers.m" />
|
|
43
47
|
|
|
44
48
|
<!-- Required frameworks -->
|
|
45
49
|
<framework src="Foundation.framework" />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @file HotUpdates+Helpers.h
|
|
3
|
+
* @brief Helper methods for Hot Updates Plugin
|
|
4
|
+
* @details Category extension providing utility methods for error handling
|
|
5
|
+
* @version 2.1.0
|
|
6
|
+
* @date 2025-11-13
|
|
7
|
+
* @author Mustafin Vladimir
|
|
8
|
+
* @copyright Copyright (c) 2025. All rights reserved.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#import "HotUpdates.h"
|
|
12
|
+
|
|
13
|
+
@interface HotUpdates (Helpers)
|
|
14
|
+
|
|
15
|
+
/*!
|
|
16
|
+
* @brief Create error dictionary for JavaScript callback
|
|
17
|
+
* @param code Error code (e.g., "URL_REQUIRED")
|
|
18
|
+
* @param message Detailed message for logs
|
|
19
|
+
* @return Dictionary with error structure {error: {code: "...", message: "..."}}
|
|
20
|
+
*/
|
|
21
|
+
- (NSDictionary*)createError:(NSString*)code message:(NSString*)message;
|
|
22
|
+
|
|
23
|
+
@end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @file HotUpdates+Helpers.m
|
|
3
|
+
* @brief Implementation of helper methods for Hot Updates Plugin
|
|
4
|
+
* @details Provides utility methods for error handling and response formatting
|
|
5
|
+
* @version 2.1.0
|
|
6
|
+
* @date 2025-11-13
|
|
7
|
+
* @author Mustafin Vladimir
|
|
8
|
+
* @copyright Copyright (c) 2025. All rights reserved.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#import "HotUpdates+Helpers.h"
|
|
12
|
+
|
|
13
|
+
@implementation HotUpdates (Helpers)
|
|
14
|
+
|
|
15
|
+
- (NSDictionary*)createError:(NSString*)code message:(NSString*)message {
|
|
16
|
+
return @{
|
|
17
|
+
@"error": @{
|
|
18
|
+
@"code": code,
|
|
19
|
+
@"message": message
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@end
|
package/src/ios/HotUpdates.h
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
#import <UIKit/UIKit.h>
|
|
21
21
|
#import <Cordova/CDVPlugin.h>
|
|
22
|
+
#import "HotUpdatesConstants.h"
|
|
23
|
+
|
|
22
24
|
@interface HotUpdates : CDVPlugin
|
|
23
25
|
{
|
|
24
26
|
NSString *documentsPath;
|
|
@@ -30,40 +32,13 @@
|
|
|
30
32
|
NSString *previousVersionPath; // Путь к предыдущей версии
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
//
|
|
34
|
-
- (void)pluginInitialize;
|
|
35
|
-
- (void)loadConfiguration;
|
|
36
|
-
- (void)initializeWWWFolder;
|
|
37
|
-
- (void)checkAndInstallPendingUpdate;
|
|
38
|
-
- (void)switchToUpdatedContentWithReload;
|
|
39
|
-
- (void)reloadWebView;
|
|
40
|
-
|
|
41
|
-
// Update management methods (internal)
|
|
42
|
-
- (void)installPendingUpdate:(NSString*)newVersion;
|
|
43
|
-
- (BOOL)unzipFile:(NSString *)zipPath toDestination:(NSString *)destinationPath;
|
|
44
|
-
|
|
45
|
-
// Version comparison utilities
|
|
46
|
-
- (NSComparisonResult)compareVersion:(NSString*)version1 withVersion:(NSString*)version2;
|
|
47
|
-
|
|
48
|
-
// JavaScript callable methods (minimal set for debugging)
|
|
49
|
-
- (void)getCurrentVersion:(CDVInvokedUrlCommand*)command;
|
|
50
|
-
- (void)getPendingUpdateInfo:(CDVInvokedUrlCommand*)command;
|
|
51
|
-
|
|
52
|
-
// Ignore List management (JS can only read, native controls)
|
|
53
|
-
- (void)getIgnoreList:(CDVInvokedUrlCommand*)command;
|
|
54
|
-
|
|
55
|
-
// Debug methods (for manual testing only)
|
|
56
|
-
- (void)addToIgnoreList:(CDVInvokedUrlCommand*)command;
|
|
57
|
-
- (void)removeFromIgnoreList:(CDVInvokedUrlCommand*)command;
|
|
58
|
-
- (void)clearIgnoreList:(CDVInvokedUrlCommand*)command;
|
|
59
|
-
|
|
60
|
-
// Update methods (v2.1.0 - manual updates only)
|
|
35
|
+
// JavaScript API methods (v2.1.0)
|
|
61
36
|
- (void)getUpdate:(CDVInvokedUrlCommand*)command; // Download update
|
|
62
37
|
- (void)forceUpdate:(CDVInvokedUrlCommand*)command; // Install downloaded update
|
|
63
38
|
- (void)canary:(CDVInvokedUrlCommand*)command; // Confirm successful load
|
|
64
|
-
- (void)
|
|
39
|
+
- (void)getIgnoreList:(CDVInvokedUrlCommand*)command; // Get ignore list (JS reads only)
|
|
65
40
|
|
|
66
|
-
//
|
|
67
|
-
- (void)getVersionInfo:(CDVInvokedUrlCommand*)command;
|
|
41
|
+
// Debug method
|
|
42
|
+
- (void)getVersionInfo:(CDVInvokedUrlCommand*)command; // Get all version info for debugging
|
|
68
43
|
|
|
69
44
|
@end
|