2
0

ui_utils.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2017 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. 'use strict';
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.waitOnEventOrTimeout = exports.WaitOnType = exports.animationStarted = exports.normalizeWheelEventDelta = exports.binarySearchFirstItem = exports.watchScroll = exports.scrollIntoView = exports.getOutputScale = exports.approximateFraction = exports.getPageSizeInches = exports.roundToDivide = exports.getVisibleElements = exports.parseQueryString = exports.noContextMenuHandler = exports.getPDFFileNameFromURL = exports.ProgressBar = exports.EventBus = exports.NullL10n = exports.TextLayerMode = exports.RendererType = exports.PresentationModeState = exports.cloneObj = exports.isFileSchema = exports.isValidRotation = exports.VERTICAL_PADDING = exports.SCROLLBAR_PADDING = exports.MAX_AUTO_SCALE = exports.UNKNOWN_SCALE = exports.MAX_SCALE = exports.MIN_SCALE = exports.DEFAULT_SCALE = exports.DEFAULT_SCALE_VALUE = exports.CSS_UNITS = undefined;
  27. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  28. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  29. var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  30. var _pdf = require('../pdf');
  31. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32. var CSS_UNITS = 96.0 / 72.0;
  33. var DEFAULT_SCALE_VALUE = 'auto';
  34. var DEFAULT_SCALE = 1.0;
  35. var MIN_SCALE = 0.10;
  36. var MAX_SCALE = 10.0;
  37. var UNKNOWN_SCALE = 0;
  38. var MAX_AUTO_SCALE = 1.25;
  39. var SCROLLBAR_PADDING = 40;
  40. var VERTICAL_PADDING = 5;
  41. var PresentationModeState = {
  42. UNKNOWN: 0,
  43. NORMAL: 1,
  44. CHANGING: 2,
  45. FULLSCREEN: 3
  46. };
  47. var RendererType = {
  48. CANVAS: 'canvas',
  49. SVG: 'svg'
  50. };
  51. var TextLayerMode = {
  52. DISABLE: 0,
  53. ENABLE: 1,
  54. ENABLE_ENHANCE: 2
  55. };
  56. function formatL10nValue(text, args) {
  57. if (!args) {
  58. return text;
  59. }
  60. return text.replace(/\{\{\s*(\w+)\s*\}\}/g, function (all, name) {
  61. return name in args ? args[name] : '{{' + name + '}}';
  62. });
  63. }
  64. var NullL10n = {
  65. getDirection: function getDirection() {
  66. return Promise.resolve('ltr');
  67. },
  68. get: function get(property, args, fallback) {
  69. return Promise.resolve(formatL10nValue(fallback, args));
  70. },
  71. translate: function translate(element) {
  72. return Promise.resolve();
  73. }
  74. };
  75. function getOutputScale(ctx) {
  76. var devicePixelRatio = window.devicePixelRatio || 1;
  77. var backingStoreRatio = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1;
  78. var pixelRatio = devicePixelRatio / backingStoreRatio;
  79. return {
  80. sx: pixelRatio,
  81. sy: pixelRatio,
  82. scaled: pixelRatio !== 1
  83. };
  84. }
  85. function scrollIntoView(element, spot) {
  86. var skipOverflowHiddenElements = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  87. var parent = element.offsetParent;
  88. if (!parent) {
  89. console.error('offsetParent is not set -- cannot scroll');
  90. return;
  91. }
  92. var offsetY = element.offsetTop + element.clientTop;
  93. var offsetX = element.offsetLeft + element.clientLeft;
  94. while (parent.clientHeight === parent.scrollHeight || skipOverflowHiddenElements && getComputedStyle(parent).overflow === 'hidden') {
  95. if (parent.dataset._scaleY) {
  96. offsetY /= parent.dataset._scaleY;
  97. offsetX /= parent.dataset._scaleX;
  98. }
  99. offsetY += parent.offsetTop;
  100. offsetX += parent.offsetLeft;
  101. parent = parent.offsetParent;
  102. if (!parent) {
  103. return;
  104. }
  105. }
  106. if (spot) {
  107. if (spot.top !== undefined) {
  108. offsetY += spot.top;
  109. }
  110. if (spot.left !== undefined) {
  111. offsetX += spot.left;
  112. parent.scrollLeft = offsetX;
  113. }
  114. }
  115. parent.scrollTop = offsetY;
  116. }
  117. function watchScroll(viewAreaElement, callback) {
  118. var debounceScroll = function debounceScroll(evt) {
  119. if (rAF) {
  120. return;
  121. }
  122. rAF = window.requestAnimationFrame(function viewAreaElementScrolled() {
  123. rAF = null;
  124. var currentY = viewAreaElement.scrollTop;
  125. var lastY = state.lastY;
  126. if (currentY !== lastY) {
  127. state.down = currentY > lastY;
  128. }
  129. state.lastY = currentY;
  130. callback(state);
  131. });
  132. };
  133. var state = {
  134. down: true,
  135. lastY: viewAreaElement.scrollTop,
  136. _eventHandler: debounceScroll
  137. };
  138. var rAF = null;
  139. viewAreaElement.addEventListener('scroll', debounceScroll, true);
  140. return state;
  141. }
  142. function parseQueryString(query) {
  143. var parts = query.split('&');
  144. var params = Object.create(null);
  145. for (var i = 0, ii = parts.length; i < ii; ++i) {
  146. var param = parts[i].split('=');
  147. var key = param[0].toLowerCase();
  148. var value = param.length > 1 ? param[1] : null;
  149. params[decodeURIComponent(key)] = decodeURIComponent(value);
  150. }
  151. return params;
  152. }
  153. function binarySearchFirstItem(items, condition) {
  154. var minIndex = 0;
  155. var maxIndex = items.length - 1;
  156. if (items.length === 0 || !condition(items[maxIndex])) {
  157. return items.length;
  158. }
  159. if (condition(items[minIndex])) {
  160. return minIndex;
  161. }
  162. while (minIndex < maxIndex) {
  163. var currentIndex = minIndex + maxIndex >> 1;
  164. var currentItem = items[currentIndex];
  165. if (condition(currentItem)) {
  166. maxIndex = currentIndex;
  167. } else {
  168. minIndex = currentIndex + 1;
  169. }
  170. }
  171. return minIndex;
  172. }
  173. function approximateFraction(x) {
  174. if (Math.floor(x) === x) {
  175. return [x, 1];
  176. }
  177. var xinv = 1 / x;
  178. var limit = 8;
  179. if (xinv > limit) {
  180. return [1, limit];
  181. } else if (Math.floor(xinv) === xinv) {
  182. return [1, xinv];
  183. }
  184. var x_ = x > 1 ? xinv : x;
  185. var a = 0,
  186. b = 1,
  187. c = 1,
  188. d = 1;
  189. while (true) {
  190. var p = a + c,
  191. q = b + d;
  192. if (q > limit) {
  193. break;
  194. }
  195. if (x_ <= p / q) {
  196. c = p;
  197. d = q;
  198. } else {
  199. a = p;
  200. b = q;
  201. }
  202. }
  203. var result = void 0;
  204. if (x_ - a / b < c / d - x_) {
  205. result = x_ === x ? [a, b] : [b, a];
  206. } else {
  207. result = x_ === x ? [c, d] : [d, c];
  208. }
  209. return result;
  210. }
  211. function roundToDivide(x, div) {
  212. var r = x % div;
  213. return r === 0 ? x : Math.round(x - r + div);
  214. }
  215. function getPageSizeInches(_ref) {
  216. var view = _ref.view,
  217. userUnit = _ref.userUnit,
  218. rotate = _ref.rotate;
  219. var _view = _slicedToArray(view, 4),
  220. x1 = _view[0],
  221. y1 = _view[1],
  222. x2 = _view[2],
  223. y2 = _view[3];
  224. var changeOrientation = rotate % 180 !== 0;
  225. var width = (x2 - x1) / 72 * userUnit;
  226. var height = (y2 - y1) / 72 * userUnit;
  227. return {
  228. width: changeOrientation ? height : width,
  229. height: changeOrientation ? width : height
  230. };
  231. }
  232. function getVisibleElements(scrollEl, views) {
  233. var sortByVisibility = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  234. var top = scrollEl.scrollTop,
  235. bottom = top + scrollEl.clientHeight;
  236. var left = scrollEl.scrollLeft,
  237. right = left + scrollEl.clientWidth;
  238. function isElementBottomBelowViewTop(view) {
  239. var element = view.div;
  240. var elementBottom = element.offsetTop + element.clientTop + element.clientHeight;
  241. return elementBottom > top;
  242. }
  243. var visible = [],
  244. view = void 0,
  245. element = void 0;
  246. var currentHeight = void 0,
  247. viewHeight = void 0,
  248. hiddenHeight = void 0,
  249. percentHeight = void 0;
  250. var currentWidth = void 0,
  251. viewWidth = void 0;
  252. var firstVisibleElementInd = views.length === 0 ? 0 : binarySearchFirstItem(views, isElementBottomBelowViewTop);
  253. for (var i = firstVisibleElementInd, ii = views.length; i < ii; i++) {
  254. view = views[i];
  255. element = view.div;
  256. currentHeight = element.offsetTop + element.clientTop;
  257. viewHeight = element.clientHeight;
  258. if (currentHeight > bottom) {
  259. break;
  260. }
  261. currentWidth = element.offsetLeft + element.clientLeft;
  262. viewWidth = element.clientWidth;
  263. if (currentWidth + viewWidth < left || currentWidth > right) {
  264. continue;
  265. }
  266. hiddenHeight = Math.max(0, top - currentHeight) + Math.max(0, currentHeight + viewHeight - bottom);
  267. percentHeight = (viewHeight - hiddenHeight) * 100 / viewHeight | 0;
  268. visible.push({
  269. id: view.id,
  270. x: currentWidth,
  271. y: currentHeight,
  272. view: view,
  273. percent: percentHeight
  274. });
  275. }
  276. var first = visible[0];
  277. var last = visible[visible.length - 1];
  278. if (sortByVisibility) {
  279. visible.sort(function (a, b) {
  280. var pc = a.percent - b.percent;
  281. if (Math.abs(pc) > 0.001) {
  282. return -pc;
  283. }
  284. return a.id - b.id;
  285. });
  286. }
  287. return {
  288. first: first,
  289. last: last,
  290. views: visible
  291. };
  292. }
  293. function noContextMenuHandler(evt) {
  294. evt.preventDefault();
  295. }
  296. function isFileSchema(url) {
  297. var i = 0,
  298. ii = url.length;
  299. while (i < ii && url[i].trim() === '') {
  300. i++;
  301. }
  302. return url.substr(i, 7).toLowerCase() === 'file://';
  303. }
  304. function isDataSchema(url) {
  305. var i = 0,
  306. ii = url.length;
  307. while (i < ii && url[i].trim() === '') {
  308. i++;
  309. }
  310. return url.substr(i, 5).toLowerCase() === 'data:';
  311. }
  312. function getPDFFileNameFromURL(url) {
  313. var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
  314. if (isDataSchema(url)) {
  315. console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
  316. return defaultFilename;
  317. }
  318. var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
  319. var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
  320. var splitURI = reURI.exec(url);
  321. var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
  322. if (suggestedFilename) {
  323. suggestedFilename = suggestedFilename[0];
  324. if (suggestedFilename.includes('%')) {
  325. try {
  326. suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
  327. } catch (ex) {}
  328. }
  329. }
  330. return suggestedFilename || defaultFilename;
  331. }
  332. function normalizeWheelEventDelta(evt) {
  333. var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
  334. var angle = Math.atan2(evt.deltaY, evt.deltaX);
  335. if (-0.25 * Math.PI < angle && angle < 0.75 * Math.PI) {
  336. delta = -delta;
  337. }
  338. var MOUSE_DOM_DELTA_PIXEL_MODE = 0;
  339. var MOUSE_DOM_DELTA_LINE_MODE = 1;
  340. var MOUSE_PIXELS_PER_LINE = 30;
  341. var MOUSE_LINES_PER_PAGE = 30;
  342. if (evt.deltaMode === MOUSE_DOM_DELTA_PIXEL_MODE) {
  343. delta /= MOUSE_PIXELS_PER_LINE * MOUSE_LINES_PER_PAGE;
  344. } else if (evt.deltaMode === MOUSE_DOM_DELTA_LINE_MODE) {
  345. delta /= MOUSE_LINES_PER_PAGE;
  346. }
  347. return delta;
  348. }
  349. function isValidRotation(angle) {
  350. return Number.isInteger(angle) && angle % 90 === 0;
  351. }
  352. function cloneObj(obj) {
  353. var result = Object.create(null);
  354. for (var i in obj) {
  355. if (Object.prototype.hasOwnProperty.call(obj, i)) {
  356. result[i] = obj[i];
  357. }
  358. }
  359. return result;
  360. }
  361. var WaitOnType = {
  362. EVENT: 'event',
  363. TIMEOUT: 'timeout'
  364. };
  365. function waitOnEventOrTimeout(_ref2) {
  366. var target = _ref2.target,
  367. name = _ref2.name,
  368. _ref2$delay = _ref2.delay,
  369. delay = _ref2$delay === undefined ? 0 : _ref2$delay;
  370. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' || !(name && typeof name === 'string') || !(Number.isInteger(delay) && delay >= 0)) {
  371. return Promise.reject(new Error('waitOnEventOrTimeout - invalid paramaters.'));
  372. }
  373. var capability = (0, _pdf.createPromiseCapability)();
  374. function handler(type) {
  375. if (target instanceof EventBus) {
  376. target.off(name, eventHandler);
  377. } else {
  378. target.removeEventListener(name, eventHandler);
  379. }
  380. if (timeout) {
  381. clearTimeout(timeout);
  382. }
  383. capability.resolve(type);
  384. }
  385. var eventHandler = handler.bind(null, WaitOnType.EVENT);
  386. if (target instanceof EventBus) {
  387. target.on(name, eventHandler);
  388. } else {
  389. target.addEventListener(name, eventHandler);
  390. }
  391. var timeoutHandler = handler.bind(null, WaitOnType.TIMEOUT);
  392. var timeout = setTimeout(timeoutHandler, delay);
  393. return capability.promise;
  394. }
  395. var animationStarted = new Promise(function (resolve) {
  396. window.requestAnimationFrame(resolve);
  397. });
  398. var EventBus = function () {
  399. function EventBus() {
  400. _classCallCheck(this, EventBus);
  401. this._listeners = Object.create(null);
  402. }
  403. _createClass(EventBus, [{
  404. key: 'on',
  405. value: function on(eventName, listener) {
  406. var eventListeners = this._listeners[eventName];
  407. if (!eventListeners) {
  408. eventListeners = [];
  409. this._listeners[eventName] = eventListeners;
  410. }
  411. eventListeners.push(listener);
  412. }
  413. }, {
  414. key: 'off',
  415. value: function off(eventName, listener) {
  416. var eventListeners = this._listeners[eventName];
  417. var i = void 0;
  418. if (!eventListeners || (i = eventListeners.indexOf(listener)) < 0) {
  419. return;
  420. }
  421. eventListeners.splice(i, 1);
  422. }
  423. }, {
  424. key: 'dispatch',
  425. value: function dispatch(eventName) {
  426. var eventListeners = this._listeners[eventName];
  427. if (!eventListeners || eventListeners.length === 0) {
  428. return;
  429. }
  430. var args = Array.prototype.slice.call(arguments, 1);
  431. eventListeners.slice(0).forEach(function (listener) {
  432. listener.apply(null, args);
  433. });
  434. }
  435. }]);
  436. return EventBus;
  437. }();
  438. function clamp(v, min, max) {
  439. return Math.min(Math.max(v, min), max);
  440. }
  441. var ProgressBar = function () {
  442. function ProgressBar(id) {
  443. var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
  444. height = _ref3.height,
  445. width = _ref3.width,
  446. units = _ref3.units;
  447. _classCallCheck(this, ProgressBar);
  448. this.visible = true;
  449. this.div = document.querySelector(id + ' .progress');
  450. this.bar = this.div.parentNode;
  451. this.height = height || 100;
  452. this.width = width || 100;
  453. this.units = units || '%';
  454. this.div.style.height = this.height + this.units;
  455. this.percent = 0;
  456. }
  457. _createClass(ProgressBar, [{
  458. key: '_updateBar',
  459. value: function _updateBar() {
  460. if (this._indeterminate) {
  461. this.div.classList.add('indeterminate');
  462. this.div.style.width = this.width + this.units;
  463. return;
  464. }
  465. this.div.classList.remove('indeterminate');
  466. var progressSize = this.width * this._percent / 100;
  467. this.div.style.width = progressSize + this.units;
  468. }
  469. }, {
  470. key: 'setWidth',
  471. value: function setWidth(viewer) {
  472. if (!viewer) {
  473. return;
  474. }
  475. var container = viewer.parentNode;
  476. var scrollbarWidth = container.offsetWidth - viewer.offsetWidth;
  477. if (scrollbarWidth > 0) {
  478. this.bar.setAttribute('style', 'width: calc(100% - ' + scrollbarWidth + 'px);');
  479. }
  480. }
  481. }, {
  482. key: 'hide',
  483. value: function hide() {
  484. if (!this.visible) {
  485. return;
  486. }
  487. this.visible = false;
  488. this.bar.classList.add('hidden');
  489. document.body.classList.remove('loadingInProgress');
  490. }
  491. }, {
  492. key: 'show',
  493. value: function show() {
  494. if (this.visible) {
  495. return;
  496. }
  497. this.visible = true;
  498. document.body.classList.add('loadingInProgress');
  499. this.bar.classList.remove('hidden');
  500. }
  501. }, {
  502. key: 'percent',
  503. get: function get() {
  504. return this._percent;
  505. },
  506. set: function set(val) {
  507. this._indeterminate = isNaN(val);
  508. this._percent = clamp(val, 0, 100);
  509. this._updateBar();
  510. }
  511. }]);
  512. return ProgressBar;
  513. }();
  514. exports.CSS_UNITS = CSS_UNITS;
  515. exports.DEFAULT_SCALE_VALUE = DEFAULT_SCALE_VALUE;
  516. exports.DEFAULT_SCALE = DEFAULT_SCALE;
  517. exports.MIN_SCALE = MIN_SCALE;
  518. exports.MAX_SCALE = MAX_SCALE;
  519. exports.UNKNOWN_SCALE = UNKNOWN_SCALE;
  520. exports.MAX_AUTO_SCALE = MAX_AUTO_SCALE;
  521. exports.SCROLLBAR_PADDING = SCROLLBAR_PADDING;
  522. exports.VERTICAL_PADDING = VERTICAL_PADDING;
  523. exports.isValidRotation = isValidRotation;
  524. exports.isFileSchema = isFileSchema;
  525. exports.cloneObj = cloneObj;
  526. exports.PresentationModeState = PresentationModeState;
  527. exports.RendererType = RendererType;
  528. exports.TextLayerMode = TextLayerMode;
  529. exports.NullL10n = NullL10n;
  530. exports.EventBus = EventBus;
  531. exports.ProgressBar = ProgressBar;
  532. exports.getPDFFileNameFromURL = getPDFFileNameFromURL;
  533. exports.noContextMenuHandler = noContextMenuHandler;
  534. exports.parseQueryString = parseQueryString;
  535. exports.getVisibleElements = getVisibleElements;
  536. exports.roundToDivide = roundToDivide;
  537. exports.getPageSizeInches = getPageSizeInches;
  538. exports.approximateFraction = approximateFraction;
  539. exports.getOutputScale = getOutputScale;
  540. exports.scrollIntoView = scrollIntoView;
  541. exports.watchScroll = watchScroll;
  542. exports.binarySearchFirstItem = binarySearchFirstItem;
  543. exports.normalizeWheelEventDelta = normalizeWheelEventDelta;
  544. exports.animationStarted = animationStarted;
  545. exports.WaitOnType = WaitOnType;
  546. exports.waitOnEventOrTimeout = waitOnEventOrTimeout;