Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(): support segues #4510

Draft
wants to merge 4 commits into
base: v3
Choose a base branch
from
Draft

feat(): support segues #4510

wants to merge 4 commits into from

Conversation

weareoutman
Copy link
Member

@weareoutman weareoutman commented Oct 11, 2024

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • New Features

    • Introduced a new event action "segue.go" for improved navigation handling.
    • Enhanced storyboard fulfillment with new functions for initializing segues and managing brick events.
  • Improvements

    • Updated rendering logic for better handling of brick identifiers and control nodes.
    • Streamlined error management and asynchronous operations in rendering functions.
  • Bug Fixes

    • Ensured child brick rendering respects the original data order.

Copy link

coderabbitai bot commented Oct 11, 2024

Walkthrough

The changes in this pull request involve modifications to the rendering logic within the Renderer.ts file, enhancements to the storyboard fulfillment process in fulfilStoryboard.ts, and the addition of a new event action in manifest.ts. Key updates include the introduction of an iid property in the renderBrick function, new functions for initializing segues, and the addition of interfaces for better type safety. Overall, the changes aim to improve the robustness and clarity of the rendering and event handling processes.

Changes

File Path Change Summary
packages/runtime/src/internal/Renderer.ts - Updated renderBrick and legacyRenderBrick functions to include iid in parameters.
- Enhanced error handling and control flow for rendering functions.
packages/runtime/src/internal/fulfilStoryboard.ts - Added new imports for brick and route types.
- Introduced initializeSeguesForRoutes, initializeSeguesForBricks, and replaceSegues functions.
- Added interfaces SegueConf and SegueRouteParam.
packages/types/src/manifest.ts - Added new action "segue.go" to BuiltinBrickEventHandler interface.

Poem

🐇 In the meadow where bricks align,
A new iid helps them shine.
Segues dance with routes so bright,
Rendering magic, pure delight!
With every hop, the changes flow,
A joyous leap, let’s watch them grow! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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: 3

🧹 Outside diff range and nitpick comments (1)
packages/runtime/src/internal/fulfilStoryboard.ts (1)

51-93: Consider adding unit tests for the new functions

The newly added functions initializeSeguesForRoutes and initializeSeguesForBricks are crucial for segue initialization. To ensure their correctness and prevent future regressions, it's advisable to add unit tests covering various scenarios.

Would you like assistance in generating unit tests for these functions?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between a0b2c1e and f8f187d.

📒 Files selected for processing (3)
  • packages/runtime/src/internal/Renderer.ts (1 hunks)
  • packages/runtime/src/internal/fulfilStoryboard.ts (2 hunks)
  • packages/types/src/manifest.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: CodeQL
packages/runtime/src/internal/fulfilStoryboard.ts

[failure] 118-118: Incomplete string escaping or encoding
This does not escape backslash characters in the input.

🪛 Biome
packages/runtime/src/internal/fulfilStoryboard.ts

[error] 105-105: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)


[error] 107-107: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (2)
packages/types/src/manifest.ts (1)

929-929: LGTM: New segue action added

The addition of the "segue.go" action to the BuiltinBrickEventHandler interface aligns with the PR objective of introducing support for segues. This change expands the event handling capabilities without affecting existing functionality.

Let's verify the implementation of this new action:

packages/runtime/src/internal/Renderer.ts (1)

353-353: Correctly passing 'iid' to control brick configuration

The addition of iid: brickConf.iid ensures that the iid property is included when rendering control nodes. This enhances the tracking and management of brick instances and aligns with the intended functionality.

packages/runtime/src/internal/fulfilStoryboard.ts Outdated Show resolved Hide resolved
Comment on lines 117 to 118
? `\${${param.value.replace(/^\s*<%[~=]?\s|\s%>\s*$/g, "")}}`
: String(param.value).replace(/`/g, "\\`")
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Escape backslashes to prevent potential string issues

The current implementation only escapes backticks in the string but does not escape backslashes. This could lead to incorrect string representations if param.value contains backslashes. Consider escaping backslashes as well.

Apply this diff to address the string escaping:

                     ? `\${${param.value.replace(/^\s*<%[~=]?\s|\s%>\s*$/g, "")}}`
-                    : String(param.value).replace(/`/g, "\\`")
+                    : String(param.value).replace(/\\/g, "\\\\").replace(/`/g, "\\`")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
? `\${${param.value.replace(/^\s*<%[~=]?\s|\s%>\s*$/g, "")}}`
: String(param.value).replace(/`/g, "\\`")
? `\${${param.value.replace(/^\s*<%[~=]?\s|\s%>\s*$/g, "")}}`
: String(param.value).replace(/\\/g, "\\\\").replace(/`/g, "\\`")
🧰 Tools
🪛 GitHub Check: CodeQL

[failure] 118-118: Incomplete string escaping or encoding
This does not escape backslash characters in the input.

@weareoutman weareoutman marked this pull request as draft October 11, 2024 11:59
weareoutman and others added 4 commits October 16, 2024 16:21
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copy link

codecov bot commented Oct 17, 2024

Codecov Report

Attention: Patch coverage is 81.53153% with 41 lines in your changes missing coverage. Please review.

Project coverage is 94.91%. Comparing base (62b92d3) to head (0a9df55).

Files with missing lines Patch % Lines
packages/runtime/src/internal/fulfilStoryboard.ts 13.04% 39 Missing and 1 partial ⚠️
packages/utils/src/storyboard/parser/parser.ts 99.10% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v3    #4510      +/-   ##
==========================================
- Coverage   95.21%   94.91%   -0.31%     
==========================================
  Files         205      207       +2     
  Lines        8860     9081     +221     
  Branches     1682     1729      +47     
==========================================
+ Hits         8436     8619     +183     
- Misses        319      355      +36     
- Partials      105      107       +2     
Files with missing lines Coverage Δ
packages/runtime/src/internal/Renderer.ts 94.23% <ø> (ø)
packages/utils/src/storyboard/parser/traverse.ts 100.00% <100.00%> (ø)
packages/utils/src/storyboard/parser/parser.ts 99.10% <99.10%> (ø)
packages/runtime/src/internal/fulfilStoryboard.ts 26.78% <13.04%> (-63.22%) ⬇️

... and 1 file with indirect coverage changes

Copy link

cypress bot commented Oct 17, 2024

next-core    Run #10664

Run Properties:  status check passed Passed #10664  •  git commit 691a914d03 ℹ️: Merge 0a9df5566ec532b918f19458412dc2a0d6ee4ed8 into 62b92d3ee62b983fdc59b60efbda...
Project next-core
Run status status check passed Passed #10664
Run duration 00m 26s
Commit git commit 691a914d03 ℹ️: Merge 0a9df5566ec532b918f19458412dc2a0d6ee4ed8 into 62b92d3ee62b983fdc59b60efbda...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 16

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.

1 participant