@jsenv/core 27.5.3 → 27.6.0
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/autoreload.js +7 -0
- package/dist/js/html_supervisor_installer.js +259 -162
- package/dist/main.js +142 -101
- package/package.json +2 -2
- package/src/dev/start_dev_server.js +4 -0
- package/src/omega/kitchen.js +13 -15
- package/src/omega/omega_server.js +4 -0
- package/src/omega/server/file_service.js +9 -66
- package/src/omega/url_graph/url_graph_load.js +0 -2
- package/src/omega/url_graph/url_info_transformations.js +27 -0
- package/src/omega/url_graph.js +1 -0
- package/src/plugins/autoreload/client/autoreload.js +7 -0
- package/src/plugins/html_supervisor/client/error_formatter.js +174 -66
- package/src/plugins/html_supervisor/client/error_overlay.js +29 -31
- package/src/plugins/html_supervisor/client/error_site_remap.js +85 -0
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +21 -63
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +70 -19
|
@@ -88,11 +88,15 @@ export const installHtmlSupervisor = ({
|
|
|
88
88
|
let completed
|
|
89
89
|
let result
|
|
90
90
|
let error
|
|
91
|
+
const urlObject = new URL(src, window.location)
|
|
92
|
+
if (reload) {
|
|
93
|
+
urlObject.searchParams.set("hmr", Date.now())
|
|
94
|
+
}
|
|
95
|
+
__html_supervisor__.currentExecution = {
|
|
96
|
+
type: type === "module" ? "dynamic_import" : "script_injection",
|
|
97
|
+
url: urlObject.href,
|
|
98
|
+
}
|
|
91
99
|
try {
|
|
92
|
-
const urlObject = new URL(src, window.location)
|
|
93
|
-
if (reload) {
|
|
94
|
-
urlObject.searchParams.set("hmr", Date.now())
|
|
95
|
-
}
|
|
96
100
|
result = await execute(urlObject.href)
|
|
97
101
|
completed = true
|
|
98
102
|
} catch (e) {
|
|
@@ -110,6 +114,7 @@ export const installHtmlSupervisor = ({
|
|
|
110
114
|
console.log(`${type} load ended`)
|
|
111
115
|
console.groupEnd()
|
|
112
116
|
}
|
|
117
|
+
__html_supervisor__.currentExecution = null
|
|
113
118
|
return
|
|
114
119
|
}
|
|
115
120
|
const executionResult = {
|
|
@@ -140,6 +145,7 @@ export const installHtmlSupervisor = ({
|
|
|
140
145
|
if (logs) {
|
|
141
146
|
console.groupEnd()
|
|
142
147
|
}
|
|
148
|
+
__html_supervisor__.currentExecution = null
|
|
143
149
|
}
|
|
144
150
|
|
|
145
151
|
const classicExecutionQueue = createExecutionQueue(performExecution)
|
|
@@ -220,76 +226,28 @@ export const installHtmlSupervisor = ({
|
|
|
220
226
|
})
|
|
221
227
|
|
|
222
228
|
if (errorOverlay) {
|
|
229
|
+
const onErrorReportedByBrowser = (error, { url, line, column }) => {
|
|
230
|
+
displayErrorInDocument(error, {
|
|
231
|
+
rootDirectoryUrl,
|
|
232
|
+
errorBaseUrl,
|
|
233
|
+
openInEditor,
|
|
234
|
+
url,
|
|
235
|
+
line,
|
|
236
|
+
column,
|
|
237
|
+
})
|
|
238
|
+
}
|
|
223
239
|
window.addEventListener("error", (errorEvent) => {
|
|
224
240
|
if (!errorEvent.isTrusted) {
|
|
225
241
|
// ignore custom error event (not sent by browser)
|
|
226
242
|
return
|
|
227
243
|
}
|
|
228
244
|
const { error, filename, lineno, colno } = errorEvent
|
|
229
|
-
|
|
230
|
-
rootDirectoryUrl,
|
|
231
|
-
errorBaseUrl,
|
|
232
|
-
openInEditor,
|
|
245
|
+
onErrorReportedByBrowser(error, {
|
|
233
246
|
url: filename,
|
|
234
247
|
line: lineno,
|
|
235
248
|
column: colno,
|
|
236
|
-
reportedBy: "browser",
|
|
237
249
|
})
|
|
238
250
|
})
|
|
239
|
-
if (window.__server_events__) {
|
|
240
|
-
const isExecuting = () => {
|
|
241
|
-
if (pendingExecutionCount > 0) {
|
|
242
|
-
return true
|
|
243
|
-
}
|
|
244
|
-
if (
|
|
245
|
-
document.readyState === "loading" ||
|
|
246
|
-
document.readyState === "interactive"
|
|
247
|
-
) {
|
|
248
|
-
return true
|
|
249
|
-
}
|
|
250
|
-
if (window.__reloader__ && window.__reloader__.status === "reloading") {
|
|
251
|
-
return true
|
|
252
|
-
}
|
|
253
|
-
return false
|
|
254
|
-
}
|
|
255
|
-
window.__server_events__.addEventCallbacks({
|
|
256
|
-
error_while_serving_file: (serverErrorEvent) => {
|
|
257
|
-
if (!isExecuting()) {
|
|
258
|
-
return
|
|
259
|
-
}
|
|
260
|
-
const {
|
|
261
|
-
message,
|
|
262
|
-
stack,
|
|
263
|
-
traceUrl,
|
|
264
|
-
traceLine,
|
|
265
|
-
traceColumn,
|
|
266
|
-
traceMessage,
|
|
267
|
-
requestedRessource,
|
|
268
|
-
isFaviconAutoRequest,
|
|
269
|
-
} = JSON.parse(serverErrorEvent.data)
|
|
270
|
-
if (isFaviconAutoRequest) {
|
|
271
|
-
return
|
|
272
|
-
}
|
|
273
|
-
displayErrorInDocument(
|
|
274
|
-
{
|
|
275
|
-
message,
|
|
276
|
-
stack,
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
rootDirectoryUrl,
|
|
280
|
-
errorBaseUrl,
|
|
281
|
-
openInEditor,
|
|
282
|
-
url: traceUrl,
|
|
283
|
-
line: traceLine,
|
|
284
|
-
column: traceColumn,
|
|
285
|
-
codeFrame: traceMessage,
|
|
286
|
-
reportedBy: "server",
|
|
287
|
-
requestedRessource,
|
|
288
|
-
},
|
|
289
|
-
)
|
|
290
|
-
},
|
|
291
|
-
})
|
|
292
|
-
}
|
|
293
251
|
}
|
|
294
252
|
}
|
|
295
253
|
|
|
@@ -47,25 +47,6 @@ export const jsenvPluginHtmlSupervisor = ({
|
|
|
47
47
|
test: true,
|
|
48
48
|
},
|
|
49
49
|
serve: (request, context) => {
|
|
50
|
-
if (request.ressource.startsWith("/__open_in_editor__/")) {
|
|
51
|
-
const file = request.ressource.slice("/__open_in_editor__/".length)
|
|
52
|
-
if (!file) {
|
|
53
|
-
return {
|
|
54
|
-
status: 400,
|
|
55
|
-
body: "Missing file in url",
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const launch = requireFromJsenv("launch-editor")
|
|
59
|
-
launch(fileURLToPath(file), () => {
|
|
60
|
-
// ignore error for now
|
|
61
|
-
})
|
|
62
|
-
return {
|
|
63
|
-
status: 200,
|
|
64
|
-
headers: {
|
|
65
|
-
"cache-control": "no-store",
|
|
66
|
-
},
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
50
|
if (request.ressource.startsWith("/__get_code_frame__/")) {
|
|
70
51
|
const url = request.ressource.slice("/__get_code_frame__/".length)
|
|
71
52
|
const match = url.match(/:([0-9]+):([0-9]+)$/)
|
|
@@ -99,6 +80,76 @@ export const jsenvPluginHtmlSupervisor = ({
|
|
|
99
80
|
body: codeFrame,
|
|
100
81
|
}
|
|
101
82
|
}
|
|
83
|
+
if (request.ressource.startsWith("/__get_error_cause__/")) {
|
|
84
|
+
const file = request.ressource.slice("/__get_error_cause__/".length)
|
|
85
|
+
if (!file) {
|
|
86
|
+
return {
|
|
87
|
+
status: 400,
|
|
88
|
+
body: "Missing file in url",
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const getErrorCauseInfo = () => {
|
|
92
|
+
const urlInfo = context.urlGraph.getUrlInfo(file)
|
|
93
|
+
if (!urlInfo) {
|
|
94
|
+
return null
|
|
95
|
+
}
|
|
96
|
+
const { error } = urlInfo
|
|
97
|
+
if (error) {
|
|
98
|
+
return error
|
|
99
|
+
}
|
|
100
|
+
// search in direct dependencies (404 or 500)
|
|
101
|
+
const { dependencies } = urlInfo
|
|
102
|
+
for (const dependencyUrl of dependencies) {
|
|
103
|
+
const dependencyUrlInfo = context.urlGraph.getUrlInfo(dependencyUrl)
|
|
104
|
+
if (dependencyUrlInfo.error) {
|
|
105
|
+
return dependencyUrlInfo.error
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return null
|
|
109
|
+
}
|
|
110
|
+
const causeInfo = getErrorCauseInfo()
|
|
111
|
+
const body = JSON.stringify(
|
|
112
|
+
causeInfo
|
|
113
|
+
? {
|
|
114
|
+
code: causeInfo.code,
|
|
115
|
+
message: causeInfo.message,
|
|
116
|
+
reason: causeInfo.reason,
|
|
117
|
+
stack: causeInfo.stack,
|
|
118
|
+
codeFrame: causeInfo.traceMessage,
|
|
119
|
+
}
|
|
120
|
+
: null,
|
|
121
|
+
null,
|
|
122
|
+
" ",
|
|
123
|
+
)
|
|
124
|
+
return {
|
|
125
|
+
status: 200,
|
|
126
|
+
headers: {
|
|
127
|
+
"cache-control": "no-cache",
|
|
128
|
+
"content-type": "application/json",
|
|
129
|
+
"content-length": Buffer.byteLength(body),
|
|
130
|
+
},
|
|
131
|
+
body,
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (request.ressource.startsWith("/__open_in_editor__/")) {
|
|
135
|
+
const file = request.ressource.slice("/__open_in_editor__/".length)
|
|
136
|
+
if (!file) {
|
|
137
|
+
return {
|
|
138
|
+
status: 400,
|
|
139
|
+
body: "Missing file in url",
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
const launch = requireFromJsenv("launch-editor")
|
|
143
|
+
launch(fileURLToPath(file), () => {
|
|
144
|
+
// ignore error for now
|
|
145
|
+
})
|
|
146
|
+
return {
|
|
147
|
+
status: 200,
|
|
148
|
+
headers: {
|
|
149
|
+
"cache-control": "no-store",
|
|
150
|
+
},
|
|
151
|
+
}
|
|
152
|
+
}
|
|
102
153
|
return null
|
|
103
154
|
},
|
|
104
155
|
transformUrlContent: {
|