123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- 'use strict';
- var ansiHTML = require('ansi-html');
- var _require = require('html-entities'),
- AllHtmlEntities = _require.AllHtmlEntities;
- var entities = new AllHtmlEntities();
- var colors = {
- reset: ['transparent', 'transparent'],
- black: '181818',
- red: 'E36049',
- green: 'B3CB74',
- yellow: 'FFD080',
- blue: '7CAFC2',
- magenta: '7FACCA',
- cyan: 'C3C2EF',
- lightgrey: 'EBE7E3',
- darkgrey: '6D7891'
- };
- var overlayIframe = null;
- var overlayDiv = null;
- var lastOnOverlayDivReady = null;
- ansiHTML.setColors(colors);
- function createOverlayIframe(onIframeLoad) {
- var iframe = document.createElement('iframe');
- iframe.id = 'webpack-dev-server-client-overlay';
- iframe.src = 'about:blank';
- iframe.style.position = 'fixed';
- iframe.style.left = 0;
- iframe.style.top = 0;
- iframe.style.right = 0;
- iframe.style.bottom = 0;
- iframe.style.width = '100vw';
- iframe.style.height = '100vh';
- iframe.style.border = 'none';
- iframe.style.zIndex = 9999999999;
- iframe.onload = onIframeLoad;
- return iframe;
- }
- function addOverlayDivTo(iframe) {
- var div = iframe.contentDocument.createElement('div');
- div.id = 'webpack-dev-server-client-overlay-div';
- div.style.position = 'fixed';
- div.style.boxSizing = 'border-box';
- div.style.left = 0;
- div.style.top = 0;
- div.style.right = 0;
- div.style.bottom = 0;
- div.style.width = '100vw';
- div.style.height = '100vh';
- div.style.backgroundColor = 'rgba(0, 0, 0, 0.85)';
- div.style.color = '#E8E8E8';
- div.style.fontFamily = 'Menlo, Consolas, monospace';
- div.style.fontSize = 'large';
- div.style.padding = '2rem';
- div.style.lineHeight = '1.2';
- div.style.whiteSpace = 'pre-wrap';
- div.style.overflow = 'auto';
- iframe.contentDocument.body.appendChild(div);
- return div;
- }
- function ensureOverlayDivExists(onOverlayDivReady) {
- if (overlayDiv) {
-
- onOverlayDivReady(overlayDiv);
- return;
- }
-
- lastOnOverlayDivReady = onOverlayDivReady;
- if (overlayIframe) {
-
- return;
- }
- overlayIframe = createOverlayIframe(function () {
- overlayDiv = addOverlayDivTo(overlayIframe);
- lastOnOverlayDivReady(overlayDiv);
- });
-
-
- document.body.appendChild(overlayIframe);
- }
- function clear() {
- if (!overlayDiv) {
-
- return;
- }
- document.body.removeChild(overlayIframe);
- overlayDiv = null;
- overlayIframe = null;
- lastOnOverlayDivReady = null;
- }
- function showMessage(messages) {
- ensureOverlayDivExists(function (div) {
-
- div.innerHTML = "<span style=\"color: #".concat(colors.red, "\">Failed to compile.</span><br><br>").concat(ansiHTML(entities.encode(messages[0])));
- });
- }
- module.exports = {
- clear: clear,
- showMessage: showMessage
- };
|