Skip to content

Conversation

Liub1202
Copy link
Collaborator

@Liub1202 Liub1202 commented Jul 4, 2025

Summary by CodeRabbit

  • New Features
    • Expanded support for native components, including view containers and content components such as cover-image, scroll-view, swiper, view, icon, progress, rich-text, selection, and text.
    • Enhanced attribute options and event bindings for these components, enabling more detailed configuration and interaction.

Copy link

coderabbitai bot commented Jul 4, 2025

Walkthrough

This update expands the NativeComponentAttrs interface by introducing detailed type definitions for a wide range of native components. Each new component receives a dedicated interface specifying its attributes, event handlers, and properties, enhancing the type coverage for native UI elements without altering existing logic or interfaces.

Changes

File(s) Change Summary
packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts Added detailed attribute interfaces for multiple native components (e.g., cover-image, swiper, view, text, etc.) and extended NativeComponentAttrs to include them.

Poem

In fields of code where types now bloom,
New components join, dispelling gloom.
From swiper to view, each finds its place,
With attributes clear, and a tidy interface.
The rabbit hops, its whiskers twitch—
More types to nibble, what a rich pitch!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 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: 1

🧹 Nitpick comments (2)
packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts (2)

105-106: Implement missing event handler definitions

The comment indicates several event handlers should be defined (beforeenter, enter, afterenter, beforeleave, leave, afterleave, clickoverlay) but they're not implemented in the interface.

 interface MpxPageContainer {
   show?: boolean
   duration?: number
   'z-index'?: number
   overlay?: boolean
   position?: string
   round?: boolean
   'close-on-slide-down'?: boolean
   'overlay-style'?: string
   'custom-style'?: string
-  // bind:beforeenter bind:enter bind:enter bind:afterenter bind:beforeleave bind:leave bind:afterleave bind:clickoverlay
+  bindbeforeenter?: EventHandler
+  bindenter?: EventHandler
+  bindafterenter?: EventHandler
+  bindbeforeleave?: EventHandler
+  bindleave?: EventHandler
+  bindafterleave?: EventHandler
+  bindclickoverlay?: EventHandler
 }

199-199: Consider more specific typing for nodes property

The nodes property accepts both Array<string> and string, but rich text nodes typically have a more structured format.

Consider defining a more specific type:

+type RichTextNode = {
+  name: string
+  attrs?: Record<string, any>
+  children?: RichTextNode[]
+} | string

 interface MpxRichText {
-  nodes?: Array<string> | string
+  nodes?: RichTextNode[]
   space?: string
   'user-select'?: boolean
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b2023bb and ecedfe1.

📒 Files selected for processing (1)
  • packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts

[error] 61-62: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 62-63: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 96-96: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 97-98: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 98-99: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 100-100: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 136-137: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 137-138: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 138-138: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 139-139: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 140-140: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 141-141: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 142-142: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 145-145: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 146-147: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 147-148: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 166-167: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 167-167: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 170-171: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)


[error] 204-204: Don't use 'Function' as a type.

Prefer explicitly define the function shape. This type accepts any function-like value, which can be a common source of bugs.

(lint/complexity/noBannedTypes)

🔇 Additional comments (3)
packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts (3)

25-43: Well-structured component type additions

The additions to the NativeComponentAttrs interface provide comprehensive coverage for view containers and basic content components. The categorization with comments helps organize the component types logically.


178-178: Good use of required property

The type property is correctly marked as required for the Icon component, which enforces proper usage.


91-91: No action needed: htouchmove is intentional
The htouchmove property is paired with vtouchmove to represent horizontal and vertical touch‐move event handlers, respectively. This matches the surrounding API pattern in
packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts (lines 91–92). Please disregard the typo suggestion.

Likely an incorrect or invalid review comment.

Comment on lines +53 to +54
bindload?: Function
binderror?: Function
Copy link

@coderabbitai coderabbitai bot Jul 4, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Replace generic Function types with specific event handler signatures

The static analysis correctly identifies that using Function as a type is problematic as it accepts any function-like value, which can be a source of bugs. Event handlers should have specific signatures.

Consider defining specific event handler types. For example:

+// Event handler type definitions
+type EventHandler<T = any> = (event: T) => void
+type TouchEventHandler = (event: TouchEvent) => void
+type ScrollEventHandler = (event: ScrollEvent) => void

 interface MpxCoverImage {
   src?: string
   'referrer-policy'?: string
-  bindload?: Function
-  binderror?: Function
+  bindload?: EventHandler
+  binderror?: EventHandler
 }

Apply similar changes to all interfaces using Function types.

Also applies to: 89-92, 132-141, 160-162, 195-195, 206-206

🤖 Prompt for AI Agents
In packages/language-core/src/codegen/globalTypes/nativeComponentsTypes_refer.ts
at lines 53-54 and also at lines 89-92, 132-141, 160-162, 195, and 206, replace
the generic Function types used for event handlers with specific event handler
signatures that define the expected parameters and return types. Identify the
appropriate event object types for each handler and update the type annotations
accordingly to ensure type safety and clarity.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Liub1202 todo

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@wangshunnn wangshunnn merged commit ed58648 into main Jul 4, 2025
2 checks passed
@wangshunnn wangshunnn deleted the nativeComponentsTypesRefer branch July 4, 2025 06:29
@coderabbitai coderabbitai bot mentioned this pull request Jul 15, 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