magix-inspector
Version:
magix项目调试分析工具
1,232 lines (1,225 loc) • 98.6 kB
JavaScript
/*
generate by magix-combine@3.11.44: https://github.com/thx/magix-combine
author: kooboy_li@163.com
loader: iife
*/
(function(){
//kissy drawIcons removeClass报错
//2014.7.29第一次以helper名称发布
var D = document;
var W = window;
if (D['___']) {
W.postMessage({
'__b': '__a',
'__d': '__c'
}, '*');
}
else {
W.addEventListener('message', function (e) {
var d = e.data;
if (d && d['__b'] == '__a') {
if (d['__d'] == '__c') {
UI['__c']();
}
}
}, false);
D['___'] = 1;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var IdePort = {
'__aa': function (url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.responseText) {
if (xhr.status === 200) {
resolve(xhr.responseText);
}
else {
reject(new Error("Network failed(" + xhr.status + "): " + url));
}
}
};
xhr.send();
});
},
'__ac': function (inputHostname) {
var files = [];
for (var _i = 1; _i < arguments.length; _i++) {
files[_i - 1] = arguments[_i];
}
IdePort['__ab'](inputHostname)
.then(function (determinedURL) {
return Promise.all(files.map(function (file) {
return IdePort['__aa'](determinedURL + encodeURIComponent(file));
}));
})
.then(function (determinedURL) {
console.info("Files(" + files.length + ") all opened.");
})["catch"](function (err) { return console.error(err); });
},
'__ab': function (inputHostname) {
if (IdePort.determinedURL && IdePort.determinedBase == inputHostname) {
return Promise.resolve(IdePort.determinedURL);
}
return IdePort['__ad'](inputHostname);
},
'__ad': function (inputHostname) {
return __awaiter(this, void 0, void 0, function () {
function hashStr(str, max) {
// SDBM Algorithm from http://www.cse.yorku.ca/~oz/hash.html
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
}
hash = hash >>> 0;
max && (hash %= max);
return hash;
}
var MAX_TRIAL, trials, port, location, determinedURL, responseHostname, err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
MAX_TRIAL = 3;
trials = 0;
port = hashStr(inputHostname, 8192) + 32768;
_a.label = 1;
case 1:
location = "http://127.0.0.1:" + port + "/";
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, IdePort['__aa'](location)];
case 3:
responseHostname = _a.sent();
if (responseHostname != inputHostname) {
throw '';
}
determinedURL = location + 'open?link=';
return [3 /*break*/, 5];
case 4:
err_1 = _a.sent();
return [3 /*break*/, 5];
case 5:
trials++;
port++;
_a.label = 6;
case 6:
if (!determinedURL && trials < MAX_TRIAL) return [3 /*break*/, 1];
_a.label = 7;
case 7:
if (!determinedURL) {
throw new Error("Cannot find available port within range: " + (port - MAX_TRIAL) + " ~ " + port);
}
IdePort.determinedBase = inputHostname;
IdePort.determinedURL = determinedURL;
return [2 /*return*/, determinedURL];
}
});
});
}
};
// Tested in Browser:
// IdePort["@{determineIDEServiceURLPromise}"]('dianjiang.di.taobao.com');
var Status = {
'__q': '#008B00',
'__s': '#FF3030',
'__r': '#BC8F8F',
'__A': '#FF3030',
'__Q': '#9AC0CD',
'__R': '#8B5F65',
'__S': '#EED5B7',
'__ae': '#94d694'
};
var Consts = {
'__af': 550,
'__ag': 470,
'__ah': 530,
'__ai': 400,
'__aj': 490,
'__ak': 34,
'__al': 6,
'__am': 15,
'__I': 5,
'__an': 5,
'__ao': 40,
'__ap': 40,
'__i': {
r: 0,
g: 153,
b: 102
},
'__j': {
r: 255,
g: 255,
b: 0
},
'__u': 15,
'__v': 5,
'__w': 12,
'__x': 5,
'__y': 12
};
var Lines = [
'FFC125',
'C71585',
'CDBA96',
'FF7F00',
'BA55D3',
'8B4726',
'7CFC00',
'4A4A4A',
'EE7AE9'
];
var ManagerColors = {
'__H': '#CC9966',
'__G': '#99CCCC',
'__F': '#FF9999',
'__E': '#CCCC99'
};
var ApplyStyle = function (x, h) {
var i = D.createElement('style');
D.documentElement.appendChild(i);
if (i.styleSheet) {
i.styleSheet.cssText = h;
}
else {
i.appendChild(D.createTextNode(h));
}
};
var IconsMap = {
'__r': 'MsCPoEb',
'__t': 'MsCPoEa'
};
var getNode = function (id) {
return D.getElementById(id);
};
var Drag = {
'__a_': function ($, off, isFn) {
var Win = $(W);
var Doc = $(D);
var ClearSelection = function (t) {
if ((t = W.getSelection)) {
t().removeAllRanges();
}
else if ((t = D.selection)) {
if (t.empty)
t.empty();
else
t = null;
}
};
var DragObject;
var DragPrevent = function (e) {
e.preventDefault();
};
var DragMove = function (event) {
if (DragObject.iMove) {
DragObject.move(event);
}
};
var DragMoveEvent = 'mousemove touchmove';
var DragEndEvent = 'mouseup touchend';
var DragPreventEvent = 'keydown mousewheel DOMMouseScroll';
var DragStop = function (e) {
if (DragObject) {
Doc[off](DragMoveEvent, DragMove)[off](DragEndEvent, DragStop)[off](DragPreventEvent, DragPrevent);
Win[off]('blur', DragStop);
var node = DragObject.node;
$(node)[off]('losecapture', DragStop);
if (node.setCapture)
node.releaseCapture();
if (DragObject.iStop) {
DragObject.stop(e);
}
DragObject = null;
}
};
return {
'__Y': function (node, moveCallback, endCallback) {
DragStop();
if (node) {
ClearSelection();
if (node.setCapture) {
node.setCapture();
}
DragObject = {
move: moveCallback,
stop: endCallback,
node: node,
iMove: isFn(moveCallback),
iStop: isFn(endCallback)
};
Doc.on(DragMoveEvent, DragMove)
.on(DragEndEvent, DragStop)
.on(DragPreventEvent, DragPrevent);
Win.on('blur', DragStop);
$(node).on('losecapture', DragStop);
}
},
'__Z': ClearSelection
};
}
};
var ehReg = /[&<>]/g;
var ehMap = {
'&': 'amp',
'<': 'lt',
'>': 'gt'
};
var encodeHTML = function (src) {
return src.replace(ehReg, function (m) { return '&' + ehMap[m] + ';'; });
};
var main = "<div class=\"MsCPoEe\" id=\"__as\"><ul class=\"MsCPoEp MsCPoEd\" id=\"__at\"><li class=\"MsCPoEl MsCPoEn MsCPoEm\" id=\"__aG\">△</li><li class=\"MsCPoEk MsCPoEn MsCPoEm\">VOM</li><li class=\"MsCPoEk MsCPoEn MsCPoEm\">Tracer</li><li class=\"MsCPoEk MsCPoEn MsCPoEm\">Manager</li></ul><div id=\"__aI\"><div style=\"width:{__af}px;height:{__ai}px;overflow-x:auto;overflow-y:hidden\" id=\"__aN\"><canvas width=\"{__af}\" height=\"{__ai}\" id=\"__aw\"></canvas></div><label class=\"MsCPoEk MsCPoEh\"><input type=\"checkbox\" class=\"MsCPoEj\" id=\"__aF\"/>控制台显示view信息</label><label class=\"MsCPoEk MsCPoEh\"><input type=\"checkbox\" class=\"MsCPoEj\" id=\"__z\"/>显示组件view</label><ul class=\"MsCPoEp MsCPoEk\" id=\"__aY\"></ul></div><div id=\"__aJ\" style=\"height:{__ai}px;overflow:scroll;overflow-x:auto;display:none;padding:8px;\"></div><div id=\"__aK\" style=\"display:none\"><div style=\"height:{__ai}px;overflow:scroll;overflow-x:auto;\" id=\"__aT\"><canvas width=\"{__ah}\" height=\"{__ai}\" id=\"__aB\"></canvas></div><ul class=\"MsCPoEp MsCPoEn\" id=\"__aW\"></ul></div><div id=\"__aD\" class=\"MsCPoEr\"></div><div id=\"__aS\" class=\"MsCPoEr\"></div></div>";
var moreInfo = "<ul><li><b class=\"MsCPoEc\">id:</b>{id}</li><li><b class=\"MsCPoEc\">view:</b>{view}</li>{events} {location} {share} {mixins} {state}<li class=\"MsCPoEo\">{ex}</li><li><b class=\"MsCPoEc\">resources</b></li><li style=\"{__aj}px;overflow:auto;max-height:200px;\">{res}</li></ul>";
var moreManagerInfo = "<ul><li><b>key:</b>{id}</li><li><b>url:</b>{url}</li><li><b>描述:</b>{desc}</li><li><b>缓存:</b>{cache}</li><li><b>清理缓存:</b>{cleans}</li><li><b>预处理:</b>{hasAfter}</li></ul>";
var total = "<li class=\"MsCPoEk MsCPoEg MsCPoEi\">view统计:[{count}]</li>";
var managerTotal = "<li class=\"MsCPoEk MsCPoEg\">{groups}个接口文件,共{total}个接口</li>";
var UI = {
'__M': function () {
var div = D.createElement('div');
div.innerHTML = main.replace(/\{(\w+|(?:@\{[^\}]+\}))\}/g, function (m, v) {
return Consts[v] || m;
});
D.documentElement.appendChild(div);
UI['__aq']();
var env = Inspector['__e']();
env['__ar']('#__as', '#__at');
},
'__aq': function () {
UI['__au']();
var moveTimer;
var env = Inspector['__e']();
env['__av']('__aw', 'mousemove', UI['@{$mousemove}'] = function (e) {
clearTimeout(moveTimer);
moveTimer = setTimeout(function () {
var offset = env['__ax']('__aw');
UI['__ay']({
x: e.pageX - offset.left,
y: e.pageY - offset.top
});
}, 10);
});
env['__av']('__aw', 'click', UI['__az'] = function (e) {
UI['__aA'](e);
});
env['__av']('__aw', 'mouseout', UI['@{$mouseout}'] = function () {
clearTimeout(moveTimer);
UI['__ay']({
x: -1,
y: -1
});
});
env['__av']('__aB', 'mousemove', UI['@{$mangerMousemove}'] = function (e) {
clearTimeout(moveTimer);
moveTimer = setTimeout(function () {
var offset = env['__ax']('__aB');
UI['__aC']({
x: e.pageX - offset.left,
y: e.pageY - offset.top
});
}, 10);
});
env['__av']('__aB', 'mouseout', UI['@{$managerMouseout}'] = function () {
clearTimeout(moveTimer);
UI['__aC']({
x: -1,
y: -1
});
});
env['__av']('__aD', 'mouseover', UI['@{$imouseover}'] = function () {
clearTimeout(UI['@{$hideTimer}']);
});
env['__av']('__aD', 'mouseout', UI['@{$imouseout}'] = function () {
UI['__aE']();
});
env['__av']('__aF', 'click', function () {
var logNode = getNode('__aF');
if (logNode.checked)
W.console.dir(env['__p']().all());
});
env['__av']('__z', 'click', function () {
Inspector['__O']();
});
env['__av']('__as', 'click', UI['@{$click}'] = function (e) {
var node;
if (e.target.id == '__aG') {
node = getNode('__as');
if (e.target.innerHTML == '△') {
node.style.height = Consts['__ak'] + 'px';
node.style.width = '40px';
node.style.overflow = 'hidden';
e.target.innerHTML = '▽';
env['__aH']('#__at').addClass('MsCPoEs');
}
else {
node.style.height = Consts['__ag'] + 'px';
node.style.width = Consts['__af'] + 'px';
node.style.overflow = 'inherit';
e.target.innerHTML = '△';
env['__aH']('#__at').removeClass('MsCPoEs');
}
}
else if (e.target.innerHTML == 'VOM') {
node = getNode('__aI');
node.style.display = 'block';
node = getNode('__aJ');
node.style.display = 'none';
node = getNode('__aK');
node.style.display = 'none';
}
else if (e.target.innerHTML == 'Tracer') {
node = getNode('__aI');
node.style.display = 'none';
node = getNode('__aK');
node.style.display = 'none';
node = getNode('__aJ');
node.style.display = 'block';
}
else if (e.target.innerHTML == 'Manager') {
node = getNode('__aI');
node.style.display = 'none';
node = getNode('__aJ');
node.style.display = 'none';
node = getNode('__aK');
node.style.display = 'block';
}
});
},
'__c': function () {
var min = getNode('__aG');
var env = Inspector['__e']();
if (min.innerHTML == '▽') {
var node = getNode('__as');
node.style.height = Consts['__ag'] + 'px';
node.style.width = Consts['__af'] + 'px';
node.style.overflow = 'inherit';
min.innerHTML = '△';
env['__aH']('#__at').removeClass('MsCPoEs');
}
},
'__N': function () {
var min = getNode('__aG');
var env = Inspector['__e']();
if (min.innerHTML == '△') {
var node = getNode('__as');
node.style.height = Consts['__ak'] + 'px';
node.style.width = '40px';
node.style.overflow = 'hidden';
min.innerHTML = '▽';
env['__aH']('#__at').addClass('MsCPoEs');
}
},
'__au': function () {
var env = Inspector['__e']();
env['__aL']('__aw', 'mousemove', UI['@{$mousemove}']);
env['__aL']('__aw', 'mouseout', UI['@{$mouseout}']);
env['__aL']('__aw', 'click', UI['__az']);
env['__aL']('__aB', 'mousemove', UI['@{$managerMousemove}']);
env['__aL']('__aB', 'mouseout', UI['@{$managerMouseout}']);
env['__aL']('__aG', 'click', UI['@{$click}']);
env['__aL']('__aD', 'mouseoout', UI['@{$imouseout}']);
env['__aL']('__aD', 'mouseover', UI['@{$imouseover}']);
//env['@{unbind}']('mx_mover', 'mousedown', UI['@{$mousedown}']);
},
'__aR': function (vf, item) {
clearTimeout(UI['@{$hideTimer}']);
var logNode = getNode('__aF');
if (logNode.checked) {
W.console.log(vf);
}
var cover = getNode('__aM');
if (!cover) {
cover = D.createElement('div');
cover.className = 'MsCPoEf';
cover.id = '__aM';
D.body.appendChild(cover);
}
var node = getNode('__aD');
node.style.display = 'block';
var left = item.center.x - Consts['__aj'] / 2 - getNode('__aN').scrollLeft;
node.style.left = left + 'px';
node.style.top = item.center.y + item.radius + Consts['__ak'] + 5 + 'px';
var env = Inspector['__e']();
env['__aO'](cover.style, vf.id);
cover.style.display = 'block';
node.innerHTML = moreInfo.replace(/\{(\w+|(?:@\{[^\}]+\}))\}/g, function (m, v) {
switch (v) {
case 'id':
return item.id;
case 'view':
if (vf) {
if (vf.$v || vf.path) {
return encodeHTML(vf.path);
}
if (vf.view) {
return encodeHTML(vf.view.path);
}
}
return '';
case 'events':
var evts = Inspector['__f'](vf);
return evts.total ? '<li><b class="MsCPoEc">listen:</b>' + evts.list + '</li>' : '';
case 'share':
var s = Inspector['__g'](vf);
return s.length ? '<li><b class="MsCPoEc">share:</b>' + s + '</li>' : '';
case 'location':
var l = Inspector['__h'](vf);
var f = l.path || (l.keys && l.keys.length);
if (f) {
var r = [];
if (l.path) {
r.push('<span style="color:#FFC125">path</span>');
}
if (l.keys) {
r = r.concat(l.keys);
}
return '<li><b class="MsCPoEc">location:</b>' + r + '</li>';
}
return '';
case 'mixins':
var mixins = Inspector['__m'](vf);
if (mixins.length) {
var list = env['__aP'](mixins);
list = list.join(',');
return '<li><b class="MsCPoEc">mixins:</b>' + list + '</li>';
}
return '';
case 'state':
var state = Inspector['__n'](vf);
if (state.length) {
return '<li><b class="MsCPoEc">state:</b>' + state.join(',') + '</li>';
}
return '';
case 'ex':
if (item.il) {
return '被孤立的节点,好可怜……';
}
if (!vf) {
return 'vframe已被销毁,但未从vom中移除';
}
if (!vf.path) {
if (!vf.view) {
return '未加载view';
}
}
else {
if ((vf.cM && !vf.view) || (vf.$c && !vf.$v)) {
return '未加载view';
}
}
if (vf.cM) {
if (!vf.fcc) {
return vf.rC != vf.cC ? '正等待子view加载' : '正等待view加载';
}
}
else {
if (!vf.$cr) {
return vf.$rc != vf.$cc ? '正等待子view加载' : '正等待view加载';
}
}
if (vf.fca || vf.$ca) {
return '等待view渲染';
}
return '';
case 'res':
var t = [];
var res = vf && vf.view && vf.view.$res;
res = res || vf && vf.$v && vf.$v.$r;
var hasRrs = void 0;
if (res) {
for (var p in res) {
hasRrs = true;
break;
}
if (hasRrs) {
t.push('<table style="width:100%"><tr><td>key</td><td>type</td></tr>');
for (var p in res) {
t.push('<tr><td>', p, '</td><td>', env['__aQ'](res[p]), '</td></tr>');
}
t.push('</table>');
}
}
return t.join('');
default:
return Consts[v] || m;
}
});
},
'__aE': function () {
var node = getNode('__aD');
var cover = getNode('__aM');
UI['@{$hideTimer}'] = setTimeout(function () {
node.style.display = 'none';
cover.style.display = 'none';
}, 150);
},
'__aU': function (item) {
clearTimeout(UI['@{$hideManagerTimer}']);
var node = getNode('__aS');
node.style.display = 'block';
node.style.left = item.rect[0] + 'px';
var top = item.rect[1] + item.rect[3] + Consts['__ak'];
var st = getNode('__aT').scrollTop;
top -= st;
node.style.top = top + 'px';
node.innerHTML = moreManagerInfo.replace(/\{(\w+)\}/g, function (m, v) {
switch (v) {
case 'id':
return item.id;
default:
return item[v] || '';
}
});
},
'__aV': function () {
var node = getNode('__aS');
UI['@{$hideManagerTimer}'] = setTimeout(function () {
node.style.display = 'none';
}, 150);
},
'__aX': function (tree) {
var node = getNode('__aW');
node.innerHTML = managerTotal.replace(/\{(\w+)\}/g, function (m, v) {
switch (v) {
case 'groups':
return tree.groups.length;
case 'total':
return tree.total;
default:
return m;
}
});
},
'__aZ': function (tree) {
var node = getNode('__aY');
node.innerHTML = total.replace(/\{(\w+)\}/g, function (m, v) {
switch (v) {
case 'count':
return 'com:' + tree.comTotal + ',vom:' + tree.vomTotal + ',total:' + tree.total;
default:
return m;
}
});
},
'__b_': function (height) {
getNode('__aB').height = height | 0;
},
'__ba': function (width) {
var c = getNode('__aw');
c.width = width | 0;
c.parentNode.scrollLeft = (c.width - Consts['__ah']) / 2;
},
'__ay': function (e) {
console.log(e);
},
'__aC': function (e) {
console.log(e);
},
'__aA': function (e) {
console.log(e);
}
};
ApplyStyle("MsCPoE_","vframe{display:block}.MsCPoE_:before{width:12px;content:\"M\";height:12px;border-radius:6px;position:absolute;background-color:#008b00;opacity:.4;font-size:10px;line-height:12px;text-align:center;color:#fff}.MsCPoEa:before{background-color:#ff3030}.MsCPoEb:before{background-color:#bc8f8f}.MsCPoEc{padding-right:5px}.MsCPoEd{background:#eee;cursor:move;margin:0;padding:0}.MsCPoEe{position:fixed;right:20px;top:20px;width:550px;height:470px;z-index:2147483647;box-shadow:0 0 5px #b9b9b9;background-color:#fff;font-size:12px;line-height:1.5}.MsCPoEf{position:absolute;opacity:.7;background-color:#90ee90}.MsCPoEe ul{list-style:none;padding:0;margin:0}.MsCPoEg{padding:5px}.MsCPoEh{height:28px;line-height:28px;margin:0 0 0 5px;padding:0}.MsCPoEi{color:#bbb}.MsCPoEj{margin-right:3px}.MsCPoEk{float:left}.MsCPoEl{float:right}.MsCPoEm{cursor:pointer}.MsCPoEn{padding:8px}.MsCPoEo{color:red}.MsCPoEp:after,.MsCPoEp:before{content:\"\";display:table}.MsCPoEp:after{clear:both}.MsCPoEp{*zoom:1}.MsCPoEq{height:1px;border:0;padding:0;margin:5px;background:rgba(0,0,0,.2);background:-webkit-gradient(linear,left top,right top,from(rgba(165,69,243,0)),color-stop(.5,rgba(125,118,132,.33)),to(rgba(165,69,243,0)))}.MsCPoEr{position:absolute;background-color:#eee;padding:8px;width:440px;display:none;box-shadow:0 2px 2px 2px #b9b9b9;word-break:break-all}.MsCPoEs:before{left:4px;bottom:5px}.MsCPoEs:after,.MsCPoEs:before{content:\" \";position:absolute;top:10px;border:2px dotted #b9b1b1;height:10px;cursor:move}.MsCPoEs:after{left:9px}");
var Tracer = {
'__P': function (info, color) {
var node = getNode('__aJ');
if (Tracer['__bb']) {
var t = D.createElement('hr');
t.className = 'MsCPoEq';
node.insertBefore(t, node.firstChild);
delete Tracer['__bb'];
}
var d = D.createElement('div');
d.innerHTML = info;
if (color)
d.style.color = color;
node.insertBefore(d, node.firstChild);
if (node.getElementsByTagName('div').length > 200) {
node.removeChild(node.lastChild);
node.removeChild(node.lastChild);
}
clearTimeout(Tracer['__bc']);
Tracer['__bc'] = setTimeout(function () {
Tracer['__bb'] = true;
}, 1500);
}
};
var Graphics = {
'__bg': function () {
var g = Graphics;
g.list = [];
delete g['__bd'];
UI['__ay'] = function (e) {
var loop, one, dis;
if (g['__bd']) {
one = g['__bd'];
dis = Math.pow(Math.pow(one.center.x - e.x, 2) + Math.pow(one.center.y - e.y, 2), 1 / 2);
if (dis > one.radius) {
g['__be']({
item: one,
action: 'leave'
});
delete g['__bd'];
loop = true;
}
}
else {
loop = true;
}
if (loop) {
for (var i = g.list.length - 1; i >= 0; i--) {
one = g.list[i];
dis = Math.pow(Math.pow(one.center.x - e.x, 2) + Math.pow(one.center.y - e.y, 2), 1 / 2);
if (dis <= one.radius) {
if (g['__bd'] != one) {
g['__bd'] = one;
g['__be']({
item: one,
action: 'enter'
});
}
break;
}
}
}
};
UI['__aA'] = g['__bf'];
},
'__bj': function () {
var g = Graphics;
g.managerList = [];
delete g['__bh'];
UI['__aC'] = function (e) {
var loop, one, rect;
if (g['__bh']) {
one = g['__bh'];
rect = one.rect;
if (e.x < rect[0] || e.y < rect[1] || e.x > (rect[0] + rect[2]) || e.y > (rect[1] + rect[3])) {
g['__bi']({
item: one,
action: 'leave'
});
delete g['__bh'];
loop = true;
}
}
else {
loop = true;
}
if (loop) {
for (var i = g.managerList.length - 1; i >= 0; i--) {
one = g.managerList[i];
rect = one.rect;
if (e.x >= rect[0] && e.y >= rect[1] && e.x <= (rect[0] + rect[2]) && e.y <= (rect[1] + rect[3])) {
if (g['__bh'] != one) {
g['__bh'] = one;
g['__bi']({
item: one,
action: 'enter'
});
}
}
}
}
};
},
'__bk': function (tree, width, height) {
var maxChildren = 0, deep = 0, deepMap = {};
var walk = function (item, level) {
item.deep = level;
if (level > deep) {
deep = level;
}
if (!deepMap[level]) {
deepMap[level] = 0;
}
item.leftCount = deepMap[level];
deepMap[level]++;
if (deepMap[level] > maxChildren) {
maxChildren = deepMap[level];
}
for (var i = 0, one = void 0; i < item.children.length; i++) {
one = item.children[i];
walk(item.children[i], item.deep + 1);
}
};
tree.deepMap = deepMap;
walk(tree, 1, 0);
maxChildren = Math.max(maxChildren, tree.isolated.length + 1);
var hRadius = width / maxChildren - Consts['__al'];
var vRadius = height / deep - Consts['__al'];
var tw = width;
var dMinRadius = 2 * Consts['__am'];
if (hRadius < dMinRadius) {
hRadius = dMinRadius;
tw = dMinRadius * maxChildren + (maxChildren + 1) * Consts['__al'];
if (tw > 30000) {
tw = 30000;
}
UI['__ba'](tw);
}
else {
UI['__ba'](tw);
}
var radius = Math.floor(Math.min(vRadius, hRadius) / 2);
var band = (radius / 20).toFixed(1);
return {
width: tw,
margin: Consts['__al'],
radius: radius,
band: band
};
},
'__O': function (tree, active) {
if (tree.id) {
var width_1 = Consts['__af'], height = Consts['__ai'], g_1 = Graphics;
g_1['__bg']();
var params_1 = g_1['__bk'](tree, width_1, height);
width_1 = params_1.width;
var ctx_1 = getNode('__aw').getContext('2d');
ctx_1.clearRect(0, 0, width_1, height);
var max_1 = params_1.radius * 2 - 2 * (params_1.band + 1) - 1;
if (!g_1['__bl'])
g_1['__bl'] = {};
var getWidth_1 = function (text) {
if (!g_1['__bl'][text]) {
ctx_1.font = 'normal 12px Arial';
g_1['__bl'][text] = ctx_1.measureText(text).width;
}
return g_1['__bl'][text];
};
var cutText_1 = function (text) {
var len = 1, width = 0;
while (len <= text.length) {
width += getWidth_1(text.substring(len - 1, len));
if (width < max_1) {
len += 1;
}
else {
return text.substring(0, len - 3) + '..';
}
}
return text;
};
var linecolorIndex_1 = 0;
var drawLine_1 = function (item, pos, ppos, lineColor) {
if (ppos) {
ctx_1.beginPath();
var deg = Math.atan((pos.y - ppos.y) / (pos.x - ppos.x)) * 180 / Math.PI;
if (deg < 0) {
deg += 180;
}
var tx = Math.round(ppos.x + params_1.radius * Math.cos(deg * Math.PI / 180));
var ty = Math.round(ppos.y + params_1.radius * Math.sin(deg * Math.PI / 180));
ctx_1.moveTo(tx, ty); // 设置路径起点,坐标为(20,20)
ctx_1.lineTo(pos.x, pos.y); // 绘制一条到(200,20)的直线
ctx_1.lineWidth = params_1.band / 1.5; // 设置线宽
ctx_1.strokeStyle = lineColor;
ctx_1.stroke(); // 进行线的着色,这时整条线才变得可见
}
var count = tree.deepMap[item.deep + 1];
if (count) {
var space_1 = (width_1 - (count * params_1.radius * 2 + (count - 1) * params_1.margin)) / 2;
var lcolor = '#' + Lines[linecolorIndex_1++ % Lines.length]; // Lines[Math.floor(Math.random() * (Lines.length - 1))];
for (var i = 0, one = void 0; i < item.children.length; i++) {
one = item.children[i];
drawLine_1(one, {
x: space_1 + one.leftCount * (params_1.radius * 2 + params_1.margin) + params_1.radius,
y: pos.y + params_1.margin + 2 * params_1.radius
}, pos, lcolor);
}
}
};
var drawCircle_1 = function (item, pos) {
ctx_1.moveTo(pos.x, pos.y);
ctx_1.beginPath();
ctx_1.arc(pos.x, pos.y, params_1.radius, 0, Math.PI * 2, true);
ctx_1.fillStyle = item.status;
if (item.id == active) {
if (item.flag) {
ctx_1.fillStyle = Status['__ae'];
}
else {
ctx_1.fillStyle = item.status;
}
item.flag = !item.flag;
}
ctx_1.fill();
//bottom small cicle
var radius = Math.max(0.5, params_1.radius / 10);
var ly = pos.y + params_1.radius / 2;
var lx = pos.x - params_1.radius / 2 + radius;
//left
if (item.event) {
ctx_1.beginPath();
ctx_1.arc(lx, ly, radius, 0, Math.PI * 2, true);
ctx_1.fillStyle = item.event;
ctx_1.fill();
}
//center
if (item.location) {
ctx_1.beginPath();
ctx_1.arc(pos.x, ly + radius, radius, 0, Math.PI * 2, true);
ctx_1.fillStyle = item.location;
ctx_1.fill();
}
// center left top
if (item.mixins) {
var x1 = lx, y1 = ly, x2 = pos.x, y2 = ly + radius;
var x3 = (x1 + x2 + Math.sqrt(3) * (y2 - y1)) / 2 - (x2 - x1) / 10;
var y3 = (y1 + y2 - Math.sqrt(3) * (x2 - x1)) / 2 + (x2 - x1) / 3;
ctx_1.beginPath();
ctx_1.arc(x3, y3, radius, 0, Math.PI * 2, true);
ctx_1.fillStyle = item.mixins;
ctx_1.fill();
}
//right
if (item.shared) {
var rx = pos.x + params_1.radius / 2 - radius;
ctx_1.beginPath();
ctx_1.arc(rx, ly, radius, 0, Math.PI * 2, true);
ctx_1.fillStyle = item.shared;
ctx_1.fill();
}
// center right top
if (item.state) {
var x1 = pos.x, y1 = ly + radius, x2 = pos.x + params_1.radius / 2 - radius, y2 = ly;
var x3 = (x1 + x2 + Math.sqrt(3) * (y2 - y1)) / 2 + (x2 - x1) / 10;
var y3 = (y1 + y2 - Math.sqrt(3) * (x2 - x1)) / 2 + (x2 - x1) / 3;
ctx_1.beginPath();
ctx_1.arc(x3, y3, radius, 0, Math.PI * 2, true);
ctx_1.fillStyle = item.state;
ctx_1.fill();
}
if (item.inline) {
ctx_1.beginPath();
var r = params_1.radius - params_1.band - 1;
var d60 = -2 * Math.PI / 360 * 60;
var d120 = -2 * Math.PI / 360 * 120;
var x1 = pos.x + r * Math.cos(d60);
var y1 = pos.y + r * Math.sin(d60);
var x2 = pos.x + r * Math.cos(d120);
var y2 = pos.y + r * Math.sin(d120);
ctx_1.moveTo(x1, y1);
ctx_1.quadraticCurveTo(pos.x, pos.y - r / 2, x2, y2);
ctx_1.moveTo(x1, y1);
ctx_1.quadraticCurveTo(pos.x, pos.y - params_1.radius - params_1.band, x2, y2);
ctx_1.fillStyle = '#fff';
ctx_1.fill();
}
ctx_1.moveTo(pos.x, pos.y);
ctx_1.beginPath();
//white slot
ctx_1.arc(pos.x, pos.y, params_1.radius - params_1.band - 1, 0, Math.PI * 2, true);
ctx_1.lineWidth = params_1.band;
ctx_1.strokeStyle = '#fff';
ctx_1.stroke();
g_1.list.push({
id: item.id,
center: pos,
il: item.il,
radius: params_1.radius
});
//text
ctx_1.beginPath();
ctx_1.moveTo(pos.x, pos.y);
ctx_1.font = 'normal 12px Arial';
ctx_1.fillStyle = '#eee';
var id = cutText_1(item.id);
var textWidth = Math.round(ctx_1.measureText(id).width);
var left = (2 * params_1.radius - textWidth) / 2;
ctx_1.fillText(id, pos.x + left - params_1.radius, pos.y + 4);
var count = tree.deepMap[item.deep + 1];
if (count) {
var space_2 = (width_1 - (count * params_1.radius * 2 + (count - 1) * params_1.margin)) / 2;
for (var i = 0, one = void 0; i < item.children.length; i++) {
one = item.children[i];
drawCircle_1(one, {
x: space_2 + one.leftCount * (params_1.radius * 2 + params_1.margin) + params_1.radius,
y: pos.y + params_1.margin + 2 * params_1.radius
});
}
}
};
var temp = tree.isolated;
var space = width_1 / 2;
if (temp.length) {
space = (width_1 - (temp.length + 1) * params_1.radius * 2 + temp.length * params_1.margin) / 2;
for (var i = 0; i < temp.length; i++) {
drawCircle_1(temp[i], {
x: space + (i + 1) * (params_1.radius * 2 + params_1.margin) + params_1.radius,
y: params_1.margin + params_1.radius
});
}
space += params_1.radius;
}
drawLine_1(tree, {
x: space,
y: params_1.margin + params_1.radius
});
drawCircle_1(tree, {
x: space,
y: params_1.margin + params_1.radius
});
UI['__aZ'](tree, params_1);
}
},
'__U': function (tree) {
var gs = Graphics;
gs['__bj']();
var height = Consts['__an'] * (tree.rows + 1) + tree.rows * Consts['__ao'] + (Consts['__ap'] + Consts['__an']) * tree.groups.length;
UI['__b_'](height);
var ctx = getNode('__aB').getContext('2d');
ctx.clearRect(0, 0, Consts['__ah'], height);
var margin = Consts['__an'];
var managerWidth = ((Consts['__ah'] - (1 + Consts['__I']) * Consts['__an']) / Consts['__I']) | 0;
var oneWidth = (function () {
ctx.font = 'normal 14px Arial';
var width = ctx.measureText('M').width;
return width;
})();
var drawRect = function (ctx, rect, one, pname) {
ctx.beginPath();
ctx.moveTo(rect[0], rect[1]);
ctx.fillStyle = one.color;
ctx.fillRect(rect[0], rect[1], rect[2], rect[3]);
//text
ctx.beginPath();
ctx.moveTo(rect[0], rect[1] + 10);
ctx.font = 'normal 14px Arial';
ctx.fillStyle = '#282828';
var id = one.id, tail;
while ((id.length - 3) * oneWidth > rect[2]) {
id = id.slice(0, -1);
tail = true;
}
if (tail) {
id = id.slice(0, -3) + '...';
}
ctx.fillText(id, rect[0] + 5, rect[1] + 25);
one.package = pname;
one.rect = rect;
gs.managerList.push(one);
};
var draw = function (groups) {
/* mc-uncheck */
for (var i = 0; i < groups.length; i++) {
var g = groups[i];
var left = Consts['__an'];
var pad = false;
ctx.beginPath();
ctx.moveTo(left, margin);
ctx.font = 'normal 14px Arial';
ctx.fillStyle = '#282828';
ctx.fillText(g.name, left + 5, margin + 25);
margin += Consts['__ap'];
var u = void 0, one = void 0;
var max = Math.max(g.maxLeft, g.maxRight);
var maps = {};
var linecolorIndex = 0;
var leftTopSpace = ((max - g.maxLeft) / 2) * (Consts['__ao'] + Consts['__an']);
var rightTopSpace = ((max - g.maxRight) / 2) * (Consts['__ao'] + Consts['__an']);
for (u = 0; u < max; u++) {
var lo = g.cleans.left[u];
var ro = g.cleans.right[u];
if (lo) {
drawRect(ctx, [
left,
margin + leftTopSpace,
150,
Consts['__ao']
], lo, g.name);
maps[lo.id] = lo;
}
if (ro) {
drawRect(ctx, [
Consts['__ah'] - Consts['__an'] - 150,
margin + rightTopSpace,
150,
Consts['__ao']
], ro, g.name);
maps[ro.id] = ro;
ro.lineColor = Lines[linecolorIndex++ % Lines.length];
}
margin += Consts['__an'] + Consts['__ao'];
}
for (var p in maps) {
one = maps[p];
if (one.cleans) {
var beginPos = {
x: one.rect[0] + one.rect[2],
y: one.rect[1] + (one.rect[3] / 2 | 0)
};
var a = (one.cleans + '').split(',');
for (var x = a.length - 1; x >= 0; x--) {
var endOne = maps[a[x]];
var endPos = {
x: endOne.rect[0],
y: endOne.rect[1] + (endOne.rect[3] / 2 | 0)
};
ctx.beginPath();
ctx.moveTo(beginPos.x, beginPos.y); // 设置路径起点,坐标为(20,20)
ctx.lineTo(endPos.x, endPos.y); // 绘制一条到(200,20)的直线
ctx.lineWidth = 1.0; // 设置线宽
ctx.strokeStyle = '#' + (endOne.lineColor || '996699');
ctx.stroke();
}
}
}
for (u = 0; u < g.caches.length; u++) {
drawRect(ctx, [left, margin, managerWidth, Consts['__ao']], g.caches[u], g.name);
if ((u + 1) % Consts['__I'] === 0) {
left = Consts['__an'];
margin += Consts['__an'] + Consts['__ao'];
pad = false;
}
else {
left += managerWidth + Consts['__an'];
pad = true;
}
}
left = Consts['__an'];
if (pad) {
margin += Consts['__an'] + Consts['__ao'];
}
for (u = 0; u < g.items.length; u++) {
one = g.items[u];
drawRect(ctx, [left, margin, managerWidth, Consts['__ao']], one, g.name);
if ((u + 1) % Consts['__I'] === 0) {
left = Consts['__an'];
margin += Consts['__an'] + Consts['__ao'];
pad = false;
}
else {
left += managerWidth + Consts['__an'];
pad = true;
}
}
left = Consts['__an'];
if (pad) {
margin += Consts['__ap'];
}
}
};
draw(tree.groups);
UI['__aX'](tree);
},
'__be': function (e) {
var env = Inspector['__e']();
var vom = env['__p']();
if (e.action == 'enter') {
Graphics['__bm'] = vom.get(e.item.id);
UI['__aR'](vom.get(e.item.id), e.item);
}
else {
Graphics['__bm'] = null;
UI['__aE']();
}
},
'__bi': function (e) {
if (e.action == 'enter') {
UI['__aU'](e.item);
}
else {
UI['__aV']();
}
},
'__bf': function (e) {
var lastVOM = Graphics['__bm'];
if (!lastVOM) {
return;
}
var path = (lastVOM.view && lastVOM.view.path) || lastVOM.path;
if (!path) {
return;
}
var base = (W.Site && W.Site.onlineHostname) || W.location.hostname;
IdePort['__ac'](base, path + '.js', path + '.html');
}
};
var type = function (o) {
return Object.prototype.toString.call(o).slice(8, -1).toLowerCase();
};
var Query = function (selector) {
var doms = type(selector) === 'array' ? selector : [selector];
if (type(selector) == 'string') {
doms = document.querySelectorAll(selector);
}
this['__bn'] = doms;
};
Query.prototype = {
off: function (type, fn) {
var doms = this['__bn'];
for (var _i = 0, doms_1 = doms; _i < doms_1.length; _i++) {
var d = doms_1[_i];
var evts = type.split(/\s+/);
for (var _a = 0, evts_1 = evts; _a < evts_1.length; _a++) {
var e = evts_1[_a];
d.removeEventListener(e, fn);
}
}
return this;
},
on: function (type, fn) {
var doms = this['__bn'];
for (var _i = 0, doms_2 = doms; _i < doms_2.length; _i++) {
var d = doms_2[_i];
var evts = type.split(/\s+/);
for (var _a = 0, evts_2 = evts; _a < evts_2.length; _a++) {
var e = evts_2[_a];
d.addEventListener(e, fn, false);
}
}
return this;
},
removeClass: function (name) {
var doms = this['__bn'];
for (var _i = 0, doms_3 = doms; _i < doms_3.length; _i++) {
var d = doms_3[_i];
d.classList.remove(name);
}
return this;
},
addClass: function (name) {
var doms = this['__bn'];
for (var _i = 0, doms_4 = doms; _i < doms_4.length; _i++) {
var d = doms_4[_i];
d.classList.add(name);
}
return this;