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,IAAI,WAAa,UAAU,QAErC","file":"/npm/rserv@1.1.3/rserv.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/rserv@1.1.3/rserv.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var fs = require('fs');\nvar http = require('http');\nvar path = require('path');\n\nvar _ = require('lodash');\nvar packageJSON = require('./package.json');\nvar express = require('express');\nvar compression = require('compression');\nvar serveIndex = require('serve-index');\nvar WebSocket = require('faye-websocket');\nvar chokidar = require('chokidar');\nvar rewrite = require('connect-body-rewrite');\nvar commander = require('commander');\n\nvar ws;\n\nmodule.exports = function (){\n\n  var default_timeout = 0;\n  var default_port = 3000;\n  var default_root = '.';\n\n  commander\n    .version(packageJSON.version)\n    .option('-t, --timeout [type]', 'timeout [' + default_timeout + ']', default_timeout)\n    .option('-p, --port [type]', 'port [' + default_port + ']', default_port)\n    .option('-r, --root [type]', 'root directory [' + default_root + '] (current directory)', default_root)\n    .parse(process.argv);\n\n  var client = fs.readFileSync(path.join(__dirname, 'client.html'), 'utf-8');\n\n  var server = http.Server(express()\n    .use(rewrite({\n      accept: function (res) {\n        return res.getHeader('content-type').match(/text\\/html/);\n      },\n      rewrite: function (body) {\n        return body.match('</body>') ? body.replace(/<\\/body>/, client) : body + '\\n' + client;\n      }\n    }))\n    .use(express.static(commander.root))\n    .use('/', serveIndex(commander.root, {'icons': true}))\n    .use(compression()));\n\n  server.addListener('upgrade', function (request, socket, head) {\n    ws = new WebSocket(request, socket, head);\n  });\n\n  server.listen(commander.port);\n\n  chokidar.watch(commander.root, {ignored: /[\\/\\\\]\\./}).on('all', _.debounce(function (event, path) {\n    if (!ws) return;\n    console.log(event, path);\n    ws.send('reload');\n  }, commander.timeout));\n\n  console.log('rserv started...');\n  console.log((commander.root === '.') ? __dirname : __dirname + '/' + commander.root);\n  console.log('http://localhost:' + commander.port);\n  console.log('timeout:' + commander.timeout);\n\n};\n"]}