@simplysm/capacitor-plugin-auto-update 13.0.97 → 13.0.98

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.
Files changed (2) hide show
  1. package/README.md +124 -0
  2. package/package.json +6 -6
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # @simplysm/capacitor-plugin-auto-update
2
+
3
+ Capacitor Auto Update Plugin -- APK installation and OTA update for Android Capacitor apps.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @simplysm/capacitor-plugin-auto-update
9
+ ```
10
+
11
+ ## API Overview
12
+
13
+ ### Types
14
+
15
+ | API | Type | Description |
16
+ |-----|------|-------------|
17
+ | `VersionInfo` | interface | App version info (`versionName`, `versionCode`) |
18
+
19
+ ### Interfaces
20
+
21
+ | API | Type | Description |
22
+ |-----|------|-------------|
23
+ | `ApkInstallerPlugin` | interface | Low-level Capacitor plugin interface for APK operations |
24
+
25
+ ### Classes
26
+
27
+ | API | Type | Description |
28
+ |-----|------|-------------|
29
+ | `ApkInstaller` | abstract class | APK installation and permission management |
30
+ | `AutoUpdate` | abstract class | OTA update flow (server-based or external storage) |
31
+
32
+ ## `VersionInfo`
33
+
34
+ ```typescript
35
+ interface VersionInfo {
36
+ versionName: string;
37
+ versionCode: string;
38
+ }
39
+ ```
40
+
41
+ ## `ApkInstallerPlugin`
42
+
43
+ ```typescript
44
+ interface ApkInstallerPlugin {
45
+ install(options: { uri: string }): Promise<void>;
46
+ checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
47
+ requestPermissions(): Promise<void>;
48
+ getVersionInfo(): Promise<VersionInfo>;
49
+ }
50
+ ```
51
+
52
+ Low-level Capacitor plugin interface. Use `ApkInstaller` static methods instead of calling this directly.
53
+
54
+ ## `ApkInstaller`
55
+
56
+ ```typescript
57
+ abstract class ApkInstaller {
58
+ static async checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
59
+ static async requestPermissions(): Promise<void>;
60
+ static async install(apkUri: string): Promise<void>;
61
+ static async getVersionInfo(): Promise<VersionInfo>;
62
+ }
63
+ ```
64
+
65
+ APK installation plugin.
66
+ - Android: Executes APK install intent, manages `REQUEST_INSTALL_PACKAGES` permission.
67
+ - Browser: Shows alert message and returns normally.
68
+
69
+ ## `AutoUpdate`
70
+
71
+ ```typescript
72
+ abstract class AutoUpdate {
73
+ static async run(opt: {
74
+ log: (messageHtml: string) => void;
75
+ serviceClient: ServiceClient;
76
+ }): Promise<void>;
77
+
78
+ static async runByExternalStorage(opt: {
79
+ log: (messageHtml: string) => void;
80
+ dirPath: string;
81
+ }): Promise<void>;
82
+ }
83
+ ```
84
+
85
+ - `run` -- Downloads the latest APK from a service server and installs it. Compares versions via semver.
86
+ - `runByExternalStorage` -- Finds the latest APK file in an external storage directory and installs it.
87
+
88
+ Both methods check install permissions, display progress via the `log` callback (HTML), and freeze the app after installation to await restart.
89
+
90
+ ## Usage Examples
91
+
92
+ ### Check permissions and install APK
93
+
94
+ ```typescript
95
+ import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
96
+
97
+ const perms = await ApkInstaller.checkPermissions();
98
+ if (!perms.granted) {
99
+ await ApkInstaller.requestPermissions();
100
+ }
101
+ await ApkInstaller.install("content://com.example.provider/latest.apk");
102
+ ```
103
+
104
+ ### Server-based auto update
105
+
106
+ ```typescript
107
+ import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
108
+
109
+ await AutoUpdate.run({
110
+ log: (html) => { document.getElementById("status")!.innerHTML = html; },
111
+ serviceClient: myServiceClient,
112
+ });
113
+ ```
114
+
115
+ ### External storage auto update
116
+
117
+ ```typescript
118
+ import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
119
+
120
+ await AutoUpdate.runByExternalStorage({
121
+ log: (html) => { document.getElementById("status")!.innerHTML = html; },
122
+ dirPath: "MyApp/updates",
123
+ });
124
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-auto-update",
3
- "version": "13.0.97",
3
+ "version": "13.0.98",
4
4
  "description": "Simplysm Package - Capacitor Auto Update Plugin",
5
5
  "author": "simplysm",
6
6
  "license": "MIT",
@@ -19,11 +19,11 @@
19
19
  ],
20
20
  "dependencies": {
21
21
  "semver": "^7.7.4",
22
- "@simplysm/capacitor-plugin-file-system": "13.0.97",
23
- "@simplysm/core-browser": "13.0.97",
24
- "@simplysm/core-common": "13.0.97",
25
- "@simplysm/service-client": "13.0.97",
26
- "@simplysm/service-common": "13.0.97"
22
+ "@simplysm/capacitor-plugin-file-system": "13.0.98",
23
+ "@simplysm/core-browser": "13.0.98",
24
+ "@simplysm/service-client": "13.0.98",
25
+ "@simplysm/core-common": "13.0.98",
26
+ "@simplysm/service-common": "13.0.98"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@capacitor/core": "^7.6.0",