Skip to content

Fix lodash import issue and enhance asset reimport metadata - #856

Open
doommm wants to merge 2 commits into
cocos:mainfrom
doommm:main
Open

Fix lodash import issue and enhance asset reimport metadata#856
doommm wants to merge 2 commits into
cocos:mainfrom
doommm:main

Conversation

@doommm

@doommm doommm commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This pull request makes several improvements to the asset management system by standardizing the way asset metadata fields are selected and serialized, ensuring consistency across the codebase. It introduces constants for commonly used sets of asset info keys, updates method signatures to use these constants, and adds a test to verify correct serialization during asset reimport. Additionally, it refactors a utility import in the node manager for clarity.

Asset metadata key management:

  • Introduced DEFAULT_ASSET_INFO_DATA_KEYS and ASSET_TREE_INFO_DATA_KEYS constants in query.ts to standardize which metadata fields are included when querying or serializing asset information. These are now used throughout the asset management code.
  • Updated method signatures in AssetQueryManager (queryAssetInfo, queryAssetInfoByUUID, queryAssetInfos, encodeAsset) to accept readonly arrays of keys, defaulting to the new constants for consistency and type safety. [1] [2] [3] [4]

Usage of standardized asset info keys:

  • Updated calls to queryAssetInfo and encodeAsset in asset.ts and operation.ts to use ASSET_TREE_INFO_DATA_KEYS instead of hardcoding key arrays, ensuring all relevant metadata is included for asset tree operations. [1] [2] [3] [4]

Testing improvements:

  • Added a unit test in operation-filesystem-bridge.test.ts to verify that reimportAsset serializes asset metadata using the correct contract (ASSET_TREE_INFO_DATA_KEYS). [1] [2] [3]

Codebase cleanup:

  • Replaced a dynamic lodash import with a direct import of findLast from lodash in node.ts for improved clarity and tree-shaking. [1] [2]

doommm added 2 commits August 13, 2026 18:11
Requiring lodash's package root fails in the engine runtime while resolving
asset and script dependencies.

Import only findLast through its module entry point so NodeManager can keep
locating referenced scene nodes without triggering the runtime load error.
Successful reimports returned the default AssetInfo payload, which omitted
inheritance metadata. PinK uses the asset-change payload to replace cached
AssetInfo and clear invalid state, so a valid asset could stay marked invalid
until a full reload.

Serialize reimport results with the shared Asset Tree data-key contract,
including sub-assets, display names, and extends. This keeps the result
compatible with asset-change without a follow-up queryAssetInfo request.
@doommm
doommm requested a review from bofeng-song August 13, 2026 11:21
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