@jsenv/core 27.5.1 → 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 +524 -344
- package/dist/main.js +179 -95
- package/package.json +3 -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 +413 -0
- package/src/plugins/html_supervisor/client/error_overlay.js +62 -272
- package/src/plugins/html_supervisor/client/error_site_remap.js +85 -0
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +26 -77
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +103 -14
- package/src/test/execute_test_plan.js +1 -2
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
removeHtmlNodeText,
|
|
20
20
|
setHtmlNodeText,
|
|
21
21
|
} from "@jsenv/ast"
|
|
22
|
-
import { generateInlineContentUrl } from "@jsenv/urls"
|
|
22
|
+
import { generateInlineContentUrl, stringifyUrlSite } from "@jsenv/urls"
|
|
23
23
|
|
|
24
24
|
import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
|
|
25
25
|
|
|
@@ -28,6 +28,7 @@ export const jsenvPluginHtmlSupervisor = ({
|
|
|
28
28
|
measurePerf = false,
|
|
29
29
|
errorOverlay = true,
|
|
30
30
|
openInEditor = true,
|
|
31
|
+
errorBaseUrl,
|
|
31
32
|
}) => {
|
|
32
33
|
const htmlSupervisorSetupFileUrl = new URL(
|
|
33
34
|
"./client/html_supervisor_setup.js?js_classic",
|
|
@@ -45,24 +46,111 @@ export const jsenvPluginHtmlSupervisor = ({
|
|
|
45
46
|
dev: true,
|
|
46
47
|
test: true,
|
|
47
48
|
},
|
|
48
|
-
serve: (request) => {
|
|
49
|
-
if (
|
|
50
|
-
|
|
49
|
+
serve: (request, context) => {
|
|
50
|
+
if (request.ressource.startsWith("/__get_code_frame__/")) {
|
|
51
|
+
const url = request.ressource.slice("/__get_code_frame__/".length)
|
|
52
|
+
const match = url.match(/:([0-9]+):([0-9]+)$/)
|
|
53
|
+
if (!match) {
|
|
54
|
+
return {
|
|
55
|
+
status: 400,
|
|
56
|
+
body: "Missing line and column in url",
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const file = url.slice(0, match.index)
|
|
60
|
+
const line = parseInt(match[1])
|
|
61
|
+
const column = parseInt(match[2])
|
|
62
|
+
const urlInfo = context.urlGraph.getUrlInfo(file)
|
|
63
|
+
if (!urlInfo) {
|
|
64
|
+
return {
|
|
65
|
+
status: 404,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const codeFrame = stringifyUrlSite({
|
|
69
|
+
url: file,
|
|
70
|
+
line,
|
|
71
|
+
column,
|
|
72
|
+
content: urlInfo.originalContent,
|
|
73
|
+
})
|
|
74
|
+
return {
|
|
75
|
+
status: 200,
|
|
76
|
+
headers: {
|
|
77
|
+
"content-type": "text/plain",
|
|
78
|
+
"content-length": Buffer.byteLength(codeFrame),
|
|
79
|
+
},
|
|
80
|
+
body: codeFrame,
|
|
81
|
+
}
|
|
51
82
|
}
|
|
52
|
-
|
|
53
|
-
|
|
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
|
+
)
|
|
54
124
|
return {
|
|
55
|
-
status:
|
|
56
|
-
|
|
125
|
+
status: 200,
|
|
126
|
+
headers: {
|
|
127
|
+
"cache-control": "no-cache",
|
|
128
|
+
"content-type": "application/json",
|
|
129
|
+
"content-length": Buffer.byteLength(body),
|
|
130
|
+
},
|
|
131
|
+
body,
|
|
57
132
|
}
|
|
58
133
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
+
}
|
|
65
152
|
}
|
|
153
|
+
return null
|
|
66
154
|
},
|
|
67
155
|
transformUrlContent: {
|
|
68
156
|
html: ({ url, content }, context) => {
|
|
@@ -173,6 +261,7 @@ export const jsenvPluginHtmlSupervisor = ({
|
|
|
173
261
|
installHtmlSupervisor(${JSON.stringify(
|
|
174
262
|
{
|
|
175
263
|
rootDirectoryUrl: context.rootDirectoryUrl,
|
|
264
|
+
errorBaseUrl,
|
|
176
265
|
logs,
|
|
177
266
|
measurePerf,
|
|
178
267
|
errorOverlay,
|
|
@@ -60,8 +60,7 @@ export const executeTestPlan = async ({
|
|
|
60
60
|
cooldownBetweenExecutions = 0,
|
|
61
61
|
gcBetweenExecutions = logMemoryHeapUsage,
|
|
62
62
|
|
|
63
|
-
coverageEnabled = process.argv.includes("--
|
|
64
|
-
process.argv.includes("--coverage"),
|
|
63
|
+
coverageEnabled = process.argv.includes("--coverage"),
|
|
65
64
|
coverageConfig = {
|
|
66
65
|
"./src/": true,
|
|
67
66
|
},
|