duktape.d.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Duktape built-ins
  2. // extracted from lib.d.ts
  3. declare interface Console {
  4. log(message?: any, ...optionalParams: any[]): void;
  5. }
  6. declare var console: Console;
  7. // Duktape require isn't recognized as a function, but can be used as one
  8. declare function require(filename: string): any;
  9. /*
  10. * Timer API. These routines are available if you ```import "AtomicEventLoop"```
  11. */
  12. /**
  13. * schedules a function to be called on the next frame. Must require("AtomicEventLoop") in main.js to use.
  14. * Muat require("AtomicEventLoop") or import "AtomicEventLoop" in main.js to use.
  15. * @method
  16. * @param {function} func the Function to call
  17. * @returns {number} the id of the callback to be used in cancelAnimationFrame in order to cancel the call
  18. */
  19. declare function requestAnimationFrame(step: any): number;
  20. /**
  21. * stops a previously queued call to requestAnimationFrame
  22. * Muat require("AtomicEventLoop") or import "AtomicEventLoop" in main.js to use.
  23. * @method
  24. * @param {number} call_id the id of the timer that was created via requestAnimationFrame
  25. */
  26. declare function cancelAnimationFrame(call_id: number);
  27. /**
  28. * schedules a function to be called after a certain number of milliseconds
  29. * Muat require("AtomicEventLoop") or import "AtomicEventLoop" in main.js to use.
  30. * @method
  31. * @param {function} func the Function to call
  32. * @param {number} delay the number of milliseconds
  33. * @param {any} [args] A comma separated list of parameters to pass to func
  34. * @returns {number} the id of the timer to be used in clearTimeout in order to cancel the timeout
  35. */
  36. declare function setTimeout(func: number, delay: number, ...args): number;
  37. /**
  38. * stops a previously queued timeout.
  39. * Muat require("AtomicEventLoop") or import "AtomicEventLoop" in main.js to use.
  40. * @method
  41. * @param {number} timer_id the id of the timer that was created via setTimeout
  42. */
  43. declare function clearTimeout(timer_id: number);
  44. /**
  45. * schedules a function to be called after the end of the current update cycle. SetImmediate timers are processed FIFO
  46. * Muat require("AtomicEventLoop") or import "AtomicEventLoop" in main.js to use.
  47. * @method
  48. * @param {function} func the Function to call
  49. * @param {any} [args] A comma separated list of parameters to pass to func
  50. * @returns {number} the id of the setImmediate function to be used in clearImmediate in order to cancel it.
  51. */
  52. declare function setImmediate(func: any, ...args): number;
  53. /**
  54. * stops a previously queued setImmediate callback.
  55. * Muat require("AtomicEventLoop") or import "AtomicEventLoop" in main.js to use.
  56. * @method
  57. * @param {number} timer_id the id of the timer that was created via setImmediate
  58. */
  59. declare function clearImmediate(timer_id: number);
  60. declare interface DuktapeModule {
  61. /**
  62. * List of modules that have been loaded via the "require" statement
  63. *
  64. * @type {string[]}
  65. * @memberOf DuktapeModule
  66. */
  67. modLoaded: string[];
  68. modSearch(id: string, require, exports, module);
  69. }
  70. declare var Duktape: DuktapeModule;