@jsenv/plugin-supervisor 1.7.2 → 1.7.4
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.
- package/dist/js/supervisor.js +9 -3
- package/dist/jsenv_plugin_supervisor.js +15 -4
- package/package.json +14 -14
- package/src/client/supervisor.js +91 -77
- package/src/jsenv_plugin_supervisor.js +15 -4
package/dist/js/supervisor.js
CHANGED
|
@@ -983,11 +983,11 @@ window.__supervisor__ = (() => {
|
|
|
983
983
|
const {
|
|
984
984
|
trace = {}
|
|
985
985
|
} = cause;
|
|
986
|
-
const preferCause = cause.code === "MODULE_NOT_FOUND" || cause.code === "PROTOCOL_NOT_SUPPORTED";
|
|
986
|
+
const preferCause = cause.code === "MODULE_NOT_FOUND" || cause.code === "PROTOCOL_NOT_SUPPORTED" || cause.code === "PARSE_ERROR";
|
|
987
987
|
const dataToRender = preferCause ? cause : exception;
|
|
988
988
|
root.querySelector(".text").innerHTML = stringifyStack({
|
|
989
989
|
codeFrame: trace.codeFrame ? generateClickableText(trace.codeFrame) : "",
|
|
990
|
-
name: dataToRender.name,
|
|
990
|
+
name: cause.parseErrorSourceType === "css" ? "CSSSyntaxError" : dataToRender.name,
|
|
991
991
|
message: preferCause ? generateClickableText(cause.reason) : dataToRender.message ? generateClickableText(dataToRender.message) : "",
|
|
992
992
|
stackTrace: dataToRender.stackTrace ? generateClickableText(dataToRender.stackTrace) : ""
|
|
993
993
|
});
|
|
@@ -1136,7 +1136,7 @@ window.__supervisor__ = (() => {
|
|
|
1136
1136
|
if (customElements && !customElements.get(JSENV_ERROR_OVERLAY_TAGNAME)) {
|
|
1137
1137
|
customElements.define(JSENV_ERROR_OVERLAY_TAGNAME, JsenvErrorOverlay);
|
|
1138
1138
|
}
|
|
1139
|
-
const overlayCSS = "\n
|
|
1139
|
+
const overlayCSS = /* css */"\n :host {\n position: fixed;\n z-index: 99999;\n top: 0;\n left: 0;\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 left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n }\n\n .overlay {\n position: relative;\n background: rgba(0, 0, 0, 0.95);\n width: 800px;\n max-width: 100vw;\n margin: 30px auto;\n padding: 25px 40px;\n padding-top: 0;\n overflow: hidden; /* for h1 margins */\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 box-sizing: border-box;\n font-family: monospace;\n direction: ltr;\n }\n\n h1 {\n color: red;\n text-align: center;\n }\n\n pre {\n overflow: auto;\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 }\n\n .tip {\n border-top: 1px solid #999;\n padding-top: 12px;\n }\n\n [data-theme=\"dark\"] {\n color: #999;\n }\n [data-theme=\"dark\"] pre {\n background: #111;\n border: 1px solid #333;\n color: #eee;\n }\n\n [data-theme=\"light\"] {\n color: #eeeeee;\n }\n [data-theme=\"light\"] pre {\n background: #1e1e1e;\n border: 1px solid white;\n color: #eeeeee;\n }\n\n pre a {\n color: inherit;\n }\n ";
|
|
1140
1140
|
}
|
|
1141
1141
|
supervisor.createException = createException;
|
|
1142
1142
|
supervisor.reportException = exception => {
|
|
@@ -1209,6 +1209,12 @@ window.__supervisor__ = (() => {
|
|
|
1209
1209
|
lineno,
|
|
1210
1210
|
colno
|
|
1211
1211
|
} = errorEvent;
|
|
1212
|
+
if (error && error.__handled__) {
|
|
1213
|
+
if (logs) {
|
|
1214
|
+
console.log("ignore error event because __handled__ is set");
|
|
1215
|
+
}
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1212
1218
|
const exception = supervisor.createException(error || message, {
|
|
1213
1219
|
// when error is reported within a worker error is null
|
|
1214
1220
|
// but there is a message property on errorEvent
|
|
@@ -921,6 +921,7 @@ const jsenvPluginSupervisor = ({
|
|
|
921
921
|
name: errorCausingRuntimeError.name,
|
|
922
922
|
message: errorCausingRuntimeError.message,
|
|
923
923
|
reason: errorCausingRuntimeError.reason,
|
|
924
|
+
parseErrorSourceType: errorCausingRuntimeError.parseErrorSourceType,
|
|
924
925
|
stack: errorBaseUrl ? "stack mocked for snapshot" : errorCausingRuntimeError.stack,
|
|
925
926
|
trace: errorCausingRuntimeError.trace,
|
|
926
927
|
isJsenvCookingError: errorCausingRuntimeError.isJsenvCookingError
|
|
@@ -979,10 +980,20 @@ const jsenvPluginSupervisor = ({
|
|
|
979
980
|
contentType: "text/javascript",
|
|
980
981
|
content: textContent
|
|
981
982
|
});
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
983
|
+
const htmlContentInjections = htmlUrlInfo.contentInjections;
|
|
984
|
+
const {
|
|
985
|
+
isPlaceholderInjection,
|
|
986
|
+
INJECTIONS
|
|
987
|
+
} = htmlUrlInfo.context;
|
|
988
|
+
for (const key of Object.keys(htmlContentInjections)) {
|
|
989
|
+
const injection = htmlUrlInfo.contentInjections[key];
|
|
990
|
+
if (isPlaceholderInjection(injection)) {
|
|
991
|
+
inlineScriptReference.urlInfo.contentInjections[key] = injection;
|
|
992
|
+
// ideally we should mark injection as optional only if it's
|
|
993
|
+
// hapenning for inline content
|
|
994
|
+
// but for now we'll just mark all html injections as optional
|
|
995
|
+
// when there is an inline script
|
|
996
|
+
htmlContentInjections[key] = INJECTIONS.optional(injection);
|
|
986
997
|
}
|
|
987
998
|
}
|
|
988
999
|
return inlineScriptReference.generatedSpecifier;
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-supervisor",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"license": "MIT",
|
|
3
|
+
"version": "1.7.4",
|
|
5
4
|
"repository": {
|
|
6
5
|
"type": "git",
|
|
7
6
|
"url": "https://github.com/jsenv/core",
|
|
8
7
|
"directory": "packages/internal/plugin-supervisor"
|
|
9
8
|
},
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"./src/client/supervisor.js",
|
|
12
|
+
"./dist/js/supervisor.js"
|
|
13
|
+
],
|
|
13
14
|
"type": "module",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
@@ -25,23 +26,22 @@
|
|
|
25
26
|
"/src/",
|
|
26
27
|
"/dist/"
|
|
27
28
|
],
|
|
28
|
-
"sideEffects": [
|
|
29
|
-
"./src/client/supervisor.js",
|
|
30
|
-
"./dist/js/supervisor.js"
|
|
31
|
-
],
|
|
32
29
|
"scripts": {
|
|
33
30
|
"build": "node ./scripts/build.mjs",
|
|
34
31
|
"prepublishOnly": "npm run build"
|
|
35
32
|
},
|
|
36
33
|
"dependencies": {
|
|
37
|
-
"@jsenv/ast": "6.7.
|
|
38
|
-
"@jsenv/sourcemap": "1.3.
|
|
34
|
+
"@jsenv/ast": "6.7.7",
|
|
35
|
+
"@jsenv/sourcemap": "1.3.9"
|
|
39
36
|
},
|
|
40
37
|
"devDependencies": {
|
|
41
|
-
"@jsenv/
|
|
42
|
-
"@jsenv/snapshot": "../../tooling/snapshot",
|
|
38
|
+
"@jsenv/core": "../../../",
|
|
43
39
|
"@jsenv/filesystem": "../../backend/filesystem",
|
|
44
40
|
"@jsenv/humanize": "../../tooling/humanize",
|
|
45
|
-
"@jsenv/
|
|
41
|
+
"@jsenv/snapshot": "../../tooling/snapshot",
|
|
42
|
+
"@jsenv/urls": "../../tooling/urls"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/src/client/supervisor.js
CHANGED
|
@@ -984,13 +984,17 @@ window.__supervisor__ = (() => {
|
|
|
984
984
|
const { trace = {} } = cause;
|
|
985
985
|
const preferCause =
|
|
986
986
|
cause.code === "MODULE_NOT_FOUND" ||
|
|
987
|
-
cause.code === "PROTOCOL_NOT_SUPPORTED"
|
|
987
|
+
cause.code === "PROTOCOL_NOT_SUPPORTED" ||
|
|
988
|
+
cause.code === "PARSE_ERROR";
|
|
988
989
|
const dataToRender = preferCause ? cause : exception;
|
|
989
990
|
root.querySelector(".text").innerHTML = stringifyStack({
|
|
990
991
|
codeFrame: trace.codeFrame
|
|
991
992
|
? generateClickableText(trace.codeFrame)
|
|
992
993
|
: "",
|
|
993
|
-
name:
|
|
994
|
+
name:
|
|
995
|
+
cause.parseErrorSourceType === "css"
|
|
996
|
+
? "CSSSyntaxError"
|
|
997
|
+
: dataToRender.name,
|
|
994
998
|
message: preferCause
|
|
995
999
|
? generateClickableText(cause.reason)
|
|
996
1000
|
: dataToRender.message
|
|
@@ -1158,81 +1162,85 @@ window.__supervisor__ = (() => {
|
|
|
1158
1162
|
customElements.define(JSENV_ERROR_OVERLAY_TAGNAME, JsenvErrorOverlay);
|
|
1159
1163
|
}
|
|
1160
1164
|
|
|
1161
|
-
const overlayCSS = `
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1165
|
+
const overlayCSS = /* css */ `
|
|
1166
|
+
:host {
|
|
1167
|
+
position: fixed;
|
|
1168
|
+
z-index: 99999;
|
|
1169
|
+
top: 0;
|
|
1170
|
+
left: 0;
|
|
1171
|
+
width: 100%;
|
|
1172
|
+
height: 100%;
|
|
1173
|
+
/* overflow-y: scroll; */
|
|
1174
|
+
margin: 0;
|
|
1175
|
+
background: rgba(0, 0, 0, 0.66);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
.backdrop {
|
|
1179
|
+
position: absolute;
|
|
1180
|
+
left: 0;
|
|
1181
|
+
right: 0;
|
|
1182
|
+
top: 0;
|
|
1183
|
+
bottom: 0;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
.overlay {
|
|
1187
|
+
position: relative;
|
|
1188
|
+
background: rgba(0, 0, 0, 0.95);
|
|
1189
|
+
width: 800px;
|
|
1190
|
+
max-width: 100vw;
|
|
1191
|
+
margin: 30px auto;
|
|
1192
|
+
padding: 25px 40px;
|
|
1193
|
+
padding-top: 0;
|
|
1194
|
+
overflow: hidden; /* for h1 margins */
|
|
1195
|
+
border-radius: 4px 8px;
|
|
1196
|
+
box-shadow:
|
|
1197
|
+
0 20px 40px rgb(0 0 0 / 30%),
|
|
1198
|
+
0 15px 12px rgb(0 0 0 / 20%);
|
|
1199
|
+
box-sizing: border-box;
|
|
1200
|
+
font-family: monospace;
|
|
1201
|
+
direction: ltr;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
h1 {
|
|
1205
|
+
color: red;
|
|
1206
|
+
text-align: center;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
pre {
|
|
1210
|
+
overflow: auto;
|
|
1211
|
+
max-width: 100%;
|
|
1212
|
+
/* padding is nice + prevents scrollbar from hiding the text behind it */
|
|
1213
|
+
/* does not work nicely on firefox though https://bugzilla.mozilla.org/show_bug.cgi?id=748518 */
|
|
1214
|
+
padding: 20px;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
.tip {
|
|
1218
|
+
border-top: 1px solid #999;
|
|
1219
|
+
padding-top: 12px;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
[data-theme="dark"] {
|
|
1223
|
+
color: #999;
|
|
1224
|
+
}
|
|
1225
|
+
[data-theme="dark"] pre {
|
|
1226
|
+
background: #111;
|
|
1227
|
+
border: 1px solid #333;
|
|
1228
|
+
color: #eee;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
[data-theme="light"] {
|
|
1232
|
+
color: #eeeeee;
|
|
1233
|
+
}
|
|
1234
|
+
[data-theme="light"] pre {
|
|
1235
|
+
background: #1e1e1e;
|
|
1236
|
+
border: 1px solid white;
|
|
1237
|
+
color: #eeeeee;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
pre a {
|
|
1241
|
+
color: inherit;
|
|
1242
|
+
}
|
|
1243
|
+
`;
|
|
1236
1244
|
}
|
|
1237
1245
|
|
|
1238
1246
|
supervisor.createException = createException;
|
|
@@ -1304,6 +1312,12 @@ window.__supervisor__ = (() => {
|
|
|
1304
1312
|
console.log('window "error" event received', errorEvent);
|
|
1305
1313
|
}
|
|
1306
1314
|
const { error, message, filename, lineno, colno } = errorEvent;
|
|
1315
|
+
if (error && error.__handled__) {
|
|
1316
|
+
if (logs) {
|
|
1317
|
+
console.log("ignore error event because __handled__ is set");
|
|
1318
|
+
}
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1307
1321
|
const exception = supervisor.createException(error || message, {
|
|
1308
1322
|
// when error is reported within a worker error is null
|
|
1309
1323
|
// but there is a message property on errorEvent
|
|
@@ -187,6 +187,8 @@ export const jsenvPluginSupervisor = ({
|
|
|
187
187
|
name: errorCausingRuntimeError.name,
|
|
188
188
|
message: errorCausingRuntimeError.message,
|
|
189
189
|
reason: errorCausingRuntimeError.reason,
|
|
190
|
+
parseErrorSourceType:
|
|
191
|
+
errorCausingRuntimeError.parseErrorSourceType,
|
|
190
192
|
stack: errorBaseUrl
|
|
191
193
|
? `stack mocked for snapshot`
|
|
192
194
|
: errorCausingRuntimeError.stack,
|
|
@@ -257,10 +259,19 @@ export const jsenvPluginSupervisor = ({
|
|
|
257
259
|
contentType: "text/javascript",
|
|
258
260
|
content: textContent,
|
|
259
261
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
const htmlContentInjections = htmlUrlInfo.contentInjections;
|
|
263
|
+
const { isPlaceholderInjection, INJECTIONS } =
|
|
264
|
+
htmlUrlInfo.context;
|
|
265
|
+
for (const key of Object.keys(htmlContentInjections)) {
|
|
266
|
+
const injection = htmlUrlInfo.contentInjections[key];
|
|
267
|
+
if (isPlaceholderInjection(injection)) {
|
|
268
|
+
inlineScriptReference.urlInfo.contentInjections[key] =
|
|
269
|
+
injection;
|
|
270
|
+
// ideally we should mark injection as optional only if it's
|
|
271
|
+
// hapenning for inline content
|
|
272
|
+
// but for now we'll just mark all html injections as optional
|
|
273
|
+
// when there is an inline script
|
|
274
|
+
htmlContentInjections[key] = INJECTIONS.optional(injection);
|
|
264
275
|
}
|
|
265
276
|
}
|
|
266
277
|
return inlineScriptReference.generatedSpecifier;
|