-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: error integration
- Loading branch information
Showing
29 changed files
with
2,417 additions
and
595 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"endOfLine": "lf", | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
const createRefreshTemplate = require('./createRefreshTemplate'); | ||
const injectRefreshEntry = require('./injectRefreshEntry'); | ||
|
||
module.exports = { createRefreshTemplate, injectRefreshEntry }; | ||
module.exports = { | ||
createRefreshTemplate, | ||
injectRefreshEntry, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const ansiHTML = require('ansi-html'); | ||
const { Html5Entities } = require('html-entities'); | ||
const theme = require('../theme'); | ||
const formatFilename = require('../utils/formatFilename'); | ||
|
||
ansiHTML.setColors(theme); | ||
|
||
const entities = new Html5Entities(); | ||
|
||
/** | ||
* @typedef {Object} CompileErrorTraceProps | ||
* @property {string} errorMessage | ||
*/ | ||
|
||
/** | ||
* A formatter that turns Webpack compile error messages into highlighted HTML source traces. | ||
* @param {Document} document | ||
* @param {HTMLElement} root | ||
* @param {CompileErrorTraceProps} props | ||
* @returns {void} | ||
*/ | ||
function CompileErrorTrace(document, root, props) { | ||
const errorParts = props.errorMessage.split('\n'); | ||
const errorMessage = errorParts | ||
.splice(1, 1)[0] | ||
// Strip filename from the error message | ||
.replace(/^(.*:)\s.*:(\s.*)$/, '$1$2'); | ||
errorParts[0] = formatFilename(errorParts[0]); | ||
errorParts.unshift(errorMessage); | ||
|
||
const stackContainer = document.createElement('pre'); | ||
stackContainer.innerHTML = ansiHTML(entities.encode(errorParts.join('\n'))); | ||
stackContainer.style.fontFamily = [ | ||
'"Operator Mono SSm"', | ||
'"Operator Mono"', | ||
'"Fira Code Retina"', | ||
'"Fira Code"', | ||
'"FiraCode-Retina"', | ||
'"Andale Mono"', | ||
'"Lucida Console"', | ||
'Menlo', | ||
'Consolas', | ||
'Monaco', | ||
'monospace', | ||
].join(', '); | ||
stackContainer.style.margin = '0'; | ||
stackContainer.style.whiteSpace = 'pre-wrap'; | ||
|
||
root.appendChild(stackContainer); | ||
} | ||
|
||
module.exports = CompileErrorTrace; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const theme = require('../theme'); | ||
const Spacer = require('./Spacer'); | ||
|
||
/** | ||
* @typedef {Object} PageHeaderProps | ||
* @property {string} [message] | ||
* @property {string} title | ||
* @property {string} [topOffset] | ||
*/ | ||
|
||
/** | ||
* The header of the overlay. | ||
* @param {Document} document | ||
* @param {HTMLElement} root | ||
* @param {PageHeaderProps} props | ||
* @returns {void} | ||
*/ | ||
function PageHeader(document, root, props) { | ||
const pageHeaderContainer = document.createElement('div'); | ||
pageHeaderContainer.style.background = '#' + theme.dimgrey; | ||
pageHeaderContainer.style.boxShadow = '0 1px 4px rgba(0, 0, 0, 0.3)'; | ||
pageHeaderContainer.style.color = '#' + theme.white; | ||
pageHeaderContainer.style.left = '0'; | ||
pageHeaderContainer.style.padding = '1rem 1.5rem'; | ||
pageHeaderContainer.style.position = 'fixed'; | ||
pageHeaderContainer.style.top = props.topOffset || '0'; | ||
pageHeaderContainer.style.width = 'calc(100vw - 3rem)'; | ||
|
||
const title = document.createElement('h3'); | ||
title.innerText = props.title; | ||
title.style.color = '#' + theme.red; | ||
title.style.fontSize = '1.125rem'; | ||
title.style.lineHeight = '1.3'; | ||
title.style.margin = '0'; | ||
pageHeaderContainer.appendChild(title); | ||
|
||
if (props.message) { | ||
title.style.margin = '0 0 0.5rem'; | ||
|
||
const message = document.createElement('span'); | ||
message.innerText = props.message; | ||
message.style.color = '#' + theme.white; | ||
message.style.wordBreak = 'break-word'; | ||
pageHeaderContainer.appendChild(message); | ||
} | ||
|
||
root.appendChild(pageHeaderContainer); | ||
|
||
// This has to run after appending elements to root | ||
// because we need to actual mounted height. | ||
Spacer(document, root, { | ||
space: pageHeaderContainer.offsetHeight.toString(10), | ||
}); | ||
} | ||
|
||
module.exports = PageHeader; |
Oops, something went wrong.