Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@youngbeen/angle-ctrl

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@youngbeen/angle-ctrl - npm Package Compare versions

Comparing version
1.0.10-rc1
to
1.0.10
+10
-4
DebugCtrl.js

@@ -47,3 +47,6 @@ "use strict";

},
warn: function warn(info, params) {
warn: function warn() {
var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var params = arguments[1];
var line = '';

@@ -56,3 +59,3 @@ var compName = '';

if (params.line) {
line = params.line;
line = params.line.toString();
msg += "[line:" + line + "]";

@@ -78,3 +81,6 @@ }

},
error: function error(info, params) {
error: function error() {
var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var params = arguments[1];
var line = '';

@@ -87,3 +93,3 @@ var compName = '';

if (params.line) {
line = params.line;
line = params.line.toString();
msg += "[line:" + line + "]";

@@ -90,0 +96,0 @@ }

@@ -6,2 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var angle_util_1 = require("@youngbeen/angle-util");
require("@youngbeen/ums-tracking");
var logs = [];

@@ -21,2 +23,3 @@ var tagRandoms = Math.floor(Math.random() * 10e13);

now = now.getTime();
now = angle_util_1.dateUtil.getDateTime(now);
logs = [].concat(_toConsumableArray(logs), [{

@@ -36,4 +39,10 @@ msg: msg,

var tag = tagTime + "-" + tagRandoms;
if (tracking) {
tracking('UMS_FELOG_ERRORLOG', {
tag: tag,
historyLogs: logs
}, 'fe_errorlog');
}
}
}
};
{
"name": "@youngbeen/angle-ctrl",
"version": "1.0.10-rc1",
"version": "1.0.10",
"description": "The controllers used in angle-FE team",
"main": "index.js",
"types": "src/index.d.ts",
"dependencies": {
"@youngbeen/angle-util": "^1.0.1",
"@youngbeen/ums-tracking": "0.0.2"
"@youngbeen/angle-util": "^1.0.3",
"@youngbeen/ums-tracking": "^0.0.3"
},

@@ -10,0 +11,0 @@ "devDependencies": {

@@ -12,8 +12,8 @@ export interface LogParams {

log(info?: string, params?: LogParams): void;
warn(info: any, params: any): void;
error(info: any, params: any): void;
warn(info?: string, params?: LogParams): void;
error(info?: string, params?: LogParams): void;
debugOn(mode?: DebugType): void;
debugOff(): void;
cheatDebugClick(count: any, interval?: number, mode?: DebugType): void;
cheatDebugClick(count: number, interval?: number, mode?: DebugType): void;
};
export default _default;

@@ -43,3 +43,3 @@ "use strict";

},
warn(info, params) {
warn(info = '', params) {
let line = '';

@@ -52,3 +52,3 @@ let compName = '';

if (params.line) {
line = params.line;
line = params.line.toString();
msg += `[line:${line}]`;

@@ -74,3 +74,3 @@ }

},
error(info, params) {
error(info = '', params) {
let line = '';

@@ -83,3 +83,3 @@ let compName = '';

if (params.line) {
line = params.line;
line = params.line.toString();
msg += `[line:${line}]`;

@@ -86,0 +86,0 @@ }

@@ -66,12 +66,12 @@ // this controller is about to provide functions for debugging controll

// NOTE: warn方法只自动记录日志,不主动发送到后台
warn (info, params) {
let line = ''
let compName = ''
let funcName = ''
let attach = ''
warn (info: string = '', params?: LogParams): void {
let line: string | number = ''
let compName: string = ''
let funcName: string = ''
let attach: any = ''
let msg = info
let msg: string = info
if (params) {
if (params.line) {
line = params.line
line = params.line.toString()
msg += `[line:${line}]`

@@ -103,12 +103,12 @@ }

// NOTE: error方法会自动记录,并自动发送到后台
error (info, params) {
let line = ''
let compName = ''
let funcName = ''
let attach = ''
error (info: string = '', params?: LogParams): void {
let line: string | number = ''
let compName: string = ''
let funcName: string = ''
let attach: any = ''
let msg = info
let msg: string = info
if (params) {
if (params.line) {
line = params.line
line = params.line.toString()
msg += `[line:${line}]`

@@ -156,3 +156,3 @@ }

// open debug mode -- [mode = 1 | 2]
debugOn (mode: DebugType = 1) {
debugOn (mode: DebugType = 1): void {
debug = mode

@@ -163,3 +163,3 @@ window.localStorage.debug = debug

debugOff () {
debugOff (): void {
debug = 0

@@ -171,3 +171,3 @@ window.localStorage.debug = debug

// open debugging mode cheat -- trigger click counts, [interval], [mode]
cheatDebugClick (count, interval = 1000, mode: DebugType = 1) {
cheatDebugClick (count: number, interval: number = 1000, mode: DebugType = 1): void {
cheatCounts++

@@ -174,0 +174,0 @@ if (cheatCounts >= count) {

@@ -5,4 +5,4 @@ export declare const timeCtrl: {

step: number;
tick: import("./TimeCtrl").Callback;
end: import("./TimeCtrl").Callback;
tick: (data: import("./TimeCtrl").CallbackData) => any;
end: (data: import("./TimeCtrl").CallbackData) => any;
}): void;

@@ -13,8 +13,8 @@ countUp({ start, total, step, tick, end }: {

step: number;
tick: import("./TimeCtrl").Callback;
end: import("./TimeCtrl").Callback;
tick: (data: import("./TimeCtrl").CallbackData) => any;
end: (data: import("./TimeCtrl").CallbackData) => any;
}): void;
};
export declare const logCtrl: {
saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void;
saveLog(msg: string, type: string, line?: string, compName?: string, funcName?: string, attach?: any): void;
sendLog(): void;

@@ -24,7 +24,7 @@ };

log(info?: string, params?: import("./DebugCtrl").LogParams): void;
warn(info: any, params: any): void;
error(info: any, params: any): void;
warn(info?: string, params?: import("./DebugCtrl").LogParams): void;
error(info?: string, params?: import("./DebugCtrl").LogParams): void;
debugOn(mode?: 0 | 2 | 1): void;
debugOff(): void;
cheatDebugClick(count: any, interval?: number, mode?: 0 | 2 | 1): void;
cheatDebugClick(count: number, interval?: number, mode?: 0 | 2 | 1): void;
};

@@ -0,5 +1,6 @@

import '@youngbeen/ums-tracking';
declare const _default: {
saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void;
saveLog(msg: string, type: string, line?: string, compName?: string, funcName?: string, attach?: any): void;
sendLog(): void;
};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const angle_util_1 = require("@youngbeen/angle-util");
require("@youngbeen/ums-tracking");
let logs = [];

@@ -12,2 +14,3 @@ const tagRandoms = Math.floor(Math.random() * 10e13);

now = now.getTime();
now = angle_util_1.dateUtil.getDateTime(now);
logs = [...logs, {

@@ -27,4 +30,10 @@ msg,

const tag = `${tagTime}-${tagRandoms}`;
if (tracking) {
tracking('UMS_FELOG_ERRORLOG', {
tag,
historyLogs: logs
}, 'fe_errorlog');
}
}
}
};
// this controller is about to provide functions for log controll
// import { dateUtil } from '@youngbeen/angle-util'
// require('@youngbeen/ums-tracking')
let logs = [] // 日志信息
const tagRandoms = Math.floor(Math.random() * 10e13) // 用于标识某访问的唯一标识符组成部分的随机数
import { dateUtil } from '@youngbeen/angle-util'
import '@youngbeen/ums-tracking'
// 定义type
// 定义shape
interface LogInfo {
msg: string
type: string
clientTime: string | number | Date
line: string
compName: string
funcName: string
attach: any,
[propName: string]: any
}
let logs: Array<LogInfo> = [] // 日志信息
const tagRandoms: number = Math.floor(Math.random() * 10e13) // 用于标识某访问的唯一标识符组成部分的随机数
let tagTime: Date | number = new Date()

@@ -12,7 +27,7 @@ tagTime = tagTime.getTime() // 用于标识某访问的唯一标识符组成部分的时间戳

// 保存日志到历史记录 -- 信息内容,信息类型,[ 行数,所在组件名,所在函数名,附加信息 ]
saveLog (msg, type, line = '', compName = '', funcName = '', attach = '') {
saveLog (msg: string, type: string, line: string = '', compName: string = '', funcName: string = '', attach: any = ''): void {
if (msg && type) {
let now: Date | number = new Date()
let now: Date | number | string = new Date()
now = now.getTime()
// now = dateUtil.getDateTime(now)
now = dateUtil.getDateTime(now)

@@ -32,12 +47,12 @@ logs = [...logs, {

// 发送日志到日志系统 --
sendLog () {
sendLog (): void {
if (logs.length) {
const tag = `${tagTime}-${tagRandoms}` // 组成该次访问的唯一标识符,用于日志筛选匹配对应使用
const tag: string = `${tagTime}-${tagRandoms}` // 组成该次访问的唯一标识符,用于日志筛选匹配对应使用
// 使用tracking方法发送日志
// if (window.tracking) {
// window.tracking('UMS_FELOG_ERRORLOG', {
// tag,
// historyLogs: logs
// }, 'fe_errorlog')
// }
if (tracking) {
tracking('UMS_FELOG_ERRORLOG', {
tag,
historyLogs: logs
}, 'fe_errorlog')
}
// 使用图片发送日志

@@ -44,0 +59,0 @@ // let url = `https://someurl?type=UMS_FELOG&content=LOGSTART>>${encodeURIComponent(JSON.stringify(content))}<<LOGEND`

@@ -1,2 +0,2 @@

interface CallbackData {
export interface CallbackData {
leftCount?: number;

@@ -6,5 +6,3 @@ count?: number;

}
export interface Callback {
(data: CallbackData): any;
}
declare type Callback = (data: CallbackData) => any;
declare const _default: {

@@ -11,0 +9,0 @@ countDown({ total, step, tick, end }: {

// this controller is about to provide functions for time controll
// 定义shape
interface CallbackData {
export interface CallbackData {
leftCount?: number

@@ -9,6 +9,6 @@ count?: number

}
export interface Callback {
(data: CallbackData): any
}
// 定义type
type Callback = (data: CallbackData) => any
export default {

@@ -15,0 +15,0 @@ // auto counting down -- { [total], [step], [tick], [end] }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LogCtrl_1 = require("./LogCtrl");
var debug = 0;
var cheatCounts = 0;
var tcCheatDebug = null;
exports.default = {
log: function log() {
var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var params = arguments[1];
var isSave = false;
var line = '';
var compName = '';
var funcName = '';
var attach = '';
var msg = info;
if (params) {
if (params.isSave) {
isSave = true;
}
if (params.line) {
line = params.line.toString();
msg += "[line:" + line + "]";
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
}
if (params.attach) {
attach = params.attach;
}
}
console.log(msg);
if (isSave) {
LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach);
}
if (debug > 1) {
window.alert(msg);
}
},
warn: function warn(info, params) {
var line = '';
var compName = '';
var funcName = '';
var attach = '';
var msg = info;
if (params) {
if (params.line) {
line = params.line;
msg += "[line:" + line + "]";
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
}
if (params.attach) {
attach = params.attach;
}
}
console.warn(msg);
LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach);
if (debug) {
window.alert(msg);
}
},
error: function error(info, params) {
var line = '';
var compName = '';
var funcName = '';
var attach = '';
var msg = info;
if (params) {
if (params.line) {
line = params.line;
msg += "[line:" + line + "]";
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
}
if (params.attach) {
attach = params.attach;
}
}
console.warn(msg);
LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach);
LogCtrl_1.default.sendLog();
if (debug) {
window.alert(msg);
}
},
debugOn: function debugOn() {
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
debug = mode;
window.localStorage.debug = debug;
window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A" + (mode === 2 ? '严格模式' : '开启'));
},
debugOff: function debugOff() {
debug = 0;
window.localStorage.debug = debug;
window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A\u5173\u95ED");
},
cheatDebugClick: function cheatDebugClick(count) {
var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
cheatCounts++;
if (cheatCounts >= count) {
if (debug) {
debug = 0;
} else {
debug = mode;
}
window.localStorage.debug = debug;
window.alert('debug模式调整为开启');
if (tcCheatDebug) {
clearTimeout(tcCheatDebug);
}
cheatCounts = 0;
} else {
if (tcCheatDebug) {
clearTimeout(tcCheatDebug);
}
tcCheatDebug = setTimeout(function () {
cheatCounts = 0;
clearTimeout(tcCheatDebug);
}, interval);
}
}
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TimeCtrl_1 = require("./TimeCtrl");
var DebugCtrl_1 = require("./DebugCtrl");
exports.timeCtrl = TimeCtrl_1.default;
exports.debugCtrl = DebugCtrl_1.default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
countDown: function countDown(_ref) {
var _ref$total = _ref.total,
total = _ref$total === undefined ? 60 : _ref$total,
_ref$step = _ref.step,
step = _ref$step === undefined ? 1000 : _ref$step,
_ref$tick = _ref.tick,
tick = _ref$tick === undefined ? null : _ref$tick,
_ref$end = _ref.end,
end = _ref$end === undefined ? null : _ref$end;
total > 0 ? total : total = 60;
step > 0 ? step : step = 1000;
var tickCallback = tick || function () {};
var endCallback = end || function () {};
var tc = setInterval(function () {
if (total > 0) {
tickCallback({ leftCount: total });
total--;
} else {
endCallback({ leftCount: total });
clearInterval(tc);
}
}, step);
},
countUp: function countUp(_ref2) {
var _ref2$start = _ref2.start,
start = _ref2$start === undefined ? 0 : _ref2$start,
_ref2$total = _ref2.total,
total = _ref2$total === undefined ? 60 : _ref2$total,
_ref2$step = _ref2.step,
step = _ref2$step === undefined ? 1000 : _ref2$step,
_ref2$tick = _ref2.tick,
tick = _ref2$tick === undefined ? null : _ref2$tick,
_ref2$end = _ref2.end,
end = _ref2$end === undefined ? null : _ref2$end;
if (start > total) {
console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)');
return;
}
var now = start;
step > 0 ? step : step = 1000;
var tickCallback = tick || function () {};
var endCallback = end || function () {};
var tc = setInterval(function () {
if (now < total) {
tickCallback({ count: now });
now++;
} else {
endCallback({ count: now });
clearInterval(tc);
}
}, step);
}
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LogCtrl_1 = require("./LogCtrl");
var debug = 0;
var cheatCounts = 0;
var tcCheatDebug = null;
exports.default = {
log: function log() {
var info = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var params = arguments[1];
var isSave = false;
var line = '';
var compName = '';
var funcName = '';
var attach = '';
var msg = info;
if (params) {
if (params.isSave) {
isSave = true;
}
if (params.line) {
line = params.line.toString();
msg += "[line:" + line + "]";
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
}
if (params.attach) {
attach = params.attach;
}
}
console.log(msg);
if (isSave) {
LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach);
}
if (debug > 1) {
window.alert(msg);
}
},
warn: function warn(info, params) {
var line = '';
var compName = '';
var funcName = '';
var attach = '';
var msg = info;
if (params) {
if (params.line) {
line = params.line;
msg += "[line:" + line + "]";
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
}
if (params.attach) {
attach = params.attach;
}
}
console.warn(msg);
LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach);
if (debug) {
window.alert(msg);
}
},
error: function error(info, params) {
var line = '';
var compName = '';
var funcName = '';
var attach = '';
var msg = info;
if (params) {
if (params.line) {
line = params.line;
msg += "[line:" + line + "]";
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
}
if (params.attach) {
attach = params.attach;
}
}
console.warn(msg);
LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach);
LogCtrl_1.default.sendLog();
if (debug) {
window.alert(msg);
}
},
debugOn: function debugOn() {
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
debug = mode;
window.localStorage.debug = debug;
window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A" + (mode === 2 ? '严格模式' : '开启'));
},
debugOff: function debugOff() {
debug = 0;
window.localStorage.debug = debug;
window.alert("debug\u6A21\u5F0F\u8C03\u6574\u4E3A\u5173\u95ED");
},
cheatDebugClick: function cheatDebugClick(count) {
var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
cheatCounts++;
if (cheatCounts >= count) {
if (debug) {
debug = 0;
} else {
debug = mode;
}
window.localStorage.debug = debug;
window.alert('debug模式调整为开启');
if (tcCheatDebug) {
clearTimeout(tcCheatDebug);
}
cheatCounts = 0;
} else {
if (tcCheatDebug) {
clearTimeout(tcCheatDebug);
}
tcCheatDebug = setTimeout(function () {
cheatCounts = 0;
clearTimeout(tcCheatDebug);
}, interval);
}
}
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TimeCtrl_1 = require("./TimeCtrl");
var LogCtrl_1 = require("./LogCtrl");
var DebugCtrl_1 = require("./DebugCtrl");
exports.timeCtrl = TimeCtrl_1.default;
exports.logCtrl = LogCtrl_1.default;
exports.debugCtrl = DebugCtrl_1.default;
"use strict";
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
Object.defineProperty(exports, "__esModule", { value: true });
var logs = [];
var tagRandoms = Math.floor(Math.random() * 10e13);
var tagTime = new Date();
tagTime = tagTime.getTime();
exports.default = {
saveLog: function saveLog(msg, type) {
var line = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var compName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var funcName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
var attach = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
if (msg && type) {
var now = new Date();
now = now.getTime();
logs = [].concat(_toConsumableArray(logs), [{
msg: msg,
type: type,
clientTime: now,
compName: compName,
funcName: funcName,
line: line,
attach: attach
}]);
}
},
sendLog: function sendLog() {
if (logs.length) {
var tag = tagTime + "-" + tagRandoms;
}
}
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
countDown: function countDown(_ref) {
var _ref$total = _ref.total,
total = _ref$total === undefined ? 60 : _ref$total,
_ref$step = _ref.step,
step = _ref$step === undefined ? 1000 : _ref$step,
_ref$tick = _ref.tick,
tick = _ref$tick === undefined ? null : _ref$tick,
_ref$end = _ref.end,
end = _ref$end === undefined ? null : _ref$end;
total > 0 ? total : total = 60;
step > 0 ? step : step = 1000;
var tickCallback = tick || function () {};
var endCallback = end || function () {};
var tc = setInterval(function () {
if (total > 0) {
tickCallback({ leftCount: total });
total--;
} else {
endCallback({ leftCount: total });
clearInterval(tc);
}
}, step);
},
countUp: function countUp(_ref2) {
var _ref2$start = _ref2.start,
start = _ref2$start === undefined ? 0 : _ref2$start,
_ref2$total = _ref2.total,
total = _ref2$total === undefined ? 60 : _ref2$total,
_ref2$step = _ref2.step,
step = _ref2$step === undefined ? 1000 : _ref2$step,
_ref2$tick = _ref2.tick,
tick = _ref2$tick === undefined ? null : _ref2$tick,
_ref2$end = _ref2.end,
end = _ref2$end === undefined ? null : _ref2$end;
if (start > total) {
console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)');
return;
}
var now = start;
step > 0 ? step : step = 1000;
var tickCallback = tick || function () {};
var endCallback = end || function () {};
var tc = setInterval(function () {
if (now < total) {
tickCallback({ count: now });
now++;
} else {
endCallback({ count: now });
clearInterval(tc);
}
}, step);
}
};
export interface LogParams {
isSave?: boolean;
line?: string | number;
compName?: string;
funcName?: string;
attach?: any;
[propName: string]: any;
}
declare type DebugType = 0 | 1 | 2;
declare const _default: {
log(info?: string, params?: LogParams): void;
warn(info: any, params: any): void;
error(info: any, params: any): void;
debugOn(mode?: DebugType): void;
debugOff(): void;
cheatDebugClick(count: any, interval?: number, mode?: DebugType): void;
};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const LogCtrl_1 = require("./LogCtrl");
let debug = 0;
let cheatCounts = 0;
let tcCheatDebug = null;
exports.default = {
log(info = '', params) {
let isSave = false;
let line = '';
let compName = '';
let funcName = '';
let attach = '';
let msg = info;
if (params) {
if (params.isSave) {
isSave = true;
}
if (params.line) {
line = params.line.toString();
msg += `[line:${line}]`;
}
if (params.compName) {
compName = params.compName;
msg += `[comp:${compName}]`;
}
if (params.funcName) {
funcName = params.funcName;
msg += `[func:${funcName}]`;
}
if (params.attach) {
attach = params.attach;
}
}
console.log(msg);
if (isSave) {
LogCtrl_1.default.saveLog(info, 'info', line, compName, funcName, attach);
}
if (debug > 1) {
window.alert(msg);
}
},
warn(info, params) {
let line = '';
let compName = '';
let funcName = '';
let attach = '';
let msg = info;
if (params) {
if (params.line) {
line = params.line;
msg += `[line:${line}]`;
}
if (params.compName) {
compName = params.compName;
msg += `[comp:${compName}]`;
}
if (params.funcName) {
funcName = params.funcName;
msg += `[func:${funcName}]`;
}
if (params.attach) {
attach = params.attach;
}
}
console.warn(msg);
LogCtrl_1.default.saveLog(info, 'warn', line, compName, funcName, attach);
if (debug) {
window.alert(msg);
}
},
error(info, params) {
let line = '';
let compName = '';
let funcName = '';
let attach = '';
let msg = info;
if (params) {
if (params.line) {
line = params.line;
msg += `[line:${line}]`;
}
if (params.compName) {
compName = params.compName;
msg += `[comp:${compName}]`;
}
if (params.funcName) {
funcName = params.funcName;
msg += `[func:${funcName}]`;
}
if (params.attach) {
attach = params.attach;
}
}
console.warn(msg);
LogCtrl_1.default.saveLog(info, 'error', line, compName, funcName, attach);
LogCtrl_1.default.sendLog();
if (debug) {
window.alert(msg);
}
},
debugOn(mode = 1) {
debug = mode;
window.localStorage.debug = debug;
window.alert(`debug模式调整为${mode === 2 ? '严格模式' : '开启'}`);
},
debugOff() {
debug = 0;
window.localStorage.debug = debug;
window.alert(`debug模式调整为关闭`);
},
cheatDebugClick(count, interval = 1000, mode = 1) {
cheatCounts++;
if (cheatCounts >= count) {
if (debug) {
debug = 0;
}
else {
debug = mode;
}
window.localStorage.debug = debug;
window.alert('debug模式调整为开启');
if (tcCheatDebug) {
clearTimeout(tcCheatDebug);
}
cheatCounts = 0;
}
else {
if (tcCheatDebug) {
clearTimeout(tcCheatDebug);
}
tcCheatDebug = setTimeout(() => {
cheatCounts = 0;
clearTimeout(tcCheatDebug);
}, interval);
}
}
};
export declare const timeCtrl: {
countDown({ total, step, tick, end }: {
total: number;
step: number;
tick: import("./TimeCtrl").Callback;
end: import("./TimeCtrl").Callback;
}): void;
countUp({ start, total, step, tick, end }: {
start: number;
total: number;
step: number;
tick: import("./TimeCtrl").Callback;
end: import("./TimeCtrl").Callback;
}): void;
};
export declare const logCtrl: {
saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void;
sendLog(): void;
};
export declare const debugCtrl: {
log(info?: string, params?: import("./DebugCtrl").LogParams): void;
warn(info: any, params: any): void;
error(info: any, params: any): void;
debugOn(mode?: 0 | 2 | 1): void;
debugOff(): void;
cheatDebugClick(count: any, interval?: number, mode?: 0 | 2 | 1): void;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const TimeCtrl_1 = require("./TimeCtrl");
const LogCtrl_1 = require("./LogCtrl");
const DebugCtrl_1 = require("./DebugCtrl");
exports.timeCtrl = TimeCtrl_1.default;
exports.logCtrl = LogCtrl_1.default;
exports.debugCtrl = DebugCtrl_1.default;
declare const _default: {
saveLog(msg: any, type: any, line?: string, compName?: string, funcName?: string, attach?: string): void;
sendLog(): void;
};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
let logs = [];
const tagRandoms = Math.floor(Math.random() * 10e13);
let tagTime = new Date();
tagTime = tagTime.getTime();
exports.default = {
saveLog(msg, type, line = '', compName = '', funcName = '', attach = '') {
if (msg && type) {
let now = new Date();
now = now.getTime();
logs = [...logs, {
msg,
type,
clientTime: now,
compName,
funcName,
line,
attach
}];
}
},
sendLog() {
if (logs.length) {
const tag = `${tagTime}-${tagRandoms}`;
}
}
};
interface CallbackData {
leftCount?: number;
count?: number;
[propName: string]: any;
}
export interface Callback {
(data: CallbackData): any;
}
declare const _default: {
countDown({ total, step, tick, end }: {
total: number;
step: number;
tick: Callback;
end: Callback;
}): void;
countUp({ start, total, step, tick, end }: {
start: number;
total: number;
step: number;
tick: Callback;
end: Callback;
}): void;
};
export default _default;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
countDown({ total = 60, step = 1000, tick = null, end = null }) {
total > 0 ? total : total = 60;
step > 0 ? step : step = 1000;
let tickCallback = tick || function () {
};
let endCallback = end || function () {
};
let tc = setInterval(function () {
if (total > 0) {
tickCallback({ leftCount: total });
total--;
}
else {
endCallback({ leftCount: total });
clearInterval(tc);
}
}, step);
},
countUp({ start = 0, total = 60, step = 1000, tick = null, end = null }) {
if (start > total) {
console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)');
return;
}
let now = start;
step > 0 ? step : step = 1000;
let tickCallback = tick || function () {
};
let endCallback = end || function () {
};
let tc = setInterval(function () {
if (now < total) {
tickCallback({ count: now });
now++;
}
else {
endCallback({ count: now });
clearInterval(tc);
}
}, step);
}
};