native-update 1.1.2 → 1.1.4
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/cli/index.js +22 -14
- package/dist/esm/core/event-emitter.d.ts +33 -0
- package/dist/esm/core/event-emitter.js +75 -0
- package/dist/esm/core/event-emitter.js.map +1 -0
- package/dist/esm/core/plugin-manager.d.ts +16 -0
- package/dist/esm/core/plugin-manager.js +50 -0
- package/dist/esm/core/plugin-manager.js.map +1 -1
- package/dist/esm/definitions.d.ts +60 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/plugin.js +51 -10
- package/dist/esm/plugin.js.map +1 -1
- package/dist/plugin.cjs.js +1 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.esm.js +1 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/docs/NATIVE_UPDATES_GUIDE.md +1 -1
- package/docs/QUICK_START.md +1 -1
- package/docs/api/app-update-api.md +9 -1
- package/docs/api/events-api.md +123 -0
- package/docs/features/app-updates.md +4 -4
- package/docs/getting-started/quick-start.md +1 -1
- package/package.json +15 -5
|
@@ -191,7 +191,7 @@ export class AndroidFlexibleUpdate {
|
|
|
191
191
|
|
|
192
192
|
// Listen for download progress
|
|
193
193
|
NativeUpdate.addListener(
|
|
194
|
-
'
|
|
194
|
+
'appUpdateProgress',
|
|
195
195
|
(progress) => {
|
|
196
196
|
console.log(
|
|
197
197
|
`Download progress: ${progress.bytesDownloaded} / ${progress.totalBytesToDownload}`
|
package/docs/QUICK_START.md
CHANGED
|
@@ -229,7 +229,7 @@ export class AndroidUpdateProgress {
|
|
|
229
229
|
|
|
230
230
|
// Track progress
|
|
231
231
|
NativeUpdate.addListener(
|
|
232
|
-
'
|
|
232
|
+
'appUpdateProgress',
|
|
233
233
|
(progress) => {
|
|
234
234
|
this.downloadProgress = Math.round(
|
|
235
235
|
(progress.bytesDownloaded / progress.totalBytesToDownload) * 100
|
|
@@ -73,7 +73,15 @@ await NativeUpdate.openAppStore({
|
|
|
73
73
|
|
|
74
74
|
## Events
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
App update events are available for monitoring the native app update process. See the [Events API Reference](./events-api.md#app-update-events) for complete documentation of the following events:
|
|
77
|
+
|
|
78
|
+
- `appUpdateStateChanged` - Fired when update state changes
|
|
79
|
+
- `appUpdateProgress` - Monitor download progress for flexible updates
|
|
80
|
+
- `appUpdateAvailable` - Notified when a new version is available
|
|
81
|
+
- `appUpdateReady` - Update downloaded and ready to install
|
|
82
|
+
- `appUpdateFailed` - Update process failed
|
|
83
|
+
- `appUpdateNotificationClicked` - User clicked update notification
|
|
84
|
+
- `appUpdateInstallClicked` - User clicked install in notification
|
|
77
85
|
|
|
78
86
|
## Platform Differences
|
|
79
87
|
|
package/docs/api/events-api.md
CHANGED
|
@@ -64,6 +64,129 @@ NativeUpdate.addListener('downloadProgress', (progress) => {
|
|
|
64
64
|
}
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
+
## App Update Events
|
|
68
|
+
|
|
69
|
+
### appUpdateStateChanged
|
|
70
|
+
|
|
71
|
+
Fired when the native app update state changes.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
NativeUpdate.addListener('appUpdateStateChanged', (state) => {
|
|
75
|
+
console.log('App update state:', state.status);
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Event Data:**
|
|
80
|
+
```typescript
|
|
81
|
+
{
|
|
82
|
+
status: InstallStatus; // See InstallStatus enum
|
|
83
|
+
installErrorCode?: number; // Error code if status is FAILED
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### appUpdateProgress
|
|
88
|
+
|
|
89
|
+
Fired during app update download progress.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
NativeUpdate.addListener('appUpdateProgress', (progress) => {
|
|
93
|
+
console.log(`Download progress: ${progress.percent}%`);
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Event Data:**
|
|
98
|
+
```typescript
|
|
99
|
+
{
|
|
100
|
+
percent: number; // Download percentage (0-100)
|
|
101
|
+
bytesDownloaded: number; // Bytes downloaded so far
|
|
102
|
+
totalBytes: number; // Total download size
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### appUpdateAvailable
|
|
107
|
+
|
|
108
|
+
Fired when a new app update is detected.
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
NativeUpdate.addListener('appUpdateAvailable', (info) => {
|
|
112
|
+
console.log(`Update available: ${info.availableVersion}`);
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Event Data:**
|
|
117
|
+
```typescript
|
|
118
|
+
{
|
|
119
|
+
currentVersion: string;
|
|
120
|
+
availableVersion: string;
|
|
121
|
+
updatePriority: number; // 0-5, where 5 is critical
|
|
122
|
+
updateSize?: number; // Update size in bytes
|
|
123
|
+
releaseNotes?: string[]; // Release notes array
|
|
124
|
+
storeUrl?: string; // App store URL
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### appUpdateReady
|
|
129
|
+
|
|
130
|
+
Fired when the app update is downloaded and ready to install.
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
NativeUpdate.addListener('appUpdateReady', (event) => {
|
|
134
|
+
console.log('Update ready to install');
|
|
135
|
+
// Prompt user to restart/install
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Event Data:**
|
|
140
|
+
```typescript
|
|
141
|
+
{
|
|
142
|
+
message: string; // "Update downloaded and ready to install"
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### appUpdateFailed
|
|
147
|
+
|
|
148
|
+
Fired when an app update fails.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
NativeUpdate.addListener('appUpdateFailed', (error) => {
|
|
152
|
+
console.error('Update failed:', error.error);
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Event Data:**
|
|
157
|
+
```typescript
|
|
158
|
+
{
|
|
159
|
+
error: string; // Error message
|
|
160
|
+
code: string; // Error code
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### appUpdateNotificationClicked
|
|
165
|
+
|
|
166
|
+
Fired when the user clicks on an update notification.
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
NativeUpdate.addListener('appUpdateNotificationClicked', () => {
|
|
170
|
+
console.log('User clicked update notification');
|
|
171
|
+
// Navigate to update screen
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Event Data:** Empty object `{}`
|
|
176
|
+
|
|
177
|
+
### appUpdateInstallClicked
|
|
178
|
+
|
|
179
|
+
Fired when the user clicks the install button in an update notification.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
NativeUpdate.addListener('appUpdateInstallClicked', () => {
|
|
183
|
+
console.log('User clicked install in notification');
|
|
184
|
+
// Start update installation
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Event Data:** Empty object `{}`
|
|
189
|
+
|
|
67
190
|
## Background Update Events
|
|
68
191
|
|
|
69
192
|
### backgroundUpdateProgress
|
|
@@ -95,7 +95,7 @@ class AppUpdateManager {
|
|
|
95
95
|
private setupUpdateListeners() {
|
|
96
96
|
// Android flexible update state changes
|
|
97
97
|
NativeUpdate.addListener(
|
|
98
|
-
'
|
|
98
|
+
'appUpdateStateChanged',
|
|
99
99
|
(state) => {
|
|
100
100
|
this.handleFlexibleUpdateState(state);
|
|
101
101
|
}
|
|
@@ -103,7 +103,7 @@ class AppUpdateManager {
|
|
|
103
103
|
|
|
104
104
|
// Download progress for flexible updates
|
|
105
105
|
NativeUpdate.addListener(
|
|
106
|
-
'
|
|
106
|
+
'appUpdateProgress',
|
|
107
107
|
(progress) => {
|
|
108
108
|
this.downloadProgress = progress.percent;
|
|
109
109
|
this.updateProgressUI(progress);
|
|
@@ -276,7 +276,7 @@ const androidUpdate = {
|
|
|
276
276
|
|
|
277
277
|
// Monitor progress
|
|
278
278
|
const listener = await NativeUpdate.addListener(
|
|
279
|
-
'
|
|
279
|
+
'appUpdateProgress',
|
|
280
280
|
(progress) => {
|
|
281
281
|
console.log(
|
|
282
282
|
`Downloaded: ${progress.bytesDownloaded}/${progress.totalBytes}`
|
|
@@ -551,7 +551,7 @@ class UpdateProgressUI {
|
|
|
551
551
|
this.createProgressUI();
|
|
552
552
|
|
|
553
553
|
NativeUpdate.addListener(
|
|
554
|
-
'
|
|
554
|
+
'appUpdateProgress',
|
|
555
555
|
(progress) => {
|
|
556
556
|
this.updateProgress(progress);
|
|
557
557
|
}
|
|
@@ -159,7 +159,7 @@ async function startFlexibleUpdate() {
|
|
|
159
159
|
|
|
160
160
|
// Listen for download completion
|
|
161
161
|
const listener = await NativeUpdate.addListener(
|
|
162
|
-
'
|
|
162
|
+
'appUpdateStateChanged',
|
|
163
163
|
(state) => {
|
|
164
164
|
if (state.status === 'DOWNLOADED') {
|
|
165
165
|
// Prompt user to restart
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-update",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
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",
|
|
@@ -44,7 +44,17 @@
|
|
|
44
44
|
"plugin",
|
|
45
45
|
"native",
|
|
46
46
|
"app-updates",
|
|
47
|
-
"native-updates"
|
|
47
|
+
"native-updates",
|
|
48
|
+
"ota",
|
|
49
|
+
"live-updates",
|
|
50
|
+
"hot-reload",
|
|
51
|
+
"app-store",
|
|
52
|
+
"google-play",
|
|
53
|
+
"in-app-updates",
|
|
54
|
+
"app-reviews",
|
|
55
|
+
"ios",
|
|
56
|
+
"android",
|
|
57
|
+
"hybrid"
|
|
48
58
|
],
|
|
49
59
|
"scripts": {
|
|
50
60
|
"build": "npm run clean && npm run tsc && rollup -c rollup.config.js",
|
|
@@ -78,14 +88,14 @@
|
|
|
78
88
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
79
89
|
"@rollup/plugin-terser": "^0.4.4",
|
|
80
90
|
"@types/node": "^24.3.0",
|
|
81
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
82
|
-
"@typescript-eslint/parser": "^8.
|
|
91
|
+
"@typescript-eslint/eslint-plugin": "^8.40.0",
|
|
92
|
+
"@typescript-eslint/parser": "^8.40.0",
|
|
83
93
|
"@vitest/ui": "^3.2.4",
|
|
84
94
|
"eslint": "^9.33.0",
|
|
85
95
|
"happy-dom": "^18.0.1",
|
|
86
96
|
"prettier": "^3.6.2",
|
|
87
97
|
"rimraf": "^6.0.1",
|
|
88
|
-
"rollup": "^4.46.
|
|
98
|
+
"rollup": "^4.46.3",
|
|
89
99
|
"typescript": "^5.9.2",
|
|
90
100
|
"vitest": "^3.2.4"
|
|
91
101
|
},
|