editor.d.ts 32 KB

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