Skip to content

Conversation

bigbigDreamer
Copy link
Contributor

@bigbigDreamer bigbigDreamer commented Jun 30, 2025

这个 PR 做了什么? (简要描述所做更改)
When I use this.animate in function component, But the type is lost

Current.page.animate()

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

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

这个 PR 涉及以下平台:

  • 所有小程序
  • 微信小程序
  • 支付宝小程序
  • 百度小程序
  • 字节跳动小程序
  • QQ 轻应用
  • 京东小程序
  • 快应用平台(QuickApp)
  • Web 平台(H5)
  • 移动端(React-Native)
  • 鸿蒙(harmony)

Summary by CodeRabbit

  • 新功能
    • 新增对关键帧动画和滚动驱动动画的类型支持,为页面实例提供更丰富的动画能力。
    • 支持配置滚动驱动的动画参数,包括滚动源、方向、起止偏移量及时间范围。

Copy link

coderabbitai bot commented Jun 30, 2025

Walkthrough

本次更新在 Taro 运行时中引入了动画相关的类型定义,包括 KeyFrame 和 ScrollTimelineOption,并在 PageInstance 接口中新增了 animate 方法重载,用于支持基于关键帧和滚动驱动的动画能力。同时,将 animate 相关类型导出到接口索引文件中,便于统一管理和引用。

Changes

文件/分组 变更摘要
packages/taro-runtime/src/interface/animate.ts 新增 KeyFrame 和 ScrollTimelineOption 两个动画相关接口定义
packages/taro-runtime/src/dsl/instance.ts PageInstance 接口新增两个 animate 方法重载,支持动画相关参数
packages/taro-runtime/src/interface/index.ts 新增导出 animate 相关类型,便于统一引用

Sequence Diagram(s)

sequenceDiagram
  participant 调用方 as 调用方
  participant PageInstance as PageInstance

  调用方->>PageInstance: animate(selector, keyFrames, duration, callback)
  Note right of PageInstance: 执行动画,结束后回调

  调用方->>PageInstance: animate(selector, keyFrames, duration, scrollTimeline)
  Note right of PageInstance: 执行滚动驱动动画
Loading

Poem

🐰
动画新接口,轻盈又灵巧,
关键帧与滚动,页面随风跳。
类型齐上阵,导出更美妙,
代码小兔子,快乐把舞跳!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fbd954d and 25051d3.

📒 Files selected for processing (3)
  • packages/taro-runtime/src/dsl/instance.ts (2 hunks)
  • packages/taro-runtime/src/interface/animate.ts (1 hunks)
  • packages/taro-runtime/src/interface/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/taro-runtime/src/interface/index.ts
  • packages/taro-runtime/src/dsl/instance.ts
  • packages/taro-runtime/src/interface/animate.ts
⏰ 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). (2)
  • GitHub Check: Build Rust Binding / stable - aarch64-apple-darwin
  • GitHub Check: Build Rust Binding / stable - x86_64-unknown-linux-gnu
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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-runtime/src/interface/animate.ts (1)

6-6: 潜在的重复属性定义

KeyFrame 接口中同时定义了 ease(第6行)和 easing(第66行)属性,这可能会造成混淆。请确认是否需要两个属性,或者统一使用其中一个。

建议保留其中一个属性定义:

-  /** 动画缓动函数 */
-  ease?: string
   ... (其他属性)
   /** 动画缓动函数 */
   easing?: string

或者在注释中说明两者的区别和使用场景。

Also applies to: 66-66

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b37a5c and c5bcbde.

📒 Files selected for processing (3)
  • packages/taro-runtime/src/dsl/instance.ts (2 hunks)
  • packages/taro-runtime/src/interface/animate.ts (1 hunks)
  • packages/taro-runtime/src/interface/index.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
packages/taro-runtime/src/interface/index.ts (1)
Learnt from: ianzone
PR: NervJS/taro#17746
File: packages/taro-runtime/tsdown.config.ts:10-16
Timestamp: 2025-05-25T18:02:31.387Z
Learning: 在 taro-runtime 包的 tsdown 配置中,必须禁用 treeshake 来保留 dom-external/index.js 文件。
🧬 Code Graph Analysis (1)
packages/taro-runtime/src/dsl/instance.ts (1)
packages/taro-runtime/src/interface/animate.ts (2)
  • KeyFrame (2-68)
  • ScrollTimelineOption (71-82)
🔇 Additional comments (4)
packages/taro-runtime/src/interface/animate.ts (1)

2-82: 接口定义完整且符合预期

动画相关的类型定义很全面,KeyFrame 接口涵盖了 CSS 动画的各种属性,ScrollTimelineOption 接口为滚动驱动动画提供了合适的配置选项。中文注释清晰明了,有助于开发者理解每个属性的用途。

packages/taro-runtime/src/interface/index.ts (1)

1-1: 导出语句正确

新增的导出语句符合现有的模式,能够正确地将动画相关接口暴露给运行时的其他模块使用。

packages/taro-runtime/src/dsl/instance.ts (2)

4-4: 导入语句更新正确

正确导入了新定义的动画相关类型,遵循了现有的导入模式。


62-65: 动画方法重载定义完善

PageInstance 接口添加的两个 animate 方法重载很好地覆盖了不同的使用场景:

  • 第一个重载支持基于关键帧的动画,带有完成回调
  • 第二个重载支持滚动驱动的动画,使用 ScrollTimelineOption 配置

这些方法签名正确解决了 PR 目标中提到的 this.animate 缺失类型信息的问题,为微信小程序的动画功能提供了完整的 TypeScript 支持。

@Single-Dancer Single-Dancer added this to the 4.1.4 milestone Jun 30, 2025
@Single-Dancer Single-Dancer self-requested a review June 30, 2025 11:28
@Single-Dancer Single-Dancer force-pushed the fix/fix-animate-type-lose branch from c5bcbde to ad68ae4 Compare June 30, 2025 11:28
Copy link

codecov bot commented Jun 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.98%. Comparing base (7d235de) to head (25051d3).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17930    +/-   ##
========================================
  Coverage   54.98%   54.98%            
========================================
  Files         417      417            
  Lines       21693    21693            
  Branches     5357     5355     -2     
========================================
  Hits        11928    11928            
+ Misses       8243     8122   -121     
- Partials     1522     1643   +121     
Flag Coverage Δ
taro-cli 72.42% <ø> (ø)
taro-runtime 59.87% <ø> (ø)
taro-web 53.19% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 42 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.

This was referenced Jul 5, 2025
@Single-Dancer Single-Dancer force-pushed the fix/fix-animate-type-lose branch 2 times, most recently from a0abdcc to fbd954d Compare July 11, 2025 08:43
@Single-Dancer Single-Dancer force-pushed the fix/fix-animate-type-lose branch from fbd954d to 25051d3 Compare July 11, 2025 10:10
@Single-Dancer Single-Dancer merged commit 6d7c79f into NervJS:main Jul 11, 2025
24 checks passed
This was referenced Jul 12, 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.

2 participants