assetsmanager.d.ts 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. declare namespace RES {
  2. /**
  3. * Version control loading interface
  4. * @version Egret 2.4
  5. * @platform Web,Native
  6. * @includeExample extension/version/VersionControl.ts
  7. * @language en_US
  8. */
  9. /**
  10. * 版本控制加载的接口
  11. * @version Egret 2.4
  12. * @platform Web,Native
  13. * @includeExample extension/version/VersionControl.ts
  14. * @language zh_CN
  15. */
  16. interface IVersionController {
  17. /**
  18. * Get the version information data.<br/>
  19. * Before calling this method requires the application of any resource load, we recommend starting at the application entry class (Main) The first call processing. This method is only responsible for acquiring version information, is not responsible for downloaded resources.
  20. * @version Egret 2.4
  21. * @platform Web,Native
  22. * @language en_US
  23. */
  24. /**
  25. * 获取版本信息数据。<br/>
  26. * 这个方法的调用需要在应用程序进行任何资源加载之前,建议在应用程序的入口类(Main)的开始最先进行调用处理。此方法只负责获取版本信息,不负责资源的下载。
  27. * @version Egret 2.4
  28. * @platform Web,Native
  29. * @language zh_CN
  30. */
  31. init(): Promise<any>;
  32. /**
  33. * Get the actual URL of the resource file.<br/>
  34. * Because this method needs to be called to control the actual version of the URL have the original resource files were changed, so would like to get the specified resource file the actual URL.<br/>
  35. * In the development and debugging phase, this method will directly return value passed.
  36. * @param url Url used in the game
  37. * @returns Actual loaded url
  38. * @version Egret 2.4
  39. * @platform Web,Native
  40. * @language en_US
  41. */
  42. /**
  43. * 获取资源文件实际的URL地址。<br/>
  44. * 由于版本控制实际已经对原来的资源文件的URL进行了改变,因此想获取指定资源文件实际的URL时需要调用此方法。<br/>
  45. * 在开发调试阶段,这个方法会直接返回传入的参数值。
  46. * @param url 游戏中使用的url
  47. * @returns 实际加载的url
  48. * @version Egret 2.4
  49. * @platform Web,Native
  50. * @language zh_CN
  51. */
  52. getVirtualUrl(url: string): string;
  53. }
  54. /**
  55. * Manage version control class
  56. * @version Egret 2.4
  57. * @platform Web,Native
  58. * @event egret.Event.COMPLETE Version control loading is complete when thrown
  59. * @event egret.IOErrorEvent.IO_ERROR Version control failed to load when thrown
  60. * @includeExample extension/version/VersionControl.ts
  61. * @language en_US
  62. */
  63. /**
  64. * 管理版本控制的类
  65. * @version Egret 2.4
  66. * @platform Web,Native
  67. * @event egret.Event.COMPLETE 版本控制加载完成时抛出
  68. * @event egret.IOErrorEvent.IO_ERROR 版本控制加载失败时抛出
  69. * @includeExample extension/version/VersionControl.ts
  70. * @language zh_CN
  71. */
  72. interface VersionController extends IVersionController {
  73. }
  74. /**
  75. * @version Egret 2.4
  76. * @platform Web,Native
  77. */
  78. let VersionController: {
  79. /**
  80. * Constructor initialization
  81. * @language en_US
  82. */
  83. /**
  84. * 初始化构造函数
  85. * @language zh_CN
  86. */
  87. new (): VersionController;
  88. };
  89. }
  90. declare type ResourceRootSelector<T extends string> = () => T;
  91. declare type ResourceNameSelector = (file: string) => string;
  92. declare type ResourceMergerSelector = (file: string) => {
  93. path: string;
  94. alias: string;
  95. };
  96. declare module RES {
  97. /**
  98. * Get resource information through file path
  99. * @param path file path
  100. * @version Egret 5.2
  101. * @platform Web,Native
  102. * @language en_US
  103. */
  104. /**
  105. * 通过文件路径获取资源信息
  106. * @param path 文件路径
  107. * @version Egret 5.2
  108. * @platform Web,Native
  109. * @language zh_CN
  110. */
  111. function getResourceInfo(path: string): File | null;
  112. /**
  113. * @private
  114. */
  115. interface ResourceInfo {
  116. url: string;
  117. type: string;
  118. root: string;
  119. crc32?: string;
  120. size?: number;
  121. extra?: 1 | undefined;
  122. name: string;
  123. soundType?: string;
  124. scale9grid?: string;
  125. groupNames?: string[];
  126. promise?: Promise<any>;
  127. }
  128. /**
  129. * @private
  130. */
  131. interface Data {
  132. resourceRoot: string;
  133. mergeSelector: ResourceMergerSelector | null;
  134. fileSystem: FileSystem;
  135. groups: {
  136. [groupName: string]: string[];
  137. };
  138. alias: {
  139. [aliasName: string]: string;
  140. };
  141. loadGroup: string[];
  142. }
  143. /**
  144. * @class RES.ResourceConfig
  145. * @classdesc
  146. * @private
  147. */
  148. class ResourceConfig {
  149. config: Data;
  150. constructor();
  151. init(): Promise<any>;
  152. /**
  153. * 根据组名获取组加载项列表
  154. * @method RES.ResourceConfig#getGroupByName
  155. * @param name {string} 组名
  156. * @returns {Array<egret.ResourceItem>}
  157. */
  158. getGroupByName(name: string): ResourceInfo[];
  159. __temp__get__type__via__url(url_or_alias: string): string;
  160. getResourceWithSubkey(key: string): {
  161. r: ResourceInfo;
  162. key: string;
  163. subkey: string;
  164. } | null;
  165. getKeyByAlias(aliasName: string): string;
  166. getResource(path_or_alias: string): ResourceInfo | null;
  167. /**
  168. * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。
  169. * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。
  170. * @method RES.ResourceConfig#createGroup
  171. * @param name {string} 要创建的加载资源组的组名
  172. * @param keys {egret.Array<string>} 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项或一个资源组名。
  173. * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。
  174. * @returns {boolean}
  175. */
  176. createGroup(name: string, keys: Array<string>, override?: boolean): boolean;
  177. /**
  178. * 添加一个二级键名到配置列表。
  179. * @method RES.ResourceConfig#addSubkey
  180. * @param subkey {string} 要添加的二级键名
  181. * @param name {string} 二级键名所属的资源name属性
  182. */
  183. addSubkey(subkey: string, name: string): void;
  184. addAlias(alias: any, key: any): void;
  185. addResourceData(data: {
  186. name: string;
  187. type: string;
  188. url: string;
  189. root?: string;
  190. extra?: 1 | undefined;
  191. }): void;
  192. removeResourceData(data: {
  193. name: string;
  194. type?: string;
  195. url: string;
  196. root?: string;
  197. extra?: 1 | undefined;
  198. }): void;
  199. }
  200. }
  201. declare module RES {
  202. /**
  203. * @class RES.ResourceLoader
  204. * @classdesc
  205. * @private
  206. */
  207. class ResourceLoader {
  208. /**
  209. * 当前组加载的项总个数,key为groupName
  210. */
  211. private groupTotalDic;
  212. /**
  213. * 已经加载的项个数,key为groupName
  214. */
  215. private numLoadedDic;
  216. /**
  217. * 加载失败的组,key为groupName
  218. */
  219. private groupErrorDic;
  220. private retryTimesDic;
  221. maxRetryTimes: number;
  222. private reporterDic;
  223. private dispatcherDic;
  224. private failedList;
  225. private loadItemErrorDic;
  226. private errorDic;
  227. /**
  228. * 资源优先级队列,key为资源,value为优先级
  229. */
  230. private itemListPriorityDic;
  231. /**
  232. * 资源是否在加载
  233. */
  234. private itemLoadDic;
  235. private promiseHash;
  236. /**
  237. * 延迟加载队列,getResByUrl ,getResAsync等方法存储队列
  238. */
  239. private lazyLoadList;
  240. pushResItem(resInfo: ResourceInfo): Promise<any>;
  241. /**
  242. * 加载队列,存储组的队列
  243. */
  244. pushResGroup(list: ResourceInfo[], groupName: string, priority: number, reporter?: PromiseTaskReporter): Promise<any>;
  245. /**
  246. * 更新组的优先级顺序
  247. * @param list 存储数据的队列
  248. * @param priority 优先级
  249. */
  250. private updatelistPriority(list, priority);
  251. /**
  252. * 搜索单项资源的优先级
  253. * @param item 单项资源
  254. */
  255. private findPriorityInDic(item);
  256. private loadingCount;
  257. /**
  258. * 最大线程数目
  259. */
  260. thread: number;
  261. /**
  262. * 加载下一项资源,线程控制
  263. */
  264. private loadNextResource();
  265. /**
  266. * 加载单向资源
  267. */
  268. private loadSingleResource();
  269. /**
  270. * 获取下一个待加载项
  271. */
  272. private getOneResourceInfoInGroup();
  273. /**
  274. * 设置组的加载进度,同时返回当前组是否加载完成
  275. * @param groupName 组名
  276. * @param r 加载完成的资源
  277. */
  278. private setGroupProgress(groupName, r);
  279. /**
  280. * 加载组的最后一项,同时派发事件
  281. * @param groupName 组名
  282. * @param lastError 最后一项是否成功,此项为错误信息
  283. */
  284. private loadGroupEnd(groupName, lastError?);
  285. /**
  286. * 删除事件派发器,Promise的缓存,返回事件派发器
  287. * @param groupName 组名或是root+name
  288. */
  289. private deleteDispatcher(groupName);
  290. /**
  291. * 加载资源
  292. * @param r 资源信息
  293. * @param p 加载处理器
  294. */
  295. private loadResource(r, p?);
  296. /**
  297. * 释放资源
  298. * @param r 资源信息
  299. */
  300. unloadResource(r: ResourceInfo): boolean;
  301. }
  302. }
  303. declare module RES {
  304. }
  305. declare module RES {
  306. type GetResAsyncCallback = (value?: any, key?: string) => any;
  307. /**
  308. * Convert the file name of the resource to the Key value used in the project.
  309. * @param url Resource Name.
  310. * @returns The key value used in the project
  311. * @version Egret 5.2
  312. * @platform Web,Native
  313. * @language en_US
  314. */
  315. /**
  316. * 将资源的文件名称转换为项目中所使用的Key值。
  317. * 在加载合并图集的时候使用,例如图集加载A_json,需要加载对应A_png,这里就是转换的机制
  318. * 一般项目中无需更改,只有没有使用默认的key和文件对应的需要修改
  319. * @param url 资源名称。
  320. * @returns 项目中所用的key值
  321. * @version Egret 5.2
  322. * @platform Web,Native
  323. * @language zh_CN
  324. */
  325. function nameSelector(url: any): string;
  326. /**
  327. * Get the read type of the file.
  328. * When using getResByUrl does not specify the type of the read file, it will find the corresponding type according to this method.
  329. * File types not found are loaded by default in binary format
  330. * @param path file path.
  331. * @returns Processor type used to read the file
  332. * @version Egret 5.2
  333. * @platform Web,Native
  334. * @language en_US
  335. */
  336. /**
  337. * 获取文件的读取类型
  338. * 在使用getResByUrl没有指定读取文件的类型,会根据这个方法寻找对应的类型
  339. * 没有查找到的文件类型以二进制格式默认加载
  340. * @param path 文件路径
  341. * @returns 读取文件所用的Processor类型
  342. * @version Egret 5.2
  343. * @platform Web,Native
  344. * @language zh_CN
  345. */
  346. function typeSelector(path: string): string;
  347. /**
  348. * Conduct mapping injection with class definition as the value, Deprecated.
  349. * @deprecated
  350. * @see RES.processor.map
  351. * @language en_US
  352. */
  353. /**
  354. * 以类定义为值进行映射注入,已废弃。
  355. * @deprecated
  356. * @see RES.processor.map
  357. * @language zh_CN
  358. */
  359. function registerAnalyzer(type: string, analyzerClass: any): void;
  360. /**
  361. * Set whether it is compatible mode
  362. * When the value is true, the assetsManager will output the design of Res. When it is false, all the loaded resources will be returned as promises.
  363. * The default is false, run in strict assetsManager mode
  364. * @version Egret 5.2.9
  365. * @platform Web,Native
  366. * @language en_US
  367. */
  368. /**
  369. * 设置是否为兼容模式
  370. * 当值为true时,assetsManager会以Res的设计输出,当为false时候,所有的加载资源都会以promise的方式返回
  371. * 默认是false,以严格assetsManager方式运行
  372. * @version Egret 5.2.9
  373. * @platform Web,Native
  374. * @language zh_CN
  375. */
  376. function setIsCompatible(value: boolean): void;
  377. /**
  378. * Load configuration file and parse.
  379. * @param url The url address of the resource config
  380. * @param resourceRoot The root address of the resource config
  381. * @returns Promise
  382. * @see #setMaxRetryTimes
  383. * @version Egret 5.2
  384. * @platform Web,Native
  385. * @language en_US
  386. */
  387. /**
  388. * 加载配置文件并解析。
  389. * @param url 资源配置的url地址
  390. * @param resourceRoot 资源配置的根地址
  391. * @returns Promise
  392. * @see #setMaxRetryTimes
  393. * @version Egret 5.2
  394. * @platform Web,Native
  395. * @language zh_CN
  396. */
  397. function loadConfig(url: string, resourceRoot: string): Promise<void>;
  398. /**
  399. * Load a set of resources according to the group name.
  400. * @param name Group name to load the resource group.
  401. * @param priority Load priority can be negative, the default value is 0.
  402. * <br>A low priority group must wait for the high priority group to complete the end of the load to start, and the same priority group will be loaded at the same time.
  403. * @param reporter Resource group loading progress prompt
  404. * @see #setMaxRetryTimes
  405. * @version Egret 5.2
  406. * @platform Web,Native
  407. * @language en_US
  408. */
  409. /**
  410. * 根据组名加载一组资源。
  411. * @param name 要加载资源组的组名。
  412. * @param priority 加载优先级,可以为负数,默认值为 0。
  413. * <br>低优先级的组必须等待高优先级组完全加载结束才能开始,同一优先级的组会同时加载。
  414. * @param reporter 资源组的加载进度提示
  415. * @see #setMaxRetryTimes
  416. * @version Egret 5.2
  417. * @platform Web,Native
  418. * @language zh_CN
  419. */
  420. function loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise<void>;
  421. /**
  422. * Check whether a resource group has been loaded.
  423. * @param name Group name。
  424. * @returns Is loading or not.
  425. * @see #setMaxRetryTimes
  426. * @version Egret 5.2
  427. * @platform Web,Native
  428. * @language en_US
  429. */
  430. /**
  431. * 检查某个资源组是否已经加载完成。
  432. * @param name 组名。
  433. * @returns 是否正在加载。
  434. * @see #setMaxRetryTimes
  435. * @version Egret 5.2
  436. * @platform Web,Native
  437. * @language zh_CN
  438. */
  439. function isGroupLoaded(name: string): boolean;
  440. /**
  441. * A list of groups of loading is obtained according to the group name.
  442. * @param name Group name.
  443. * @returns The resource item array of group.
  444. * @see RES.ResourceItem
  445. * @see #setMaxRetryTimes
  446. * @version Egret 5.2
  447. * @platform Web,Native
  448. * @language en_US
  449. */
  450. /**
  451. * 根据组名获取组加载项列表。
  452. * @param name 组名。
  453. * @returns 加载项列表。
  454. * @see RES.ResourceItem
  455. * @see #setMaxRetryTimes
  456. * @version Egret 5.2
  457. * @platform Web,Native
  458. * @language zh_CN
  459. */
  460. function getGroupByName(name: string): Array<ResourceItem>;
  461. /**
  462. * Create a custom load resource group, note that this method is valid only after the resource configuration file is loaded.
  463. * <br>You can monitor the ResourceEvent.CONFIG_COMPLETE event to verify that the configuration is complete.
  464. * @param name Group name to create the load resource group.
  465. * @param keys To be included in the list of key keys, the corresponding configuration file in the name or sbuKeys property one or a resource group name.
  466. * @param override Is the default false for the same name resource group already exists.
  467. * @returns Create success or fail.
  468. * @see #setMaxRetryTimes
  469. * @version Egret 5.2
  470. * @platform Web,Native
  471. * @language en_US
  472. */
  473. /**
  474. * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。
  475. * <br>可以监听 ResourceEvent.CONFIG_COMPLETE 事件来确认配置加载完成。
  476. * @param name 要创建的加载资源组的组名。
  477. * @param keys 要包含的键名列表,key 对应配置文件里的 name 属性或 sbuKeys 属性的一项或一个资源组名。
  478. * @param override 是否覆盖已经存在的同名资源组,默认 false。
  479. * @returns 是否创建成功。
  480. * @see #setMaxRetryTimes
  481. * @version Egret 5.2
  482. * @platform Web,Native
  483. * @language zh_CN
  484. */
  485. function createGroup(name: string, keys: Array<string>, override?: boolean): boolean;
  486. /**
  487. * Check whether the configuration file contains the specified resources.
  488. * @param key A sbuKeys attribute or name property in a configuration file.
  489. * @returns Whether you have the specified resource
  490. * @see #setMaxRetryTimes
  491. * @version Egret 5.2
  492. * @platform Web,Native
  493. * @language en_US
  494. */
  495. /**
  496. * 检查配置文件里是否含有指定的资源。
  497. * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。
  498. * @returns 是否拥有指定资源
  499. * @see #setMaxRetryTimes
  500. * @version Egret 5.2
  501. * @platform Web,Native
  502. * @language zh_CN
  503. */
  504. function hasRes(key: string): boolean;
  505. /**
  506. * The synchronization method for obtaining the cache has been loaded with the success of the resource.
  507. * <br>The type of resource and the corresponding return value types are as follows:
  508. * <br>RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript primary object
  509. * <br>RES.ResourceItem.TYPE_IMAGE : img Html Object,or egret.BitmapData interface。
  510. * <br>RES.ResourceItem.TYPE_JSON : Object
  511. * <br>RES.ResourceItem.TYPE_SHEET : Object
  512. * <br> 1. If the incoming parameter is the name of the entire SpriteSheet is returned is {image1: Texture, "image2": Texture}.
  513. * <br> 2. If the incoming is "sheet.image1", the return is a single resource.
  514. * <br> 3. If the incoming is the name of the "image1" single resource, the return is a single resource.
  515. * But if there are two SpriteSheet in a single picture of the same name, the return of the image after the load.
  516. * <br>RES.ResourceItem.TYPE_SOUND : HtmlSound Html Object
  517. * <br>RES.ResourceItem.TYPE_TEXT : string
  518. * @param key A subKeys attribute or name property in a configuration file.
  519. * @see RES.ResourceItem
  520. * @see #setMaxRetryTimes
  521. * @version Egret 5.2
  522. * @platform Web,Native
  523. * @language en_US
  524. */
  525. /**
  526. * 同步方式获取缓存的已经加载成功的资源。
  527. * <br>资源类型和对应的返回值类型关系如下:
  528. * <br>RES.ResourceItem.TYPE_BIN : ArrayBuffer JavaScript 原生对象
  529. * <br>RES.ResourceItem.TYPE_IMAGE : img Html 对象,或者 egret.BitmapData 接口。
  530. * <br>RES.ResourceItem.TYPE_JSON : Object
  531. * <br>RES.ResourceItem.TYPE_SHEET : Object
  532. * <br> 1. 如果传入的参数是整个 SpriteSheet 的名称返回的是 {"image1":Texture,"image2":Texture} 这样的格式。
  533. * <br> 2. 如果传入的是 "sheet.image1",返回的是单个资源。
  534. * <br> 3. 如果传入的是 "image1" 单个资源的名称,返回的是单个资源。但是如果有两张 SpriteSheet 中有单个图片资源名称相同,返回的是后加载的那个图片资源。
  535. * <br>RES.ResourceItem.TYPE_SOUND : HtmlSound Html 对象
  536. * <br>RES.ResourceItem.TYPE_TEXT : string
  537. * @param key 对应配置文件里的 name 属性或 subKeys 属性的一项。
  538. * @see RES.ResourceItem
  539. * @see #setMaxRetryTimes
  540. * @version Egret 5.2
  541. * @platform Web,Native
  542. * @language zh_CN
  543. */
  544. function getRes(key: string): any;
  545. /**
  546. * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way.
  547. * @param key A sbuKeys attribute or name property in a configuration file.
  548. * @see #setMaxRetryTimes
  549. * @version Egret 5.2
  550. * @platform Web,Native
  551. * @language en_US
  552. */
  553. /**
  554. * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。
  555. * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。
  556. * @see #setMaxRetryTimes
  557. * @version Egret 5.2
  558. * @platform Web,Native
  559. * @language zh_CN
  560. */
  561. function getResAsync(key: string): Promise<any> | void;
  562. /**
  563. * Asynchronous mode to get the resources in the configuration. As long as the resources exist in the configuration file, you can get it in an asynchronous way.
  564. * @param key A sbuKeys attribute or name property in a configuration file.
  565. * @param compFunc Call back function. Example:compFunc(data,key):void.
  566. * @param thisObject This pointer of call back function.
  567. * @see #setMaxRetryTimes
  568. * @version Egret 5.2
  569. * @platform Web,Native
  570. * @language en_US
  571. */
  572. /**
  573. * 异步方式获取配置里的资源。只要是配置文件里存在的资源,都可以通过异步方式获取。
  574. * @param key 对应配置文件里的 name 属性或 sbuKeys 属性的一项。
  575. * @param compFunc 回调函数。示例:compFunc(data,key):void。
  576. * @param thisObject 回调函数的 this 引用。
  577. * @see #setMaxRetryTimes
  578. * @version Egret 5.2
  579. * @platform Web,Native
  580. * @language zh_CN
  581. */
  582. function getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise<any> | void;
  583. /**
  584. * Access to external resources through the full URL.
  585. * @param url The external path to load the file.
  586. * @param compFunc Call back function. Example:compFunc(data,url):void。
  587. * @param thisObject This pointer of call back function.
  588. * @param type File type (optional). Use the static constants defined in the ResourceItem class. If you do not set the file name extension.
  589. * @version Egret 5.2
  590. * @platform Web,Native
  591. * @language en_US
  592. */
  593. /**
  594. * 通过完整URL方式获取外部资源。
  595. * @param url 要加载文件的外部路径。
  596. * @param compFunc 回调函数。示例:compFunc(data,url):void。
  597. * @param thisObject 回调函数的 this 引用。
  598. * @param type 文件类型(可选)。请使用 ResourceItem 类中定义的静态常量。若不设置将根据文件扩展名生成。
  599. * @version Egret 5.2
  600. * @platform Web,Native
  601. * @language zh_CN
  602. */
  603. function getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise<any>;
  604. /**
  605. * Destroy a single resource file or a set of resources to the cache data, to return whether to delete success.
  606. * @param name Name attribute or resource group name of the load item in the configuration file.
  607. * @param force Destruction of a resource group when the other resources groups have the same resource situation whether the resources will be deleted, the default value true.
  608. * @returns Are successful destruction.
  609. * @see #setMaxRetryTimes
  610. * @version Egret 5.2
  611. * @platform Web,Native
  612. * @language en_US
  613. */
  614. /**
  615. * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。
  616. * @param name 配置文件中加载项的name属性或资源组名。
  617. * @param force 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值 true。
  618. * @see #setMaxRetryTimes
  619. * @returns 是否销毁成功。
  620. * @version Egret 5.2
  621. * @platform Web,Native
  622. * @language zh_CN
  623. */
  624. function destroyRes(name: string, force?: boolean): boolean;
  625. /**
  626. * Sets the maximum number of concurrent load threads, the default value is 4.
  627. * @param thread The number of concurrent loads to be set.
  628. * @see #setMaxRetryTimes
  629. * @version Egret 5.2
  630. * @platform Web,Native
  631. * @language en_US
  632. */
  633. /**
  634. * 设置最大并发加载线程数量,默认值是 4。
  635. * @param thread 要设置的并发加载数。
  636. * @see #setMaxRetryTimes
  637. * @version Egret 5.2
  638. * @platform Web,Native
  639. * @language zh_CN
  640. */
  641. function setMaxLoadingThread(thread: number): void;
  642. /**
  643. * Sets the number of retry times when the resource failed to load, and the default value is 3.
  644. * @param retry To set the retry count.
  645. * @includeExample extension/resource/Resource.ts
  646. * @version Egret 5.2
  647. * @platform Web,Native
  648. * @language en_US
  649. */
  650. /**
  651. * 设置资源加载失败时的重试次数,默认值是 3。
  652. * @param retry 要设置的重试次数。
  653. * @includeExample extension/resource/Resource.ts
  654. * @version Egret 5.2
  655. * @platform Web,Native
  656. * @language zh_CN
  657. */
  658. function setMaxRetryTimes(retry: number): void;
  659. /**
  660. * Add event listeners, reference ResourceEvent defined constants.
  661. * @param type Event name。
  662. * @param listener Listener functions for handling events. This function must accept the Event object as its only parameter, and can't return any results,
  663. * As shown in the following example: function (evt:Event):void can have any name.
  664. * @param thisObject The this object that is bound to a function.
  665. * @param useCapture Determine the listener is running on the capture or running on the target and the bubbling phase. Set useCapture to true,
  666. * then the listener in the capture phase processing events, but not in the target or the bubbling phase processing events.
  667. * If useCapture is false, then the listener only in the target or the bubbling phase processing events.
  668. * To listen for events in all three stages, please call addEventListener two times: once the useCapture is set to true, once the useCapture is set to false.
  669. * @param priority Event listener priority. Priority is specified by a 32 - bit integer with a symbol. The higher the number, the higher the priority.
  670. * All listeners with a priority for n will be processed before the -1 n listener.
  671. * If two or more listeners share the same priority, they are processed in accordance with the order of their added. The default priority is 0.
  672. * @see RES.ResourceEvent
  673. * @version Egret 5.2
  674. * @platform Web,Native
  675. * @language en_US
  676. */
  677. /**
  678. * 添加事件侦听器,参考 ResourceEvent 定义的常量。
  679. * @param type 事件的类型。
  680. * @param listener 处理事件的侦听器函数。此函数必须接受 Event 对象作为其唯一的参数,并且不能返回任何结果,
  681. * 如下面的示例所示: function(evt:Event):void 函数可以有任何名称。
  682. * @param thisObject 侦听函数绑定的 this 对象。
  683. * @param useCapture 确定侦听器是运行于捕获阶段还是运行于目标和冒泡阶段。如果将 useCapture 设置为 true,
  684. * 则侦听器只在捕获阶段处理事件,而不在目标或冒泡阶段处理事件。如果 useCapture 为 false,则侦听器只在目标或冒泡阶段处理事件。
  685. * 要在所有三个阶段都侦听事件,请调用 addEventListener 两次:一次将 useCapture 设置为 true,一次将 useCapture 设置为 false。
  686. * @param priority 事件侦听器的优先级。优先级由一个带符号的 32 位整数指定。数字越大,优先级越高。优先级为 n 的所有侦听器会在
  687. * 优先级为 n -1 的侦听器之前得到处理。如果两个或更多个侦听器共享相同的优先级,则按照它们的添加顺序进行处理。默认优先级为 0。
  688. * @see RES.ResourceEvent
  689. * @see #setMaxRetryTimes
  690. * @version Egret 5.2
  691. * @platform Web,Native
  692. * @language zh_CN
  693. */
  694. function addEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean, priority?: number): void;
  695. /**
  696. * Remove event listeners, reference ResourceEvent defined constants.
  697. * @param type Event name。
  698. * @param listener Listening function。
  699. * @param thisObject The this object that is bound to a function.
  700. * @param useCapture Is used to capture, and this property is only valid in the display list.
  701. * @version Egret 5.2
  702. * @platform Web,Native
  703. * @language en_US
  704. */
  705. /**
  706. * 移除事件侦听器,参考ResourceEvent定义的常量。
  707. * @param type 事件名。
  708. * @param listener 侦听函数。
  709. * @param thisObject 侦听函数绑定的this对象。
  710. * @param useCapture 是否使用捕获,这个属性只在显示列表中生效。
  711. * @version Egret 5.2
  712. * @platform Web,Native
  713. * @language zh_CN
  714. */
  715. function removeEventListener(type: string, listener: (event: egret.Event) => void, thisObject: any, useCapture?: boolean): void;
  716. /**
  717. * Adding a custom resource configuration.
  718. * @param data To add configuration.
  719. * @version Egret 5.2
  720. * @platform Web,Native
  721. * @language en_US
  722. */
  723. /**
  724. * 自定义添加一项资源配置。
  725. * @param data 要添加的配置。
  726. * @version Egret 5.2
  727. * @platform Web,Native
  728. * @language zh_CN
  729. */
  730. function $addResourceData(data: {
  731. name: string;
  732. type: string;
  733. url: string;
  734. }): void;
  735. /**
  736. * Returns the VersionController
  737. * @version Egret 5.2
  738. * @platform Web,Native
  739. * @language en_US
  740. */
  741. /**
  742. * 获得版本控制器.
  743. * @version Egret 5.2
  744. * @platform Web,Native
  745. * @language zh_CN
  746. */
  747. function getVersionController(): VersionController;
  748. /**
  749. * Register the VersionController
  750. * @param vcs The VersionController to register.
  751. * @version Egret 5.2
  752. * @platform Web,Native
  753. * @language en_US
  754. */
  755. /**
  756. * 注册版本控制器,通过RES模块加载资源时会从版本控制器获取真实url
  757. * @param vcs 注入的版本控制器。
  758. * @version Egret 5.2
  759. * @platform Web,Native
  760. * @language zh_CN
  761. */
  762. function registerVersionController(vcs: VersionController): void;
  763. /**
  764. * Convert the address of the loaded resource (via version controller conversion)
  765. * @param url path to the original resource
  766. * @returns converted address
  767. * @version Egret 5.2
  768. * @platform Web,Native
  769. * @language en_US
  770. */
  771. /**
  772. * 转换加载资源的地址(经过版本控制器的转换)
  773. * @param url 原始资源的路径
  774. * @returns 转换后的地址
  775. * @version Egret 5.2
  776. * @platform Web,Native
  777. * @language zh_CN
  778. */
  779. function getVirtualUrl(url: any): any;
  780. /**
  781. * @private
  782. */
  783. class Resource extends egret.EventDispatcher {
  784. vcs: VersionController;
  785. isVcsInit: boolean;
  786. constructor();
  787. registerVersionController(vcs: VersionController): void;
  788. /**
  789. * 开始加载配置
  790. * @method RES.loadConfig
  791. */
  792. loadConfig(): Promise<void>;
  793. /**
  794. * @private
  795. * 版本控制器加载后的加载配置
  796. */
  797. private normalLoadConfig;
  798. /**
  799. * 检查某个资源组是否已经加载完成
  800. * @method RES.isGroupLoaded
  801. * @param name {string}
  802. */
  803. isGroupLoaded(name: string): boolean;
  804. /**
  805. * 根据组名获取组加载项列表
  806. * @method RES.getGroupByName
  807. * @param name {string}
  808. */
  809. getGroupByName(name: string): Array<ResourceInfo>;
  810. /**
  811. * 根据组名加载一组资源
  812. * @method RES.loadGroup
  813. * @param name {string}
  814. * @param priority {number}
  815. */
  816. loadGroup(name: string, priority?: number, reporter?: PromiseTaskReporter): Promise<any>;
  817. private _loadGroup(name, priority?, reporter?);
  818. /**
  819. * 创建自定义的加载资源组,注意:此方法仅在资源配置文件加载完成后执行才有效。
  820. * 可以监听ResourceEvent.CONFIG_COMPLETE事件来确认配置加载完成。
  821. * @method RES.ResourceConfig#createGroup
  822. * @param name {string} 要创建的加载资源组的组名
  823. * @param keys {egret.Array<string>} 要包含的键名列表,key对应配置文件里的name属性或一个资源组名。
  824. * @param override {boolean} 是否覆盖已经存在的同名资源组,默认false。
  825. * @returns {boolean}
  826. */
  827. createGroup(name: string, keys: Array<string>, override?: boolean): boolean;
  828. /**
  829. * 检查配置文件里是否含有指定的资源
  830. * @method RES.hasRes
  831. * @param key {string} 对应配置文件里的name属性或subKeys属性的一项。
  832. * @returns {boolean}
  833. */
  834. hasRes(key: string): boolean;
  835. /**
  836. * 通过key同步获取资源
  837. * @method RES.getRes
  838. * @param key {string}
  839. * @returns {any}
  840. */
  841. getRes(resKey: string): any;
  842. /**
  843. * 通过key异步获取资源
  844. * @method RES.getResAsync
  845. * @param key {string}
  846. * @param compFunc {Function} 回调函数。示例:compFunc(data,url):void。
  847. * @param thisObject {any}
  848. */
  849. getResAsync(key: string): Promise<any>;
  850. getResAsync(key: string, compFunc: GetResAsyncCallback, thisObject: any): Promise<any>;
  851. /**
  852. * 通过url获取资源
  853. * @method RES.getResByUrl
  854. * @param url {string}
  855. * @param compFunc {Function}
  856. * @param thisObject {any}
  857. * @param type {string}
  858. */
  859. getResByUrl(url: string, compFunc?: Function, thisObject?: any, type?: string): Promise<any>;
  860. /**
  861. * 销毁单个资源文件或一组资源的缓存数据,返回是否删除成功。
  862. * @method RES.destroyRes
  863. * @param name {string} 配置文件中加载项的name属性或资源组名
  864. * @param force {boolean} 销毁一个资源组时其他资源组有同样资源情况资源是否会被删除,默认值true
  865. * @returns {boolean}
  866. */
  867. destroyRes(name: string, force?: boolean): boolean;
  868. /**
  869. * 设置最大并发加载线程数量,默认值是4.
  870. * @method RES.setMaxLoadingThread
  871. * @param thread {number} 要设置的并发加载数。
  872. */
  873. setMaxLoadingThread(thread: number): void;
  874. /**
  875. * 设置资源加载失败时的重试次数。
  876. * @param retry 要设置的重试次数。
  877. */
  878. setMaxRetryTimes(retry: number): void;
  879. addResourceData(data: {
  880. name: string;
  881. type: string;
  882. url: string;
  883. }): void;
  884. }
  885. }
  886. declare namespace RES {
  887. /**
  888. * Print the memory occupied by the picture.
  889. * @version Egret 5.2
  890. * @platform Web,Native
  891. * @language en_US
  892. */
  893. /**
  894. * 对文件路径的一些操作,针对的是 C:/A/B/C/D/example.ts这种格式
  895. * @version Egret 5.2
  896. * @platform Web,Native
  897. * @language zh_CN
  898. */
  899. namespace path {
  900. /**
  901. * Format the file path,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts"
  902. * @param filename Incoming file path
  903. * @version Egret 5.2
  904. * @platform Web,Native
  905. * @language en_US
  906. */
  907. /**
  908. * 格式化文件路径,"C:/A/B//C//D//example.ts"=>"C:/A/B/C/D/example.ts"
  909. * @param filename 传入的文件路径
  910. * @version Egret 5.2
  911. * @platform Web,Native
  912. * @language zh_CN
  913. */
  914. function normalize(filename: string): string;
  915. /**
  916. * Get the file name according to the file path, "C:/A/B/example.ts"=>"example.ts"
  917. * @param filename Incoming file path
  918. * @return File name
  919. * @version Egret 5.2
  920. * @platform Web,Native
  921. * @language en_US
  922. */
  923. /**
  924. * 根据文件路径得到文件名字,"C:/A/B/example.ts"=>"example.ts"
  925. * @param filename 传入的文件路径
  926. * @return 文件的名字
  927. * @version Egret 5.2
  928. * @platform Web,Native
  929. * @language zh_CN
  930. */
  931. function basename(filename: string): string;
  932. /**
  933. * The path to the folder where the file is located,"C:/A/B/example.ts"=>"C:/A/B"
  934. * @param filename Incoming file path
  935. * @return The address of the folder where the file is located
  936. * @version Egret 5.2
  937. * @platform Web,Native
  938. * @language en_US
  939. */
  940. /**
  941. * 文件所在文件夹路径,"C:/A/B/example.ts"=>"C:/A/B"
  942. * @param filename 传入的文件路径
  943. * @return 文件所在文件夹的地址
  944. * @version Egret 5.2
  945. * @platform Web,Native
  946. * @language zh_CN
  947. */
  948. function dirname(path: string): string;
  949. }
  950. }
  951. declare namespace RES {
  952. /**
  953. * @private
  954. */
  955. class NativeVersionController implements IVersionController {
  956. private versionInfo;
  957. init(): Promise<void>;
  958. getVirtualUrl(url: string): string;
  959. private getLocalData(filePath);
  960. }
  961. }
  962. declare module RES.processor {
  963. interface Processor {
  964. /**
  965. * Start loading a single resource
  966. * @param host Load the processor, you can use the processor to load resources, directly use http to get the resources back
  967. * @param resource Resource information
  968. * @version Egret 5.2
  969. * @platform Web,Native
  970. * @language en_US
  971. */
  972. /**
  973. * 开始加载单项资源
  974. * @param host 加载处理器,可以不使用这个处理器加载资源,直接用http获取资源返回即可
  975. * @param resource 资源的信息
  976. * @version Egret 5.2
  977. * @platform Web,Native
  978. * @language zh_CN
  979. */
  980. onLoadStart(host: ProcessHost, resource: ResourceInfo): Promise<any>;
  981. /**
  982. * Remove a single resource, usually call host.unload (resource);
  983. * @param host Load the processor
  984. * @param resource Resource information
  985. * @version Egret 5.2
  986. * @platform Web,Native
  987. * @language en_US
  988. */
  989. /**
  990. * 移除单项资源,一般调用host.unload(resource);
  991. * @param host 加载处理器
  992. * @param resource 资源的信息
  993. * @version Egret 5.2
  994. * @platform Web,Native
  995. * @language zh_CN
  996. */
  997. onRemoveStart(host: ProcessHost, resource: ResourceInfo): void;
  998. /**
  999. * Get the submap of the merged atlas
  1000. * @param host Load the processor
  1001. * @param resource Resource information
  1002. * @param key The key value of the resource
  1003. * @param subkey Collection of subset names
  1004. * @version Egret 5.2
  1005. * @platform Web,Native
  1006. * @language en_US
  1007. */
  1008. /**
  1009. * 获取合并图集的子图
  1010. * @param host 加载处理器
  1011. * @param resource 资源的信息
  1012. * @param key 资源的key值
  1013. * @param subkey 子集名称的集合
  1014. * @version Egret 5.2
  1015. * @platform Web,Native
  1016. * @language zh_CN
  1017. */
  1018. getData?(host: ProcessHost, resource: ResourceInfo, key: string, subkey: string): any;
  1019. }
  1020. /**
  1021. * Register the processor that loads the resource
  1022. * @param type Load resource type
  1023. * @param processor Loaded processor, an instance that implements the Processor interface
  1024. * @version Egret 5.2
  1025. * @platform Web,Native
  1026. * @language en_US
  1027. */
  1028. /**
  1029. * 注册加载资源的处理器
  1030. * @param type 加载资源类型
  1031. * @param processor 加载的处理器,一个实现Processor接口的实例
  1032. * @version Egret 5.2
  1033. * @platform Web,Native
  1034. * @language zh_CN
  1035. */
  1036. function map(type: string, processor: Processor): void;
  1037. /**
  1038. * @private
  1039. * @param url
  1040. * @param file
  1041. */
  1042. function getRelativePath(url: string, file: string): string;
  1043. var ImageProcessor: Processor;
  1044. var BinaryProcessor: Processor;
  1045. var TextProcessor: Processor;
  1046. var JsonProcessor: Processor;
  1047. var SoundProcessor: Processor;
  1048. }
  1049. declare module RES {
  1050. /**
  1051. * The events of resource loading.
  1052. * @version Egret 5.2
  1053. * @platform Web,Native
  1054. * @language en_US
  1055. */
  1056. /**
  1057. * 资源加载事件。
  1058. * @version Egret 5.2
  1059. * @platform Web,Native
  1060. * @language zh_CN
  1061. */
  1062. class ResourceEvent extends egret.Event {
  1063. /**
  1064. * Failure event for a load item.
  1065. * @version Egret 5.2
  1066. * @platform Web,Native
  1067. * @language en_US
  1068. */
  1069. /**
  1070. * 一个加载项加载失败事件。
  1071. * @version Egret 5.2
  1072. * @platform Web,Native
  1073. * @language zh_CN
  1074. */
  1075. static ITEM_LOAD_ERROR: string;
  1076. /**
  1077. * Configure file to load and parse the completion event. Note: if a configuration file is loaded, it will not be thrown out, and if you want to handle the configuration loading failure, monitor the CONFIG_LOAD_ERROR event.
  1078. * @version Egret 5.2
  1079. * @platform Web,Native
  1080. * @language en_US
  1081. */
  1082. /**
  1083. * 配置文件加载并解析完成事件。注意:若有配置文件加载失败,将不会抛出此事件,若要处理配置加载失败,请同时监听 CONFIG_LOAD_ERROR 事件。
  1084. * @version Egret 5.2
  1085. * @platform Web,Native
  1086. * @language zh_CN
  1087. */
  1088. static CONFIG_COMPLETE: string;
  1089. /**
  1090. * Configuration file failed to load.
  1091. * @version Egret 5.2
  1092. * @platform Web,Native
  1093. * @language en_US
  1094. */
  1095. /**
  1096. * 配置文件加载失败事件。
  1097. * @version Egret 5.2
  1098. * @platform Web,Native
  1099. * @language zh_CN
  1100. */
  1101. static CONFIG_LOAD_ERROR: string;
  1102. /**
  1103. * Delay load group resource loading progress event.
  1104. * @version Egret 5.2
  1105. * @platform Web,Native
  1106. * @language en_US
  1107. */
  1108. /**
  1109. * 延迟加载组资源加载进度事件。
  1110. * @version Egret 5.2
  1111. * @platform Web,Native
  1112. * @language zh_CN
  1113. */
  1114. static GROUP_PROGRESS: string;
  1115. /**
  1116. * Delay load group resource to complete event. Note: if you have a resource item loading failure, the event will not be thrown, if you want to handle the group load failure, please listen to the GROUP_LOAD_ERROR event.
  1117. * @version Egret 5.2
  1118. * @platform Web,Native
  1119. * @language en_US
  1120. */
  1121. /**
  1122. * 延迟加载组资源加载完成事件。注意:若组内有资源项加载失败,将不会抛出此事件,若要处理组加载失败,请同时监听 GROUP_LOAD_ERROR 事件。
  1123. * @version Egret 5.2
  1124. * @platform Web,Native
  1125. * @language zh_CN
  1126. */
  1127. static GROUP_COMPLETE: string;
  1128. /**
  1129. * Delayed load group resource failed event.
  1130. * @version Egret 5.2
  1131. * @platform Web,Native
  1132. * @language en_US
  1133. */
  1134. /**
  1135. * 延迟加载组资源加载失败事件。
  1136. * @version Egret 5.2
  1137. * @platform Web,Native
  1138. * @language zh_CN
  1139. */
  1140. static GROUP_LOAD_ERROR: string;
  1141. /**
  1142. * Creates an Event object to pass as a parameter to event listeners.
  1143. * @param type The type of the event, accessible as Event.type.
  1144. * @param bubbles Determines whether the Event object participates in the bubbling stage of the event flow. The default value is false.
  1145. * @param cancelable Determines whether the Event object can be canceled. The default values is false.
  1146. * @version Egret 5.2
  1147. * @platform Web,Native
  1148. * @private
  1149. * @language en_US
  1150. */
  1151. /**
  1152. * 创建一个作为参数传递给事件侦听器的 Event 对象。
  1153. * @param type 事件的类型,可以作为 Event.type 访问。
  1154. * @param bubbles 确定 Event 对象是否参与事件流的冒泡阶段。默认值为 false。
  1155. * @param cancelable 确定是否可以取消 Event 对象。默认值为 false。
  1156. * @version Egret 5.2
  1157. * @platform Web,Native
  1158. * @private
  1159. * @language zh_CN
  1160. */
  1161. constructor(type: string, bubbles?: boolean, cancelable?: boolean);
  1162. /**
  1163. * File number that has been loaded.
  1164. * @version Egret 5.2
  1165. * @platform Web,Native
  1166. * @language en_US
  1167. */
  1168. /**
  1169. * 已经加载的文件数。
  1170. * @version Egret 5.2
  1171. * @platform Web,Native
  1172. * @language zh_CN
  1173. */
  1174. itemsLoaded: number;
  1175. /**
  1176. * Total file number to load.
  1177. * @version Egret 5.2
  1178. * @platform Web,Native
  1179. * @language en_US
  1180. */
  1181. /**
  1182. * 要加载的总文件数。
  1183. * @version Egret 5.2
  1184. * @platform Web,Native
  1185. * @language zh_CN
  1186. */
  1187. itemsTotal: number;
  1188. /**
  1189. * Resource group name.
  1190. * @version Egret 5.2
  1191. * @platform Web,Native
  1192. * @language en_US
  1193. */
  1194. /**
  1195. * 资源组名。
  1196. * @version Egret 5.2
  1197. * @platform Web,Native
  1198. * @language zh_CN
  1199. */
  1200. groupName: string;
  1201. /**
  1202. * An item of information that is finished by the end of a load.
  1203. * @version Egret 5.2
  1204. * @platform Web,Native
  1205. * @language en_US
  1206. */
  1207. /**
  1208. * 一次加载项加载结束的项信息对象。
  1209. * @version Egret 5.2
  1210. * @platform Web,Native
  1211. * @language zh_CN
  1212. */
  1213. resItem: ResourceItem;
  1214. }
  1215. }
  1216. declare module RES {
  1217. /**
  1218. * Resource term. One of the resources arrays in resource.json.
  1219. * @version Egret 5.2
  1220. * @platform Web,Native
  1221. * @language en_US
  1222. */
  1223. /**
  1224. * 资源项。对应 resource.json 中 resources 数组中的一项。
  1225. * @version Egret 5.2
  1226. * @platform Web,Native
  1227. * @language zh_CN
  1228. */
  1229. namespace ResourceItem {
  1230. /**
  1231. * XML file.
  1232. * @version Egret 5.2
  1233. * @platform Web,Native
  1234. * @language en_US
  1235. */
  1236. /**
  1237. * XML 文件。
  1238. * @version Egret 5.2
  1239. * @platform Web,Native
  1240. * @language zh_CN
  1241. */
  1242. const TYPE_XML: string;
  1243. /**
  1244. * Picture file.
  1245. * @version Egret 5.2
  1246. * @platform Web,Native
  1247. * @language en_US
  1248. */
  1249. /**
  1250. * 图片文件。
  1251. * @version Egret 5.2
  1252. * @platform Web,Native
  1253. * @language zh_CN
  1254. */
  1255. const TYPE_IMAGE: string;
  1256. /**
  1257. * Binary file.
  1258. * @version Egret 5.2
  1259. * @platform Web
  1260. * @language en_US
  1261. */
  1262. /**
  1263. * 二进制文件。
  1264. * @version Egret 5.2
  1265. * @platform Web
  1266. * @language zh_CN
  1267. */
  1268. const TYPE_BIN: string;
  1269. /**
  1270. * Text file.
  1271. * @version Egret 5.2
  1272. * @platform Web,Native
  1273. * @language en_US
  1274. */
  1275. /**
  1276. * 文本文件。
  1277. * @version Egret 5.2
  1278. * @platform Web,Native
  1279. * @language zh_CN
  1280. */
  1281. const TYPE_TEXT: string;
  1282. /**
  1283. * JSON file.
  1284. * @version Egret 5.2
  1285. * @platform Web,Native
  1286. * @language en_US
  1287. */
  1288. /**
  1289. * JSON 文件。
  1290. * @version Egret 5.2
  1291. * @platform Web,Native
  1292. * @language zh_CN
  1293. */
  1294. const TYPE_JSON: string;
  1295. /**
  1296. * SpriteSheet file.
  1297. * @version Egret 5.2
  1298. * @platform Web,Native
  1299. * @language en_US
  1300. */
  1301. /**
  1302. * SpriteSheet 文件。
  1303. * @version Egret 5.2
  1304. * @platform Web,Native
  1305. * @language zh_CN
  1306. */
  1307. const TYPE_SHEET: string;
  1308. /**
  1309. * BitmapTextSpriteSheet file.
  1310. * @version Egret 5.2
  1311. * @platform Web,Native
  1312. * @language en_US
  1313. */
  1314. /**
  1315. * BitmapTextSpriteSheet 文件。
  1316. * @version Egret 5.2
  1317. * @platform Web,Native
  1318. * @language zh_CN
  1319. */
  1320. const TYPE_FONT: string;
  1321. /**
  1322. * Sound file.
  1323. * @version Egret 5.2
  1324. * @platform Web,Native
  1325. * @language en_US
  1326. */
  1327. /**
  1328. * 声音文件。
  1329. * @version Egret 5.2
  1330. * @platform Web,Native
  1331. * @language zh_CN
  1332. */
  1333. const TYPE_SOUND: string;
  1334. function convertToResItem(r: ResourceInfo): ResourceItem;
  1335. }
  1336. interface ResourceItem extends ResourceInfo {
  1337. /**
  1338. * Name of resource term.
  1339. * @version Egret 5.2
  1340. * @platform Web,Native
  1341. * @language en_US
  1342. */
  1343. /**
  1344. * 加载项名称。
  1345. * @version Egret 5.2
  1346. * @platform Web,Native
  1347. * @language zh_CN
  1348. */
  1349. name: string;
  1350. /**
  1351. * URL of resource term.
  1352. * @version Egret 5.2
  1353. * @platform Web,Native
  1354. * @language en_US
  1355. */
  1356. /**
  1357. * 要加载的文件地址。
  1358. * @version Egret 5.2
  1359. * @platform Web,Native
  1360. * @language zh_CN
  1361. */
  1362. url: string;
  1363. /**
  1364. * Type of resource term.
  1365. * @version Egret 5.2
  1366. * @platform Web,Native
  1367. * @language en_US
  1368. */
  1369. /**
  1370. * 加载项文件类型。
  1371. * @version Egret 5.2
  1372. * @platform Web,Native
  1373. * @language zh_CN
  1374. */
  1375. type: string;
  1376. /**
  1377. * The raw data object to be referenced.
  1378. * @version Egret 5.2
  1379. * @platform Web,Native
  1380. * @language en_US
  1381. */
  1382. /**
  1383. * 被引用的原始数据对象。
  1384. * @version Egret 5.2
  1385. * @platform Web,Native
  1386. * @language zh_CN
  1387. */
  1388. data: ResourceInfo;
  1389. crc32?: string;
  1390. size?: number;
  1391. soundType?: string;
  1392. }
  1393. }
  1394. declare module RES {
  1395. /**
  1396. * assetsManager underlying storage resource information
  1397. * @version Egret 5.2
  1398. * @platform Web,Native
  1399. * @language en_US
  1400. */
  1401. /**
  1402. * assetsManager底层存储资源信息
  1403. * @version Egret 5.2
  1404. * @platform Web,Native
  1405. * @language zh_CN
  1406. */
  1407. interface File {
  1408. url: string;
  1409. type: string;
  1410. name: string;
  1411. root: string;
  1412. }
  1413. /**
  1414. * @private
  1415. */
  1416. interface FileSystem {
  1417. addFile(data: {
  1418. name: string;
  1419. type: string;
  1420. url: string;
  1421. root?: string;
  1422. extra?: 1 | undefined;
  1423. }): any;
  1424. getFile(filename: string): File | null;
  1425. profile(): void;
  1426. removeFile(filename: string): any;
  1427. }
  1428. }
  1429. declare module RES {
  1430. /**
  1431. * Print the memory occupied by the picture.
  1432. * @version Egret 5.2
  1433. * @platform Web,Native
  1434. * @language en_US
  1435. */
  1436. /**
  1437. * 打印图片所占内存
  1438. * @version Egret 5.2
  1439. * @platform Web,Native
  1440. * @language zh_CN
  1441. */
  1442. function profile(): void;
  1443. /**
  1444. * @private
  1445. */
  1446. interface ProcessHost {
  1447. state: {
  1448. [index: string]: number;
  1449. };
  1450. resourceConfig: ResourceConfig;
  1451. load: (resource: ResourceInfo, processor?: string | processor.Processor) => Promise<any>;
  1452. unload: (resource: ResourceInfo) => void;
  1453. save: (rexource: ResourceInfo, data: any) => void;
  1454. get: (resource: ResourceInfo) => any;
  1455. remove: (resource: ResourceInfo) => void;
  1456. }
  1457. /**
  1458. * @private
  1459. */
  1460. class ResourceManagerError extends Error {
  1461. static errorMessage: {
  1462. 1001: string;
  1463. 1002: string;
  1464. 2001: string;
  1465. 2002: string;
  1466. 2003: string;
  1467. 2004: string;
  1468. 2005: string;
  1469. 2006: string;
  1470. };
  1471. /**
  1472. * why instanceof e != ResourceManagerError ???
  1473. * see link : https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  1474. */
  1475. private __resource_manager_error__;
  1476. constructor(code: number, replacer?: Object, replacer2?: Object);
  1477. }
  1478. }
  1479. declare namespace RES {
  1480. /**
  1481. * Resource group loading progress prompt
  1482. * @version Egret 5.2
  1483. * @platform Web,Native
  1484. * @language en_US
  1485. */
  1486. /**
  1487. * 资源组的加载进度提示
  1488. * @version Egret 5.2
  1489. * @platform Web,Native
  1490. * @language zh_CN
  1491. */
  1492. interface PromiseTaskReporter {
  1493. /**
  1494. * Progress callback, asynchronous execution, load number and order have nothing to do
  1495. * @param current The number of currently loaded
  1496. * @param total Total resources required in the current resource bundle
  1497. * @param resItem currently loading resource information
  1498. * @version Egret 5.2
  1499. * @platform Web,Native
  1500. * @language en_US
  1501. */
  1502. /**
  1503. * 进度回调,异步执行,加载数目和顺序无关
  1504. * @param current 当前已经加载数目
  1505. * @param total 当前资源包内需要资源总数
  1506. * @param resItem 当前加载资源信息
  1507. * @version Egret 5.2
  1508. * @platform Web,Native
  1509. * @language zh_CN
  1510. */
  1511. onProgress?(current: number, total: number, resItem: ResourceInfo | undefined): void;
  1512. }
  1513. }