@jsenv/core 27.0.0-alpha.3 → 27.0.0-alpha.32

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 (222) hide show
  1. package/main.js +4 -0
  2. package/package.json +17 -14
  3. package/readme.md +4 -12
  4. package/src/build/build.js +690 -429
  5. package/src/build/build_urls_generator.js +33 -21
  6. package/src/build/graph_utils.js +31 -0
  7. package/src/build/{inject_version_mappings.js → inject_global_version_mappings.js} +33 -15
  8. package/src/build/inject_service_worker_urls.js +79 -0
  9. package/src/build/resync_ressource_hints.js +68 -0
  10. package/src/build/start_build_server.js +201 -0
  11. package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +2 -2
  12. package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +3 -1
  13. package/src/dev/start_dev_server.js +58 -26
  14. package/src/execute/execute.js +30 -4
  15. package/src/execute/run.js +19 -56
  16. package/src/execute/runtimes/browsers/from_playwright.js +201 -147
  17. package/src/execute/runtimes/node/controllable_file.mjs +26 -10
  18. package/src/execute/runtimes/node/node_execution_performance.js +67 -0
  19. package/src/execute/runtimes/node/node_process.js +280 -39
  20. package/src/omega/{runtime_support/default_runtime_support.js → compat/default_runtime_compat.js} +3 -5
  21. package/src/omega/{runtime_support/features_compatibility.js → compat/features_compats.js} +66 -4
  22. package/src/omega/compat/runtime_compat.js +50 -0
  23. package/src/omega/errors.js +51 -58
  24. package/src/omega/fetched_content_compliance.js +24 -0
  25. package/src/omega/file_url_converter.js +8 -50
  26. package/src/omega/kitchen.js +409 -286
  27. package/src/omega/server/file_service.js +9 -11
  28. package/src/omega/url_graph/url_graph_load.js +14 -7
  29. package/src/omega/url_graph/url_graph_report.js +17 -15
  30. package/src/omega/url_graph.js +32 -10
  31. package/src/omega/web_workers.js +42 -0
  32. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/autoreload_preference.js +0 -0
  33. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/event_source_client.js +2 -2
  34. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/reload.js +0 -0
  35. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/url_helpers.js +0 -0
  36. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +41 -0
  37. package/src/{dev/plugins/autoreload/jsenv_plugin_autoreload.js → plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js} +27 -168
  38. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +25 -0
  39. package/src/plugins/autoreload/jsenv_plugin_hmr.js +35 -0
  40. package/src/plugins/bundling/css/bundle_css.js +21 -0
  41. package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +13 -0
  42. package/src/{build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js → plugins/bundling/js_module/bundle_js_module.js} +120 -79
  43. package/src/plugins/bundling/jsenv_plugin_bundling.js +51 -0
  44. package/src/{omega/core_plugins → plugins}/commonjs_globals/jsenv_plugin_commonjs_globals.js +48 -41
  45. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +66 -0
  46. package/src/{omega/core_plugins → plugins}/filesystem_magic/jsenv_plugin_filesystem_magic.js +7 -4
  47. package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_document.js +0 -0
  48. package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_notification.js +0 -0
  49. package/src/{omega/core_plugins → plugins}/html_supervisor/client/html_supervisor_installer.js +3 -2
  50. package/src/{omega/core_plugins → plugins}/html_supervisor/client/html_supervisor_setup.js +0 -0
  51. package/src/{omega/core_plugins → plugins}/html_supervisor/client/perf_browser.js +0 -0
  52. package/src/{omega/core_plugins → plugins}/html_supervisor/client/uneval_exception.js +0 -0
  53. package/src/{omega/core_plugins → plugins}/html_supervisor/jsenv_plugin_html_supervisor.js +38 -46
  54. package/src/plugins/http_urls/jsenv_plugin_http_urls.js +12 -0
  55. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/babel_plugin_metadata_import_meta_hot.js +4 -5
  56. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/client/import_meta_hot.js +3 -1
  57. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/html_hot_dependencies.js +2 -2
  58. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +98 -0
  59. package/src/{omega/core_plugins → plugins}/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +26 -8
  60. package/src/plugins/import_meta_url/client/import_meta_url_browser.js +52 -0
  61. package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +9 -0
  62. package/src/{omega/core_plugins → plugins}/importmap/jsenv_plugin_importmap.js +37 -31
  63. package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +25 -0
  64. package/src/{omega/core_plugins → plugins}/inline/client/inline_content.js +0 -0
  65. package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_data_urls.js +18 -14
  66. package/src/{omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js → plugins/inline/jsenv_plugin_html_inline_content.js} +61 -40
  67. package/src/plugins/inline/jsenv_plugin_inline.js +36 -0
  68. package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_inline_query_param.js +6 -6
  69. package/src/plugins/inline/jsenv_plugin_js_inline_content.js +263 -0
  70. package/src/plugins/leading_slash/jsenv_plugin_leading_slash.js +13 -0
  71. package/src/plugins/minification/css/minify_css.js +9 -0
  72. package/src/plugins/minification/html/minify_html.js +15 -0
  73. package/src/{build/plugins/minify_js/jsenv_plugin_minify_js.js → plugins/minification/js/minify_js.js} +6 -22
  74. package/src/plugins/minification/jsenv_plugin_minification.js +78 -0
  75. package/src/plugins/minification/json/minify_json.js +8 -0
  76. package/src/{omega/core_plugins → plugins}/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +15 -15
  77. package/src/{omega → plugins}/plugin_controller.js +18 -10
  78. package/src/plugins/plugins.js +73 -0
  79. package/src/plugins/transpilation/as_js_classic/client/s.js +808 -0
  80. package/src/plugins/transpilation/as_js_classic/client/s.js.md +1 -0
  81. package/src/plugins/transpilation/as_js_classic/helpers/babel_plugin_transform_import_meta_url.js +47 -0
  82. package/src/plugins/transpilation/as_js_classic/helpers/systemjs_old.js +43 -0
  83. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +183 -0
  84. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_script_type_module_as_classic.js +256 -0
  85. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_workers_type_module_as_classic.js +139 -0
  86. package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +0 -0
  87. package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/client/global_this.js +0 -0
  88. package/src/{omega/core_plugins/babel/babel_helper → plugins/transpilation/babel/helpers}/babel_plugin_babel_helpers_as_jsenv_imports.js +1 -2
  89. package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +161 -0
  90. package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugins_compatibility.js +0 -0
  91. package/src/{omega/core_plugins → plugins/transpilation}/babel/jsenv_plugin_babel.js +38 -22
  92. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +30 -6
  93. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/.eslintrc.cjs +0 -0
  94. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/new_stylesheet.js +0 -0
  95. package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -0
  96. package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/client/regenerator_runtime.js +0 -0
  97. package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +18 -0
  98. package/src/plugins/transpilation/fetch_original_url_info.js +30 -0
  99. package/src/{omega/core_plugins → plugins/transpilation}/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +0 -0
  100. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +225 -0
  101. package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +37 -0
  102. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +44 -0
  103. package/src/plugins/url_references/css/css_urls.js +49 -0
  104. package/src/plugins/url_references/html/html_urls.js +273 -0
  105. package/src/plugins/url_references/js/js_urls.js +163 -0
  106. package/src/plugins/url_references/jsenv_plugin_url_references.js +18 -0
  107. package/src/plugins/url_references/webmanifest/webmanifest_urls.js +17 -0
  108. package/src/{omega/core_plugins → plugins}/url_resolution/jsenv_plugin_url_resolution.js +12 -5
  109. package/src/{omega/core_plugins → plugins}/url_version/jsenv_plugin_url_version.js +8 -8
  110. package/src/test/execute_plan.js +25 -11
  111. package/src/test/execute_test_plan.js +14 -1
  112. package/src/test/logs_file_execution.js +8 -7
  113. package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +0 -30
  114. package/src/dev/plugins/autoreload/client/event_source_connection.js +0 -195
  115. package/src/dev/plugins/autoreload/sse_service.js +0 -149
  116. package/src/execute/runtimes/node/controlled_process.js +0 -316
  117. package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +0 -29
  118. package/src/omega/core_plugins/babel/babel_helper/client/.eslintrc.cjs +0 -24
  119. package/src/omega/core_plugins/babel/babel_helper/client/AsyncGenerator/AsyncGenerator.js +0 -81
  120. package/src/omega/core_plugins/babel/babel_helper/client/AwaitValue/AwaitValue.js +0 -3
  121. package/src/omega/core_plugins/babel/babel_helper/client/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -33
  122. package/src/omega/core_plugins/babel/babel_helper/client/arrayLikeToArray/arrayLikeToArray.js +0 -7
  123. package/src/omega/core_plugins/babel/babel_helper/client/arrayWithHoles/arrayWithHoles.js +0 -4
  124. package/src/omega/core_plugins/babel/babel_helper/client/arrayWithoutHoles/arrayWithoutHoles.js +0 -6
  125. package/src/omega/core_plugins/babel/babel_helper/client/assertThisInitialized/assertThisInitialized.js +0 -7
  126. package/src/omega/core_plugins/babel/babel_helper/client/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -40
  127. package/src/omega/core_plugins/babel/babel_helper/client/asyncIterator/asyncIterator.js +0 -65
  128. package/src/omega/core_plugins/babel/babel_helper/client/asyncToGenerator/asyncToGenerator.js +0 -34
  129. package/src/omega/core_plugins/babel/babel_helper/client/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -5
  130. package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -20
  131. package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -6
  132. package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -13
  133. package/src/omega/core_plugins/babel/babel_helper/client/classCallCheck/classCallCheck.js +0 -5
  134. package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -5
  135. package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -6
  136. package/src/omega/core_plugins/babel/babel_helper/client/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -7
  137. package/src/omega/core_plugins/babel/babel_helper/client/classNameTDZError/classNameTDZError.js +0 -4
  138. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -7
  139. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldGet/classPrivateFieldGet.js +0 -7
  140. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -6
  141. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -5
  142. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldSet/classPrivateFieldSet.js +0 -8
  143. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodGet/classPrivateMethodGet.js +0 -6
  144. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodSet/classPrivateMethodSet.js +0 -3
  145. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -9
  146. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -15
  147. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -6
  148. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -3
  149. package/src/omega/core_plugins/babel/babel_helper/client/construct/construct.js +0 -16
  150. package/src/omega/core_plugins/babel/babel_helper/client/createClass/createClass.js +0 -15
  151. package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -60
  152. package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -23
  153. package/src/omega/core_plugins/babel/babel_helper/client/createRawReactElement/createRawReactElement.js +0 -50
  154. package/src/omega/core_plugins/babel/babel_helper/client/createSuper/createSuper.js +0 -22
  155. package/src/omega/core_plugins/babel/babel_helper/client/decorate/decorate.js +0 -403
  156. package/src/omega/core_plugins/babel/babel_helper/client/defaults/defaults.js +0 -11
  157. package/src/omega/core_plugins/babel/babel_helper/client/defineEnumerableProperties/defineEnumerableProperties.js +0 -23
  158. package/src/omega/core_plugins/babel/babel_helper/client/defineProperty/defineProperty.js +0 -18
  159. package/src/omega/core_plugins/babel/babel_helper/client/extends/extends.js +0 -14
  160. package/src/omega/core_plugins/babel/babel_helper/client/get/get.js +0 -19
  161. package/src/omega/core_plugins/babel/babel_helper/client/getPrototypeOf/getPrototypeOf.js +0 -4
  162. package/src/omega/core_plugins/babel/babel_helper/client/inherits/inherits.js +0 -19
  163. package/src/omega/core_plugins/babel/babel_helper/client/inheritsLoose/inheritsLoose.js +0 -7
  164. package/src/omega/core_plugins/babel/babel_helper/client/initializerDefineProperty/initializerDefineProperty.js +0 -10
  165. package/src/omega/core_plugins/babel/babel_helper/client/initializerWarningHelper/initializerWarningHelper.js +0 -6
  166. package/src/omega/core_plugins/babel/babel_helper/client/instanceof/instanceof.js +0 -6
  167. package/src/omega/core_plugins/babel/babel_helper/client/interopRequireDefault/interopRequireDefault.js +0 -3
  168. package/src/omega/core_plugins/babel/babel_helper/client/interopRequireWildcard/interopRequireWildcard.js +0 -37
  169. package/src/omega/core_plugins/babel/babel_helper/client/isNativeFunction/isNativeFunction.js +0 -4
  170. package/src/omega/core_plugins/babel/babel_helper/client/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -21
  171. package/src/omega/core_plugins/babel/babel_helper/client/iterableToArray/iterableToArray.js +0 -7
  172. package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimit/iterableToArrayLimit.js +0 -36
  173. package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -10
  174. package/src/omega/core_plugins/babel/babel_helper/client/jsx/jsx.js +0 -50
  175. package/src/omega/core_plugins/babel/babel_helper/client/maybeArrayLike/maybeArrayLike.js +0 -10
  176. package/src/omega/core_plugins/babel/babel_helper/client/newArrowCheck/newArrowCheck.js +0 -5
  177. package/src/omega/core_plugins/babel/babel_helper/client/nonIterableRest/nonIterableRest.js +0 -5
  178. package/src/omega/core_plugins/babel/babel_helper/client/nonIterableSpread/nonIterableSpread.js +0 -5
  179. package/src/omega/core_plugins/babel/babel_helper/client/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -3
  180. package/src/omega/core_plugins/babel/babel_helper/client/objectSpread/objectSpread.js +0 -23
  181. package/src/omega/core_plugins/babel/babel_helper/client/objectSpread2/objectSpread2.js +0 -41
  182. package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutProperties/objectWithoutProperties.js +0 -19
  183. package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -13
  184. package/src/omega/core_plugins/babel/babel_helper/client/possibleConstructorReturn/possibleConstructorReturn.js +0 -10
  185. package/src/omega/core_plugins/babel/babel_helper/client/readOnlyError/readOnlyError.js +0 -4
  186. package/src/omega/core_plugins/babel/babel_helper/client/readme.md +0 -8
  187. package/src/omega/core_plugins/babel/babel_helper/client/set/set.js +0 -44
  188. package/src/omega/core_plugins/babel/babel_helper/client/setPrototypeOf/setPrototypeOf.js +0 -6
  189. package/src/omega/core_plugins/babel/babel_helper/client/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -8
  190. package/src/omega/core_plugins/babel/babel_helper/client/slicedToArray/slicedToArray.js +0 -10
  191. package/src/omega/core_plugins/babel/babel_helper/client/slicedToArrayLoose/slicedToArrayLoose.js +0 -13
  192. package/src/omega/core_plugins/babel/babel_helper/client/superPropBase/superPropBase.js +0 -10
  193. package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -10
  194. package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -7
  195. package/src/omega/core_plugins/babel/babel_helper/client/tdz/tdz.js +0 -4
  196. package/src/omega/core_plugins/babel/babel_helper/client/temporalRef/temporalRef.js +0 -6
  197. package/src/omega/core_plugins/babel/babel_helper/client/temporalUndefined/temporalUndefined.js +0 -3
  198. package/src/omega/core_plugins/babel/babel_helper/client/toArray/toArray.js +0 -10
  199. package/src/omega/core_plugins/babel/babel_helper/client/toConsumableArray/toConsumableArray.js +0 -10
  200. package/src/omega/core_plugins/babel/babel_helper/client/toPrimitive/toPrimitive.js +0 -10
  201. package/src/omega/core_plugins/babel/babel_helper/client/toPropertyKey/toPropertyKey.js +0 -6
  202. package/src/omega/core_plugins/babel/babel_helper/client/typeof/typeof.js +0 -14
  203. package/src/omega/core_plugins/babel/babel_helper/client/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -12
  204. package/src/omega/core_plugins/babel/babel_helper/client/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -8
  205. package/src/omega/core_plugins/babel/babel_helper/client/wrapNativeSuper/wrapNativeSuper.js +0 -30
  206. package/src/omega/core_plugins/babel/babel_helper/client/wrapRegExp/wrapRegExp.js +0 -63
  207. package/src/omega/core_plugins/babel/babel_helper/client/writeOnlyError/writeOnlyError.js +0 -4
  208. package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +0 -187
  209. package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +0 -67
  210. package/src/omega/core_plugins/import_assertions/helpers/json_module.js +0 -12
  211. package/src/omega/core_plugins/import_assertions/helpers/text_module.js +0 -6
  212. package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +0 -211
  213. package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +0 -13
  214. package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +0 -210
  215. package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +0 -12
  216. package/src/omega/core_plugins.js +0 -39
  217. package/src/omega/runtime_support/runtime_support.js +0 -20
  218. package/src/omega/url_mentions/css_url_mentions.js +0 -63
  219. package/src/omega/url_mentions/html_url_mentions.js +0 -185
  220. package/src/omega/url_mentions/js_module_url_mentions.js +0 -91
  221. package/src/omega/url_mentions/parse_url_mentions.js +0 -37
  222. package/src/omega/url_mentions/worker_classic_url_mentions.js +0 -37
@@ -1,316 +0,0 @@
1
- import { fork } from "node:child_process"
2
- import { urlToFileSystemPath } from "@jsenv/filesystem"
3
- import { createDetailedMessage } from "@jsenv/logger"
4
- import {
5
- Abort,
6
- raceCallbacks,
7
- createCallbackListNotifiedOnce,
8
- } from "@jsenv/abort"
9
- import { uneval } from "@jsenv/uneval"
10
-
11
- import { memoize } from "@jsenv/utils/memoize/memoize.js"
12
-
13
- import { createChildExecOptions } from "./child_exec_options.js"
14
- import { ExecOptions } from "./exec_options.js"
15
- import { killProcessTree } from "./kill_process_tree.js"
16
-
17
- const NODE_CONTROLLABLE_FILE_URL = new URL(
18
- "./controllable_file.mjs",
19
- import.meta.url,
20
- ).href
21
-
22
- export const createControlledProcess = async ({
23
- signal = new AbortController().signal,
24
- logger,
25
- logProcessCommand = false,
26
-
27
- onStop,
28
- onError,
29
- onConsole,
30
-
31
- debugPort,
32
- debugMode,
33
- debugModeInheritBreak,
34
- commandLineOptions = [],
35
- env,
36
- inheritProcessEnv = true,
37
-
38
- stdin = "pipe",
39
- stdout = "pipe",
40
- stderr = "pipe",
41
- }) => {
42
- if (env !== undefined && typeof env !== "object") {
43
- throw new TypeError(`env must be an object, got ${env}`)
44
- }
45
- const cleanupCallbackList = createCallbackListNotifiedOnce()
46
- const cleanup = async (reason) => {
47
- await cleanupCallbackList.notify({ reason })
48
- }
49
-
50
- const childExecOptions = await createChildExecOptions({
51
- signal,
52
- debugPort,
53
- debugMode,
54
- debugModeInheritBreak,
55
- })
56
- const execArgv = ExecOptions.toExecArgv({
57
- ...childExecOptions,
58
- ...ExecOptions.fromExecArgv(commandLineOptions),
59
- })
60
- const envForChildProcess = {
61
- ...(inheritProcessEnv ? process.env : {}),
62
- ...env,
63
- }
64
- logger[logProcessCommand ? "info" : "debug"](
65
- `${process.argv[0]} ${execArgv.join(" ")} ${urlToFileSystemPath(
66
- NODE_CONTROLLABLE_FILE_URL,
67
- )}`,
68
- )
69
- const childProcess = fork(urlToFileSystemPath(NODE_CONTROLLABLE_FILE_URL), {
70
- execArgv,
71
- // silent: true
72
- stdio: ["pipe", "pipe", "pipe", "ipc"],
73
- env: envForChildProcess,
74
- })
75
- logger.debug(
76
- createDetailedMessage(`child process forked (pid ${childProcess.pid})`, {
77
- "execArgv": execArgv.join(`\n`),
78
- "custom env": JSON.stringify(env, null, " "),
79
- }),
80
- )
81
- // if we pass stream, pipe them https://github.com/sindresorhus/execa/issues/81
82
- if (typeof stdin === "object") {
83
- stdin.pipe(childProcess.stdin)
84
- }
85
- if (typeof stdout === "object") {
86
- childProcess.stdout.pipe(stdout)
87
- }
88
- if (typeof stderr === "object") {
89
- childProcess.stderr.pipe(stderr)
90
- }
91
- const childProcessReadyPromise = new Promise((resolve) => {
92
- onceProcessMessage(childProcess, "ready", resolve)
93
- })
94
- const removeOutputListener = installProcessOutputListener(
95
- childProcess,
96
- ({ type, text }) => {
97
- onConsole({ type, text })
98
- },
99
- )
100
- const stop = memoize(async ({ gracefulStopAllocatedMs } = {}) => {
101
- // all libraries are facing problem on windows when trying
102
- // to kill a process spawning other processes.
103
- // "killProcessTree" is theorically correct but sometimes keep process handing forever.
104
- // Inside GitHub workflow the whole Virtual machine gets unresponsive and ends up being killed
105
- // There is no satisfying solution to this problem so we stick to the basic
106
- // childProcess.kill()
107
- if (process.platform === "win32") {
108
- childProcess.kill()
109
- return
110
- }
111
- if (gracefulStopAllocatedMs) {
112
- try {
113
- await killProcessTree(childProcess.pid, {
114
- signal: GRACEFUL_STOP_SIGNAL,
115
- timeout: gracefulStopAllocatedMs,
116
- })
117
- return
118
- } catch (e) {
119
- if (e.code === "TIMEOUT") {
120
- logger.debug(
121
- `kill with SIGTERM because gracefulStop still pending after ${gracefulStopAllocatedMs}ms`,
122
- )
123
- await killProcessTree(childProcess.pid, {
124
- signal: GRACEFUL_STOP_FAILED_SIGNAL,
125
- })
126
- return
127
- }
128
- throw e
129
- }
130
- }
131
- await killProcessTree(childProcess.pid, { signal: STOP_SIGNAL })
132
- return
133
- })
134
- raceCallbacks(
135
- {
136
- // https://nodejs.org/api/child_process.html#child_process_event_disconnect
137
- // disconnect: (cb) => {
138
- // return onceProcessEvent(childProcess, "disconnect", cb)
139
- // },
140
- // https://nodejs.org/api/child_process.html#child_process_event_error
141
- error: (cb) => {
142
- return onceProcessEvent(childProcess, "error", cb)
143
- },
144
- exit: (cb) => {
145
- return onceProcessEvent(childProcess, "exit", (code, signal) => {
146
- cb({ code, signal })
147
- })
148
- },
149
- },
150
- (winner) => {
151
- const raceEffects = {
152
- // disconnect: () => {
153
- // stoppedCallbackList.notify()
154
- // },
155
- error: (error) => {
156
- removeOutputListener()
157
- if (
158
- !childProcess.connected &&
159
- error.code === "ERR_IPC_DISCONNECTED"
160
- ) {
161
- return
162
- }
163
- onError(error)
164
- },
165
- exit: async ({ code, signal }) => {
166
- // process.exit(1) in child process or process.exitCode = 1 + process.exit()
167
- // means there was an error even if we don't know exactly what.
168
- if (
169
- code !== null &&
170
- code !== 0 &&
171
- code !== SIGINT_EXIT_CODE &&
172
- code !== SIGTERM_EXIT_CODE &&
173
- code !== SIGABORT_EXIT_CODE
174
- ) {
175
- onError(createExitWithFailureCodeError(code))
176
- }
177
- await cleanup("process exit")
178
- onStop({ code, signal })
179
- },
180
- }
181
- raceEffects[winner.name](winner.data)
182
- },
183
- )
184
- const requestActionOnChildProcess = async ({
185
- signal,
186
- actionType,
187
- actionParams,
188
- }) => {
189
- const actionOperation = Abort.startOperation()
190
- actionOperation.addAbortSignal(signal)
191
- try {
192
- const result = await new Promise(async (resolve, reject) => {
193
- actionOperation.throwIfAborted()
194
- await childProcessReadyPromise
195
- onceProcessMessage(
196
- childProcess,
197
- "action-result",
198
- ({ status, value }) => {
199
- if (status === "action-completed") {
200
- resolve(value)
201
- } else {
202
- reject(value)
203
- }
204
- },
205
- )
206
- logger.debug(
207
- createDetailedMessage(`ask child process to perform an action`, {
208
- actionType,
209
- actionParams: JSON.stringify(actionParams, null, " "),
210
- }),
211
- )
212
- try {
213
- actionOperation.throwIfAborted()
214
- await sendToProcess(childProcess, "action", {
215
- actionType,
216
- actionParams,
217
- })
218
- } catch (e) {
219
- if (Abort.isAbortError(e) && actionOperation.signal.aborted) {
220
- throw e
221
- }
222
- logger.error(
223
- createDetailedMessage(`error while sending message to child`, {
224
- ["error stack"]: e.stack,
225
- }),
226
- )
227
- throw e
228
- }
229
- })
230
- return result
231
- } finally {
232
- await actionOperation.end()
233
- }
234
- }
235
- return {
236
- execArgv,
237
- stop,
238
- requestActionOnChildProcess,
239
- }
240
- }
241
-
242
- // https://nodejs.org/api/process.html#process_signal_events
243
- const SIGINT_SIGNAL_NUMBER = 2
244
- const SIGABORT_SIGNAL_NUMBER = 6
245
- const SIGTERM_SIGNAL_NUMBER = 15
246
- const SIGINT_EXIT_CODE = 128 + SIGINT_SIGNAL_NUMBER
247
- const SIGABORT_EXIT_CODE = 128 + SIGABORT_SIGNAL_NUMBER
248
- const SIGTERM_EXIT_CODE = 128 + SIGTERM_SIGNAL_NUMBER
249
- // http://man7.org/linux/man-pages/man7/signal.7.html
250
- // https:// github.com/nodejs/node/blob/1d9511127c419ec116b3ddf5fc7a59e8f0f1c1e4/lib/internal/child_process.js#L472
251
- const GRACEFUL_STOP_SIGNAL = "SIGTERM"
252
- const STOP_SIGNAL = "SIGKILL"
253
- // it would be more correct if GRACEFUL_STOP_FAILED_SIGNAL was SIGHUP instead of SIGKILL.
254
- // but I'm not sure and it changes nothing so just use SIGKILL
255
- const GRACEFUL_STOP_FAILED_SIGNAL = "SIGKILL"
256
-
257
- const sendToProcess = async (childProcess, type, data) => {
258
- const source = uneval(data, { functionAllowed: true })
259
- return new Promise((resolve, reject) => {
260
- childProcess.send({ type, data: source }, (error) => {
261
- if (error) {
262
- reject(error)
263
- } else {
264
- resolve()
265
- }
266
- })
267
- })
268
- }
269
-
270
- const installProcessOutputListener = (childProcess, callback) => {
271
- // beware that we may receive ansi output here, should not be a problem but keep that in mind
272
- const stdoutDataCallback = (chunk) => {
273
- callback({ type: "log", text: String(chunk) })
274
- }
275
- childProcess.stdout.on("data", stdoutDataCallback)
276
- const stdErrorDataCallback = (chunk) => {
277
- callback({ type: "error", text: String(chunk) })
278
- }
279
- childProcess.stderr.on("data", stdErrorDataCallback)
280
- return () => {
281
- childProcess.stdout.removeListener("data", stdoutDataCallback)
282
- childProcess.stderr.removeListener("data", stdoutDataCallback)
283
- }
284
- }
285
-
286
- const createExitWithFailureCodeError = (code) => {
287
- if (code === 12) {
288
- return new Error(
289
- `child exited with 12: forked child wanted to use a non available port for debug`,
290
- )
291
- }
292
- const error = new Error(`child exited with ${code}`)
293
- error.exitCode = code
294
- return error
295
- }
296
-
297
- const onceProcessMessage = (childProcess, type, callback) => {
298
- const onmessage = (message) => {
299
- if (message.type === type) {
300
- childProcess.removeListener("message", onmessage)
301
- // eslint-disable-next-line no-eval
302
- callback(message.data ? eval(`(${message.data})`) : "")
303
- }
304
- }
305
- childProcess.on("message", onmessage)
306
- return () => {
307
- childProcess.removeListener("message", onmessage)
308
- }
309
- }
310
-
311
- const onceProcessEvent = (childProcess, type, callback) => {
312
- childProcess.once(type, callback)
313
- return () => {
314
- childProcess.removeListener(type, callback)
315
- }
316
- }
@@ -1,29 +0,0 @@
1
- // https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-core/src/tools/build-external-helpers.js
2
- // the list of possible helpers:
3
- // https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-helpers/src/helpers.js#L13
4
-
5
- const babelHelperClientDirectoryUrl = new URL("./client/", import.meta.url).href
6
-
7
- // we cannot use "@jsenv/core/src/*" because babel helper might be injected
8
- // into node_modules not depending on "@jsenv/core"
9
- export const getBabelHelperFileUrl = (babelHelperName) => {
10
- const babelHelperFileUrl = new URL(
11
- `./${babelHelperName}/${babelHelperName}.js`,
12
- babelHelperClientDirectoryUrl,
13
- ).href
14
- return babelHelperFileUrl
15
- }
16
-
17
- export const babelHelperNameFromUrl = (url) => {
18
- if (!url.startsWith(babelHelperClientDirectoryUrl)) {
19
- return null
20
- }
21
- const afterBabelHelperDirectory = url.slice(
22
- babelHelperClientDirectoryUrl.length,
23
- )
24
- const babelHelperName = afterBabelHelperDirectory.slice(
25
- 0,
26
- afterBabelHelperDirectory.indexOf("/"),
27
- )
28
- return babelHelperName
29
- }
@@ -1,24 +0,0 @@
1
- const eslintConfig = require("../../.eslintrc.cjs")
2
-
3
- // babel helpers are copy pasted from the babel repository
4
- Object.assign(eslintConfig.rules, {
5
- "eqeqeq": ["off"],
6
- "no-eq-null": ["off"],
7
- "no-undef-init": ["off"],
8
- "dot-notation": ["off"],
9
- "consistent-return": ["off"],
10
- "one-var": ["off"],
11
- "object-shorthand": ["off"],
12
- "no-return-assign": ["off"],
13
- "prefer-template": ["off"],
14
- "prefer-rest-params": ["off"],
15
- "no-void": ["off"],
16
- "no-implicit-coercion": ["off"],
17
- "prefer-spread": ["off"],
18
- "no-loop-func": ["off"],
19
- "no-negated-condition": ["off"],
20
- "no-func-assign": ["off"],
21
- "no-else-return": ["off"],
22
- })
23
-
24
- module.exports = eslintConfig
@@ -1,81 +0,0 @@
1
- import AwaitValue from "../AwaitValue/AwaitValue.js"
2
-
3
- export default function AsyncGenerator(gen) {
4
- var front, back
5
- function send(key, arg) {
6
- return new Promise(function (resolve, reject) {
7
- var request = {
8
- key: key,
9
- arg: arg,
10
- resolve: resolve,
11
- reject: reject,
12
- next: null,
13
- }
14
- if (back) {
15
- back = back.next = request
16
- } else {
17
- front = back = request
18
- resume(key, arg)
19
- }
20
- })
21
- }
22
- function resume(key, arg) {
23
- try {
24
- var result = gen[key](arg)
25
- var value = result.value
26
- var wrappedAwait = value instanceof AwaitValue
27
- Promise.resolve(wrappedAwait ? value.wrapped : value).then(
28
- function (arg) {
29
- if (wrappedAwait) {
30
- resume(key === "return" ? "return" : "next", arg)
31
- return
32
- }
33
- settle(result.done ? "return" : "normal", arg)
34
- },
35
- function (err) {
36
- resume("throw", err)
37
- },
38
- )
39
- } catch (err) {
40
- settle("throw", err)
41
- }
42
- }
43
- function settle(type, value) {
44
- switch (type) {
45
- case "return":
46
- front.resolve({ value: value, done: true })
47
- break
48
- case "throw":
49
- front.reject(value)
50
- break
51
- default:
52
- front.resolve({ value: value, done: false })
53
- break
54
- }
55
- front = front.next
56
- if (front) {
57
- resume(front.key, front.arg)
58
- } else {
59
- back = null
60
- }
61
- }
62
- this._invoke = send
63
- // Hide "return" method if generator return is not supported
64
- if (typeof gen.return !== "function") {
65
- this.return = undefined
66
- }
67
- }
68
- AsyncGenerator.prototype[
69
- (typeof Symbol === "function" && Symbol.asyncIterator) || "@@asyncIterator"
70
- ] = function () {
71
- return this
72
- }
73
- AsyncGenerator.prototype.next = function (arg) {
74
- return this._invoke("next", arg)
75
- }
76
- AsyncGenerator.prototype.throw = function (arg) {
77
- return this._invoke("throw", arg)
78
- }
79
- AsyncGenerator.prototype.return = function (arg) {
80
- return this._invoke("return", arg)
81
- }
@@ -1,3 +0,0 @@
1
- export default function _AwaitValue (value) {
2
- this.wrapped = value
3
- }
@@ -1,33 +0,0 @@
1
- /* eslint-disable no-void */
2
- export default function _applyDecoratedDescriptor(
3
- target,
4
- property,
5
- decorators,
6
- descriptor,
7
- context,
8
- ) {
9
- var desc = {}
10
- Object.keys(descriptor).forEach(function (key) {
11
- desc[key] = descriptor[key]
12
- })
13
- desc.enumerable = Boolean(desc.enumerable)
14
- desc.configurable = Boolean(desc.configurable)
15
- if ("value" in desc || desc.initializer) {
16
- desc.writable = true
17
- }
18
- desc = decorators
19
- .slice()
20
- .reverse()
21
- .reduce(function (desc, decorator) {
22
- return decorator(target, property, desc) || desc
23
- }, desc)
24
- if (context && desc.initializer !== void 0) {
25
- desc.value = desc.initializer ? desc.initializer.call(context) : void 0
26
- desc.initializer = undefined
27
- }
28
- if (desc.initializer === void 0) {
29
- Object.defineProperty(target, property, desc)
30
- desc = null
31
- }
32
- return desc
33
- }
@@ -1,7 +0,0 @@
1
- /* eslint-disable no-eq-null, eqeqeq */
2
- export default function arrayLikeToArray(arr, len) {
3
- if (len == null || len > arr.length) len = arr.length
4
- var arr2 = new Array(len)
5
- for (var i = 0; i < len; i++) arr2[i] = arr[i]
6
- return arr2
7
- }
@@ -1,4 +0,0 @@
1
- // eslint-disable-next-line consistent-return
2
- export default (arr) => {
3
- if (Array.isArray(arr)) return arr
4
- }
@@ -1,6 +0,0 @@
1
- import arrayLikeToArray from "../arrayLikeToArray/arrayLikeToArray.js"
2
-
3
- // eslint-disable-next-line consistent-return
4
- export default (arr) => {
5
- if (Array.isArray(arr)) return arrayLikeToArray(arr)
6
- }
@@ -1,7 +0,0 @@
1
- export default (self) => {
2
- // eslint-disable-next-line no-void
3
- if (self === void 0) {
4
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
5
- }
6
- return self
7
- }
@@ -1,40 +0,0 @@
1
- export default function _asyncGeneratorDelegate(inner, awaitWrap) {
2
- var iter = {},
3
- waiting = false
4
- function pump(key, value) {
5
- waiting = true
6
- value = new Promise(function (resolve) {
7
- resolve(inner[key](value))
8
- })
9
- return { done: false, value: awaitWrap(value) }
10
- }
11
- iter[(typeof Symbol !== "undefined" && Symbol.iterator) || "@@iterator"] = function () {
12
- return this
13
- }
14
- iter.next = function (value) {
15
- if (waiting) {
16
- waiting = false
17
- return value
18
- }
19
- return pump("next", value)
20
- }
21
- if (typeof inner.throw === "function") {
22
- iter.throw = function (value) {
23
- if (waiting) {
24
- waiting = false
25
- throw value
26
- }
27
- return pump("throw", value)
28
- }
29
- }
30
- if (typeof inner.return === "function") {
31
- iter.return = function (value) {
32
- if (waiting) {
33
- waiting = false
34
- return value
35
- }
36
- return pump("return", value)
37
- }
38
- }
39
- return iter
40
- }
@@ -1,65 +0,0 @@
1
- export default function _asyncIterator(iterable) {
2
- var method,
3
- async,
4
- sync,
5
- retry = 2;
6
-
7
- if (typeof Symbol !== "undefined") {
8
- async = Symbol.asyncIterator;
9
- sync = Symbol.iterator;
10
- }
11
-
12
- while (retry--) {
13
- if (async && (method = iterable[async]) != null) {
14
- return method.call(iterable);
15
- }
16
- if (sync && (method = iterable[sync]) != null) {
17
- return new AsyncFromSyncIterator(method.call(iterable));
18
- }
19
-
20
- async = "@@asyncIterator";
21
- sync = "@@iterator";
22
- }
23
-
24
- throw new TypeError("Object is not async iterable");
25
- }
26
-
27
- function AsyncFromSyncIterator(s) {
28
- AsyncFromSyncIterator = function (s) {
29
- this.s = s;
30
- this.n = s.next;
31
- };
32
- AsyncFromSyncIterator.prototype = {
33
- /* SyncIterator */ s: null,
34
- /* SyncIterator.[[Next]] */ n: null,
35
- next: function () {
36
- return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments));
37
- },
38
- return: function (value) {
39
- var ret = this.s.return;
40
- if (ret === undefined) {
41
- return Promise.resolve({ value: value, done: true });
42
- }
43
- return AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments));
44
- },
45
- throw: function (value) {
46
- var thr = this.s.return;
47
- if (thr === undefined) return Promise.reject(value);
48
- return AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments));
49
- },
50
- };
51
-
52
- function AsyncFromSyncIteratorContinuation(r) {
53
- // This step is _before_ calling AsyncFromSyncIteratorContinuation in the spec.
54
- if (Object(r) !== r) {
55
- return Promise.reject(new TypeError(r + " is not an object."));
56
- }
57
-
58
- var done = r.done;
59
- return Promise.resolve(r.value).then(function (value) {
60
- return { value: value, done: done };
61
- });
62
- }
63
-
64
- return new AsyncFromSyncIterator(s);
65
- }
@@ -1,34 +0,0 @@
1
- export default function (fn) {
2
- return function () {
3
- var self = this
4
- // eslint-disable-next-line prefer-rest-params
5
- var args = arguments
6
- return new Promise(function (resolve, reject) {
7
- var gen = fn.apply(self, args)
8
- function _next(value) {
9
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value)
10
- }
11
- function _throw(err) {
12
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err)
13
- }
14
- _next(undefined)
15
- })
16
- }
17
- }
18
-
19
- const asyncGeneratorStep = (gen, resolve, reject, _next, _throw, key, arg) => {
20
- var info
21
- var value
22
- try {
23
- info = gen[key](arg)
24
- value = info.value
25
- } catch (error) {
26
- reject(error)
27
- return
28
- }
29
- if (info.done) {
30
- resolve(value)
31
- } else {
32
- Promise.resolve(value).then(_next, _throw)
33
- }
34
- }
@@ -1,5 +0,0 @@
1
- import AwaitValue from "../AwaitValue/AwaitValue.js"
2
-
3
- export default function (value) {
4
- return new AwaitValue(value)
5
- }
@@ -1,20 +0,0 @@
1
- export default function _classApplyDescriptorDestructureSet(receiver, descriptor) {
2
- if (descriptor.set) {
3
- if (!("__destrObj" in descriptor)) {
4
- descriptor.__destrObj = {
5
- // eslint-disable-next-line accessor-pairs
6
- set value(v) {
7
- descriptor.set.call(receiver, v)
8
- },
9
- }
10
- }
11
- return descriptor.__destrObj
12
- }
13
- if (!descriptor.writable) {
14
- // This should only throw in strict mode, but class bodies are
15
- // always strict and private fields can only be used inside
16
- // class bodies.
17
- throw new TypeError("attempted to set read only private field")
18
- }
19
- return descriptor
20
- }