editor.d.ts 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. /**
  2. * Cocos Creator 编辑器命名空间
  3. * @author 陈皮皮(ifaswind)
  4. * @version 20200727
  5. * @see https://gitee.com/ifaswind/eazax-ccc/blob/master/declarations/editor.d.ts
  6. */
  7. declare namespace Editor {
  8. /**
  9. * Log the normal message and show on the console. The method will send ipc message editor:console-log to all windows.
  10. * @param args Whatever arguments the message needs
  11. */
  12. export function log(...args: any): void;
  13. /**
  14. * Log the normal message and show on the console. The method will send ipc message editor:console-log to all windows.
  15. * @param args Whatever arguments the message needs
  16. */
  17. export function info(...args: any): void;
  18. /**
  19. * Log the warnning message and show on the console, it also shows the call stack start from the function call it. The method will send ipc message editor:console-warn to all windows.
  20. * @param args Whatever arguments the message needs
  21. */
  22. export function warn(...args: any): void;
  23. /**
  24. * Log the error message and show on the console, it also shows the call stack start from the function call it. The method will sends ipc message editor:console-error to all windows.
  25. * @param args Whatever arguments the message needs
  26. */
  27. export function error(...args: any): void;
  28. /**
  29. * Log the success message and show on the console The method will send ipc message editor:console-success to all windows.
  30. * @param args Whatever arguments the message needs
  31. */
  32. export function success(...args: any): void;
  33. /**
  34. * Require the module by Editor.url. This is good for module exists in package, since the absolute path of package may be variant in different machine.
  35. * @param url
  36. */
  37. export function require(url: string): any;
  38. /**
  39. * Returns the file path (if it is registered in custom protocol) or url (if it is a known public protocol).
  40. * @param url
  41. * @param encode
  42. */
  43. export function url(url: string, encode?: string): string;
  44. namespace RendererProcess {
  45. /**
  46. * AssetDB singleton class in renderer process, you can access the instance with `Editor.assetdb`.
  47. */
  48. class AssetDB {
  49. /**
  50. * The remote AssetDB instance of main process, same as `Editor.remote.assetdb`.
  51. */
  52. readonly remote: Remote;
  53. /**
  54. * The library path.
  55. */
  56. readonly library: string;
  57. /**
  58. * Reveal given url in native file system.
  59. * @param url
  60. */
  61. explore(url: string): string;
  62. /**
  63. * Reveal given url's library file in native file system.
  64. * @param url
  65. */
  66. exploreLib(url: string): string;
  67. /**
  68. * Get native file path by url.
  69. * @param url
  70. * @param cb The callback function.
  71. */
  72. queryPathByUrl(url: string, cb?: (err: any, path: any) => void): void;
  73. /**
  74. * Get uuid by url.
  75. * @param url
  76. * @param cb The callback function.
  77. */
  78. queryUuidByUrl(url: string, cb?: (err: any, uuid: any) => void): void;
  79. /**
  80. * Get native file path by uuid.
  81. * @param uuid
  82. * @param cb The callback function.
  83. */
  84. queryPathByUuid(uuid: string, cb?: (err: any, path: any) => void): void;
  85. /**
  86. * Get asset url by uuid.
  87. * @param uuid
  88. * @param cb The callback function.
  89. */
  90. queryUrlByUuid(uuid: string, cb?: (err: any, url: any) => void): void;
  91. /**
  92. * Get asset info by uuid.
  93. * @param uuid
  94. * @param cb The callback function.
  95. */
  96. queryInfoByUuid(uuid: string, cb?: (err: any, info: any) => void): void;
  97. /**
  98. * Get meta info by uuid.
  99. * @param uuid
  100. * @param cb The callback function.
  101. */
  102. queryMetaInfoByUuid(uuid: string, cb?: (err: any, info: any) => void): void;
  103. /**
  104. * Query all assets from asset-db.
  105. * @param cb The callback function.
  106. */
  107. deepQuery(cb?: (err: any, results: any[]) => void): void;
  108. /**
  109. * Query assets by url pattern and asset-type.
  110. * @param pattern The url pattern.
  111. * @param assetTypes The asset type(s).
  112. * @param cb The callback function.
  113. */
  114. queryAssets(pattern: string, assetTypes: string | string[], cb?: (err: any, results: any[]) => void): void;
  115. /**
  116. * Import files outside asset-db to specific url folder.
  117. * @param rawfiles Rawfile path list.
  118. * @param destUrl The url of dest folder.
  119. * @param showProgress Show progress or not.
  120. * @param cb The callbak function.
  121. */
  122. import(rawfiles: string[], destUrl: string, showProgress?: boolean, cb?: (err: any, result: any) => void): void;
  123. /**
  124. * Create asset in specific url by sending string data to it.
  125. * @param uuid
  126. * @param metaJson
  127. * @param cb the callback function.
  128. */
  129. create(url: string, data: string, cb?: (err: any, result: any) => void): void;
  130. /**
  131. * Move asset from src to dest.
  132. * @param srcUrl
  133. * @param destUrl
  134. * @param showMessageBox
  135. */
  136. move(srcUrl: string, destUrl: string, showMessageBox?: boolean): void;
  137. /**
  138. * Delete assets by url list.
  139. * @param urls
  140. */
  141. delete(urls: string[]): void;
  142. /**
  143. * Save specific asset by sending string data.
  144. * @param url
  145. * @param data
  146. * @param cb the callback function.
  147. */
  148. saveExists(url: string, data: string, cb?: (err: any, result: any) => void): void;
  149. /**
  150. * Create or save assets by sending string data. If the url is already existed, it will be changed with new data. The behavior is same with method saveExists. Otherwise, a new asset will be created. The behavior is same with method create.
  151. * @param url
  152. * @param data
  153. * @param cb the callback function.
  154. */
  155. createOrSave(url: string, data: string, cb?: (err: any, result: any) => void): void;
  156. /**
  157. * Save specific meta by sending meta's json string.
  158. * @param uuid
  159. * @param metaJson
  160. * @param cb the callback function.
  161. */
  162. saveMeta(uuid: string, metaJson: string, cb?: (err: any, result: any) => void): void;
  163. /**
  164. * Refresh the assets in url, and return the results.
  165. * @param url
  166. * @param cb
  167. */
  168. refresh(url: string, cb?: (err: any, results: any[]) => void): void;
  169. }
  170. }
  171. namespace MainProcess {
  172. /**
  173. * AssetDB singleton class in main process, you can access the instance with `Editor.assetdb`.
  174. */
  175. class AssetDB {
  176. /**
  177. * Return uuid by url. If uuid not found, it will return null.
  178. * @param url
  179. */
  180. urlToUuid(url: string): string;
  181. /**
  182. * Return uuid by file path. If uuid not found, it will return null.
  183. * @param fspath
  184. */
  185. fspathToUuid(fspath: string): string;
  186. /**
  187. * Return file path by uuid. If file path not found, it will return null.
  188. * @param url
  189. */
  190. uuidToFspath(url: string): string;
  191. /**
  192. * Return url by uuid. If url not found, it will return null.
  193. * @param uuid
  194. */
  195. uuidToUrl(uuid: string): string;
  196. /**
  197. * Return url by file path. If file path not found, it will return null.
  198. * @param fspath
  199. */
  200. fspathToUrl(fspath: string): string;
  201. /**
  202. * Return file path by url. If url not found, it will return null.
  203. * @param url
  204. */
  205. urlToFspath(url: string): string;
  206. /**
  207. * Check existance by url.
  208. * @param url
  209. */
  210. exists(url: string): string;
  211. /**
  212. * Check existance by uuid.
  213. * @param uuid
  214. */
  215. existsByUuid(uuid: string): string;
  216. /**
  217. * Check existance by path.
  218. * @param fspath
  219. */
  220. existsByPath(fspath: string): string;
  221. /**
  222. * Check whether asset for a given url is a sub asset.
  223. * @param url
  224. */
  225. isSubAsset(url: string): boolean;
  226. /**
  227. * Check whether asset for a given uuid is a sub asset.
  228. * @param uuid
  229. */
  230. isSubAssetByUuid(uuid: string): boolean;
  231. /**
  232. * Check whether asset for a given path is a sub asset.
  233. * @param fspath
  234. */
  235. isSubAssetByPath(fspath: string): boolean;
  236. /**
  237. * Check whether asset contains sub assets for a given url.
  238. * @param url
  239. */
  240. containsSubAssets(url: string): boolean;
  241. /**
  242. * Check whether asset contains sub assets for a given uuid.
  243. * @param uuid
  244. */
  245. containsSubAssetsByUuid(uuid: string): boolean;
  246. /**
  247. * Check whether asset contains sub assets for a given path.
  248. * @param fspath
  249. */
  250. containsSubAssetsByPath(fspath: string): boolean;
  251. /**
  252. * Return asset info by a given url.
  253. * @param url
  254. */
  255. assetInfo(url: string): AssetInfo;
  256. /**
  257. * Return asset info by a given uuid.
  258. * @param uuid
  259. */
  260. assetInfoByUuid(uuid: string): AssetInfo;
  261. /**
  262. * Return asset info by a given file path.
  263. * @param fspath
  264. */
  265. assetInfoByPath(fspath: string): AssetInfo;
  266. /**
  267. * Return all sub assets info by url if the url contains sub assets.
  268. * @param url
  269. */
  270. subAssetInfos(url: string): AssetInfo[];
  271. /**
  272. * Return all sub assets info by uuid if the uuid contains sub assets.
  273. * @param uuid
  274. */
  275. subAssetInfosByUuid(uuid: string): AssetInfo[];
  276. /**
  277. * Return all sub assets info by path if the path contains sub assets.
  278. * @param fspath
  279. */
  280. subAssetInfosByPath(fspath: string): AssetInfo[];
  281. /**
  282. * Return meta instance by a given url.
  283. * @param url
  284. */
  285. loadMeta(url: string): MetaBase;
  286. /**
  287. * Return meta instance by a given uuid.
  288. * @param uuid
  289. */
  290. loadMetaByUuid(uuid: string): MetaBase;
  291. /**
  292. * Return meta instance by a given path.
  293. * @param fspath
  294. */
  295. loadMetaByPath(fspath: string): MetaBase;
  296. /**
  297. * Return whether a given url is reference to a mount.
  298. * @param url
  299. */
  300. isMount(url: string): boolean;
  301. /**
  302. * Return whether a given path is reference to a mount.
  303. * @param fspath
  304. */
  305. isMountByPath(fspath: string): boolean;
  306. /**
  307. * Return whether a given uuid is reference to a mount.
  308. * @param uuid
  309. */
  310. isMountByUuid(uuid: string): boolean;
  311. /**
  312. * Return mount info by url.
  313. * @param url
  314. */
  315. mountInfo(url: string): MountInfo;
  316. /**
  317. * Return mount info by uuid.
  318. * @param uuid
  319. */
  320. mountInfoByUuid(uuid: string): MountInfo;
  321. /**
  322. * Return mount info by path.
  323. * @param fspath
  324. */
  325. mountInfoByPath(fspath: string): MountInfo;
  326. /**
  327. * Mount a directory to assetdb, and give it a name. If you don't provide a name, it will mount to root.
  328. * @param path file system path.
  329. * @param mountPath the mount path (relative path).
  330. * @param opts options.
  331. * @param opts.hide if the mount hide in assets browser.
  332. * @param opts.virtual if this is a virtual mount point.
  333. * @param opts.icon icon for the mount.
  334. * @param cb a callback function.
  335. * @example Editor.assetdb.mount('path/to/mount', 'assets', function (err) {
  336. // mounted, do something ...
  337. });
  338. */
  339. mount(path: string, mountPath: string, opts: { hide: object, vitural: object, icon: object }, cb?: (err: any) => void): void;
  340. /**
  341. * Attach the specified mount path.
  342. * @param mountPath the mount path (relative path).
  343. * @param cb a callback function.
  344. * @example Editor.assetdb.attachMountPath('assets', function (err, results) {
  345. // mount path attached, do something ...
  346. // results are the assets created
  347. });
  348. */
  349. attachMountPath(mountPath: string, cb?: (err: any, results: any[]) => void): void;
  350. /**
  351. * Unattach the specified mount path.
  352. * @param mountPath the mount path (relative path).
  353. * @param cb a callback function.
  354. * @example Editor.assetdb.unattachMountPath('assets', function (err, results) {
  355. // mount path unattached, do something ...
  356. // results are the assets deleted
  357. });
  358. */
  359. unattachMountPath(mountPath: string, cb?: (err: any, results: any[]) => void): void;
  360. /**
  361. * Unmount by name.
  362. * @param mountPath the mount path.
  363. * @param cb a callback function.
  364. * @example Editor.assetdb.unmount('assets', function (err) {
  365. // unmounted, do something ...
  366. });
  367. */
  368. unmount(mountPath: string, cb?: (err: any) => void): void;
  369. /**
  370. * Init assetdb, it will scan the mounted directories, and import unimported assets.
  371. * @param cb a callback function.
  372. * @example Editor.assetdb.init(function (err, results) {
  373. // assets that imported during init
  374. results.forEach(function (result) {
  375. // result.uuid
  376. // result.parentUuid
  377. // result.url
  378. // result.path
  379. // result.type
  380. });
  381. });
  382. */
  383. init(cb?: (err: any, results: any[]) => void): void;
  384. /**
  385. * Refresh the assets in url, and return the results.
  386. * @param url
  387. * @param cb
  388. */
  389. refresh(url: string, cb?: Function): void;
  390. /**
  391. * deepQuery
  392. * @param cb
  393. * @example Editor.assetdb.deepQuery(function (err, results) {
  394. results.forEach(function (result) {
  395. // result.name
  396. // result.extname
  397. // result.uuid
  398. // result.type
  399. // result.isSubAsset
  400. // result.children - the array of children result
  401. });
  402. });
  403. */
  404. deepQuery(cb?: Function): void;
  405. /**
  406. * queryAssets
  407. * @param pattern The url pattern.
  408. * @param assetTypes The asset type(s).
  409. * @param cb The callback function.
  410. */
  411. queryAssets(pattern: string, assetTypes: string[], cb?: (err: Error, results: any[]) => void): void;
  412. /**
  413. * queryMetas
  414. * @param pattern The url pattern.
  415. * @param type The asset type.
  416. * @param cb The callback function.
  417. */
  418. queryMetas(pattern: string, type: string, cb?: (err: Error, results: any[]) => void): void;
  419. /**
  420. * move
  421. * @param srcUrl The url pattern.
  422. * @param destUrl The asset type.
  423. * @param cb The callback function.
  424. */
  425. move(srcUrl: string, destUrl: string, cb?: (err: Error, results: any[]) => void): void;
  426. /**
  427. * delete
  428. * @param urls
  429. * @param cb
  430. */
  431. delete(urls: string[], cb?: (err: Error, results: any[]) => void): void;
  432. /**
  433. * Create asset at url with data.
  434. * @param url
  435. * @param data
  436. * @param cb
  437. */
  438. create(url: string, data: string, cb?: (err: Error, results: any[]) => void): void;
  439. /**
  440. * Save data to the exists asset at url.
  441. * @param url
  442. * @param data
  443. * @param cb
  444. */
  445. saveExists(url: string, data: string, cb?: (err: Error, meta: any) => void): void;
  446. /**
  447. * Import raw files to url
  448. * @param rawfiles
  449. * @param url
  450. * @param cb
  451. */
  452. import(rawfiles: string[], url: string, cb?: (err: Error, results: any[]) => void): void;
  453. /**
  454. * Overwrite the meta by loading it through uuid.
  455. * @param uuid
  456. * @param jsonString
  457. * @param cb
  458. */
  459. saveMeta(uuid: string, jsonString: string, cb?: (err: Error, meta: any) => void): void;
  460. /**
  461. * Exchange uuid for two assets.
  462. * @param urlA
  463. * @param urlB
  464. * @param cb
  465. */
  466. exchangeUuid(urlA: string, urlB: string, cb?: (err: Error, results: any[]) => void): void;
  467. /**
  468. * Clear imports.
  469. * @param url
  470. * @param cb
  471. */
  472. clearImports(url: string, cb?: (err: Error, results: any[]) => void): void;
  473. /**
  474. * Register meta type.
  475. * @param extname
  476. * @param folder Whether it's a folder type.
  477. * @param metaCtor
  478. */
  479. register(extname: string, folder: boolean, metaCtor: object): void;
  480. /**
  481. * Unregister meta type.
  482. * @param metaCtor
  483. */
  484. unregister(metaCtor: object): void;
  485. /**
  486. * Get the relative path from mount path to the asset by fspath.
  487. * @param fspath
  488. */
  489. getRelativePath(fspath: string): string;
  490. /**
  491. * Get the backup file path of asset file.
  492. * @param filePath
  493. */
  494. getAssetBackupPath(filePath: string): string;
  495. }
  496. }
  497. // interface AssetInfo {
  498. // uuid: string;
  499. // path: string;
  500. // url: string;
  501. // type: string;
  502. // isSubAsset: boolean;
  503. // }
  504. // interface AssetInfo {
  505. // assetType: string;
  506. // id: string;
  507. // isSubAsset?: boolean;
  508. // name: string;
  509. // subAssetTypes: string;
  510. // }
  511. interface MetaBase {
  512. ver: string;
  513. uuid: string;
  514. }
  515. interface MountInfo {
  516. path: string;
  517. name: string;
  518. type: string;
  519. }
  520. interface Metas {
  521. asset: string[];
  522. folder: string[];
  523. mount: string[];
  524. 'custom-asset': string[];
  525. 'native-asset': string[];
  526. 'animation-clip': string[];
  527. 'audio-clip': string[];
  528. 'bitmap-font': string[];
  529. }
  530. class Remote {
  531. readonly isClosing: boolean;
  532. readonly lang: string;
  533. readonly isNode: boolean;
  534. readonly isElectron: boolean;
  535. readonly isNative: boolean;
  536. readonly isPureWeb: boolean;
  537. readonly isRendererProcess: boolean;
  538. readonly isMainProcess: boolean;
  539. readonly isDarwin: boolean;
  540. readonly isWin32: boolean;
  541. readonly isRetina: boolean;
  542. readonly frameworkPath: string;
  543. readonly dev: boolean;
  544. readonly logfile: string;
  545. readonly themePaths: string[];
  546. readonly theme: string;
  547. readonly showInternalMount: boolean;
  548. readonly metas: Metas;
  549. readonly metaBackupPath: string;
  550. readonly assetBackupPath: string;
  551. readonly libraryPath: string;
  552. readonly importPath: string;
  553. readonly externalMounts: any;
  554. readonly mountsWritable: string;
  555. readonly assetdb: MainProcess.AssetDB;
  556. readonly assetdbInited: boolean;
  557. readonly sceneList: string[];
  558. }
  559. /**
  560. * Remote 实例
  561. */
  562. export const remote: Remote;
  563. /**
  564. * AssetDB 实例
  565. */
  566. export const assetdb: MainProcess.AssetDB;
  567. }
  568. interface AssetInfo {
  569. uuid?: string;
  570. path?: string;
  571. url?: string;
  572. type?: string;
  573. isSubAsset?: boolean;
  574. assetType?: string;
  575. id?: string;
  576. name?: string;
  577. subAssetTypes?: string;
  578. }
  579. declare module Editor.Project {
  580. /**
  581. * Absolute path for current open project.
  582. */
  583. export const path: string;
  584. export const name: string;
  585. export const id: string;
  586. }
  587. declare module Editor.Builder {
  588. /**
  589. *
  590. * @param eventName The name of the event
  591. * @param callback The event callback
  592. */
  593. export function on(eventName: string, callback: (options: BuildOptions, cb: Function) => void): void;
  594. /**
  595. *
  596. * @param eventName The name of the event
  597. * @param callback The event callback
  598. */
  599. export function once(eventName: string, callback: (options: BuildOptions, cb: Function) => void): void;
  600. /**
  601. *
  602. * @param eventName The name of the event
  603. * @param callback The event callback
  604. */
  605. export function removeListener(eventName: string, callback: Function): void;
  606. }
  607. declare module Editor.Scene {
  608. /**
  609. *
  610. * @param packageName
  611. * @param method
  612. * @param cb
  613. */
  614. export function callSceneScript(packageName: string, method: string, cb: (err: Error, msg: any) => void): void;
  615. }
  616. declare module Editor.Panel {
  617. /**
  618. * Open a panel via panelID.
  619. * @param panelID The panel ID
  620. * @param argv
  621. */
  622. export function open(panelID: string, argv?: object): void;
  623. /**
  624. * Close a panel via panelID.
  625. * @param panelID The panel ID
  626. */
  627. export function close(panelID: string): void;
  628. /**
  629. * Find panel frame via panelID.
  630. * @param panelID The panel ID
  631. */
  632. export function find(panelID: string): void;
  633. /**
  634. * Extends a panel.
  635. * @param proto
  636. */
  637. export function extend(proto: object): void;
  638. }
  639. declare module Editor.Selection {
  640. /**
  641. * Select item with its id.
  642. * @param type
  643. * @param id
  644. * @param unselectOthers
  645. * @param confirm
  646. */
  647. export function select(type: string, id: string, unselectOthers?: boolean, confirm?: boolean): void;
  648. /**
  649. * Unselect item with its id.
  650. * @param type
  651. * @param id
  652. * @param confirm
  653. */
  654. export function unselect(type: string, id: string, confirm?: boolean): void;
  655. /**
  656. * Hover item with its id. If id is null, it means hover out.
  657. * @param type
  658. * @param id
  659. */
  660. export function hover(type: string, id: string): string;
  661. /**
  662. *
  663. * @param type
  664. */
  665. export function clear(type: string): void;
  666. /**
  667. *
  668. * @param type
  669. */
  670. export function curActivate(type: string): string[];
  671. /**
  672. *
  673. * @param type
  674. */
  675. export function curGlobalActivate(type: string): string[];
  676. /**
  677. *
  678. * @param type
  679. */
  680. export function curSelection(type: string): string[];
  681. /**
  682. *
  683. * @param items
  684. * @param mode 'top-level', 'deep' and 'name'
  685. * @param func
  686. */
  687. export function filter(items: string[], mode: string, func: Function): string[];
  688. }
  689. declare module Editor.Ipc {
  690. /**
  691. * Send message with ...args to main process asynchronously. It is possible to add a callback as the last or the 2nd last argument to receive replies from the IPC receiver.
  692. * @param message Ipc message.
  693. * @param args Whatever arguments the message needs.
  694. * @param callback You can specify a callback function to receive IPC reply at the last or the 2nd last argument.
  695. * @param timeout You can specify a timeout for the callback at the last argument. If no timeout specified, it will be 5000ms.
  696. */
  697. export function sendToMain(message: string, ...args?: any, callback?: Function, timeout?: number): void;
  698. /**
  699. * Send message with ...args to panel defined in renderer process asynchronously. It is possible to add a callback as the last or the 2nd last argument to receive replies from the IPC receiver.
  700. * @param panelID Panel ID.
  701. * @param message Ipc message.
  702. * @param args Whatever arguments the message needs.
  703. * @param callback You can specify a callback function to receive IPC reply at the last or the 2nd last argument.
  704. * @param timeout You can specify a timeout for the callback at the last argument. If no timeout specified, it will be 5000ms.
  705. */
  706. export function sendToPanel(panelID: string, message: string, ...args?: any, callback?: Function, timeout?: number): void;
  707. /**
  708. * Send message with ...args to all opened window and to main process asynchronously.
  709. * @param message Ipc message.
  710. * @param args Whatever arguments the message needs.
  711. * @param option You can indicate the last argument as an IPC option by Editor.Ipc.option({...}).
  712. */
  713. export function sendToAll(message: string, ...args?: any, option?: object): void;
  714. /**
  715. * Send message with ...args to main process synchronized and return a result which is responded from main process.
  716. * @param message Ipc message.
  717. * @param args Whatever arguments the message needs.
  718. */
  719. export function sendToMainSync(message: string, ...args?: any): void;
  720. /**
  721. * Send message with ...args to main process by package name and the short name of the message.
  722. * @param pkgName Package name.
  723. * @param message Ipc message.
  724. * @param args Whatever arguments the message needs.
  725. */
  726. export function sendToPackage(pkgName: string, message: string, ...args?: any): void;
  727. }
  728. declare module Editor.UI {
  729. export module Setting {
  730. /**
  731. * Control the default step for float point input element. Default is 0.1.
  732. * @param value
  733. */
  734. export function stepFloat(value: number): void;
  735. /**
  736. * Control the default step for integer input element. Default is 1.
  737. * @param value
  738. */
  739. export function stepInt(value: number): void;
  740. /**
  741. * Control the step when shift key press down. Default is 10.
  742. * @param value
  743. */
  744. export function shiftStep(value: number): void;
  745. }
  746. export module DragDrop {
  747. export function start(e: any, t: any): void;
  748. export function end(): void;
  749. export function updateDropEffect(e: any, t: any);
  750. export function type(e: any);
  751. export function filterFiles(e: any);
  752. export function items(dataTransfer: DataTransfer): AssetInfo[];
  753. export function getDragIcon(e: any);
  754. export function options(e: any);
  755. export function getLength(e: any): number;
  756. export const dragging: boolean;
  757. }
  758. }
  759. declare interface BuildOptions {
  760. actualPlatform: string;
  761. android: { packageName: string };
  762. 'android-instant': {
  763. REMOTE_SERVER_ROOT: string;
  764. host: string;
  765. packageName: string;
  766. pathPattern: string;
  767. recordPath: string;
  768. scheme: string;
  769. skipRecord: boolean;
  770. }
  771. apiLevel: string;
  772. appABIs: string[];
  773. appBundle: boolean;
  774. buildPath: string;
  775. buildScriptsOnly: boolean;
  776. debug: string;
  777. dest: string;
  778. embedWebDebugger: boolean;
  779. encryptJs: boolean;
  780. excludeScenes: string[];
  781. excludedModules: string[];
  782. 'fb-instant-games': object;
  783. inlineSpriteFrames: boolean;
  784. inlineSpriteFrames_native: boolean;
  785. ios: { packageName: string };
  786. mac: { packageName: string };
  787. md5Cache: boolean;
  788. mergeStartScene: boolean;
  789. optimizeHotUpdate: boolean;
  790. orientation: {
  791. landscapeLeft: boolean;
  792. landscapeRight: boolean;
  793. portrait: boolean;
  794. upsideDown: boolean;
  795. };
  796. packageName: string;
  797. platform: string;
  798. previewHeight: number;
  799. previewWidth: number;
  800. scenes: string[];
  801. sourceMaps: boolean;
  802. startScene: string;
  803. template: string;
  804. title: string;
  805. useDebugKeystore: boolean;
  806. vsVersion: string;
  807. webOrientation: boolean;
  808. win32: object;
  809. xxteaKey: string;
  810. zipCompressJs: string;
  811. project: string;
  812. projectName: string;
  813. debugBuildWorker: boolean;
  814. /**
  815. * 从 v2.4 开始,options 中不再提供 buildResults,而是提供了一个 bundles 数组。
  816. */
  817. buildResults: BuildResults;
  818. bundles: bundle[];
  819. }
  820. declare class BuildResults {
  821. /**
  822. * Returns true if the asset contains in the build.
  823. * 指定的 uuid 资源是否包含在构建资源中
  824. * @param uuid 需要检测的资源 uuid
  825. * @param assertContains 不包含时是否打印报错信息
  826. */
  827. containsAsset(uuid: string, assertContains: boolean): boolean;
  828. /**
  829. * Returns the uuids of all assets included in the build.
  830. * 返回构建资源中包含的所有资源的 uuid
  831. */
  832. getAssetUuids(): string[];
  833. /**
  834. * Return the uuids of assets which are dependencies of the input, also include all indirect dependencies.
  835. * The list returned will not include the input uuid itself.
  836. * 获取指定 uuid 资源中的所有依赖资源,返回的列表中不包含自身
  837. * @param uuid 指定的 uuid 资源
  838. */
  839. getDependencies(uuid: string): string[];
  840. /**
  841. * Get type of asset defined in the engine.
  842. * You can get the constructor of an asset by using `cc.js.getClassByName(type)`.
  843. * 获取指定 uuid 的资源在引擎中定义的资源类型
  844. * 同时可以使用 cc.js.getClassByName(type) 进行获取资源的构造函数
  845. * @param uuid 指定的 uuid 资源
  846. */
  847. getAssetType(uuid: string): string;
  848. /**
  849. * Get the path of the specified native asset such as texture. Returns empty string if not found.
  850. * 获取指定 uuid 资源(例如纹理)的存放路径(如果找不到,则返回空字符串)
  851. * @param uuid 指定的 uuid 资源
  852. */
  853. getNativeAssetPath(uuid: string): string;
  854. /**
  855. * 获取指定 uuid 资源(例如纹理)的所有存放路径(如果找不到,则返回空数组)
  856. * 例如:需要获取纹理多种压缩格式的存放资源路径时,即可使用该函数
  857. * @param uuid - 指定的 uuid 资源
  858. */
  859. getNativeAssetPaths(uuid: string): string[];
  860. }
  861. interface bundle {
  862. /**
  863. * bundle 的根目录
  864. */
  865. root: string;
  866. /**
  867. * bundle 的输出目录
  868. */
  869. dest: string;
  870. /**
  871. * 脚本的输出目录
  872. */
  873. scriptDest: string;
  874. /**
  875. * bundle 的名称
  876. */
  877. name: string;
  878. /**
  879. * bundle 的优先级
  880. */
  881. priority: number;
  882. /**
  883. * bundle 中包含的场景
  884. */
  885. scenes: string[];
  886. /**
  887. * bundle 的压缩类型
  888. */
  889. compressionType: 'subpackage' | 'normal' | 'none' | 'merge_all_json' | 'zip';
  890. /**
  891. * bundle 所构建出来的所有资源
  892. */
  893. buildResults: BuildResults;
  894. /**
  895. * bundle 的版本信息,由 config 生成
  896. */
  897. version: string;
  898. /**
  899. * bundle 的 config.json 文件
  900. */
  901. config: any;
  902. /**
  903. * bundle 是否是远程包
  904. */
  905. isRemote: boolean;
  906. }
  907. declare module Editor.Utils {
  908. module UuidUtils {
  909. /**
  910. * 压缩后的 uuid 可以减小保存时的尺寸,但不能做为文件名(因为无法区分大小写并且包含非法字符)。
  911. * 默认将 uuid 的后面 27 位压缩成 18 位,前 5 位保留下来,方便调试。
  912. * 如果启用 min 则将 uuid 的后面 30 位压缩成 20 位,前 2 位保留不变。
  913. * @param uuid
  914. * @param min
  915. */
  916. export function compressUuid(uuid: string, min?: boolean): string;
  917. export function compressHex(hexString: string, reservedHeadLength?: number): string;
  918. export function decompressUuid(str: string): string;
  919. export function isUuid(str: string): boolean;
  920. export function uuid(): string;
  921. }
  922. }