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

385 revert $ #17912

Merged
merged 16 commits into from
Nov 25, 2024
32 changes: 16 additions & 16 deletions cocos/asset/asset-manager/asset-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@
*/
public references = references;

private _releaseManager$ = releaseManager;
private _files$ = files;
private _parsed$ = parsed;
private _parsePipeline$ = BUILD ? null : new Pipeline('parse existing json', [this.loadPipe]);
private _projectBundles$: string[] = [];
private _releaseManager = releaseManager;
private _files = files;
private _parsed = parsed;
private _parsePipeline = BUILD ? null : new Pipeline('parse existing json', [this.loadPipe]);
private _projectBundles: string[] = [];
private static _instance: AssetManager;
private _eventTarget$ = new EventTarget();
private _eventTarget = new EventTarget();

/**
* @en
Expand All @@ -334,15 +334,15 @@
/**
* @engineInternal
*/
public get files(): Cache {

Check warning on line 337 in cocos/asset/asset-manager/asset-manager.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Missing space before function parentheses
return this._files$;
return this._files;
}

/**
* @engineInternal
*/
public getReleaseManager (): ReleaseManager {
return this._releaseManager$;
return this._releaseManager;
}

/**
Expand Down Expand Up @@ -381,7 +381,7 @@
* @engineInternal
*/
public onAssetMissing (func: (parentAsset: Asset, owner: any, propName: string, uuid: string) => void, target?: any): void {
this._eventTarget$.on(EVENT_ASSET_MISSING, func, target);
this._eventTarget.on(EVENT_ASSET_MISSING, func, target);
}

/**
Expand All @@ -395,7 +395,7 @@
* @engineInternal
*/
public offAssetMissing (func: (parentAsset: Asset, owner: any, propName: string, uuid: string) => void, target?: any): void {
this._eventTarget$.off(EVENT_ASSET_MISSING, func, target);
this._eventTarget.off(EVENT_ASSET_MISSING, func, target);
}

/**
Expand All @@ -411,7 +411,7 @@
* @engineInternal
*/
public dispatchAssetMissing (parentAsset: Asset, owner: any, propName: string, uuid: string): void {
this._eventTarget$.emit(EVENT_ASSET_MISSING, parentAsset, owner, propName, uuid);
this._eventTarget.emit(EVENT_ASSET_MISSING, parentAsset, owner, propName, uuid);
}

/**
Expand All @@ -434,9 +434,9 @@
this.downloader.maxConcurrency = downloadMaxConcurrency;
}

this._files$.clear();
this._parsed$.clear();
this._releaseManager$.init();
this._files.clear();
this._parsed.clear();
this._releaseManager.init();
this.assets.clear();
this.bundles.clear();
this.packManager.init();
Expand All @@ -453,7 +453,7 @@
}
this.generalImportBase = importBase;
this.generalNativeBase = nativeBase;
this._projectBundles$ = settings.querySettings(SettingsCategory.ASSETS, 'projectBundles') || [];
this._projectBundles = settings.querySettings(SettingsCategory.ASSETS, 'projectBundles') || [];
const assetsOverride = settings.querySettings(SettingsCategory.ASSETS, 'assetsOverrides') || {};
for (const key in assetsOverride) {
this.assetsOverrideMap.set(key, assetsOverride[key] as string);
Expand Down Expand Up @@ -827,7 +827,7 @@
if (onComp) { onComp(err, data); }
}),
});
this._parsePipeline$!.async(task);
this._parsePipeline!.async(task);
}
}

Expand Down
22 changes: 11 additions & 11 deletions cocos/asset/asset-manager/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ import type { AssetManager } from './asset-manager';
*
*/
export default class Bundle {
private _config$: Config = new Config();
private _config: Config = new Config();

/**
* For internal use.
* @engineInternal
*/
public get config (): Config {
return this._config$;
return this._config;
}

/**
Expand All @@ -61,7 +61,7 @@ export default class Bundle {
*
*/
public get name (): string {
return this._config$.name;
return this._config.name;
}

/**
Expand All @@ -73,7 +73,7 @@ export default class Bundle {
*
*/
public get deps (): string[] {
return this._config$.deps!;
return this._config.deps!;
}

/**
Expand All @@ -85,7 +85,7 @@ export default class Bundle {
*
*/
public get base (): string {
return this._config$.base;
return this._config.base;
}

/**
Expand All @@ -104,7 +104,7 @@ export default class Bundle {
*
*/
public getInfoWithPath (path: string, type?: Constructor<Asset> | null): IAddressableInfo | null {
return this._config$.getInfoWithPath(path, type);
return this._config.getInfoWithPath(path, type);
}

/**
Expand All @@ -126,7 +126,7 @@ export default class Bundle {
* bundle.getDirWithPath('images', Texture2D, infos);
*/
public getDirWithPath (path: string, type?: Constructor<Asset> | null, out?: IAddressableInfo[]): IAddressableInfo[] {
return this._config$.getDirWithPath(path, type, out);
return this._config.getDirWithPath(path, type, out);
}

/**
Expand All @@ -144,7 +144,7 @@ export default class Bundle {
*
*/
public getAssetInfo (uuid: string): IAssetInfo | null {
return this._config$.getAssetInfo(uuid);
return this._config.getAssetInfo(uuid);
}

/**
Expand All @@ -162,7 +162,7 @@ export default class Bundle {
*
*/
public getSceneInfo (name: string): ISceneInfo | null {
return this._config$.getSceneInfo(name);
return this._config.getSceneInfo(name);
}

/**
Expand All @@ -177,7 +177,7 @@ export default class Bundle {
*
*/
public init (options: IConfigOption): void {
this._config$.init(options);
this._config.init(options);
bundles.add(options.name, this);
}

Expand Down Expand Up @@ -639,7 +639,7 @@ export default class Bundle {
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
public _destroy (): void {
this._config$.destroy();
this._config.destroy();
}
}

Expand Down
24 changes: 12 additions & 12 deletions cocos/asset/asset-manager/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ export default class Config {
this.name = options.name || '';
this.deps = options.deps || [];
// init
this._initUuid$(options.uuids);
this._initPath$(options.paths);
this._initScene$(options.scenes);
this._initPackage$(options.packs);
this._initVersion$(options.versions);
this._initRedirect$(options.redirect);
this._initUuid(options.uuids);
this._initPath(options.paths);
this._initScene(options.scenes);
this._initPackage(options.packs);
this._initVersion(options.versions);
this._initRedirect(options.redirect);
for (const ext in options.extensionMap) {
if (!Object.prototype.hasOwnProperty.call(options.extensionMap, ext)) {
continue;
Expand Down Expand Up @@ -333,7 +333,7 @@ export default class Config {
this.assetInfos.destroy();
}

private _initUuid$ (uuidList: string[]): void {
private _initUuid (uuidList: string[]): void {
if (!uuidList) {
return;
}
Expand All @@ -344,7 +344,7 @@ export default class Config {
}
}

private _initPath$ (pathList: Record<string, string[]>): void {
private _initPath (pathList: Record<string, string[]>): void {
if (!pathList) { return; }
const paths = this.paths;
paths.clear();
Expand All @@ -369,7 +369,7 @@ export default class Config {
}
}

private _initScene$ (sceneList: Record<string, string>): void {
private _initScene (sceneList: Record<string, string>): void {
if (!sceneList) { return; }
const scenes = this.scenes;
scenes.clear();
Expand All @@ -382,7 +382,7 @@ export default class Config {
}
}

private _initPackage$ (packageList: Record<string, string[]>): void {
private _initPackage (packageList: Record<string, string[]>): void {
if (!packageList) { return; }
const assetInfos = this.assetInfos;
for (const packUuid in packageList) {
Expand All @@ -407,7 +407,7 @@ export default class Config {
}
}

private _initVersion$ (versions: { import?: string[], native?: string[] }): void {
private _initVersion (versions: { import?: string[], native?: string[] }): void {
if (!versions) { return; }
const assetInfos = this.assetInfos;
let entries = versions.import;
Expand All @@ -428,7 +428,7 @@ export default class Config {
}
}

private _initRedirect$ (redirect: string[]): void {
private _initRedirect (redirect: string[]): void {
if (!redirect) { return; }
const assetInfos = this.assetInfos;
for (let i = 0, l = redirect.length; i < l; i += 2) {
Expand Down
16 changes: 8 additions & 8 deletions cocos/asset/asset-manager/depend-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
public getDepsRecursively (uuid: string): string[] {
const exclude = Object.create(null);
const depends = [];
this._descend$(uuid, exclude, depends);
this._descend(uuid, exclude, depends);

Check failure on line 146 in cocos/asset/asset-manager/depend-util.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `Record<string, any>`
return depends;
}

Expand Down Expand Up @@ -182,14 +182,14 @@
// TODO: json: any[] is not assigned to IFileData
// workaround: mark json as any
// issue: https://github.com/cocos/cocos-engine/issues/14642
if (Array.isArray(json) && (!(BUILD || isCompiledJson(json)) || !hasNativeDep(json as any))) {

Check failure on line 185 in cocos/asset/asset-manager/depend-util.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `[FileInfo & DeserializeContext, 0 | string[], 0 | string[], (string | IClass | AnyCCClass)[], 0 | IMask[], any[], ... 4 more ..., (string | number)[]]`
out = {
deps: this._parseDepsFromJson$(json),
deps: this._parseDepsFromJson(json),
};
} else {
try {
const asset = deserialize(json, { __uuid__: uuid });

Check failure on line 191 in cocos/asset/asset-manager/depend-util.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `Record<string, any>`
out = this._parseDepsFromAsset$(asset);
out = this._parseDepsFromAsset(asset);
if (out.nativeDep) {
out.nativeDep.uuid = uuid;
}
Expand All @@ -206,14 +206,14 @@
return out;
}
}
out = this._parseDepsFromAsset$(json);
out = this._parseDepsFromAsset(json);

Check failure on line 209 in cocos/asset/asset-manager/depend-util.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `Asset`
}
// cache dependency list
this._depends.add(uuid, out);
return out;
}

private _parseDepsFromAsset$ (asset: Asset): IDependencies {
private _parseDepsFromAsset (asset: Asset): IDependencies {
const out: IDependencies = {
deps: [],
parsedFromExistAsset: true,
Expand All @@ -232,20 +232,20 @@
return out;
}

private _parseDepsFromJson$ (json: any[]): string[] {
private _parseDepsFromJson (json: any[]): string[] {
const depends = parseUuidDependencies(json);
depends.forEach((uuid, index): string => depends[index] = decodeUuid(uuid));
return depends;
}

private _descend$ (uuid: string, exclude: Record<string, any>, depends: string[]): void {
private _descend (uuid: string, exclude: Record<string, any>, depends: string[]): void {
const deps = this.getDeps(uuid);
for (let i = 0; i < deps.length; i++) {
const depend = deps[i];
if (!exclude[depend]) {
exclude[depend] = true;
depends.push(depend);
this._descend$(depend, exclude, depends);
this._descend(depend, exclude, depends);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions cocos/asset/asset-manager/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
*/
public _autoReleaseSetting: Record<string, boolean> = Object.create(null);
private _parseLoadResArgs$ = parseLoadResArgs;
private _parseLoadResArgs = parseLoadResArgs;

/**
* @deprecated since v3.5.0, this is an engine private interface that will be removed in the future.
Expand Down Expand Up @@ -148,7 +148,7 @@
* @param completeCallback - Callback invoked when all resources loaded
* @deprecated since v3.0, loader.load is deprecated, please use assetManager.loadRemote instead
*/
public load (res: string|string[]|Record<string, any>, progressCallback?: ((...args) => void)|null, completeCallback?: ((...args) => void)|null): void {

Check warning on line 151 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 156. Maximum allowed is 150
if (completeCallback === undefined) {
if (progressCallback !== undefined) {
completeCallback = progressCallback;
Expand Down Expand Up @@ -192,15 +192,15 @@
let asset = item;
const url = (requests[i] as Record<string, any>).url;
if (images.includes(asset)) {
factory.create(url, item, '.png', {}, (err, image): void => {

Check failure on line 195 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
asset = native[i] = image;
});
} else if (audios.includes(asset)) {
factory.create(url, item, '.mp3', {}, (err, audio): void => {

Check failure on line 199 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
asset = native[i] = audio;
});
}
assets.add(url, asset);

Check failure on line 203 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`

Check failure on line 203 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `Asset`
}
}
if (native.length > 1) {
Expand Down Expand Up @@ -236,7 +236,7 @@
* @deprecated since v3.0 loader.getItem is deprecated, please use assetManager.assets.get instead
*/
public getItem (id): { content: Asset | null | undefined; } | null {
return assetManager.assets.has(id) ? { content: assetManager.assets.get(id) } : null;

Check failure on line 239 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`

Check failure on line 239 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
}

/**
Expand Down Expand Up @@ -307,7 +307,7 @@
progressCallback?: LoadProgressCallback | LoadCompleteCallback<T>,
completeCallback?: LoadCompleteCallback<T>,
): any {
const { type: _type, onProgress, onComplete } = this._parseLoadResArgs$(
const { type: _type, onProgress, onComplete } = this._parseLoadResArgs(
type as any,
progressCallback as LoadProgressCallback,
completeCallback as LoadCompleteCallback<T>,
Expand Down Expand Up @@ -358,7 +358,7 @@
progressCallback?: LoadProgressCallback,
completeCallback?: LoadCompleteCallback<T[]>,
): void {
const { type: _type, onProgress, onComplete } = this._parseLoadResArgs$<LoadCompleteCallback<Asset[]>>(
const { type: _type, onProgress, onComplete } = this._parseLoadResArgs<LoadCompleteCallback<Asset[]>>(
type as any,
progressCallback as LoadProgressCallback,
completeCallback as LoadCompleteCallback<Asset[]>,
Expand Down Expand Up @@ -447,7 +447,7 @@
progressCallback?: LoadProgressCallback | LoadDirCompleteCallback<T>,
completeCallback?: LoadDirCompleteCallback<T>,
): any {
const { type: _type, onProgress, onComplete } = this._parseLoadResArgs$<LoadDirCompleteCallback<Asset>>(
const { type: _type, onProgress, onComplete } = this._parseLoadResArgs<LoadDirCompleteCallback<Asset>>(
type as any,
progressCallback as LoadProgressCallback,
completeCallback as LoadDirCompleteCallback<Asset>,
Expand Down Expand Up @@ -756,7 +756,7 @@
* @param asset - The asset or its url or its uuid
* @param autoRelease - Whether to release automatically during scene switch
*
* @deprecated since v3.0 loader.setAutoRelease is deprecated, if you want to prevent some asset from auto releasing, please use Asset.addRef instead

Check warning on line 759 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 153. Maximum allowed is 150
*/
public setAutoRelease (asset: Asset|string, autoRelease: boolean): void {
if (typeof asset === 'object') { asset = asset._uuid; }
Expand Down Expand Up @@ -793,7 +793,7 @@
* ```
* @param asset - The asset or its url or its uuid
* @param autoRelease - Whether to release automatically during scene switch
* @deprecated loader.setAutoReleaseRecursively is deprecated, if you want to prevent some asset from auto releasing, please use Asset.addRef instead

Check warning on line 796 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 153. Maximum allowed is 150
*/
public setAutoReleaseRecursively (asset: Asset|string, autoRelease: boolean): void {
if (typeof asset === 'object') { asset = asset._uuid; }
Expand Down Expand Up @@ -994,7 +994,7 @@
]);

const _autoRelease = releaseManager._autoRelease;
releaseManager._autoRelease = function (oldScene, newScene, persistNodes): void {

Check warning on line 997 in cocos/asset/asset-manager/deprecated.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
_autoRelease.call(releaseManager, oldScene, newScene, persistNodes);
const releaseSettings = loader._autoReleaseSetting;
const keys = Object.keys(releaseSettings);
Expand Down
Loading
Loading