UNPKG

cabbie-async

Version:
240 lines (176 loc) 8.11 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 _driver = require('./driver'); var _driver2 = _interopRequireDefault(_driver); var _activeWindow = require('./active-window'); var _activeWindow2 = _interopRequireDefault(_activeWindow); var _addDebugging = require('./add-debugging'); var _addDebugging2 = _interopRequireDefault(_addDebugging); 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 }; } var ActiveWindow = _flowRuntime2.default.tdz(function () { return _activeWindow2.default; }); /* * Window object */ /** * * This file is generated automatically, run npm run build to re-generate. **/ var Driver = _flowRuntime2.default.tdz(function () { return _driver2.default; }); var BaseWindow = function (_BaseClass) { (0, _inherits3.default)(BaseWindow, _BaseClass); function BaseWindow(driver /*: Driver*/, id /*: string*/) { (0, _classCallCheck3.default)(this, BaseWindow); var _driverType = _flowRuntime2.default.ref(Driver); var _idType = _flowRuntime2.default.string(); _flowRuntime2.default.param('driver', _driverType).assert(driver); _flowRuntime2.default.param('id', _idType).assert(id); return (0, _possibleConstructorReturn3.default)(this, (BaseWindow.__proto__ || (0, _getPrototypeOf2.default)(BaseWindow)).call(this, driver, '/window/' + id)); } /* * Get the size of a window */ (0, _createClass3.default)(BaseWindow, [{ key: 'getSize', value: function getSize() /*: Promise<{ width: number; height: number; }>*/ { var _returnType; return _regenerator2.default.async(function getSize$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _returnType = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.object(_flowRuntime2.default.property('width', _flowRuntime2.default.number()), _flowRuntime2.default.property('height', _flowRuntime2.default.number())), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.object(_flowRuntime2.default.property('width', _flowRuntime2.default.number()), _flowRuntime2.default.property('height', _flowRuntime2.default.number()))))); _context.t0 = _returnType; _context.next = 4; return _regenerator2.default.awrap(this.requestJSON('GET', '/size')); case 4: _context.t1 = _context.sent; return _context.abrupt('return', _context.t0.assert.call(_context.t0, _context.t1)); case 6: case 'end': return _context.stop(); } } }, null, this); } /* * Get the size of a window */ }, { key: 'resize', value: function resize(width /*: number*/, height /*: number*/) /*: Promise<void>*/ { var _widthType, _heightType, _returnType2; return _regenerator2.default.async(function resize$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _widthType = _flowRuntime2.default.number(); _heightType = _flowRuntime2.default.number(); _returnType2 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('width', _widthType).assert(width); _flowRuntime2.default.param('height', _heightType).assert(height); _context2.next = 7; return _regenerator2.default.awrap(this.requestJSON('POST', '/size', { width: width, height: height })); case 7: case 'end': return _context2.stop(); } } }, null, this); } /* * Maximize a window */ }, { key: 'maximize', value: function maximize() /*: Promise<void>*/ { var _returnType3; return _regenerator2.default.async(function maximize$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _returnType3 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _context3.next = 3; return _regenerator2.default.awrap(this.requestJSON('POST', '/maximize')); case 3: case 'end': return _context3.stop(); } } }, null, this); } /* * Get the position of a window */ }, { key: 'getPosition', value: function getPosition() /*: Promise<{ x: number; y: number; }>*/ { var _returnType4; return _regenerator2.default.async(function getPosition$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _returnType4 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.object(_flowRuntime2.default.property('x', _flowRuntime2.default.number()), _flowRuntime2.default.property('y', _flowRuntime2.default.number())), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.object(_flowRuntime2.default.property('x', _flowRuntime2.default.number()), _flowRuntime2.default.property('y', _flowRuntime2.default.number()))))); _context4.t0 = _returnType4; _context4.next = 4; return _regenerator2.default.awrap(this.requestJSON('GET', '/position')); case 4: _context4.t1 = _context4.sent; return _context4.abrupt('return', _context4.t0.assert.call(_context4.t0, _context4.t1)); case 6: case 'end': return _context4.stop(); } } }, null, this); } /* * Position a window */ }, { key: 'position', value: function position(x /*: number*/, y /*: number*/) /*: Promise<void>*/ { var _xType, _yType, _returnType5; return _regenerator2.default.async(function position$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: _xType = _flowRuntime2.default.number(); _yType = _flowRuntime2.default.number(); _returnType5 = _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); _context5.next = 7; return _regenerator2.default.awrap(this.requestJSON('POST', '/position', { x: x, y: y })); case 7: case 'end': return _context5.stop(); } } }, null, this); } }]); return BaseWindow; }(_baseClass2.default); (0, _addDebugging2.default)(BaseWindow, { baseClass: true }); exports.default = BaseWindow;