@h-ai/capacitor 1.0.0-beta.10 → 1.0.0-beta.11

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 CHANGED
@@ -115,6 +115,31 @@ export const prerender = true
115
115
  export const ssr = false
116
116
  ```
117
117
 
118
+ ### Build an Android APK in a container
119
+
120
+ Run `pnpm build --target app --platform android --runtime auto --debug` at the Hai project root. Omit `--debug` for a signed release. Successful batches appear under `.hai/build/app/android/<variant>/`. See the [native build and signing instructions](../../docs/usage/getting-started/build.md#原生和离线条件).
121
+
122
+ The build image includes Node.js 24, pnpm 12.11.2, JDK 21, Android SDK 36, and Build Tools 35.0.0 and 36.0.0. The build runs on `linux/amd64`. The app's Gradle project and native plugins determine the APK's target ABIs, such as `arm64-v8a` and `armeabi-v7a`. Building for iOS requires macOS and Xcode.
123
+
124
+ Build the image from the framework repository root. In a project with this package installed, set `image_dir` to the `images` directory in the installed `@h-ai/capacitor` package.
125
+
126
+ ```sh
127
+ image_dir=packages/capacitor/images
128
+ docker build --platform linux/amd64 -t hai-capacitor-android:36 \
129
+ -f "$image_dir/android.Dockerfile" "$image_dir"
130
+ ```
131
+
132
+ Run the container from the project root. Start with a clean working copy, run `pnpm install --frozen-lockfile` in the container, and build any local workspace packages the app depends on. Then run the app's existing build, `cap sync android`, and APK packaging commands. The APK is written to the mounted project. With rootless Podman, replace `docker` with `podman` and add `--userns=keep-id` alongside `--user`.
133
+
134
+ ```sh
135
+ docker run --rm -it --platform linux/amd64 \
136
+ --user "$(id -u):$(id -g)" -e HOME=/tmp \
137
+ -e GRADLE_USER_HOME=/tmp/.gradle -e ANDROID_USER_HOME=/tmp/.android \
138
+ -v "$PWD:/workspace" hai-capacitor-android:36 bash
139
+ ```
140
+
141
+ Downloading dependencies requires access to npm, Gradle distributions, Google Maven, and Maven Central. Use the app's signing workflow for release builds. Mount the keystore read-only and inject passwords through the build environment. See the [mobile-app packaging and acceptance example](../../apps/mobile-app/README.md#原生交付与验收).
142
+
118
143
  ### Error handling
119
144
 
120
145
  Business operations on `capacitor.*` and `safe*Preference` return `HaiResult<T>`. TokenStorage adapter methods reject their promises on platform or storage errors:
package/README.ja.md CHANGED
@@ -115,6 +115,31 @@ export const prerender = true
115
115
  export const ssr = false
116
116
  ```
117
117
 
118
+ ### コンテナで Android APK をビルドする
119
+
120
+ Hai プロジェクトルートで `pnpm build --target app --platform android --runtime auto --debug` を実行します。`--debug` を省略すると署名付きリリースになります。成功したビルドは `.hai/build/app/android/<variant>/` に格納します。[ネイティブビルドと署名](../../docs/usage/getting-started/build.md#原生和离线条件)を参照してください。
121
+
122
+ ビルドイメージには Node.js 24、pnpm 12.11.2、JDK 21、Android SDK 36、Build Tools 35.0.0 と 36.0.0 が含まれます。ビルドは `linux/amd64` で実行します。APK の `arm64-v8a`、`armeabi-v7a` などの対象 ABI は、アプリの Gradle プロジェクトとネイティブプラグインで決まります。iOS のビルドには macOS と Xcode が必要です。
123
+
124
+ フレームワークのリポジトリルートでイメージをビルドします。このパッケージをインストールしたプロジェクトでは、`image_dir` にインストール先の `@h-ai/capacitor` にある `images` ディレクトリを指定できます。
125
+
126
+ ```sh
127
+ image_dir=packages/capacitor/images
128
+ docker build --platform linux/amd64 -t hai-capacitor-android:36 \
129
+ -f "$image_dir/android.Dockerfile" "$image_dir"
130
+ ```
131
+
132
+ アプリのプロジェクトルートでコンテナを起動します。クリーンな作業コピーを使い、コンテナ内で `pnpm install --frozen-lockfile` を実行してから、アプリが依存するローカルワークスペースパッケージをビルドします。続けてアプリのビルド、`cap sync android`、既存の APK パッケージングを実行します。APK はマウントしたプロジェクトに出力されます。rootless Podman では `docker` を `podman` に変更し、`--user` に加えて `--userns=keep-id` を指定します。
133
+
134
+ ```sh
135
+ docker run --rm -it --platform linux/amd64 \
136
+ --user "$(id -u):$(id -g)" -e HOME=/tmp \
137
+ -e GRADLE_USER_HOME=/tmp/.gradle -e ANDROID_USER_HOME=/tmp/.android \
138
+ -v "$PWD:/workspace" hai-capacitor-android:36 bash
139
+ ```
140
+
141
+ 依存関係の取得には npm、Gradle の配布元、Google Maven、Maven Central へのアクセスが必要です。リリースにはアプリの署名手順を使用し、キーストアを読み取り専用でマウントして、パスワードをビルド環境から渡します。[mobile-app のビルドと受け入れ確認](../../apps/mobile-app/README.md#原生交付与验收)を参照してください。
142
+
118
143
  ### エラー処理
119
144
 
120
145
  `capacitor.*` と `safe*Preference` は `HaiResult<T>` を返します。TokenStorage のメソッドはプラットフォームや保存エラーで Promise を reject します。
package/README.md CHANGED
@@ -115,6 +115,31 @@ export const prerender = true
115
115
  export const ssr = false
116
116
  ```
117
117
 
118
+ ### Android 容器打包
119
+
120
+ 在 Hai 工程根运行 `pnpm build --target app --platform android --runtime auto --debug`。省略 `--debug` 构建签名发布包,成功后在 `.hai/build/app/android/<构建类型>/` 查看最新批次。签名设置见 [原生和离线条件](../../docs/usage/getting-started/build.md#原生和离线条件)。
121
+
122
+ 构建镜像提供 Node.js 24、pnpm 12.11.2、JDK 21、Android SDK 36 和 Build Tools 35.0.0 / 36.0.0。构建机使用 `linux/amd64`,APK 的 `arm64-v8a`、`armeabi-v7a` 等目标 ABI 由应用的 Gradle 工程及其原生插件决定。iOS 打包需要 macOS 和 Xcode。
123
+
124
+ 从框架仓库根目录构建镜像。已安装本包的项目可将 `image_dir` 指向 `@h-ai/capacitor` 实际安装目录下的 `images`。
125
+
126
+ ```sh
127
+ image_dir=packages/capacitor/images
128
+ docker build --platform linux/amd64 -t hai-capacitor-android:36 \
129
+ -f "$image_dir/android.Dockerfile" "$image_dir"
130
+ ```
131
+
132
+ 在待打包项目的根目录运行容器。使用干净的工作副本,在容器内执行 `pnpm install --frozen-lockfile`,先构建应用依赖的本地 workspace 包,再执行应用已有的构建、`cap sync android` 和 APK 打包命令。APK 写入挂载的工程目录。使用 rootless Podman 时,将 `docker` 换成 `podman`,在 `--user` 之外加上 `--userns=keep-id`。
133
+
134
+ ```sh
135
+ docker run --rm -it --platform linux/amd64 \
136
+ --user "$(id -u):$(id -g)" -e HOME=/tmp \
137
+ -e GRADLE_USER_HOME=/tmp/.gradle -e ANDROID_USER_HOME=/tmp/.android \
138
+ -v "$PWD:/workspace" hai-capacitor-android:36 bash
139
+ ```
140
+
141
+ 构建下载依赖时需要访问 npm、Gradle 分发站点、Google Maven 和 Maven Central。发布包沿用应用的签名流程,密钥库从容器外只读挂载,口令由构建环境注入。应用示例见 [mobile-app 原生交付与验收](../../apps/mobile-app/README.md#原生交付与验收)。
142
+
118
143
  ### 错误处理
119
144
 
120
145
  `capacitor.*` 业务操作与 `safe*Preference` 返回 `HaiResult<T>`;TokenStorage 适配器方法以 Promise 拒绝报告平台与存储错误:
@@ -0,0 +1,31 @@
1
+ # JDK 21、Android SDK 36 和 Build Tools 36.0.0 由 Cirrus Labs 基础镜像提供。
2
+ ARG HAI_ANDROID_IMAGE=ghcr.io/cirruslabs/android-sdk:36@sha256:d9c965f2373f9c8cc023b207cdcc7d21508f98e6a45ab66462fe41aa9f866dea
3
+ FROM ${HAI_ANDROID_IMAGE}
4
+
5
+ ARG HAI_NPM_REGISTRY=https://registry.npmjs.org
6
+ ENV JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
7
+
8
+ # 构建机使用 linux/amd64,APK 内的目标 ABI 由应用的 Gradle 配置决定。
9
+ RUN test "$(uname -m)" = x86_64 \
10
+ && curl --fail --silent --show-error --location --retry 3 --max-time 120 \
11
+ https://nodejs.org/dist/v24.22.1/node-v24.22.1-linux-x64.tar.gz -o /tmp/node.tar.gz \
12
+ && echo 'eb6728e77c576a35162c122c45ccadf224d89ff00abc8dae46cc2897c6002d7c /tmp/node.tar.gz' | sha256sum --check \
13
+ && tar -xzf /tmp/node.tar.gz --strip-components=1 -C /usr/local \
14
+ && rm /tmp/node.tar.gz \
15
+ && npm install --global --registry "$HAI_NPM_REGISTRY" --no-audit --no-fund --include=optional pnpm@12.11.2 \
16
+ && test "$(pnpm --version)" = 12.11.2 \
17
+ && npm cache clean --force
18
+
19
+ # Capacitor 插件可能由 AGP 选择默认的 Build Tools 35.0.0。
20
+ ARG HAI_ANDROID_BUILD_TOOLS_35_URL=https://dl.google.com/android/repository/build-tools_r35_linux.zip
21
+ RUN mkdir /tmp/android-tools35 \
22
+ && curl --fail --silent --show-error --location --retry 3 --retry-all-errors --connect-timeout 20 \
23
+ "$HAI_ANDROID_BUILD_TOOLS_35_URL" -o /tmp/android-tools35/tools.zip \
24
+ && echo 'bd3a4966912eb8b30ed0d00b0cda6b6543b949d5ffe00bea54c04c81e1561d88 /tmp/android-tools35/tools.zip' | sha256sum --check \
25
+ && unzip -q /tmp/android-tools35/tools.zip -d /tmp/android-tools35 \
26
+ && mv /tmp/android-tools35/android-15 "$ANDROID_HOME/build-tools/35.0.0" \
27
+ && test -x "$ANDROID_HOME/build-tools/35.0.0/aapt2" \
28
+ && rm /tmp/android-tools35/tools.zip \
29
+ && rmdir /tmp/android-tools35
30
+
31
+ WORKDIR /workspace
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@h-ai/capacitor",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.10",
4
+ "version": "1.0.0-beta.11",
5
5
  "description": "Hai Framework Capacitor bridge module for native mobile capabilities.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
@@ -13,7 +13,8 @@
13
13
  "main": "./dist/index.js",
14
14
  "types": "./dist/index.d.ts",
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "images/android.Dockerfile"
17
18
  ],
18
19
  "publishConfig": {
19
20
  "access": "public"
@@ -47,8 +48,8 @@
47
48
  }
48
49
  },
49
50
  "dependencies": {
50
- "@h-ai/api-client": "1.0.0-beta.10",
51
- "@h-ai/core": "1.0.0-beta.10"
51
+ "@h-ai/api-client": "1.0.0-beta.11",
52
+ "@h-ai/core": "1.0.0-beta.11"
52
53
  },
53
54
  "devDependencies": {
54
55
  "@aparajita/capacitor-secure-storage": "^8.0.1",