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

[3.6.0] export AssetsManager to native #12254

Merged
merged 2 commits into from
Jul 28, 2022

Conversation

PatriceJiang
Copy link
Contributor

Re: #11135

Changelog

  • export AssetManager to native

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.

@PatriceJiang PatriceJiang added this to the V3.6 milestone Jul 28, 2022
@PatriceJiang PatriceJiang requested a review from minggo July 28, 2022 09:54
@github-actions
Copy link

github-actions bot commented Jul 28, 2022

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -37316,8 +37316,272 @@
             requestURL: string;
             storagePath: string;
             identifier: string;
         };
+        export class EventAssetsManager {
+            getEventCode(): number;
+            getCURLECode(): number;
+            getCURLMCode(): number;
+            getMessage(): string;
+            getAssetId(): string;
+            getAssetsManagerEx(): AssetsManager;
+            isResuming(): boolean;
+            getPercent(): number;
+            getPercentByFile(): number;
+            getDownloadedBytes(): number;
+            getTotalBytes(): number;
+            getDownloadedFiles(): number;
+            getTotalFiles(): number;
+            constructor(eventName: string, manager: AssetsManager, code: number, assetId: string, message: string, curleCode: number, curlmCode: number);
+        }
+        export interface ManifestAsset {
+            md5: string;
+            path: string;
+            compressed: boolean;
+            size: number;
+            downloadState: number;
+        }
+        export class Manifest {
+            /**
+             * @en Check whether the version informations have been fully loaded
+             * @zh 检查是否已加载版本信息
+             */
+            isVersionLoaded(): boolean;
+            /**
+             * @en Check whether the manifest have been fully loaded
+             * @zh 检查是否已加载 manifest
+             */
+            isLoaded(): boolean;
+            /**
+             * @en Gets remote package url.
+             * @zh 获取远程包的 URL
+             */
+            getPackageUrl(): string;
+            /**
+             * @en Gets remote manifest file url.
+             * @zh 获取远程 manifest 文件的 URL
+             */
+            getManifestFileUrl(): string;
+            /**
+             * @en Gets remote version file url.
+             * @zh 获取远程版本文件的 URL
+             */
+            getVersionFileUrl(): string;
+            /**
+             * @en Gets manifest version.
+             * @zh 获取远程 manifest 文件的版本
+             */
+            getVersion(): string;
+            /**
+             * @en Get the search paths list related to the Manifest.
+             * @zh 返回 Manifest 相关的搜索路径
+             */
+            getSearchPaths(): string[];
+            /**
+             * @en Get the manifest root path, normally it should also be the local storage path.
+             * @zh 获取 manifest 的根路径, 一般为本地存储目录.
+             */
+            getManifestRoot(): string;
+            constructor(content: string, manifestRoot: string);
+            constructor(manifestUrl: string);
+            /**
+             * @en Parse the manifest file information into this manifest
+             * @zh 解析 manifest 文件
+             * @param manifestUrl @en Url of the local manifest @zh 文件路径
+             */
+            parseFile(manifestUrl: string): void;
+            /**
+             * @en Parse the manifest from json string into this manifest
+             * @zh 解析 manifest 的 JSON 文件
+             * @param content @en Json string content @zh JSON 文本
+             * @param manifestRoot @en The root path of the manifest file (It should be local path,
+             * so that we can find assets path relative to the root path) @zh manifest 根路径
+             */
+            parseJSONString(content: string, manifestRoot: string): void;
+            /**
+             * @en Get whether the manifest is being updating
+             * @en 是否在更新
+             * @return @en Updating or not @zh 是否在更新
+             */
+            isUpdating(): boolean;
+            /**
+             * @en Set whether the manifest is being updating
+             * @zh 设置更新状态
+             * @param updating @en Updating or not @zh 是否更新
+             */
+            setUpdating(updating: boolean): void;
+        }
+        export class AssetsManager {
+            /**
+             * @en Create function for creating a new AssetsManagerEx
+             *
+             * warning   The cached manifest in your storage path have higher priority and will be searched first,
+             * only if it doesn't exist, AssetsManagerEx will use the given manifestUrl.
+             *
+             * @zh 创建 AssetManager
+             *
+             * @param manifestUrl  @en The url for the local manifest file @zh manifest 文件路径
+             * @param storagePath  @en The storage path for downloaded assets @zh 存储路径
+             */
+            static create(manifestUrl: string, storagePath: string): AssetsManager;
+            constructor(manifestUrl: string, storagePath: string, handle: (arg1: string, arg2: string) => number);
+            constructor(manifestUrl: string, storagePath: string);
+            /**
+             * @en  Check out if there is a new version of manifest.
+             * You may use this method before updating, then let user determine whether
+             * he wants to update resources.
+             * @zh 检查更新
+             */
+            checkUpdate(): void;
+            /**
+             * @en Prepare the update process, this will cleanup download process flags,
+             * fill up download units with temporary manifest or remote manifest
+             * @zh 准备更新
+             */
+            prepareUpdate(): void;
+            /**
+             * @en Update with the current local manifest.
+             * @zh 执行更新
+             */
+            update(): void;
+            /**
+             * @en Reupdate all failed assets under the current AssetsManagerEx context
+             * @zh 重新下载之前失败的资源
+             */
+            downloadFailedAssets(): void;
+            /**
+             * @en Gets the current update state.
+             * @zh 返回当前的状态码
+             */
+            getState(): number;
+            /**
+             * @en Gets storage path.
+             * @zh 获取存储路径
+             */
+            getStoragePath(): string;
+            /**
+             * @en Function for retrieving the local manifest object
+             * @zh 获取本地 manifest 路径
+             */
+            getLocalManifest(): Manifest;
+            /**
+             * @en Load a local manifest from url.
+             *
+             * You can only manually load local manifest when the update state is UNCHECKED, it will fail once the update process is began.
+             *
+             * This API will do the following things:
+             *
+             * 1. Reset storage path
+             *
+             * 2. Set local storage
+             *
+             * 3. Search for cached manifest and compare with the local manifest
+             *
+             * 4. Init temporary manifest and remote manifest
+             *
+             * If successfully load the given local manifest and inited other manifests, it will return true, otherwise it will return false
+             * @zh 加载本地的 manifest
+             * @param manifestUrl  @en The local manifest url @zh manifest 路径
+             */
+            loadLocalManifest(manifestUrl: string): boolean;
+            /**
+             * @en Load a custom local manifest object, the local manifest must be loaded already.
+             *
+             * You can only manually load local manifest when the update state is UNCHECKED, it will fail once the update process is began.
+             *
+             * This API will do the following things:
+             *
+             * 1. Reset storage path
+             *
+             * 2. Set local storage
+             *
+             * 3. Search for cached manifest and compare with the local manifest
+             *
+             * 4. Init temporary manifest and remote manifest
+             *
+             * If successfully load the given local manifest and inited other manifests, it will return true, otherwise it will return false
+             * @zh 加载本地的 manifest
+             *
+             * @param localManifest @en The local manifest object to be set @zh manifest 对象
+             *
+             * @param storagePath  @en The local storage path @zh 存储路径
+             */
+            loadLocalManifest(localManifest: Manifest, storagePath: string): boolean;
+            /**
+             * @en Function for retrieving the remote manifest object
+             * @zh 获取远程的 manifest 对象
+             */
+            getRemoteManifest(): Manifest;
+            /**
+             * @en Load a custom remote manifest object, the manifest must be loaded already.
+             *
+             * You can only manually load remote manifest when the update state is UNCHECKED and local manifest is already inited,
+             * it will fail once the update process is began.
+             * @zh 加载自定义i的远程 manifest 对象
+             * @param remoteManifest   @en The remote manifest object to be set @zh manifest 对象
+             */
+            loadRemoteManifest(remoteManifest: Manifest): boolean;
+            /**
+             * @en Gets whether the current download is resuming previous unfinished job,
+             * this will only be available after READY_TO_UPDATE state,
+             * under unknown states it will return false by default.
+             * @zh 是否在恢复状态
+             */
+            isResuming(): boolean;
+            /**
+             * @en Gets the total byte size to be downloaded of the update, this will only be available
+             * after READY_TO_UPDATE state, under unknown states it will return 0 by default.
+             * @zh 需要下载或者更新的总字节数
+             */
+            getTotalBytes(): number;
+            /**
+             * @en Gets the current downloaded byte size of the update, this will only be available
+             * after READY_TO_UPDATE state, under unknown states it will return 0 by default.
+             * @zh 已下载的字节数
+             */
+            getDownloadedBytes(): number;
+            /**
+             * @en Gets the total files count to be downloaded of the update, this will only be available
+             *  after READY_TO_UPDATE state, under unknown states it will return 0 by default.
+             * @zh 需要下载的总的文件数目
+             */
+            getTotalFiles(): number;
+            /**
+             * @en Gets the current downloaded files count of the update, this will only be available
+             *  after READY_TO_UPDATE state, under unknown states it will return 0 by default.
+             * @zh 已下载的文件数目
+             */
+            getDownloadedFiles(): number;
+            /**
+             * @en Function for retrieving the max concurrent task count
+             * @zh 下载的最大并发数
+             */
+            getMaxConcurrentTask(): number;
+            /**
+             * @en Function for setting the max concurrent task count
+             * @zh 设置下载的最大并发数目
+             */
+            setMaxConcurrentTask(max: number): void;
+            /**
+             * @en Set the handle function for comparing manifests versions
+             * @zh 设置版本比对函数
+             *
+             * @param handle  @en  The compare function @zh 比较函数
+             */
+            setVersionCompareHandle(handle: (arg1: string, arg2: string) => number): void;
+            /**
+             * @en Set the verification function for checking whether downloaded asset is correct, e.g. using md5 verification
+             * @zh 设置内容校验函数
+             * @param callback  @en The verify callback function @zh 校验函数
+             */
+            setVerifyCallback(callback: (arg1: string, arg: ManifestAsset) => number): void;
+            /**
+             * @en Set the event callback for receiving update process events
+             * @zh 设置更新事件处理回调
+             * @param callback @en The event callback function @zh 事件处理回调
+             */
+            setEventCallback(callback: (arg: EventAssetsManager) => void): void;
+        }
         /**
          * @en DownloaderHints @zh 下载任务的配置接口
          * @param countOfMaxProcessingTasks
          * @en Maximum number of download tasks processed at the same time, optional, default is 6

@minggo minggo merged commit 9feca1c into cocos:v3.6.0 Jul 28, 2022
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.

2 participants