UNPKG

cabbie-async

Version:
174 lines (132 loc) 5.8 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 _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 Alert = function (_BaseClass) { (0, _inherits3.default)(Alert, _BaseClass); function Alert() { (0, _classCallCheck3.default)(this, Alert); return (0, _possibleConstructorReturn3.default)(this, (Alert.__proto__ || (0, _getPrototypeOf2.default)(Alert)).apply(this, arguments)); } (0, _createClass3.default)(Alert, [{ key: 'getText', /* * Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog */ value: function getText() /*: Promise<string>*/ { var _returnType; return _regenerator2.default.async(function getText$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _returnType = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.string(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.string()))); _context.t0 = _returnType; _context.next = 4; return _regenerator2.default.awrap(this.requestJSON('GET', '/alert_text')); 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); } /* * Sends keystrokes to a JavaScript prompt() dialog */ }, { key: 'setText', value: function setText(text /*: string*/) /*: Promise<void>*/ { var _textType, _returnType2; return _regenerator2.default.async(function setText$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: _textType = _flowRuntime2.default.string(); _returnType2 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _flowRuntime2.default.param('text', _textType).assert(text); _context2.next = 5; return _regenerator2.default.awrap(this.requestJSON('POST', '/alert_text', { text: text })); case 5: case 'end': return _context2.stop(); } } }, null, this); } /* * Accepts the currently displayed alert dialog. Usually, this is equivalent to * clicking on the 'OK' button in the dialog. */ }, { key: 'accept', value: function accept() /*: Promise<void>*/ { var _returnType3; return _regenerator2.default.async(function accept$(_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', '/accept_alert')); case 3: case 'end': return _context3.stop(); } } }, null, this); } /* * Dismisses the currently displayed alert dialog. For confirm() and prompt() dialogs, * this is equivalent to clicking the 'Cancel' button. For alert() dialogs, this is * equivalent to clicking the 'OK' button. * * Note: Never use this with an alert. Use accept() instead. */ }, { key: 'dismiss', value: function dismiss() /*: Promise<void>*/ { var _returnType4; return _regenerator2.default.async(function dismiss$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _returnType4 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void()))); _context4.next = 3; return _regenerator2.default.awrap(this.requestJSON('POST', '/dismiss_alert')); case 3: case 'end': return _context4.stop(); } } }, null, this); } }]); return Alert; }(_baseClass2.default); /** * * This file is generated automatically, run npm run build to re-generate. **/ (0, _addDebugging2.default)(Alert); exports.default = Alert;