@simplysm/capacitor-plugin-auto-update 14.0.48 → 14.0.51

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
@@ -14,104 +14,15 @@ npm install @simplysm/capacitor-plugin-auto-update
14
14
 
15
15
  ### APK 설치
16
16
 
17
- | API | Type | Description |
18
- |-----|------|-------------|
19
- | `VersionInfo` | interface | 버전 정보 (versionName, versionCode) |
20
- | `ApkInstallerPlugin` | interface | Capacitor 네이티브 플러그인 인터페이스 (직접 사용하지 않음) |
21
- | `ApkInstaller` | abstract class | APK 설치 플러그인 정적 파사드 — 권한 확인/요청, 설치, 버전 조회 |
17
+ | Entry | Kind | Description |
18
+ |-------|------|-------------|
19
+ | [`ApkInstaller`](./docs/apk-installer/apk-installer.md) | abstract class | APK 설치 플러그인 정적 파사드 — 권한 확인/요청, 설치, 버전 조회. `VersionInfo`, `ApkInstallerPlugin` 타입 포함. |
22
20
 
23
21
  ### 자동 업데이트
24
22
 
25
- | API | Type | Description |
26
- |-----|------|-------------|
27
- | `AutoUpdate` | abstract class | 자동 업데이트 오케스트레이터 — 서버 또는 외부 저장소에서 최신 APK를 확인하고 설치 |
28
-
29
- ---
30
-
31
- ## `VersionInfo`
32
-
33
- 앱 버전 정보를 나타내는 인터페이스.
34
-
35
- ```typescript
36
- export interface VersionInfo {
37
- versionName: string;
38
- versionCode: string;
39
- }
40
- ```
41
-
42
- | Field | Type | Description |
23
+ | Entry | Kind | Description |
43
24
  |-------|------|-------------|
44
- | `versionName` | `string` | 버전 이름. semver 형식 (예: `"1.2.3"`). `AutoUpdate`의 버전 비교에 사용된다. |
45
- | `versionCode` | `string` | 앱 버전 코드. 정수를 문자열로 표현 (예: `"42"`). |
46
-
47
- ## `ApkInstallerPlugin`
48
-
49
- Capacitor 네이티브 플러그인 인터페이스. 직접 사용하지 않고 `ApkInstaller` 파사드를 통해 접근한다. 타입 참조 목적으로만 export된다.
50
-
51
- ```typescript
52
- export interface ApkInstallerPlugin {
53
- install(options: { uri: string }): Promise<void>;
54
- checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
55
- requestPermissions(): Promise<void>;
56
- getVersionInfo(): Promise<VersionInfo>;
57
- }
58
- ```
59
-
60
- | Method | Return | Description |
61
- |--------|--------|-------------|
62
- | `install(options: { uri: string })` | `Promise<void>` | `content://` URI(FileProvider URI)로 APK 설치 인텐트 실행 |
63
- | `checkPermissions()` | `Promise<{ granted: boolean; manifest: boolean }>` | 설치 권한 승인 여부(`granted`)와 AndroidManifest 선언 여부(`manifest`) 동시 확인 |
64
- | `requestPermissions()` | `Promise<void>` | `REQUEST_INSTALL_PACKAGES` 권한 요청 — 시스템 설정 화면으로 이동 |
65
- | `getVersionInfo()` | `Promise<VersionInfo>` | PackageManager에서 현재 앱 버전 정보 조회 |
66
-
67
- ## `ApkInstaller`
68
-
69
- APK 설치 플러그인 정적 파사드 클래스. Android에서는 네이티브 플러그인을 실행하고, 브라우저 환경에서는 `ApkInstallerWeb`으로 폴백한다. 브라우저 폴백: `install()`은 `alert()` 표시 후 반환, `checkPermissions()`는 항상 `{ granted: true, manifest: true }` 반환, `requestPermissions()`는 무동작, `getVersionInfo()`는 `env("__VER__") ?? "0.0.0"`을 `versionName`으로 반환.
70
-
71
- ```typescript
72
- export abstract class ApkInstaller {
73
- static async checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
74
- static async requestPermissions(): Promise<void>;
75
- static async install(apkUri: string): Promise<void>;
76
- static async getVersionInfo(): Promise<VersionInfo>;
77
- }
78
- ```
79
-
80
- | Method | Parameters | Return | Description |
81
- |--------|-----------|--------|-------------|
82
- | `checkPermissions` | 없음 | `Promise<{ granted: boolean; manifest: boolean }>` | 설치 권한 승인 여부와 AndroidManifest 선언 여부 확인. `manifest: false`이면 APK를 재설치해야 한다. |
83
- | `requestPermissions` | 없음 | `Promise<void>` | `REQUEST_INSTALL_PACKAGES` 권한 요청. 시스템 설정 화면으로 이동하므로 이후 `checkPermissions`로 결과를 폴링해야 한다. |
84
- | `install` | `apkUri: string` | `Promise<void>` | `content://` URI(FileProvider URI)로 APK 설치. `FileSystem.getUri(filePath)`로 URI를 얻는다. |
85
- | `getVersionInfo` | 없음 | `Promise<VersionInfo>` | 현재 설치된 앱의 버전 정보 조회. 브라우저 환경에서는 `env("__VER__") ?? "0.0.0"`을 `versionName`으로 반환한다. |
86
-
87
- ## `AutoUpdate`
88
-
89
- 자동 업데이트 오케스트레이터. 서버 또는 외부 저장소에서 최신 APK를 확인하고 설치한다. 모든 메서드가 `static`이며 인스턴스화하지 않는다. Android 환경 전용이며, 비-Android에서 호출하면 에러를 표시하고 앱을 무한 대기 상태로 전환한다.
90
-
91
- ```typescript
92
- export abstract class AutoUpdate {
93
- static async run(opt: {
94
- log: (messageHtml: string) => void;
95
- serviceClient: ServiceClient;
96
- }): Promise<void>;
97
-
98
- static async runByExternalStorage(opt: {
99
- log: (messageHtml: string) => void;
100
- dirPath: string;
101
- }): Promise<void>;
102
- }
103
- ```
104
-
105
- | Method | Parameters | Description |
106
- |--------|-----------|-------------|
107
- | `run` | `opt.log: (messageHtml: string) => void`, `opt.serviceClient: ServiceClient` | `AutoUpdateService.getLastVersion("android")`로 서버에서 최신 버전 정보를 조회한 뒤, 현재 버전보다 높으면 APK를 다운로드하여 설치한다. 업데이트 후 `_freezeApp()`으로 앱을 무한 대기 상태로 전환한다. |
108
- | `runByExternalStorage` | `opt.log: (messageHtml: string) => void`, `opt.dirPath: string` | 외부 저장소의 `opt.dirPath` 디렉토리에서 `{semver}.apk` 패턴 파일 중 최신 버전을 찾아 설치한다. 현재 버전보다 높은 경우에만 업데이트한다. |
109
-
110
- **`opt.log` 콜백**: HTML 문자열을 받아 사용자에게 진행 상황을 표시한다. 버튼(`<button>`) 등 인터랙티브 HTML이 포함될 수 있다. 에러 발생 시에도 `log`로 에러 메시지를 표시한 뒤 `_freezeApp()`으로 전환한다.
111
-
112
- **권한 처리**: 두 메서드 모두 내부적으로 `_checkPermission()`을 호출한다. `manifest: false`이면 재설치 에러를 throw하고, `granted: false`이면 권한 요청 후 최대 300초간 폴링한다.
113
-
114
- **버전 비교**: `semver` 라이브러리를 사용한다. `versionName`이 유효한 semver 형식이 아니면 업데이트 확인을 건너뛴다.
25
+ | [`AutoUpdate`](./docs/auto-update/auto-update.md) | abstract class | 자동 업데이트 오케스트레이터 서버 또는 외부 저장소에서 최신 APK를 확인하고 설치 |
115
26
 
116
27
  ## Usage Examples
117
28
 
@@ -133,7 +44,8 @@ async function checkForUpdate(serviceClient: ServiceClient) {
133
44
  serviceClient,
134
45
  });
135
46
 
136
- // 업데이트가 없거나 업데이트가 완료되면(무한 대기 전환 전) 이 줄에 도달한다.
47
+ // 업데이트가 없을 때만 이 줄에 도달한다.
48
+ // 업데이트가 실행되면 _freezeApp()으로 무한 대기 전환되므로 이 줄에 도달하지 않는다.
137
49
  statusEl.innerHTML = "";
138
50
  }
139
51
  ```
@@ -161,22 +73,10 @@ await AutoUpdate.runByExternalStorage({
161
73
  import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
162
74
  import { FileSystem } from "@simplysm/capacitor-plugin-file-system";
163
75
 
164
- // 권한 확인
165
76
  const { granted, manifest } = await ApkInstaller.checkPermissions();
166
- if (!manifest) {
167
- // AndroidManifest.xml에 REQUEST_INSTALL_PACKAGES 미선언 → APK 재설치 필요
168
- throw new Error("앱을 재설치해야 합니다.");
169
- }
170
- if (!granted) {
171
- await ApkInstaller.requestPermissions();
172
- }
173
-
174
- // 현재 버전 확인
175
- const versionInfo = await ApkInstaller.getVersionInfo();
176
- // versionInfo.versionName → "1.2.3"
177
- // versionInfo.versionCode → "42"
77
+ if (!manifest) throw new Error("앱을 재설치해야 합니다.");
78
+ if (!granted) await ApkInstaller.requestPermissions();
178
79
 
179
- // APK 설치 (filePath는 FileSystem으로 저장한 경로)
180
80
  const apkUri = await FileSystem.getUri("/path/to/latest.apk");
181
81
  await ApkInstaller.install(apkUri);
182
82
  ```
@@ -0,0 +1,91 @@
1
+ # ApkInstaller
2
+
3
+ APK 설치 플러그인 정적 파사드 클래스. Android에서는 네이티브 플러그인을 실행하고, 브라우저 환경에서는 `ApkInstallerWeb`으로 폴백한다.
4
+
5
+ ```typescript
6
+ export abstract class ApkInstaller {
7
+ static async checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
8
+ static async requestPermissions(): Promise<void>;
9
+ static async install(apkUri: string): Promise<void>;
10
+ static async getVersionInfo(): Promise<VersionInfo>;
11
+ }
12
+ ```
13
+
14
+ ## Members
15
+
16
+ | Member | Kind | Parameters | Return | Description |
17
+ |--------|------|-----------|--------|-------------|
18
+ | `checkPermissions` | static method | 없음 | `Promise<{ granted: boolean; manifest: boolean }>` | 설치 권한 승인 여부(`granted`)와 AndroidManifest 선언 여부(`manifest`) 동시 확인. `manifest: false`이면 APK를 재설치해야 한다. |
19
+ | `requestPermissions` | static method | 없음 | `Promise<void>` | `REQUEST_INSTALL_PACKAGES` 권한 요청. 시스템 설정 화면으로 이동하므로 이후 `checkPermissions`로 결과를 폴링해야 한다. |
20
+ | `install` | static method | `apkUri: string` | `Promise<void>` | `content://` URI(FileProvider URI)로 APK 설치 인텐트 실행. `FileSystem.getUri(filePath)`로 URI를 얻는다. |
21
+ | `getVersionInfo` | static method | 없음 | `Promise<VersionInfo>` | 현재 설치된 앱의 버전 정보 조회. 브라우저 환경에서는 `env("__VER__") ?? "0.0.0"`을 `versionName`으로 반환한다. |
22
+
23
+ **브라우저 폴백 동작:**
24
+ - `install()` — `alert()` 메시지 표시 후 반환
25
+ - `checkPermissions()` — 항상 `{ granted: true, manifest: true }` 반환
26
+ - `requestPermissions()` — 무동작
27
+ - `getVersionInfo()` — `versionName: env("__VER__") ?? "0.0.0"`, `versionCode: "0"` 반환
28
+
29
+ ## Related Types
30
+
31
+ ### `ApkInstallerPlugin`
32
+
33
+ Capacitor 네이티브 플러그인 인터페이스. 직접 사용하지 않고 `ApkInstaller` 파사드를 통해 접근한다. 타입 참조 목적으로만 export된다.
34
+
35
+ ```typescript
36
+ export interface ApkInstallerPlugin {
37
+ install(options: { uri: string }): Promise<void>;
38
+ checkPermissions(): Promise<{ granted: boolean; manifest: boolean }>;
39
+ requestPermissions(): Promise<void>;
40
+ getVersionInfo(): Promise<VersionInfo>;
41
+ }
42
+ ```
43
+
44
+ | Method | Return | Description |
45
+ |--------|--------|-------------|
46
+ | `install(options: { uri: string })` | `Promise<void>` | `content://` URI(FileProvider URI)로 APK 설치 인텐트 실행 |
47
+ | `checkPermissions()` | `Promise<{ granted: boolean; manifest: boolean }>` | 설치 권한 승인 여부(`granted`)와 AndroidManifest 선언 여부(`manifest`) 동시 확인 |
48
+ | `requestPermissions()` | `Promise<void>` | `REQUEST_INSTALL_PACKAGES` 권한 요청 — 시스템 설정 화면으로 이동 |
49
+ | `getVersionInfo()` | `Promise<VersionInfo>` | PackageManager에서 현재 앱 버전 정보 조회 |
50
+
51
+ ### `VersionInfo`
52
+
53
+ 앱 버전 정보를 나타내는 인터페이스.
54
+
55
+ ```typescript
56
+ export interface VersionInfo {
57
+ versionName: string;
58
+ versionCode: string;
59
+ }
60
+ ```
61
+
62
+ | Field | Type | Description |
63
+ |-------|------|-------------|
64
+ | `versionName` | `string` | 앱 버전 이름. semver 형식 (예: `"1.2.3"`). `AutoUpdate`의 버전 비교에 사용된다. |
65
+ | `versionCode` | `string` | 앱 버전 코드. 정수를 문자열로 표현 (예: `"42"`). |
66
+
67
+ ## Usage
68
+
69
+ ```typescript
70
+ import { ApkInstaller } from "@simplysm/capacitor-plugin-auto-update";
71
+ import { FileSystem } from "@simplysm/capacitor-plugin-file-system";
72
+
73
+ // 권한 확인
74
+ const { granted, manifest } = await ApkInstaller.checkPermissions();
75
+ if (!manifest) {
76
+ // AndroidManifest.xml에 REQUEST_INSTALL_PACKAGES 미선언 → APK 재설치 필요
77
+ throw new Error("앱을 재설치해야 합니다.");
78
+ }
79
+ if (!granted) {
80
+ await ApkInstaller.requestPermissions();
81
+ }
82
+
83
+ // 현재 버전 확인
84
+ const versionInfo = await ApkInstaller.getVersionInfo();
85
+ // versionInfo.versionName → "1.2.3"
86
+ // versionInfo.versionCode → "42"
87
+
88
+ // APK 설치 (filePath는 FileSystem으로 저장한 경로)
89
+ const apkUri = await FileSystem.getUri("/path/to/latest.apk");
90
+ await ApkInstaller.install(apkUri);
91
+ ```
@@ -0,0 +1,95 @@
1
+ # AutoUpdate
2
+
3
+ 자동 업데이트 오케스트레이터. 서버 또는 외부 저장소에서 최신 APK를 확인하고 설치한다. 모든 메서드가 `static`이며 인스턴스화하지 않는다. Android 환경 전용이며, 비-Android에서 호출하면 에러를 표시하고 앱을 무한 대기 상태로 전환한다.
4
+
5
+ ```typescript
6
+ export abstract class AutoUpdate {
7
+ static async run(opt: {
8
+ log: (messageHtml: string) => void;
9
+ serviceClient: ServiceClient;
10
+ }): Promise<void>;
11
+
12
+ static async runByExternalStorage(opt: {
13
+ log: (messageHtml: string) => void;
14
+ dirPath: string;
15
+ }): Promise<void>;
16
+ }
17
+ ```
18
+
19
+ ## Members
20
+
21
+ | Member | Kind | Parameters | Description |
22
+ |--------|------|-----------|-------------|
23
+ | `run` | static method | `opt.log`, `opt.serviceClient` | `AutoUpdateService.getLastVersion("android")`로 서버에서 최신 버전 정보를 조회한 뒤, 현재 버전보다 높으면 APK를 다운로드하여 설치한다. 업데이트 후 앱을 무한 대기 상태로 전환한다. |
24
+ | `runByExternalStorage` | static method | `opt.log`, `opt.dirPath` | 외부 저장소의 `opt.dirPath` 디렉토리에서 숫자와 점으로만 구성된 이름의 `.apk` 파일(예: `1.2.3.apk`) 중 최신 semver 버전을 찾아 설치한다. 현재 버전보다 높은 경우에만 업데이트한다. |
25
+
26
+ ## Parameters
27
+
28
+ ### `run` opt
29
+
30
+ | Param | Type | Description |
31
+ |-------|------|-------------|
32
+ | `log` | `(messageHtml: string) => void` | 진행 상황 HTML을 받아 사용자에게 표시하는 콜백. 버튼 등 인터랙티브 HTML이 포함될 수 있다. |
33
+ | `serviceClient` | `ServiceClient` | `@simplysm/service-client`의 `ServiceClient` 인스턴스. 서버에서 버전 정보를 조회하는 데 사용된다. |
34
+
35
+ ### `runByExternalStorage` opt
36
+
37
+ | Param | Type | Description |
38
+ |-------|------|-------------|
39
+ | `log` | `(messageHtml: string) => void` | 진행 상황 HTML을 받아 사용자에게 표시하는 콜백. |
40
+ | `dirPath` | `string` | 외부 저장소 루트(`FileSystem.getStoragePath("external")`) 기준 상대 경로. 해당 경로에 `1.2.3.apk` 형식 파일이 있어야 한다. |
41
+
42
+ ## 동작 설명
43
+
44
+ **권한 처리**: 두 메서드 모두 내부적으로 권한 확인을 수행한다.
45
+ - `manifest: false` → 재설치 에러를 throw하고 앱을 무한 대기로 전환한다.
46
+ - `granted: false` → 권한 요청 후 최대 300초(1초 간격)간 승인을 폴링한다.
47
+
48
+ **버전 비교**: `semver` 라이브러리를 사용한다. `versionName`이 유효한 semver 형식이 아니면 업데이트 확인을 건너뛴다.
49
+
50
+ **업데이트 후 동작**: 업데이트가 실행되면 `new Promise(() => {})` 무한 대기로 전환된다. 사용자가 앱을 재시작해야 새 버전이 적용된다. 업데이트가 필요 없을 때는 정상 반환한다.
51
+
52
+ **에러 처리**: `try/catch`로 전체를 감싸며, 에러 발생 시 `opt.log()`로 HTML 에러 메시지를 표시한 뒤 무한 대기로 전환한다.
53
+
54
+ **`run` APK 저장 경로**: `FileSystem.getStoragePath("appCache")`에 `latest.apk`로 저장한다.
55
+
56
+ ## Usage
57
+
58
+ ### 서버 기반 자동 업데이트
59
+
60
+ 앱 부트스트랩 시 `AutoUpdate.run()`을 호출한다. `AutoUpdateService`는 `@simplysm/service-common`의 서비스 인터페이스다.
61
+
62
+ ```typescript
63
+ import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
64
+ import type { ServiceClient } from "@simplysm/service-client";
65
+
66
+ async function checkForUpdate(serviceClient: ServiceClient) {
67
+ const statusEl = document.getElementById("status")!;
68
+
69
+ await AutoUpdate.run({
70
+ log: (messageHtml) => {
71
+ statusEl.innerHTML = messageHtml;
72
+ },
73
+ serviceClient,
74
+ });
75
+
76
+ // 업데이트가 없을 때만 이 줄에 도달한다.
77
+ // 업데이트가 실행되면 무한 대기 전환되므로 이 줄에 도달하지 않는다.
78
+ statusEl.innerHTML = "";
79
+ }
80
+ ```
81
+
82
+ ### 외부 저장소(USB) 기반 업데이트
83
+
84
+ `opt.dirPath`는 외부 저장소 루트 기준 상대 경로다. 해당 경로에 `1.2.3.apk` 형식 파일이 있어야 한다.
85
+
86
+ ```typescript
87
+ import { AutoUpdate } from "@simplysm/capacitor-plugin-auto-update";
88
+
89
+ await AutoUpdate.runByExternalStorage({
90
+ log: (messageHtml) => {
91
+ document.getElementById("status")!.innerHTML = messageHtml;
92
+ },
93
+ dirPath: "updates/my-app",
94
+ });
95
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/capacitor-plugin-auto-update",
3
- "version": "14.0.48",
3
+ "version": "14.0.51",
4
4
  "description": "심플리즘 패키지 - Capacitor 자동 업데이트 플러그인",
5
5
  "author": "심플리즘",
6
6
  "license": "Apache-2.0",
@@ -15,15 +15,16 @@
15
15
  "files": [
16
16
  "dist",
17
17
  "src",
18
- "android"
18
+ "android",
19
+ "docs"
19
20
  ],
20
21
  "dependencies": {
21
22
  "semver": "^7.7.4",
22
- "@simplysm/capacitor-plugin-file-system": "14.0.48",
23
- "@simplysm/core-browser": "14.0.48",
24
- "@simplysm/service-client": "14.0.48",
25
- "@simplysm/core-common": "14.0.48",
26
- "@simplysm/service-common": "14.0.48"
23
+ "@simplysm/capacitor-plugin-file-system": "14.0.51",
24
+ "@simplysm/core-browser": "14.0.51",
25
+ "@simplysm/service-client": "14.0.51",
26
+ "@simplysm/core-common": "14.0.51",
27
+ "@simplysm/service-common": "14.0.51"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@capacitor/core": "^7.6.2",