2018-07-30 16:20:57 +00:00
|
|
|
import loopProtect from 'loop-protect';
|
2018-08-20 18:54:12 +00:00
|
|
|
import { Hook } from 'console-feed';
|
2018-07-30 16:20:57 +00:00
|
|
|
|
|
|
|
window.loopProtect = loopProtect;
|
|
|
|
|
|
|
|
const consoleBuffer = [];
|
|
|
|
const LOGWAIT = 500;
|
|
|
|
Hook(window.console, (log) => {
|
|
|
|
const { method, data: args } = log[0];
|
|
|
|
consoleBuffer.push({
|
|
|
|
method,
|
|
|
|
arguments: args,
|
|
|
|
source: 'sketch'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
setInterval(() => {
|
|
|
|
if (consoleBuffer.length > 0) {
|
|
|
|
window.parent.postMessage(consoleBuffer, '*');
|
|
|
|
consoleBuffer.length = 0;
|
|
|
|
}
|
|
|
|
}, LOGWAIT);
|