@jsenv/core 27.0.0-alpha.8 → 27.0.0-alpha.82

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 (254) hide show
  1. package/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +95 -0
  2. package/dist/babel_helpers/AwaitValue/AwaitValue.js +3 -0
  3. package/dist/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +29 -0
  4. package/dist/babel_helpers/applyDecs/applyDecs.js +756 -0
  5. package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +9 -0
  6. package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +4 -0
  7. package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +5 -0
  8. package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +8 -0
  9. package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +52 -0
  10. package/dist/babel_helpers/asyncIterator/asyncIterator.js +78 -0
  11. package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +39 -0
  12. package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +4 -0
  13. package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +24 -0
  14. package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +7 -0
  15. package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +14 -0
  16. package/dist/babel_helpers/classCallCheck/classCallCheck.js +5 -0
  17. package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -0
  18. package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -0
  19. package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +8 -0
  20. package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +4 -0
  21. package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -0
  22. package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -0
  23. package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +7 -0
  24. package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -0
  25. package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -0
  26. package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +7 -0
  27. package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +3 -0
  28. package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -0
  29. package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +9 -0
  30. package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -0
  31. package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -0
  32. package/dist/babel_helpers/construct/construct.js +15 -0
  33. package/dist/babel_helpers/createClass/createClass.js +18 -0
  34. package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +63 -0
  35. package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +22 -0
  36. package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +50 -0
  37. package/dist/babel_helpers/createSuper/createSuper.js +22 -0
  38. package/dist/babel_helpers/decorate/decorate.js +622 -0
  39. package/dist/babel_helpers/defaults/defaults.js +14 -0
  40. package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +26 -0
  41. package/dist/babel_helpers/defineProperty/defineProperty.js +19 -0
  42. package/dist/babel_helpers/extends/extends.js +16 -0
  43. package/dist/babel_helpers/get/get.js +21 -0
  44. package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -0
  45. package/dist/babel_helpers/identity/identity.js +3 -0
  46. package/dist/babel_helpers/inherits/inherits.js +21 -0
  47. package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +6 -0
  48. package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +10 -0
  49. package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +3 -0
  50. package/dist/babel_helpers/instanceof/instanceof.js +7 -0
  51. package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +5 -0
  52. package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +49 -0
  53. package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +4 -0
  54. package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -0
  55. package/dist/babel_helpers/iterableToArray/iterableToArray.js +3 -0
  56. package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +38 -0
  57. package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +13 -0
  58. package/dist/babel_helpers/jsx/jsx.js +49 -0
  59. package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +10 -0
  60. package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +5 -0
  61. package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +3 -0
  62. package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +3 -0
  63. package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -0
  64. package/dist/babel_helpers/objectSpread/objectSpread.js +22 -0
  65. package/dist/babel_helpers/objectSpread2/objectSpread2.js +41 -0
  66. package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +20 -0
  67. package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +15 -0
  68. package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +10 -0
  69. package/dist/babel_helpers/readOnlyError/readOnlyError.js +4 -0
  70. package/dist/babel_helpers/set/set.js +51 -0
  71. package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +5 -0
  72. package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -0
  73. package/dist/babel_helpers/slicedToArray/slicedToArray.js +5 -0
  74. package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +7 -0
  75. package/dist/babel_helpers/superPropBase/superPropBase.js +10 -0
  76. package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +11 -0
  77. package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +8 -0
  78. package/dist/babel_helpers/tdz/tdz.js +4 -0
  79. package/dist/babel_helpers/temporalRef/temporalRef.js +5 -0
  80. package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +3 -0
  81. package/dist/babel_helpers/toArray/toArray.js +5 -0
  82. package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +5 -0
  83. package/dist/babel_helpers/toPrimitive/toPrimitive.js +14 -0
  84. package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +5 -0
  85. package/dist/babel_helpers/typeof/typeof.js +7 -0
  86. package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -0
  87. package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +7 -0
  88. package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +35 -0
  89. package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +67 -0
  90. package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +4 -0
  91. package/dist/html/explorer.html +557 -0
  92. package/dist/js/controllable_file.mjs +227 -0
  93. package/dist/js/event_source_client.js +324 -0
  94. package/dist/js/global_this.js +32 -0
  95. package/dist/js/html_supervisor_installer.js +522 -0
  96. package/dist/js/html_supervisor_setup.js +82 -0
  97. package/dist/js/import_meta_hot.js +84 -0
  98. package/dist/js/inline_content.js +8 -0
  99. package/dist/js/new_stylesheet.js +409 -0
  100. package/dist/js/regenerator_runtime.js +721 -0
  101. package/dist/js/s.js +429 -0
  102. package/dist/main.js +13422 -0
  103. package/dist/other/jsenv.png +0 -0
  104. package/dist/s.js +626 -0
  105. package/dist/s.js.map +204 -0
  106. package/package.json +57 -51
  107. package/readme.md +6 -14
  108. package/src/build/build.js +1074 -563
  109. package/src/build/build_urls_generator.js +65 -24
  110. package/src/build/graph_utils.js +31 -0
  111. package/src/build/{inject_version_mappings.js → inject_global_version_mappings.js} +49 -18
  112. package/src/build/inject_service_worker_urls.js +79 -0
  113. package/src/build/resync_ressource_hints.js +115 -0
  114. package/src/build/start_build_server.js +210 -0
  115. package/src/dev/plugins/explorer/client/explorer.html +1 -1
  116. package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +9 -13
  117. package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +3 -1
  118. package/src/dev/start_dev_server.js +165 -38
  119. package/src/execute/execute.js +35 -8
  120. package/src/execute/run.js +21 -57
  121. package/src/execute/runtimes/browsers/from_playwright.js +220 -150
  122. package/src/execute/runtimes/node/child_exec_options.js +1 -1
  123. package/src/execute/runtimes/node/controllable_file.mjs +26 -10
  124. package/src/execute/runtimes/node/kill_process_tree.js +2 -4
  125. package/src/execute/runtimes/node/node_execution_performance.js +67 -0
  126. package/src/execute/runtimes/node/node_process.js +288 -39
  127. package/src/main.js +27 -0
  128. package/src/omega/{runtime_support/features_compatibility.js → compat/features_compats.js} +30 -7
  129. package/src/omega/{runtime_support/runtime_support.js → compat/runtime_compat.js} +14 -16
  130. package/src/omega/errors.js +63 -67
  131. package/src/omega/fetched_content_compliance.js +24 -0
  132. package/src/omega/file_url_converter.js +9 -51
  133. package/src/omega/kitchen.js +605 -467
  134. package/src/omega/omega_server.js +2 -3
  135. package/src/omega/server/file_service.js +88 -41
  136. package/src/omega/server/user_agent.js +5 -6
  137. package/src/omega/url_graph/url_graph_load.js +31 -23
  138. package/src/omega/url_graph/url_graph_report.js +94 -51
  139. package/src/omega/url_graph/url_info_transformations.js +37 -17
  140. package/src/omega/url_graph.js +88 -19
  141. package/src/omega/url_specifier_encoding.js +59 -0
  142. package/src/omega/web_workers.js +42 -0
  143. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/autoreload_preference.js +0 -0
  144. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/event_source_client.js +19 -12
  145. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/reload.js +0 -0
  146. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/url_helpers.js +0 -0
  147. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +41 -0
  148. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +204 -0
  149. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +25 -0
  150. package/src/plugins/autoreload/jsenv_plugin_hmr.js +35 -0
  151. package/src/plugins/bundling/css/bundle_css.js +140 -0
  152. package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +13 -0
  153. package/src/plugins/bundling/js_module/bundle_js_module.js +343 -0
  154. package/src/plugins/bundling/jsenv_plugin_bundling.js +54 -0
  155. package/src/plugins/cache_control/jsenv_plugin_cache_control.js +34 -0
  156. package/src/{omega/core_plugins → plugins}/commonjs_globals/jsenv_plugin_commonjs_globals.js +54 -41
  157. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +183 -0
  158. package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_document.js +0 -0
  159. package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_notification.js +0 -0
  160. package/src/plugins/html_supervisor/client/html_supervisor_installer.js +254 -0
  161. package/src/plugins/html_supervisor/client/html_supervisor_setup.js +82 -0
  162. package/src/{omega/core_plugins → plugins}/html_supervisor/client/perf_browser.js +0 -0
  163. package/src/{omega/core_plugins → plugins}/html_supervisor/client/uneval_exception.js +0 -0
  164. package/src/{omega/core_plugins → plugins}/html_supervisor/jsenv_plugin_html_supervisor.js +73 -55
  165. package/src/plugins/http_urls/jsenv_plugin_http_urls.js +12 -0
  166. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/babel_plugin_metadata_import_meta_hot.js +4 -5
  167. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/client/import_meta_hot.js +3 -1
  168. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/html_hot_dependencies.js +7 -4
  169. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +100 -0
  170. package/src/{omega/core_plugins → plugins}/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +33 -8
  171. package/src/plugins/import_meta_url/client/import_meta_url_browser.js +52 -0
  172. package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +9 -0
  173. package/src/{omega/core_plugins → plugins}/importmap/jsenv_plugin_importmap.js +40 -36
  174. package/src/plugins/inject_globals/inject_globals.js +57 -0
  175. package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +24 -0
  176. package/src/{omega/core_plugins → plugins}/inline/client/inline_content.js +0 -0
  177. package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_data_urls.js +22 -21
  178. package/src/plugins/inline/jsenv_plugin_html_inline_content.js +161 -0
  179. package/src/plugins/inline/jsenv_plugin_inline.js +36 -0
  180. package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_inline_query_param.js +8 -11
  181. package/src/plugins/inline/jsenv_plugin_js_inline_content.js +294 -0
  182. package/src/plugins/leading_slash/jsenv_plugin_leading_slash.js +13 -0
  183. package/src/plugins/minification/css/minify_css.js +9 -0
  184. package/src/plugins/minification/html/minify_html.js +13 -0
  185. package/src/{build/plugins/minify_js/jsenv_plugin_minify_js.js → plugins/minification/js/minify_js.js} +6 -22
  186. package/src/plugins/minification/jsenv_plugin_minification.js +78 -0
  187. package/src/plugins/minification/json/minify_json.js +8 -0
  188. package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +162 -0
  189. package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +12 -0
  190. package/src/{omega → plugins}/plugin_controller.js +57 -12
  191. package/src/plugins/plugins.js +89 -0
  192. package/src/plugins/transpilation/as_js_classic/client/s.js +429 -0
  193. package/src/plugins/transpilation/as_js_classic/helpers/babel_plugin_transform_import_meta_url.js +47 -0
  194. package/src/plugins/transpilation/as_js_classic/helpers/systemjs_old.js +43 -0
  195. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +211 -0
  196. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +304 -0
  197. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_workers.js +55 -0
  198. package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +0 -0
  199. package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/client/global_this.js +0 -0
  200. package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +0 -0
  201. package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugin_structure.js +14 -17
  202. package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugins_compatibility.js +0 -0
  203. package/src/{omega/core_plugins → plugins/transpilation}/babel/jsenv_plugin_babel.js +39 -32
  204. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +30 -6
  205. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/new_stylesheet.js +0 -0
  206. package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -0
  207. package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/client/regenerator_runtime.js +0 -0
  208. package/src/plugins/transpilation/babel/require_babel_plugin.js +8 -0
  209. package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +18 -0
  210. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +184 -0
  211. package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +79 -0
  212. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +46 -0
  213. package/src/plugins/url_analysis/css/css_urls.js +49 -0
  214. package/src/plugins/url_analysis/html/html_urls.js +272 -0
  215. package/src/plugins/url_analysis/js/js_urls.js +68 -0
  216. package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +103 -0
  217. package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +20 -0
  218. package/src/{omega/core_plugins → plugins}/url_resolution/jsenv_plugin_url_resolution.js +9 -5
  219. package/src/plugins/url_version/jsenv_plugin_url_version.js +28 -0
  220. package/src/require_from_jsenv.js +3 -0
  221. package/src/test/execute_plan.js +85 -44
  222. package/src/test/execute_test_plan.js +37 -25
  223. package/src/test/execution_steps.js +2 -5
  224. package/src/test/logs_file_execution.js +56 -49
  225. package/main.js +0 -19
  226. package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +0 -227
  227. package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +0 -30
  228. package/src/dev/plugins/autoreload/client/event_source_connection.js +0 -195
  229. package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +0 -374
  230. package/src/dev/plugins/autoreload/sse_service.js +0 -149
  231. package/src/execute/runtimes/node/controlled_process.js +0 -316
  232. package/src/omega/core_plugins/babel/new_stylesheet/client/.eslintrc.cjs +0 -24
  233. package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +0 -67
  234. package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +0 -58
  235. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +0 -168
  236. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +0 -77
  237. package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +0 -98
  238. package/src/omega/core_plugins/import_assertions/helpers/json_module.js +0 -12
  239. package/src/omega/core_plugins/import_assertions/helpers/text_module.js +0 -6
  240. package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +0 -211
  241. package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +0 -13
  242. package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +0 -142
  243. package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +0 -207
  244. package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +0 -12
  245. package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +0 -77
  246. package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +0 -50
  247. package/src/omega/core_plugins.js +0 -39
  248. package/src/omega/runtime_support/default_runtime_support.js +0 -13
  249. package/src/omega/url_graph/url_graph_sort.js +0 -29
  250. package/src/omega/url_mentions/css_url_mentions.js +0 -63
  251. package/src/omega/url_mentions/html_url_mentions.js +0 -185
  252. package/src/omega/url_mentions/js_module_url_mentions.js +0 -91
  253. package/src/omega/url_mentions/parse_url_mentions.js +0 -37
  254. package/src/omega/url_mentions/worker_classic_url_mentions.js +0 -37
@@ -1,4 +1,22 @@
1
- import { createControlledProcess } from "./controlled_process.js"
1
+ import { fork } from "node:child_process"
2
+ import {
3
+ Abort,
4
+ raceCallbacks,
5
+ createCallbackListNotifiedOnce,
6
+ } from "@jsenv/abort"
7
+ import { uneval } from "@jsenv/uneval"
8
+
9
+ import { urlToFileSystemPath } from "@jsenv/urls"
10
+ import { createDetailedMessage } from "@jsenv/log"
11
+ import { memoize } from "@jsenv/utils/memoize/memoize.js"
12
+ import { createChildExecOptions } from "./child_exec_options.js"
13
+ import { ExecOptions } from "./exec_options.js"
14
+ import { killProcessTree } from "./kill_process_tree.js"
15
+
16
+ const NODE_CONTROLLABLE_FILE_URL = new URL(
17
+ "./controllable_file.mjs",
18
+ import.meta.url,
19
+ ).href
2
20
 
3
21
  export const nodeProcess = {
4
22
  name: "node",
@@ -8,33 +26,32 @@ export const nodeProcess = {
8
26
  nodeProcess.run = async ({
9
27
  signal = new AbortController().signal,
10
28
  logger,
11
- logProcessCommand,
29
+ logProcessCommand = false,
12
30
  rootDirectoryUrl,
13
31
  fileRelativeUrl,
14
32
 
15
33
  keepRunning,
16
34
  gracefulStopAllocatedMs = 4000,
17
35
  stopSignal,
18
- onStop,
19
- onError,
20
36
  onConsole,
21
- onResult,
22
37
 
23
- measurePerformance,
24
- collectPerformance,
25
38
  collectCoverage = false,
26
39
  coverageForceIstanbul,
40
+ collectPerformance,
27
41
 
28
42
  debugPort,
29
43
  debugMode,
30
44
  debugModeInheritBreak,
31
45
  env,
32
- inheritProcessEnv,
46
+ inheritProcessEnv = true,
33
47
  commandLineOptions = [],
34
- stdin,
35
- stdout,
36
- stderr,
48
+ stdin = "pipe",
49
+ stdout = "pipe",
50
+ stderr = "pipe",
37
51
  }) => {
52
+ if (env !== undefined && typeof env !== "object") {
53
+ throw new TypeError(`env must be an object, got ${env}`)
54
+ }
38
55
  env = {
39
56
  ...env,
40
57
  COVERAGE_ENABLED: collectCoverage,
@@ -49,44 +66,276 @@ nodeProcess.run = async ({
49
66
  "--experimental-import-meta-resolve",
50
67
  ...commandLineOptions,
51
68
  ]
52
- const { stop, requestActionOnChildProcess } = await createControlledProcess({
69
+
70
+ const cleanupCallbackList = createCallbackListNotifiedOnce()
71
+ const cleanup = async (reason) => {
72
+ await cleanupCallbackList.notify({ reason })
73
+ }
74
+
75
+ const childExecOptions = await createChildExecOptions({
53
76
  signal,
54
- logger,
55
77
  debugPort,
56
78
  debugMode,
57
79
  debugModeInheritBreak,
58
- env,
59
- inheritProcessEnv,
60
- commandLineOptions,
61
- stdin,
62
- stdout,
63
- stderr,
64
- logProcessCommand,
65
-
66
- stopSignal,
67
- onStop,
68
- onError,
69
- onConsole,
70
80
  })
71
- const namespace = await requestActionOnChildProcess({
72
- signal,
73
- actionType: "execute-using-dynamic-import",
74
- actionParams: {
75
- fileUrl: new URL(fileRelativeUrl, rootDirectoryUrl).href,
76
- measurePerformance,
77
- collectPerformance,
78
- collectCoverage,
81
+ const execArgv = ExecOptions.toExecArgv({
82
+ ...childExecOptions,
83
+ ...ExecOptions.fromExecArgv(commandLineOptions),
84
+ })
85
+ const envForChildProcess = {
86
+ ...(inheritProcessEnv ? process.env : {}),
87
+ ...env,
88
+ }
89
+ logger[logProcessCommand ? "info" : "debug"](
90
+ `${process.argv[0]} ${execArgv.join(" ")} ${urlToFileSystemPath(
91
+ NODE_CONTROLLABLE_FILE_URL,
92
+ )}`,
93
+ )
94
+ const childProcess = fork(urlToFileSystemPath(NODE_CONTROLLABLE_FILE_URL), {
95
+ execArgv,
96
+ // silent: true
97
+ stdio: ["pipe", "pipe", "pipe", "ipc"],
98
+ env: envForChildProcess,
99
+ })
100
+ logger.debug(
101
+ createDetailedMessage(`child process forked (pid ${childProcess.pid})`, {
102
+ "execArgv": execArgv.join(`\n`),
103
+ "custom env": JSON.stringify(env, null, " "),
104
+ }),
105
+ )
106
+ // if we pass stream, pipe them https://github.com/sindresorhus/execa/issues/81
107
+ if (typeof stdin === "object") {
108
+ stdin.pipe(childProcess.stdin)
109
+ }
110
+ if (typeof stdout === "object") {
111
+ childProcess.stdout.pipe(stdout)
112
+ }
113
+ if (typeof stderr === "object") {
114
+ childProcess.stderr.pipe(stderr)
115
+ }
116
+ const childProcessReadyPromise = new Promise((resolve) => {
117
+ onceProcessMessage(childProcess, "ready", resolve)
118
+ })
119
+ const removeOutputListener = installProcessOutputListener(
120
+ childProcess,
121
+ ({ type, text }) => {
122
+ onConsole({ type, text })
79
123
  },
124
+ )
125
+ const stop = memoize(async ({ gracefulStopAllocatedMs } = {}) => {
126
+ // all libraries are facing problem on windows when trying
127
+ // to kill a process spawning other processes.
128
+ // "killProcessTree" is theorically correct but sometimes keep process handing forever.
129
+ // Inside GitHub workflow the whole Virtual machine gets unresponsive and ends up being killed
130
+ // There is no satisfying solution to this problem so we stick to the basic
131
+ // childProcess.kill()
132
+ if (process.platform === "win32") {
133
+ childProcess.kill()
134
+ return
135
+ }
136
+ if (gracefulStopAllocatedMs) {
137
+ try {
138
+ await killProcessTree(childProcess.pid, {
139
+ signal: GRACEFUL_STOP_SIGNAL,
140
+ timeout: gracefulStopAllocatedMs,
141
+ })
142
+ return
143
+ } catch (e) {
144
+ if (e.code === "TIMEOUT") {
145
+ logger.debug(
146
+ `kill with SIGTERM because gracefulStop still pending after ${gracefulStopAllocatedMs}ms`,
147
+ )
148
+ await killProcessTree(childProcess.pid, {
149
+ signal: GRACEFUL_STOP_FAILED_SIGNAL,
150
+ })
151
+ return
152
+ }
153
+ throw e
154
+ }
155
+ }
156
+ await killProcessTree(childProcess.pid, { signal: STOP_SIGNAL })
157
+ return
80
158
  })
81
- onResult({
82
- status: "completed",
83
- namespace,
159
+
160
+ const actionOperation = Abort.startOperation()
161
+ actionOperation.addAbortSignal(signal)
162
+ const winnerPromise = new Promise((resolve) => {
163
+ raceCallbacks(
164
+ {
165
+ aborted: (cb) => {
166
+ return actionOperation.addAbortCallback(cb)
167
+ },
168
+ // https://nodejs.org/api/child_process.html#child_process_event_disconnect
169
+ // disconnect: (cb) => {
170
+ // return onceProcessEvent(childProcess, "disconnect", cb)
171
+ // },
172
+ // https://nodejs.org/api/child_process.html#child_process_event_error
173
+ error: (cb) => {
174
+ return onceProcessEvent(childProcess, "error", cb)
175
+ },
176
+ exit: (cb) => {
177
+ return onceProcessEvent(childProcess, "exit", (code, signal) => {
178
+ cb({ code, signal })
179
+ })
180
+ },
181
+ response: (cb) => {
182
+ onceProcessMessage(childProcess, "action-result", cb)
183
+ },
184
+ },
185
+ resolve,
186
+ )
84
187
  })
188
+ const getResult = async () => {
189
+ actionOperation.throwIfAborted()
190
+ await childProcessReadyPromise
191
+ actionOperation.throwIfAborted()
192
+ await sendToProcess(childProcess, "action", {
193
+ actionType: "execute-using-dynamic-import",
194
+ actionParams: {
195
+ fileUrl: new URL(fileRelativeUrl, rootDirectoryUrl).href,
196
+ collectPerformance,
197
+ },
198
+ })
199
+ const winner = await winnerPromise
200
+ if (winner.name === "aborted") {
201
+ return {
202
+ status: "aborted",
203
+ }
204
+ }
205
+ if (winner.name === "error") {
206
+ const error = winner.data
207
+ removeOutputListener()
208
+ return {
209
+ status: "errored",
210
+ error,
211
+ }
212
+ }
213
+ if (winner.name === "exit") {
214
+ const { code } = winner.data
215
+ await cleanup("process exit")
216
+ if (code === 12) {
217
+ return {
218
+ status: "errored",
219
+ error: new Error(
220
+ `node process exited with 12 (the forked child process wanted to use a non-available port for debug)`,
221
+ ),
222
+ }
223
+ }
224
+ if (
225
+ code === null ||
226
+ code === 0 ||
227
+ code === SIGINT_EXIT_CODE ||
228
+ code === SIGTERM_EXIT_CODE ||
229
+ code === SIGABORT_EXIT_CODE
230
+ ) {
231
+ return {
232
+ status: "errored",
233
+ error: new Error(`node process exited during execution`),
234
+ }
235
+ }
236
+ // process.exit(1) in child process or process.exitCode = 1 + process.exit()
237
+ // means there was an error even if we don't know exactly what.
238
+ return {
239
+ status: "errored",
240
+ error: new Error(
241
+ `node process exited with code ${code} during execution`,
242
+ ),
243
+ }
244
+ }
245
+ const { status, value } = winner.data
246
+ if (status === "action-failed") {
247
+ return {
248
+ status: "errored",
249
+ error: value,
250
+ }
251
+ }
252
+ return {
253
+ status: "completed",
254
+ ...value,
255
+ }
256
+ }
257
+
258
+ let result
259
+ try {
260
+ result = await getResult()
261
+ } catch (e) {
262
+ result = {
263
+ status: "errored",
264
+ error: e,
265
+ }
266
+ }
85
267
  if (keepRunning) {
86
268
  stopSignal.notify = stop
87
- return
269
+ } else {
270
+ await stop({
271
+ gracefulStopAllocatedMs,
272
+ })
88
273
  }
89
- await stop({
90
- gracefulStopAllocatedMs,
274
+ await actionOperation.end()
275
+ return result
276
+ }
277
+
278
+ // https://nodejs.org/api/process.html#process_signal_events
279
+ const SIGINT_SIGNAL_NUMBER = 2
280
+ const SIGABORT_SIGNAL_NUMBER = 6
281
+ const SIGTERM_SIGNAL_NUMBER = 15
282
+ const SIGINT_EXIT_CODE = 128 + SIGINT_SIGNAL_NUMBER
283
+ const SIGABORT_EXIT_CODE = 128 + SIGABORT_SIGNAL_NUMBER
284
+ const SIGTERM_EXIT_CODE = 128 + SIGTERM_SIGNAL_NUMBER
285
+ // http://man7.org/linux/man-pages/man7/signal.7.html
286
+ // https:// github.com/nodejs/node/blob/1d9511127c419ec116b3ddf5fc7a59e8f0f1c1e4/lib/internal/child_process.js#L472
287
+ const GRACEFUL_STOP_SIGNAL = "SIGTERM"
288
+ const STOP_SIGNAL = "SIGKILL"
289
+ // it would be more correct if GRACEFUL_STOP_FAILED_SIGNAL was SIGHUP instead of SIGKILL.
290
+ // but I'm not sure and it changes nothing so just use SIGKILL
291
+ const GRACEFUL_STOP_FAILED_SIGNAL = "SIGKILL"
292
+
293
+ const sendToProcess = async (childProcess, type, data) => {
294
+ const source = uneval(data, { functionAllowed: true })
295
+ return new Promise((resolve, reject) => {
296
+ childProcess.send({ type, data: source }, (error) => {
297
+ if (error) {
298
+ reject(error)
299
+ } else {
300
+ resolve()
301
+ }
302
+ })
91
303
  })
92
304
  }
305
+
306
+ const installProcessOutputListener = (childProcess, callback) => {
307
+ // beware that we may receive ansi output here, should not be a problem but keep that in mind
308
+ const stdoutDataCallback = (chunk) => {
309
+ callback({ type: "log", text: String(chunk) })
310
+ }
311
+ childProcess.stdout.on("data", stdoutDataCallback)
312
+ const stdErrorDataCallback = (chunk) => {
313
+ callback({ type: "error", text: String(chunk) })
314
+ }
315
+ childProcess.stderr.on("data", stdErrorDataCallback)
316
+ return () => {
317
+ childProcess.stdout.removeListener("data", stdoutDataCallback)
318
+ childProcess.stderr.removeListener("data", stdoutDataCallback)
319
+ }
320
+ }
321
+
322
+ const onceProcessMessage = (childProcess, type, callback) => {
323
+ const onmessage = (message) => {
324
+ if (message.type === type) {
325
+ childProcess.removeListener("message", onmessage)
326
+ // eslint-disable-next-line no-eval
327
+ callback(message.data ? eval(`(${message.data})`) : "")
328
+ }
329
+ }
330
+ childProcess.on("message", onmessage)
331
+ return () => {
332
+ childProcess.removeListener("message", onmessage)
333
+ }
334
+ }
335
+
336
+ const onceProcessEvent = (childProcess, type, callback) => {
337
+ childProcess.once(type, callback)
338
+ return () => {
339
+ childProcess.removeListener(type, callback)
340
+ }
341
+ }
package/src/main.js ADDED
@@ -0,0 +1,27 @@
1
+ // dev
2
+ export { startDevServer } from "./dev/start_dev_server.js"
3
+ // test
4
+ export {
5
+ executeTestPlan,
6
+ defaultCoverageConfig,
7
+ } from "./test/execute_test_plan.js"
8
+ export {
9
+ chromium,
10
+ chromiumIsolatedTab,
11
+ } from "./execute/runtimes/browsers/chromium.js"
12
+ export {
13
+ firefox,
14
+ firefoxIsolatedTab,
15
+ } from "./execute/runtimes/browsers/firefox.js"
16
+ export {
17
+ webkit,
18
+ webkitIsolatedTab,
19
+ } from "./execute/runtimes/browsers/webkit.js"
20
+ export { nodeProcess } from "./execute/runtimes/node/node_process.js"
21
+ // build
22
+ export { build } from "./build/build.js"
23
+ export { startBuildServer } from "./build/start_build_server.js"
24
+
25
+ // advanced
26
+ export { execute } from "./execute/execute.js"
27
+ export { jsenvPluginInjectGlobals } from "./plugins/inject_globals/jsenv_plugin_inject_globals.js"
@@ -9,6 +9,15 @@ export const featureCompats = {
9
9
  android: "61",
10
10
  samsung: "8.2",
11
11
  },
12
+ document_current_script: {
13
+ edge: "12",
14
+ firefox: "4",
15
+ chrome: "29",
16
+ safari: "8",
17
+ opera: "16",
18
+ android: "4.4",
19
+ samsung: "4",
20
+ },
12
21
  import_meta: {
13
22
  chrome: "64",
14
23
  edge: "79",
@@ -18,13 +27,16 @@ export const featureCompats = {
18
27
  ios: "12",
19
28
  android: "9",
20
29
  },
30
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility
21
31
  import_dynamic: {
32
+ android: "8",
33
+ chrome: "63",
22
34
  edge: "79",
23
35
  firefox: "67",
24
- chrome: "63",
25
- safari: "11.3",
36
+ ios: "11.3",
26
37
  opera: "50",
27
- android: "8",
38
+ safari: "11.3",
39
+ samsung: "8.0",
28
40
  node: "13.2",
29
41
  },
30
42
  top_level_await: {
@@ -71,6 +83,14 @@ export const featureCompats = {
71
83
  ios: "5",
72
84
  android: "4.4",
73
85
  },
86
+ // https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker#browser_compatibility
87
+ worker_type_module: {
88
+ chrome: "80",
89
+ edge: "80",
90
+ opera: "67",
91
+ android: "80",
92
+ },
93
+ worker_importmap: {},
74
94
  service_worker: {
75
95
  edge: "17",
76
96
  firefox: "44",
@@ -86,14 +106,17 @@ export const featureCompats = {
86
106
  opera: "67",
87
107
  android: "80",
88
108
  },
89
- // https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker#browser_compatibility
90
- worker_type_module: {
109
+ shared_worker: {
110
+ chrome: "4",
111
+ edge: "79",
112
+ firefox: "29",
113
+ opera: "10.6",
114
+ },
115
+ shared_worker_type_module: {
91
116
  chrome: "80",
92
117
  edge: "80",
93
118
  opera: "67",
94
- android: "80",
95
119
  },
96
- worker_importmap: {},
97
120
  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
98
121
  global_this: {
99
122
  edge: "79",
@@ -1,39 +1,37 @@
1
1
  import { findHighestVersion } from "@jsenv/utils/semantic_versioning/highest_version.js"
2
- import { featureCompats } from "./features_compatibility.js"
2
+ import { featureCompats } from "./features_compats.js"
3
3
 
4
- export const RUNTIME_SUPPORT = {
4
+ export const RUNTIME_COMPAT = {
5
5
  featureCompats,
6
6
 
7
- add: (originalRuntimeSupport, feature) => {
7
+ add: (originalRuntimeCompat, feature) => {
8
8
  const featureCompat = getFeatureCompat(feature)
9
- const runtimeSupport = {
10
- ...originalRuntimeSupport,
9
+ const runtimeCompat = {
10
+ ...originalRuntimeCompat,
11
11
  }
12
12
  Object.keys(featureCompat).forEach((runtimeName) => {
13
- const firstVersion = originalRuntimeSupport[runtimeName]
13
+ const firstVersion = originalRuntimeCompat[runtimeName]
14
14
  const secondVersion = featureCompat[runtimeName]
15
- runtimeSupport[runtimeName] = firstVersion
15
+ runtimeCompat[runtimeName] = firstVersion
16
16
  ? findHighestVersion(firstVersion, secondVersion)
17
17
  : secondVersion
18
18
  })
19
- return runtimeSupport
19
+ return runtimeCompat
20
20
  },
21
21
 
22
- isSupported: (runtimeSupport, feature) => {
22
+ isSupported: (runtimeCompat, feature) => {
23
23
  const featureCompat = getFeatureCompat(feature)
24
- const runtimeNames = Object.keys(runtimeSupport)
25
- return runtimeNames.every((runtimeName) => {
26
- const runtimeVersion = runtimeSupport[runtimeName]
24
+ const runtimeNames = Object.keys(runtimeCompat)
25
+ const runtimeWithoutCompat = runtimeNames.find((runtimeName) => {
26
+ const runtimeVersion = runtimeCompat[runtimeName]
27
27
  const runtimeVersionCompatible = featureCompat[runtimeName] || "Infinity"
28
28
  const highestVersion = findHighestVersion(
29
29
  runtimeVersion,
30
30
  runtimeVersionCompatible,
31
31
  )
32
- if (highestVersion !== runtimeVersion) {
33
- return false
34
- }
35
- return true
32
+ return highestVersion !== runtimeVersion
36
33
  })
34
+ return !runtimeWithoutCompat
37
35
  },
38
36
  }
39
37