-
Notifications
You must be signed in to change notification settings - Fork 455
feat(canvas): add the renderer extension capability #718
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
Conversation
|
Warning Rate limit exceeded@hexqi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 40 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent changes encompass updates to several components and modules, enhancing functionality and control flow. Key modifications include conditional rendering in the Changes
Possibly related PRs
Suggested labels
Poem
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- packages/canvas/container/src/components/CanvasMenu.vue (2 hunks)
- packages/canvas/render/src/RenderMain.js (5 hunks)
- packages/canvas/render/src/runner.js (3 hunks)
- packages/common/component/ProgressBar.vue (1 hunks)
- packages/plugins/materials/src/composable/useMaterial.js (1 hunks)
Additional context used
Biome
packages/canvas/render/src/runner.js
[error] 131-133: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
Additional comments not posted (13)
packages/common/component/ProgressBar.vue (1)
24-25: LGTM!The code changes enhance the robustness of the component by introducing a safeguard to handle the case when
getMetaApireturnsnullorundefined. This prevents potential runtime errors that could occur ifgetEditBlockwere called when it is not defined.packages/canvas/render/src/runner.js (3)
112-112: LGTM!The changes to the
createfunction signature are approved:
- Making the function async allows using await and returning a promise, enabling asynchronous operations.
- Accepting a
configparameter allows passing configuration options to the function, such as lifecycle hooks.
113-116: LGTM!The addition of the
beforeAppCreatelifecycle hook is approved:
- It allows executing custom logic before the application is unmounted and recreated.
- Invoking it with
Vue,canvasWin, andapiprovides access to necessary dependencies and APIs.- Awaiting its completion ensures that any asynchronous operations are completed before proceeding.
130-132: LGTM!The addition of the
appCreatedlifecycle hook is approved:
- It allows executing custom logic after the application is created and mounted.
- Invoking it with the
Appinstance provides access to the application instance for customization.- Awaiting its completion ensures that any asynchronous operations are completed before proceeding.
The static analysis suggestion to use an optional chain is a false positive because the code already checks if
appCreatedis a function before invoking it.packages/canvas/container/src/components/CanvasMenu.vue (3)
30-30: LGTM!The conditional rendering of the
SaveNewBlockcomponent based on thehasBlockproperty is a good practice.
230-230: LGTM!The
hasBlockproperty is correctly defined usinggetMetaApi(META_SERVICE.Block)and used to conditionally render theSaveNewBlockcomponent.
37-37: Verify the usage of the imported entitiesgetMetaApiandMETA_SERVICE.The imported entities are not used in the provided code segment. Ensure that they are used correctly to determine the
hasBlockproperty.Run the following script to verify the usage:
Verification successful
Verified Usage of
getMetaApiandMETA_SERVICEThe imported entities
getMetaApiandMETA_SERVICEare correctly used in theCanvasMenu.vuefile to determine thehasBlockproperty. The usage aligns with the expected functionality. No issues found.
packages/canvas/container/src/components/CanvasMenu.vue:hasBlock: getMetaApi(META_SERVICE.Block)Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `getMetaApi` and `META_SERVICE` in the component. # Test: Search for the usage of `getMetaApi`. Expect: Usage in the `setup` function. rg --type vue $'getMetaApi' -g '!node_modules' # Test: Search for the usage of `META_SERVICE`. Expect: Usage in the `setup` function. rg --type vue $'META_SERVICE' -g '!node_modules'Length of output: 149
Script:
#!/bin/bash # Description: Verify the usage of `getMetaApi` and `META_SERVICE` in the component. # Test: Search for the usage of `getMetaApi` across all files. rg 'getMetaApi' -g '!node_modules' # Test: Search for the usage of `META_SERVICE` across all files. rg 'META_SERVICE' -g '!node_modules'Length of output: 5605
packages/plugins/materials/src/composable/useMaterial.js (1)
Line range hint
354-362: LGTM!The
addMaterialsfunction is well-implemented and follows a clear logic flow. It correctly handles the addition of components, snippets, and blocks to the respective state variables. The function ensures that there is at least one group inmaterialState.blocksto add the blocks to and properly handles the asynchronous nature ofregisterBlockusingPromise.allSettled.The code changes are approved.
packages/canvas/render/src/RenderMain.js (5)
18-18: LGTM!The code change is approved.
46-47: LGTM!The code change is approved. Using
parseDatainstead of dynamically evaluating the getter expression usingFunctionconstructor enhances the clarity and safety of the code.
346-380: LGTM!The code changes are approved. The new functions related to rendering provide flexibility in customizing the rendering behavior and enhance the component's extensibility. The changes are well-structured and follow the existing coding style and conventions.
413-413: LGTM!The code change is approved. Using the
getRendererfunction to get the rendering function is consistent with the introduction of the new rendering-related functions.
443-448: LGTM!The code changes are approved. The
apiobject is correctly updated to include the new rendering-related functions, making them available for use in other parts of the application.
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- packages/canvas/render/src/RenderMain.js (5 hunks)
- packages/canvas/render/src/runner.js (4 hunks)
- packages/plugins/materials/src/composable/useMaterial.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/plugins/materials/src/composable/useMaterial.js
Additional comments not posted (10)
packages/canvas/render/src/runner.js (4)
49-50: LGTM!The code changes are approved. The
createfunction is updated to be asynchronous and accept aconfigparameter containing lifecycle hooks, which enhances the flexibility and control over the application lifecycle.
51-53: LGTM!The code changes are approved. The
beforeAppCreatelifecycle hook is invoked with the necessary dependencies, allowing custom logic to be executed before the application is unmounted and recreated.
67-70: LGTM!The code changes are approved. The
appCreatedlifecycle hook is invoked with the newly createdAppinstance, allowing custom logic to be executed after the application is created and mounted.
90-90: LGTM!The code changes are approved. The
createfunction invocation is updated to pass theconfigparameter, ensuring that the lifecycle hooks are utilized during the rendering process.packages/canvas/render/src/RenderMain.js (6)
20-29: LGTM!The code changes are approved.
57-57: LGTM!The code changes are approved. Replacing the dynamic
Functionconstructor with a call toparseDataenhances code clarity and safety.
357-377: LGTM!The code changes are approved. The
defaultRendererfunction improves consistency in rendering behavior by ensuring the canvas includes a root node.
379-383: LGTM!The code changes are approved. The
getRendererandsetRendererfunctions enhance the component's extensibility by allowing users to customize rendering behavior dynamically.
385-391: LGTM!The code changes are approved. The
getRendererMountedandsetRendererMountedfunctions further enhance the component's extensibility by allowing users to set custom mounted callbacks.
424-424: LGTM!The code changes are approved. Modifying the
renderfunction to call the renderer returned bygetRenderer()aligns with the new functionality introduced in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/canvas/render/src/RenderMain.js (5 hunks)
- packages/canvas/render/src/runner.js (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/canvas/render/src/runner.js
Additional comments not posted (2)
packages/canvas/render/src/RenderMain.js (2)
57-57: Security Improvement: Use ofparseDatain Computed GettersReplacing dynamic function evaluation with
parseDataenhances security by avoidingeval-like behavior and improves code maintainability.
446-449: Export Section UpdatesThe export section has been appropriately updated to include new functions like
getRenderer,setRenderer, and others, making them accessible throughout the application.
yy-wow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
3a3029f to
b726107
Compare
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/canvas/render/src/RenderMain.js (5 hunks)
- packages/canvas/render/src/runner.js (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/canvas/render/src/runner.js
Additional comments not posted (4)
packages/canvas/render/src/RenderMain.js (4)
48-48: Refactor to enhance clarity and maintainability.The refactoring of computed getters to use
parseDatainstead of a dynamicFunctionconstructor is a significant improvement in terms of security and maintainability. This change avoids the risks associated witheval-like behavior.
348-368: Review the implementation ofdefaultRenderer.The
defaultRendererfunction is well-implemented, ensuring that the canvas rendering includes a root node. This alignment with code generation and previewing is crucial for consistency. The use of Vue'shfunction to create a virtual DOM is appropriate and follows Vue best practices.
437-440: Review the updated export structure.The export section now includes several new functions (
setNode,getRenderer,setRenderer,getRendererMounted, andsetRendererMounted). This change enhances the module's extensibility by making these functions available for use in other parts of the application.
407-407: Verify the rendering function invocation.The
rendermethod correctly invokes the renderer obtained fromgetRenderer. This ensures that the correct rendering logic is used based on the current configuration. It is important to verify that this method handles all edge cases and maintains the component's reactivity.
* feat: unibuy-render * fix:eslint报错
* feat: unibuy-render * fix:eslint报错 * fix:增加导出钩子函数
* feat: unibuy-render * fix:eslint报错 * fix:增加导出钩子函数 * fix:getters处理优化
b726107 to
1e19840
Compare
1e19840 to
f396562
Compare
特性 画布create增加lifeCycles配置,添加beforeAppCreate与appCreated钩子 画布添加getRender/setRender API --------- Co-authored-by: yaoyun8 <[email protected]>
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
特性
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit
Summary by CodeRabbit
New Features
SaveNewBlockcomponent based on block presence.addMaterials, for batch operations on materials.Bug Fixes
ProgressBarcomponent to prevent runtime errors when retrievinggetEditBlock.