cabbie-sync
Version:
A synchronous webdriver client
147 lines (99 loc) • 4.29 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
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() /*: Array<string>*/ {
var _returnType = _flowRuntime2.default.return(_flowRuntime2.default.array(_flowRuntime2.default.string()));
return _returnType.assert(this.requestJSON('GET', '/available_engines'));
}
/*
* Get the name of the active IME engine. The name string is platform specific.
*/
}, {
key: 'getActiveEngine',
value: function getActiveEngine() /*: string*/ {
var _returnType2 = _flowRuntime2.default.return(_flowRuntime2.default.string());
return _returnType2.assert(this.requestJSON('GET', '/active_engine'));
}
/*
* Indicates whether IME input is active at the moment (not if it's available)
*/
}, {
key: 'isActivated',
value: function isActivated() /*: boolean*/ {
var _returnType3 = _flowRuntime2.default.return(_flowRuntime2.default.boolean());
return _returnType3.assert(this.requestJSON('GET', '/activated'));
}
/*
* 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*/) /*: void*/ {
var _engineType = _flowRuntime2.default.string();
var _returnType4 = _flowRuntime2.default.return(_flowRuntime2.default.void());
_flowRuntime2.default.param('engine', _engineType).assert(engine);
this.requestJSON('POST', '/activate', { engine: engine });
}
/*
* De-activates the currently-active IME engine
*/
}, {
key: 'deactivate',
value: function deactivate() /*: void*/ {
var _returnType5 = _flowRuntime2.default.return(_flowRuntime2.default.void());
this.requestJSON('POST', '/deactivate');
}
}]);
return IME;
}(_baseClass2.default);
(0, _addDebugging2.default)(IME);
exports.default = IME;