MCPcopy
hub / github.com/webpack/webpack-dev-server / show

Function show

client-src/overlay.js:594–645  ·  view source on GitHub ↗

* @param {string} type type * @param {(string | Message)[]} messages messages * @param {undefined | false | string} trustedTypesPolicyName trusted types policy name * @param {"build" | "runtime"} messageSource message source

(type, messages, trustedTypesPolicyName, messageSource)

Source from the content-addressed store, hash-verified

592 * @param {"build" | "runtime"} messageSource message source
593 */
594 function show(type, messages, trustedTypesPolicyName, messageSource) {
595 ensureOverlayExists(() => {
596 /** @type {HTMLDivElement} */
597 (headerElement).innerText =
598 messageSource === "runtime"
599 ? "Uncaught runtime errors:"
600 : "Compiled with problems:";
601
602 messages.forEach((message) => {
603 const entryElement = document.createElement("div");
604 const msgStyle =
605 type === "warning" ? msgStyles.warning : msgStyles.error;
606 applyStyle(entryElement, {
607 ...msgStyle,
608 padding: "1rem 1rem 1.5rem 1rem",
609 });
610
611 const typeElement = document.createElement("div");
612 const { header, body } = formatProblem(type, message);
613
614 typeElement.innerText = header;
615 applyStyle(typeElement, msgTypeStyle);
616
617 if (typeof message !== "string" && message.moduleIdentifier) {
618 applyStyle(typeElement, { cursor: "pointer" });
619 // element.dataset not supported in IE
620 typeElement.setAttribute("data-can-open", "true");
621 typeElement.addEventListener("click", () => {
622 fetch(
623 `/webpack-dev-server/open-editor?fileName=${message.moduleIdentifier}`,
624 );
625 });
626 }
627
628 // Make it look similar to our terminal.
629 const text = ansiHTML(encode(body));
630 const messageTextNode = document.createElement("div");
631 applyStyle(messageTextNode, msgTextStyle);
632
633 // @ts-expect-error https://github.com/microsoft/TypeScript/issues/30024
634 messageTextNode.innerHTML = overlayTrustedTypesPolicy
635 ? overlayTrustedTypesPolicy.createHTML(text)
636 : text;
637
638 entryElement.appendChild(typeElement);
639 entryElement.appendChild(messageTextNode);
640
641 /** @type {HTMLDivElement} */
642 (containerElement).appendChild(entryElement);
643 });
644 }, trustedTypesPolicyName);
645 }
646
647 /** @type {(event: KeyboardEvent) => void} */
648 let handleEscapeKey;

Callers 1

createOverlayFunction · 0.85

Calls 4

ensureOverlayExistsFunction · 0.85
applyStyleFunction · 0.85
formatProblemFunction · 0.85
encodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…