Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 464b0f0

Browse files
shinytang6catarak
authored andcommitted
delete/comment some files
1 parent 1b8ff2a commit 464b0f0

File tree

3 files changed

+66
-104
lines changed

3 files changed

+66
-104
lines changed

client/modules/IDE/components/PreviewFrame.jsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import PropTypes from 'prop-types';
22
import React from 'react';
33
import ReactDOM from 'react-dom';
44
// import escapeStringRegexp from 'escape-string-regexp';
5-
import srcDoc from 'srcdoc-polyfill';
65
import { isEqual } from 'lodash';
7-
// import update from 'immutability-helper';
86
import loopProtect from 'loop-protect';
97
import loopProtectScript from 'loop-protect/dist/loop-protect.min';
108
import Frame, { FrameContextConsumer } from 'react-frame-component';
11-
import { Hook, Decode } from 'console-feed';
9+
import { Hook } from 'console-feed';
1210
import { JSHINT } from 'jshint';
1311
import decomment from 'decomment';
1412
import { getBlobUrl } from '../actions/files';
@@ -21,7 +19,7 @@ import {
2119
EXTERNAL_LINK_REGEX,
2220
NOT_EXTERNAL_LINK_REGEX
2321
} from '../../../../server/utils/fileUtils';
24-
import { hijackConsole, hijackConsoleErrorsScript, startTag, getAllScriptOffsets }
22+
import { startTag }
2523
from '../../../utils/consoleUtils';
2624

2725
export default class PreviewFrame extends React.Component {
@@ -397,10 +395,11 @@ export default class PreviewFrame extends React.Component {
397395

398396
// catch reference errors, via http://stackoverflow.com/a/12747364/2994108
399397
window.onerror = function (msg, url, lineNumber, columnNo, error) {
400-
const string = msg.toLowerCase();
401-
const substring = 'script error';
398+
// const string = msg.toLowerCase();
399+
// const substring = 'script error';
402400
let data = {};
403401
data = msg + ' (' + 'sketch' + ': line ' + lineNumber + ')';// eslint-disable-line
402+
console.log(data);
404403
window.parent.postMessage([{
405404
method: 'error',
406405
arguments: data,

client/utils/consoleUtils.js

Lines changed: 61 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -11,106 +11,70 @@ import debugDarkUrl from '../images/console-debug-dark.svg';
1111
import infoLightUrl from '../images/console-info-light.svg';
1212
import infoDarkUrl from '../images/console-info-dark.svg';
1313

14-
export const hijackConsole = `var iframeWindow = window;
15-
var originalConsole = iframeWindow.console;
16-
iframeWindow.console = {};
17-
18-
var methods = [
19-
'debug', 'clear', 'error', 'info', 'log', 'warn'
20-
];
21-
22-
var consoleBuffer = [];
23-
var LOGWAIT = 500;
24-
25-
methods.forEach( function(method) {
26-
iframeWindow.console[method] = function() {
27-
originalConsole[method].apply(originalConsole, arguments);
28-
29-
var args = Array.from(arguments);
30-
args = args.map(function(i) {
31-
// catch objects
32-
return (typeof i === 'string') ? i : JSON.stringify(i);
33-
});
34-
35-
consoleBuffer.push({
36-
method: method,
37-
arguments: args,
38-
source: 'sketch'
39-
});
40-
};
41-
});
42-
43-
setInterval(function() {
44-
if (consoleBuffer.length > 0) {
45-
window.parent.postMessage(consoleBuffer, '*');
46-
consoleBuffer.length = 0;
47-
}
48-
}, LOGWAIT);`;
49-
50-
export const hijackConsoleErrorsScript = (offs) => {
51-
const s = `
52-
function getScriptOff(line) {
53-
var offs = ${offs};
54-
var l = 0;
55-
var file = "";
56-
for (var i=0; i<offs.length; i++) {
57-
var n = offs[i][0];
58-
if (n < line && n > l) {
59-
l = n;
60-
file = offs[i][1];
61-
}
62-
}
63-
return [line - l, file];
64-
}
65-
// catch reference errors, via http://stackoverflow.com/a/12747364/2994108
66-
window.onerror = function (msg, url, lineNumber, columnNo, error) {
67-
var string = msg.toLowerCase();
68-
var substring = "script error";
69-
var data = {};
70-
if (url.match(${EXTERNAL_LINK_REGEX}) !== null && error.stack){
71-
var errorNum = error.stack.split("about:srcdoc:")[1].split(":")[0];
72-
var fileInfo = getScriptOff(errorNum);
73-
data = msg + " (" + fileInfo[1] + ": line " + fileInfo[0] + ")";
74-
} else {
75-
var fileInfo = getScriptOff(lineNumber);
76-
data = msg + " (" + fileInfo[1] + ": line " + fileInfo[0] + ")";
77-
}
78-
window.parent.postMessage([{
79-
method: "error",
80-
arguments: data,
81-
source: fileInfo[1]
82-
}], "*");
83-
return false;
84-
};
85-
`;
86-
return s;
87-
};
14+
// export const hijackConsoleErrorsScript = (offs) => {
15+
// const s = `
16+
// function getScriptOff(line) {
17+
// var offs = ${offs};
18+
// var l = 0;
19+
// var file = "";
20+
// for (var i=0; i<offs.length; i++) {
21+
// var n = offs[i][0];
22+
// if (n < line && n > l) {
23+
// l = n;
24+
// file = offs[i][1];
25+
// }
26+
// }
27+
// return [line - l, file];
28+
// }
29+
// // catch reference errors, via http://stackoverflow.com/a/12747364/2994108
30+
// window.onerror = function (msg, url, lineNumber, columnNo, error) {
31+
// var string = msg.toLowerCase();
32+
// var substring = "script error";
33+
// var data = {};
34+
// if (url.match(${EXTERNAL_LINK_REGEX}) !== null && error.stack){
35+
// var errorNum = error.stack.split("about:srcdoc:")[1].split(":")[0];
36+
// var fileInfo = getScriptOff(errorNum);
37+
// data = msg + " (" + fileInfo[1] + ": line " + fileInfo[0] + ")";
38+
// } else {
39+
// var fileInfo = getScriptOff(lineNumber);
40+
// data = msg + " (" + fileInfo[1] + ": line " + fileInfo[0] + ")";
41+
// }
42+
// window.parent.postMessage([{
43+
// method: "error",
44+
// arguments: data,
45+
// source: fileInfo[1]
46+
// }], "*");
47+
// return false;
48+
// };
49+
// `;
50+
// return s;
51+
// };
8852

8953
export const startTag = '@fs-';
9054

91-
export const getAllScriptOffsets = (htmlFile) => {
92-
const offs = [];
93-
let found = true;
94-
let lastInd = 0;
95-
let ind = 0;
96-
let endFilenameInd = 0;
97-
let filename = '';
98-
let lineOffset = 0;
99-
while (found) {
100-
ind = htmlFile.indexOf(startTag, lastInd);
101-
if (ind === -1) {
102-
found = false;
103-
} else {
104-
endFilenameInd = htmlFile.indexOf('.js', ind + startTag.length + 3);
105-
filename = htmlFile.substring(ind + startTag.length, endFilenameInd);
106-
// the length of hijackConsoleErrorsScript is 33 lines
107-
lineOffset = htmlFile.substring(0, ind).split('\n').length + 33;
108-
offs.push([lineOffset, filename]);
109-
lastInd = ind + 1;
110-
}
111-
}
112-
return offs;
113-
};
55+
// export const getAllScriptOffsets = (htmlFile) => {
56+
// const offs = [];
57+
// let found = true;
58+
// let lastInd = 0;
59+
// let ind = 0;
60+
// let endFilenameInd = 0;
61+
// let filename = '';
62+
// let lineOffset = 0;
63+
// while (found) {
64+
// ind = htmlFile.indexOf(startTag, lastInd);
65+
// if (ind === -1) {
66+
// found = false;
67+
// } else {
68+
// endFilenameInd = htmlFile.indexOf('.js', ind + startTag.length + 3);
69+
// filename = htmlFile.substring(ind + startTag.length, endFilenameInd);
70+
// // the length of hijackConsoleErrorsScript is 33 lines
71+
// lineOffset = htmlFile.substring(0, ind).split('\n').length + 33;
72+
// offs.push([lineOffset, filename]);
73+
// lastInd = ind + 1;
74+
// }
75+
// }
76+
// return offs;
77+
// };
11478

11579
export const CONSOLE_FEED_WITHOUT_ICONS = {
11680
LOG_WARN_ICON: 'none',

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
"express": "^4.13.4",
8787
"express-session": "^1.13.0",
8888
"htmlhint": "^0.9.13",
89-
"immutability-helper": "^2.7.1",
9089
"is-url": "^1.2.2",
9190
"js-beautify": "^1.6.4",
9291
"jsdom": "^9.8.3",

0 commit comments

Comments
 (0)