@jsenv/plugin-supervisor 1.7.3 → 1.7.5

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.
@@ -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 :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 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: 0 20px 40px rgb(0 0 0 / 30%), 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 }";
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 => {
@@ -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
- for (const key of Object.keys(htmlUrlInfo.contentInjections)) {
983
- const value = htmlUrlInfo.contentInjections[key];
984
- if (htmlUrlInfo.context.isPlaceholderInjection(value)) {
985
- inlineScriptReference.urlInfo.contentInjections[key] = value;
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.3",
4
- "license": "MIT",
3
+ "version": "1.7.5",
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
- "publishConfig": {
11
- "access": "public"
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.6",
38
- "@jsenv/sourcemap": "1.3.9"
34
+ "@jsenv/ast": "6.7.8",
35
+ "@jsenv/sourcemap": "1.3.10"
39
36
  },
40
37
  "devDependencies": {
41
- "@jsenv/urls": "../../tooling/urls",
42
- "@jsenv/snapshot": "../../tooling/snapshot",
38
+ "@jsenv/core": "../../../",
43
39
  "@jsenv/filesystem": "../../backend/filesystem",
44
40
  "@jsenv/humanize": "../../tooling/humanize",
45
- "@jsenv/core": "../../../"
41
+ "@jsenv/snapshot": "../../tooling/snapshot",
42
+ "@jsenv/urls": "../../tooling/urls"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
46
  }
47
47
  }
@@ -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: dataToRender.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
- :host {
1163
- position: fixed;
1164
- z-index: 99999;
1165
- top: 0;
1166
- left: 0;
1167
- width: 100%;
1168
- height: 100%;
1169
- overflow-y: scroll;
1170
- margin: 0;
1171
- background: rgba(0, 0, 0, 0.66);
1172
- }
1173
-
1174
- .backdrop {
1175
- position: absolute;
1176
- left: 0;
1177
- right: 0;
1178
- top: 0;
1179
- bottom: 0;
1180
- }
1181
-
1182
- .overlay {
1183
- position: relative;
1184
- background: rgba(0, 0, 0, 0.95);
1185
- width: 800px;
1186
- margin: 30px auto;
1187
- padding: 25px 40px;
1188
- padding-top: 0;
1189
- overflow: hidden; /* for h1 margins */
1190
- border-radius: 4px 8px;
1191
- box-shadow: 0 20px 40px rgb(0 0 0 / 30%), 0 15px 12px rgb(0 0 0 / 20%);
1192
- box-sizing: border-box;
1193
- font-family: monospace;
1194
- direction: ltr;
1195
- }
1196
-
1197
- h1 {
1198
- color: red;
1199
- text-align: center;
1200
- }
1201
-
1202
- pre {
1203
- overflow: auto;
1204
- max-width: 100%;
1205
- /* padding is nice + prevents scrollbar from hiding the text behind it */
1206
- /* does not work nicely on firefox though https://bugzilla.mozilla.org/show_bug.cgi?id=748518 */
1207
- padding: 20px;
1208
- }
1209
-
1210
- .tip {
1211
- border-top: 1px solid #999;
1212
- padding-top: 12px;
1213
- }
1214
-
1215
- [data-theme="dark"] {
1216
- color: #999;
1217
- }
1218
- [data-theme="dark"] pre {
1219
- background: #111;
1220
- border: 1px solid #333;
1221
- color: #eee;
1222
- }
1223
-
1224
- [data-theme="light"] {
1225
- color: #EEEEEE;
1226
- }
1227
- [data-theme="light"] pre {
1228
- background: #1E1E1E;
1229
- border: 1px solid white;
1230
- color: #EEEEEE;
1231
- }
1232
-
1233
- pre a {
1234
- color: inherit;
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;
@@ -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
- for (const key of Object.keys(htmlUrlInfo.contentInjections)) {
261
- const value = htmlUrlInfo.contentInjections[key];
262
- if (htmlUrlInfo.context.isPlaceholderInjection(value)) {
263
- inlineScriptReference.urlInfo.contentInjections[key] = value;
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;