Commit 10751361 authored by techird's avatar techird

添加错误报告源代码符号查找

parent 0034c01d
......@@ -36,14 +36,8 @@ module.exports = function(grunt) {
options: {
banner: banner + '(function(window) {\n\n',
footer: '\n\n})(window)',
process: function(src, filepath) {
return ['\n',
'/* ' + filepath + ' */',
src.replace(/^.+$/mg, ' $&'),
'/* ' + filepath + ' end */',
'\n',
].join('\n');
}
sourceMap: true,
sourceMapStyle: 'link'
},
src: sources.filter(function(source) {
return source.pack == '*' || source.pack.split('|').indexOf(pack) !== -1;
......@@ -67,7 +61,8 @@ module.exports = function(grunt) {
uglify: {
minimize: {
options: {
banner: banner
banner: banner,
sourceMap: true
},
files: (function() {
var files = {};
......@@ -90,6 +85,7 @@ module.exports = function(grunt) {
'static/**/*',
'lib/ZeroClipboard.swf',
'lib/inflate.js',
'lib/source-map.min.js',
'index.html',
'edit.html',
'viewshare.html',
......
This diff is collapsed.
......@@ -60,17 +60,6 @@
}
.error-detail {
textarea {
box-sizing: border-box;
width: 100%;
height: 200px;
border: 1px solid #EEE;
background: #fcfcfc;
outline: none;
padding: 6px;
color: #666;
display: none;
}
position: relative;
a.expander {
display: block;
......@@ -85,13 +74,8 @@
text-decoration: underline;
}
}
.copy-and-feedback {
display: none;
float: right;
margin-top: 10px;
}
&.expanded {
textarea, .copy-and-feedback {
.error-detail-wrapper {
display: block;
}
a.expander:before {
......@@ -111,6 +95,24 @@
font-size: 12px;
color: #AAA;
}
.error-detail-wrapper {
display: none;
textarea {
box-sizing: border-box;
width: 100%;
height: 200px;
border: 1px solid #EEE;
background: #fcfcfc;
outline: none;
padding: 6px;
color: #666;
}
.copy-and-feedback {
float: right;
margin-top: 10px;
}
}
}
}
......
......@@ -1361,17 +1361,6 @@ input[type=search]::-ms-clear {
#content-wrapper .error-dialog .fui-dialog-body .error-detail {
position: relative;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail textarea {
box-sizing: border-box;
width: 100%;
height: 200px;
border: 1px solid #EEE;
background: #fcfcfc;
outline: none;
padding: 6px;
color: #666;
display: none;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail a.expander {
display: block;
margin: 8px 0;
......@@ -1395,13 +1384,7 @@ input[type=search]::-ms-clear {
#content-wrapper .error-dialog .fui-dialog-body .error-detail a.expander:hover {
text-decoration: underline;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail .copy-and-feedback {
display: none;
float: right;
margin-top: 10px;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail.expanded textarea,
#content-wrapper .error-dialog .fui-dialog-body .error-detail.expanded .copy-and-feedback {
#content-wrapper .error-dialog .fui-dialog-body .error-detail.expanded .error-detail-wrapper {
display: block;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail.expanded a.expander:before {
......@@ -1430,6 +1413,23 @@ input[type=search]::-ms-clear {
font-size: 12px;
color: #AAA;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail .error-detail-wrapper {
display: none;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail .error-detail-wrapper textarea {
box-sizing: border-box;
width: 100%;
height: 200px;
border: 1px solid #EEE;
background: #fcfcfc;
outline: none;
padding: 6px;
color: #666;
}
#content-wrapper .error-dialog .fui-dialog-body .error-detail .error-detail-wrapper .copy-and-feedback {
float: right;
margin-top: 10px;
}
#content-wrapper .error-dialog .fui-dialog-foot {
position: static;
padding: 5px 20px;
......
This diff is collapsed.
......@@ -27,9 +27,83 @@ KityMinder.registerUI('widget/notice', function (minder) {
var $error_body = $($error.getBodyElement());
var isBuilded = (function() {
var scripts = [].slice.apply(document.getElementsByTagName('script'));
var s, m;
while( (s = scripts.pop()) ) {
if ( (m = /kityminder.*\.min\.js/.exec(s.src))) return m[0];
}
return false;
})();
// concatMap: sperate files -> join file
// minMap: join file -> min file
var concatMap, minMap;
function fixSourceSymbol($ta, $mask) {
function fix() {
var text = $ta.text();
var pattern = new RegExp('at.+' + isBuilded + '.+\\:(\\d+)\\:(\\d+)\\)?', 'g');
var match;
$ta.text(text.replace(pattern, function(match, $1, $2) {
var lookup = {line: +$1, column: +$2};
var info = minMap.originalPositionFor(lookup);
var name = info.name;
lookup = {line: info.line, column: info.column};
info = concatMap.originalPositionFor(lookup);
name = name || '<Anonymous>';
var replaced = 'at ' + name + ' (' +
info.source.replace('../', '') + ':' + info.line + ':' + info.column + ')';
if (replaced.indexOf('promise') != -1) {
replaced = 'at <async> Promise.' + name;
}
return replaced;
}));
}
if (isBuilded) {
if (concatMap) return fix();
$mask.addClass('loading');
setTimeout(function() {
$mask.removeClass('loading');
}, 5000);
var script = document.createElement('script');
script.onload = function() {
Promise.all([
$.pajax({
url: isBuilded.replace('min.js', 'js.map'),
dataType: 'json'
}),
$.pajax({
url: isBuilded.replace('.js', '.map'),
dataType: 'json'
})
]).then(function(files) {
concatMap = new window.sourceMap.SourceMapConsumer(files[0]);
minMap = new window.sourceMap.SourceMapConsumer(files[1]);
fix();
$mask.removeClass('loading');
});
};
script.src = 'lib/source-map.min.js';
document.head.appendChild(script);
}
}
$error_body.delegate('.error-detail a.expander', 'click', function(e) {
var $detail = $(e.target).closest('.error-detail').toggleClass('expanded');
memory.set('show-error-detail', $detail.hasClass('expanded'));
var showDetail = $detail.hasClass('expanded');
memory.set('show-error-detail', showDetail);
});
function info(msg, warn) {
......@@ -59,6 +133,8 @@ KityMinder.registerUI('widget/notice', function (minder) {
e = new Error(e);
}
if (e.getDetail) return e;
// 文件访问错误
if (e instanceof fio.FileRequestError) {
if (!e.status) {
......@@ -103,14 +179,22 @@ KityMinder.registerUI('widget/notice', function (minder) {
.addClass('error-detail')
.append($('<a class="expander"></a>').text(minder.getLang('ui.error_detail')))
.appendTo($error_body);
var $detailContent = $('<div>')
.addClass('error-detail-wrapper')
.appendTo($detail);
var $textarea = $('<textarea>')
.attr('id', 'error-detail-content')
.text(e.getDetail())
.appendTo($detail);
.appendTo($detailContent);
fixSourceSymbol($textarea, $detailContent);
var $copy = $('<button>')
.addClass('copy-and-feedback')
.text(minder.getLang('ui.copy_and_feedback'))
.appendTo($detail);
.appendTo($detailContent);
$copy.attr('data-clipboard-target', 'error-detail-content');
......@@ -145,7 +229,7 @@ KityMinder.registerUI('widget/notice', function (minder) {
$target.remove();
}
}
return {
info: info,
error: error,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment