dwatch.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. let wasm;
  2. let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
  3. cachedTextDecoder.decode();
  4. let cachegetUint8Memory0 = null;
  5. function getUint8Memory0() {
  6. if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
  7. cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
  8. }
  9. return cachegetUint8Memory0;
  10. }
  11. function getStringFromWasm0(ptr, len) {
  12. return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
  13. }
  14. const heap = new Array(32).fill(undefined);
  15. heap.push(undefined, null, true, false);
  16. function getObject(idx) { return heap[idx]; }
  17. let stack_pointer = 32;
  18. function addBorrowedObject(obj) {
  19. if (stack_pointer == 1) throw new Error('out of js stack');
  20. heap[--stack_pointer] = obj;
  21. return stack_pointer;
  22. }
  23. /**
  24. * @param {any} out
  25. * @returns {Handle}
  26. */
  27. export function setup(out) {
  28. try {
  29. var ret = wasm.setup(addBorrowedObject(out));
  30. return Handle.__wrap(ret);
  31. } finally {
  32. heap[stack_pointer++] = undefined;
  33. }
  34. }
  35. function _assertClass(instance, klass) {
  36. if (!(instance instanceof klass)) {
  37. throw new Error(`expected instance of ${klass.name}`);
  38. }
  39. return instance.ptr;
  40. }
  41. /**
  42. * @param {Handle} h
  43. * @param {number} delay
  44. * @param {number} i
  45. * @returns {RunUntilResult}
  46. */
  47. export function add_event(h, delay, i) {
  48. _assertClass(h, Handle);
  49. var ret = wasm.add_event(h.ptr, delay, i);
  50. return RunUntilResult.__wrap(ret);
  51. }
  52. /**
  53. * @param {Handle} h
  54. * @param {number} t
  55. * @param {any} out
  56. * @returns {RunUntilResult}
  57. */
  58. export function run_until(h, t, out) {
  59. try {
  60. _assertClass(h, Handle);
  61. var ret = wasm.run_until(h.ptr, t, addBorrowedObject(out));
  62. return RunUntilResult.__wrap(ret);
  63. } finally {
  64. heap[stack_pointer++] = undefined;
  65. }
  66. }
  67. /**
  68. */
  69. export const InEvent = Object.freeze({ E_bottomLeftPressed:0,"0":"E_bottomLeftPressed",E_bottomLeftReleased:1,"1":"E_bottomLeftReleased",E_bottomRightPressed:2,"2":"E_bottomRightPressed",E_bottomRightReleased:3,"3":"E_bottomRightReleased",E_topLeftPressed:4,"4":"E_topLeftPressed",E_topLeftReleased:5,"5":"E_topLeftReleased",E_topRightPressed:6,"6":"E_topRightPressed",E_topRightReleased:7,"7":"E_topRightReleased",E_alarmStart:8,"8":"E_alarmStart",A0:9,"9":"A0",A1:10,"10":"A1",A2:11,"11":"A2",A3:12,"12":"A3",A4:13,"13":"A4",A5:14,"14":"A5",A6:15,"15":"A6",A7:16,"16":"A7",A8:17,"17":"A8",A9:18,"18":"A9",A10:19,"19":"A10", });
  70. /**
  71. */
  72. export const OutEvent = Object.freeze({ E_setAlarm:0,"0":"E_setAlarm",E_setIndiglo:1,"1":"E_setIndiglo",E_unsetIndiglo:2,"2":"E_unsetIndiglo",E_increaseChronoByOne:3,"3":"E_increaseChronoByOne",E_resetChrono:4,"4":"E_resetChrono",E_refreshTimeDisplay:5,"5":"E_refreshTimeDisplay",E_refreshAlarmDisplay:6,"6":"E_refreshAlarmDisplay",E_startSelection:7,"7":"E_startSelection",E_stopSelection:8,"8":"E_stopSelection",E_selectNext:9,"9":"E_selectNext",E_increaseSelection:10,"10":"E_increaseSelection",E_refreshChronoDisplay:11,"11":"E_refreshChronoDisplay",E_increaseTimeByOne:12,"12":"E_increaseTimeByOne",E_checkTime:13,"13":"E_checkTime", });
  73. /**
  74. */
  75. export class Handle {
  76. static __wrap(ptr) {
  77. const obj = Object.create(Handle.prototype);
  78. obj.ptr = ptr;
  79. return obj;
  80. }
  81. free() {
  82. const ptr = this.ptr;
  83. this.ptr = 0;
  84. wasm.__wbg_handle_free(ptr);
  85. }
  86. }
  87. /**
  88. */
  89. export class RunUntilResult {
  90. static __wrap(ptr) {
  91. const obj = Object.create(RunUntilResult.prototype);
  92. obj.ptr = ptr;
  93. return obj;
  94. }
  95. free() {
  96. const ptr = this.ptr;
  97. this.ptr = 0;
  98. wasm.__wbg_rununtilresult_free(ptr);
  99. }
  100. /**
  101. * @returns {number}
  102. */
  103. get simtime() {
  104. var ret = wasm.__wbg_get_rununtilresult_simtime(this.ptr);
  105. return ret >>> 0;
  106. }
  107. /**
  108. * @param {number} arg0
  109. */
  110. set simtime(arg0) {
  111. wasm.__wbg_set_rununtilresult_simtime(this.ptr, arg0);
  112. }
  113. /**
  114. * @returns {boolean}
  115. */
  116. get reschedule() {
  117. var ret = wasm.__wbg_get_rununtilresult_reschedule(this.ptr);
  118. return ret !== 0;
  119. }
  120. /**
  121. * @param {boolean} arg0
  122. */
  123. set reschedule(arg0) {
  124. wasm.__wbg_set_rununtilresult_reschedule(this.ptr, arg0);
  125. }
  126. /**
  127. * @returns {number}
  128. */
  129. get at() {
  130. var ret = wasm.__wbg_get_rununtilresult_at(this.ptr);
  131. return ret >>> 0;
  132. }
  133. /**
  134. * @param {number} arg0
  135. */
  136. set at(arg0) {
  137. wasm.__wbg_set_rununtilresult_at(this.ptr, arg0);
  138. }
  139. }
  140. async function load(module, imports) {
  141. if (typeof Response === 'function' && module instanceof Response) {
  142. if (typeof WebAssembly.instantiateStreaming === 'function') {
  143. try {
  144. return await WebAssembly.instantiateStreaming(module, imports);
  145. } catch (e) {
  146. if (module.headers.get('Content-Type') != 'application/wasm') {
  147. console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
  148. } else {
  149. throw e;
  150. }
  151. }
  152. }
  153. const bytes = await module.arrayBuffer();
  154. return await WebAssembly.instantiate(bytes, imports);
  155. } else {
  156. const instance = await WebAssembly.instantiate(module, imports);
  157. if (instance instanceof WebAssembly.Instance) {
  158. return { instance, module };
  159. } else {
  160. return instance;
  161. }
  162. }
  163. }
  164. async function init(input) {
  165. if (typeof input === 'undefined') {
  166. input = import.meta.url.replace(/\.js$/, '_bg.wasm');
  167. }
  168. const imports = {};
  169. imports.wbg = {};
  170. imports.wbg.__wbg_handleoutput_70a5b58d88cc044e = function(arg0, arg1) {
  171. getObject(arg0).handle_output(arg1 >>> 0);
  172. };
  173. imports.wbg.__wbindgen_throw = function(arg0, arg1) {
  174. throw new Error(getStringFromWasm0(arg0, arg1));
  175. };
  176. if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
  177. input = fetch(input);
  178. }
  179. const { instance, module } = await load(await input, imports);
  180. wasm = instance.exports;
  181. init.__wbindgen_wasm_module = module;
  182. return wasm;
  183. }
  184. export default init;