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,wBAA0B,SAAU,EAAM,GAClE,EAAS,KAAM,KAAK,QAAQ,GAAM,IACtC,EAEA,kBAAkB,UAAU,oBAAsB,SAAU,EAAM,GAE9D,EAAS,KAAM,KAAK,QAAQ,GAAM,KACtC,EAEA,kBAAkB,UAAU,iBAAmB,SAAU,GACrD,IAAI,EAAS,oCAAsC,KAAK,KAAO,IAAM,KAAK,KACtE,KAAK,WACL,QAAQ,IAAI,EAAS,aACrB,KAAK,OAAO,OAAM,WACd,EAAS,MAAM,EACnB,MAEA,QAAQ,IAAI,EAAS,4BACrB,EAAS,MAAM,GAEvB,EAEA,kBAAkB,UAAU,WAAa,SAAU,EAAM,EAAQ,GAC7D,IAEI,EAFA,EAAU,KAAK,QAAQ,GACvB,GAAW,EAEX,EAAgB,SAAU,GAC1B,IAAI,EAAJ,CAGA,aAAa,GACb,GAAW,EACX,IAAI,EAAS,CAAC,OAAU,OAAQ,OAAU,GAAI,UAAa,GAAI,OAAU,GAAI,MAAS,IAClF,aAAe,OACf,EAAkB,UAAI,EAAI,MAAM,WAChC,EAAe,OAAI,OACnB,EAAc,MAAI,EAAI,YAEtB,EAAe,OAAI,EAEvB,EAAS,KAAM,EAXf,CAYJ,EACA,EAAU,YAAW,WACjB,EAAc,IAAI,MAAM,iCAC5B,GAAG,KAAK,SAER,EAAO,KAAK,GACZ,IACI,IAAI,EAAS,EAAQ,MAAM,KAAM,EACrC,CAAE,MAAO,GACL,EAAc,EAClB,EAGK,IAAa,GAAW,EAAQ,MAAQ,EAAQ,SAAW,EAAQ,KAAK,SACzE,EAAc,EAEtB,EAEA,kBAAkB,UAAU,gBAAkB,SAAU,GACpD,EAAS,KAAM,OAAO,KAAK,KAAK,SACpC","file":"/npm/robotremoteserver@0.0.6/lib/robotremoteserver.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/robotremoteserver@0.0.6/lib/robotremoteserver.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict'\n\nvar xmlrpc = require('xmlrpc')\n\nfunction RobotRemoteServer(libraries, options) {\n    this.host = options.host\n    this.port = options.port\n    this.timeout = parseInt(options.timeout) || 10000\n\n    var loadedLibraries = {\n        'stop_remote_server': {\n            doc: 'Stop remote server',\n            args: [],\n            impl: this.stopRemoteServer\n        }\n    }\n\n    // Load libraries\n    libraries.forEach(function (lib) {\n        for (var keywordName in lib) {\n            var keyword = lib[keywordName]\n            if (!keyword.args) {\n                keyword.args = []\n                for (var i = 0; i < keyword.length; i++) {\n                    keyword.args.push('arg' + (i + 1))\n                }\n            }\n            if (!keyword.doc) {\n                keyword.doc = ''\n            }\n            loadedLibraries[keywordName] = keyword\n        }\n    })\n    this.library = loadedLibraries\n\n    this.allowStop = options.allowStop === true || false\n    this.server = xmlrpc.createServer(options)\n\n    // Register functions\n    var that = this\n    var rpcWrap = function (keyword) {\n        return function (method, params, response) {\n            params.push(response)\n            keyword.apply(that, params)\n        }\n    }\n    this.server.on('get_keyword_names', rpcWrap(this.getKeywordNames))\n    this.server.on('run_keyword', rpcWrap(this.runKeyword))\n    this.server.on('get_keyword_arguments', rpcWrap(this.getKeywordArguments))\n    this.server.on('get_keyword_documentation', rpcWrap(this.getKeywordDocumentation))\n\n    // Register signal handlers.\n    var handleSignal = function () {\n        that.allowStop = true\n        that.stopRemoteServer(function () {\n        })\n    }\n    process.on('SIGHUP', handleSignal)\n    process.on('SIGINT', handleSignal)\n\n    console.log('Robot Framework remote server starting at ' + this.host + ':' + this.port)\n}\n\nexports.RobotRemoteServer = RobotRemoteServer\n\nRobotRemoteServer.prototype.getKeywordDocumentation = function (name, response) {\n    response(null, this.library[name].doc)\n}\n\nRobotRemoteServer.prototype.getKeywordArguments = function (name, response) {\n\n    response(null, this.library[name].args)\n}\n\nRobotRemoteServer.prototype.stopRemoteServer = function (response) {\n    var prefix = 'Robot Framework remote server at ' + this.host + ':' + this.port\n    if (this.allowStop) {\n        console.log(prefix + ' stopping')\n        this.server.close(function () {\n            response(null, true)\n        })\n    } else {\n        console.log(prefix + ' does not allow stopping')\n        response(null, false)\n    }\n}\n\nRobotRemoteServer.prototype.runKeyword = function (name, params, response) {\n    var keyword = this.library[name]\n    var returned = false\n    var timeout\n    var keywordReturn = function (val) {\n        if (returned) {\n            return\n        }\n        clearTimeout(timeout)\n        returned = true\n        var result = {'status': 'PASS', 'output': '', 'traceback': '', 'return': '', 'error': ''}\n        if (val instanceof Error) {\n            result['traceback'] = val.stack.toString()\n            result['status'] = 'FAIL'\n            result['error'] = val.toString()\n        } else {\n            result['return'] = val\n        }\n        response(null, result)\n    }\n    timeout = setTimeout(function () {\n        keywordReturn(new Error(\"Keyword execution got timeout\"))\n    }, this.timeout)\n\n    params.push(keywordReturn)\n    try {\n        var result = keyword.apply(this, params)\n    } catch (e) {\n        keywordReturn(e)\n    }\n    // The keyword was synchronous.\n    // TODO introduce async attribute for keywords. mutual axclusive with args attribute.\n    if (!returned && (result || (keyword.args && keyword.length === keyword.args.length))) {\n        keywordReturn(result)\n    }\n}\n\nRobotRemoteServer.prototype.getKeywordNames = function (response) {\n    response(null, Object.keys(this.library))\n}\n"]}