You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3 lines
5.5 KiB
3 lines
5.5 KiB
|
3 years ago
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.logWarn=logWarn,exports.mkdirsSync=mkdirsSync,exports.getIPv4IPAddress=getIPv4IPAddress,exports.getServerIPAndPort=getServerIPAndPort,exports.getClientIPAddress=getClientIPAddress,exports.stripPrefixForIPV4MappedIPV6Address=stripPrefixForIPV4MappedIPV6Address,exports.outputQRCodeOnTerminal=outputQRCodeOnTerminal,exports.relateCwd=relateCwd,exports.equals=equals,exports.extend=extend,exports.renderString=renderString,exports.KnownError=KnownError,exports.debounce=debounce,exports.setCustomConfig=setCustomConfig,exports.getProjectDslName=getProjectDslName,exports.getDeviceInfo=getDeviceInfo,Object.defineProperty(exports,"getLaunchPage",{enumerable:!0,get:function(){return _util.getLaunchPage}}),exports.colorconsole=void 0;var _os=_interopRequireDefault(require("os")),_fs=_interopRequireDefault(require("fs")),_path=_interopRequireDefault(require("path")),_http=_interopRequireDefault(require("http")),_console=require("console"),_chalk=_interopRequireDefault(require("chalk")),_qrcodeTerminal=_interopRequireDefault(require("qrcode-terminal")),_config=_interopRequireDefault(require("../config")),_util=require("./buildMode/util");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const logLevelMap={};function prependLevel(e,t){if(!logLevelMap[e]){const t=e.toUpperCase().substr(0,4);logLevelMap[e]=t}"string"==typeof t[0]&&t[0].length>1&&"["!==t[0][0]&&(t[0]=`[${logLevelMap[e]}] ${t[0]}`)}let originConsole=global.console,console=_console.Console?new _console.Console(process.stdout,process.stderr):originConsole;const colorconsole={init(e){e&&_console.Console&&(console=new _console.Console(e,e))},trace(...e){prependLevel("trace",e),console.trace(...e)},log(...e){prependLevel("log",e),console.log(_chalk.default.green(...e))},info(...e){prependLevel("info",e),console.info(_chalk.default.green(...e))},warn(...e){prependLevel("warn",e),console.warn(_chalk.default.yellow.bold(...e))},error(...e){prependLevel("error",e),console.error(_chalk.default.red.bold(...e))},throw(...e){throw new Error(_chalk.default.red.bold(...e))}};function logWarn(e,t,o){t&&t.length&&t.forEach(t=>{const r=t.line&&t.column?"\t@"+t.line+":"+t.column:"";o||(t.reason.startsWith("ERROR")?colorconsole.error(e.context,t.reason+r):colorconsole.warn(e.context,t.reason+r))})}function mkdirsSync(e){return!!_fs.default.existsSync(e)||(mkdirsSync(_path.default.dirname(e))?(_fs.default.mkdirSync(e),!0):void 0)}function getIPv4IPAddress(){const e=_os.default.networkInterfaces();let t;for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){if(e[o].every(e=>!("IPv4"===e.family&&!e.internal&&"127.0.0.1"!==e.address)||(t=e,!1)),void 0!==t)break}return t&&t.address}function getServerIPAndPort(e){return(getIPv4IPAddress()||"127.0.0.1")+`${80===e?"":":"+e}`}function getClientIPAddress(e){return stripPrefixForIPV4MappedIPV6Address(e.headers["x-forwarded-for"]||e.connection&&e.connection.remoteAddress||e.socket&&e.socket.remoteAddress||e.connection&&e.connection.socket&&e.connection.socket.remoteAddress)}function stripPrefixForIPV4MappedIPV6Address(e){return/^::1$/.test(e)&&(e="127.0.0.1"),/^::.{0,4}:(\d{1,3}\.){3}\d{1,3}/.test(e)&&(e=e.replace(/^.*:/,"")),e}function outputQRCodeOnTerminal(e){console.info(`\n生成HTTP服务器的二维码: ${e}`),_qrcodeTerminal.default.generate(e,{small:!0})}function relateCwd(e){const t=_config.default.projectPath;return _path.default.relative(t,e)}function equals(e,t,o,...r){if(o){if(o(e,t,...r))return!0}const n=Object.prototype.toString.call(e);if(n!==Object.prototype.toString.call(t))return!1;if("[object Null]"===n||"[object Undefined]"===n)return!0;if("[object Object]"!==n&&"[object Array]"!==n)return Object(e).toString()===Object(t).toString();const s={};Object.keys(e).forEach(e=>s[e]=!0),Object.keys(t).forEach(e=>s[e]=!0);const l=Object.keys(s);for(let r=0;r<l.length;r++){const n=l[r];if(!equals(e[n],t[n],o,n))return!1}return!0}function extend(e,...t){if("function"==typeof Object.assign)Object.assign(e,...t);else{const o=t.shift();for(cons
|
||
|
|
//# sourceMappingURL=index.js.map
|