Skip to content

Comments

Support subpackage for wechat#2617

Merged
GuoLei1990 merged 7 commits intogalacean:mainfrom
singlecoder:feat/wechat-subpackage
Apr 15, 2025
Merged

Support subpackage for wechat#2617
GuoLei1990 merged 7 commits intogalacean:mainfrom
singlecoder:feat/wechat-subpackage

Conversation

@singlecoder
Copy link
Member

@singlecoder singlecoder commented Apr 14, 2025

Summary by CodeRabbit

  • Refactor
    • Improved asset loading process to support subpackage handling for better resource management.

@singlecoder singlecoder self-assigned this Apr 14, 2025
@coderabbitai
Copy link

coderabbitai bot commented Apr 14, 2025

Walkthrough

The _loadSingleItem method in the ResourceManager class was updated to extract the entire remoteConfig object from _virtualPathResourceMap for the given asset base URL and derive remoteAssetBaseURL from remoteConfig.path if present. A new local variable subpackageName is extracted from remoteConfig.subpackageName. The asset loading logic now delegates to a new private method _loadSubpackageAndMainAsset, which currently forwards the call to _loadMainAsset. The EditorResourceItem type was extended with an optional subpackageName property. No changes were made to error handling or the overall control flow.

Changes

File(s) Change Summary
packages/core/src/asset/ResourceManager.ts Updated _loadSingleItem to extract remoteConfig and subpackageName, derive remoteAssetBaseURL from remoteConfig.path; added _loadSubpackageAndMainAsset method that delegates to _loadMainAsset; extended EditorResourceItem with optional subpackageName property.

Poem

A subpackage name hops into sight,
Paths refined, URLs just right.
A method new, yet quietly stays,
Delegating loads in subtle ways.
Code rabbits cheer, their work’s in bloom—
Smooth asset loads, no hint of gloom! 🐇🎉

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 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 7ac4710 and 4ad629f.

📒 Files selected for processing (1)
  • packages/core/src/asset/ResourceManager.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/core/src/asset/ResourceManager.ts

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and 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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
packages/core/src/asset/ResourceManager.ts (1)

352-619: 🛠️ Refactor suggestion

Add documentation explaining subpackages

There's no documentation explaining what subpackages are or how they should be loaded/initialized. This makes it difficult for other developers to understand the purpose and functionality of these methods.

Add JSDoc comments to the _loadSubpackage and initSubpackages methods explaining:

  • What WeChat subpackages are
  • How they're loaded and initialized
  • The expected data structure for initialization
  • Any requirements or constraints for using this feature

For example:

/**
 * Loads a WeChat subpackage before proceeding with asset loading.
 * Subpackages are used in WeChat mini-programs to load resources on demand.
 * @param itemOrURL - The asset item or URL that might require a subpackage
 * @returns A promise that resolves when the subpackage is loaded
 * @internal
 */
private _loadSubpackage(itemOrURL: LoadItem | string): AssetPromise<void> {
  // Implementation goes here
}
🧹 Nitpick comments (1)
packages/loader/src/ProjectLoader.ts (1)

21-22: Add TypeScript typing instead of using @ts-ignore

The addition of the initSubpackages method call is appropriate to initialize subpackages immediately after fetching project data. However, using @ts-ignore suggests there might be typing issues with this method.

Consider properly typing the initSubpackages method in the ResourceManager class definition to avoid using @ts-ignore. This would improve type safety and code maintainability.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fa6d0e1 and ffa4907.

📒 Files selected for processing (2)
  • packages/core/src/asset/ResourceManager.ts (2 hunks)
  • packages/loader/src/ProjectLoader.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/core/src/asset/ResourceManager.ts (3)
packages/core/src/asset/LoadItem.ts (1)
  • LoadItem (8-38)
packages/core/src/asset/AssetPromise.ts (1)
  • AssetPromise (4-192)
packages/core/src/Utils.ts (1)
  • Utils (3-269)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: e2e (22.x)
🔇 Additional comments (1)
packages/core/src/asset/ResourceManager.ts (1)

356-431: Good refactor incorporating subpackage loading

The refactored _loadSingleItem method correctly handles the sequential loading process by first loading subpackages before proceeding with asset loading. The improved error handling using Error objects instead of string messages is also a good practice.

@codecov
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.99%. Comparing base (fa6d0e1) to head (4ad629f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2617      +/-   ##
==========================================
+ Coverage   68.97%   68.99%   +0.01%     
==========================================
  Files         961      961              
  Lines      100356   100373      +17     
  Branches     8685     8691       +6     
==========================================
+ Hits        69219    69248      +29     
+ Misses      30877    30865      -12     
  Partials      260      260              
Flag Coverage Δ
unittests 68.99% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@GuoLei1990 GuoLei1990 changed the title Feat: wechat subpackage Support wechat subpackage Apr 15, 2025
@GuoLei1990 GuoLei1990 changed the title Support wechat subpackage Support subpackage for wechat Apr 15, 2025
@GuoLei1990 GuoLei1990 added enhancement New feature or request resource Resource-related functions labels Apr 15, 2025
@GuoLei1990 GuoLei1990 merged commit 9d74066 into galacean:main Apr 15, 2025
9 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 28, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request resource Resource-related functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants