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

Optimize code size: mark more properties as mangled. #18265

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cocos/2d/components/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
* @zh
* 文本字符之间的间距。仅在使用 BMFont 位图字体时生效。
*/
@visible(function (this: Label) {

Check warning on line 337 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
return !this._isSystemFontUsed && this._font instanceof BitmapFont;
})
@displayOrder(9)
Expand Down Expand Up @@ -433,7 +433,7 @@
* 文本字体名称, 只在 useSystemFont 属性为 true 的时候生效。
*/
@displayOrder(13)
@visible(function (this: Label) { return this._isSystemFontUsed; })

Check warning on line 436 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
get fontFamily (): string {
return this._fontFamily;
}
Expand All @@ -455,7 +455,7 @@
*/
@type(Font)
@displayOrder(13)
@visible(function (this: Label) { return !this._isSystemFontUsed; })

Check warning on line 458 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
get font (): Font | null {
// return this._N$file;
return this._font;
Expand Down Expand Up @@ -576,7 +576,7 @@
* @en The height of underline.
* @zh 下划线高度。
*/
@visible(function (this: Label) { return this._isUnderline; })

Check warning on line 579 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@editable
@displayOrder(18)
get underlineHeight (): number {
Expand All @@ -596,7 +596,7 @@
** 描边效果组件,用于字体描边,只能用于系统字体或 ttf 字体。
**/
@editable
@visible(function (this: Label) { return !(this._font instanceof BitmapFont); })

Check warning on line 599 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(19)
get enableOutline (): boolean {
return this._enableOutline;
Expand All @@ -615,7 +615,7 @@
* 改变描边的颜色。
*/
@editable
@visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); })

Check warning on line 618 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(20)
get outlineColor (): Color {
return this._outlineColor;
Expand All @@ -634,7 +634,7 @@
* 改变描边的宽度。
*/
@editable
@visible(function (this: Label) { return this._enableOutline && !(this._font instanceof BitmapFont); })

Check warning on line 637 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(21)
get outlineWidth (): number {
return this._outlineWidth;
Expand All @@ -650,7 +650,7 @@
* @zh 用于给 Label 组件添加阴影效果,只能用于系统字体或 ttf 字体。在缓存模式为 char 时不可用。
*/
@editable
@visible(function (this: Label) { return !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })

Check warning on line 653 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(22)
get enableShadow (): boolean {
return this._enableShadow;
Expand All @@ -669,7 +669,7 @@
* 阴影的颜色。
*/
@editable
@visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })

Check warning on line 672 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(23)
get shadowColor (): Color {
return this._shadowColor;
Expand All @@ -688,7 +688,7 @@
* 字体与阴影的偏移。
*/
@editable
@visible(function (this: Label) { return this._enableShadow && !(this._font instanceof BitmapFont) && (this.cacheMode !== CacheMode.CHAR); })

Check warning on line 691 in cocos/2d/components/label.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
@displayOrder(24)
get shadowOffset (): Vec2 {
return this._shadowOffset;
Expand Down Expand Up @@ -1093,6 +1093,7 @@

/**
* @engineInternal
* @mangle
*/
public _updateBlendFunc (): void {
// override for BYTEDANCE
Expand Down
3 changes: 3 additions & 0 deletions cocos/2d/components/rich-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ export class RichText extends Component {

/**
* @engineInternal
* @mangle
*/
protected splitLongStringApproximatelyIn2048 (text: string, styleIndex: number): string[] {
const approxSize = text.length * this.fontSize;
Expand Down Expand Up @@ -625,6 +626,7 @@ export class RichText extends Component {

/**
* @engineInternal
* @mangle
*/
protected splitLongStringOver2048 (text: string, styleIndex: number): string[] {
const partStringArr: string[] = [];
Expand Down Expand Up @@ -746,6 +748,7 @@ export class RichText extends Component {

/**
* @engineInternal
* @mangle
*/
protected _calculateSize (out: Vec2, styleIndex: number, s: string): Vec2 {
let label: ISegment;
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/framework/sprite-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class SpriteRenderer extends ModelRenderer {
/**
* @engineInternal
*/
public _onRebuildPSO (idx: number, material: Material): void {
public override _onRebuildPSO (idx: number, material: Material): void {
if (!this._model || !this._model.inited) { return; }
this._model.setSubModelMaterial(idx, material);
this._onUpdateLocalDescriptorSet();
Expand Down
3 changes: 3 additions & 0 deletions cocos/2d/framework/ui-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class UIRenderer extends Renderer {
/**
* As can not set setter internal individually, so add setRenderData();
* @engineInternal
* @mangle
*/
setRenderData (renderData: RenderData | null): void {
this._renderData = renderData;
Expand Down Expand Up @@ -277,6 +278,7 @@ export class UIRenderer extends Renderer {
public _internalId = -1;
/**
* @engineInternal
* @mangle
*/
public _flagChangedVersion = -1;

Expand Down Expand Up @@ -460,6 +462,7 @@ export class UIRenderer extends Renderer {

/**
* @engineInternal
* @mangle
*/
public updateMaterial (): void {
if (this._customMaterial) {
Expand Down
2 changes: 2 additions & 0 deletions cocos/2d/framework/ui-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,7 @@ export class UITransform extends Component {
/**
* @deprecated Since v3.7.0, this is an engine private interface that will be removed in the future.
* @engineInternal
* @mangle
*/
public static _sortSiblings (): void {
UITransform.priorityChangeNodeMap.forEach((node, ID): void => {
Expand All @@ -808,6 +809,7 @@ export class UITransform extends Component {
/**
* @deprecated Since v3.7.0, this is an engine private interface that will be removed in the future.
* @engineInternal
* @mangle
*/
public static _cleanChangeMap (): void {
UITransform.priorityChangeNodeMap.clear();
Expand Down
4 changes: 3 additions & 1 deletion cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ export class MeshRenderer extends ModelRenderer {

/**
* @engineInternal
* @mangle
*/
public clearGlobalStandardSkinObjectFlag (): void {
this._enabledGlobalStandardSkinObject = false;
Expand Down Expand Up @@ -1000,6 +1001,7 @@ export class MeshRenderer extends ModelRenderer {

/**
* @engineInternal
* @mangle
*/
public _detachFromScene (): void {
if (this._model && this._model.scene) {
Expand Down Expand Up @@ -1088,7 +1090,7 @@ export class MeshRenderer extends ModelRenderer {
/**
* @engineInternal
*/
public _onRebuildPSO (idx: number, material: Material): void {
public override _onRebuildPSO (idx: number, material: Material): void {
if (!this._model || !this._model.inited) { return; }
this._model.isDynamicBatching = this._isBatchingEnabled();
this._model.setSubModelMaterial(idx, material);
Expand Down
10 changes: 10 additions & 0 deletions cocos/3d/reflection-probe/reflection-probe-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public registerEvent (): void {
if (!this._registeredEvent) {
Expand Down Expand Up @@ -125,6 +126,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public clearPlanarReflectionMap (probe: ReflectionProbe): void {
for (const entry of this._usePlanarModels.entries()) {
Expand All @@ -136,6 +138,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public register (probe: ReflectionProbe): void {
const index = this._probes.indexOf(probe);
Expand All @@ -147,6 +150,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public unregister (probe: ReflectionProbe): void {
for (let i = 0; i < this._probes.length; i++) {
Expand All @@ -163,6 +167,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public exists (probeId: number): boolean {
if (this._probes.length === 0) return false;
Expand All @@ -176,6 +181,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public getNewReflectionProbeId (): number {
let probeId = 0;
Expand Down Expand Up @@ -212,13 +218,15 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public clearAll (): void {
this._probes = [];
}

/**
* @engineInternal
* @mangle
*/
public getProbeByCamera (camera: Camera): ReflectionProbe | null {
for (let i = 0; i < this._probes.length; i++) {
Expand Down Expand Up @@ -276,6 +284,7 @@ export class ReflectionProbeManager {
* @zh 更新使用反射探针进行平面反射的物体。
* @param probe update the model for reflection probe
* @engineInternal
* @mangle
*/
public selectPlanarReflectionProbe (model: Model): void {
if (!model.node || !model.worldBounds || model.reflectionProbeType !== ReflectionProbeType.PLANAR_REFLECTION) return;
Expand Down Expand Up @@ -494,6 +503,7 @@ export class ReflectionProbeManager {

/**
* @engineInternal
* @mangle
*/
public updateProbeOfModels (): void {
if (this._probes.length === 0) return;
Expand Down
7 changes: 7 additions & 0 deletions cocos/asset/asset-manager/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class Parser {

/**
* @engineInternal
* @mangle
*/
public parseImage (
file: HTMLImageElement | Blob,
Expand All @@ -98,6 +99,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parsePVRTex (
file: ArrayBuffer | ArrayBufferView,
Expand All @@ -117,6 +119,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parsePKMTex (
file: ArrayBuffer | ArrayBufferView,
Expand All @@ -136,6 +139,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parseASTCTex (
file: ArrayBuffer | ArrayBufferView,
Expand All @@ -155,6 +159,7 @@ export class Parser {

/**
* @engineInternal
* Don't mangle this function since it's used in platform adapter code.
*/
public parsePlist (
file: string,
Expand All @@ -169,6 +174,7 @@ export class Parser {

/**
* @engineInternal
* @mangle
*/
public parseImport (
file: Record<string, any> | CCON,
Expand All @@ -191,6 +197,7 @@ export class Parser {

/**
* @engineInternal
* @mangle
*/
public init (): void {
this._parsing.clear();
Expand Down
1 change: 1 addition & 0 deletions cocos/asset/asset-manager/request-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class RequestItem {

/**
* @engineInternal
* @mangle
*/
public static MAX_DEAD_NUM = 500;

Expand Down
1 change: 1 addition & 0 deletions cocos/asset/asset-manager/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
export default class Task {
/**
* @engineInternal
* @mangle
*/
public static MAX_DEAD_NUM = 500;

Expand Down Expand Up @@ -284,7 +285,7 @@
switch (event) {
case 'complete':
if (this.onComplete) {
this.onComplete(param1, param2);

Check failure on line 288 in cocos/asset/asset-manager/task.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `Error | null | undefined`
}
break;
case 'progress':
Expand Down
1 change: 1 addition & 0 deletions cocos/asset/assets/effect-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ export class EffectAsset extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _precompile (): void {
if (cclegacy.rendering && cclegacy.rendering.enableEffectImport) {
Expand Down
6 changes: 6 additions & 0 deletions cocos/asset/assets/image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ export class ImageAsset extends Asset {
* @param type @zh 压缩纹理类型。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parseCompressedTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -339,6 +340,7 @@ export class ImageAsset extends Asset {
* @param endOffset @zh 压缩纹理结束时的偏移。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parsePVRTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -396,6 +398,7 @@ export class ImageAsset extends Asset {
* @param endOffset @zh 压缩纹理结束时的偏移。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parsePKMTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -435,6 +438,7 @@ export class ImageAsset extends Asset {
* @param endOffset @zh 压缩纹理结束时的偏移。
* @param out @zh 压缩纹理输出。
* @engineInternal
* @mangle
*/
public static parseASTCTexture (
file: ArrayBuffer | ArrayBufferView,
Expand Down Expand Up @@ -483,6 +487,7 @@ export class ImageAsset extends Asset {
/**
* @en extract the first mipmap from a compressed image asset
* @engineInternal
* @mangle
*/
public extractMipmap0 (): ImageAsset {
if (this.mipmapLevelDataSize && this.mipmapLevelDataSize.length > 0) {
Expand All @@ -508,6 +513,7 @@ export class ImageAsset extends Asset {
/**
* @en extract mipmaps from a compressed image asset
* @engineInternal
* @mangle
*/
public extractMipmaps (): ImageAsset[] {
const images: ImageAsset[] = [];
Expand Down
7 changes: 7 additions & 0 deletions cocos/asset/assets/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _fillInfo (info: IMaterialInfo): void {
if (info.technique !== undefined) { this._techIdx = info.technique; }
Expand All @@ -402,6 +403,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _prepareInfo (patch: Record<string, unknown> | Record<string, unknown>[], cur: Record<string, unknown>[]): void {
let patchArray = patch;
Expand All @@ -416,6 +418,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _createPasses (): Pass[] {
const tech = this._effectAsset!.techniques[this._techIdx || 0];
Expand Down Expand Up @@ -443,6 +446,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _update (keepProps = true): void {
if (this._effectAsset) {
Expand Down Expand Up @@ -470,6 +474,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _uploadProperty (pass: Pass, name: string, val: MaterialPropertyFull | MaterialPropertyFull[]): boolean {
const handle = pass.getHandle(name);
Expand Down Expand Up @@ -503,6 +508,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _bindTexture (pass: Pass, handle: number, val: MaterialPropertyFull, index?: number): void {
const binding = Pass.getBindingFromHandle(handle);
Expand All @@ -521,6 +527,7 @@ export class Material extends Asset {

/**
* @engineInternal
* @mangle
*/
protected _doDestroy (): void {
if (this._passes && this._passes.length) {
Expand Down
1 change: 1 addition & 0 deletions cocos/asset/assets/render-texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export class RenderTexture extends TextureBase {
* @zh 初始化渲染贴图的具体实现。
* @param info @en The create info of render texture. @zh 渲染贴图的创建信息。
* @engineInternal
* @mangle
*/
protected _initWindow (info?: IRenderTextureCreateInfo): void {
const root = cclegacy.director.root as Root;
Expand Down
Loading
Loading