@capgo/capacitor-updater 7.2.20 → 7.3.3
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 +6 -1
- package/android/src/main/java/ee/forgr/capacitor_updater/BundleInfo.java +48 -26
- package/android/src/main/java/ee/forgr/capacitor_updater/CapacitorUpdaterPlugin.java +152 -141
- package/android/src/main/java/ee/forgr/capacitor_updater/{CapacitorUpdater.java → CapgoUpdater.java} +93 -59
- package/android/src/main/java/ee/forgr/capacitor_updater/CryptoCipherV2.java +13 -8
- package/android/src/main/java/ee/forgr/capacitor_updater/DelayUpdateUtils.java +43 -43
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadService.java +24 -20
- package/android/src/main/java/ee/forgr/capacitor_updater/DownloadWorkerManager.java +8 -4
- package/android/src/main/java/ee/forgr/capacitor_updater/Logger.java +338 -0
- package/dist/docs.json +16 -0
- package/dist/esm/definitions.d.ts +7 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/AES.swift +5 -3
- package/ios/Plugin/CapacitorUpdaterPlugin.swift +108 -94
- package/ios/Plugin/{CapacitorUpdater.swift → CapgoUpdater.swift} +71 -69
- package/ios/Plugin/CryptoCipherV2.swift +31 -26
- package/ios/Plugin/DelayUpdateUtils.swift +26 -24
- package/ios/Plugin/Logger.swift +289 -0
- package/ios/Plugin/UserDefaultsExtension.swift +0 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -141,6 +141,7 @@ This informs Capacitor Updater that the current update bundle has loaded succesf
|
|
|
141
141
|
- Add this to your application.
|
|
142
142
|
```javascript
|
|
143
143
|
const version = await CapacitorUpdater.download({
|
|
144
|
+
version: '0.0.4',
|
|
144
145
|
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
|
|
145
146
|
})
|
|
146
147
|
await CapacitorUpdater.set(version); // sets the new version, and reloads the app
|
|
@@ -158,6 +159,7 @@ You might also consider performing auto-update when application state changes, a
|
|
|
158
159
|
if (state.isActive) {
|
|
159
160
|
// Ensure download occurs while the app is active, or download may fail
|
|
160
161
|
version = await CapacitorUpdater.download({
|
|
162
|
+
version: '0.0.4',
|
|
161
163
|
url: 'https://github.com/Cap-go/demo-app/releases/download/0.0.4/dist.zip',
|
|
162
164
|
})
|
|
163
165
|
}
|
|
@@ -249,6 +251,7 @@ CapacitorUpdater can be configured with these options:
|
|
|
249
251
|
| **`defaultChannel`** | <code>string</code> | Set the default channel for the app in the config. Case sensitive. This will setting will override the default channel set in the cloud, but will still respect overrides made in the cloud. | <code>undefined</code> | 5.5.0 |
|
|
250
252
|
| **`appId`** | <code>string</code> | Configure the app id for the app in the config. | <code>undefined</code> | 6.0.0 |
|
|
251
253
|
| **`keepUrlPathAfterReload`** | <code>boolean</code> | Configure the plugin to keep the URL path after a reload. WARNING: When a reload is triggered, 'window.history' will be cleared. | <code>false</code> | 6.8.0 |
|
|
254
|
+
| **`disableJSLogging`** | <code>boolean</code> | Disable the JavaScript logging of the plugin. if true, the plugin will not log to the JavaScript console. only the native log will be done | <code>false</code> | 7.3.0 |
|
|
252
255
|
|
|
253
256
|
### Examples
|
|
254
257
|
|
|
@@ -281,7 +284,8 @@ In `capacitor.config.json`:
|
|
|
281
284
|
"allowModifyUrl": undefined,
|
|
282
285
|
"defaultChannel": undefined,
|
|
283
286
|
"appId": undefined,
|
|
284
|
-
"keepUrlPathAfterReload": undefined
|
|
287
|
+
"keepUrlPathAfterReload": undefined,
|
|
288
|
+
"disableJSLogging": undefined
|
|
285
289
|
}
|
|
286
290
|
}
|
|
287
291
|
}
|
|
@@ -321,6 +325,7 @@ const config: CapacitorConfig = {
|
|
|
321
325
|
defaultChannel: undefined,
|
|
322
326
|
appId: undefined,
|
|
323
327
|
keepUrlPathAfterReload: undefined,
|
|
328
|
+
disableJSLogging: undefined,
|
|
324
329
|
},
|
|
325
330
|
},
|
|
326
331
|
};
|
|
@@ -43,11 +43,11 @@ public class BundleInfo {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public BundleInfo(final String id, final String version, final BundleStatus status, final String downloaded, final String checksum) {
|
|
46
|
-
this.downloaded = downloaded.trim();
|
|
47
|
-
this.id = id;
|
|
46
|
+
this.downloaded = downloaded != null ? downloaded.trim() : "";
|
|
47
|
+
this.id = id != null ? id : "";
|
|
48
48
|
this.version = version;
|
|
49
|
-
this.checksum = checksum;
|
|
50
|
-
this.status = status;
|
|
49
|
+
this.checksum = checksum != null ? checksum : "";
|
|
50
|
+
this.status = status != null ? status : BundleStatus.ERROR;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
public Boolean isBuiltin() {
|
|
@@ -71,7 +71,7 @@ public class BundleInfo {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
public String getDownloaded() {
|
|
74
|
-
return this.isBuiltin() ? DOWNLOADED_BUILTIN : this.downloaded;
|
|
74
|
+
return this.isBuiltin() ? DOWNLOADED_BUILTIN : (this.downloaded != null ? this.downloaded : "");
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
public BundleInfo setDownloaded(Date downloaded) {
|
|
@@ -79,7 +79,7 @@ public class BundleInfo {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
public String getChecksum() {
|
|
82
|
-
return this.isBuiltin() ? "" : this.checksum;
|
|
82
|
+
return this.isBuiltin() ? "" : (this.checksum != null ? this.checksum : "");
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
public BundleInfo setChecksum(String checksum) {
|
|
@@ -103,7 +103,10 @@ public class BundleInfo {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
public BundleStatus getStatus() {
|
|
106
|
-
|
|
106
|
+
if (this.isBuiltin()) {
|
|
107
|
+
return BundleStatus.SUCCESS;
|
|
108
|
+
}
|
|
109
|
+
return this.status != null ? this.status : BundleStatus.ERROR;
|
|
107
110
|
}
|
|
108
111
|
|
|
109
112
|
public BundleInfo setStatus(BundleStatus status) {
|
|
@@ -127,7 +130,7 @@ public class BundleInfo {
|
|
|
127
130
|
result.put("version", this.getVersionName());
|
|
128
131
|
result.put("downloaded", this.getDownloaded());
|
|
129
132
|
result.put("checksum", this.getChecksum());
|
|
130
|
-
result.put("status", this.getStatus());
|
|
133
|
+
result.put("status", this.getStatus().toString());
|
|
131
134
|
return result;
|
|
132
135
|
}
|
|
133
136
|
|
|
@@ -146,23 +149,42 @@ public class BundleInfo {
|
|
|
146
149
|
|
|
147
150
|
@Override
|
|
148
151
|
public String toString() {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
",
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
152
|
+
try {
|
|
153
|
+
// Build JSON manually with extra safety checks
|
|
154
|
+
StringBuilder json = new StringBuilder();
|
|
155
|
+
json.append("{");
|
|
156
|
+
|
|
157
|
+
// Safe ID access
|
|
158
|
+
String safeId = this.id != null ? this.id : "";
|
|
159
|
+
if (this.isBuiltin()) safeId = ID_BUILTIN;
|
|
160
|
+
json.append("\"id\":\"").append(safeId).append("\",");
|
|
161
|
+
|
|
162
|
+
// Safe version access
|
|
163
|
+
String safeVersion = this.version != null ? this.version : ID_BUILTIN;
|
|
164
|
+
json.append("\"version\":\"").append(safeVersion).append("\",");
|
|
165
|
+
|
|
166
|
+
// Safe downloaded access
|
|
167
|
+
String safeDownloaded = this.downloaded != null ? this.downloaded : "";
|
|
168
|
+
if (this.isBuiltin()) safeDownloaded = DOWNLOADED_BUILTIN;
|
|
169
|
+
json.append("\"downloaded\":\"").append(safeDownloaded).append("\",");
|
|
170
|
+
|
|
171
|
+
// Safe checksum access
|
|
172
|
+
String safeChecksum = this.checksum != null ? this.checksum : "";
|
|
173
|
+
json.append("\"checksum\":\"").append(safeChecksum).append("\",");
|
|
174
|
+
|
|
175
|
+
// Safe status access
|
|
176
|
+
BundleStatus safeStatus = this.status != null ? this.status : BundleStatus.ERROR;
|
|
177
|
+
if (this.isBuiltin()) safeStatus = BundleStatus.SUCCESS;
|
|
178
|
+
json.append("\"status\":\"").append(safeStatus.toString()).append("\"");
|
|
179
|
+
|
|
180
|
+
json.append("}");
|
|
181
|
+
return json.toString();
|
|
182
|
+
} catch (Exception e) {
|
|
183
|
+
// Log the error for debugging but still return valid JSON
|
|
184
|
+
System.err.println("BundleInfo toString() error: " + e.getMessage());
|
|
185
|
+
e.printStackTrace();
|
|
186
|
+
// Return absolute minimal JSON
|
|
187
|
+
return "{\"id\":\"" + (this.id != null ? this.id : "unknown") + "\",\"status\":\"error\"}";
|
|
188
|
+
}
|
|
167
189
|
}
|
|
168
190
|
}
|