@capgo/capacitor-updater 7.2.21 → 7.4.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/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
  };
@@ -1014,12 +1019,22 @@ Returns null if no next bundle is set.
1014
1019
  This URL and versions are used to download the bundle from the server, If you use backend all information will be gived by the method getLatest.
1015
1020
  If you don't use backend, you need to provide the URL and version of the bundle. Checksum and sessionKey are required if you encrypted the bundle with the CLI command encrypt, you should receive them as result of the command.
1016
1021
 
1017
- | Prop | Type | Description | Default | Since |
1018
- | ---------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----- |
1019
- | **`url`** | <code>string</code> | The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.) | | |
1020
- | **`version`** | <code>string</code> | The version code/name of this bundle/version | | |
1021
- | **`sessionKey`** | <code>string</code> | The session key for the update, when the bundle is encrypted with a session key | <code>undefined</code> | 4.0.0 |
1022
- | **`checksum`** | <code>string</code> | The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted | <code>undefined</code> | 4.0.0 |
1022
+ | Prop | Type | Description | Default | Since |
1023
+ | ---------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ----- |
1024
+ | **`url`** | <code>string</code> | The URL of the bundle zip file (e.g: dist.zip) to be downloaded. (This can be any URL. E.g: Amazon S3, a GitHub tag, any other place you've hosted your bundle.) | | |
1025
+ | **`version`** | <code>string</code> | The version code/name of this bundle/version | | |
1026
+ | **`sessionKey`** | <code>string</code> | The session key for the update, when the bundle is encrypted with a session key | <code>undefined</code> | 4.0.0 |
1027
+ | **`checksum`** | <code>string</code> | The checksum for the update, it should be in sha256 and encrypted with private key if the bundle is encrypted | <code>undefined</code> | 4.0.0 |
1028
+ | **`manifest`** | <code>ManifestEntry[]</code> | The manifest for multi-file downloads | <code>undefined</code> | 6.1.0 |
1029
+
1030
+
1031
+ #### ManifestEntry
1032
+
1033
+ | Prop | Type |
1034
+ | ------------------ | --------------------------- |
1035
+ | **`file_name`** | <code>string \| null</code> |
1036
+ | **`file_hash`** | <code>string \| null</code> |
1037
+ | **`download_url`** | <code>string \| null</code> |
1023
1038
 
1024
1039
 
1025
1040
  #### BundleId
@@ -1088,15 +1103,6 @@ If you don't use backend, you need to provide the URL and version of the bundle.
1088
1103
  | **`manifest`** | <code>ManifestEntry[]</code> | | 6.1 |
1089
1104
 
1090
1105
 
1091
- #### ManifestEntry
1092
-
1093
- | Prop | Type |
1094
- | ------------------ | --------------------------- |
1095
- | **`file_name`** | <code>string \| null</code> |
1096
- | **`file_hash`** | <code>string \| null</code> |
1097
- | **`download_url`** | <code>string \| null</code> |
1098
-
1099
-
1100
1106
  #### GetLatestOptions
1101
1107
 
1102
1108
  | Prop | Type | Description | Default | Since |
@@ -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
- return this.isBuiltin() ? BundleStatus.SUCCESS : this.status;
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
- return (
150
- "BundleInfo{" +
151
- "id='" +
152
- getId() +
153
- '\'' +
154
- ", version='" +
155
- getVersionName() +
156
- '\'' +
157
- ", downloaded='" +
158
- getDownloaded() +
159
- '\'' +
160
- ", checksum='" +
161
- getChecksum() +
162
- '\'' +
163
- ", status=" +
164
- getStatus() +
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
  }