native-update 1.0.3 → 1.0.5

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.
@@ -55,12 +55,11 @@ src/__tests__/
55
55
  3. **Test Update Flow**
56
56
  ```typescript
57
57
  // Check for updates
58
- const update = await NativeUpdate.checkForUpdate();
58
+ const update = await NativeUpdate.sync();
59
59
 
60
- // Download if available
61
- if (update.available) {
62
- await NativeUpdate.downloadUpdate();
63
- await NativeUpdate.applyUpdate();
60
+ // Update will be downloaded and applied based on sync result
61
+ if (update.status === 'UPDATE_INSTALLED') {
62
+ await NativeUpdate.reload();
64
63
  }
65
64
  ```
66
65
 
@@ -124,10 +123,11 @@ try {
124
123
  node tools/bundle-signer.js sign test-bundle.zip private-key.pem
125
124
 
126
125
  # Verify in app
127
- const isValid = await NativeUpdate.verifySignature(
128
- bundleData,
129
- signature
130
- );
126
+ const isValid = await NativeUpdate.LiveUpdate.validateUpdate({
127
+ bundlePath: 'bundle-path',
128
+ checksum: 'bundle-checksum',
129
+ signature: signature
130
+ });
131
131
  ```
132
132
 
133
133
  ### 4. Performance Testing
@@ -135,7 +135,7 @@ const isValid = await NativeUpdate.verifySignature(
135
135
  #### Download Performance
136
136
  ```typescript
137
137
  // Monitor download speed
138
- NativeUpdate.addListener('downloadProgress', (progress) => {
138
+ NativeUpdate.LiveUpdate.addListener('downloadProgress', (progress) => {
139
139
  console.log(`Speed: ${progress.speed} MB/s`);
140
140
  console.log(`Progress: ${progress.percent}%`);
141
141
  });
@@ -175,18 +175,16 @@ NativeUpdate.addListener('downloadProgress', (progress) => {
175
175
  publicKey: 'your-public-key',
176
176
  });
177
177
 
178
- // Check
179
- const update = await NativeUpdate.checkForUpdate();
180
- if (!update.available) return;
181
-
182
- // Download with progress
183
- await NativeUpdate.downloadUpdate();
178
+ // Sync will check, download and apply update
179
+ const result = await NativeUpdate.sync();
184
180
 
185
- // Apply
186
- await NativeUpdate.applyUpdate();
181
+ if (result.status === 'UPDATE_INSTALLED') {
182
+ // Reload to apply update
183
+ await NativeUpdate.reload();
184
+ }
187
185
 
188
186
  // Verify
189
- const current = await NativeUpdate.getCurrentVersion();
187
+ const current = await NativeUpdate.current();
190
188
  console.log('Updated to:', current.version);
191
189
  }
192
190
  ```
@@ -196,7 +194,7 @@ NativeUpdate.addListener('downloadProgress', (progress) => {
196
194
  #### Network Failures
197
195
  ```typescript
198
196
  // Test offline behavior
199
- await NativeUpdate.checkForUpdate()
197
+ await NativeUpdate.sync()
200
198
  .catch(error => {
201
199
  expect(error.code).toBe('NETWORK_ERROR');
202
200
  });
@@ -205,8 +203,9 @@ await NativeUpdate.checkForUpdate()
205
203
  #### Corrupted Bundles
206
204
  ```typescript
207
205
  // Test checksum validation
208
- const corruptedBundle = await fetch('corrupted-bundle.zip');
209
- await NativeUpdate.applyUpdate(corruptedBundle)
206
+ await NativeUpdate.download({
207
+ version: 'corrupted-version'
208
+ })
210
209
  .catch(error => {
211
210
  expect(error.code).toBe('CHECKSUM_ERROR');
212
211
  });
@@ -217,15 +216,15 @@ await NativeUpdate.applyUpdate(corruptedBundle)
217
216
  ```typescript
218
217
  // Test rollback mechanism
219
218
  async function testRollback() {
220
- // Apply bad update
221
- await NativeUpdate.applyUpdate(badUpdate);
219
+ // Set bad update
220
+ await NativeUpdate.set(badUpdate);
222
221
 
223
222
  // Simulate app crash
224
223
  await simulateCrash();
225
224
 
226
225
  // Verify rollback on restart
227
- const version = await NativeUpdate.getCurrentVersion();
228
- expect(version).toBe(previousVersion);
226
+ const version = await NativeUpdate.current();
227
+ expect(version.version).toBe(previousVersion);
229
228
  }
230
229
  ```
231
230
 
@@ -269,8 +268,8 @@ jobs:
269
268
  - [ ] Invalid configs rejected
270
269
  - [ ] Channel switching works
271
270
 
272
- - [ ] **Update Check**
273
- - [ ] Returns correct update status
271
+ - [ ] **Update Sync**
272
+ - [ ] Returns correct sync status
274
273
  - [ ] Respects version constraints
275
274
  - [ ] Handles network errors
276
275
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-update",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Foundation package for building a comprehensive update system for Capacitor apps. Provides architecture and interfaces but requires backend implementation.",
5
5
  "type": "module",
6
6
  "main": "dist/plugin.cjs.js",