UNPKG

cabbie-async

Version:
327 lines (242 loc) 10.9 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _regenerator = require('babel-runtime/regenerator'); var _regenerator2 = _interopRequireDefault(_regenerator); var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); var _inherits2 = require('babel-runtime/helpers/inherits'); var _inherits3 = _interopRequireDefault(_inherits2); var _addDebugging = require('./add-debugging'); var _addDebugging2 = _interopRequireDefault(_addDebugging); var _driver = require('./driver'); var _driver2 = _interopRequireDefault(_driver); var _baseClass = require('./base-class'); var _baseClass2 = _interopRequireDefault(_baseClass); var _flowRuntime = require('flow-runtime'); var _flowRuntime2 = _interopRequireDefault(_flowRuntime); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * * This file is generated automatically, run npm run build to re-generate. **/ var Driver = _flowRuntime2.default.tdz(function () { return _driver2.default; }); /* * Global touch object handling global touch commands */ var GlobalTouch = function (_BaseClass) { (0, _inherits3.default)(GlobalTouch, _BaseClass); function GlobalTouch(driver /*: Driver*/) { (0, _classCallCheck3.default)(this, GlobalTouch); var _driverType = _flowRuntime2.default.ref(Driver); _flowRuntime2.default.param('driver', _driverType).assert(driver); return (0, _possibleConstructorReturn3.default)(this, (GlobalTouch.__proto__ || (0, _getPrototypeOf2.default)(GlobalTouch)).call(this, driver, '/touch')); } /* * Tap on an element */ (0, _createClass3.default)(GlobalTouch, [{ key: '_tap', value: function _tap(elementId /*: string*/) /*: Promise<void>*/ { var _elementIdType, _returnType; return _regenerator2.default.async(function _tap$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _elementIdType = _flowRuntime2.default.string(); _returnType = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('elementId', _elementIdType).assert(elementId); _context.next = 5; return _regenerator2.default.awrap(this.requestJSON('POST', '/click', { element: elementId })); case 5: case 'end': return _context.stop(); } } }, null, this); } /* * Double tap on an element */ }, { key: '_doubleTap', value: function _doubleTap(elementId /*: string*/) /*: Promise<void>*/ { var _elementIdType2, _returnType2; return _regenerator2.default.async(function _doubleTap$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _elementIdType2 = _flowRuntime2.default.string(); _returnType2 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('elementId', _elementIdType2).assert(elementId); _context2.next = 5; return _regenerator2.default.awrap(this.requestJSON('POST', '/doubleclick', { element: elementId })); case 5: case 'end': return _context2.stop(); } } }, null, this); } /* * Long tap on an element */ }, { key: '_longTap', value: function _longTap(elementId /*: string*/) /*: Promise<void>*/ { var _elementIdType3, _returnType3; return _regenerator2.default.async(function _longTap$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _elementIdType3 = _flowRuntime2.default.string(); _returnType3 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('elementId', _elementIdType3).assert(elementId); _context3.next = 5; return _regenerator2.default.awrap(this.requestJSON('POST', '/longclick', { element: elementId })); case 5: case 'end': return _context3.stop(); } } }, null, this); } /* * Finger down on the screen at the given position */ }, { key: 'down', value: function down(x /*: number*/, y /*: number*/) /*: Promise<void>*/ { var _xType, _yType, _returnType4; return _regenerator2.default.async(function down$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _xType = _flowRuntime2.default.number(); _yType = _flowRuntime2.default.number(); _returnType4 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('x', _xType).assert(x); _flowRuntime2.default.param('y', _yType).assert(y); _context4.next = 7; return _regenerator2.default.awrap(this.requestJSON('POST', '/down', { x: x, y: y })); case 7: case 'end': return _context4.stop(); } } }, null, this); } /* * Finger up on the screen at the given position */ }, { key: 'up', value: function up(x /*: number*/, y /*: number*/) /*: Promise<void>*/ { var _xType2, _yType2, _returnType5; return _regenerator2.default.async(function up$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _xType2 = _flowRuntime2.default.number(); _yType2 = _flowRuntime2.default.number(); _returnType5 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('x', _xType2).assert(x); _flowRuntime2.default.param('y', _yType2).assert(y); _context5.next = 7; return _regenerator2.default.awrap(this.requestJSON('POST', '/up', { x: x, y: y })); case 7: case 'end': return _context5.stop(); } } }, null, this); } /* * Move finger on the screen to the given position */ }, { key: 'move', value: function move(x /*: number*/, y /*: number*/) /*: Promise<void>*/ { var _xType3, _yType3, _returnType6; return _regenerator2.default.async(function move$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _xType3 = _flowRuntime2.default.number(); _yType3 = _flowRuntime2.default.number(); _returnType6 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('x', _xType3).assert(x); _flowRuntime2.default.param('y', _yType3).assert(y); _context6.next = 7; return _regenerator2.default.awrap(this.requestJSON('POST', '/move', { x: x, y: y })); case 7: case 'end': return _context6.stop(); } } }, null, this); } /* * Scroll on the touch screen using finger based motion events according to an offset */ }, { key: 'scroll', value: function scroll(xOffset /*: number*/, yOffset /*: number*/) /*: Promise<void>*/ { var _xOffsetType, _yOffsetType, _returnType7; return _regenerator2.default.async(function scroll$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _xOffsetType = _flowRuntime2.default.number(); _yOffsetType = _flowRuntime2.default.number(); _returnType7 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('xOffset', _xOffsetType).assert(xOffset); _flowRuntime2.default.param('yOffset', _yOffsetType).assert(yOffset); _context7.next = 7; return _regenerator2.default.awrap(this.requestJSON('POST', '/scroll', { xoffset: xOffset, yoffset: yOffset })); case 7: case 'end': return _context7.stop(); } } }, null, this); } /* * Flick on the touch screen using finger motion events. This flick command starts at a particular screen location. */ }, { key: 'flick', value: function flick(xSpeed /*: number*/, ySpeed /*: number*/) /*: Promise<void>*/ { var _xSpeedType, _ySpeedType, _returnType8; return _regenerator2.default.async(function flick$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: _xSpeedType = _flowRuntime2.default.number(); _ySpeedType = _flowRuntime2.default.number(); _returnType8 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('xSpeed', _xSpeedType).assert(xSpeed); _flowRuntime2.default.param('ySpeed', _ySpeedType).assert(ySpeed); _context8.next = 7; return _regenerator2.default.awrap(this.requestJSON('POST', '/flick', { xspeed: xSpeed, yspeed: ySpeed })); case 7: case 'end': return _context8.stop(); } } }, null, this); } }]); return GlobalTouch; }(_baseClass2.default); (0, _addDebugging2.default)(GlobalTouch); exports.default = GlobalTouch;