cj-tauri 2.2.0 → 2.3.1

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
@@ -107,6 +107,88 @@ function resolveCjpm(home) {
107
107
  return null;
108
108
  }
109
109
 
110
+ /**
111
+ * 解析 stdx 动态库目录(${CANGJIE_STDX} 要的值)。
112
+ * cli/cjpm.toml 的两个 target 段都写 `path-option = ["${CANGJIE_STDX}"]`,cjpm 按进程环境变量
113
+ * 展开它——PowerShell / cmd 里没设这个变量时展开成空串,报的是
114
+ * `root package 'cli' imports package 'stdx.encoding.json' ... not added as a dependency`
115
+ * (看着像 toml 漏配,其实是变量没落地),首次构建当场就死。这里按顺序探测:
116
+ * 1. 用户已设的 CANGJIE_STDX(存在才用,指错了会拿到假的「已配置」);
117
+ * 2. ~/.cangjie/stdx/<包>/dynamic/stdx(CI / 教程的落位);
118
+ * 3. SDK 根的兄弟目录 cangjie-stdx-<版本>/<三元组>/dynamic/stdx(解压在 SDK 旁边的习惯)。
119
+ * 要求目录里有 stdx.* 的库文件,防止指到 stdx 包根(那是「create 成功、build 才炸」的另一种指错);
120
+ * 自动探测的候选还必须匹配**宿主平台**(包名含 windows/linux、不含 ohos)——
121
+ * 机器上可能同时躺着给鸿蒙交叉编译用的 cangjie-stdx-ohos-aarch64 包,它里面没有
122
+ * 宿主目标的库文件,链上去就是 `lld: error: unable to find library -lstdx.encoding.json`
123
+ * (2026-11-12 Windows 实测)。用户显式设置的 CANGJIE_STDX 仍然优先(那是他自己的选择),
124
+ * 但若路径里带 ohos 会打一行警告。 */
125
+ function resolveStdx(home) {
126
+ const looksRight = (p) => {
127
+ try {
128
+ return fs.readdirSync(p).some((n) => n.startsWith('stdx.'));
129
+ } catch (e) {
130
+ return false;
131
+ }
132
+ };
133
+ // 宿主平台关键词:自动探测的包名必须含它且不含 ohos(交叉编译包不能当宿主 stdx 用)
134
+ const platKey = IS_WIN ? 'windows' : (process.platform === 'darwin' ? 'darwin' : 'linux');
135
+ const hostUsable = (pkgName) => pkgName.includes(platKey) && !pkgName.includes('ohos');
136
+
137
+ const candidates = [];
138
+ if (process.env.CANGJIE_STDX && fs.existsSync(process.env.CANGJIE_STDX)) {
139
+ if (process.env.CANGJIE_STDX.includes('ohos')) {
140
+ note('告警: CANGJIE_STDX 指向 ohos 包(给鸿蒙交叉编译用),主机构建用不了,请改指宿主平台的 stdx');
141
+ }
142
+ candidates.push(process.env.CANGJIE_STDX);
143
+ }
144
+ const cjStdxBase = path.join(os.homedir(), '.cangjie', 'stdx');
145
+ try {
146
+ for (const pkg of fs.readdirSync(cjStdxBase)) {
147
+ if (hostUsable(pkg)) {
148
+ candidates.push(path.join(cjStdxBase, pkg, 'dynamic', 'stdx'));
149
+ }
150
+ }
151
+ } catch (e) {
152
+ // 目录不存在 = 没按这个布局装过,忽略
153
+ }
154
+ const sdkParent = path.dirname(home);
155
+ try {
156
+ for (const pkg of fs.readdirSync(sdkParent)) {
157
+ if (!pkg.startsWith('cangjie-stdx-')) {
158
+ continue;
159
+ }
160
+ const triple = IS_WIN ? 'windows_x86_64_cjnative' : (process.platform === 'darwin' ? 'darwin_x86_64_cjnative' : 'linux_x86_64_cjnative');
161
+ if (hostUsable(pkg)) {
162
+ candidates.push(path.join(sdkParent, pkg, triple, 'dynamic', 'stdx'));
163
+ }
164
+ }
165
+ } catch (e) {
166
+ // 同上
167
+ }
168
+ return candidates.find(looksRight) || null;
169
+ }
170
+
171
+ /** CANGJIE_STDX 解析不到时的提示:给下载入口与 setx 落法,别让 cjpm 的报错背锅 */
172
+ function printMissingStdxHint() {
173
+ const lines = [
174
+ '错误: 没找到 stdx 扩展标准库(CANGJIE_STDX 未设置,常见安装位置也没探测到)。',
175
+ 'CLI 与生成的工程都 import stdx.encoding.json,cjpm.toml 按 ${CANGJIE_STDX} 引用它,',
176
+ '这个变量没进进程时 cjpm 报「imports package stdx... not added as a dependency」,极易误判成 toml 漏配。',
177
+ '请下载 stdx(与 SDK 版本配套,1.2.0 ↔ 1.2.0.1,混配会「编译全过、真机启动即崩」):',
178
+ ' https://atomgit.com/Cangjie/cangjie_stdx/releases(匿名可下)',
179
+ IS_WIN
180
+ ? '解压后把 CANGJIE_STDX 指到 <解压目录>\\windows_x86_64_cjnative\\dynamic\\stdx(动态库目录,不是包根),'
181
+ : '解压后把 CANGJIE_STDX 指到 <解压目录>/linux_x86_64_cjnative/dynamic/stdx(动态库目录,不是包根),',
182
+ IS_WIN
183
+ ? '并 setx CANGJIE_STDX <路径> 持久化(重开终端生效);然后重跑本命令。'
184
+ : '并 export CANGJIE_STDX=<路径> 持久化(写进 ~/.bashrc / ~/.zshrc);然后重跑本命令。',
185
+ '详见: https://atomgit.com/qq8864/cj-tauri/blob/main/docs/使用文档.md',
186
+ ];
187
+ for (const line of lines) {
188
+ note(line);
189
+ }
190
+ }
191
+
110
192
  /**
111
193
  * 拼装子进程环境。
112
194
  * PATH = 运行时库目录 + bin + tools/bin + tools/lib + ~/.cjpm/bin + 原 PATH
@@ -140,6 +222,19 @@ function buildEnv(home, runtimeDir) {
140
222
  if (!env.CJ_TAURI_ROOT) {
141
223
  env.CJ_TAURI_ROOT = PKG_ROOT;
142
224
  }
225
+
226
+ // ${CANGJIE_STDX} 是 cjpm.toml 里的字面引用,cjpm 按进程环境变量展开:
227
+ // 这里解析到了就补进 env(用户已设且有效时不覆盖),CLI 自己 spawn cjpm 时会继承下去,
228
+ // 生成工程之后的 cj-tauri build / run 同样受益。
229
+ const stdx = resolveStdx(home);
230
+ if (stdx) {
231
+ if (stdx !== process.env.CANGJIE_STDX) {
232
+ verbose(`CANGJIE_STDX 未设置或无效,探测到: ${stdx}`);
233
+ }
234
+ env.CANGJIE_STDX = stdx;
235
+ } else if (!process.env.CANGJIE_STDX) {
236
+ verbose('CANGJIE_STDX 未设置且未探测到(首次构建 CLI 时会失败,含安装提示)');
237
+ }
143
238
  return env;
144
239
  }
145
240
 
@@ -204,6 +299,13 @@ function copyDir(from, to, skipNames) {
204
299
  * 而全局安装的包目录可能是只读的(系统 node_modules 尤其如此)。
205
300
  */
206
301
  function buildCli(env, cjpm) {
302
+ // 硬前置:cli/cjpm.toml 的 path-option 是 ${CANGJIE_STDX},变量为空时 cjpm 把它读成
303
+ // 「stdx 没声明成依赖」。提前拦下并给安装提示,比甩一段 cjpm 报错给人强。
304
+ if (!env.CANGJIE_STDX) {
305
+ note('错误: 构建需要 stdx 扩展标准库,但没有找到可用的 CANGJIE_STDX。');
306
+ printMissingStdxHint();
307
+ return null;
308
+ }
207
309
  const buildDir = path.join(cacheRoot(), VERSION, 'build', 'cli');
208
310
  note(`首次运行:正在构建 CLI 本体(${cjpm} build)...`);
209
311
  fs.rmSync(buildDir, { recursive: true, force: true });
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.2.0"
5
+ version = "2.3.1"
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.2.0"
5
+ version = "2.3.1"
6
6
  target-dir = ""
7
7
  output-type = "executable"
8
8
  compile-option = ""
package/cli/src/doctor.cj CHANGED
@@ -100,7 +100,7 @@ func cmdDoctor(): Int64 {
100
100
  case None =>
101
101
  doctorLine(rep, CheckLevel.Fail, "CANGJIE_HOME", "未找到",
102
102
  "设置 CANGJIE_HOME,或把 SDK 的 bin 加进 PATH(doctor 从 cjc 反推);" +
103
- "下载:https://cangjie-lang.cn/download(需登录华为账号),本项目要求 SDK 1.2.0 + stdx 1.2.0.1,两者必须配套")
103
+ "下载:https://cangjie-lang.cn/download(匿名可下,不用登录),本项目要求 SDK 1.2.0 + stdx 1.2.0.1,两者必须配套")
104
104
  }
105
105
 
106
106
  let (cjcCode, cjcVer) = doctorProbe("cjc", ["-v"])
@@ -468,7 +468,10 @@ public class Manifest {
468
468
  // 2026-10-25 起 http 插件的鸿蒙支(http_ohos.cj)走系统网络栈 ohos.net.http,
469
469
  // 模块符号(ohos.net.http:*_ti)在 libohos.net.http.so——缺了应用启动即
470
470
  // 「relocating failed: symbol not found」(真机实测),所以进默认链接。
471
- " link-option = \"" + appendLink("-lpasteboard -ludmf -lohos.net.http", this.linkOhos) + "\"\n" +
471
+ // 2026-11-12 起框架的诊断出口也进默认链接:src/log_bridge.cj 的鸿蒙段直接调 hilog 的
472
+ // NDK C 接口 `OH_LOG_Print`(tag = cj-tauri),符号在 libhilog_ndk.z.so。缺了它同样是
473
+ // 模块加载期解析不到符号——而这条的代价最贵:**日志通道坏了,报错也看不见**。
474
+ " link-option = \"" + appendLink("-lpasteboard -ludmf -lohos.net.http -lhilog_ndk.z", this.linkOhos) + "\"\n" +
472
475
  "[target.aarch64-linux-ohos.bin-dependencies]\n" +
473
476
  " # 鸿蒙版 stdx:相对路径指向骨架根上的 `stdx` 联接(build-hap.sh 用 CANGJIE_STDX_OHOS\n" +
474
477
  " # 建,不入库)。hvigor 只替换它自己的模板变量,写别的 " + "$" + "{...}" + " 会变空串、整条\n" +
@@ -477,7 +480,7 @@ public class Manifest {
477
480
  " package-option = {}\n" +
478
481
  "\n[target.x86_64-linux-ohos]\n" +
479
482
  " compile-option = \"-B \\\"" + dc + "/build-tools/third_party/llvm/bin\\\" -B \\\"" + dn + "/sysroot/usr/lib/x86_64-linux-ohos\\\" -L \\\"" + dn + "/sysroot/usr/lib/x86_64-linux-ohos\\\" -L \\\"" + dn + "/llvm/lib/clang/15.0.4/lib/x86_64-linux-ohos\\\" -L \\\"" + dn + "/llvm/lib/x86_64-linux-ohos\\\" --sysroot \\\"" + dn + "/sysroot\\\"\"\n" +
480
- " link-option = \"" + appendLink("-lpasteboard -ludmf -lohos.net.http", this.linkOhos) + "\"\n" +
483
+ " link-option = \"" + appendLink("-lpasteboard -ludmf -lohos.net.http -lhilog_ndk.z", this.linkOhos) + "\"\n" +
481
484
  "[target.x86_64-linux-ohos.bin-dependencies]\n" +
482
485
  " path-option = [\"" + x1 + "\", \"" + x2 + "\", \"" + x3 + "\", \"../stdx\"]\n" +
483
486
  " package-option = {}\n"
@@ -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.2.0"
13
+ return "2.3.1"
14
14
  }
15
15
 
16
16
  /** 一次命令所需的路径上下文 */
@@ -32,7 +32,13 @@
32
32
  # 只写在框架自己的 cjpm.toml 里不生效,缺了模块里就留一堆 `U OH_Pasteboard_*`,
33
33
  # 表现是应用启动即 SIGSEGV(模块加载期解析不到符号)。
34
34
  # 库在同 sysroot 的 `usr/lib/aarch64-linux-ohos`,上面 compile-option 的 `-L` 已指着它。
35
- link-option = "-lpasteboard -ludmf"
35
+ # -lohos.net.http:http 插件的鸿蒙支走系统网络栈(仓颉运行时装不了 OpenSSL,见 AGENTS §4),
36
+ # 模块符号在 libohos.net.http.so。
37
+ # -lhilog_ndk.z:框架的诊断出口(`src/log_bridge.cj` 鸿蒙段的 `OH_LOG_Print`,tag = cj-tauri)。
38
+ # 这条尤其别漏——日志通道自己因为缺符号起不来,就没有任何地方能报出原因。
39
+ # 注意:`cj-tauri sync` 会用 `cli/src/manifest.cj` 的 `renderOhosEntryToml` **重新生成本文件**,
40
+ # 这里写的 link-option 会被覆盖,真源在生成器那一份(三处要一起改)。
41
+ link-option = "-lpasteboard -ludmf -lohos.net.http -lhilog_ndk.z"
36
42
  [target.aarch64-linux-ohos.bin-dependencies]
37
43
  # 鸿蒙版 stdx:这里写**相对路径**,指向工程根上的 `stdx` 联接(build-hap.sh 用
38
44
  # CANGJIE_STDX_OHOS 建,不入库)。两条实测依据:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cj-tauri",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
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/app.cj CHANGED
@@ -277,7 +277,7 @@ public class TauriApp <: AppHost {
277
277
  */
278
278
  public func loadCapabilities(dir: String): TauriApp {
279
279
  let n = loadCapabilitiesFromDir(dir, this.capabilities)
280
- eprintln("[cj-tauri] 已从 ${dir} 加载 ${n} 个 capability 清单")
280
+ logd("[cj-tauri] 已从 ${dir} 加载 ${n} 个 capability 清单")
281
281
  return this
282
282
  }
283
283
 
package/src/app_events.cj CHANGED
@@ -100,18 +100,18 @@ extend TauriApp {
100
100
  try {
101
101
  hook(json, label)
102
102
  } catch (e: Exception) {
103
- eprintln("[cj-tauri] shell hook 抛出异常(已忽略):${e}")
103
+ logd("[cj-tauri] shell hook 抛出异常(已忽略):${e}")
104
104
  }
105
105
  }
106
106
  match (parseShellEnvelope(json)) {
107
- case None => eprintln("[cj-tauri] shell event 信封解析失败(已丢弃):${json}")
107
+ case None => logd("[cj-tauri] shell event 信封解析失败(已丢弃):${json}")
108
108
  case Some(obj) =>
109
109
  var kind = ""
110
110
  if (let Some(k) <- shellString(obj, "kind")) {
111
111
  kind = k
112
112
  }
113
113
  match (shellEventNameFor(kind)) {
114
- case None => eprintln("[cj-tauri] shell event: 未知 kind \"${kind}\"(未投递):${json}")
114
+ case None => logd("[cj-tauri] shell event: 未知 kind \"${kind}\"(未投递):${json}")
115
115
  case Some(event) =>
116
116
  if (kind == "menu") {
117
117
  this.syncMenuStateFromShellObj(label, obj)
@@ -119,7 +119,7 @@ extend TauriApp {
119
119
  try {
120
120
  this.hub.emitToWindow(event, obj, label)
121
121
  } catch (e: Exception) {
122
- eprintln("[cj-tauri] shell event 投递失败(已忽略):${e}")
122
+ logd("[cj-tauri] shell event 投递失败(已忽略):${e}")
123
123
  }
124
124
  }
125
125
  }
@@ -156,7 +156,7 @@ extend TauriApp {
156
156
  let js = "window.__CJ_TAURI__._dispatch(${json});"
157
157
  let targets = this.windows.targets(window)
158
158
  if (targets.size == 0 && window.size > 0) {
159
- eprintln("[cj-tauri] 未注册的窗口 label:\"${window}\"(回执 / 事件未投递)")
159
+ logd("[cj-tauri] 未注册的窗口 label:\"${window}\"(回执 / 事件未投递)")
160
160
  return
161
161
  }
162
162
  for (rec in targets) {
@@ -41,7 +41,7 @@ extend TauriApp {
41
41
  this.menus.add(label, menu)
42
42
  host.setMenu(menu.toWire())
43
43
  case None =>
44
- eprintln("[cj-tauri] setMenu: 未注册的窗口 label \"${label}\"(菜单未设置)")
44
+ logd("[cj-tauri] setMenu: 未注册的窗口 label \"${label}\"(菜单未设置)")
45
45
  }
46
46
  return this
47
47
  }
@@ -126,13 +126,13 @@ extend TauriApp {
126
126
  case Some(item) =>
127
127
  item.enabled = enabled
128
128
  item.checked = checked
129
- case None => eprintln("[cj-tauri] setMenuItemState: 模型里没有 \"${id}\"(只改平台侧)")
129
+ case None => logd("[cj-tauri] setMenuItemState: 模型里没有 \"${id}\"(只改平台侧)")
130
130
  }
131
- case None => eprintln("[cj-tauri] setMenuItemState: 窗口 \"${label}\" 无应用层菜单模型(只改平台侧)")
131
+ case None => logd("[cj-tauri] setMenuItemState: 窗口 \"${label}\" 无应用层菜单模型(只改平台侧)")
132
132
  }
133
133
  match (this.hostOf(label)) {
134
134
  case Some(host) => host.setMenuItemState(id, enabled, checked)
135
- case None => eprintln("[cj-tauri] setMenuItemState: 未注册的窗口 label \"${label}\"(未生效)")
135
+ case None => logd("[cj-tauri] setMenuItemState: 未注册的窗口 label \"${label}\"(未生效)")
136
136
  }
137
137
  }
138
138
 
@@ -182,7 +182,7 @@ extend TauriApp {
182
182
  case Some(host) =>
183
183
  host.setDragDropPolicy(policy.enabled, policy.files)
184
184
  case None =>
185
- eprintln("[cj-tauri] setDragDrop: 未注册的窗口 label \"${label}\"(策略未设置)")
185
+ logd("[cj-tauri] setDragDrop: 未注册的窗口 label \"${label}\"(策略未设置)")
186
186
  }
187
187
  return this
188
188
  }
@@ -204,7 +204,7 @@ extend TauriApp {
204
204
  case Some(host) =>
205
205
  host.setGlobalHotkeys(keys.toWire())
206
206
  case None =>
207
- eprintln("[cj-tauri] setGlobalHotkeys: 未注册的窗口 label \"${label}\"(快捷键未设置)")
207
+ logd("[cj-tauri] setGlobalHotkeys: 未注册的窗口 label \"${label}\"(快捷键未设置)")
208
208
  }
209
209
  return this
210
210
  }
@@ -221,7 +221,7 @@ extend TauriApp {
221
221
  case Some(host) =>
222
222
  host.setTray(tray.toWire())
223
223
  case None =>
224
- eprintln("[cj-tauri] setTray: 默认窗口未注册(托盘未设置)")
224
+ logd("[cj-tauri] setTray: 默认窗口未注册(托盘未设置)")
225
225
  }
226
226
  return this
227
227
  }
@@ -280,7 +280,7 @@ extend TauriApp {
280
280
  case Some(host) =>
281
281
  host.setWindowVisible(visible)
282
282
  case None =>
283
- eprintln("[cj-tauri] setWindowVisible: 未注册的窗口 label \"${label}\"(窗口未改可见性)")
283
+ logd("[cj-tauri] setWindowVisible: 未注册的窗口 label \"${label}\"(窗口未改可见性)")
284
284
  }
285
285
  return this
286
286
  }
package/src/app_run.cj CHANGED
@@ -80,7 +80,7 @@ extend TauriApp {
80
80
  case Some(mode) =>
81
81
  // flush 显式给:CLI 用管道抓 stdout,不能指望进程退出时的缓冲冲刷
82
82
  print(renderPluginManifest(this.plugins, mode), flush: true)
83
- eprintln("[cj-tauri] 已导出插件清单(mode=${mode}):本轮未创建窗口")
83
+ logd("[cj-tauri] 已导出插件清单(mode=${mode}):本轮未创建窗口")
84
84
  return true
85
85
  case None => return false
86
86
  }
@@ -99,7 +99,7 @@ extend TauriApp {
99
99
  this.host.addInitScript(js)
100
100
  }
101
101
  if (this.pluginScripts.size > 0) {
102
- eprintln("[cj-tauri] 插件 JS 已注册为预执行脚本:${this.pluginScripts.size} 段")
102
+ logd("[cj-tauri] 插件 JS 已注册为预执行脚本:${this.pluginScripts.size} 段")
103
103
  }
104
104
  }
105
105
 
@@ -143,12 +143,12 @@ extend TauriApp {
143
143
  }
144
144
  this.pluginScripts = pluginInitScripts(this.plugins)
145
145
  if (this.plugins.size > 0) {
146
- eprintln("[cj-tauri] 已装配 ${this.plugins.size} 个插件:")
147
- eprintln(describePlugins(this.plugins))
146
+ logd("[cj-tauri] 已装配 ${this.plugins.size} 个插件:")
147
+ logd(describePlugins(this.plugins))
148
148
  let sets = describePermissionSets(this.plugins)
149
149
  if (sets.size > 0) {
150
- eprintln("[cj-tauri] 命名权限集(在 capabilities 的 permissions 里按集名引用):")
151
- eprintln(sets)
150
+ logd("[cj-tauri] 命名权限集(在 capabilities 的 permissions 里按集名引用):")
151
+ logd(sets)
152
152
  }
153
153
  warnUnauthorizedPlugins(this.plugins, this.capabilities)
154
154
  }
@@ -184,7 +184,7 @@ extend TauriApp {
184
184
  match (this.hostOf(label)) {
185
185
  case Some(h) => return h.hostCapabilities()
186
186
  case None =>
187
- eprintln("[cj-tauri] system:host: 未注册的窗口 label \"${label}\"(能力位按 0 返回)")
187
+ logd("[cj-tauri] system:host: 未注册的窗口 label \"${label}\"(能力位按 0 返回)")
188
188
  return 0
189
189
  }
190
190
  }
@@ -219,7 +219,7 @@ extend TauriApp {
219
219
  // shell 事件分发要在 load 之前装(菜单点击随时可能来,装晚了就漏)
220
220
  this.wireShellEvents(w.host, w.label)
221
221
  w.host.load(PageSource.Inline(w.html))
222
- eprintln("[cj-tauri] 附加窗口已启动:label=\"${w.label}\"")
222
+ logd("[cj-tauri] 附加窗口已启动:label=\"${w.label}\"")
223
223
  }
224
224
  }
225
225
 
package/src/capability.cj CHANGED
@@ -322,7 +322,7 @@ public class CapabilityRegistry {
322
322
  */
323
323
  public func addRuntimeScopeAllow(plugin: String, pattern: String): Bool {
324
324
  if (!isConcreteScopeValue(pattern)) {
325
- eprintln("[cj-tauri] runtime scope allow refused (${plugin}): pattern must be a concrete value, got '${pattern}'")
325
+ logd("[cj-tauri] runtime scope allow refused (${plugin}): pattern must be a concrete value, got '${pattern}'")
326
326
  return false
327
327
  }
328
328
  synchronized(this.scopeLock) {
@@ -402,8 +402,8 @@ public class CapabilityRegistry {
402
402
  public func warnUnknownPermissionSets(reg: CapabilityRegistry): Unit {
403
403
  for (name in reg.declaredPermissionSets()) {
404
404
  if (!reg.hasPermissionSet(name)) {
405
- eprintln("[cj-tauri] 未知的命名权限集 \"${name}\":没有插件提供它,这一条不生效")
406
- eprintln("[cj-tauri] 检查拼写;若它来自插件,确认提供它的插件已 .plugin(...) 装配")
405
+ logd("[cj-tauri] 未知的命名权限集 \"${name}\":没有插件提供它,这一条不生效")
406
+ logd("[cj-tauri] 检查拼写;若它来自插件,确认提供它的插件已 .plugin(...) 装配")
407
407
  }
408
408
  }
409
409
  }
@@ -22,7 +22,7 @@ func loadCapabilitiesFromDir(dir: String, reg: CapabilityRegistry): Int64 {
22
22
  try {
23
23
  entries = Directory.readFrom(dir)
24
24
  } catch (e: Exception) {
25
- eprintln("[cj-tauri] 读取 capability 目录失败 ${dir}: ${e}")
25
+ logd("[cj-tauri] 读取 capability 目录失败 ${dir}: ${e}")
26
26
  return loaded
27
27
  }
28
28
  for (info in entries) {
@@ -37,17 +37,17 @@ func loadCapabilitiesFromDir(dir: String, reg: CapabilityRegistry): Int64 {
37
37
  try {
38
38
  text = String.fromUtf8(File.readFrom(path))
39
39
  } catch (e: Exception) {
40
- eprintln("[cj-tauri] 读取 capability 失败 ${path}: ${e}")
40
+ logd("[cj-tauri] 读取 capability 失败 ${path}: ${e}")
41
41
  continue
42
42
  }
43
43
  try {
44
44
  if (reg.addFromJson(JsonValue.fromStr(text))) {
45
45
  loaded += 1
46
46
  } else {
47
- eprintln("[cj-tauri] capability 缺少 identifier,已跳过: ${path}")
47
+ logd("[cj-tauri] capability 缺少 identifier,已跳过: ${path}")
48
48
  }
49
49
  } catch (e: Exception) {
50
- eprintln("[cj-tauri] capability JSON 解析失败 ${path}: ${e}")
50
+ logd("[cj-tauri] capability JSON 解析失败 ${path}: ${e}")
51
51
  }
52
52
  }
53
53
  return loaded
@@ -63,14 +63,14 @@ func autoLoadCapabilities(reg: CapabilityRegistry): Unit {
63
63
  }
64
64
  let dir = "capabilities"
65
65
  if (!exists(dir)) {
66
- eprintln("[cj-tauri] 未挂载任何 capability,且没有 capabilities/ 目录")
67
- eprintln("[cj-tauri] 默认最小权限:未声明的命令与事件一律拒绝(见 docs/使用文档.md)")
66
+ logd("[cj-tauri] 未挂载任何 capability,且没有 capabilities/ 目录")
67
+ logd("[cj-tauri] 默认最小权限:未声明的命令与事件一律拒绝(见 docs/使用文档.md)")
68
68
  return
69
69
  }
70
70
  let n = loadCapabilitiesFromDir(dir, reg)
71
71
  if (n > 0) {
72
- eprintln("[cj-tauri] 已自动加载 capabilities/:${n} 个清单")
72
+ logd("[cj-tauri] 已自动加载 capabilities/:${n} 个清单")
73
73
  } else {
74
- eprintln("[cj-tauri] capabilities/ 目录下没有可用的 *.json 清单")
74
+ logd("[cj-tauri] capabilities/ 目录下没有可用的 *.json 清单")
75
75
  }
76
76
  }
@@ -16,12 +16,12 @@ package cjTauri
16
16
  */
17
17
  public func extractEmbeddedAssets(dir: String): Int64 {
18
18
  if (dir.isEmpty()) {
19
- eprintln("[cj-tauri] extractEmbeddedAssets: 目录为空")
19
+ logd("[cj-tauri] extractEmbeddedAssets: 目录为空")
20
20
  return -1
21
21
  }
22
22
  let n = extractAssetsBridge(dir)
23
23
  if (n < 0) {
24
- eprintln("[cj-tauri] 释放内嵌资源失败:${dir}")
24
+ logd("[cj-tauri] 释放内嵌资源失败:${dir}")
25
25
  }
26
26
  return n
27
27
  }
@@ -47,7 +47,7 @@ func extractAssetsBridge(dir: String): Int64 {
47
47
  @When[env == "ohos"]
48
48
  func extractAssetsBridge(dir: String): Int64 {
49
49
  let _ = dir
50
- eprintln("[cj-tauri] 本平台没有 C 桥,无内嵌资源可释放")
50
+ logd("[cj-tauri] 本平台没有 C 桥,无内嵌资源可释放")
51
51
  return 0
52
52
  }
53
53
 
@@ -68,12 +68,12 @@ func extractAssetsBridge(dir: String): Int64 {
68
68
  */
69
69
  public func preloadEmbeddedLibrary(path: String): Bool {
70
70
  if (path.isEmpty()) {
71
- eprintln("[cj-tauri] preloadEmbeddedLibrary: 路径为空")
71
+ logd("[cj-tauri] preloadEmbeddedLibrary: 路径为空")
72
72
  return false
73
73
  }
74
74
  let ok = preloadLibraryBridge(path)
75
75
  if (!ok) {
76
- eprintln("[cj-tauri] 预加载动态库失败:${path}")
76
+ logd("[cj-tauri] 预加载动态库失败:${path}")
77
77
  }
78
78
  return ok
79
79
  }
package/src/host.cj CHANGED
@@ -626,10 +626,10 @@ func dialogOnResult(host: CPointer<Unit>, path: CString): Unit {
626
626
  try {
627
627
  match (HostGlobals.hostRouteOf(host)) {
628
628
  case Some(r) => r.onDialog(path.toString())
629
- case None => eprintln("[cj-tauri] dialog callback: 未登记的宿主句柄(已丢弃)")
629
+ case None => logd("[cj-tauri] dialog callback: 未登记的宿主句柄(已丢弃)")
630
630
  }
631
631
  } catch (e: Exception) {
632
- eprintln("[cj-tauri] dialog callback error: ${e}")
632
+ logd("[cj-tauri] dialog callback error: ${e}")
633
633
  }
634
634
  }
635
635
 
@@ -644,10 +644,10 @@ func hostOnDestroy(host: CPointer<Unit>): Unit {
644
644
  try {
645
645
  match (HostGlobals.hostRouteOf(host)) {
646
646
  case Some(r) => r.onDestroy()
647
- case None => eprintln("[cj-tauri] destroy callback: 未登记的宿主句柄(已忽略)")
647
+ case None => logd("[cj-tauri] destroy callback: 未登记的宿主句柄(已忽略)")
648
648
  }
649
649
  } catch (e: Exception) {
650
- eprintln("[cj-tauri] destroy callback error: ${e}")
650
+ logd("[cj-tauri] destroy callback error: ${e}")
651
651
  }
652
652
  }
653
653
 
@@ -667,7 +667,7 @@ func shellOnEvent(host: CPointer<Unit>, json: CString): Unit {
667
667
  case None => () // 未登记(旧宿主已注销 / 非本进程句柄):静默,别在热路径上刷屏
668
668
  }
669
669
  } catch (e: Exception) {
670
- eprintln("[cj-tauri] shell callback error: ${e}")
670
+ logd("[cj-tauri] shell callback error: ${e}")
671
671
  }
672
672
  }
673
673
 
@@ -733,7 +733,7 @@ func hostHandleEquals(a: CPointer<Unit>, b: CPointer<Unit>): Bool {
733
733
  let _ = b
734
734
  if (!HOST_ROUTE_WARNED) {
735
735
  HOST_ROUTE_WARNED = true
736
- eprintln("[cj-tauri] host route by handle unavailable on this platform: injected host keeps its own callbacks")
736
+ logd("[cj-tauri] host route by handle unavailable on this platform: injected host keeps its own callbacks")
737
737
  }
738
738
  return false
739
739
  }