Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: merge lowcodeconfig with registry, migrate alias config to demo #551

Merged

Conversation

chilingling
Copy link
Member

@chilingling chilingling commented Jun 6, 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?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Enhanced theme support with dynamic theme imports based on configuration.
    • Added new configuration object for better customization and management.
  • Refactor

    • Replaced getGlobalConfig with getMergeMeta across multiple components and hooks for improved configuration management.
    • Simplified alias assignments in Vite configuration.
  • Chores

    • Removed outdated alias mappings and unnecessary imports.
    • Updated lifecycle configurations to be more modular and manageable.

Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Walkthrough

The changes primarily involve replacing the usage of getGlobalConfig with getMergeMeta('engine.config') across various files to access configuration data. This update enhances modularity and flexibility in configuration management. Additionally, new alias mappings were added to the Vite configuration, and theme support was introduced by dynamically importing theme files based on configuration settings.

Changes

Files/Paths Change Summary
designer-demo/registry.js Added a new config object with properties like id, theme, and material.
designer-demo/vite.config.js Added multiple alias mappings to enhance module resolution.
packages/canvas/src/components/render/runner.js Updated createRender function to access config.canvasDependencies instead of canvasOptions[dslMode].
packages/common/component/LifeCycles.vue Modified imports to include useModal, usePage, useNotify, useCanvas, and introduced getMergeMeta.
packages/controller/adapter.js Updated to use getMergeMeta instead of getGlobalConfig for retrieving configuration data.
packages/controller/src/hooks/useBlock.js Replaced getGlobalConfig() with getMergeMeta('engine.config') for retrieving dslMode.
packages/controller/src/hooks/useResource.js Replaced getGlobalConfig with getMergeMeta to retrieve material bundle URLs.
packages/controller/src/hooks/useSaveLocal.js Updated imports and replaced getGlobalConfig() with getMergeMeta('engine.config')?.platformId.
packages/controller/src/index.js Removed exports of getGlobalConfig and setGlobalConfig.
packages/design-core/config/lowcode.config.js Added comment to move lifecycle-related configurations into page management configurations.
packages/design-core/registry.js Added new properties to config object for theme support, material links, canvas dependencies, DSL mode, platform ID, and lifecycle configurations.
packages/design-core/src/App.vue Imported getMergeMeta and used it to dynamically import a theme file based on configuration.
packages/design-core/src/init.js Removed setGlobalConfig and globalConfig imports, replaced with setting window.TinyGlobalConfig to newRegistry.config.
packages/design-core/src/preview/src/App.vue Imported getMergeMeta and used it to dynamically import a theme file based on configuration.
packages/design-core/src/theme/dark.js New file importing the tiny-engine-theme-dark module.
packages/design-core/src/theme/light.js New file importing the tiny-engine-theme-light module.
packages/design-core/vite.config.js Removed multiple alias declarations for various paths, simplifying alias assignment logic.
packages/plugins/block/src/BlockSetting.vue Replaced getGlobalConfig() with getMergeMeta('engine.config').
packages/plugins/bridge/src/BridgeSetting.vue Replaced getGlobalConfig()?.dslMode with getMergeMeta('engine.config')?.dslMode.
packages/plugins/datasource/src/DataSourceTemplate.vue Replaced getGlobalConfig with getMergeMeta for retrieving platform configuration data.
packages/plugins/i18n/src/Main.vue Modified imports to remove getGlobalConfig and add getMergeMeta.
packages/plugins/materials/src/block/http.js Replaced getGlobalConfig()?.dslMode with getMergeMeta('engine.config')?.dslMode.
packages/plugins/page/src/PageHistory.vue Replaced getGlobalConfig with getMergeMeta for retrieving dslMode and platformId values.
packages/settings/props/src/components/groups/LifeCycle.vue Replaced getGlobalConfig with getMergeMeta for retrieving lifecycle configuration data.
packages/toolbars/generate-vue/src/Main.vue Refactored imports and updated how global configuration data is accessed.
packages/toolbars/logo/src/Main.vue Modified imports to remove getGlobalConfig and add getMergeMeta, updated menus definition to use getMergeMeta('engine.config')?.dslMode.
packages/toolbars/preview/src/Main.vue Replaced getGlobalConfig with getMergeMeta('engine.config') for retrieving specific configuration parameters.

Sequence Diagram(s) (Beta)

Poem

In the land of code so bright,
Configs dance from night to light,
From getGlobalConfig we now depart,
getMergeMeta plays its part.
Themes and paths align with grace,
A modular future we embrace.
🎨✨🚀


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 Configration 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.

@chilingling chilingling force-pushed the feat/designCoreConfigExtract branch from aead370 to 37ebe14 Compare June 6, 2024 12:44
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: 4

Outside diff range and nitpick comments (3)
packages/plugins/materials/src/block/http.js (1)

Line range hint 58-61: Optimize the method chain by using .flatMap() instead of .map().flat().

- const blocks = blockGroups
-   .map((group) => group.blocks.map((block) => ({ ...block, groupId: group.id, groupName: group.name })))
-   .flat()
-   .filter(({ framework, id }) => {
-     if (dslMode === framework && !blockIdSet.has(id)) {
-       blockIdSet.add(id)
-       return true
-     }
-     return false
-   })
+ const blocks = blockGroups.flatMap((group) =>
+   group.blocks
+     .filter(({ framework, id }) => dslMode === framework && !blockIdSet.has(id))
+     .map((block) => {
+       blockIdSet.add(id);
+       return { ...block, groupId: group.id, groupName: group.name };
+     })
+ );
packages/canvas/src/components/render/runner.js (1)

Line range hint 125-125: Consider using optional chaining to avoid potential runtime errors when accessing properties on undefined objects.

- const { styles: thirdStyles = [], scripts: thirdScripts = [] } = window.thirdPartyDeps || {}
+ const { styles: thirdStyles = [], scripts: thirdScripts = [] } = window.thirdPartyDeps ?? {}
packages/controller/src/hooks/useResource.js (1)

Line range hint 432-433: Optimize the use of spread syntax in accumulators.

Using spread syntax in .reduce accumulators can lead to performance issues due to O(n^2) complexity. Consider using .push or .splice instead to improve performance.

- return { ...componentsMap, [component.componentName]: component }
+ componentsMap[component.componentName] = component;
+ return componentsMap;
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1724bbc and 37ebe14.

Files selected for processing (27)
  • designer-demo/registry.js (1 hunks)
  • designer-demo/vite.config.js (1 hunks)
  • packages/canvas/src/components/render/runner.js (1 hunks)
  • packages/common/component/LifeCycles.vue (2 hunks)
  • packages/controller/adapter.js (2 hunks)
  • packages/controller/src/hooks/useBlock.js (3 hunks)
  • packages/controller/src/hooks/useResource.js (2 hunks)
  • packages/controller/src/hooks/useSaveLocal.js (3 hunks)
  • packages/controller/src/index.js (2 hunks)
  • packages/design-core/config/lowcode.config.js (1 hunks)
  • packages/design-core/registry.js (1 hunks)
  • packages/design-core/src/App.vue (2 hunks)
  • packages/design-core/src/init.js (2 hunks)
  • packages/design-core/src/preview/src/App.vue (1 hunks)
  • packages/design-core/src/theme/dark.js (1 hunks)
  • packages/design-core/src/theme/light.js (1 hunks)
  • packages/design-core/vite.config.js (4 hunks)
  • packages/plugins/block/src/BlockSetting.vue (3 hunks)
  • packages/plugins/bridge/src/BridgeSetting.vue (2 hunks)
  • packages/plugins/datasource/src/DataSourceTemplate.vue (1 hunks)
  • packages/plugins/i18n/src/Main.vue (2 hunks)
  • packages/plugins/materials/src/block/http.js (4 hunks)
  • packages/plugins/page/src/PageHistory.vue (2 hunks)
  • packages/settings/props/src/components/groups/LifeCycle.vue (3 hunks)
  • packages/toolbars/generate-vue/src/Main.vue (2 hunks)
  • packages/toolbars/logo/src/Main.vue (2 hunks)
  • packages/toolbars/preview/src/Main.vue (2 hunks)
Files not reviewed due to errors (1)
  • packages/toolbars/logo/src/Main.vue (no review received)
Files skipped from review due to trivial changes (4)
  • packages/controller/src/index.js
  • packages/design-core/src/theme/dark.js
  • packages/design-core/src/theme/light.js
  • packages/design-core/vite.config.js
Additional context used
Biome
packages/plugins/materials/src/block/http.js

[error] 58-61: The call chain .map().flat() can be replaced with a single .flatMap() call. (lint/complexity/useFlatMap)

Safe fix: Replace the chain with .flatMap().

packages/canvas/src/components/render/runner.js

[error] 125-125: Change to an optional chain. (lint/complexity/useOptionalChain)

Unsafe fix: Change to an optional chain.

packages/controller/src/hooks/useResource.js

[error] 432-433: Avoid the use of spread (...) syntax on accumulators. (lint/performance/noAccumulatingSpread)

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

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

7-7: The import of getMergeMeta is correctly placed and follows standard practices.

packages/controller/adapter.js (2)

14-14: The import of getMergeMeta is correctly placed and follows standard practices.


58-58: The usage of getMergeMeta to determine the editor's theme is implemented correctly and safely uses optional chaining.

packages/toolbars/preview/src/Main.vue (3)

20-21: The import statements for hooks and getMergeMeta are correctly placed and follow standard practices.


48-48: The usage of getMergeMeta to fetch the framework configuration is implemented correctly within the setup function.


49-49: The usage of getMergeMeta to fetch the platform configuration is implemented correctly within the setup function.

packages/plugins/page/src/PageHistory.vue (1)

9-10: LGTM! Ensure that getMergeMeta correctly fetches the required configuration properties.

Also applies to: 60-61

Verification successful

The search results indicate that getMergeMeta is widely used across various Vue files in the repository, including packages/plugins/page/src/PageHistory.vue. The function is used to fetch configuration properties such as dslMode and platformId, which aligns with the intended purpose of centralizing configuration management.

  • packages/plugins/page/src/PageHistory.vue: The function is used to fetch dslMode and platformId from engine.config.

Given this context, it appears that getMergeMeta is correctly implemented and used consistently across the codebase to fetch configuration properties.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `getMergeMeta` is correctly implemented and returns expected configuration properties.

# Test: Search for the function usage and ensure it returns the expected properties.
rg --type vue $'getMergeMeta'

Length of output: 56



Script:

#!/bin/bash
# Description: Verify that `getMergeMeta` is correctly implemented and returns expected configuration properties.

# Test: Search for the function usage and ensure it returns the expected properties.
rg 'getMergeMeta' --glob '**/*.vue'

Length of output: 3701

designer-demo/registry.js (1)

14-18: LGTM! The new config object centralizes configuration settings effectively.

Verification successful

To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible from other parts of the system, we need to refine our search to instances where config is accessed as a property of registry or in a similar context.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to expand our search to include different contexts where the config object might be used.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to check if it is accessed within the init functions in designer-demo/src/main.js and packages/design-core/src/init.js.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to confirm that newRegistry in packages/design-core/src/init.js refers to the registry object from designer-demo/registry.js.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to confirm that registry in designer-demo/src/main.js refers to the registry object from designer-demo/registry.js.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to confirm that registry in ./defineEntry.js is exported from designer-demo/registry.js.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to locate the correct file that exports registry.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to confirm which defineEntry.js file is imported in designer-demo/src/main.js.


To ensure the new config object in designer-demo/registry.js is correctly integrated and accessible, we need to confirm the export of registry in designer-demo/src/defineEntry.js.


The registry object is correctly exported from designer-demo/src/defineEntry.js and imported into designer-demo/src/main.js. This confirms that the registry object, which includes the new config object, is integrated and accessible from other parts of the system.

  • designer-demo/src/defineEntry.js: export { registry }
  • designer-demo/src/main.js: import { registry } from './defineEntry.js'
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the new `config` object is correctly integrated and accessible from other parts of the system.

# Test: Search for the usage of `config` properties across the project.
rg --type js $'config'

Length of output: 61417



Script:

#!/bin/bash
# Description: Verify that the new `config` object in `designer-demo/registry.js` is correctly integrated and accessible from other parts of the system.

# Test: Search for the usage of `registry.config` across the project.
rg --type js 'registry.config'

Length of output: 30



Script:

#!/bin/bash
# Description: Verify that the new `config` object in `designer-demo/registry.js` is correctly integrated and accessible from other parts of the system.

# Test: Search for the usage of `config` within the `registry` object or similar contexts.
rg --type js 'registry.*config'

Length of output: 245



Script:

#!/bin/bash
# Description: Verify that the new `config` object in `designer-demo/registry.js` is correctly integrated and accessible from other parts of the system.

# Test: Search for the usage of `config` within the `init` functions in `designer-demo/src/main.js` and `packages/design-core/src/init.js`.
rg --type js 'config' designer-demo/src/main.js packages/design-core/src/init.js

Length of output: 529



Script:

#!/bin/bash
# Description: Verify that `newRegistry` in `packages/design-core/src/init.js` refers to the `registry` object from `designer-demo/registry.js`.

# Test: Search for the initialization of `newRegistry` in `packages/design-core/src/init.js`.
rg --type js 'newRegistry' packages/design-core/src/init.js

Length of output: 208



Script:

#!/bin/bash
# Description: Verify that `registry` in `designer-demo/src/main.js` refers to the `registry` object from `designer-demo/registry.js`.

# Test: Search for the initialization of `registry` in `designer-demo/src/main.js`.
rg --type js 'registry' designer-demo/src/main.js

Length of output: 127



Script:

#!/bin/bash
# Description: Verify that `registry` in `./defineEntry.js` refers to the `registry` object from `designer-demo/registry.js`.

# Test: Search for the export of `registry` in `./defineEntry.js`.
rg --type js 'registry' designer-demo/defineEntry.js

Length of output: 121



Script:

#!/bin/bash
# Description: Locate the correct file that exports `registry`.

# Test: Search for files named `defineEntry.js` or similar in the project.
fd defineEntry.js

Length of output: 100



Script:

#!/bin/bash
# Description: Confirm which `defineEntry.js` file is imported in `designer-demo/src/main.js`.

# Test: Search for the import statement in `designer-demo/src/main.js`.
rg --type js 'defineEntry' designer-demo/src/main.js

Length of output: 194



Script:

#!/bin/bash
# Description: Confirm the export of `registry` in `designer-demo/src/defineEntry.js`.

# Test: Search for the export statement in `designer-demo/src/defineEntry.js`.
rg --type js 'export' designer-demo/src/defineEntry.js

Length of output: 74

packages/design-core/src/init.js (1)

49-50: LGTM! Ensure that sensitive configuration data is not exposed globally.

packages/controller/src/hooks/useSaveLocal.js (1)

14-14: LGTM! Ensure that getMergeMeta correctly fetches the platformId.

Also applies to: 30-30, 55-55

Verification successful

The metasHashMap is populated within the generateRegistry function, which processes entries in a registry object. The id and value pairs are added to metasHashMap if the id exists and the key is not metaData. This ensures that getMergeMeta can retrieve the platformId from metasHashMap when it is populated correctly.

The implementation appears to be correct and should function as intended.

  • packages/entry/src/common.js: The generateRegistry function populates metasHashMap with the necessary configuration data, including platformId.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `getMergeMeta` is correctly implemented and returns the expected `platformId`.

# Test: Search for the function usage and ensure it returns the expected property.
rg --type js $'getMergeMeta'

Length of output: 5356



Script:

#!/bin/bash
# Description: Extract the implementation of `getMergeMeta` from `packages/entry/src/common.js`.

# Extract the function implementation
ast-grep --lang javascript --pattern $'export const getMergeMeta = $_ => $_' packages/entry/src/common.js

Length of output: 271



Script:

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

# Search for `metasHashMap` definition and initialization
rg --type js 'metasHashMap'

Length of output: 204



Script:

#!/bin/bash
# Description: Extract the code that populates `metasHashMap` in `packages/entry/src/common.js`.

# Extract the relevant code
ast-grep --lang javascript --pattern $'metasHashMap[$_] = $_' packages/entry/src/common.js

Length of output: 157



Script:

#!/bin/bash
# Description: Extract the surrounding code where `metasHashMap` is populated in `packages/entry/src/common.js`.

# Extract the surrounding code
sed -n '140,160p' packages/entry/src/common.js

Length of output: 531

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

21-21: Correctly replaced getGlobalConfig with getMergeMeta to align with new configuration management.


30-30: Ensure that platformId is always provided in the configuration to avoid runtime errors.

packages/plugins/materials/src/block/http.js (1)

15-15: Correctly implemented getMergeMeta for dynamic configuration access in HTTP request functions.

Also applies to: 41-41, 55-55, 81-81

packages/canvas/src/components/render/runner.js (1)

138-138: Correctly implemented dynamic handling of canvas dependencies. Ensure that all dependencies are correctly formatted and accessible.

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

43-43: Ensure getMergeMeta is imported from the correct module.


50-53: Verify the dynamic theme import path.

Verification successful

The dynamic theme import path is correct, as the required theme files light.js and dark.js exist in the ./packages/design-core/src/theme/ directory.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the dynamic theme import path is correct.

# Test: Search for the theme files. Expect: Files should exist.
fd --type file --exec ls {} \; | grep -E 'theme/(light|dark)\.js$'

Length of output: 154

designer-demo/vite.config.js (1)

8-59: Verify the correctness of the alias paths.

Verification successful

Let's correct the script to properly handle __dirname and single quotes, and re-run the verification.


Let's modify the script to use cd and pwd to resolve the full paths, and re-run the verification.


The verification script executed successfully and did not produce any errors, indicating that all the alias paths in the Vite configuration file are correct and exist in the filesystem.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the correctness of the alias paths in the Vite configuration.

# Test: Check if the paths resolve correctly. Expect: No errors.
for path in $(grep 'path.resolve' designer-demo/vite.config.js | cut -d'(' -f2 | cut -d')' -f1); do
  if [ ! -d "$path" ] && [ ! -f "$path" ]; then
    echo "Path $path does not exist."
  fi
done

Length of output: 29687



Script:

#!/bin/bash
# Description: Verify the correctness of the alias paths in the Vite configuration.

# Test: Check if the paths resolve correctly. Expect: No errors.
grep 'path.resolve' designer-demo/vite.config.js | while read -r line; do
  path=$(echo "$line" | sed -E "s/.*path\.resolve\(__dirname, '(.*)'\).*/\1/")
  full_path=$(realpath "designer-demo/$path")
  if [ ! -d "$full_path" ] && [ ! -f "$full_path" ]; then
    echo "Path $full_path does not exist."
  fi
done

Length of output: 24906



Script:

#!/bin/bash
# Description: Verify the correctness of the alias paths in the Vite configuration.

# Test: Check if the paths resolve correctly. Expect: No errors.
grep 'path.resolve' designer-demo/vite.config.js | while read -r line; do
  path=$(echo "$line" | sed -E "s/.*path\.resolve\(__dirname, '(.*)'\).*/\1/")
  full_path=$(cd "designer-demo/$(dirname "$path")" && pwd)/$(basename "$path")
  if [ ! -d "$full_path" ] && [ ! -f "$full_path" ]; then
    echo "Path $full_path does not exist."
  fi
done

Length of output: 30071

packages/settings/props/src/components/groups/LifeCycle.vue (2)

78-78: Ensure getMergeMeta is imported from the correct module.


106-106: Verify the dynamic retrieval of lifecycle options.

Also applies to: 122-122

Verification successful

To verify the dynamic retrieval of lifecycle options, we need to inspect the implementation of the getMergeMeta function and ensure it correctly handles the 'engine.config' parameter. This will help us understand if the lifecycle options are being retrieved as expected.

Let's search for the implementation of getMergeMeta in the codebase and analyze its logic.


Let's use rg to search for the getMergeMeta function definition, which might handle the encoding issue better.


Let's search for the export statement of getMergeMeta to locate its definition.


Let's search for the definition of getMergeMeta within the @opentiny/tiny-engine-entry module.


Let's review the implementation of getMergeMeta in packages/entry/src/common.js to verify its logic.


The getMergeMeta function retrieves data from a metasHashMap using the provided id. This means that the lifecycle options are dynamically retrieved based on the engine.config key.

  • The function getMergeMeta is defined as:
    export const getMergeMeta = (id) => {
      return metasHashMap[id]
    }

This confirms that the lifecycle options are dynamically retrieved based on the engine.config key, as expected.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the dynamic retrieval of lifecycle options is correct.

# Test: Check if the lifecycle options are retrieved correctly. Expect: Correct data structure.
echo "Retrieving lifecycle options..."
echo $(grep 'getMergeMeta' packages/settings/props/src/components/groups/LifeCycle.vue | cut -d'(' -f2 | cut -d')' -f1)

Length of output: 404



Script:

#!/bin/bash
# Search for the implementation of the getMergeMeta function in the codebase
ast-grep --lang javascript --pattern 'function getMergeMeta($_) { $$$ }'

Length of output: 165



Script:

#!/bin/bash
# Search for the implementation of the getMergeMeta function in the codebase using ripgrep
rg 'function getMergeMeta' --glob '!node_modules/*'

Length of output: 53



Script:

#!/bin/bash
# Search for the export statement of the getMergeMeta function in the codebase using ripgrep
rg 'export function getMergeMeta' --glob '!node_modules/*'

Length of output: 60



Script:

#!/bin/bash
# Search for the definition of getMergeMeta within the @opentiny/tiny-engine-entry module
rg 'getMergeMeta' --glob '!node_modules/*'

Length of output: 5371



Script:

#!/bin/bash
# Display the implementation of getMergeMeta in packages/entry/src/common.js
rg 'export const getMergeMeta' -A 10 packages/entry/src/common.js

Length of output: 133

packages/toolbars/generate-vue/src/Main.vue (2)

27-27: Ensure getMergeMeta is imported from the correct module.


59-60: Verify the dynamic retrieval of platform and DSL mode configurations.

packages/plugins/block/src/BlockSetting.vue (2)

82-82: Import of getMergeMeta aligns with the new configuration management strategy.


247-248: Usage of getMergeMeta ensures dynamic and consistent configuration access across the component.

Also applies to: 277-277

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

82-82: Import of getMergeMeta aligns with the new configuration management strategy.


116-116: Usage of getMergeMeta ensures dynamic and consistent configuration access across the component.

Also applies to: 118-118

packages/controller/src/hooks/useResource.js (2)

17-17: Replace getGlobalConfig with getMergeMeta to standardize configuration retrieval.

This change aligns with the PR's objective to centralize and standardize configuration management.


253-253: Ensure getMergeMeta is used correctly for fetching material configurations.

This usage is consistent with the new approach to configuration management, ensuring that material configurations are dynamically fetched based on the current engine configuration.

packages/plugins/i18n/src/Main.vue (2)

127-128: Replace getGlobalConfig with getMergeMeta to standardize configuration retrieval.

This change aligns with the PR's objective to centralize and standardize configuration management.


152-152: Ensure getMergeMeta is used correctly for theme determination.

This usage is consistent with the new approach to configuration management, ensuring that theme settings are dynamically fetched based on the current engine configuration.

packages/controller/src/hooks/useBlock.js (1)

335-335: Verify the existence and correct configuration of engine.config.

Also applies to: 357-357

Verification successful

The search results confirm that engine.config is referenced in multiple files across the codebase, including the file under review (packages/controller/src/hooks/useBlock.js). This indicates that engine.config is a recognized configuration entity within the project.

  • packages/controller/src/hooks/useBlock.js: Lines 335 and 357 reference engine.config for dslMode.

Given this context, the use of getMergeMeta('engine.config')?.dslMode appears to be consistent with the rest of the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the existence and correct configuration of `engine.config`.

# Test: Search for the definition of `engine.config`. Expect: At least one definition.
rg --type json --type js --type vue 'engine.config'

Length of output: 79



Script:

#!/bin/bash
# Description: Verify the existence and correct configuration of `engine.config`.

# Test: Search for the definition of `engine.config`. Expect: At least one definition.
rg --type json --type js --type ts 'engine.config'

Length of output: 3884

packages/design-core/src/preview/src/App.vue Show resolved Hide resolved
packages/design-core/registry.js Show resolved Hide resolved
packages/design-core/src/preview/src/App.vue Show resolved Hide resolved
packages/design-core/config/lowcode.config.js Outdated Show resolved Hide resolved
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 37ebe14 and b918ad4.

Files selected for processing (2)
  • designer-demo/registry.js (1 hunks)
  • packages/design-core/src/init.js (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • designer-demo/registry.js
  • packages/design-core/src/init.js

@hexqi hexqi merged commit d9adbb7 into opentiny:refactor/develop Jun 7, 2024
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