p5.js-web-editor/client/utils/previewEntry.js
Liang Tang 617f00653c Improve current console (#656)
* init v2

* make replay work

* fix a failing scenary of react-frame

* fix some bugs

* delete/comment some files

* remove

* fix some bugs && remove more comments

* remove unnecessary lines

* minor tweak

* fix some bugs

* try to hook iframe using webpack

* update

* changes according to cassie

* minor tweak

* fix lint

* extract sass

* add icons

* update webpack config

* update webpack configuration

* update

* tweak

* fix a small bug
2018-07-30 12:20:57 -04:00

21 lines
483 B
JavaScript

import loopProtect from 'loop-protect';
import Hook from 'console-feed/lib/Hook/index';
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);