Commit 10751361 authored by techird's avatar techird

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

parent 0034c01d
...@@ -36,14 +36,8 @@ module.exports = function(grunt) { ...@@ -36,14 +36,8 @@ module.exports = function(grunt) {
options: { options: {
banner: banner + '(function(window) {\n\n', banner: banner + '(function(window) {\n\n',
footer: '\n\n})(window)', footer: '\n\n})(window)',
process: function(src, filepath) { sourceMap: true,
return ['\n', sourceMapStyle: 'link'
'/* ' + filepath + ' */',
src.replace(/^.+$/mg, ' $&'),
'/* ' + filepath + ' end */',
'\n',
].join('\n');
}
}, },
src: sources.filter(function(source) { src: sources.filter(function(source) {
return source.pack == '*' || source.pack.split('|').indexOf(pack) !== -1; return source.pack == '*' || source.pack.split('|').indexOf(pack) !== -1;
...@@ -67,7 +61,8 @@ module.exports = function(grunt) { ...@@ -67,7 +61,8 @@ module.exports = function(grunt) {
uglify: { uglify: {
minimize: { minimize: {
options: { options: {
banner: banner banner: banner,
sourceMap: true
}, },
files: (function() { files: (function() {
var files = {}; var files = {};
...@@ -90,6 +85,7 @@ module.exports = function(grunt) { ...@@ -90,6 +85,7 @@ module.exports = function(grunt) {
'static/**/*', 'static/**/*',
'lib/ZeroClipboard.swf', 'lib/ZeroClipboard.swf',
'lib/inflate.js', 'lib/inflate.js',
'lib/source-map.min.js',
'index.html', 'index.html',
'edit.html', 'edit.html',
'viewshare.html', 'viewshare.html',
......
This diff is collapsed.
...@@ -30,8 +30,8 @@ ...@@ -30,8 +30,8 @@
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"grunt": "~0.4.1", "grunt": "~0.4.1",
"grunt-contrib-concat": "~0.3.0", "grunt-contrib-concat": "~0.5.0",
"grunt-contrib-uglify": "~0.2.6", "grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-copy": "~0.5.0", "grunt-contrib-copy": "~0.5.0",
"grunt-text-replace": "~0.3.9", "grunt-text-replace": "~0.3.9",
"grunt-contrib-watch": "~0.6.1", "grunt-contrib-watch": "~0.6.1",
......
...@@ -60,17 +60,6 @@ ...@@ -60,17 +60,6 @@
} }
.error-detail { .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; position: relative;
a.expander { a.expander {
display: block; display: block;
...@@ -85,13 +74,8 @@ ...@@ -85,13 +74,8 @@
text-decoration: underline; text-decoration: underline;
} }
} }
.copy-and-feedback {
display: none;
float: right;
margin-top: 10px;
}
&.expanded { &.expanded {
textarea, .copy-and-feedback { .error-detail-wrapper {
display: block; display: block;
} }
a.expander:before { a.expander:before {
...@@ -111,6 +95,24 @@ ...@@ -111,6 +95,24 @@
font-size: 12px; font-size: 12px;
color: #AAA; 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 { ...@@ -1361,17 +1361,6 @@ input[type=search]::-ms-clear {
#content-wrapper .error-dialog .fui-dialog-body .error-detail { #content-wrapper .error-dialog .fui-dialog-body .error-detail {
position: relative; 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 { #content-wrapper .error-dialog .fui-dialog-body .error-detail a.expander {
display: block; display: block;
margin: 8px 0; margin: 8px 0;
...@@ -1395,13 +1384,7 @@ input[type=search]::-ms-clear { ...@@ -1395,13 +1384,7 @@ input[type=search]::-ms-clear {
#content-wrapper .error-dialog .fui-dialog-body .error-detail a.expander:hover { #content-wrapper .error-dialog .fui-dialog-body .error-detail a.expander:hover {
text-decoration: underline; text-decoration: underline;
} }
#content-wrapper .error-dialog .fui-dialog-body .error-detail .copy-and-feedback { #content-wrapper .error-dialog .fui-dialog-body .error-detail.expanded .error-detail-wrapper {
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 {
display: block; display: block;
} }
#content-wrapper .error-dialog .fui-dialog-body .error-detail.expanded a.expander:before { #content-wrapper .error-dialog .fui-dialog-body .error-detail.expanded a.expander:before {
...@@ -1430,6 +1413,23 @@ input[type=search]::-ms-clear { ...@@ -1430,6 +1413,23 @@ input[type=search]::-ms-clear {
font-size: 12px; font-size: 12px;
color: #AAA; 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 { #content-wrapper .error-dialog .fui-dialog-foot {
position: static; position: static;
padding: 5px 20px; padding: 5px 20px;
......
This diff is collapsed.
...@@ -27,9 +27,83 @@ KityMinder.registerUI('widget/notice', function (minder) { ...@@ -27,9 +27,83 @@ KityMinder.registerUI('widget/notice', function (minder) {
var $error_body = $($error.getBodyElement()); 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) { $error_body.delegate('.error-detail a.expander', 'click', function(e) {
var $detail = $(e.target).closest('.error-detail').toggleClass('expanded'); 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) { function info(msg, warn) {
...@@ -59,6 +133,8 @@ KityMinder.registerUI('widget/notice', function (minder) { ...@@ -59,6 +133,8 @@ KityMinder.registerUI('widget/notice', function (minder) {
e = new Error(e); e = new Error(e);
} }
if (e.getDetail) return e;
// 文件访问错误 // 文件访问错误
if (e instanceof fio.FileRequestError) { if (e instanceof fio.FileRequestError) {
if (!e.status) { if (!e.status) {
...@@ -103,14 +179,22 @@ KityMinder.registerUI('widget/notice', function (minder) { ...@@ -103,14 +179,22 @@ KityMinder.registerUI('widget/notice', function (minder) {
.addClass('error-detail') .addClass('error-detail')
.append($('<a class="expander"></a>').text(minder.getLang('ui.error_detail'))) .append($('<a class="expander"></a>').text(minder.getLang('ui.error_detail')))
.appendTo($error_body); .appendTo($error_body);
var $detailContent = $('<div>')
.addClass('error-detail-wrapper')
.appendTo($detail);
var $textarea = $('<textarea>') var $textarea = $('<textarea>')
.attr('id', 'error-detail-content') .attr('id', 'error-detail-content')
.text(e.getDetail()) .text(e.getDetail())
.appendTo($detail); .appendTo($detailContent);
fixSourceSymbol($textarea, $detailContent);
var $copy = $('<button>') var $copy = $('<button>')
.addClass('copy-and-feedback') .addClass('copy-and-feedback')
.text(minder.getLang('ui.copy_and_feedback')) .text(minder.getLang('ui.copy_and_feedback'))
.appendTo($detail); .appendTo($detailContent);
$copy.attr('data-clipboard-target', 'error-detail-content'); $copy.attr('data-clipboard-target', 'error-detail-content');
......
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