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 : prefab code optimization and protection #15845

Merged
merged 8 commits into from
Aug 9, 2023

Conversation

dogeFu
Copy link
Contributor

@dogeFu dogeFu commented Aug 2, 2023

Re: #https://github.com/cocos/3d-tasks/issues/17058

Changelog

  • node.jsb.ts code synchronization with node.ts
  • add node.prefab getter to avoid any
  • add targetMap type and remove any
  • add protection when access node.prefab when expanding prefab
  • remove applyNodeAndComponentId called(it's add for onlineX which is abandon now)

Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

@dogeFu dogeFu requested review from PPpro and SantyWang August 2, 2023 06:19
cocos/scene-graph/prefab/utils.ts Outdated Show resolved Hide resolved
cocos/scene-graph/prefab/prefab-info.ts Outdated Show resolved Hide resolved
@dogeFu dogeFu requested review from minggo and removed request for SantyWang August 4, 2023 02:47
@github-actions
Copy link

github-actions bot commented Aug 7, 2023

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -25556,14 +25556,14 @@
     }
     export namespace Prefab {
         export namespace _utils {
             export function createNodeWithPrefab(node: Node): void;
-            export function generateTargetMap(node: Node, targetMap: any, isRoot: boolean): void;
+            export function generateTargetMap(node: Node, targetMap: TargetMap, isRoot: boolean): void;
             export function getTarget(localID: string[], targetMap: any): Node | Component | null;
-            export function applyMountedChildren(node: Node, mountedChildren: MountedChildrenInfo[], targetMap: Record<string, any | Node | Component>): void;
-            export function applyMountedComponents(node: Node, mountedComponents: MountedComponentsInfo[], targetMap: Record<string, any | Node | Component>): void;
-            export function applyRemovedComponents(node: Node, removedComponents: TargetInfo[], targetMap: Record<string, any | Node | Component>): void;
-            export function applyPropertyOverrides(node: Node, propertyOverrides: PropertyOverrideInfo[], targetMap: Record<string, any | Node | Component>): void;
+            export function applyMountedChildren(node: Node, mountedChildren: MountedChildrenInfo[], targetMap: TargetMap): void;
+            export function applyMountedComponents(node: Node, mountedComponents: MountedComponentsInfo[], targetMap: TargetMap): void;
+            export function applyRemovedComponents(node: Node, removedComponents: TargetInfo[], targetMap: TargetMap): void;
+            export function applyPropertyOverrides(node: Node, propertyOverrides: PropertyOverrideInfo[], targetMap: TargetMap): void;
             export function applyTargetOverrides(node: Node): void;
             export function expandPrefabInstanceNode(node: Node, recursively?: boolean): void;
             export function expandNestedPrefabInstanceNode(node: Node): void;
             export function applyNodeAndComponentId(prefabInstanceNode: Node, rootId: string): void;
@@ -25606,17 +25606,20 @@
                 mountedChildren: MountedChildrenInfo[];
                 mountedComponents: MountedComponentsInfo[];
                 propertyOverrides: PropertyOverrideInfo[];
                 removedComponents: TargetInfo[];
-                targetMap: Record<string, any | Node | Component>;
+                targetMap: TargetMap;
                 /**
                  * make sure prefab instance expand only once
                  * @internal
                  */
                 expanded: boolean;
                 findPropertyOverride(localID: string[], propPath: string[]): Prefab._utils.PropertyOverrideInfo | null | undefined;
                 removePropertyOverride(localID: string[], propPath: string[]): void;
             }
+            export interface TargetMap {
+                [k: string]: TargetMap | Node | Component;
+            }
             export class PrefabInfo {
                 root?: Node;
                 asset?: Prefab;
                 fileId: string;

@dogeFu dogeFu requested a review from minggo August 7, 2023 10:17
@minggo minggo merged commit 46a59ab into cocos:v3.8.1 Aug 9, 2023
10 checks passed
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.

3 participants