62 lines
1.8 KiB
TypeScript
62 lines
1.8 KiB
TypeScript
import './app.less';
|
|
import bootHtml from './app.html';
|
|
import { watchConsole } from './injects/watch-console';
|
|
import { setOnErrorListener } from './injects/on-error';
|
|
import { createCss, createHtml, createScript } from '../shared/create-script';
|
|
import { messageListener } from '../shared/message-listener';
|
|
import { postMessage, postResponseMessage } from '../shared/post-message';
|
|
import { RenderCanvas } from './elements/render-canvas/render-canvas';
|
|
import { getCenter, getHeight, getRandom, getWidth, rect, box, getRandomColor } from './injects/dom-helpers';
|
|
import { setWindowStop } from './injects/window-stop';
|
|
import { LoadingSpinner } from './elements/loading-spinner/loading-spinner';
|
|
|
|
|
|
window.customElements.define('loading-spinner', LoadingSpinner);
|
|
window.customElements.define('render-canvas', RenderCanvas);
|
|
|
|
console.log("BOOTING");
|
|
|
|
document.body.innerHTML += bootHtml;
|
|
let consoleLimit = 10;
|
|
watchConsole((type, value) => {
|
|
if (consoleLimit > 0) {
|
|
--consoleLimit;
|
|
postMessage(parent, type, value.toString());
|
|
}
|
|
else if (consoleLimit === 0) {
|
|
--consoleLimit;
|
|
postMessage(parent, type, "+ more");
|
|
}
|
|
});
|
|
messageListener((type, value, id) => {
|
|
if (type == "javascript") {
|
|
createScript(value);
|
|
postResponseMessage(parent, id, value);
|
|
}
|
|
else if (type == "html") {
|
|
createHtml(value);
|
|
}
|
|
else if (type == "css") {
|
|
createCss(value);
|
|
}
|
|
});
|
|
setOnErrorListener((type, value) => {
|
|
postMessage(parent, type, value);
|
|
});
|
|
|
|
//@ts-ignore
|
|
window.rect = rect;
|
|
//@ts-ignore
|
|
window.box = box;
|
|
//@ts-ignore
|
|
window.width = getWidth;
|
|
//@ts-ignore
|
|
window.height = getHeight;
|
|
//@ts-ignore
|
|
window.center = getCenter;
|
|
//@ts-ignore
|
|
window.rand = getRandom;
|
|
//@ts-ignore
|
|
window.randomColor = getRandomColor;
|
|
|
|
setWindowStop(); |