Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@2extliuweijian32
Copy link
Contributor

@2extliuweijian32 2extliuweijian32 commented Oct 10, 2025

这个 PR 做了什么? (简要描述所做更改)

这个 PR 是什么类型? (至少选择一个)

  • 错误修复 (Bugfix) issue: fix #
  • 新功能 (Feature)
  • 代码重构 (Refactor)
  • TypeScript 类型定义修改 (Types)
  • 文档修改 (Docs)
  • 代码风格更新 (Code style update)
  • 构建优化 (Chore)
  • 其他,请描述 (Other, please describe):

这个 PR 涉及以下平台:

  • 所有平台
  • Web 端(H5)
  • 移动端(React-Native)
  • 鸿蒙(Harmony)
  • 鸿蒙容器(Harmony Hybrid)
  • ASCF 元服务
  • 快应用(QuickApp)
  • 所有小程序
  • 微信小程序
  • 企业微信小程序
  • 京东小程序
  • 百度小程序
  • 支付宝小程序
  • 支付宝 IOT 小程序
  • 钉钉小程序
  • QQ 小程序
  • 飞书小程序
  • 快手小程序
  • 头条小程序

Summary by CodeRabbit

  • 新功能
    • 统一将部分导航能力 Promise 化并映射至目标平台,提供更一致的“跳转到/返回原子服务”等操作体验。
    • 构建流程收尾阶段自动生成 ascf.config.json 项目配置文件,减少手动步骤并提升可用性。

@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

Walkthrough

在 initNativeApi 末尾引入并调用 reflectApis,将特定 Taro API 映射到 has 能力;新增 reflect-apis.ts 实现映射与 promisify 处理。在 AscfApp 的 setupTransaction 收尾阶段,于 modifyWebpackConfig 之后新增一次 generateProjectConfig('ascf.config.json', 'ascf.config.json') 调用。

Changes

Cohort / File(s) Summary
API 反射与封装
packages/taro-platform-ascf/src/reflect-apis.ts, packages/taro-platform-ascf/src/apis.ts
新增 reflect-apis.ts:建立 API 映射(navigateToMiniProgram → navigateToAtomicService,navigateBackMiniProgram → navigateBackAtomicService),通过 processApis 仅做 promisify 和元数据转换;在 apis.ts 的 initNativeApi 末尾引入并调用 reflectApis(taro, has)。
构建流程补充
packages/taro-platform-ascf/src/program.ts
在 AscfApp 的 setupTransaction close 阶段,modifyWebpackConfig 之后增加 generateProjectConfig('ascf.config.json', 'ascf.config.json') 调用。

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as 应用
  participant Init as initNativeApi
  participant RA as reflectApis
  participant PA as processApis
  participant HAS as has(平台能力)

  App->>Init: 初始化平台原生 API
  Note over Init: 定义 getRenderer 等既有步骤
  Init->>RA: reflectApis(taro, has)
  RA->>PA: processApis({ needPromiseApis, isOnlyPromisify: true, transformMeta })
  PA->>HAS: 调用映射后的能力键(如 navigateToAtomicService)
  HAS-->>PA: 返回结果(Promise)
  PA-->>RA: 包装后的 Promise API
  RA-->>Init: 完成反射封装
Loading
sequenceDiagram
  autonumber
  participant Build as AscfApp 构建
  participant TX as setupTransaction(close)
  participant MW as modifyWebpackConfig
  participant GPC as generateProjectConfig

  Build->>TX: 收尾阶段
  TX->>MW: 调整 Webpack 配置
  MW-->>TX: 完成
  TX->>GPC: 生成 ascf.config.json → ascf.config.json
  GPC-->>TX: 完成
  TX-->>Build: 结束
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

小兔挥耳踏秋风,
新 API 映射轻轻拢。
Promise 装袋不漏缝,
has 一声即相通。
构建收尾添一笔,
配置落定月如弓。 🐇🌙

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed 标题采用了规范的 commit 风格并准确概括了主要改动,即为 Taro 到 ASCF 平台增加方法映射,与 PR 变更内容完全契合,简洁清晰且针对性强。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/taro-platform-ascf/src/reflect-apis.ts (1)

12-12: 建议添加类型标注

虽然代码逻辑正确,但建议为 needPromiseApis 添加显式类型标注以提高可维护性。

应用此差异添加类型标注:

-const needPromiseApis = new Set(reflectApisMap.keys())
+const needPromiseApis: Set<string> = new Set(reflectApisMap.keys())
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ff04a2 and a1ad014.

📒 Files selected for processing (3)
  • packages/taro-platform-ascf/src/apis.ts (2 hunks)
  • packages/taro-platform-ascf/src/program.ts (1 hunks)
  • packages/taro-platform-ascf/src/reflect-apis.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/taro-platform-ascf/src/apis.ts (1)
packages/taro-platform-ascf/src/reflect-apis.ts (1)
  • reflectApis (14-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
  • GitHub Check: Build Rust Binding / stable - x86_64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-pc-windows-msvc
  • GitHub Check: Build Rust WASM / stable - wasm32-wasi
🔇 Additional comments (5)
packages/taro-platform-ascf/src/apis.ts (2)

4-4: LGTM!

导入语句正确,符合文件结构。


35-35: LGTM!

initNativeApi 末尾调用 reflectApis 的位置恰当,可以在标准 API 初始化完成后进行反射映射。这遵循了现有的 API 处理模式。

packages/taro-platform-ascf/src/reflect-apis.ts (2)

7-10: LGTM!

API 映射正确且语义清晰,将小程序导航方法映射到鸿蒙原子化服务的对应方法。


14-25: 确认 ASCF 原子服务 API 并添加运行时校验

  • 手动核对 has.navigateToAtomicService 和 has.navigateBackAtomicService 在目标 ASCF 环境中可用,参数/返回值与 Taro.navigateToMiniProgram/navigateBackMiniProgram 保持兼容
  • 在 packages/taro-platform-ascf/src/reflect-apis.ts 的 transformMeta 中,调用前通过 if (typeof has[key] !== 'function') 输出或抛出友好错误,避免调用不存在的方法时报错
  • 可在注释或文档中添加官方 API 链接,便于后续维护和验证
packages/taro-platform-ascf/src/program.ts (1)

40-40: 保持 ascf.config.json 作为源/目标文件一致
与 taro-platform-swan 用法一致,无需改动。

@codecov
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.97%. Comparing base (1414e3d) to head (53ce7d8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #18448   +/-   ##
=======================================
  Coverage   55.97%   55.97%           
=======================================
  Files         416      416           
  Lines       21560    21560           
  Branches     5305     5251   -54     
=======================================
  Hits        12069    12069           
+ Misses       7879     7873    -6     
- Partials     1612     1618    +6     
Flag Coverage Δ
taro-cli 72.85% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.13% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Single-Dancer Single-Dancer added this to the 4.1.8 milestone Oct 10, 2025
This was referenced Oct 11, 2025
@tutuxxx tutuxxx self-requested a review October 16, 2025 03:01
@Single-Dancer Single-Dancer merged commit 7420fda into NervJS:main Oct 16, 2025
43 of 46 checks passed
This was referenced Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants