cj-tauri 2.3.1 → 2.3.2

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/bin/cj-tauri.js CHANGED
@@ -125,7 +125,12 @@ function resolveCjpm(home) {
125
125
  function resolveStdx(home) {
126
126
  const looksRight = (p) => {
127
127
  try {
128
- return fs.readdirSync(p).some((n) => n.startsWith('stdx.'));
128
+ // 必须能找到实际要链的库(libstdx.encoding.json.*):指到「包根」而不是
129
+ // <三元组>/dynamic/stdx 时,变量展开成功但cjpm 找不到库,报的是和「变量为空」
130
+ // 一模一样的 imports package ... not added as a dependency(2026-11-13 实测,
131
+ // 用户把 CANGJIE_STDX 设成 D:\cangjie-stdx 包根就复现了)——所以按库文件判,
132
+ // 不能按「有 stdx.* 开头的文件」判(真实库都是 libstdx.* 命名)。
133
+ return fs.readdirSync(p).some((n) => n.startsWith('libstdx.encoding.json.'));
129
134
  } catch (e) {
130
135
  return false;
131
136
  }
@@ -133,6 +138,10 @@ function resolveStdx(home) {
133
138
  // 宿主平台关键词:自动探测的包名必须含它且不含 ohos(交叉编译包不能当宿主 stdx 用)
134
139
  const platKey = IS_WIN ? 'windows' : (process.platform === 'darwin' ? 'darwin' : 'linux');
135
140
  const hostUsable = (pkgName) => pkgName.includes(platKey) && !pkgName.includes('ohos');
141
+ // stdx 里实际被引用的那一层**按链接形态**:静态产物(cjpm 常规 build 的默认形态)吃
142
+ // static\stdx 的 .a(2026-11-13 用户实测);--dynamic-std 的动态产物才用 dynamic\stdx。
143
+ // CLI 本体是常规构建,探测取 static(动态构建的用户请显式设置变量,显式值优先于探测)。
144
+ const stdxLayer = IS_WIN ? 'static' : 'dynamic';
136
145
 
137
146
  const candidates = [];
138
147
  if (process.env.CANGJIE_STDX && fs.existsSync(process.env.CANGJIE_STDX)) {
@@ -145,7 +154,11 @@ function resolveStdx(home) {
145
154
  try {
146
155
  for (const pkg of fs.readdirSync(cjStdxBase)) {
147
156
  if (hostUsable(pkg)) {
148
- candidates.push(path.join(cjStdxBase, pkg, 'dynamic', 'stdx'));
157
+ // 两种落位都收:CI / 教程把包直接解成 <包>/<层>/stdx,Windows 的 zip 则是
158
+ // <包>/<三元组>/<层>/stdx(zip 无顶层目录)。looksRight 会把不存在的滤掉。
159
+ const triple = IS_WIN ? 'windows_x86_64_cjnative' : (process.platform === 'darwin' ? 'darwin_x86_64_cjnative' : 'linux_x86_64_cjnative');
160
+ candidates.push(path.join(cjStdxBase, pkg, stdxLayer, 'stdx'));
161
+ candidates.push(path.join(cjStdxBase, pkg, triple, stdxLayer, 'stdx'));
149
162
  }
150
163
  }
151
164
  } catch (e) {
@@ -159,7 +172,7 @@ function resolveStdx(home) {
159
172
  }
160
173
  const triple = IS_WIN ? 'windows_x86_64_cjnative' : (process.platform === 'darwin' ? 'darwin_x86_64_cjnative' : 'linux_x86_64_cjnative');
161
174
  if (hostUsable(pkg)) {
162
- candidates.push(path.join(sdkParent, pkg, triple, 'dynamic', 'stdx'));
175
+ candidates.push(path.join(sdkParent, pkg, triple, stdxLayer, 'stdx'));
163
176
  }
164
177
  }
165
178
  } catch (e) {
@@ -177,7 +190,10 @@ function printMissingStdxHint() {
177
190
  '请下载 stdx(与 SDK 版本配套,1.2.0 ↔ 1.2.0.1,混配会「编译全过、真机启动即崩」):',
178
191
  ' https://atomgit.com/Cangjie/cangjie_stdx/releases(匿名可下)',
179
192
  IS_WIN
180
- ? '解压后把 CANGJIE_STDX 指到 <解压目录>\\windows_x86_64_cjnative\\dynamic\\stdx(动态库目录,不是包根),'
193
+ ? '解压后把 CANGJIE_STDX 指到 <解压目录>\\windows_x86_64_cjnative\\static\\stdx(静态库目录,'
194
+ : '解压后把 CANGJIE_STDX 指到 <解压目录>/linux_x86_64_cjnative/dynamic/stdx(动态库目录,不是包根),',
195
+ IS_WIN
196
+ ? 'Windows 编本机可执行吃的是静态库,不是包根、也不是 dynamic\\stdx);'
181
197
  : '解压后把 CANGJIE_STDX 指到 <解压目录>/linux_x86_64_cjnative/dynamic/stdx(动态库目录,不是包根),',
182
198
  IS_WIN
183
199
  ? '并 setx CANGJIE_STDX <路径> 持久化(重开终端生效);然后重跑本命令。'
package/cjpm.toml CHANGED
@@ -2,7 +2,7 @@
2
2
  cjc-version = "1.0.5"
3
3
  name = "cjTauri"
4
4
  description = "仓颉版 Tauri:轻量跨端混合开发框架(WebView 宿主 + IPC 桥 + 能力安全模型)"
5
- version = "2.3.1"
5
+ version = "2.3.2"
6
6
  target-dir = ""
7
7
  output-type = "static"
8
8
  compile-option = ""
package/cli/cjpm.toml CHANGED
@@ -2,7 +2,7 @@
2
2
  cjc-version = "1.0.5"
3
3
  name = "cli"
4
4
  description = "cj-tauri CLI:脚手架 create / dev / build / run / info"
5
- version = "2.3.1"
5
+ version = "2.3.2"
6
6
  target-dir = ""
7
7
  output-type = "executable"
8
8
  compile-option = ""
@@ -10,7 +10,7 @@ import std.collection.*
10
10
 
11
11
  /** CLI 版本:须与 cli/cjpm.toml 的 version、CHANGELOG 顶部版本一致(scripts/check-version.sh 校验) */
12
12
  func cliVersion(): String {
13
- return "2.3.1"
13
+ return "2.3.2"
14
14
  }
15
15
 
16
16
  /** 一次命令所需的路径上下文 */
@@ -457,9 +457,10 @@ func runProject(c: AppContext): Int64 {
457
457
  return code
458
458
  }
459
459
 
460
- /** 某个目录下是不是鸿蒙脚手架工程(判据:build-hap.sh + entry/cjpm.toml 同时在) */
460
+ /** 某个目录下是不是鸿蒙脚手架工程(判据:构建入口脚本 + entry/cjpm.toml 同时在) */
461
461
  func isOhosProjectAt(dir: String): Bool {
462
- return exists(joinPath(dir, "build-hap.sh")) && exists(joinPath(joinPath(dir, "entry"), "cjpm.toml"))
462
+ let hasEntryToml = exists(joinPath(joinPath(dir, "entry"), "cjpm.toml"))
463
+ return hasEntryToml && (exists(joinPath(dir, "build-hap.sh")) || exists(joinPath(dir, "build-hap.ps1")))
463
464
  }
464
465
 
465
466
  /**
@@ -482,14 +483,33 @@ func findOhosProjectRoot(): Option<String> {
482
483
  }
483
484
 
484
485
  /**
485
- * 鸿蒙工程:构建入口就是工程自带的 `build-hap.sh`
486
+ * 鸿蒙工程:构建入口是工程自带的 `build-hap.sh`(bash)或 `build-hap.ps1`(PowerShell)
486
487
  *
487
488
  * 跑它而不是自己拼 hvigor 命令:DevEco 探测、cjc/opt 同代、stdx 联接、`--no-daemon`
488
- * 这些坑全在脚本里(见模板 build-hap.sh 的注释),CLI 只负责传参。
489
- * `--install` 走 `run`:编完装到设备并 `aa start`。
489
+ * 这些坑全在脚本里(见模板注释),CLI 只负责传参。两个入口语义一致,都在模板里维护、
490
+ * 改动请同步。Windows 优先 ps1(powershell 系统自带,bash 要另装 Git Bash);
491
+ * ps1 不存在才回落 bash。`--install` 走 `run`:编完装到设备并 `aa start`。
490
492
  */
491
493
  func buildOhos(root: String, install: Bool): Int64 {
492
494
  var argv = ArrayList<String>()
495
+ if (hostIsWindows() && exists(joinPath(root, "build-hap.ps1"))) {
496
+ // -ExecutionPolicy Bypass:用户机器默认策略可能是 Restricted,只为跑构建脚本不该要求全局改策略
497
+ argv.add("-NoProfile")
498
+ argv.add("-ExecutionPolicy")
499
+ argv.add("Bypass")
500
+ argv.add("-File")
501
+ argv.add("build-hap.ps1")
502
+ if (install) {
503
+ argv.add("-Install")
504
+ }
505
+ println("[cj-tauri] 鸿蒙工程:powershell build-hap.ps1${if (install) { " -Install" } else { "" }}(${root})")
506
+ let code = execute("powershell.exe", argv.toArray(), workingDirectory: Path(root))
507
+ if (code != 0) {
508
+ eprintln("[cj-tauri] 构建失败(exit=${code})")
509
+ eprintln(" 日志: ${joinPath(root, ".buildlog")}/last-build.log")
510
+ }
511
+ return code
512
+ }
493
513
  argv.add("build-hap.sh")
494
514
  if (install) {
495
515
  argv.add("--install")
@@ -351,7 +351,11 @@ func cmdCreate(nameArg: String, tpl: String, bundleArg: String, labelArg: String
351
351
  }
352
352
  if (ohos) {
353
353
  println(" 鸿蒙端: export CANGJIE_STDX_OHOS=<鸿蒙版 stdx>/linux_ohos_aarch64_cjnative/dynamic/stdx")
354
- println(" cd targets/ohos && bash build-hap.sh [--install]")
354
+ if (hostIsWindows()) {
355
+ println(" cd targets\\ohos && npx cj-tauri build(走 build-hap.ps1)")
356
+ } else {
357
+ println(" cd targets/ohos && bash build-hap.sh [--install]")
358
+ }
355
359
  println("")
356
360
  println(" 提示: 模板不带签名证书——首次在 DevEco 里 File → Project Structure → Signing Configs")
357
361
  println(" 勾「Automatically generate signature」(要登录华为账号);不签名只能编出")
package/cli/src/sync.cj CHANGED
@@ -356,7 +356,12 @@ func cmdSync(args: Array<String>): Int64 {
356
356
  match (resolveFrameworkRoot()) {
357
357
  case Some(f) => fwRoot = f
358
358
  case None =>
359
- eprintln("[cj-tauri] 未定位到框架根:请 export CJ_TAURI_ROOT=<框架仓库根>,或 --framework <路径>")
359
+ // 提示跟着宿主 shell 走:PowerShell 里给 export 命令是误导(报「无法将 export 项识别为 cmdlet」)
360
+ if (hostIsWindows()) {
361
+ eprintln("[cj-tauri] 未定位到框架根:请 `$env:CJ_TAURI_ROOT = \"<框架仓库根>\"`(或 setx 持久化),或 --framework <路径>")
362
+ } else {
363
+ eprintln("[cj-tauri] 未定位到框架根:请 export CJ_TAURI_ROOT=<框架仓库根>,或 --framework <路径>")
364
+ }
360
365
  return 1
361
366
  }
362
367
  }
@@ -367,9 +372,14 @@ func cmdSync(args: Array<String>): Int64 {
367
372
  writeText("targets/desktop/cjpm.toml", m.renderDesktopToml(fwRoot, cliVersion()))
368
373
  writeText("targets/desktop/src/main.cj", m.renderDesktopMain(cliVersion()))
369
374
  println("[cj-tauri] 已生成 targets/desktop/cjpm.toml 与 targets/desktop/src/main.cj(launcher 调 ${m.pkg}.build())")
370
- println("[cj-tauri] 下一步:cd targets/desktop && cjpm build(需 CANGJIE_STDX 指向 stdx dynamic/stdx)")
371
- // issue #6-③:直接跑产物找不到 libcjtbridge.so 时,这是唯一能指路的提示
372
- println("[cj-tauri] 运行产物需 LD_LIBRARY_PATH 含 ${toTomlPath(fwRoot)}/native(libcjtbridge.so 所在),或改用 cj-tauri run / dev")
375
+ if (hostIsWindows()) {
376
+ println("[cj-tauri] 下一步:cd targets\\desktop && cjpm build(常规构建需 CANGJIE_STDX 指向 static\\stdx;动态构建才是 dynamic\\stdx)")
377
+ println("[cj-tauri] 运行产物需 PATH 含 ${toTomlPath(fwRoot)}\\native(libcjtbridge.dll 所在),或改用 cj-tauri run / dev")
378
+ } else {
379
+ println("[cj-tauri] 下一步:cd targets/desktop && cjpm build(需 CANGJIE_STDX 指向 stdx dynamic/stdx)")
380
+ // issue #6-③:直接跑产物找不到 libcjtbridge.so 时,这是唯一能指路的提示
381
+ println("[cj-tauri] 运行产物需 LD_LIBRARY_PATH 含 ${toTomlPath(fwRoot)}/native(libcjtbridge.so 所在),或改用 cj-tauri run / dev")
382
+ }
373
383
  }
374
384
  if (target == "" || target == "ohos") {
375
385
  code = syncOhos(m, fwRoot)
@@ -658,8 +668,13 @@ func syncOhos(m: Manifest, fwRoot: String): Int64 {
658
668
  }
659
669
  let copied = copyAssetsToRawfile(m.assetsRoot, rawfileDir)
660
670
  println("[cj-tauri] 已生成 targets/ohos:模板 ${count} 文件 + 清单派生 4 文件 + rawfile ${copied} 资产")
661
- println("[cj-tauri] 下一步:export CANGJIE_STDX_OHOS=<鸿蒙版 stdx>/linux_ohos_aarch64_cjnative/dynamic/stdx")
662
- println(" cd targets/ohos && bash build-hap.sh")
671
+ if (hostIsWindows()) {
672
+ println("[cj-tauri] 下一步:`$env:CANGJIE_STDX_OHOS = \"<鸿蒙版 stdx>\\linux_ohos_aarch64_cjnative\\dynamic\\stdx\"`(PowerShell)")
673
+ println(" cd targets\\ohos && npx cj-tauri build(走 build-hap.ps1;装设备加 -Install 走 run)")
674
+ } else {
675
+ println("[cj-tauri] 下一步:export CANGJIE_STDX_OHOS=<鸿蒙版 stdx>/linux_ohos_aarch64_cjnative/dynamic/stdx")
676
+ println(" cd targets/ohos && bash build-hap.sh")
677
+ }
663
678
  return 0
664
679
  }
665
680
  }
@@ -0,0 +1,205 @@
1
+ # {{PROJECT_NAME}} - HarmonyOS PC (2in1) HAP build entry for PowerShell.
2
+ #
3
+ # PowerShell twin of build-hap.sh (same steps, native Windows paths; no Git Bash needed).
4
+ # Usage:
5
+ # powershell -ExecutionPolicy Bypass -File build-hap.ps1 build the hap
6
+ # powershell -ExecutionPolicy Bypass -File build-hap.ps1 -Install build + hdc install + aa start
7
+ # powershell -ExecutionPolicy Bypass -File build-hap.ps1 -Clean remove entry/build first
8
+ #
9
+ # Prerequisites (each checked below with an actionable message):
10
+ # 1. DevEco Studio 6.1+ (ships hvigor + node). Probed at common locations;
11
+ # set DEVECO_WIN=<install root, Windows form> to override.
12
+ # 2. Ohos stdx: set CANGJIE_STDX_OHOS=<stdx>/linux_ohos_aarch64_cjnative/dynamic/stdx
13
+ # - without it cjpm reports a misleading "missing dependency" error.
14
+ # 3. Signing: the template ships no certificate. In DevEco: File -> Project Structure ->
15
+ # Signing Configs -> "Automatically generate signature" (requires a Huawei account).
16
+ # Unsigned builds still produce *-unsigned.hap but cannot be installed (9568289 etc.).
17
+
18
+ $ErrorActionPreference = "Stop"
19
+ $RootDir = $PSScriptRoot
20
+ $DoInstall = $false
21
+ $DoClean = $false
22
+ foreach ($a in $args) {
23
+ switch -- ($a.ToLower()) {
24
+ "-install" { $DoInstall = $true }
25
+ "--install" { $DoInstall = $true }
26
+ "-clean" { $DoClean = $true }
27
+ "--clean" { $DoClean = $true }
28
+ "-h" { Get-Content $PSCommandPath | Select-Object -First 22; exit 0 }
29
+ "--help" { Get-Content $PSCommandPath | Select-Object -First 22; exit 0 }
30
+ default { Write-Error "[ohos] unknown arg: $a (supported: -Install / -Clean / -Help)"; exit 2 }
31
+ }
32
+ }
33
+
34
+ function Write-Ohos([string]$msg) { Write-Host "[ohos] $msg" }
35
+ function Write-OhosErr([string]$msg) { Write-Host "[ohos] $msg" -ForegroundColor Red }
36
+
37
+ # DevEco install root: DEVECO_WIN first, then common locations.
38
+ function Find-Deveco {
39
+ if ($env:DEVECO_WIN) { return $env:DEVECO_WIN }
40
+ foreach ($cand in @(
41
+ "D:\oh\DevEcoStudio",
42
+ "C:\Program Files\Huawei\DevEco Studio",
43
+ "D:\Program Files\Huawei\DevEco Studio",
44
+ "C:\Program Files (x86)\Huawei\DevEco Studio")) {
45
+ if (Test-Path (Join-Path $cand "tools\hvigor")) { return $cand }
46
+ }
47
+ return $null
48
+ }
49
+
50
+ # A preset env value pointing at a non-existent dir makes hvigor fail with
51
+ # "Invalid value of 'DEVECO_SDK_HOME'" - fall back and say what was ignored.
52
+ function Pick-DevecoPath([string]$cand, [string]$fallback) {
53
+ if ($cand -and (Test-Path $cand)) { return $cand }
54
+ if ($cand) { Write-OhosErr "ignoring invalid path: $cand, using $fallback" }
55
+ return $fallback
56
+ }
57
+
58
+ $deveco = Find-Deveco
59
+ if (-not $deveco) {
60
+ Write-OhosErr "DevEco Studio not found. Set DEVECO_WIN=<install root, Windows form>"
61
+ Write-Host " e.g. `$env:DEVECO_WIN = 'D:\Program Files\Huawei\DevEco Studio'"
62
+ exit 1
63
+ }
64
+ $env:DEVECO_WIN = $deveco
65
+ $env:DEVECO_SDK_HOME = Pick-DevecoPath $env:DEVECO_SDK_HOME (Join-Path $deveco "sdk")
66
+ $env:NODE_HOME = Pick-DevecoPath $env:NODE_HOME (Join-Path $deveco "tools\node")
67
+
68
+ if (-not $env:CANGJIE_STDX_OHOS) {
69
+ Write-OhosErr "set CANGJIE_STDX_OHOS=<ohos stdx>/linux_ohos_aarch64_cjnative/dynamic/stdx first"
70
+ exit 1
71
+ }
72
+
73
+ $nodeExe = Join-Path $deveco "tools\node\node.exe"
74
+ $hvigorJs = Join-Path $deveco "tools\hvigor\bin\hvigorw.js"
75
+ if (-not (Test-Path $hvigorJs)) {
76
+ Write-OhosErr "$hvigorJs not found - is DEVECO_WIN correct?"
77
+ exit 1
78
+ }
79
+
80
+ # hvigorw locates the Cangjie build plugin itself and creates the node_modules junctions;
81
+ # headless runs must hand it the path or the failure surfaces as
82
+ # "property name must be valid: cangjieOptions" (looks like a project config error,
83
+ # actually the plugin was not loaded).
84
+ if (-not $env:DEVECO_HVIGOR_CANGJIE_PLUGIN) {
85
+ $appdata = if ($env:APPDATA) { $env:APPDATA } else { "$env:USERPROFILE\AppData\Roaming" }
86
+ $cjb = Get-ChildItem -Path (Join-Path $appdata "Huawei") -Filter "DevEcoStudio*" -Directory -ErrorAction SilentlyContinue |
87
+ ForEach-Object { Get-ChildItem (Join-Path $_.FullName "plugins") -Filter "devecostudio-cangjie-plugin-*" -Directory -ErrorAction SilentlyContinue } |
88
+ ForEach-Object { Get-ChildItem (Join-Path $_.FullName "lib\hvigor") -Filter "cangjie-build-support" -Directory -ErrorAction SilentlyContinue } |
89
+ Select-Object -First 1
90
+ if ($cjb) {
91
+ $env:DEVECO_HVIGOR_CANGJIE_PLUGIN = $cjb.FullName
92
+ } else {
93
+ Write-OhosErr "Cangjie build plugin not found under <APPDATA>\Huawei\DevEcoStudio*\plugins\devecostudio-cangjie-plugin-*\lib\hvigor\cangjie-build-support"
94
+ Write-Host " set DEVECO_HVIGOR_CANGJIE_PLUGIN=<that dir>"
95
+ exit 1
96
+ }
97
+ }
98
+ # The plugin being loadable is not the same as being enabled: when disabled it deletes the
99
+ # cangjie schema silently (terminal only shows 00303038). Set both switches.
100
+ $env:DEVECO_CANGJIE_PLUGIN_ENABLED = "true"
101
+ $env:NODE_PATH = Join-Path (Get-Location) "node_modules"
102
+
103
+ # The SDK's cjpm.exe hard-depends on libcangjie-runtime.dll (under runtime/lib):
104
+ # without it hvigor exits 0xC0000139 within milliseconds.
105
+ if (-not $env:CANGJIE_SDK) {
106
+ $cand = Get-ChildItem "$env:USERPROFILE\.cangjie-sdk" -Directory -ErrorAction SilentlyContinue |
107
+ ForEach-Object { Join-Path $_.FullName "cangjie" } | Where-Object { Test-Path $_ } |
108
+ Sort-Object { [version]($_.Split('\') | Where-Object { $_ -match '^\d' } | Select-Object -First 1) } -ErrorAction SilentlyContinue |
109
+ Select-Object -Last 1
110
+ if ($cand) { $env:CANGJIE_SDK = $cand }
111
+ }
112
+ $cjsdkRt = Join-Path $env:CANGJIE_SDK "build-tools\runtime\lib\windows_x86_64_cjnative"
113
+ $cjsdkBin = Join-Path $env:CANGJIE_SDK "build-tools\bin"
114
+ $cjsdkToolsBin = Join-Path $env:CANGJIE_SDK "build-tools\tools\bin"
115
+ if (Test-Path $cjsdkRt) {
116
+ $env:PATH = "$cjsdkRt;$env:PATH"
117
+ } else {
118
+ Write-OhosErr "Cangjie runtime dir not found: $cjsdkRt - cjpm will exit 0xC0000139"
119
+ Write-Host " set CANGJIE_SDK=<.cangjie-sdk/<version>/cangjie>"
120
+ }
121
+ # cjc and opt must come from the SAME SDK build: cjc looks up opt via CANGJIE_HOME;
122
+ # a mismatch shows up as "EnumReflection format: operand numbers error!".
123
+ if (Test-Path $cjsdkBin) {
124
+ $env:PATH = "$cjsdkBin;$cjsdkToolsBin;$env:PATH"
125
+ $env:CANGJIE_HOME = Join-Path $env:CANGJIE_SDK "build-tools"
126
+ $cjcCmd = Get-Command cjc -ErrorAction SilentlyContinue
127
+ Write-Ohos "cjc = $($cjcCmd.Source)"
128
+ Write-Ohos "CANGJIE_HOME = $env:CANGJIE_HOME"
129
+ }
130
+
131
+ # entry/cjpm.toml references stdx via the relative path "../stdx" = a junction on the project
132
+ # root: hvigor only substitutes its own template vars, any other ${...} expands to an empty
133
+ # string which kills the whole path-option line (reported as "not added as a dependency").
134
+ $stdxLink = Join-Path $RootDir "stdx"
135
+ if (-not (Test-Path $stdxLink)) {
136
+ if (-not (Test-Path $env:CANGJIE_STDX_OHOS)) {
137
+ Write-OhosErr "CANGJIE_STDX_OHOS points to a non-existent dir: $env:CANGJIE_STDX_OHOS"
138
+ exit 1
139
+ }
140
+ New-Item -ItemType Junction -Path $stdxLink -Value $env:CANGJIE_STDX_OHOS | Out-Null
141
+ Write-Ohos "stdx junction created: $stdxLink -> $env:CANGJIE_STDX_OHOS"
142
+ }
143
+
144
+ # Stale artifacts: hvigor's CompileCangjie and framework-side cjpm each keep their own
145
+ # incremental cache; clearing only one feeds back an old .so (judge by artifact size,
146
+ # not by "build success").
147
+ if ($DoClean) {
148
+ Write-Ohos "cleaning entry/build (--clean)"
149
+ if (Test-Path (Join-Path $RootDir "entry\build")) { Remove-Item -Recurse -Force (Join-Path $RootDir "entry\build") }
150
+ }
151
+
152
+ # Assets sync: the project root assets/ dir is the single source of truth (RFC-002 section 7);
153
+ # pages and capability manifests are real rawfile files inside the hap - building without
154
+ # this sync installs STALE pages (self-checks still run, changes silently lost).
155
+ $appRoot = Split-Path (Split-Path $RootDir)
156
+ if ((Test-Path (Join-Path $appRoot "cj-tauri.toml")) -and (Test-Path (Join-Path $appRoot "assets"))) {
157
+ $rawfile = Join-Path $RootDir "entry\src\main\resources\rawfile"
158
+ New-Item -ItemType Directory -Force -Path (Join-Path $rawfile "ui") | Out-Null
159
+ New-Item -ItemType Directory -Force -Path (Join-Path $rawfile "capabilities") | Out-Null
160
+ # remove-then-copy: Copy-Item -Recurse into an existing dir would nest ui/ui/ and pages go stale
161
+ Remove-Item -Recurse -Force (Join-Path $rawfile "ui"), (Join-Path $rawfile "capabilities") -ErrorAction SilentlyContinue
162
+ Copy-Item -Recurse -Force (Join-Path $appRoot "assets\ui") (Join-Path $rawfile "ui")
163
+ Copy-Item -Recurse -Force (Join-Path $appRoot "assets\capabilities") (Join-Path $rawfile "capabilities")
164
+ Write-Ohos "assets synced from project root to rawfile (ui/ + capabilities/)"
165
+ }
166
+
167
+ # --no-daemon is mandatory: the resident daemon's CompileCangjie uses the env captured at
168
+ # daemon start; PATH/CANGJIE_HOME exported here never reach it (symptom: manual cjpm works,
169
+ # hvigor run crashes in opt).
170
+ $buildlogDir = Join-Path $RootDir ".buildlog"
171
+ New-Item -ItemType Directory -Force -Path $buildlogDir | Out-Null
172
+ & $nodeExe $hvigorJs --no-daemon --mode module -p product=default -p module=entry@default assembleHap 2>&1 |
173
+ Tee-Object -FilePath (Join-Path $buildlogDir "last-build.log")
174
+ if ($LASTEXITCODE -ne 0) {
175
+ Write-OhosErr "hvigor assembleHap failed (exit=$LASTEXITCODE)"
176
+ exit $LASTEXITCODE
177
+ }
178
+
179
+ $hap = Get-ChildItem (Join-Path $RootDir "entry\build\default\outputs\default") -Filter "*.hap" -ErrorAction SilentlyContinue |
180
+ Sort-Object LastWriteTime -Descending | Select-Object -First 1
181
+ if (-not $hap) {
182
+ Write-OhosErr "build finished but no hap artifact; check .buildlog/last-build.log"
183
+ exit 1
184
+ }
185
+ Write-Ohos "HAP = $($hap.FullName) ($($hap.Length) bytes)"
186
+ if ($hap.Name -like "*unsigned*") {
187
+ Write-OhosErr "unsigned hap: cannot be installed. Configure auto-signing in DevEco and rebuild."
188
+ $DoInstall = $false
189
+ }
190
+
191
+ if ($DoInstall) {
192
+ $hdc = Join-Path $deveco "sdk\default\openharmony\toolchains\hdc.exe"
193
+ if (-not (Test-Path $hdc)) {
194
+ Write-OhosErr "hdc not found: $hdc (-Install needs it; or put your own hdc on PATH)"
195
+ exit 1
196
+ }
197
+ Write-Ohos "connected devices:"
198
+ & $hdc list targets
199
+ Write-Ohos "installing $($hap.Name)"
200
+ & $hdc install -r $hap.FullName
201
+ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
202
+ Write-Ohos "starting EntryAbility"
203
+ # -a must be the ability name in module.json5 (EntryAbility), not the Cangjie class name.
204
+ & $hdc shell aa start -a EntryAbility -b {{BUNDLE_NAME}}
205
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cj-tauri",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Tauri for the Cangjie language: a scaffold CLI for hybrid desktop apps — Cangjie backend (statically compiled) plus a system WebView frontend (HTML/CSS/JS), with a bidirectional IPC bridge and a capability-based security model. Windows, Linux and HarmonyOS PC.",
5
5
  "keywords": [
6
6
  "cangjie",
package/src/version.cj CHANGED
@@ -9,7 +9,7 @@ package cjTauri
9
9
  * - cli/src/project.cj 的 cliVersion()
10
10
  * - CHANGELOG.md 顶部第一个已发版段
11
11
  */
12
- public let CJ_TAURI_VERSION = "2.3.1"
12
+ public let CJ_TAURI_VERSION = "2.3.2"
13
13
 
14
14
  /**
15
15
  * IPC 报文协议版本(报文形状是跨层契约,加版本字段是协议治理惯例):事件 / 回执信封的 `protocol` 字段