@jsenv/core 28.0.1 → 28.1.1

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.
Files changed (57) hide show
  1. package/dist/controllable_child_process.mjs +1 -2
  2. package/dist/controllable_worker_thread.mjs +1 -2
  3. package/dist/js/autoreload.js +25 -9
  4. package/dist/js/execute_using_dynamic_import.js +804 -1
  5. package/dist/js/script_type_module_supervisor.js +122 -0
  6. package/dist/js/supervisor.js +933 -0
  7. package/dist/js/{wrapper.mjs → ws.js} +0 -0
  8. package/dist/main.js +452 -504
  9. package/package.json +13 -13
  10. package/readme.md +1 -1
  11. package/src/build/inject_global_version_mappings.js +3 -3
  12. package/src/dev/start_dev_server.js +2 -2
  13. package/src/execute/execute.js +1 -1
  14. package/src/execute/run.js +26 -38
  15. package/src/execute/runtimes/browsers/from_playwright.js +51 -77
  16. package/src/execute/runtimes/node/node_child_process.js +36 -36
  17. package/src/execute/runtimes/node/node_worker_thread.js +36 -36
  18. package/src/omega/kitchen.js +28 -9
  19. package/src/omega/omega_server.js +2 -2
  20. package/src/omega/server/file_service.js +2 -2
  21. package/src/omega/url_graph/url_info_transformations.js +8 -1
  22. package/src/plugins/autoreload/client/reload.js +20 -7
  23. package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +4 -4
  24. package/src/plugins/import_meta_hot/html_hot_dependencies.js +2 -2
  25. package/src/plugins/importmap/jsenv_plugin_importmap.js +5 -3
  26. package/src/plugins/inject_globals/inject_globals.js +3 -3
  27. package/src/plugins/inline/jsenv_plugin_data_urls.js +1 -1
  28. package/src/plugins/inline/jsenv_plugin_html_inline_content.js +10 -5
  29. package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +2 -13
  30. package/src/plugins/plugins.js +5 -5
  31. package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +4 -4
  32. package/src/plugins/supervisor/client/script_type_module_supervisor.js +99 -0
  33. package/src/plugins/supervisor/client/supervisor.js +933 -0
  34. package/src/plugins/{html_supervisor/jsenv_plugin_html_supervisor.js → supervisor/jsenv_plugin_supervisor.js} +128 -102
  35. package/src/plugins/toolbar/client/execution/toolbar_execution.js +1 -1
  36. package/src/plugins/toolbar/jsenv_plugin_toolbar.js +4 -4
  37. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +7 -5
  38. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +5 -4
  39. package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +13 -7
  40. package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +6 -4
  41. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +4 -2
  42. package/src/plugins/url_analysis/html/html_urls.js +11 -10
  43. package/src/test/coverage/babel_plugin_instrument.js +1 -35
  44. package/src/test/coverage/empty_coverage_factory.js +1 -1
  45. package/src/test/execute_plan.js +7 -3
  46. package/src/test/execute_test_plan.js +2 -1
  47. package/src/test/logs_file_execution.js +49 -8
  48. package/dist/js/html_supervisor_installer.js +0 -1091
  49. package/dist/js/html_supervisor_setup.js +0 -89
  50. package/dist/js/uneval.js +0 -804
  51. package/src/plugins/html_supervisor/client/error_formatter.js +0 -426
  52. package/src/plugins/html_supervisor/client/error_in_notification.js +0 -21
  53. package/src/plugins/html_supervisor/client/error_overlay.js +0 -191
  54. package/src/plugins/html_supervisor/client/html_supervisor_installer.js +0 -315
  55. package/src/plugins/html_supervisor/client/html_supervisor_setup.js +0 -89
  56. package/src/plugins/html_supervisor/client/perf_browser.js +0 -17
  57. package/src/plugins/html_supervisor/client/uneval_exception.js +0 -8
@@ -28,6 +28,7 @@ export const executePlan = async (
28
28
  signal,
29
29
  handleSIGINT,
30
30
  logger,
31
+ logRefresh,
31
32
  logRuntime,
32
33
  logEachDuration,
33
34
  logSummary,
@@ -211,6 +212,7 @@ export const executePlan = async (
211
212
  const debugLogsEnabled = loggerToLevels(logger).debug
212
213
  const executionLogsEnabled = loggerToLevels(logger).info
213
214
  const executionSpinner =
215
+ logRefresh &&
214
216
  !debugLogsEnabled &&
215
217
  executionLogsEnabled &&
216
218
  process.stdout.isTTY &&
@@ -310,9 +312,11 @@ export const executePlan = async (
310
312
  } else {
311
313
  executionResult = {
312
314
  status: "errored",
313
- error: new Error(
314
- `No file at ${fileRelativeUrl} for execution "${executionName}"`,
315
- ),
315
+ errors: [
316
+ new Error(
317
+ `No file at ${fileRelativeUrl} for execution "${executionName}"`,
318
+ ),
319
+ ],
316
320
  }
317
321
  }
318
322
  counters.done++
@@ -37,6 +37,7 @@ export const executeTestPlan = async ({
37
37
  signal = new AbortController().signal,
38
38
  handleSIGINT = true,
39
39
  logLevel = "info",
40
+ logRefresh = true,
40
41
  logRuntime = true,
41
42
  logEachDuration = true,
42
43
  logSummary = true,
@@ -130,7 +131,7 @@ export const executeTestPlan = async ({
130
131
  signal,
131
132
  handleSIGINT,
132
133
  logger,
133
- logLevel,
134
+ logRefresh,
134
135
  logSummary,
135
136
  logRuntime,
136
137
  logEachDuration,
@@ -44,8 +44,9 @@ export const createExecutionLog = (
44
44
  if (completedExecutionLogAbbreviation && status === "completed") {
45
45
  return `${description}${summary}`
46
46
  }
47
- const { consoleCalls = [], error } = executionResult
47
+ const { consoleCalls = [], errors = [] } = executionResult
48
48
  const consoleOutput = formatConsoleCalls(consoleCalls)
49
+ const errorsOutput = formatErrors(errors)
49
50
  return formatExecution({
50
51
  label: `${description}${summary}`,
51
52
  details: {
@@ -59,12 +60,39 @@ export const createExecutionLog = (
59
60
  : msAsDuration(endMs - startMs),
60
61
  }
61
62
  : {}),
62
- ...(error ? { error: error.stack || error.message || error } : {}),
63
63
  },
64
64
  consoleOutput,
65
+ errorsOutput,
65
66
  })
66
67
  }
67
68
 
69
+ const formatErrors = (errors) => {
70
+ if (errors.length === 0) {
71
+ return ""
72
+ }
73
+ const formatError = (error) => error.stack || error.message || error
74
+
75
+ if (errors.length === 1) {
76
+ return `${ANSI.color(`-------- error --------`, ANSI.RED)}
77
+ ${formatError(errors[0])}
78
+ ${ANSI.color(`-------------------------`, ANSI.RED)}`
79
+ }
80
+
81
+ let output = []
82
+ errors.forEach((error) => {
83
+ output.push(
84
+ prefixFirstAndIndentRemainingLines({
85
+ prefix: `${UNICODE.CIRCLE_CROSS} `,
86
+ indentation: " ",
87
+ text: formatError(error),
88
+ }),
89
+ )
90
+ })
91
+ return `${ANSI.color(`-------- errors (${errors.length}) --------`, ANSI.RED)}
92
+ ${output.join(`\n`)}
93
+ ${ANSI.color(`-------------------------`, ANSI.RED)}`
94
+ }
95
+
68
96
  export const createSummaryLog = (
69
97
  summary,
70
98
  ) => `-------------- summary -----------------
@@ -271,6 +299,7 @@ export const formatConsoleOutput = (consoleCalls) => {
271
299
  const textFormatted = prefixFirstAndIndentRemainingLines({
272
300
  prefix: CONSOLE_ICONS[regroupedCall.type],
273
301
  text,
302
+ trimLines: true,
274
303
  trimLastLine: index === regroupedCalls.length - 1,
275
304
  })
276
305
  consoleOutput += textFormatted
@@ -278,14 +307,19 @@ export const formatConsoleOutput = (consoleCalls) => {
278
307
  return consoleOutput
279
308
  }
280
309
 
281
- const prefixFirstAndIndentRemainingLines = ({ prefix, text, trimLastLine }) => {
310
+ const prefixFirstAndIndentRemainingLines = ({
311
+ prefix,
312
+ indentation = " ",
313
+ text,
314
+ trimLines,
315
+ trimLastLine,
316
+ }) => {
282
317
  const lines = text.split(/\r?\n/)
283
318
  const firstLine = lines.shift()
284
319
  let result = `${prefix} ${firstLine}`
285
320
  let i = 0
286
- const indentation = ` `
287
321
  while (i < lines.length) {
288
- const line = lines[i].trim()
322
+ const line = trimLines ? lines[i].trim() : lines[i]
289
323
  i++
290
324
  result += line.length
291
325
  ? `\n${indentation}${line}`
@@ -325,7 +359,12 @@ const formatConsoleSummary = (repartition) => {
325
359
  return `console (${parts.join(" ")})`
326
360
  }
327
361
 
328
- const formatExecution = ({ label, details = {}, consoleOutput }) => {
362
+ const formatExecution = ({
363
+ label,
364
+ details = {},
365
+ consoleOutput,
366
+ errorsOutput,
367
+ }) => {
329
368
  let message = ``
330
369
  message += label
331
370
  Object.keys(details).forEach((key) => {
@@ -333,8 +372,10 @@ const formatExecution = ({ label, details = {}, consoleOutput }) => {
333
372
  ${key}: ${details[key]}`
334
373
  })
335
374
  if (consoleOutput) {
336
- message += `
337
- ${consoleOutput}`
375
+ message += `\n${consoleOutput}`
376
+ }
377
+ if (errorsOutput) {
378
+ message += `\n${errorsOutput}`
338
379
  }
339
380
  return message
340
381
  }