@simplysm/capacitor-plugin-auto-update 13.0.96 → 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 +81 -97
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -1,140 +1,124 @@
1
1
  # @simplysm/capacitor-plugin-auto-update
2
2
 
3
- Capacitor 자동 업데이트 플러그인. 서버에서 최신 APK를 확인하고 다운로드/설치하거나, 외부 스토리지의 APK 파일로 업데이트한다.
3
+ Capacitor Auto Update Plugin -- APK installation and OTA update for Android Capacitor apps.
4
4
 
5
- ## 설치
5
+ ## Installation
6
6
 
7
7
  ```bash
8
8
  npm install @simplysm/capacitor-plugin-auto-update
9
9
  ```
10
10
 
11
- **의존성:** `@simplysm/service-client`, `@simplysm/service-common`, `@simplysm/capacitor-plugin-file-system`, `@simplysm/core-common`, `@simplysm/core-browser`, `semver`
12
- **Peer:** `@capacitor/core` ^7.4.4
11
+ ## API Overview
13
12
 
14
- ## Export 목록
13
+ ### Types
15
14
 
16
- ```typescript
17
- // index.ts
18
- export { ApkInstaller } from "./ApkInstaller";
19
- export { AutoUpdate } from "./AutoUpdate";
20
- export type { ApkInstallerPlugin, VersionInfo } from "./ApkInstallerPlugin";
21
- ```
22
-
23
- ## 주요 사용법
15
+ | API | Type | Description |
16
+ |-----|------|-------------|
17
+ | `VersionInfo` | interface | App version info (`versionName`, `versionCode`) |
24
18
 
25
- ### 서버 기반 자동 업데이트
19
+ ### Interfaces
26
20
 
27
- 서버의 `AutoUpdateService`를 통해 최신 버전을 확인하고 APK를 다운로드/설치한다.
21
+ | API | Type | Description |
22
+ |-----|------|-------------|
23
+ | `ApkInstallerPlugin` | interface | Low-level Capacitor plugin interface for APK operations |
28
24
 
29
- ```typescript
30
- import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
31
- import type { ServiceClient } from "@simplysm/service-client";
25
+ ### Classes
32
26
 
33
- await AutoUpdate.run({
34
- serviceClient, // ServiceClient 인스턴스
35
- log: (messageHtml) => {
36
- // 진행 상태를 HTML로 표시 (에러, 다운로드 진행률 )
37
- },
38
- });
39
- ```
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) |
40
31
 
41
- 동작 흐름:
42
- 1. 서버에서 최신 버전 조회 (`AutoUpdateService.getLastVersion("android")`)
43
- 2. `REQUEST_INSTALL_PACKAGES` 권한 확인/요청 (매니페스트 미선언 시 재설치 유도)
44
- 3. 현재 앱 버전과 semver 비교 (최신이면 조기 반환)
45
- 4. APK 다운로드 (`fetchUrlBytes`, 진행률 콜백)
46
- 5. `appCache` 경로에 `latest.apk`로 저장
47
- 6. APK 설치 인텐트 실행 후 앱 정지 (`await new Promise(() => {})`)
32
+ ## `VersionInfo`
48
33
 
49
- 서버 서비스 인터페이스 (`@simplysm/service-common`):
50
34
  ```typescript
51
- interface AutoUpdateService {
52
- getLastVersion(platform: string): Promise<{ version: string; downloadPath: string } | undefined>;
35
+ interface VersionInfo {
36
+ versionName: string;
37
+ versionCode: string;
53
38
  }
54
39
  ```
55
40
 
56
- ### 외부 스토리지 기반 업데이트
57
-
58
- USB 또는 SD카드 등 외부 스토리지의 APK 파일로 업데이트한다. 파일명이 semver 형식이어야 한다 (예: `1.2.3.apk`).
41
+ ## `ApkInstallerPlugin`
59
42
 
60
43
  ```typescript
61
- await AutoUpdate.runByExternalStorage({
62
- dirPath: "updates", // 외부 스토리지 루트 기준 상대 경로
63
- log: (messageHtml) => {
64
- // 진행 상태 HTML 표시
65
- },
66
- });
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
+ }
67
50
  ```
68
51
 
69
- 동작 흐름:
70
- 1. `REQUEST_INSTALL_PACKAGES` 권한 확인/요청
71
- 2. 외부 스토리지의 `dirPath`에서 `.apk` 파일 목록 조회
72
- 3. 파일명(`1.2.3.apk` -> `1.2.3`)을 semver로 파싱하여 최신 버전 선택
73
- 4. 현재 앱 버전과 비교 후 설치
52
+ Low-level Capacitor plugin interface. Use `ApkInstaller` static methods instead of calling this directly.
74
53
 
75
- ### APK 설치 (저수준 API)
76
-
77
- `ApkInstaller`는 `AutoUpdate` 내부에서 사용되지만, 직접 호출도 가능하다.
54
+ ## `ApkInstaller`
78
55
 
79
56
  ```typescript
80
- import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
81
-
82
- // 권한 확인 (granted: 설치 허용됨, manifest: 매니페스트에 권한 선언됨)
83
- const perms = await ApkInstaller.checkPermissions();
84
- // { granted: boolean; manifest: boolean }
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
+ ```
85
64
 
86
- // 권한 요청 (Android 8+: 설정 화면으로 이동)
87
- await ApkInstaller.requestPermissions();
65
+ APK installation plugin.
66
+ - Android: Executes APK install intent, manages `REQUEST_INSTALL_PACKAGES` permission.
67
+ - Browser: Shows alert message and returns normally.
88
68
 
89
- // APK 설치 (content:// URI 필요, FileProvider URI)
90
- await ApkInstaller.install(apkUri);
69
+ ## `AutoUpdate`
91
70
 
92
- // 앱 버전 정보 조회
93
- const info = await ApkInstaller.getVersionInfo();
94
- // { versionName: "1.0.0", versionCode: "1" }
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
+ }
95
83
  ```
96
84
 
97
- ## API 레퍼런스
98
-
99
- ### `AutoUpdate` (abstract class, static 메서드)
100
-
101
- | 메서드 | 시그니처 | 설명 |
102
- |--------|----------|------|
103
- | `run` | `(opt: { log: (messageHtml: string) => void; serviceClient: ServiceClient }) => Promise<void>` | 서버 기반 자동 업데이트 |
104
- | `runByExternalStorage` | `(opt: { log: (messageHtml: string) => void; dirPath: string }) => Promise<void>` | 외부 스토리지 기반 업데이트 |
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.
105
87
 
106
- ### `ApkInstaller` (abstract class, static 메서드)
88
+ Both methods check install permissions, display progress via the `log` callback (HTML), and freeze the app after installation to await restart.
107
89
 
108
- | 메서드 | 시그니처 | 설명 |
109
- |--------|----------|------|
110
- | `checkPermissions` | `() => Promise<{ granted: boolean; manifest: boolean }>` | 설치 권한 확인 |
111
- | `requestPermissions` | `() => Promise<void>` | 설치 권한 요청 |
112
- | `install` | `(apkUri: string) => Promise<void>` | APK 설치 (content:// URI) |
113
- | `getVersionInfo` | `() => Promise<VersionInfo>` | 앱 버전 정보 조회 |
90
+ ## Usage Examples
114
91
 
115
- ### `VersionInfo` (interface)
92
+ ### Check permissions and install APK
116
93
 
117
94
  ```typescript
118
- interface VersionInfo {
119
- versionName: string; // semver 문자열 (예: "1.0.0")
120
- versionCode: string; // 빌드 번호 문자열
95
+ import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
96
+
97
+ const perms = await ApkInstaller.checkPermissions();
98
+ if (!perms.granted) {
99
+ await ApkInstaller.requestPermissions();
121
100
  }
101
+ await ApkInstaller.install("content://com.example.provider/latest.apk");
122
102
  ```
123
103
 
124
- ## 플랫폼 지원
104
+ ### Server-based auto update
125
105
 
126
- | 기능 | Android | Web |
127
- |------|---------|-----|
128
- | APK 설치 | FileProvider URI + ACTION_VIEW 인텐트 | alert 표시 후 정상 반환 |
129
- | 버전 확인 | PackageManager API | `import.meta.env.__VER__` (기본값 `"0.0.0"`) |
130
- | 권한 관리 | REQUEST_INSTALL_PACKAGES (Android 8+) | 항상 granted/manifest = true |
131
- | 권한 설정 이동 | ACTION_MANAGE_UNKNOWN_APP_SOURCES | no-op |
106
+ ```typescript
107
+ import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
132
108
 
133
- ## Android 네이티브 구현
109
+ await AutoUpdate.run({
110
+ log: (html) => { document.getElementById("status")!.innerHTML = html; },
111
+ serviceClient: myServiceClient,
112
+ });
113
+ ```
114
+
115
+ ### External storage auto update
134
116
 
135
- - **패키지:** `kr.co.simplysm.capacitor.apkinstaller`
136
- - **플러그인명:** `ApkInstaller`
137
- - `install`: `ACTION_VIEW` 인텐트로 APK 설치 (`FLAG_GRANT_READ_URI_PERMISSION`)
138
- - `checkPermissions`: `canRequestPackageInstalls()` (Android 8+) + 매니페스트 검사
139
- - `requestPermissions`: `ACTION_MANAGE_UNKNOWN_APP_SOURCES` 설정 화면 이동
140
- - `getVersionInfo`: `PackageManager.getPackageInfo`로 versionName/versionCode 조회
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.96",
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.96",
23
- "@simplysm/core-browser": "13.0.96",
24
- "@simplysm/core-common": "13.0.96",
25
- "@simplysm/service-client": "13.0.96",
26
- "@simplysm/service-common": "13.0.96"
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",