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

refactor(materials): useResource spilt & Message notification for material loading life cycle #716

Open
wants to merge 3 commits into
base: refactor/develop
Choose a base branch
from

Conversation

wenmine
Copy link
Collaborator

@wenmine wenmine commented Jul 30, 2024

English | 简体中文

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Built its own designer, fully self-validated

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Background and solution

What is the current behavior?

可改造的点

  1. 有两个功能相对独立:1. 和全局appData相关 2. 初始化当前画布页面、区块,可以把两个独立的功能分开
  2. 利用数据流的通信,将appData获取后发送事件通知
  3. 由于useMaterial.initMaterial初始化物料模块只会在canvas ready时执行,将fetchResource调用useMaterial.initMaterial初始化物料模块提出到app.vue中,解耦useMaterial。
  4. 由于initPageorBlock 初始化画布页面模块只会在canvas ready时执行,将 fetchResource调用 initPageorBlock 抽取出来,同2一样,使用事件通信
  5. 将 handlePopStateEvent 抽取出来
  6. 看一下APP.vue是一个什么样的角色,如果app.vue里可以调用上面的几个元服务,那么2,3,4都可以直接写在app.vue中。

Issue Number: N/A

What is the new behavior?

因此将其拆分成2个元服务以及将部分功能进行提取

元服务

  • useAppData 作为存放全局数据(来源appData)
  • usePageBlockSchema 作为初始化当前画布页面或者区块

功能提取

  • 提取fetchResource里调用useMaterial.initMaterial初始化物料模块,解耦useMaterial。直接在design-core app.vue里调用。
  • 提取fetchResource里调用 initPageorBlock 初始化物料模块,直接在design-core app.vue里调用。

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new messaging function to enhance material data fetching processes.
    • Added a reactive state management solution for handling application resources.
    • Implemented internationalization support within a new application data composable.
  • Improvements

    • Refined resource fetching and initialization logic for better performance and clarity.
    • Enhanced naming conventions for better understanding of functions related to schema and resources.
    • Updated services to focus on page block schema capabilities and improved data management.
  • Bug Fixes

    • Improved the initialization process to ensure proper application state before resource operations.
  • Documentation

    • Updated documentation to reflect new function names and improved functionalities in the materials module.

Copy link
Contributor

coderabbitai bot commented Jul 30, 2024

Walkthrough

The recent updates across various files enhance resource management and initialization processes within the application. Key functions have been renamed and refactored for clarity, focusing on a schema-driven approach for handling materials and blocks. This restructuring streamlines data fetching and resource initialization, leading to a more coherent application state and improved maintainability.

Changes

Files & Summary
packages/design-core/src/App.vue
- Updated handlePopStateEvent to use usePageBlockSchema() instead of useResource().
- Made watch() callback asynchronous for better initialization flow.
packages/plugins/materials/src/composable/useMaterial.js
- Added publishMessage for enhanced messaging.
- Renamed fetchMaterial to initUserMaterial, and getMaterialsRes to fetchUserMaterialData.
- Updated generateNode to generateSchemaNode and refactored initMaterial.
packages/plugins/materials/src/composable/useResource.js
- Simplified fetchResource by removing the isInit parameter.
- Introduced initResource for initialization tasks.
packages/plugins/materials/src/meta/block/src/BlockList.vue
- Renamed generateNode to generateSchemaNode for improved block management.
packages/common/composable/useAppData.js
- Introduced a new composable for managing application data and internationalization with key functions like initAppData and fetchAppData.
packages/register/src/hooks.js
- Removed useResource hook; added useAppData and usePageBlockSchema hooks for better data handling.

Sequence Diagram(s)

sequenceDiagram
    participant App
    participant UseMaterial
    participant UseResource

    App->>UseResource: initResource()
    UseResource->>UseMaterial: initMaterialModule()
    UseMaterial->>UseResource: fetchUserMaterialData()
    UseResource-->>App: Resource Initialized
Loading

🐰 In a world where changes bloom,
New functions dance and dispel gloom.
Fetch and init, a seamless flow,
With schema nodes, watch our blocks grow!
Clarity reigns where chaos was,
Hooray for progress! Hip, hip, hurrah! 🌼


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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
Contributor

@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, codebase verification and nitpick comments (2)
packages/plugins/materials/src/composable/useResource拆解.md (2)

2-10: Suggestion: Provide more context or examples for the state object.

The state object is well-defined, but the documentation could benefit from additional context or examples to explain its usage.


1-41: Suggestion: Add more examples and context.

The document provides a good overview of the useResource composable, but it could benefit from additional examples and context to help users understand its usage better.

Tools
Markdownlint

19-19: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


25-25: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


30-30: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


33-33: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


36-36: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3b20b8b and 643945d.

Files selected for processing (6)
  • packages/design-core/src/App.vue (1 hunks)
  • packages/plugins/materials/src/composable/useMaterial.js (8 hunks)
  • packages/plugins/materials/src/composable/useResource.js (3 hunks)
  • packages/plugins/materials/src/composable/useResource拆解.md (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockList.vue (2 hunks)
  • packages/plugins/materials/src/meta/component/src/Main.vue (3 hunks)
Additional context used
Markdownlint
packages/plugins/materials/src/composable/useResource拆解.md

19-19: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


25-25: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


30-30: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


33-33: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


36-36: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)

Additional comments not posted (11)
packages/design-core/src/App.vue (1)

64-64: LGTM! But verify the usage of initResource in the codebase.

The code changes are approved.

However, ensure that all function calls to initResource are correct.

Verification successful

Verification Successful: initResource Usage

The function initResource is correctly defined and used in the codebase:

  • Defined in packages/plugins/materials/src/composable/useResource.js
  • Called in packages/design-core/src/App.vue

No issues found with the function usage.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `initResource` are correct.

# Test: Search for the function usage. Expect: Only occurrences of the new function.
rg --type js -A 5 $'initResource'

Length of output: 1228

packages/plugins/materials/src/composable/useResource.js (3)

Line range hint 125-158:
LGTM! The changes simplify the function's signature.

The simplification of the fetchResource function's signature improves clarity and maintainability.


160-167: LGTM! The new function separates concerns between fetching resources and initializing them.

The new initResource function aligns with the PR objectives by separating concerns between fetching resources and initializing them.


172-174: LGTM! The export statement reflects the addition of the new function.

The update to the export statement correctly reflects the addition of the new initResource function.

packages/plugins/materials/src/meta/component/src/Main.vue (2)

51-51: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to generateSchemaNode match the new signature.

Verification successful

LGTM! Function usage verified.

The function generateSchemaNode is used consistently with the new signature across the codebase. No issues found.

  • useMaterial.js
  • Main.vue
  • BlockList.vue
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `generateSchemaNode` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type javascript -A 5 $'generateSchemaNode'

Length of output: 81


Script:

#!/bin/bash
# Description: Verify all function calls to `generateSchemaNode` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg -A 5 'generateSchemaNode'

Length of output: 4269


12-12: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to generateSchemaNode match the new signature.

Verification successful

All instances of generateSchemaNode match the new signature.

The function generateSchemaNode is correctly used across the codebase with the new signature.

  • packages/plugins/materials/src/composable/useMaterial.js
  • packages/plugins/materials/src/meta/component/src/Main.vue
  • packages/plugins/materials/src/meta/block/src/BlockList.vue
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `generateSchemaNode` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type vue -A 5 $'generateSchemaNode'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify all function calls to `generateSchemaNode` match the new signature.

# Test: Search for the function usage across all file types. Expect: Only occurrences of the new signature.
rg -A 5 'generateSchemaNode'

Length of output: 4269

packages/plugins/materials/src/meta/block/src/BlockList.vue (1)

52-52: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to generateSchemaNode match the new signature.

Verification successful

Verified function usage of generateSchemaNode.

The function generateSchemaNode is used consistently with the expected parameters in the following instances:

  • :data="generateSchemaNode({ component: child.snippetName || child.component })"
  • const node = generateSchemaNode({ type: 'block', component: blockName })

These usages align with the expected function signature and parameters.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `generateSchemaNode` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type vue -A 5 $'generateSchemaNode'

Length of output: 67


Script:

#!/bin/bash
# Description: Verify all function calls to `generateSchemaNode` match the new signature.

# Find all .vue files and search for the function usage within those files.
fd --extension vue --exec rg 'generateSchemaNode' {}

Length of output: 383


Script:

#!/bin/bash
# Description: Extract lines and surrounding context where `generateSchemaNode` is used to verify correct usage.

# Find all .vue files and search for the function usage within those files, including surrounding context.
fd --extension vue --exec rg 'generateSchemaNode' -A 5 -B 5 {}

Length of output: 2176

packages/plugins/materials/src/composable/useMaterial.js (4)

40-44: New function publishMessage looks good.

The function is correctly implemented and follows best practices.


Line range hint 64-74:
New function generateSchemaNode looks good.

The function is correctly implemented and follows best practices.


263-267: New function fetchUserMaterialData looks good.

The function is correctly implemented and follows best practices.


340-349: New function initMaterialModule looks good.

The function is correctly implemented and follows best practices.

Comment on lines 18 to 26
#### 作用
1. 获取appData
2. 用appData初始化或者刷新state
3. 调用useMaterial.initMaterialModule初始化物料模块
4. 初始化当前画布显示的页面或者区块 initPageorBlock
5. 刷新i18n
#### 在哪里被调用
1. app.vue 在canvas ready后,作为资源初始化
2. BlockGroupPanel 在新增消费的区块时调用,用作刷新相关数据
Copy link
Contributor

Choose a reason for hiding this comment

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

Use fenced code blocks for better readability.

Indented code blocks are not the recommended style for markdown. Use fenced code blocks instead.

-    1. 获取appData
-    2. 用appData初始化或者刷新state
-    3. 调用useMaterial.initMaterialModule初始化物料模块
-    4. 初始化当前画布显示的页面或者区块 initPageorBlock
-    5. 刷新i18n
+```
+1. 获取appData
+2. 用appData初始化或者刷新state
+3. 调用useMaterial.initMaterialModule初始化物料模块
+4. 初始化当前画布显示的页面或者区块 initPageorBlock
+5. 刷新i18n
+```
Tools
Markdownlint

19-19: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


25-25: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)

Comment on lines 29 to 33
#### 作用
1. 能够在路由发生改变时init当前的页面和block
2. 刷新i18n
#### 在哪里被调用
1. app.vue 绑定pop state的事件监听
Copy link
Contributor

Choose a reason for hiding this comment

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

Use fenced code blocks for better readability.

Indented code blocks are not the recommended style for markdown. Use fenced code blocks instead.

-    1. 能够在路由发生改变时init当前的页面和block
-    2. 刷新i18n
+```
+1. 能够在路由发生改变时init当前的页面和block
+2. 刷新i18n
+```
Tools
Markdownlint

30-30: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)


33-33: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)

Comment on lines 36 to 40
1. 利用数据流的通信,将appData获取后发送事件通知
2. 将fetchResource调用useMaterial.initMaterialModule初始化物料模块提出,解耦useMaterial。
3. 将 fetchResource调用 initPageorBlock 抽取出来,同2一样,使用事件通信
4. 将 handlePopStateEvent 抽取出来
5. 看一下APP.vue是一个什么样的角色,如果app.vue里可以调用上面的几个元服务,那么2,3,4都可以直接写在app.vue中。
Copy link
Contributor

Choose a reason for hiding this comment

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

Use fenced code blocks for better readability.

Indented code blocks are not the recommended style for markdown. Use fenced code blocks instead.

-    1. 利用数据流的通信,将appData获取后发送事件通知
-    2. 将fetchResource调用useMaterial.initMaterialModule初始化物料模块提出,解耦useMaterial。
-    3. 将 fetchResource调用 initPageorBlock 抽取出来,同2一样,使用事件通信
-    4. 将 handlePopStateEvent 抽取出来
-    5. 看一下APP.vue是一个什么样的角色,如果app.vue里可以调用上面的几个元服务,那么2,3,4都可以直接写在app.vue中。
+```
+1. 利用数据流的通信,将appData获取后发送事件通知
+2. 将fetchResource调用useMaterial.initMaterialModule初始化物料模块提出,解耦useMaterial。
+3. 将 fetchResource调用 initPageorBlock 抽取出来,同2一样,使用事件通信
+4. 将 handlePopStateEvent 抽取出来
+5. 看一下APP.vue是一个什么样的角色,如果app.vue里可以调用上面的几个元服务,那么2,3,4都可以直接写在app.vue中。
+```
Tools
Markdownlint

36-36: Expected: fenced; Actual: indented
Code block style

(MD046, code-block-style)

Copy link
Contributor

@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

Outside diff range, codebase verification and nitpick comments (1)
packages/register/src/constants.js (1)

16-18: Add comments for new properties.

Consider adding comments to explain the purpose of the new properties AppData and PageBlockSchema in META_SERVICE for better maintainability.

  AppData: 'engine.service.appData', // Handles application data
  PageBlockSchema: 'engine.service.pageBlockSchema' // Manages page block schemas
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 643945d and 8dcd5c1.

Files ignored due to path filters (1)
  • mockServer/src/database/pages.db is excluded by !**/*.db
Files selected for processing (27)
  • designer-demo/registry.js (2 hunks)
  • packages/canvas/container/src/container.js (3 hunks)
  • packages/common/component/MetaListItems.vue (3 hunks)
  • packages/common/composable/index.js (2 hunks)
  • packages/common/composable/useAppData.js (1 hunks)
  • packages/common/js/canvas.js (1 hunks)
  • packages/common/js/completion.js (2 hunks)
  • packages/configurator/src/variable-configurator/VariableConfigurator.vue (2 hunks)
  • packages/design-core/index.js (2 hunks)
  • packages/design-core/src/App.vue (3 hunks)
  • packages/engine-cli/template/designer/registry.js (1 hunks)
  • packages/plugins/bridge/src/js/resource.js (4 hunks)
  • packages/plugins/data/src/DataSourceList.vue (2 hunks)
  • packages/plugins/data/src/Main.vue (2 hunks)
  • packages/plugins/datasource/src/DataSourceGlobalDataHandler.vue (3 hunks)
  • packages/plugins/datasource/src/DataSourceList.vue (2 hunks)
  • packages/plugins/datasource/src/js/datasource.js (2 hunks)
  • packages/plugins/i18n/src/composable/useTranslate.js (3 hunks)
  • packages/plugins/materials/index.js (2 hunks)
  • packages/plugins/materials/src/composable/index.js (1 hunks)
  • packages/plugins/materials/src/composable/useMaterial.js (8 hunks)
  • packages/plugins/materials/src/composable/usePageBlockSchema.js (3 hunks)
  • packages/plugins/materials/src/composable/useResource拆解.md (1 hunks)
  • packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue (2 hunks)
  • packages/register/src/constants.js (1 hunks)
  • packages/register/src/hooks.js (5 hunks)
  • packages/settings/props/src/components/modal/ModalContent.vue (3 hunks)
Additional context used
Markdownlint
packages/plugins/materials/src/composable/useResource拆解.md

43-43: null
Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


62-62: Expected: indented; Actual: fenced
Code block style

(MD046, code-block-style)


138-138: Expected: indented; Actual: fenced
Code block style

(MD046, code-block-style)

Additional comments not posted (62)
packages/plugins/materials/src/composable/index.js (3)

3-3: LGTM! New import statement is correct.

The import statement for usePageBlockSchema is necessary for the new PageBlockSchemaService.


5-13: LGTM! MaterialService definition is correct.

The MaterialService has been correctly defined with the new structure and references.


14-20: LGTM! PageBlockSchemaService definition is correct.

The PageBlockSchemaService has been correctly defined with the new structure and references.

packages/common/composable/index.js (2)

5-5: LGTM! New import statement is correct.

The import statement for useAppData is necessary for the new AppDataService.


27-34: LGTM! AppDataService definition is correct.

The AppDataService has been correctly defined with the new structure and references.

packages/common/js/canvas.js (1)

14-18: LGTM! Ensure the new isDemo source is correct.

The change to use useAppData().appDataState.isDemo is correct for the new structure.

However, verify that the new isDemo source is correctly implemented and used throughout the codebase.

Verification successful

Verified: The new isDemo source is correctly implemented and used throughout the codebase.

  • The isDemo variable is correctly sourced from useAppData().appDataState.isDemo.
  • The search results show consistent usage of isDemo within the relevant files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `isDemo` source.

# Test: Search for the usage of `isDemo`. Expect: Only occurrences of the new source.
rg --type js -A 5 $'isDemo'

Length of output: 2525

packages/plugins/materials/index.js (3)

36-36: Verify the export of PageBlockSchemaService.

Ensure that PageBlockSchemaService is correctly exported and used in the codebase, and that ResourceService is no longer required.

Verification successful

Verified the export of PageBlockSchemaService.

The PageBlockSchemaService is correctly exported and used in the codebase. Additionally, the ResourceService is no longer present, confirming its removal.

  • PageBlockSchemaService is found in:

    • packages/plugins/materials/index.js
    • packages/plugins/materials/src/composable/index.js
    • packages/design-core/index.js
  • ResourceService is not found in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the export of `PageBlockSchemaService` and ensure `ResourceService` is no longer used.

# Test: Search for the export of `PageBlockSchemaService`. Expect: Occurrences of `PageBlockSchemaService` in the codebase.
rg --type js 'PageBlockSchemaService'

# Test: Search for the export of `ResourceService`. Expect: No occurrences of `ResourceService` in the codebase.
rg --type js 'ResourceService'

Length of output: 634


15-15: Verify the usage of PageBlockSchemaService.

Ensure that PageBlockSchemaService is correctly used in the codebase and that ResourceService is no longer required.

Verification successful

Verification successful for PageBlockSchemaService usage.

  • PageBlockSchemaService is correctly used in the codebase.
  • ResourceService is no longer present in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `PageBlockSchemaService` and ensure `ResourceService` is no longer used.

# Test: Search for the usage of `PageBlockSchemaService`. Expect: Occurrences of `PageBlockSchemaService` in the codebase.
rg --type js 'PageBlockSchemaService'

# Test: Search for the usage of `ResourceService`. Expect: No occurrences of `ResourceService` in the codebase.
rg --type js 'ResourceService'

Length of output: 634


33-33: Verify the inclusion of PageBlockSchemaService in metas.

Ensure that PageBlockSchemaService is correctly used in the metas array and that ResourceService is no longer required.

Verification successful

Confirmed: PageBlockSchemaService is correctly included in metas and ResourceService is no longer used.

  • PageBlockSchemaService is present in packages/plugins/materials/index.js and other relevant files.
  • No occurrences of ResourceService were found in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the inclusion of `PageBlockSchemaService` in `metas` and ensure `ResourceService` is no longer used.

# Test: Search for the usage of `PageBlockSchemaService` in `metas`. Expect: Occurrences of `PageBlockSchemaService` in the codebase.
rg --type js 'PageBlockSchemaService'

# Test: Search for the usage of `ResourceService` in `metas`. Expect: No occurrences of `ResourceService` in the codebase.
rg --type js 'ResourceService'

Length of output: 634

designer-demo/registry.js (2)

56-56: Verify the inclusion of AppDataService in metas.

Ensure that AppDataService is correctly used in the metas array.

Verification successful

Verified the inclusion of AppDataService in metas.

The AppDataService is correctly included and used in the metas array in the relevant files.

  • designer-demo/registry.js
  • packages/engine-cli/template/designer/registry.js
  • packages/design-core/index.js
  • packages/common/composable/index.js
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the inclusion of `AppDataService` in `metas`.

# Test: Search for the usage of `AppDataService` in `metas`. Expect: Occurrences of `AppDataService` in the codebase.
rg --type js 'AppDataService'

Length of output: 509


Script:

#!/bin/bash
# Description: Verify the correct usage of `AppDataService` in the codebase.

# Search for the definition and usage of `AppDataService` in `designer-demo/registry.js`
rg -A 10 'AppDataService' designer-demo/registry.js

# Search for the definition and usage of `AppDataService` in `packages/engine-cli/template/designer/registry.js`
rg -A 10 'AppDataService' packages/engine-cli/template/designer/registry.js

# Search for the definition and usage of `AppDataService` in `packages/design-core/index.js`
rg -A 10 'AppDataService' packages/design-core/index.js

# Search for the definition and usage of `AppDataService` in `packages/common/composable/index.js`
rg -A 10 'AppDataService' packages/common/composable/index.js

Length of output: 1251


45-45: Verify the usage of AppDataService.

Ensure that AppDataService is correctly used in the codebase.

Verification successful

Verified the usage of AppDataService.

The AppDataService is correctly imported and used in the codebase, specifically in designer-demo/registry.js and packages/engine-cli/template/designer/registry.js.

  • designer-demo/registry.js: Used in a configuration object.
  • packages/engine-cli/template/designer/registry.js: Used in a configuration object.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `AppDataService`.

# Test: Search for the usage of `AppDataService`. Expect: Occurrences of `AppDataService` in the codebase.
rg --type js 'AppDataService'

Length of output: 509


Script:

#!/bin/bash
# Description: Retrieve the definition of `AppDataService` from `packages/common/composable/index.js`
ast-grep --lang javascript --pattern 'export const AppDataService = $_' --json

# Description: Verify the usage of `AppDataService` in `designer-demo/registry.js`
rg -A 5 'AppDataService' designer-demo/registry.js

# Description: Verify the usage of `AppDataService` in `packages/engine-cli/template/designer/registry.js`
rg -A 5 'AppDataService' packages/engine-cli/template/designer/registry.js

Length of output: 1353

packages/engine-cli/template/designer/registry.js (2)

55-55: Verify the inclusion of AppDataService in metas.

Ensure that AppDataService is correctly used in the metas array.


48-48: Verify the usage of AppDataService.

Ensure that AppDataService is correctly used in the codebase.

Verification successful

The usage of AppDataService is correctly implemented.

The AppDataService is properly imported and used in the metas array in both designer-demo/registry.js and packages/engine-cli/template/designer/registry.js.

  • designer-demo/registry.js
  • packages/engine-cli/template/designer/registry.js
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `AppDataService`.

# Test: Search for the usage of `AppDataService`. Expect: Occurrences of `AppDataService` in the codebase.
rg --type js 'AppDataService'

Length of output: 509


Script:

#!/bin/bash
# Description: Verify the usage of `AppDataService` in `designer-demo/registry.js` and `packages/engine-cli/template/designer/registry.js`.

# Test: Search for the usage of `AppDataService` in `designer-demo/registry.js`.
rg --type js 'AppDataService' designer-demo/registry.js -A 5 -B 5

# Test: Search for the usage of `AppDataService` in `packages/engine-cli/template/designer/registry.js`.
rg --type js 'AppDataService' packages/engine-cli/template/designer/registry.js -A 5 -B 5

Length of output: 907

packages/register/src/constants.js (1)

16-18: Verify the removal of Resource.

Ensure that the removal of the Resource property does not break any existing functionality. Verify its usage across the codebase.

Verification successful

Let's perform a more comprehensive search to ensure that engine.service.resource is not used anywhere in the codebase.


The removal of the Resource property has been successfully verified.

No occurrences of engine.service.resource were found across the codebase, indicating that its removal does not break any existing functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of `Resource` property from META_SERVICE.

# Test: Search for the usage of `engine.service.resource`. Expect: No occurrences.
rg --type js 'engine.service.resource'

Length of output: 38


Script:

#!/bin/bash
# Description: Verify the removal of `Resource` property from META_SERVICE.

# Test: Search for the usage of `engine.service.resource` in all file types.
rg 'engine.service.resource'

Length of output: 28

packages/design-core/src/App.vue (4)

66-66: Verify the initAppData function.

Ensure that the initAppData function correctly initializes the application data.

Verification successful

Verified the initAppData function.

The initAppData function correctly initializes the application data by fetching the app data, setting the app data state, and initializing internationalization.

  • fetchAppData() retrieves the application data.
  • setAppDataState(appData) updates the state with the fetched data.
  • initI18n() initializes the internationalization.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct initialization of application data using `initAppData`.

# Test: Search for the implementation of `initAppData`. Expect: Correct initialization of application data.
rg --type js 'initAppData'

Length of output: 396


Script:

#!/bin/bash
# Extract the implementation of the `initAppData` function from `packages/common/composable/useAppData.js`.

# Search for the `initAppData` function and include surrounding lines for context.
rg --type js -A 20 'const initAppData = async () => {' packages/common/composable/useAppData.js

Length of output: 227


Script:

#!/bin/bash
# Extract the implementation of the `initAppData` function from `packages/common/composable/useAppData.js`.

# Search for the `initAppData` function and include surrounding lines for context.
rg --type js -A 20 'const initAppData = async \(\) => \{' packages/common/composable/useAppData.js

Length of output: 407


68-69: Verify the initMaterial and initPageOrBlock functions.

Ensure that the initMaterial and initPageOrBlock functions correctly initialize the materials and page or block schemas.

Verification successful

The initMaterial and initPageOrBlock functions correctly initialize the materials and page or block schemas.

  • initMaterial initializes built-in materials, sets up a components map from appData, and initializes user materials.
  • initPageOrBlock initializes a page or block based on the provided pageTree, fetching data and setting up the layout and canvas accordingly.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct initialization of materials and page or block schemas using `initMaterial` and `initPageOrBlock`.

# Test: Search for the implementation of `initMaterial` and `initPageOrBlock`. Expect: Correct initialization of materials and page or block schemas.
rg --type js 'initMaterial|initPageOrBlock'

Length of output: 722


Script:

#!/bin/bash
# Extract the implementation of initMaterial function from useMaterial.js
ast-grep --lang javascript --pattern $'const initMaterial = async ($_) => {
  $$$
}' packages/plugins/materials/src/composable/useMaterial.js

# Extract the implementation of initPageOrBlock function from usePageBlockSchema.js
ast-grep --lang javascript --pattern $'const initPageOrBlock = async ($_) => {
  $$$
}' packages/plugins/materials/src/composable/usePageBlockSchema.js

Length of output: 3992


64-72: Verify the asynchronous initialization.

Ensure that the asynchronous initialization of appData, materials, and pageOrBlock is correct and does not introduce performance issues.


53-53: Verify the usage of usePageBlockSchema.

Ensure that the usePageBlockSchema function correctly handles the appDataState.pageTree in the handlePopStateEvent function.

packages/settings/props/src/components/modal/ModalContent.vue (3)

22-22: Verify the import statement.

Ensure that the useAppData function is correctly imported and used in place of useResource.

Verification successful

Verified the import statement.

The useAppData function is correctly imported from @opentiny/tiny-engine-meta-register and used consistently across the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct import of `useAppData`.

# Test: Search for the implementation of `useAppData`. Expect: Correct import and usage.
rg --type js 'useAppData'

Length of output: 6196


48-48: Verify the setup function.

Ensure that the setup function correctly uses appDataState in place of resState.


68-70: Verify the panelTitle computed property.

Ensure that the panelTitle computed property correctly uses appDataState to retrieve localized titles.

Verification successful

Verified the panelTitle computed property.

The panelTitle computed property correctly uses appDataState to retrieve localized titles. The logic implemented ensures that it first checks for an i18nKey in props.values.title and uses it to fetch the corresponding title from appDataState.langs. If the key does not exist, it falls back to using props.values.title.

  • panelTitle computed property in ModalContent.vue correctly uses appDataState.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of `appDataState` in the `panelTitle` computed property.

# Test: Search for the implementation of `appDataState`. Expect: Correct usage in the `panelTitle` computed property.
rg --type js 'appDataState'

Length of output: 5507


Script:

#!/bin/bash
# Description: Verify the correct usage of `appDataState` in the `panelTitle` computed property in ModalContent.vue.

# Search for the implementation of the `panelTitle` computed property in ModalContent.vue
rg 'computed:|panelTitle' -A 10 packages/settings/props/src/components/modal/ModalContent.vue

Length of output: 1129

packages/design-core/index.js (2)

18-18: Verify the integration of PageBlockSchemaService.

Ensure that PageBlockSchemaService is correctly implemented and relevant to the Materials module. Verify that the removal of ResourceService does not affect other parts of the application.

Verification successful

Verify the implementation of PageBlockSchemaService and check for ResourceService usage.

Ensure that PageBlockSchemaService is correctly implemented and relevant to the Materials module. Verify that the removal of ResourceService does not affect other parts of the application.


Integration of PageBlockSchemaService verified and ResourceService removal confirmed.

  • PageBlockSchemaService is correctly implemented and relevant to the Materials module.
  • The removal of ResourceService does not affect other parts of the application as it is not used elsewhere in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and implementation of PageBlockSchemaService

# Test: Search for the implementation and usage of PageBlockSchemaService. Expect: Correct implementation and usage.
rg --type js 'PageBlockSchemaService'

Length of output: 603


Script:

#!/bin/bash
# Description: Verify the implementation of PageBlockSchemaService and check for ResourceService usage

# Test 1: Display the implementation details of PageBlockSchemaService
rg --type js --context 10 'export const PageBlockSchemaService' packages/plugins/materials/src/composable/index.js

# Test 2: Search for the usage of ResourceService in the codebase
rg --type js 'ResourceService'

Length of output: 509


42-42: Verify the integration of AppDataService.

Ensure that AppDataService is correctly implemented and relevant to the module. Verify that its addition does not introduce any issues.

Verification successful

The integration of AppDataService is verified and appears to be correct.

  • The implementation in packages/common/composable/index.js is consistent with other services.
  • The usage in designer-demo/registry.js and packages/engine-cli/template/designer/registry.js is appropriate and consistent with other services.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage and implementation of AppDataService

# Test: Search for the implementation and usage of AppDataService. Expect: Correct implementation and usage.
rg --type js 'AppDataService'

Length of output: 509


Script:

#!/bin/bash
# Description: Inspect the implementation of AppDataService and its usage in relevant files

# Inspect the implementation of AppDataService in packages/common/composable/index.js
echo "Implementation of AppDataService in packages/common/composable/index.js:"
rg --type js --context 10 'export const AppDataService' packages/common/composable/index.js

# Inspect the usage of AppDataService in designer-demo/registry.js
echo "Usage of AppDataService in designer-demo/registry.js:"
rg --type js --context 10 'AppDataService' designer-demo/registry.js

# Inspect the usage of AppDataService in packages/engine-cli/template/designer/registry.js
echo "Usage of AppDataService in packages/engine-cli/template/designer/registry.js:"
rg --type js --context 10 'AppDataService' packages/engine-cli/template/designer/registry.js

Length of output: 2027

packages/common/composable/useAppData.js (4)

33-40: LGTM! Ensure proper error handling.

The function initializes i18n settings and handles errors by logging them. Consider enhancing error handling by providing user feedback or retry mechanisms.


42-66: LGTM! Ensure default values are handled correctly.

The function sets the state of app data and handles default values using DEFAULT_INTERCEPTOR. Ensure that all possible edge cases are covered.


68-72: LGTM! Ensure proper error handling for API calls.

The function fetches app data from an API. Ensure that the function handles API errors and edge cases appropriately.


74-80: LGTM! Ensure proper error handling and event notifications.

The function initializes app data and handles i18n settings. Ensure that errors are handled gracefully and consider implementing event notifications as mentioned in the TODO comment.

packages/plugins/materials/src/composable/usePageBlockSchema.js (3)

Line range hint 73-101:
LGTM! Ensure proper handling of edge cases.

The function initializes a page or block based on the provided page tree. Ensure that all possible edge cases are covered, such as missing or malformed data.


102-106: LGTM! Ensure proper handling of pop state events.

The function handles pop state events and initializes a page or block. Ensure that all possible edge cases are covered, such as missing or malformed data.


111-113: LGTM!

The export statement correctly includes handlePopStateEvent and initPageOrBlock.

packages/register/src/hooks.js (3)

21-23: LGTM! But verify the integration of new hooks.

The additions of useAppData and usePageBlockSchema to the HOOK_NAME object are straightforward.

However, ensure that these new hooks are correctly integrated and used within the application.

Verification successful

Hooks useAppData and usePageBlockSchema are well-integrated.

The new hooks have been imported and utilized across various modules, confirming their integration into the codebase.

  • useAppData is used in multiple files such as VariableConfigurator.vue, useTranslate.js, ModalContent.vue, and many more.
  • usePageBlockSchema is used in files like index.js within materials package and App.vue within design-core package.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the integration of new hooks `useAppData` and `usePageBlockSchema`.

# Test: Search for the usage of the new hooks. Expect: Occurrences of the new hooks.
rg --type js 'useAppData'
rg --type js 'usePageBlockSchema'

Length of output: 7051


77-78: LGTM! But verify the export of new hooks.

The additions of useAppData and usePageBlockSchema to the exports are straightforward.

However, ensure that these new hooks are correctly exported and used within the application.

Verification successful

Let's verify if the new hooks useAppData and usePageBlockSchema are being used within the application.


The new hooks useAppData and usePageBlockSchema are correctly exported and used within the application.

  • useAppData is used in multiple files such as VariableConfigurator.vue, useTranslate.js, resource.js, DataSourceList.vue, Main.vue, App.vue, BlockGroupPanel.vue, datasource.js, DataSourceGlobalDataHandler.vue, ModalContent.vue, completion.js, canvas.js, index.js, MetaListItems.vue, and container.js.
  • usePageBlockSchema is used in index.js and App.vue.

These usages confirm that the hooks are integrated and utilized correctly within the application.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the export of new hooks `useAppData` and `usePageBlockSchema`.

# Test: Search for the export of the new hooks. Expect: Occurrences of the new hooks.
rg --type js 'export const useAppData'
rg --type js 'export const usePageBlockSchema'

Length of output: 317


Script:

#!/bin/bash
# Description: Verify the usage of new hooks `useAppData` and `usePageBlockSchema`.

# Test: Search for the usage of the new hooks. Expect: Occurrences of the new hooks in the codebase.
rg --type js 'useAppData'
rg --type js 'usePageBlockSchema'

Length of output: 7051


46-47: LGTM! But verify the initialization of new hooks.

The additions of useAppData and usePageBlockSchema to the hooksState object are straightforward.

However, ensure that these new hooks are correctly initialized and used within the application.

Verification successful

The new hooks useAppData and usePageBlockSchema are correctly initialized and used within the application.

The search results indicate that these hooks are extensively utilized across multiple files, confirming their proper integration.

  • useAppData is used in various files such as ModalContent.vue, useTranslate.js, BlockGroupPanel.vue, and many others.
  • usePageBlockSchema is used in files like App.vue, index.js, and others.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the initialization of new hooks `useAppData` and `usePageBlockSchema`.

# Test: Search for the initialization of the new hooks. Expect: Occurrences of the new hooks.
rg --type js 'hooksState\[HOOK_NAME.useAppData\]'
rg --type js 'hooksState\[HOOK_NAME.usePageBlockSchema\]'

Length of output: 111


Script:

#!/bin/bash
# Description: Verify the initialization and usage of new hooks `useAppData` and `usePageBlockSchema`.

# Test: Search for all occurrences of the new hooks across the codebase.
rg --type js 'useAppData'
rg --type js 'usePageBlockSchema'

Length of output: 7051

packages/plugins/datasource/src/DataSourceGlobalDataHandler.vue (3)

52-54: LGTM! But verify the usage of the new state values.

The updates to the state object to use useAppData for dataHandlerValue, willFetchValue, and errorHandlerValue are straightforward.

However, ensure that these new state values are correctly used within the application.

Verification successful

The new state values are correctly used within the application.

The updates to use useAppData for dataHandlerValue, willFetchValue, and errorHandlerValue are properly reflected in the packages/plugins/datasource/src/DataSourceGlobalDataHandler.vue file.

  • dataHandlerValue is used in <data-handler-editor v-model="state.dataHandlerValue"></data-handler-editor>, in the dataHandler object, and assigned to useAppData().appDataState.dataHandler.
  • willFetchValue is used in <data-handler-editor v-model="state.willFetchValue"></data-handler-editor>, in the willFetch object, and assigned to useAppData().appDataState.willFetch.
  • errorHandlerValue is used in <data-handler-editor v-model="state.errorHandlerValue"></data-handler-editor>, in the errorHandler object, and assigned to useAppData().appDataState.errorHandler.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new state values from `useAppData`.

# Test: Search for the usage of the new state values. Expect: Occurrences of the new state values.
rg --type vue 'state.dataHandlerValue'
rg --type vue 'state.willFetchValue'
rg --type vue 'state.errorHandlerValue'

Length of output: 199


Script:

#!/bin/bash
# Description: Verify the usage of the new state values from `useAppData`.

# Test: Search for the usage of the new state values. Expect: Occurrences of the new state values.
rg 'state.dataHandlerValue' --glob '*.vue'
rg 'state.willFetchValue' --glob '*.vue'
rg 'state.errorHandlerValue' --glob '*.vue'

Length of output: 1626


25-25: LGTM! But verify the import of the new hook.

The addition of useAppData to the imports is straightforward.

However, ensure that this new hook is correctly imported and used within the application.

Verification successful

Let's correct the regex error and also search for the usage of useAppData within the codebase to ensure it is being used correctly.


Let's adjust the script to search within .vue files using a file extension pattern.


The import and usage of the useAppData hook have been verified successfully.

The useAppData hook is imported and used correctly in multiple .vue files, including DataSourceGlobalDataHandler.vue.

  • packages/plugins/datasource/src/DataSourceGlobalDataHandler.vue
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the import of the new hook `useAppData`.

# Test: Search for the import of the new hook. Expect: Occurrences of the new hook.
rg --type vue 'import { useAppData }'

Length of output: 152


Script:

#!/bin/bash
# Description: Verify the import of the new hook `useAppData`.

# Test: Search for the import of the new hook. Expect: Occurrences of the new hook.
rg --type vue 'import \{ useAppData \}'

# Test: Search for the usage of the new hook within the codebase. Expect: Occurrences of the new hook usage.
rg --type vue 'useAppData'

Length of output: 124


Script:

#!/bin/bash
# Description: Verify the import of the new hook `useAppData`.

# Test: Search for the import of the new hook. Expect: Occurrences of the new hook.
rg 'import \{ useAppData \}' --glob '*.vue'

# Test: Search for the usage of the new hook within the codebase. Expect: Occurrences of the new hook usage.
rg 'useAppData' --glob '*.vue'

Length of output: 3333


68-70: LGTM! But verify the setting of the new state values.

The updates to the saveGlobalDataHandle function to use useAppData for setting dataHandler, willFetch, and errorHandler are straightforward.

However, ensure that these new state values are correctly set within the application.

Verification successful

LGTM! The new state values are correctly set within the application.

The updates to the saveGlobalDataHandle function to use useAppData for setting dataHandler, willFetch, and errorHandler are confirmed to be correctly set and utilized within the codebase.

  • The state values dataHandler, willFetch, and errorHandler are present and used across various files, indicating proper integration.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the setting of the new state values from `useAppData`.

# Test: Search for the setting of the new state values. Expect: Occurrences of the new state values.
rg --type vue 'useAppData().appDataState.dataHandler'
rg --type vue 'useAppData().appDataState.willFetch'
rg --type vue 'useAppData().appDataState.errorHandler'

Length of output: 250


Script:

#!/bin/bash
# Description: Verify the setting of the new state values from `useAppData`.

# Test: Search for the setting of the new state values. Expect: Occurrences of the new state values.
rg 'useAppData().appDataState.dataHandler'
rg 'useAppData().appDataState.willFetch'
rg 'useAppData().appDataState.errorHandler'

Length of output: 133


Script:

#!/bin/bash
# Description: Verify the definitions and usages of the new state values.

# Test: Search for the definitions and usages of the new state values. Expect: Occurrences of the definitions and usages.
rg 'dataHandler'
rg 'willFetch'
rg 'errorHandler'

Length of output: 30919

packages/plugins/materials/src/composable/useResource拆解.md (3)

56-136: LGTM! But verify the accuracy of the documentation.

The explanation of the purpose and API of the new services useAppData and usePageBlockSchema seems clear.

However, ensure that the documentation is accurate and complete.

Verification successful

The documentation for useAppData and usePageBlockSchema is accurate and complete.

The detailed descriptions and API usages provided in the documentation align with the actual implementations and usages found in the codebase.

  • useAppData is defined and used across multiple files, including hooks.js, VariableConfigurator.vue, DataSourceList.vue, Main.vue, and others.
  • usePageBlockSchema is defined and used in files such as hooks.js, App.vue, and index.js.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the accuracy of the documentation related to the new services `useAppData` and `usePageBlockSchema`.

# Test: Search for the usage and definition of `useAppData` and `usePageBlockSchema`. Expect: Occurrences of the purpose and API.
rg --type md 'useAppData'
rg --type md 'usePageBlockSchema'

Length of output: 401


Script:

#!/bin/bash
# Description: Verify the accuracy of the documentation related to the new services `useAppData` and `usePageBlockSchema`.

# Test: Search for the implementation and usage of `useAppData` and `usePageBlockSchema` in the codebase.
rg 'useAppData'
rg 'usePageBlockSchema'

Length of output: 7373

Tools
Markdownlint

62-62: Expected: indented; Actual: fenced
Code block style

(MD046, code-block-style)


3-9: LGTM! But verify the accuracy of the documentation.

The explanation of the original purpose and API of useResource seems clear.

However, ensure that the documentation is accurate and complete.


34-40: LGTM! But verify the accuracy of the documentation.

The explanation of the refactoring points for useResource seems clear.

However, ensure that the documentation is accurate and complete.

Verification successful

The documentation is accurate and complete.

The refactoring points mentioned in useResource拆解.md are well-aligned with the actual implementation and usage of useResource and related functions in the codebase.

  • The initMaterial function is correctly described and used in App.vue.
  • The initPageorBlock function is accurately mentioned and used in App.vue.
  • The handlePopStateEvent function is correctly referenced and used in App.vue.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the accuracy of the documentation related to the refactoring points for `useResource`.

# Test: Search for the usage and definition of `useResource`. Expect: Occurrences of the refactoring points.
rg --type md 'useResource'

Length of output: 179


Script:

#!/bin/bash
# Description: Search for the implementation and usage of `useResource` in the codebase to verify the accuracy of the documentation.

# Search for the implementation of `useResource`.
rg 'useResource' -t js -A 10

# Search for the usage of `useResource` in the codebase.
rg 'useResource' -t js -A 10

Length of output: 57


Script:

#!/bin/bash
# Description: Search for the implementation and usage of `useResource` and related functions/components in the codebase to verify the accuracy of the documentation.

# Search for the implementation and usage of `useResource`.
rg 'useResource' -A 10

# Search for the implementation and usage of `initMaterial`.
rg 'initMaterial' -A 10

# Search for the implementation and usage of `initPageorBlock`.
rg 'initPageorBlock' -A 10

# Search for the implementation and usage of `handlePopStateEvent`.
rg 'handlePopStateEvent' -A 10

Length of output: 16548

packages/plugins/datasource/src/DataSourceList.vue (2)

35-35: Shift in data source from useResource to useAppData.

The import statement has been modified to use useAppData instead of useResource, indicating a change in how data is managed within the component.


78-78: Update in data assignment within onMounted lifecycle hook.

The onMounted lifecycle hook now assigns dataSourceList.value to the dataSource property of appDataState retrieved from useAppData, reflecting the new data management approach.

packages/common/component/MetaListItems.vue (2)

65-65: Shift in data source from useResource to useAppData.

The import statement has been modified to use useAppData instead of useResource, indicating a change in how data is managed within the component.


106-106: Update in data retrieval within the setup function.

The setup function now uses appDataState from useAppData instead of resState from useResource, affecting how language-specific text for internationalization is retrieved.

packages/plugins/datasource/src/js/datasource.js (1)

57-66: Update in application state management within getRequest function.

The getRequest function now uses appDataState from useAppData instead of resState from useResource, affecting how application state data handlers, error handlers, and fetch interceptors are retrieved.

packages/plugins/data/src/DataSourceList.vue (1)

70-70: Verify the usage of the new data source.

The change from useResource to useAppData seems appropriate, but ensure that appDataState.pageTree is correctly populated and used throughout the application.

Verification successful

Verified the usage of the new data source.

The change from useResource to useAppData is appropriate. The appDataState.pageTree is correctly populated and used throughout the application.

  • DataSourceList.vue: Lines 70-70
  • useAppData.js: Lines where appDataState.pageTree is set
  • App.vue: Lines where appDataState.pageTree is used
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `appDataState.pageTree` in the codebase.

# Test: Search for the usage of `appDataState.pageTree`. Expect: Correct usage throughout the application.
rg --type javascript -A 5 $'appDataState.pageTree'

Length of output: 84


Script:

#!/bin/bash
# Description: Verify the usage of `appDataState.pageTree` in the codebase.

# Test: Search for the usage of `appDataState.pageTree`. Expect: Correct usage throughout the application.
rg --type js -A 5 $'appDataState.pageTree'

Length of output: 1620

packages/plugins/bridge/src/js/resource.js (2)

183-184: Verify the usage of the new data source.

The change from useResource to useAppData seems appropriate, but ensure that appDataState[data.category] is correctly populated and used throughout the application.


226-227: Verify the usage of the new data source.

The change from useResource to useAppData seems appropriate, but ensure that appDataState[state.type] is correctly populated and used throughout the application.

Verification successful

Verify the usage of the new data source.

The change from useResource to useAppData seems appropriate, and appDataState[state.type] is correctly populated and used throughout the application.

  • packages/plugins/datasource/src/js/datasource.js
  • packages/plugins/i18n/src/composable/useTranslate.js
  • packages/common/composable/useAppData.js
  • Other relevant files
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `appDataState[state.type]` in the codebase.

# Test: Search for the usage of `appDataState[state.type]`. Expect: Correct usage throughout the application.
rg --type javascript -A 5 $'appDataState[state.type]'

Length of output: 89


Script:

#!/bin/bash
# Description: Verify the usage of `appDataState[state.type]` in the codebase.

# Test: Search for the usage of `appDataState[state.type]`. Expect: Correct usage throughout the application.
rg -A 5 'appDataState[state.type]'

Length of output: 10262

packages/plugins/i18n/src/composable/useTranslate.js (1)

120-123: Verify the usage of the new data source.

The change from resState to appDataState seems appropriate, but ensure that appDataState.langs.locales is correctly populated and used throughout the application.

Verification successful

Verified the usage of the new data source.

The change from resState to appDataState is appropriate and appDataState.langs.locales is correctly populated and used in packages/plugins/i18n/src/composable/useTranslate.js.

  • packages/plugins/i18n/src/composable/useTranslate.js: The usage of appDataState.langs.locales is consistent and correct.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `appDataState.langs.locales` in the codebase.

# Test: Search for the usage of `appDataState.langs.locales`. Expect: Correct usage throughout the application.
rg --type javascript -A 5 $'appDataState.langs.locales'

Length of output: 89


Script:

#!/bin/bash
# Description: Verify the usage of `appDataState.langs.locales` in the codebase.

# Test: Search for the usage of `appDataState.langs.locales`. Expect: Correct usage throughout the application.
rg --type js -A 5 $'appDataState.langs.locales'

Length of output: 46


Script:

#!/bin/bash
# Description: Verify the usage of `appDataState` in the codebase.

# Test: Search for the usage of `appDataState`. Expect: Correct usage throughout the application.
rg --type js -A 5 $'appDataState'

Length of output: 15017

packages/common/js/completion.js (2)

13-13: Update import statement to use useAppData.

The import statement has been updated to use useAppData instead of useResource. This change reflects a shift in the data handling approach.


74-74: Update data retrieval logic in getUserWords function.

The getUserWords function now uses useAppData().appDataState instead of useResource().resState. This change indicates a refactor in the state management strategy.

packages/plugins/materials/src/meta/block/src/BlockGroupPanel.vue (2)

27-27: Update import statement to use useAppData.

The import statement has been updated to use useAppData instead of useResource. This change reflects a shift in the data handling approach.


121-121: Update data initialization logic in addBlocks method.

The addBlocks method now calls useAppData().initAppData() instead of useResource().fetchResource({ isInit: false }). This change indicates a significant alteration in how the application initializes or refreshes its data when adding block groups.

packages/plugins/materials/src/composable/useMaterial.js (5)

40-44: Add publishMessage function.

The publishMessage function facilitates message publishing to specified topics, enhancing the module's messaging capabilities.


Line range hint 64-71: Rename and update generateNode function to generateSchemaNode.

The function has been renamed to generateSchemaNode and its documentation has been updated to clarify its role in generating schema nodes for components.


263-263: Rename and update getMaterialsRes function to fetchUserMaterialData.

The function has been renamed to fetchUserMaterialData and its documentation has been updated to clarify its purpose of fetching user-related material data.


269-275: Rename and update fetchMaterial function to initUserMaterial.

The function has been renamed to initUserMaterial and now publishes messages indicating the start and completion of data fetching, improving the tracking of asynchronous operations.


340-349: Refactor initMaterial function to initMaterialModule.

The function has been refactored to streamline its parameters, removing the isInit flag. The logic within this function has been adjusted to ensure it always initializes the component state and processes the appData components, followed by a call to initUserMaterial.

packages/plugins/data/src/Main.vue (1)

Line range hint 303-308:
Verify the correctness of the function call.

Ensure that the useAppData().appDataState.globalState provides the expected data structure and values.

Verification successful

The function call using useAppData().appDataState.globalState is correct. The data structure and values provided by useAppData().appDataState are consistent with the expected usage in the codebase.

  • The property globalState is used in various places, confirming its validity.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the data structure and values provided by `useAppData().appDataState.globalState`.

# Test: Search for the function usage. Expect: Correct data structure and values.
rg --type js -A 5 $'useAppData().appDataState.globalState'

Length of output: 59


Script:

#!/bin/bash
# Description: Verify the structure and usage of `useAppData`.

# Search for `useAppData` to understand its structure and usage.
rg --type js -A 10 'useAppData'

Length of output: 35506

packages/configurator/src/variable-configurator/VariableConfigurator.vue (2)

468-470: Verify the correctness of the function call.

Ensure that the useAppData().appDataState[item.id]?.forEach((res) => { ... }) provides the expected data structure and values.

Verification successful

The function call useAppData().appDataState[item.id]?.forEach((res) => { ... }) is correct.

The appDataState object is a reactive object defined in packages/common/composable/useAppData.js and contains various properties that support this usage.

  • packages/common/composable/useAppData.js
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the data structure and values provided by `useAppData().appDataState[item.id]`.

# Test: Search for the function usage. Expect: Correct data structure and values.
rg --type js -A 5 $'useAppData().appDataState[item.id]'

Length of output: 56


Script:

#!/bin/bash
# Description: Search for the definition and usage of `useAppData` in the codebase.

# Search for the definition of `useAppData`
rg --type js 'function useAppData' -A 10

# Search for the definition of `appDataState`
rg --type js 'appDataState' -A 10

Length of output: 23628


124-124: Verify the correctness of the import statement.

Ensure that useAppData is correctly imported and used within the component.

Verification successful

Let's correct the regex pattern and re-run the script to verify the import statement for useAppData.


Let's adjust the script to ensure proper escaping of single quotes and re-run it.


Let's simplify the search pattern to locate the useAppData import statement and its usage separately.


The import statement for useAppData is correct and its usage is verified.

  • The import statement for useAppData is present in packages/configurator/src/variable-configurator/VariableConfigurator.vue.
  • The usage of useAppData is also found within the same file, indicating it is correctly imported and utilized.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the import statement for `useAppData`.

# Test: Search for the import statement. Expect: Correct import and usage.
rg --type js -A 5 $'import { useAppData } from \'@opentiny/tiny-engine-meta-register\''

Length of output: 248


Script:

#!/bin/bash
# Description: Verify the correctness of the import statement for `useAppData`.

# Test: Search for the import statement. Expect: Correct import and usage.
rg --type js -A 5 "import { useAppData } from '@opentiny/tiny-engine-meta-register'"

Length of output: 248


Script:

#!/bin/bash
# Description: Verify the correctness of the import statement for `useAppData`.

# Test: Search for the import statement. Expect: Correct import and usage.
rg --type js -A 5 'import { useAppData } from "@opentiny/tiny-engine-meta-register"'

Length of output: 242


Script:

#!/bin/bash
# Description: Verify the correctness of the import statement for `useAppData`.

# Step 1: Search for the import statement.
rg --type js 'import { useAppData } from "@opentiny/tiny-engine-meta-register"'

# Step 2: Search for the usage of `useAppData`.
rg --type js 'useAppData'

Length of output: 6434

packages/canvas/container/src/container.js (2)

793-795: Verify the correctness of the function call.

Ensure that the useAppData().appDataState.globalState provides the expected data structure and values.

Verification successful

Verified the correctness of the function call.

The useAppData().appDataState.globalState is consistently used across the codebase, confirming that it provides the expected data structure and values.

  • packages/canvas/container/src/container.js: Lines 793-795
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the data structure and values provided by `useAppData().appDataState.globalState`.

# Test: Search for the function usage. Expect: Correct data structure and values.
rg --type js -A 5 $'useAppData().appDataState.globalState'

Length of output: 59


Script:

#!/bin/bash
# Description: Verify the definition and structure of `useAppData`.

# Search for the definition of `useAppData`
rg --type js -A 10 'function useAppData'

# Search for the usage of `useAppData`
rg --type js -A 5 'useAppData('

Length of output: 149


Script:

#!/bin/bash
# Description: Verify the definition and structure of `useAppData`.

# Search for the definition of `useAppData`
rg --type js -A 10 'function useAppData'

# Search for the usage of `useAppData`
rg --type js -A 5 'useAppData\('

Length of output: 12317


914-917: Verify the correctness of the function calls.

Ensure that the useAppData().appDataState.globalState, useAppData().appDataState.dataSource, and useAppData().appDataState.utils provide the expected data structure and values.

@wenmine wenmine changed the title refactor(materials): 1. 物料加载前后增加通信机制 2. 调整useResouce&useMaterial refactor(materials): useResource spilt & Message notification for material loading life cycle Jul 31, 2024
Copy link
Contributor

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8dcd5c1 and 6365814.

Files selected for processing (1)
  • packages/plugins/materials/src/composable/useMaterial.js (8 hunks)
Additional comments not posted (7)
packages/plugins/materials/src/composable/useMaterial.js (7)

17-17: LGTM! New imports are correctly added.

The new imports getMergeMeta, useNotify, useCanvas, useBlock, and useMessage are necessary for the refactored functions.


39-44: LGTM! New function publishMessage is correctly implemented.

The function publishMessage is correctly implemented to publish messages to a specified topic using useMessage.


Line range hint 60-69:
LGTM! Function generateNode renamed to generateSchemaNode with updated documentation.

The function name change is consistent, and the documentation is correctly updated to reflect the new name.


261-263: LGTM! Function getMaterialsRes renamed to fetchUserMaterialData with updated documentation.

The function name change is consistent, and the documentation is correctly updated to reflect the new name.


269-275: LGTM! New function initUserMaterial is correctly implemented.

The function initUserMaterial replaces the previous fetchMaterial function and correctly publishes messages indicating the start and completion of data fetching.


Line range hint 319-327:
LGTM! New function initBuiltinMaterial is correctly implemented.

The function initBuiltinMaterial is correctly implemented to initialize built-in materials.


349-356: LGTM! Function initMaterial is correctly refactored.

The function initMaterial is refactored to streamline its parameters and always initialize the component state, improving the initialization process.

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