// =================================================== // IMPORTANT: only for development // Total.js - framework for Node.js // https://www.totaljs.com // =================================================== const fs = require('fs'); const options = {}; // options.ip = '127.0.0.1'; // options.port = parseInt(process.argv[2]); // options.config = { name: 'Total.js' }; // options.https = { key: fs.readFileSync('keys/agent2-key.pem'), cert: fs.readFileSync('keys/agent2-cert.pem')}; // options.sleep = 3000; // options.debugger = 40894; function debug(){var port=parseInt(process.argv[process.argv.length-1]);return isNaN(port)||(options.port=port),port>0&&!options.port&&(options.port=port||8e3),options.https?F.https('debug',options):(F.http('debug',options),void(first?F.emit('debug-start'):F.emit('debug-restart')))}function app(){function onFilter(path,isDirectory){return!isDirectory&®_THEMES.test(path)?REG_THEMES_INDEX.test(path):!!isDirectory||(REG_EXTENSION.test(path)||REG_COMPONENTS.test(path)||REG_CONFIGS.test(path))}function onIncrease(clear){clear&&(clearTimeout(pidIncrease),speed=TIME),pidIncrease=setTimeout(function(){speed+=TIME,speed>4e3&&(speed=4e3),onIncrease()},12e4)}function onComplete(f){fs.readdir(directory,function(err,arr){for(var length=arr.length,i=0;i0&&(console.log(prefix+'PID: '+process.pid+' (v'+VERSION+')'),pid=path.join(directory,'debug.pid'),fs.writeFileSync(pid,process.pid),setInterval(function(){fs.exists(pid,function(e){e||(fs.unlink(pid,noop),null!==app&&(isSkip=!0,process.kill(app.pid)),process.exit(0))})},2e3)),restart(),refresh_directory()}function run(){if(isDebugging)return void debug();var filename=path.join(directory,'debug.pid');fs.existsSync(filename)?(fs.unlinkSync(filename),setTimeout(function(){app()},3e3)):app()}require('total.js');const isDebugging=process.argv.indexOf('debugging')!==-1,directory=process.cwd(),path=require('path'),VERSION='8.0',TIME=2e3,REG_CONFIGS=/configs\//g,REG_FILES=/config\-debug|config\-release|config|versions|sitemap|dependencies|\.js|\.resource/i,REG_THEMES=/\/themes\//i,REG_COMPONENTS=/components\/.*?\.html/i,REG_THEMES_INDEX=/themes(\/|\\)?[a-z0-9_.-]+(\/|\\)?index\.js/i,REG_EXTENSION=/\.(js|resource|package)/i;var first=process.argv.indexOf('restart')===-1;process.on('uncaughtException',function(e){e.toString().indexOf('ESRCH')==-1&&console.log(e)}),process.title='total: debug',run();