@jsenv/plugin-supervisor 1.8.9 → 1.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1066,16 +1066,22 @@ window.__supervisor__ = (() => {
1066
1066
  * a warning, never the other way around.
1067
1067
  */
1068
1068
  class JsenvWarningOverlay extends HTMLElement {
1069
+ // "node" is for what a string cannot say: a live indicator, something
1070
+ // animated, anything the code reporting the warning wants to render itself
1069
1071
  constructor({
1070
1072
  title,
1071
1073
  text,
1072
- details = []
1074
+ details = [],
1075
+ node
1073
1076
  }) {
1074
1077
  super();
1075
1078
  const root = this.attachShadow({
1076
1079
  mode: "open"
1077
1080
  });
1078
- root.innerHTML = "\n<style>\n ".concat(overlayCSS, "\n</style>\n<div class=\"backdrop\"></div>\n<div class=\"overlay\" data-theme=\"dark\" data-level=\"warning\">\n <button class=\"copy\" type=\"button\">Copy</button>\n <h1 class=\"title\">\n ").concat(escapeHtml(title), "\n </h1>\n <pre class=\"text\">").concat(escapeHtml(text), "</pre>\n <div class=\"details\">\n ").concat(details.map(detail => "<p>".concat(escapeHtml(detail), "</p>")).join("\n "), "\n </div>\n <div class=\"tip\">\n Click outside to close.\n </div>\n</div>");
1081
+ root.innerHTML = "\n<style>\n ".concat(overlayCSS, "\n</style>\n<div class=\"backdrop\"></div>\n<div class=\"overlay\" data-theme=\"dark\" data-level=\"warning\">\n <button class=\"copy\" type=\"button\">Copy</button>\n <h1 class=\"title\">\n ").concat(escapeHtml(title), "\n </h1>\n <pre class=\"text\">").concat(escapeHtml(text), "</pre>\n <div class=\"details\">\n ").concat(details.map(detail => "<p>".concat(escapeHtml(detail), "</p>")).join("\n "), "\n </div>\n <div class=\"extra\"></div>\n <div class=\"tip\">\n Click outside to close.\n </div>\n</div>");
1082
+ if (node) {
1083
+ root.querySelector(".extra").appendChild(node);
1084
+ }
1079
1085
  enableCopyButton(root);
1080
1086
  root.querySelector(".backdrop").onclick = () => {
1081
1087
  if (!this.parentNode) {
@@ -1102,6 +1108,14 @@ window.__supervisor__ = (() => {
1102
1108
  parts.push(paragraph.textContent.trim());
1103
1109
  }
1104
1110
  }
1111
+ // a node rendered by the warning reporter says which of its parts are
1112
+ // worth pasting, the rest being decoration
1113
+ const extraNode = overlay.querySelector(".extra");
1114
+ if (extraNode) {
1115
+ for (const line of extraNode.querySelectorAll("[data-copy-line]")) {
1116
+ parts.push(line.textContent.trim().replace(/\s+/g, " "));
1117
+ }
1118
+ }
1105
1119
  const copied = await writeTextToClipboard(parts.join("\n"));
1106
1120
  button.textContent = copied ? "Copied" : "Copy failed";
1107
1121
  clearTimeout(resetTimeout);
@@ -1232,13 +1246,14 @@ window.__supervisor__ = (() => {
1232
1246
  if (customElements && !customElements.get(JSENV_WARNING_OVERLAY_TAGNAME)) {
1233
1247
  customElements.define(JSENV_WARNING_OVERLAY_TAGNAME, JsenvWarningOverlay);
1234
1248
  }
1235
- const overlayCSS = /* css */"\n :host {\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99999;\n width: 100%;\n height: 100%;\n /* overflow-y: scroll; */\n margin: 0;\n background: rgba(0, 0, 0, 0.66);\n }\n\n .backdrop {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n .overlay {\n position: relative;\n box-sizing: border-box;\n width: 800px;\n /* keep a margin visible on every side, the content scrolls rather\n than the overlay growing edge to edge */\n max-width: 98dvw;\n max-height: calc(100dvh - 60px);\n margin: 30px auto;\n padding: 25px 40px;\n padding-top: 0;\n font-family: monospace;\n direction: ltr;\n background: rgba(0, 0, 0, 0.95);\n border-radius: 4px 8px;\n box-shadow:\n 0 20px 40px rgb(0 0 0 / 30%),\n 0 15px 12px rgb(0 0 0 / 20%);\n overflow: auto; /* creates a block formatting context, for h1 margins */\n }\n\n h1 {\n color: red;\n text-align: center;\n }\n\n [data-level=\"warning\"] h1 {\n color: #ffab40;\n }\n\n .copy {\n position: absolute;\n top: 12px;\n right: 12px;\n padding: 4px 10px;\n color: inherit;\n font-size: 12px;\n font-family: inherit;\n background: transparent;\n border: 1px solid currentColor;\n border-radius: 4px;\n opacity: 0.7;\n cursor: pointer;\n }\n .copy:hover {\n opacity: 1;\n }\n\n .details {\n padding: 0 20px 16px;\n line-height: 1.5;\n }\n .details p {\n margin: 0 0 8px;\n }\n .details p:last-child {\n margin-bottom: 0;\n }\n\n pre {\n max-width: 100%;\n /* padding is nice + prevents scrollbar from hiding the text behind it */\n /* does not work nicely on firefox though https://bugzilla.mozilla.org/show_bug.cgi?id=748518 */\n padding: 20px;\n overflow: auto;\n }\n\n .tip {\n padding-top: 12px;\n border-top: 1px solid #999;\n }\n\n [data-theme=\"dark\"] {\n color: #999;\n }\n [data-theme=\"dark\"] pre {\n color: #eee;\n background: #111;\n border: 1px solid #333;\n }\n\n [data-theme=\"light\"] {\n color: #eeeeee;\n }\n [data-theme=\"light\"] pre {\n color: #eeeeee;\n background: #1e1e1e;\n border: 1px solid white;\n }\n\n pre a {\n color: inherit;\n }\n ";
1249
+ const overlayCSS = /* css */"\n :host {\n position: fixed;\n top: 0;\n left: 0;\n z-index: 99999;\n width: 100%;\n height: 100%;\n /* overflow-y: scroll; */\n margin: 0;\n background: rgba(0, 0, 0, 0.66);\n }\n\n .backdrop {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n\n .overlay {\n position: relative;\n box-sizing: border-box;\n width: 800px;\n /* keep a margin visible on every side, the content scrolls rather\n than the overlay growing edge to edge */\n max-width: 98dvw;\n max-height: calc(100dvh - 60px);\n margin: 30px auto;\n padding: 25px 40px;\n padding-top: 0;\n font-family: monospace;\n direction: ltr;\n background: rgba(0, 0, 0, 0.95);\n border-radius: 4px 8px;\n box-shadow:\n 0 20px 40px rgb(0 0 0 / 30%),\n 0 15px 12px rgb(0 0 0 / 20%);\n overflow: auto; /* creates a block formatting context, for h1 margins */\n }\n\n h1 {\n color: red;\n text-align: center;\n }\n\n [data-level=\"warning\"] h1 {\n color: #ffab40;\n }\n\n .copy {\n position: absolute;\n top: 12px;\n right: 12px;\n padding: 4px 10px;\n color: inherit;\n font-size: 12px;\n font-family: inherit;\n background: transparent;\n border: 1px solid currentColor;\n border-radius: 4px;\n opacity: 0.7;\n cursor: pointer;\n }\n .copy:hover {\n opacity: 1;\n }\n\n .details {\n padding: 0 20px 16px;\n line-height: 1.5;\n }\n .details p {\n margin: 0 0 8px;\n }\n .details p:last-child {\n margin-bottom: 0;\n }\n\n pre {\n max-width: 100%;\n /* padding is nice + prevents scrollbar from hiding the text behind it */\n /* does not work nicely on firefox though https://bugzilla.mozilla.org/show_bug.cgi?id=748518 */\n padding: 20px;\n overflow: auto;\n }\n\n .extra {\n padding: 0 20px 16px;\n }\n .extra:empty {\n display: none;\n }\n\n .tip {\n padding-top: 12px;\n border-top: 1px solid #999;\n }\n\n [data-theme=\"dark\"] {\n color: #999;\n }\n [data-theme=\"dark\"] pre {\n color: #eee;\n background: #111;\n border: 1px solid #333;\n }\n\n [data-theme=\"light\"] {\n color: #eeeeee;\n }\n [data-theme=\"light\"] pre {\n color: #eeeeee;\n background: #1e1e1e;\n border: 1px solid white;\n }\n\n pre a {\n color: inherit;\n }\n ";
1236
1250
  }
1237
1251
  supervisor.createException = createException;
1238
1252
  supervisor.reportWarning = ({
1239
1253
  title,
1240
1254
  text,
1241
- details
1255
+ details,
1256
+ node
1242
1257
  }) => {
1243
1258
  if (!errorOverlay) {
1244
1259
  return () => {};
@@ -1246,7 +1261,8 @@ window.__supervisor__ = (() => {
1246
1261
  return displayJsenvWarningOverlay({
1247
1262
  title,
1248
1263
  text,
1249
- details
1264
+ details,
1265
+ node
1250
1266
  });
1251
1267
  };
1252
1268
  supervisor.reportException = exception => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-supervisor",
3
- "version": "1.8.9",
3
+ "version": "1.8.11",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "prepublishOnly": "npm run build"
28
28
  },
29
29
  "dependencies": {
30
- "@jsenv/ast": "6.8.5",
30
+ "@jsenv/ast": "6.9.1",
31
31
  "@jsenv/sourcemap": "1.4.2"
32
32
  },
33
33
  "devDependencies": {
@@ -1107,7 +1107,9 @@ window.__supervisor__ = (() => {
1107
1107
  * a warning, never the other way around.
1108
1108
  */
1109
1109
  class JsenvWarningOverlay extends HTMLElement {
1110
- constructor({ title, text, details = [] }) {
1110
+ // "node" is for what a string cannot say: a live indicator, something
1111
+ // animated, anything the code reporting the warning wants to render itself
1112
+ constructor({ title, text, details = [], node }) {
1111
1113
  super();
1112
1114
  const root = this.attachShadow({ mode: "open" });
1113
1115
  root.innerHTML = `
@@ -1124,10 +1126,14 @@ window.__supervisor__ = (() => {
1124
1126
  <div class="details">
1125
1127
  ${details.map((detail) => `<p>${escapeHtml(detail)}</p>`).join("\n ")}
1126
1128
  </div>
1129
+ <div class="extra"></div>
1127
1130
  <div class="tip">
1128
1131
  Click outside to close.
1129
1132
  </div>
1130
1133
  </div>`;
1134
+ if (node) {
1135
+ root.querySelector(".extra").appendChild(node);
1136
+ }
1131
1137
  enableCopyButton(root);
1132
1138
  root.querySelector(".backdrop").onclick = () => {
1133
1139
  if (!this.parentNode) {
@@ -1160,6 +1166,14 @@ window.__supervisor__ = (() => {
1160
1166
  parts.push(paragraph.textContent.trim());
1161
1167
  }
1162
1168
  }
1169
+ // a node rendered by the warning reporter says which of its parts are
1170
+ // worth pasting, the rest being decoration
1171
+ const extraNode = overlay.querySelector(".extra");
1172
+ if (extraNode) {
1173
+ for (const line of extraNode.querySelectorAll("[data-copy-line]")) {
1174
+ parts.push(line.textContent.trim().replace(/\s+/g, " "));
1175
+ }
1176
+ }
1163
1177
  const copied = await writeTextToClipboard(parts.join("\n"));
1164
1178
  button.textContent = copied ? "Copied" : "Copy failed";
1165
1179
  clearTimeout(resetTimeout);
@@ -1376,6 +1390,13 @@ window.__supervisor__ = (() => {
1376
1390
  overflow: auto;
1377
1391
  }
1378
1392
 
1393
+ .extra {
1394
+ padding: 0 20px 16px;
1395
+ }
1396
+ .extra:empty {
1397
+ display: none;
1398
+ }
1399
+
1379
1400
  .tip {
1380
1401
  padding-top: 12px;
1381
1402
  border-top: 1px solid #999;
@@ -1406,11 +1427,11 @@ window.__supervisor__ = (() => {
1406
1427
  }
1407
1428
 
1408
1429
  supervisor.createException = createException;
1409
- supervisor.reportWarning = ({ title, text, details }) => {
1430
+ supervisor.reportWarning = ({ title, text, details, node }) => {
1410
1431
  if (!errorOverlay) {
1411
1432
  return () => {};
1412
1433
  }
1413
- return displayJsenvWarningOverlay({ title, text, details });
1434
+ return displayJsenvWarningOverlay({ title, text, details, node });
1414
1435
  };
1415
1436
  supervisor.reportException = (exception) => {
1416
1437
  if (errorOverlay) {