@jsenv/core 34.2.2 → 35.0.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.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/dist/html/explorer.html +5 -4
  3. package/dist/{jsenv.js → jsenv_core.js} +840 -3914
  4. package/package.json +7 -21
  5. package/src/build/build.js +34 -16
  6. package/src/build/version_mappings_injection.js +20 -27
  7. package/src/dev/file_service.js +9 -9
  8. package/src/dev/start_dev_server.js +3 -3
  9. package/src/dev/user_agent.js +1 -1
  10. package/src/kitchen/kitchen.js +5 -3
  11. package/src/main.js +0 -23
  12. package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +2 -2
  13. package/src/plugins/importmap/jsenv_plugin_importmap.js +6 -2
  14. package/src/plugins/{inline/jsenv_plugin_html_inline_content.js → inline_content_analysis/jsenv_plugin_html_inline_content_analysis.js} +12 -6
  15. package/src/plugins/{inline/jsenv_plugin_inline.js → inline_content_analysis/jsenv_plugin_inline_content_analysis.js} +8 -10
  16. package/src/plugins/{inline/jsenv_plugin_js_inline_content.js → inline_content_analysis/jsenv_plugin_js_inline_content_analysis.js} +4 -2
  17. package/src/plugins/inlining/jsenv_plugin_inlining.js +22 -0
  18. package/src/plugins/{inline/jsenv_plugin_inline_query_param.js → inlining/jsenv_plugin_inlining_as_data_url.js} +16 -9
  19. package/src/plugins/inlining/jsenv_plugin_inlining_into_html.js +149 -0
  20. package/src/plugins/plugins.js +5 -2
  21. package/src/plugins/ribbon/jsenv_plugin_ribbon.js +11 -10
  22. package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +2 -2
  23. package/src/plugins/supervisor/html_supervisor_injection.js +23 -25
  24. package/src/plugins/supervisor/jsenv_plugin_supervisor.js +1 -1
  25. package/src/plugins/transpilation/babel/require_babel_plugin.js +1 -1
  26. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +20 -5
  27. package/src/plugins/transpilation/js_module_fallback/convert_js_module_to_js_classic.js +1 -1
  28. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js +2 -2
  29. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_on_workers.js +3 -3
  30. package/src/plugins/url_analysis/html/html_urls.js +1 -1
  31. package/dist/controllable_child_process.mjs +0 -129
  32. package/dist/controllable_worker_thread.mjs +0 -91
  33. package/dist/js/execute_using_dynamic_import.js +0 -850
  34. package/dist/js/v8_coverage.js +0 -508
  35. package/src/execute/execute.js +0 -109
  36. package/src/execute/run.js +0 -161
  37. package/src/execute/runtimes/browsers/chromium.js +0 -10
  38. package/src/execute/runtimes/browsers/firefox.js +0 -9
  39. package/src/execute/runtimes/browsers/from_playwright.js +0 -574
  40. package/src/execute/runtimes/browsers/middleware_istanbul.js +0 -65
  41. package/src/execute/runtimes/browsers/middleware_js_supervisor.js +0 -100
  42. package/src/execute/runtimes/browsers/webkit.js +0 -26
  43. package/src/execute/runtimes/node/child_exec_options.js +0 -166
  44. package/src/execute/runtimes/node/controllable_child_process.mjs +0 -135
  45. package/src/execute/runtimes/node/controllable_worker_thread.mjs +0 -103
  46. package/src/execute/runtimes/node/exec_options.js +0 -44
  47. package/src/execute/runtimes/node/execute_using_dynamic_import.js +0 -55
  48. package/src/execute/runtimes/node/exit_codes.js +0 -9
  49. package/src/execute/runtimes/node/kill_process_tree.js +0 -76
  50. package/src/execute/runtimes/node/node_child_process.js +0 -348
  51. package/src/execute/runtimes/node/node_execution_performance.js +0 -67
  52. package/src/execute/runtimes/node/node_worker_thread.js +0 -282
  53. package/src/execute/runtimes/node/profiler_v8_coverage.js +0 -56
  54. package/src/execute/runtimes/readme.md +0 -13
  55. package/src/execute/web_server_param.js +0 -74
  56. package/src/test/coverage/babel_plugin_instrument.js +0 -48
  57. package/src/test/coverage/coverage_reporter_html_directory.js +0 -32
  58. package/src/test/coverage/coverage_reporter_json_file.js +0 -17
  59. package/src/test/coverage/coverage_reporter_text_log.js +0 -19
  60. package/src/test/coverage/empty_coverage_factory.js +0 -52
  61. package/src/test/coverage/file_by_file_coverage.js +0 -25
  62. package/src/test/coverage/istanbul_coverage_composition.js +0 -28
  63. package/src/test/coverage/istanbul_coverage_map_from_coverage.js +0 -16
  64. package/src/test/coverage/list_files_not_covered.js +0 -15
  65. package/src/test/coverage/missing_coverage.js +0 -41
  66. package/src/test/coverage/report_to_coverage.js +0 -198
  67. package/src/test/coverage/v8_and_istanbul.js +0 -37
  68. package/src/test/coverage/v8_coverage.js +0 -26
  69. package/src/test/coverage/v8_coverage_composition.js +0 -24
  70. package/src/test/coverage/v8_coverage_node_directory.js +0 -85
  71. package/src/test/coverage/v8_coverage_to_istanbul.js +0 -99
  72. package/src/test/execute_steps.js +0 -425
  73. package/src/test/execute_test_plan.js +0 -372
  74. package/src/test/execution_colors.js +0 -10
  75. package/src/test/execution_steps.js +0 -65
  76. package/src/test/gc.js +0 -9
  77. package/src/test/logs_file_execution.js +0 -427
  78. package/src/test/logs_file_execution.test.mjs +0 -41
  79. package/src/test/readme.md +0 -3
  80. /package/src/{basic_fetch.js → helpers/basic_fetch.js} +0 -0
  81. /package/src/{lookup_package_directory.js → helpers/lookup_package_directory.js} +0 -0
  82. /package/src/{ping_server.js → helpers/ping_server.js} +0 -0
  83. /package/src/{require_from_jsenv.js → helpers/require_from_jsenv.js} +0 -0
  84. /package/src/{watch_source_files.js → helpers/watch_source_files.js} +0 -0
  85. /package/src/{web_url_converter.js → helpers/web_url_converter.js} +0 -0
  86. /package/src/plugins/{inline → inline_content_analysis}/client/inline_content.js +0 -0
  87. /package/src/plugins/{inline → inline_content_analysis}/jsenv_plugin_data_urls.js +0 -0
@@ -1,427 +0,0 @@
1
- import wrapAnsi from "wrap-ansi"
2
- import {
3
- ANSI,
4
- UNICODE,
5
- msAsEllapsedTime,
6
- msAsDuration,
7
- byteAsMemoryUsage,
8
- } from "@jsenv/log"
9
-
10
- import { EXECUTION_COLORS } from "./execution_colors.js"
11
-
12
- export const createExecutionLog = (
13
- {
14
- executionIndex,
15
- fileRelativeUrl,
16
- runtimeName,
17
- runtimeVersion,
18
- executionParams,
19
- executionResult,
20
- startMs,
21
- endMs,
22
- },
23
- {
24
- completedExecutionLogAbbreviation,
25
- counters,
26
- logRuntime,
27
- logEachDuration,
28
- timeEllapsed,
29
- memoryHeap,
30
- },
31
- ) => {
32
- const { status } = executionResult
33
- const descriptionFormatter = descriptionFormatters[status]
34
- const description = descriptionFormatter({
35
- index: executionIndex,
36
- total: counters.total,
37
- executionParams,
38
- })
39
- const summary = createIntermediateSummary({
40
- executionIndex,
41
- counters,
42
- timeEllapsed,
43
- memoryHeap,
44
- })
45
- let log
46
- if (completedExecutionLogAbbreviation && status === "completed") {
47
- log = `${description}${summary}`
48
- } else {
49
- const { consoleCalls = [], errors = [] } = executionResult
50
- const consoleOutput = formatConsoleCalls(consoleCalls)
51
- const errorsOutput = formatErrors(errors)
52
- log = formatExecution({
53
- label: `${description}${summary}`,
54
- details: {
55
- file: fileRelativeUrl,
56
- ...(logRuntime ? { runtime: `${runtimeName}/${runtimeVersion}` } : {}),
57
- ...(logEachDuration
58
- ? {
59
- duration:
60
- status === "executing"
61
- ? msAsEllapsedTime(Date.now() - startMs)
62
- : msAsDuration(endMs - startMs),
63
- }
64
- : {}),
65
- },
66
- consoleOutput,
67
- errorsOutput,
68
- })
69
- }
70
-
71
- const { columns = 80 } = process.stdout
72
- log = wrapAnsi(log, columns, {
73
- trim: false,
74
- hard: true,
75
- wordWrap: false,
76
- })
77
- if (endMs) {
78
- if (completedExecutionLogAbbreviation) {
79
- return `${log}\n`
80
- }
81
- if (executionIndex === counters.total - 1) {
82
- return `${log}\n`
83
- }
84
- return `${log}\n\n`
85
- }
86
- return log
87
- }
88
-
89
- const formatErrors = (errors) => {
90
- if (errors.length === 0) {
91
- return ""
92
- }
93
- const formatError = (error) => error.stack || error.message || error
94
-
95
- if (errors.length === 1) {
96
- return `${ANSI.color(`-------- error --------`, ANSI.RED)}
97
- ${formatError(errors[0])}
98
- ${ANSI.color(`-------------------------`, ANSI.RED)}`
99
- }
100
-
101
- let output = []
102
- errors.forEach((error) => {
103
- output.push(
104
- prefixFirstAndIndentRemainingLines({
105
- prefix: `${UNICODE.CIRCLE_CROSS} `,
106
- indentation: " ",
107
- text: formatError(error),
108
- }),
109
- )
110
- })
111
- return `${ANSI.color(`-------- errors (${errors.length}) --------`, ANSI.RED)}
112
- ${output.join(`\n`)}
113
- ${ANSI.color(`-------------------------`, ANSI.RED)}`
114
- }
115
-
116
- export const createSummaryLog = (
117
- summary,
118
- ) => `-------------- summary -----------------
119
- ${createAllExecutionsSummary(summary)}
120
- total duration: ${msAsDuration(summary.duration)}
121
- ----------------------------------------`
122
-
123
- const createAllExecutionsSummary = ({ counters }) => {
124
- if (counters.total === 0) {
125
- return `no execution`
126
- }
127
- const executionLabel =
128
- counters.total === 1 ? `1 execution` : `${counters.total} executions`
129
- return `${executionLabel}: ${createStatusSummary({
130
- counters,
131
- })}`
132
- }
133
-
134
- const createIntermediateSummary = ({
135
- executionIndex,
136
- counters,
137
- memoryHeap,
138
- timeEllapsed,
139
- }) => {
140
- const parts = []
141
- if (executionIndex > 0 || counters.done > 0) {
142
- parts.push(
143
- createStatusSummary({
144
- counters: {
145
- ...counters,
146
- total: executionIndex + 1,
147
- },
148
- }),
149
- )
150
- }
151
- if (timeEllapsed) {
152
- parts.push(`duration: ${msAsEllapsedTime(timeEllapsed)}`)
153
- }
154
- if (memoryHeap) {
155
- parts.push(`memory heap: ${byteAsMemoryUsage(memoryHeap)}`)
156
- }
157
- if (parts.length === 0) {
158
- return ""
159
- }
160
- return ` (${parts.join(` / `)})`
161
- }
162
-
163
- const createStatusSummary = ({ counters }) => {
164
- if (counters.aborted === counters.total) {
165
- return `all ${ANSI.color(`aborted`, EXECUTION_COLORS.aborted)}`
166
- }
167
- if (counters.timedout === counters.total) {
168
- return `all ${ANSI.color(`timed out`, EXECUTION_COLORS.timedout)}`
169
- }
170
- if (counters.failed === counters.total) {
171
- return `all ${ANSI.color(`failed`, EXECUTION_COLORS.failed)}`
172
- }
173
- if (counters.completed === counters.total) {
174
- return `all ${ANSI.color(`completed`, EXECUTION_COLORS.completed)}`
175
- }
176
- if (counters.cancelled === counters.total) {
177
- return `all ${ANSI.color(`cancelled`, EXECUTION_COLORS.cancelled)}`
178
- }
179
- return createMixedDetails({
180
- counters,
181
- })
182
- }
183
-
184
- const createMixedDetails = ({ counters }) => {
185
- const parts = []
186
- if (counters.timedout) {
187
- parts.push(
188
- `${counters.timedout} ${ANSI.color(
189
- `timed out`,
190
- EXECUTION_COLORS.timedout,
191
- )}`,
192
- )
193
- }
194
- if (counters.failed) {
195
- parts.push(
196
- `${counters.failed} ${ANSI.color(`failed`, EXECUTION_COLORS.failed)}`,
197
- )
198
- }
199
- if (counters.completed) {
200
- parts.push(
201
- `${counters.completed} ${ANSI.color(
202
- `completed`,
203
- EXECUTION_COLORS.completed,
204
- )}`,
205
- )
206
- }
207
- if (counters.aborted) {
208
- parts.push(
209
- `${counters.aborted} ${ANSI.color(`aborted`, EXECUTION_COLORS.aborted)}`,
210
- )
211
- }
212
- if (counters.cancelled) {
213
- parts.push(
214
- `${counters.cancelled} ${ANSI.color(
215
- `cancelled`,
216
- EXECUTION_COLORS.cancelled,
217
- )}`,
218
- )
219
- }
220
- return `${parts.join(", ")}`
221
- }
222
-
223
- const descriptionFormatters = {
224
- executing: ({ index, total }) => {
225
- return ANSI.color(
226
- `executing ${padNumber(index, total)} of ${total}`,
227
- EXECUTION_COLORS.executing,
228
- )
229
- },
230
- aborted: ({ index, total }) => {
231
- return ANSI.color(
232
- `${UNICODE.FAILURE_RAW} execution ${padNumber(
233
- index,
234
- total,
235
- )} of ${total} aborted`,
236
- EXECUTION_COLORS.aborted,
237
- )
238
- },
239
- timedout: ({ index, total, executionParams }) => {
240
- return ANSI.color(
241
- `${UNICODE.FAILURE_RAW} execution ${padNumber(
242
- index,
243
- total,
244
- )} of ${total} timeout after ${executionParams.allocatedMs}ms`,
245
- EXECUTION_COLORS.timedout,
246
- )
247
- },
248
- failed: ({ index, total }) => {
249
- return ANSI.color(
250
- `${UNICODE.FAILURE_RAW} execution ${padNumber(
251
- index,
252
- total,
253
- )} of ${total} failed`,
254
- EXECUTION_COLORS.failed,
255
- )
256
- },
257
- completed: ({ index, total }) => {
258
- return ANSI.color(
259
- `${UNICODE.OK_RAW} execution ${padNumber(
260
- index,
261
- total,
262
- )} of ${total} completed`,
263
- EXECUTION_COLORS.completed,
264
- )
265
- },
266
- cancelled: ({ index, total }) => {
267
- return ANSI.color(
268
- `${UNICODE.FAILURE_RAW} execution ${padNumber(
269
- index,
270
- total,
271
- )} of ${total} cancelled`,
272
- EXECUTION_COLORS.cancelled,
273
- )
274
- },
275
- }
276
-
277
- const padNumber = (index, total) => {
278
- const number = index + 1
279
- const numberWidth = String(number).length
280
- const totalWith = String(total).length
281
- let missingWidth = totalWith - numberWidth
282
- let padded = ""
283
- while (missingWidth--) {
284
- padded += "0"
285
- }
286
- padded += number
287
- return padded
288
- }
289
-
290
- const formatConsoleCalls = (consoleCalls) => {
291
- if (consoleCalls.length === 0) {
292
- return ""
293
- }
294
- const repartition = {
295
- debug: 0,
296
- info: 0,
297
- warning: 0,
298
- error: 0,
299
- log: 0,
300
- }
301
- consoleCalls.forEach((consoleCall) => {
302
- repartition[consoleCall.type]++
303
- })
304
- const consoleOutput = formatConsoleOutput(consoleCalls)
305
-
306
- return `${ANSI.color(
307
- `-------- ${formatConsoleSummary(repartition)} --------`,
308
- ANSI.GREY,
309
- )}
310
- ${consoleOutput}
311
- ${ANSI.color(`-------------------------`, ANSI.GREY)}`
312
- }
313
-
314
- export const formatConsoleOutput = (consoleCalls) => {
315
- // inside Node.js you can do process.stdout.write()
316
- // and in that case the consoleCall is not suffixed with "\n"
317
- // we want to keep these calls together in the output
318
- const regroupedCalls = []
319
- consoleCalls.forEach((consoleCall, index) => {
320
- if (index === 0) {
321
- regroupedCalls.push(consoleCall)
322
- return
323
- }
324
- const previousCall = consoleCalls[index - 1]
325
- if (previousCall.type !== consoleCall.type) {
326
- regroupedCalls.push(consoleCall)
327
- return
328
- }
329
- if (previousCall.text.endsWith("\n")) {
330
- regroupedCalls.push(consoleCall)
331
- return
332
- }
333
- if (previousCall.text.endsWith("\r")) {
334
- regroupedCalls.push(consoleCall)
335
- return
336
- }
337
- const previousRegroupedCallIndex = regroupedCalls.length - 1
338
- const previousRegroupedCall = regroupedCalls[previousRegroupedCallIndex]
339
- previousRegroupedCall.text = `${previousRegroupedCall.text}${consoleCall.text}`
340
- })
341
-
342
- let consoleOutput = ``
343
- regroupedCalls.forEach((regroupedCall, index) => {
344
- const text = regroupedCall.text
345
- const textFormatted = prefixFirstAndIndentRemainingLines({
346
- prefix: CONSOLE_ICONS[regroupedCall.type],
347
- text,
348
- trimLines: true,
349
- trimLastLine: index === regroupedCalls.length - 1,
350
- })
351
- consoleOutput += textFormatted
352
- })
353
- return consoleOutput
354
- }
355
-
356
- const prefixFirstAndIndentRemainingLines = ({
357
- prefix,
358
- indentation = " ",
359
- text,
360
- trimLines,
361
- trimLastLine,
362
- }) => {
363
- const lines = text.split(/\r?\n/)
364
- const firstLine = lines.shift()
365
- let result = `${prefix} ${firstLine}`
366
- let i = 0
367
- while (i < lines.length) {
368
- const line = trimLines ? lines[i].trim() : lines[i]
369
- i++
370
- result += line.length
371
- ? `\n${indentation}${line}`
372
- : trimLastLine && i === lines.length
373
- ? ""
374
- : `\n`
375
- }
376
- return result
377
- }
378
-
379
- const CONSOLE_ICONS = {
380
- debug: UNICODE.DEBUG,
381
- info: UNICODE.INFO,
382
- warning: UNICODE.WARNING,
383
- error: UNICODE.FAILURE,
384
- log: " ",
385
- }
386
-
387
- const formatConsoleSummary = (repartition) => {
388
- const { debug, info, warning, error } = repartition
389
- const parts = []
390
- if (error) {
391
- parts.push(`${CONSOLE_ICONS.error} ${error}`)
392
- }
393
- if (warning) {
394
- parts.push(`${CONSOLE_ICONS.warning} ${warning}`)
395
- }
396
- if (info) {
397
- parts.push(`${CONSOLE_ICONS.info} ${info}`)
398
- }
399
- if (debug) {
400
- parts.push(`${CONSOLE_ICONS.debug} ${debug}`)
401
- }
402
- if (parts.length === 0) {
403
- return `console`
404
- }
405
- return `console (${parts.join(" ")})`
406
- }
407
-
408
- const formatExecution = ({
409
- label,
410
- details = {},
411
- consoleOutput,
412
- errorsOutput,
413
- }) => {
414
- let message = ``
415
- message += label
416
- Object.keys(details).forEach((key) => {
417
- message += `
418
- ${key}: ${details[key]}`
419
- })
420
- if (consoleOutput) {
421
- message += `\n${consoleOutput}`
422
- }
423
- if (errorsOutput) {
424
- message += `\n${errorsOutput}`
425
- }
426
- return message
427
- }
@@ -1,41 +0,0 @@
1
- import { assert } from "@jsenv/assert"
2
-
3
- import { formatConsoleOutput } from "./logs_file_execution.js"
4
-
5
- {
6
- const actual = formatConsoleOutput([
7
- { type: "log", text: "a\n" },
8
- { type: "log", text: "b\n" },
9
- ])
10
- const expected = ` a
11
- b`
12
- assert({ actual, expected })
13
- }
14
-
15
- {
16
- const actual = formatConsoleOutput([
17
- { type: "log", text: "a" },
18
- { type: "log", text: "b" },
19
- ])
20
- const expected = ` ab`
21
- assert({ actual, expected })
22
- }
23
-
24
- {
25
- const actual = formatConsoleOutput([
26
- {
27
- type: "log",
28
- text: `1
29
- 2`,
30
- },
31
- {
32
- type: "log",
33
- text: `alpha
34
- beta`,
35
- },
36
- ])
37
- const expected = ` 1
38
- 2alpha
39
- beta`
40
- assert({ actual, expected })
41
- }
@@ -1,3 +0,0 @@
1
- # test/
2
-
3
- Code implementing "executeTestPlan" can be found here
File without changes
File without changes