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.7
to
1.0.8
+5
.babelrc
{
"presets": [
"env"
]
}
+47
-37

@@ -1,16 +0,22 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
Object.defineProperty(exports, "__esModule", {
value: true
});
// this controller is about to provide functions for debugging controll
var _LogCtrl = require('./LogCtrl');
var logCtrl = _interopRequire(require("./LogCtrl"));
var _LogCtrl2 = _interopRequireDefault(_LogCtrl);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// import System from '../models/System'
// import $ from 'jQuery'
var debug = 0; // debug模式, 0 - 关闭debug,1 - 初级debug(仅alert警告和错误), 2 - 严格debug(alert所有信息)
// this controller is about to provide functions for debugging controll
var cheatCounts = 0; // cheat debug点击的累计次数
var tcCheatDebug = null; // cheat debug time ctrl
module.exports = {
exports.default = {
// system log -- 信息,[ 是否记录到log中,所在组件名,所在函数名,行数,附加信息 ]

@@ -20,6 +26,6 @@ // NOTE: log方法默认不会记录到日志中

var isSave = false;
var line = "";
var compName = "";
var funcName = "";
var attach = "";
var line = '';
var compName = '';
var funcName = '';
var attach = '';

@@ -33,11 +39,11 @@ var msg = info;

line = params.line;
msg += "[line:" + line + "]";
msg += '[line:' + line + ']';
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
msg += '[comp:' + compName + ']';
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
msg += '[func:' + funcName + ']';
}

@@ -51,3 +57,3 @@ if (params.attach) {

if (isSave) {
logCtrl.saveLog(info, "info", line, compName, funcName, attach);
_LogCtrl2.default.saveLog(info, 'info', line, compName, funcName, attach);
}

@@ -61,9 +67,10 @@

// system warn -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ]
// NOTE: warn方法只自动记录日志,不主动发送到后台
warn: function warn(info, params) {
var line = "";
var compName = "";
var funcName = "";
var attach = "";
var line = '';
var compName = '';
var funcName = '';
var attach = '';

@@ -74,11 +81,11 @@ var msg = info;

line = params.line;
msg += "[line:" + line + "]";
msg += '[line:' + line + ']';
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
msg += '[comp:' + compName + ']';
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
msg += '[func:' + funcName + ']';
}

@@ -91,3 +98,3 @@ if (params.attach) {

console.warn(msg);
logCtrl.saveLog(info, "warn", line, compName, funcName, attach);
_LogCtrl2.default.saveLog(info, 'warn', line, compName, funcName, attach);

@@ -100,9 +107,10 @@ if (debug) {

// system error -- 信息,[ 所在组件名,所在函数名,行数,附加信息 ]
// NOTE: error方法会自动记录,并自动发送到后台
error: function error(info, params) {
var line = "";
var compName = "";
var funcName = "";
var attach = "";
var line = '';
var compName = '';
var funcName = '';
var attach = '';

@@ -113,11 +121,11 @@ var msg = info;

line = params.line;
msg += "[line:" + line + "]";
msg += '[line:' + line + ']';
}
if (params.compName) {
compName = params.compName;
msg += "[comp:" + compName + "]";
msg += '[comp:' + compName + ']';
}
if (params.funcName) {
funcName = params.funcName;
msg += "[func:" + funcName + "]";
msg += '[func:' + funcName + ']';
}

@@ -130,5 +138,5 @@ if (params.attach) {

console.warn(msg);
logCtrl.saveLog(info, "error", line, compName, funcName, attach);
_LogCtrl2.default.saveLog(info, 'error', line, compName, funcName, attach);
// 发生错误,立即发送信息到日志系统
logCtrl.sendLog();
_LogCtrl2.default.sendLog();

@@ -141,2 +149,3 @@ if (debug) {

// // freeze background scroll

@@ -159,19 +168,19 @@ // freezeBgScroll() {

debugOn: function debugOn() {
var mode = arguments[0] === undefined ? 1 : arguments[0];
var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
debug = mode;
window.localStorage.debug = debug;
window.alert("debug模式调整为" + (mode === 2 ? "严格模式" : "开启"));
window.alert('debug\u6A21\u5F0F\u8C03\u6574\u4E3A' + (mode === 2 ? '严格模式' : '开启'));
},
debugOff: function debugOff() {
debug = 0;
window.localStorage.debug = debug;
window.alert("debug模式调整为关闭");
window.alert('debug\u6A21\u5F0F\u8C03\u6574\u4E3A\u5173\u95ED');
},
// open debugging mode cheat -- trigger click counts, [interval], [mode]
cheatDebugClick: function cheatDebugClick(count) {
var interval = arguments[1] === undefined ? 1000 : arguments[1];
var mode = arguments[2] === undefined ? 1 : arguments[2];
var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1000;
var mode = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;

@@ -187,3 +196,3 @@ cheatCounts++;

window.localStorage.debug = debug;
window.alert("debug模式调整为开启");
window.alert('debug模式调整为开启');
if (tcCheatDebug) {

@@ -239,2 +248,3 @@ clearTimeout(tcCheatDebug);

// }
};
+16
-13

@@ -1,21 +0,24 @@

"use strict";
'use strict';
var _interopRequire = function (obj) { return obj && obj.__esModule ? obj["default"] : obj; };
Object.defineProperty(exports, "__esModule", {
value: true
});
// entry js
exports.debugCtrl = exports.logCtrl = exports.timeCtrl = undefined;
var TimeCtrl = _interopRequire(require("./TimeCtrl"));
var _TimeCtrl = require('./TimeCtrl');
var LogCtrl = _interopRequire(require("./LogCtrl"));
var _TimeCtrl2 = _interopRequireDefault(_TimeCtrl);
var DebugCtrl = _interopRequire(require("./DebugCtrl"));
var _LogCtrl = require('./LogCtrl');
var timeCtrl = TimeCtrl;
exports.timeCtrl = timeCtrl;
var logCtrl = LogCtrl;
exports.logCtrl = logCtrl;
var debugCtrl = DebugCtrl;
exports.debugCtrl = debugCtrl;
var _LogCtrl2 = _interopRequireDefault(_LogCtrl);
var _DebugCtrl = require('./DebugCtrl');
var _DebugCtrl2 = _interopRequireDefault(_DebugCtrl);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var timeCtrl = exports.timeCtrl = _TimeCtrl2.default; // entry js
var logCtrl = exports.logCtrl = _LogCtrl2.default;
var debugCtrl = exports.debugCtrl = _DebugCtrl2.default;

@@ -1,21 +0,23 @@

"use strict";
'use strict';
var _toConsumableArray = function (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
});
// this controller is about to provide functions for log controll
var _angleUtil = require('@youngbeen/angle-util');
var dateUtil = require("@youngbeen/angle-util").dateUtil;
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); } } // this controller is about to provide functions for log controll
var logs = []; // 日志信息
var tagRandoms = Math.floor(Math.random() * 100000000000000); // 用于标识某访问的唯一标识符组成部分的随机数
var tagRandoms = Math.floor(Math.random() * 10e13); // 用于标识某访问的唯一标识符组成部分的随机数
var tagTime = new Date();
tagTime = tagTime.getTime(); // 用于标识某访问的唯一标识符组成部分的时间戳
module.exports = {
exports.default = {
// 保存日志到历史记录 -- 信息内容,信息类型,[ 行数,所在组件名,所在函数名,附加信息 ]
saveLog: function saveLog(msg, type) {
var line = arguments[2] === undefined ? "" : arguments[2];
var compName = arguments[3] === undefined ? "" : arguments[3];
var funcName = arguments[4] === undefined ? "" : arguments[4];
var attach = arguments[5] === undefined ? "" : arguments[5];
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] : '';

@@ -25,3 +27,3 @@ if (msg && type) {

now = now.getTime();
now = dateUtil.getDateTime(now);
now = _angleUtil.dateUtil.getDateTime(now);

@@ -40,25 +42,24 @@ logs = [].concat(_toConsumableArray(logs), [{

// 发送日志到日志系统 --
sendLog: function sendLog() {
if (logs.length) {
var tag = "" + tagTime + "-" + tagRandoms; // 组成该次访问的唯一标识符,用于日志筛选匹配对应使用
var tag = tagTime + '-' + tagRandoms; // 组成该次访问的唯一标识符,用于日志筛选匹配对应使用
var now = new Date();
now = now.getTime();
now = dateUtil.getDateTime(now);
now = _angleUtil.dateUtil.getDateTime(now);
var params = {
url: window.location.href || "",
url: window.location.href || '',
tag: tag,
ua: window.navigator.userAgent || "",
ua: window.navigator.userAgent || '',
clientTime: now, // 格式形如 2017-01-01 10:00:00
historyLogs: logs
};
// window.tracking('UMS_FELOG_ERRORLOG', params)
var content = {
id: "UMS_FELOG_ERRORLOG",
// window.tracking('UMS_FELOG_ERRORLOG', params)
};var content = {
id: 'UMS_FELOG_ERRORLOG',
params: params
};
// TODO 自有后台接收日志的地址后续需要调整
var url = "https://someurl?type=UMS_FELOG&content=LOGSTART>>" + encodeURIComponent(JSON.stringify(content)) + "<<LOGEND";
// TODO 自有后台接收日志的地址后续需要调整
};var url = 'https://someurl?type=UMS_FELOG&content=LOGSTART>>' + encodeURIComponent(JSON.stringify(content)) + '<<LOGEND';
var oImage = new Image();

@@ -65,0 +66,0 @@ oImage.src = url;

{
"name": "@youngbeen/angle-ctrl",
"version": "1.0.7",
"version": "1.0.8",
"description": "The controllers used in angle-FE team",

@@ -10,3 +10,4 @@ "main": "index.js",

"devDependencies": {
"babel-cli": "^6.26.0"
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0"
},

@@ -13,0 +14,0 @@ "scripts": {

@@ -197,3 +197,3 @@ ## [@youngbeen/angle-ctrl](https://www.npmjs.com/package/@youngbeen/angle-ctrl)

```
debugCtrl.cheatDebugClick(count, interval)
debugCtrl.cheatDebugClick(count, interval, mode)
```

@@ -203,9 +203,9 @@

* interval参数可选,代表连续点击可接受的时间间隔最大值,默认1000ms
* mode参数可选,代表开启的debug模式,默认1普通调试模式
> 该方法触发开启的调试模式始终是普通调试模式
```
debugCtrl.cheatDebugClick(10) // 目标被连续点击10次自动触发开启调试模式
debugCtrl.cheatDebugClick(10) // 目标被连续点击10次自动触发开启普通调试模式
debugCtrl.cheatDebugClick(5, 1000, 2) // 目标被连续点击5次自动触发开启严格调试模式
```
#### 隐藏式迷宫矩阵开启调试模式 `cheatDebugMaze` **_(暂不可用)_**

@@ -0,79 +1,73 @@

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
// this controller is about to provide functions for time controll
"use strict";
module.exports = {
exports.default = {
// auto counting down -- { [total], [step], [tick], [end] }
countDown: function countDown(params) {
if (params) {
(function () {
var total = params.total || 60;
total > 0 ? parseInt(total) : total = 60;
var step = params.step || 1000;
step > 0 ? parseInt(step) : step = 1000;
var tickCallback = params.tick || function (result) {};
var endCallback = params.end || function (result) {};
var total = params.total || 60;
total > 0 ? parseInt(total) : total = 60;
var step = params.step || 1000;
step > 0 ? parseInt(step) : step = 1000;
var tickCallback = params.tick || function (result) {
// console.log('tick', result.leftCount)
};
var endCallback = params.end || function (result) {
// console.log('end the counting')
};
var tc = setInterval(function () {
if (total > 0) {
// time still left
tickCallback({ leftCount: total });
total--;
} else {
// counts end
endCallback({ leftCount: total });
clearInterval(tc);
}
}, step);
})();
var tc = setInterval(function () {
if (total > 0) {
// time still left
tickCallback({ leftCount: total });
total--;
} else {
// counts end
endCallback({ leftCount: total });
clearInterval(tc);
}
}, step);
}
},
// auto counting up -- { [start], [total], [step], [tick], [end] }
countUp: function countUp(params) {
if (params) {
var _ret = (function () {
var start = params.start || 0;
start = parseInt(start);
var total = params.total || 60;
total = parseInt(total);
if (start > total) {
// invalid start , total setting
console.warn("Error: \"start\" should not large than \"total\" (countUp()@TimeCtrl)");
return {
v: false
};
var start = params.start || 0;
start = parseInt(start);
var total = params.total || 60;
total = parseInt(total);
if (start > total) {
// invalid start , total setting
console.warn('Error: "start" should not large than "total" (countUp()@TimeCtrl)');
return false;
}
var now = start;
var step = params.step || 1000;
step > 0 ? parseInt(step) : step = 1000;
var tickCallback = params.tick || function (result) {
// console.log('tick', result.count)
};
var endCallback = params.end || function (result) {
// console.log('end the counting')
};
var tc = setInterval(function () {
if (now < total) {
// count continue
tickCallback({ count: now });
now++;
} else {
// counts end
endCallback({ count: now });
clearInterval(tc);
}
var now = start;
var step = params.step || 1000;
step > 0 ? parseInt(step) : step = 1000;
var tickCallback = params.tick || function (result) {};
var endCallback = params.end || function (result) {};
var tc = setInterval(function () {
if (now < total) {
// count continue
tickCallback({ count: now });
now++;
} else {
// counts end
endCallback({ count: now });
clearInterval(tc);
}
}, step);
})();
if (typeof _ret === "object") {
return _ret.v;
}
}, step);
}
}
};
// console.log('tick', result.leftCount)
// console.log('end the counting')
// console.log('tick', result.count)
// console.log('end the counting')
};