cabbie-async
Version:
An asynchronous webdriver client
231 lines (173 loc) • 7.55 kB
JavaScript
'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 _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 }; }
/**
*
* This file is generated automatically, run npm run build to re-generate.
**/
var Driver = _flowRuntime2.default.tdz(function () {
return _driver2.default;
});
/*
* Input Method Editor object
*/
var IME = function (_BaseClass) {
(0, _inherits3.default)(IME, _BaseClass);
function IME(driver /*: Driver*/) {
(0, _classCallCheck3.default)(this, IME);
var _driverType = _flowRuntime2.default.ref(Driver);
_flowRuntime2.default.param('driver', _driverType).assert(driver);
return (0, _possibleConstructorReturn3.default)(this, (IME.__proto__ || (0, _getPrototypeOf2.default)(IME)).call(this, driver, '/ime'));
}
/*
* List all available engines on the machine. To use an engine, it has to be present in this list.
*/
(0, _createClass3.default)(IME, [{
key: 'getEngines',
value: function getEngines() /*: Promise<Array<string>>*/ {
var _returnType;
return _regenerator2.default.async(function getEngines$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_returnType = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.array(_flowRuntime2.default.string()), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.array(_flowRuntime2.default.string()))));
_context.t0 = _returnType;
_context.next = 4;
return _regenerator2.default.awrap(this.requestJSON('GET', '/available_engines'));
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 name of the active IME engine. The name string is platform specific.
*/
}, {
key: 'getActiveEngine',
value: function getActiveEngine() /*: Promise<string>*/ {
var _returnType2;
return _regenerator2.default.async(function getActiveEngine$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_returnType2 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.string(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.string())));
_context2.t0 = _returnType2;
_context2.next = 4;
return _regenerator2.default.awrap(this.requestJSON('GET', '/active_engine'));
case 4:
_context2.t1 = _context2.sent;
return _context2.abrupt('return', _context2.t0.assert.call(_context2.t0, _context2.t1));
case 6:
case 'end':
return _context2.stop();
}
}
}, null, this);
}
/*
* Indicates whether IME input is active at the moment (not if it's available)
*/
}, {
key: 'isActivated',
value: function isActivated() /*: Promise<boolean>*/ {
var _returnType3;
return _regenerator2.default.async(function isActivated$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_returnType3 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.boolean(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.boolean())));
_context3.t0 = _returnType3;
_context3.next = 4;
return _regenerator2.default.awrap(this.requestJSON('GET', '/activated'));
case 4:
_context3.t1 = _context3.sent;
return _context3.abrupt('return', _context3.t0.assert.call(_context3.t0, _context3.t1));
case 6:
case 'end':
return _context3.stop();
}
}
}, null, this);
}
/*
* Make an engine that is available (appears on the list returned by
* getAvailableEngines) active. After this call, the engine will be
* added to the list of engines loaded in the IME daemon and the input
* sent using sendKeys will be converted by the active engine.
*
* Note that this is a platform-independent method of activating IME
* (the platform-specific way being using keyboard shortcuts)
*/
}, {
key: 'activate',
value: function activate(engine /*: string*/) /*: Promise<void>*/ {
var _engineType, _returnType4;
return _regenerator2.default.async(function activate$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_engineType = _flowRuntime2.default.string();
_returnType4 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_flowRuntime2.default.param('engine', _engineType).assert(engine);
_context4.next = 5;
return _regenerator2.default.awrap(this.requestJSON('POST', '/activate', { engine: engine }));
case 5:
case 'end':
return _context4.stop();
}
}
}, null, this);
}
/*
* De-activates the currently-active IME engine
*/
}, {
key: 'deactivate',
value: function deactivate() /*: Promise<void>*/ {
var _returnType5;
return _regenerator2.default.async(function deactivate$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_returnType5 = _flowRuntime2.default.return(_flowRuntime2.default.union(_flowRuntime2.default.void(), _flowRuntime2.default.ref('Promise', _flowRuntime2.default.void())));
_context5.next = 3;
return _regenerator2.default.awrap(this.requestJSON('POST', '/deactivate'));
case 3:
case 'end':
return _context5.stop();
}
}
}, null, this);
}
}]);
return IME;
}(_baseClass2.default);
(0, _addDebugging2.default)(IME);
exports.default = IME;