tiny-engine icon indicating copy to clipboard operation
tiny-engine copied to clipboard

docs: update registry code example

Open chilingling opened this issue 1 month ago • 1 comments

English | 简体中文

PR 更新文档代码示例

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] 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
  • [x] 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
  • [x] No

Other information

Summary by CodeRabbit

  • Documentation
    • Updated registry examples to use dynamic public keys for preview, plugin registration, and UI/page customization.
    • Changed preview configuration to accept a direct options object with flexible URL handling (static or computed).
    • Replaced plugins-array patterns with single public-entry registrations for plugins and customizations.
    • Updated examples to use the new import/configuration style and clarified engine configuration fields.

chilingling avatar Nov 03 '25 06:11 chilingling

Walkthrough

Documentation examples updated to migrate from array-based plugin/toolbar registration to key-based registry entries using META_APP constants, changing how Preview, plugin registration, and AppManage/customization options are declared and how engine.config is specified.

Changes

Cohort / File(s) Summary
Preview Integration Configuration
docs/api/frontend-api/preview-api.md
Replaced toolbar-array Preview registration with a direct [META_APP.Preview] registry entry. Switched previewUrl handling to an options object (string or function). Moved config: { ... } into a top-level 'engine.config' key in registry examples.
Plugin Registration Pattern
docs/development-getting-started/dev-quick-start.md
Replaced the exported plugins: [...] array with a computed registry property [DemoPlugin.id]: DemoPlugin. Removed explicit dsls, settings, and canvas properties from the exported object.
Page Customization Configuration
docs/extension-capabilities-tutorial/customize-page-configured.md
Moved customPageOperations from a Page plugin entry into a top-level [META_APP.AppManage] public registry key with an options object. Removed the prior Page plugin entry.
Plugin UI Customization Pattern
docs/extension-capabilities-tutorial/customize-plugin-ui.md
Replaced per-plugin Page-like customization entries in the plugins array with [META_APP.AppManage] registry entries (supporting title, icon, and entry). Added explicit META_APP import in examples.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Changes are documentation-only and follow a consistent registry-key migration pattern.
  • Review focus: example syntax correctness, consistent use of [META_APP.*] keys, and the relocated 'engine.config' shape.

Poem

🐰 A hop, a nibble, configs rearranged,
Arrays to keys, the registry changed.
META_APP whispers, options unfurl,
Tiny hops of logic across the world. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "docs: update registry code example" clearly and directly relates to the main changes in the changeset. The raw summary shows that all modified files are documentation files containing registry configuration code examples that have been updated to use new patterns (replacing arrays/config objects with public key entries using META_APP). The title is concise, specific, and uses the conventional "docs:" prefix to indicate documentation changes. A teammate reviewing the commit history would understand that this PR updates documentation related to registry configuration examples, which accurately reflects the actual content of the changes.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1bbadf3afd5056f33be7339eb3519000dfa0bef8 and 8533708a050f86a7a4096e9909dc30fa2781b91b.

📒 Files selected for processing (1)
  • docs/extension-capabilities-tutorial/customize-plugin-ui.md (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: gene9831
Repo: opentiny/tiny-engine PR: 1041
File: packages/plugins/datasource/src/DataSourceList.vue:138-138
Timestamp: 2025-01-14T10:06:25.508Z
Learning: PR #1041 in opentiny/tiny-engine is specifically for reverting Prettier v3 formatting to v2, without any logical code changes or syntax improvements.
Learnt from: yy-wow
Repo: opentiny/tiny-engine PR: 850
File: packages/toolbars/preview/src/Main.vue:16-16
Timestamp: 2024-10-10T02:47:46.239Z
Learning: In `packages/toolbars/preview/src/Main.vue`, within the `preview` function, the `getMergeMeta` method is used at lines 64 and 65 to retrieve `engine.config` configurations.
📚 Learning: 2025-05-28T03:58:31.212Z
Learnt from: chilingling
Repo: opentiny/tiny-engine PR: 1440
File: packages/plugins/materials/src/composable/useResource.ts:82-84
Timestamp: 2025-05-28T03:58:31.212Z
Learning: In the TinyEngine codebase, there are two different data structures for page information:
1. App schema components tree (appSchemaState.pageTree) uses nested meta structure with page.meta?.id
2. API responses from pagePluginApi.getPageById() return flattened structure with pageInfo.id and pageInfo.occupier directly
The code should use page.meta?.id when working with pageTree data and pageInfo.id when working with API response data.

Applied to files:

  • docs/extension-capabilities-tutorial/customize-plugin-ui.md
📚 Learning: 2025-07-03T09:22:59.512Z
Learnt from: hexqi
Repo: opentiny/tiny-engine PR: 1501
File: mockServer/src/tool/Common.js:79-82
Timestamp: 2025-07-03T09:22:59.512Z
Learning: In the tiny-engine project, the mockServer code uses ES6 import syntax but is compiled to CommonJS output. This means CommonJS globals like `__dirname` are available at runtime, while ES6 module-specific features like `import.meta` would cause runtime errors.

Applied to files:

  • docs/extension-capabilities-tutorial/customize-plugin-ui.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: push-check
🔇 Additional comments (2)
docs/extension-capabilities-tutorial/customize-plugin-ui.md (2)

14-25: ✅ Prior import issue resolved.

The missing META_APP import statement from the previous review has been successfully added at line 16. The first code example is now self-contained and properly demonstrates the registry-based plugin UI customization using [META_APP.AppManage].


35-46: Consistent and complete documentation update.

The second code example properly includes the META_APP import and demonstrates the alternative pattern of replacing the entire plugin page via the entry property. The example is followed by a concrete Vue component implementation, which effectively illustrates the complete workflow.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 03 '25 06:11 coderabbitai[bot]