WindowExt.d.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. interface HostMessage {
  23. message: string;
  24. }
  25. /**
  26. * Defines the interface to what is available for the host to call or for the client to call on the window object
  27. */
  28. interface Window {
  29. atomicQuery(message: {
  30. request: any,
  31. persistent: boolean,
  32. onSuccess: (result?: string) => void,
  33. onFailure: (error_code: number, error_message: string) => void
  34. }): void;
  35. /**
  36. * Used to send a notification message to the host
  37. * @param {string} messageType
  38. * @param {object} data
  39. * @return {Promise} will resolve when the host has handled the message
  40. * @deprecated use window.hostNotify
  41. */
  42. atomicQueryPromise(messageType: string, data?: {}): Promise<void>;
  43. /**
  44. * Used to send a notification message to the host
  45. * @param {string} messageType
  46. * @param {object} data
  47. * @return {Promise} will resolve when the host has handled the message
  48. * @deprecated
  49. */
  50. atomicHostEvent(messageType: string, data?: {}): Promise<void>;
  51. /**
  52. * Used to send a request to the server. The server will send back the results in the promise
  53. * @param {string} messageType
  54. * @param {object} data
  55. * @return {Promise}
  56. */
  57. atomicHostRequest<T>(messageType: string, data?: {}): Promise<T>;
  58. HOST_loadCode(codeUrl): void;
  59. HOST_saveCode(): void;
  60. HOST_resourceRenamed(path: string, newPath: string): void;
  61. HOST_resourceDeleted(path: string): void;
  62. HOST_preferencesChanged(jsonProjectPrefs: string, jsonApplicationPrefs: string): void;
  63. /**
  64. * Preferences set by the host. Each preference category is a JSON string of all the prefs
  65. */
  66. HOST_Preferences: {
  67. ApplicationPreferences: string,
  68. ProjectPreferences: string
  69. };
  70. }
  71. // globally expose these
  72. declare function atomicHostEvent(messageType: string, data?: {}): Promise<void>;
  73. declare function atomicHostRequest<T>(messageType: string, data?: {}): Promise<T>;