@jsenv/core 27.4.0 → 27.5.2
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 +359 -0
- package/dist/js/execute_using_dynamic_import.js +1 -1
- package/dist/js/html_supervisor_installer.js +469 -254
- package/dist/js/html_supervisor_setup.js +3 -4
- package/dist/js/new_stylesheet.js +26 -58
- package/dist/js/server_events_client.js +307 -0
- package/dist/main.js +7558 -7311
- package/package.json +12 -10
- package/{README.md → readme.md} +8 -9
- package/src/build/build.js +12 -16
- package/src/build/start_build_server.js +24 -28
- package/src/dev/start_dev_server.js +34 -96
- package/src/execute/execute.js +17 -35
- package/src/omega/errors.js +20 -18
- package/src/omega/kitchen.js +7 -6
- package/src/omega/omega_server.js +96 -127
- package/src/omega/server/file_service.js +247 -46
- package/src/omega/url_graph.js +33 -20
- package/src/plugins/autoreload/client/autoreload.js +201 -0
- package/src/plugins/autoreload/{dev_sse/client → client}/autoreload_preference.js +0 -0
- package/src/plugins/autoreload/{dev_sse/client → client}/reload.js +29 -10
- package/src/plugins/autoreload/{dev_sse/client → client}/url_helpers.js +0 -0
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +4 -4
- package/src/plugins/autoreload/{dev_sse/jsenv_plugin_dev_sse_client.js → jsenv_plugin_autoreload_client.js} +8 -8
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +196 -0
- package/src/{dev/plugins → plugins}/explorer/client/explorer.html +0 -0
- package/src/{dev/plugins → plugins}/explorer/client/jsenv.png +0 -0
- package/src/{dev/plugins → plugins}/explorer/jsenv_plugin_explorer.js +1 -3
- package/src/plugins/html_supervisor/client/error_formatter.js +300 -0
- package/src/plugins/html_supervisor/client/error_overlay.js +172 -0
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +124 -54
- package/src/plugins/html_supervisor/client/html_supervisor_setup.js +3 -4
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +72 -27
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +97 -117
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +66 -58
- package/src/plugins/plugin_controller.js +102 -67
- package/src/plugins/plugins.js +10 -8
- package/src/{helpers/event_source/event_source.js → plugins/server_events/client/event_source_connection.js} +102 -31
- package/src/plugins/server_events/client/server_events_client.js +17 -0
- package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +48 -0
- package/src/plugins/server_events/server_events_dispatcher.js +69 -0
- package/src/{dev/plugins → plugins}/toolbar/client/animation/toolbar_animation.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/eventsource/eventsource.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/eventsource/toolbar_eventsource.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/execution/execution.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/execution/toolbar_execution.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/focus/focus.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/focus/toolbar_focus.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/jsenv_logo.svg +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/notification/toolbar_notification.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/responsive/overflow_menu.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/responsive/toolbar_responsive.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/settings/settings.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/settings/toolbar_settings.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/jsenv_theme.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/light_theme.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/theme/toolbar_theme.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar.html +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_injector.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/toolbar_main.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.css +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/tooltip/tooltip.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/animation.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/dom.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/fetch_using_xhr.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/fetching.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/iframe_to_parent_href.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/jsenv_logger.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/preferences.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/responsive.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/util/util.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/client/variant/variant.js +0 -0
- package/src/{dev/plugins → plugins}/toolbar/jsenv_plugin_toolbar.js +0 -0
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +4 -3
- package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +25 -55
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +44 -24
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +6 -1
- package/src/plugins/url_analysis/html/html_urls.js +8 -8
- package/src/test/execute_plan.js +36 -54
- package/src/test/execute_test_plan.js +2 -2
- package/dist/js/event_source_client.js +0 -549
- package/src/helpers/event_source/sse_service.js +0 -53
- package/src/plugins/autoreload/dev_sse/client/event_source_client.js +0 -193
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +0 -192
- package/src/plugins/html_supervisor/client/error_in_document.js +0 -345
|
@@ -1,345 +0,0 @@
|
|
|
1
|
-
const JSENV_ERROR_OVERLAY_TAGNAME = "jsenv-error-overlay"
|
|
2
|
-
|
|
3
|
-
export const displayErrorInDocument = (
|
|
4
|
-
error,
|
|
5
|
-
{ rootDirectoryUrl, url, line, column },
|
|
6
|
-
) => {
|
|
7
|
-
document.querySelectorAll(JSENV_ERROR_OVERLAY_TAGNAME).forEach((node) => {
|
|
8
|
-
node.parentNode.removeChild(node)
|
|
9
|
-
})
|
|
10
|
-
const { theme, title, message, stack } = errorToHTML(error, {
|
|
11
|
-
url,
|
|
12
|
-
line,
|
|
13
|
-
column,
|
|
14
|
-
})
|
|
15
|
-
const jsenvErrorOverlay = new JsenvErrorOverlay({
|
|
16
|
-
theme,
|
|
17
|
-
title,
|
|
18
|
-
stack: stack
|
|
19
|
-
? `${replaceLinks(message, { rootDirectoryUrl })}\n${replaceLinks(stack, {
|
|
20
|
-
rootDirectoryUrl,
|
|
21
|
-
})}`
|
|
22
|
-
: replaceLinks(message, { rootDirectoryUrl }),
|
|
23
|
-
})
|
|
24
|
-
document.body.appendChild(jsenvErrorOverlay)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class JsenvErrorOverlay extends HTMLElement {
|
|
28
|
-
constructor({ title, stack, theme = "dark" }) {
|
|
29
|
-
super()
|
|
30
|
-
this.root = this.attachShadow({ mode: "open" })
|
|
31
|
-
this.root.innerHTML = overlayHtml
|
|
32
|
-
this.root.querySelector(".overlay").setAttribute("data-theme", theme)
|
|
33
|
-
this.root.querySelector(".title").innerHTML = title
|
|
34
|
-
this.root.querySelector(".stack").innerHTML = stack
|
|
35
|
-
this.root.querySelector(".backdrop").onclick = () => {
|
|
36
|
-
if (!this.parentNode) {
|
|
37
|
-
// not in document anymore
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
this.root.querySelector(".backdrop").onclick = null
|
|
41
|
-
this.parentNode.removeChild(this)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (customElements && !customElements.get(JSENV_ERROR_OVERLAY_TAGNAME)) {
|
|
47
|
-
customElements.define(JSENV_ERROR_OVERLAY_TAGNAME, JsenvErrorOverlay)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const overlayHtml = `
|
|
51
|
-
<style>
|
|
52
|
-
:host {
|
|
53
|
-
position: fixed;
|
|
54
|
-
z-index: 99999;
|
|
55
|
-
top: 0;
|
|
56
|
-
left: 0;
|
|
57
|
-
width: 100%;
|
|
58
|
-
height: 100%;
|
|
59
|
-
overflow-y: scroll;
|
|
60
|
-
margin: 0;
|
|
61
|
-
background: rgba(0, 0, 0, 0.66);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.backdrop {
|
|
65
|
-
position: absolute;
|
|
66
|
-
left: 0;
|
|
67
|
-
right: 0;
|
|
68
|
-
top: 0;
|
|
69
|
-
bottom: 0;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.overlay {
|
|
73
|
-
position: relative;
|
|
74
|
-
background: rgba(0, 0, 0, 0.95);
|
|
75
|
-
width: 800px;
|
|
76
|
-
margin: 30px auto;
|
|
77
|
-
padding: 25px 40px;
|
|
78
|
-
padding-top: 0;
|
|
79
|
-
overflow: hidden; /* for h1 margins */
|
|
80
|
-
border-radius: 4px 8px;
|
|
81
|
-
box-shadow: 0 20px 40px rgb(0 0 0 / 30%), 0 15px 12px rgb(0 0 0 / 20%);
|
|
82
|
-
box-sizing: border-box;
|
|
83
|
-
font-family: monospace;
|
|
84
|
-
direction: ltr;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
h1 {
|
|
88
|
-
color: red;
|
|
89
|
-
text-align: center;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
pre {
|
|
93
|
-
overflow: auto;
|
|
94
|
-
max-width: 100%;
|
|
95
|
-
/* padding is nice + prevents scrollbar from hiding the text behind it */
|
|
96
|
-
/* does not work nicely on firefox though https://bugzilla.mozilla.org/show_bug.cgi?id=748518 */
|
|
97
|
-
padding: 20px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.tip {
|
|
101
|
-
border-top: 1px solid #999;
|
|
102
|
-
padding-top: 12px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
[data-theme="dark"] {
|
|
106
|
-
color: #999;
|
|
107
|
-
}
|
|
108
|
-
[data-theme="dark"] pre {
|
|
109
|
-
background: #111;
|
|
110
|
-
border: 1px solid #333;
|
|
111
|
-
color: #eee;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
[data-theme="light"] {
|
|
115
|
-
color: #EEEEEE;
|
|
116
|
-
}
|
|
117
|
-
[data-theme="light"] pre {
|
|
118
|
-
background: #1E1E1E;
|
|
119
|
-
border: 1px solid white;
|
|
120
|
-
color: #EEEEEE;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
pre a {
|
|
124
|
-
color: inherit;
|
|
125
|
-
}
|
|
126
|
-
</style>
|
|
127
|
-
<div class="backdrop"></div>
|
|
128
|
-
<div class="overlay">
|
|
129
|
-
<h1 class="title"></h1>
|
|
130
|
-
<pre class="stack"></pre>
|
|
131
|
-
<div class="tip">Click outside to close.</div>
|
|
132
|
-
</div>
|
|
133
|
-
`
|
|
134
|
-
|
|
135
|
-
const parseErrorInfo = (error) => {
|
|
136
|
-
if (error === undefined) {
|
|
137
|
-
return {
|
|
138
|
-
message: "undefined",
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
if (error === null) {
|
|
142
|
-
return {
|
|
143
|
-
message: "null",
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
if (typeof error === "string") {
|
|
147
|
-
return {
|
|
148
|
-
message: error,
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
if (error instanceof Error) {
|
|
152
|
-
if (error.name === "SyntaxError") {
|
|
153
|
-
return {
|
|
154
|
-
message: error.message,
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (error.cause && error.cause.code === "PARSE_ERROR") {
|
|
158
|
-
if (error.messageHTML) {
|
|
159
|
-
return {
|
|
160
|
-
message: error.messageHTML,
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
message: error.message,
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
// stackTrace formatted by V8
|
|
168
|
-
if (Error.captureStackTrace) {
|
|
169
|
-
return {
|
|
170
|
-
message: error.message,
|
|
171
|
-
stack: getErrorStackWithoutErrorMessage(error),
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
return {
|
|
175
|
-
message: error.message,
|
|
176
|
-
stack: error.stack ? ` ${error.stack}` : null,
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if (typeof error === "object") {
|
|
180
|
-
return error
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
message: JSON.stringify(error),
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const getErrorStackWithoutErrorMessage = (error) => {
|
|
188
|
-
let stack = error.stack
|
|
189
|
-
const messageInStack = `${error.name}: ${error.message}`
|
|
190
|
-
if (stack.startsWith(messageInStack)) {
|
|
191
|
-
stack = stack.slice(messageInStack.length)
|
|
192
|
-
}
|
|
193
|
-
const nextLineIndex = stack.indexOf("\n")
|
|
194
|
-
if (nextLineIndex > -1) {
|
|
195
|
-
stack = stack.slice(nextLineIndex + 1)
|
|
196
|
-
}
|
|
197
|
-
return stack
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const errorToHTML = (error, { url, line, column }) => {
|
|
201
|
-
let { message, stack } = parseErrorInfo(error)
|
|
202
|
-
if (url) {
|
|
203
|
-
if (!stack || (error && error.name === "SyntaxError")) {
|
|
204
|
-
stack = ` at ${appendLineAndColumn(url, { line, column })}`
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return {
|
|
208
|
-
theme:
|
|
209
|
-
error && error.cause && error.cause.code === "PARSE_ERROR"
|
|
210
|
-
? "light"
|
|
211
|
-
: "dark",
|
|
212
|
-
title: "An error occured",
|
|
213
|
-
message,
|
|
214
|
-
stack,
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const replaceLinks = (string, { rootDirectoryUrl }) => {
|
|
219
|
-
// normalize line breaks
|
|
220
|
-
string = string.replace(/\n/g, "\n")
|
|
221
|
-
string = escapeHtml(string)
|
|
222
|
-
// render links
|
|
223
|
-
string = stringToStringWithLink(string, {
|
|
224
|
-
transform: (url, { line, column }) => {
|
|
225
|
-
const urlObject = new URL(url)
|
|
226
|
-
|
|
227
|
-
const onFileUrl = (fileUrlObject) => {
|
|
228
|
-
const atFsIndex = fileUrlObject.pathname.indexOf("/@fs/")
|
|
229
|
-
let fileUrl
|
|
230
|
-
if (atFsIndex > -1) {
|
|
231
|
-
const afterAtFs = fileUrlObject.pathname.slice(
|
|
232
|
-
atFsIndex + "/@fs/".length,
|
|
233
|
-
)
|
|
234
|
-
fileUrl = new URL(afterAtFs, "file:///").href
|
|
235
|
-
} else {
|
|
236
|
-
fileUrl = fileUrlObject.href
|
|
237
|
-
}
|
|
238
|
-
fileUrl = appendLineAndColumn(fileUrl, {
|
|
239
|
-
line,
|
|
240
|
-
column,
|
|
241
|
-
})
|
|
242
|
-
return link({
|
|
243
|
-
href: `javascript:window.fetch('/__open_in_editor__/${fileUrl}')`,
|
|
244
|
-
text: fileUrl,
|
|
245
|
-
})
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
if (urlObject.origin === window.origin) {
|
|
249
|
-
const fileUrlObject = new URL(
|
|
250
|
-
`${urlObject.pathname.slice(1)}${urlObject.search}`,
|
|
251
|
-
rootDirectoryUrl,
|
|
252
|
-
)
|
|
253
|
-
return onFileUrl(fileUrlObject)
|
|
254
|
-
}
|
|
255
|
-
if (urlObject.href.startsWith("file:")) {
|
|
256
|
-
return onFileUrl(urlObject)
|
|
257
|
-
}
|
|
258
|
-
return link({
|
|
259
|
-
href: url,
|
|
260
|
-
text: appendLineAndColumn(url, { line, column }),
|
|
261
|
-
})
|
|
262
|
-
},
|
|
263
|
-
})
|
|
264
|
-
return string
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const escapeHtml = (string) => {
|
|
268
|
-
return string
|
|
269
|
-
.replace(/&/g, "&")
|
|
270
|
-
.replace(/</g, "<")
|
|
271
|
-
.replace(/>/g, ">")
|
|
272
|
-
.replace(/"/g, """)
|
|
273
|
-
.replace(/'/g, "'")
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const appendLineAndColumn = (url, { line, column }) => {
|
|
277
|
-
if (line !== undefined && column !== undefined) {
|
|
278
|
-
return `${url}:${line}:${column}`
|
|
279
|
-
}
|
|
280
|
-
if (line !== undefined) {
|
|
281
|
-
return `${url}:${line}`
|
|
282
|
-
}
|
|
283
|
-
return url
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// `Error: yo
|
|
287
|
-
// at Object.execute (http://127.0.0.1:57300/build/src/__test__/file-throw.js:9:13)
|
|
288
|
-
// at doExec (http://127.0.0.1:3000/src/__test__/file-throw.js:452:38)
|
|
289
|
-
// at postOrderExec (http://127.0.0.1:3000/src/__test__/file-throw.js:448:16)
|
|
290
|
-
// at http://127.0.0.1:3000/src/__test__/file-throw.js:399:18`.replace(/(?:https?|ftp|file):\/\/(.*+)$/gm, (...args) => {
|
|
291
|
-
// debugger
|
|
292
|
-
// })
|
|
293
|
-
const stringToStringWithLink = (
|
|
294
|
-
source,
|
|
295
|
-
{
|
|
296
|
-
transform = (url) => {
|
|
297
|
-
return {
|
|
298
|
-
href: url,
|
|
299
|
-
text: url,
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
} = {},
|
|
303
|
-
) => {
|
|
304
|
-
return source.replace(/(?:https?|ftp|file):\/\/\S+/gm, (match) => {
|
|
305
|
-
let linkHTML = ""
|
|
306
|
-
|
|
307
|
-
const lastChar = match[match.length - 1]
|
|
308
|
-
|
|
309
|
-
// hotfix because our url regex sucks a bit
|
|
310
|
-
const endsWithSeparationChar = lastChar === ")" || lastChar === ":"
|
|
311
|
-
if (endsWithSeparationChar) {
|
|
312
|
-
match = match.slice(0, -1)
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const lineAndColumnPattern = /:([0-9]+):([0-9]+)$/
|
|
316
|
-
const lineAndColumMatch = match.match(lineAndColumnPattern)
|
|
317
|
-
if (lineAndColumMatch) {
|
|
318
|
-
const lineAndColumnString = lineAndColumMatch[0]
|
|
319
|
-
const lineNumber = lineAndColumMatch[1]
|
|
320
|
-
const columnNumber = lineAndColumMatch[2]
|
|
321
|
-
linkHTML = transform(match.slice(0, -lineAndColumnString.length), {
|
|
322
|
-
line: lineNumber,
|
|
323
|
-
column: columnNumber,
|
|
324
|
-
})
|
|
325
|
-
} else {
|
|
326
|
-
const linePattern = /:([0-9]+)$/
|
|
327
|
-
const lineMatch = match.match(linePattern)
|
|
328
|
-
if (lineMatch) {
|
|
329
|
-
const lineString = lineMatch[0]
|
|
330
|
-
const lineNumber = lineMatch[1]
|
|
331
|
-
linkHTML = transform(match.slice(0, -lineString.length), {
|
|
332
|
-
line: lineNumber,
|
|
333
|
-
})
|
|
334
|
-
} else {
|
|
335
|
-
linkHTML = transform(match, {})
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
if (endsWithSeparationChar) {
|
|
339
|
-
return `${linkHTML}${lastChar}`
|
|
340
|
-
}
|
|
341
|
-
return linkHTML
|
|
342
|
-
})
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
const link = ({ href, text = href }) => `<a href="${href}">${text}</a>`
|