@h-ai/capacitor 0.1.0-alpha.65 → 0.1.0-alpha.67
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.en.md +14 -10
- package/README.ja.md +14 -10
- package/README.md +15 -11
- package/package.json +3 -3
package/README.en.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[Framework home](../../README.en.md) · Related modules: [@h-ai/api-client](../api-client/README.en.md) · [@h-ai/core](../core/README.en.md)
|
|
6
6
|
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
7
9
|
A Capacitor native bridge for hai Framework mobile apps, with a unified API for secure token storage, device information, push notifications, camera, and status bar access.
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Core features
|
|
10
12
|
|
|
11
13
|
- **Token storage**: `@aparajita/capacitor-secure-storage` (required on native platforms). Android uses KeyStore + encrypted SharedPreferences; iOS uses Keychain. No Web fallback.
|
|
12
14
|
- **Preferences**: `@capacitor/preferences` (required). General preferences storage for nonsensitive settings, not authentication tokens.
|
|
@@ -16,7 +18,9 @@ A Capacitor native bridge for hai Framework mobile apps, with a unified API for
|
|
|
16
18
|
- **Camera/gallery**: `@capacitor/camera` (optional). Capture photos or select gallery images.
|
|
17
19
|
- **Status bar**: `@capacitor/status-bar` (optional). Immersive mode, background color, and style settings.
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## Getting started
|
|
22
|
+
|
|
23
|
+
### Quick start
|
|
20
24
|
|
|
21
25
|
```ts
|
|
22
26
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -28,7 +32,7 @@ if (!result.success) {
|
|
|
28
32
|
}
|
|
29
33
|
```
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
#### Secure token storage with api-client
|
|
32
36
|
|
|
33
37
|
```ts
|
|
34
38
|
import { apiClient } from '@h-ai/api-client'
|
|
@@ -45,7 +49,7 @@ await apiClient.init({
|
|
|
45
49
|
|
|
46
50
|
`createCapacitorTokenStorage()` persists tokens only on native Android/iOS and requires `@aparajita/capacitor-secure-storage`. On Web it does not fall back to `localStorage`: `get*()` returns `null`, and `set*()` / `clear()` are no-ops.
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
#### Device information and push notifications
|
|
49
53
|
|
|
50
54
|
```ts
|
|
51
55
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -61,7 +65,7 @@ if (reg.success) {
|
|
|
61
65
|
}
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
#### Status bar
|
|
65
69
|
|
|
66
70
|
```ts
|
|
67
71
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -73,7 +77,7 @@ await capacitor.statusBar.configure({
|
|
|
73
77
|
})
|
|
74
78
|
```
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
#### Camera
|
|
77
81
|
|
|
78
82
|
```ts
|
|
79
83
|
const photo = await capacitor.camera.takePhoto({
|
|
@@ -83,7 +87,7 @@ const photo = await capacitor.camera.takePhoto({
|
|
|
83
87
|
})
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
#### Preferences
|
|
87
91
|
|
|
88
92
|
```ts
|
|
89
93
|
await capacitor.preferences.set('my_key', 'value')
|
|
@@ -93,7 +97,7 @@ await capacitor.preferences.remove('my_key')
|
|
|
93
97
|
|
|
94
98
|
`capacitor.preferences` is for general preferences such as language, theme, and drafts. Use `createCapacitorTokenStorage()` for authentication tokens.
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
### Configuration
|
|
97
101
|
|
|
98
102
|
This module has no configuration file. `capacitor.init()` only checks whether the Capacitor runtime is available.
|
|
99
103
|
|
|
@@ -105,7 +109,7 @@ export const prerender = true
|
|
|
105
109
|
export const ssr = false
|
|
106
110
|
```
|
|
107
111
|
|
|
108
|
-
|
|
112
|
+
### Error handling
|
|
109
113
|
|
|
110
114
|
All asynchronous APIs return `HaiResult<T>` instead of throwing directly:
|
|
111
115
|
|
|
@@ -138,7 +142,7 @@ Common error codes:
|
|
|
138
142
|
| `HaiCapacitorError.CAMERA_FAILED` | `hai:capacitor:040` | Camera operation failed |
|
|
139
143
|
| `HaiCapacitorError.STATUS_BAR_FAILED` | `hai:capacitor:050` | Status bar operation failed |
|
|
140
144
|
|
|
141
|
-
##
|
|
145
|
+
## Development and testing
|
|
142
146
|
|
|
143
147
|
```bash
|
|
144
148
|
pnpm --filter @h-ai/capacitor test
|
package/README.ja.md
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
[フレームワークのホーム](../../README.ja.md) · 関連モジュール:[@h-ai/api-client](../api-client/README.ja.md) · [@h-ai/core](../core/README.ja.md)
|
|
6
6
|
|
|
7
|
+
## 概要
|
|
8
|
+
|
|
7
9
|
hai Framework のモバイルアプリ向け Capacitor ネイティブブリッジ。安全な Token ストレージ、端末情報、プッシュ通知、カメラ、ステータスバーを共通 API で提供します。
|
|
8
10
|
|
|
9
11
|
## 主な機能
|
|
@@ -16,7 +18,9 @@ hai Framework のモバイルアプリ向け Capacitor ネイティブブリッ
|
|
|
16
18
|
- **カメラ/アルバム**:`@capacitor/camera`(任意)。撮影とアルバム画像の選択。
|
|
17
19
|
- **ステータスバー**:`@capacitor/status-bar`(任意)。没入型表示、背景色、スタイルの設定。
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## 使い始める
|
|
22
|
+
|
|
23
|
+
### クイックスタート
|
|
20
24
|
|
|
21
25
|
```ts
|
|
22
26
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -28,7 +32,7 @@ if (!result.success) {
|
|
|
28
32
|
}
|
|
29
33
|
```
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
#### api-client と連携する安全な Token ストレージ
|
|
32
36
|
|
|
33
37
|
```ts
|
|
34
38
|
import { apiClient } from '@h-ai/api-client'
|
|
@@ -45,7 +49,7 @@ await apiClient.init({
|
|
|
45
49
|
|
|
46
50
|
`createCapacitorTokenStorage()` は Android/iOS のネイティブ環境でのみ Token を永続化し、`@aparajita/capacitor-secure-storage` が必要です。Web では `localStorage` に切り替わらず、`get*()` は `null` を返し、`set*()` / `clear()` は何もしません。
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
#### 端末情報とプッシュ通知
|
|
49
53
|
|
|
50
54
|
```ts
|
|
51
55
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -61,7 +65,7 @@ if (reg.success) {
|
|
|
61
65
|
}
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
#### ステータスバー
|
|
65
69
|
|
|
66
70
|
```ts
|
|
67
71
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -73,7 +77,7 @@ await capacitor.statusBar.configure({
|
|
|
73
77
|
})
|
|
74
78
|
```
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
#### カメラ
|
|
77
81
|
|
|
78
82
|
```ts
|
|
79
83
|
const photo = await capacitor.camera.takePhoto({
|
|
@@ -83,7 +87,7 @@ const photo = await capacitor.camera.takePhoto({
|
|
|
83
87
|
})
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
#### Preferences
|
|
87
91
|
|
|
88
92
|
```ts
|
|
89
93
|
await capacitor.preferences.set('my_key', 'value')
|
|
@@ -93,7 +97,7 @@ await capacitor.preferences.remove('my_key')
|
|
|
93
97
|
|
|
94
98
|
`capacitor.preferences` は言語、テーマ、下書きなどの一般的な設定用です。認証 Token には `createCapacitorTokenStorage()` を使用してください。
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
### 設定
|
|
97
101
|
|
|
98
102
|
このモジュールに設定ファイルはありません。`capacitor.init()` は Capacitor の実行環境が利用可能かどうかのみを確認します。
|
|
99
103
|
|
|
@@ -105,7 +109,7 @@ export const prerender = true
|
|
|
105
109
|
export const ssr = false
|
|
106
110
|
```
|
|
107
111
|
|
|
108
|
-
|
|
112
|
+
### エラー処理
|
|
109
113
|
|
|
110
114
|
すべての非同期 API は直接 throw せず、`HaiResult<T>` を返します:
|
|
111
115
|
|
|
@@ -138,7 +142,7 @@ if (!result.success) {
|
|
|
138
142
|
| `HaiCapacitorError.CAMERA_FAILED` | `hai:capacitor:040` | カメラ操作に失敗 |
|
|
139
143
|
| `HaiCapacitorError.STATUS_BAR_FAILED` | `hai:capacitor:050` | ステータスバー操作に失敗 |
|
|
140
144
|
|
|
141
|
-
##
|
|
145
|
+
## 開発とテスト
|
|
142
146
|
|
|
143
147
|
```bash
|
|
144
148
|
pnpm --filter @h-ai/capacitor test
|
|
@@ -146,6 +150,6 @@ pnpm --filter @h-ai/capacitor test
|
|
|
146
150
|
|
|
147
151
|
> ネイティブプラグインへの依存があるため、テストでは `@capacitor/*` モジュールを mock する必要があります。
|
|
148
152
|
|
|
149
|
-
##
|
|
153
|
+
## ライセンス
|
|
150
154
|
|
|
151
155
|
Apache-2.0
|
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[框架首页](../../README.md) · 相关模块:[@h-ai/api-client](../api-client/README.md) · [@h-ai/core](../core/README.md)
|
|
6
6
|
|
|
7
|
+
## 简介
|
|
8
|
+
|
|
7
9
|
Capacitor 原生桥接模块,为 hai Framework 移动应用提供原生安全 Token 存储、设备信息、推送通知、相机与状态栏等能力的统一封装。
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## 核心功能清单
|
|
10
12
|
|
|
11
13
|
- **Token 存储**:`@aparajita/capacitor-secure-storage`(原生必需)。Android 使用 KeyStore + 加密 SharedPreferences,iOS 使用 Keychain;Web 不回退。
|
|
12
14
|
- **Preferences**:`@capacitor/preferences`(必需)。通用偏好数据存储,适合非敏感配置,不用于认证 Token。
|
|
@@ -16,7 +18,9 @@ Capacitor 原生桥接模块,为 hai Framework 移动应用提供原生安全
|
|
|
16
18
|
- **相机/相册**:`@capacitor/camera`(可选)。拍照、选取相册图片。
|
|
17
19
|
- **状态栏**:`@capacitor/status-bar`(可选)。沉浸式、背景色、样式配置。
|
|
18
20
|
|
|
19
|
-
##
|
|
21
|
+
## 使用入门
|
|
22
|
+
|
|
23
|
+
### 快速开始
|
|
20
24
|
|
|
21
25
|
```ts
|
|
22
26
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -28,7 +32,7 @@ if (!result.success) {
|
|
|
28
32
|
}
|
|
29
33
|
```
|
|
30
34
|
|
|
31
|
-
|
|
35
|
+
#### 与 api-client 配合的 Token 安全存储
|
|
32
36
|
|
|
33
37
|
```ts
|
|
34
38
|
import { apiClient } from '@h-ai/api-client'
|
|
@@ -45,7 +49,7 @@ await apiClient.init({
|
|
|
45
49
|
|
|
46
50
|
`createCapacitorTokenStorage()` 仅在 Android/iOS 原生环境中持久化 token,并要求已安装 `@aparajita/capacitor-secure-storage`。纯 Web 环境下不会退化到 `localStorage`;`get*()` 返回 `null`,`set*()` / `clear()` 为 no-op。
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
#### 设备信息与推送
|
|
49
53
|
|
|
50
54
|
```ts
|
|
51
55
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -61,7 +65,7 @@ if (reg.success) {
|
|
|
61
65
|
}
|
|
62
66
|
```
|
|
63
67
|
|
|
64
|
-
|
|
68
|
+
#### 状态栏
|
|
65
69
|
|
|
66
70
|
```ts
|
|
67
71
|
import { capacitor } from '@h-ai/capacitor'
|
|
@@ -73,7 +77,7 @@ await capacitor.statusBar.configure({
|
|
|
73
77
|
})
|
|
74
78
|
```
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
#### 相机
|
|
77
81
|
|
|
78
82
|
```ts
|
|
79
83
|
const photo = await capacitor.camera.takePhoto({
|
|
@@ -83,7 +87,7 @@ const photo = await capacitor.camera.takePhoto({
|
|
|
83
87
|
})
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
#### Preferences
|
|
87
91
|
|
|
88
92
|
```ts
|
|
89
93
|
await capacitor.preferences.set('my_key', 'value')
|
|
@@ -93,7 +97,7 @@ await capacitor.preferences.remove('my_key')
|
|
|
93
97
|
|
|
94
98
|
`capacitor.preferences` 适合保存语言、主题、草稿等普通偏好数据;认证 Token 请使用 `createCapacitorTokenStorage()`。
|
|
95
99
|
|
|
96
|
-
|
|
100
|
+
### 配置
|
|
97
101
|
|
|
98
102
|
本模块无配置文件。`capacitor.init()` 仅检测 Capacitor 运行环境是否可用。
|
|
99
103
|
|
|
@@ -105,7 +109,7 @@ export const prerender = true
|
|
|
105
109
|
export const ssr = false
|
|
106
110
|
```
|
|
107
111
|
|
|
108
|
-
|
|
112
|
+
### 错误处理
|
|
109
113
|
|
|
110
114
|
所有异步 API 返回 `HaiResult<T>`,不会直接 throw:
|
|
111
115
|
|
|
@@ -138,7 +142,7 @@ if (!result.success) {
|
|
|
138
142
|
| `HaiCapacitorError.CAMERA_FAILED` | `hai:capacitor:040` | 相机操作失败 |
|
|
139
143
|
| `HaiCapacitorError.STATUS_BAR_FAILED` | `hai:capacitor:050` | 状态栏操作失败 |
|
|
140
144
|
|
|
141
|
-
##
|
|
145
|
+
## 开发测试
|
|
142
146
|
|
|
143
147
|
```bash
|
|
144
148
|
pnpm --filter @h-ai/capacitor test
|
|
@@ -146,6 +150,6 @@ pnpm --filter @h-ai/capacitor test
|
|
|
146
150
|
|
|
147
151
|
> 由于原生插件依赖,测试中需 mock `@capacitor/*` 模块。
|
|
148
152
|
|
|
149
|
-
##
|
|
153
|
+
## 许可证
|
|
150
154
|
|
|
151
155
|
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/capacitor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.67",
|
|
5
5
|
"description": "Hai Framework Capacitor bridge module for native mobile capabilities.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"exports": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@h-ai/api-client": "0.1.0-alpha.
|
|
51
|
-
"@h-ai/core": "0.1.0-alpha.
|
|
50
|
+
"@h-ai/api-client": "0.1.0-alpha.67",
|
|
51
|
+
"@h-ai/core": "0.1.0-alpha.67"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@aparajita/capacitor-secure-storage": "^8.0.1",
|