@jsenv/core 26.0.1 → 27.0.0-alpha.10

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 (465) hide show
  1. package/main.js +17 -24
  2. package/package.json +35 -71
  3. package/readme.md +30 -37
  4. package/src/build/build.js +867 -0
  5. package/src/build/build_urls_generator.js +73 -0
  6. package/src/build/inject_service_worker_urls.js +25 -0
  7. package/src/build/inject_version_mappings.js +63 -0
  8. package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +227 -0
  9. package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +30 -0
  10. package/src/build/plugins/minify_js/jsenv_plugin_minify_js.js +47 -0
  11. package/src/dev/plugins/autoreload/babel_plugin_metadata_import_meta_hot.js +98 -0
  12. package/src/dev/plugins/autoreload/client/autoreload_preference.js +11 -0
  13. package/src/dev/plugins/autoreload/client/event_source_client.js +186 -0
  14. package/src/{internal/dev_server/event_source_client → dev/plugins/autoreload/client}/event_source_connection.js +21 -25
  15. package/src/dev/plugins/autoreload/client/import_meta_hot.js +80 -0
  16. package/src/dev/plugins/autoreload/client/reload.js +101 -0
  17. package/src/dev/plugins/autoreload/client/url_helpers.js +20 -0
  18. package/src/dev/plugins/autoreload/html_hot_dependencies.js +156 -0
  19. package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +374 -0
  20. package/src/dev/plugins/autoreload/sse_service.js +149 -0
  21. package/src/dev/plugins/explorer/client/explorer.html +607 -0
  22. package/src/{internal → dev/plugins/explorer/client}/jsenv.png +0 -0
  23. package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +74 -0
  24. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/animation/toolbar_animation.js +0 -0
  25. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/eventsource/eventsource.css +2 -2
  26. package/src/dev/plugins/toolbar/client/eventsource/toolbar_eventsource.js +57 -0
  27. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/execution/execution.css +0 -0
  28. package/src/dev/plugins/toolbar/client/execution/toolbar_execution.js +88 -0
  29. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/focus.css +0 -0
  30. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/toolbar_focus.js +0 -0
  31. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/jsenv_logo.svg +0 -0
  32. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/notification/toolbar_notification.js +0 -0
  33. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/overflow_menu.css +0 -0
  34. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/toolbar_responsive.js +0 -0
  35. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/settings.css +0 -0
  36. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/toolbar_settings.js +1 -0
  37. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/jsenv_theme.css +1 -15
  38. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/light_theme.css +0 -17
  39. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/toolbar_theme.js +0 -0
  40. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar.html +40 -199
  41. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_injector.js +8 -28
  42. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.css +0 -24
  43. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.js +10 -56
  44. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.css +1 -1
  45. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.js +0 -0
  46. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/animation.js +0 -0
  47. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/dom.js +0 -0
  48. package/src/{internal/browser_utils → dev/plugins/toolbar/client/util}/fetch_using_xhr.js +0 -0
  49. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/fetching.js +2 -4
  50. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/iframe_to_parent_href.js +0 -0
  51. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/jsenv_logger.js +0 -0
  52. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/preferences.js +0 -0
  53. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/responsive.js +0 -0
  54. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/util.js +0 -0
  55. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/variant/variant.js +0 -0
  56. package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +62 -0
  57. package/src/dev/start_dev_server.js +108 -0
  58. package/src/execute/execute.js +138 -0
  59. package/src/execute/run.js +208 -0
  60. package/src/execute/runtimes/browsers/chromium.js +8 -0
  61. package/src/execute/runtimes/browsers/firefox.js +7 -0
  62. package/src/execute/runtimes/browsers/from_playwright.js +464 -0
  63. package/src/{browser_runtimes.js → execute/runtimes/browsers/webkit.js} +4 -18
  64. package/src/{internal/node_launcher/child_process_options.js → execute/runtimes/node/child_exec_options.js} +25 -36
  65. package/src/{internal/node_launcher/node_controllable_file.mjs → execute/runtimes/node/controllable_file.mjs} +1 -18
  66. package/src/{internal/node_launcher/node_controllable_process.js → execute/runtimes/node/controlled_process.js} +128 -150
  67. package/src/execute/runtimes/node/exec_options.js +44 -0
  68. package/src/{internal/node_launcher → execute/runtimes/node}/kill_process_tree.js +3 -1
  69. package/src/execute/runtimes/node/node_process.js +92 -0
  70. package/src/execute/runtimes/node/node_worker_thread.js +28 -0
  71. package/src/omega/core_plugins/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +35 -0
  72. package/{helpers/global-this/global-this.js → src/omega/core_plugins/babel/global_this/client/global_this.js} +0 -0
  73. package/src/{internal/compile_server/js → omega/core_plugins/babel/helpers}/babel_plugin_babel_helpers_as_jsenv_imports.js +15 -20
  74. package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +176 -0
  75. package/src/{internal/features → omega/core_plugins/babel/helpers}/babel_plugins_compatibility.js +1 -24
  76. package/src/omega/core_plugins/babel/jsenv_plugin_babel.js +111 -0
  77. package/src/omega/core_plugins/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +117 -0
  78. package/{helpers/babel → src/omega/core_plugins/babel/new_stylesheet/client}/.eslintrc.cjs +1 -1
  79. package/{helpers/new_stylesheet → src/omega/core_plugins/babel/new_stylesheet/client}/new_stylesheet.js +0 -0
  80. package/src/omega/core_plugins/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +34 -0
  81. package/{helpers/regenerator-runtime/regenerator-runtime.js → src/omega/core_plugins/babel/regenerator_runtime/client/regenerator_runtime.js} +0 -0
  82. package/src/omega/core_plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +169 -0
  83. package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +67 -0
  84. package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +58 -0
  85. package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_document.js +10 -16
  86. package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_notification.js +0 -0
  87. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +168 -0
  88. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +77 -0
  89. package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/perf_browser.js +0 -0
  90. package/src/{internal/runtime_client → omega/core_plugins/html_supervisor/client}/uneval_exception.js +0 -0
  91. package/src/omega/core_plugins/html_supervisor/jsenv_plugin_html_supervisor.js +233 -0
  92. package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +98 -0
  93. package/src/{internal/building/import_assertions → omega/core_plugins/import_assertions/helpers}/json_module.js +3 -2
  94. package/src/omega/core_plugins/import_assertions/helpers/text_module.js +6 -0
  95. package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +211 -0
  96. package/src/omega/core_plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +90 -0
  97. package/src/omega/core_plugins/importmap/jsenv_plugin_importmap.js +212 -0
  98. package/src/omega/core_plugins/inject_globals/jsenv_plugin_inject_globals.js +27 -0
  99. package/src/omega/core_plugins/inline/client/inline_content.js +6 -0
  100. package/src/omega/core_plugins/inline/jsenv_plugin_data_urls.js +70 -0
  101. package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +13 -0
  102. package/src/omega/core_plugins/inline/jsenv_plugin_inline_query_param.js +42 -0
  103. package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +142 -0
  104. package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +207 -0
  105. package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +12 -0
  106. package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +77 -0
  107. package/src/omega/core_plugins/url_resolution/jsenv_plugin_url_resolution.js +28 -0
  108. package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +50 -0
  109. package/src/omega/core_plugins.js +42 -0
  110. package/src/omega/errors.js +168 -0
  111. package/src/omega/file_url_converter.js +21 -0
  112. package/src/omega/kitchen.js +776 -0
  113. package/src/omega/omega_server.js +129 -0
  114. package/src/omega/plugin_controller.js +240 -0
  115. package/src/omega/runtime_support/default_runtime_support.js +13 -0
  116. package/src/omega/runtime_support/features_compatibility.js +130 -0
  117. package/src/omega/runtime_support/runtime_support.js +52 -0
  118. package/src/omega/server/file_service.js +155 -0
  119. package/src/omega/server/user_agent.js +22 -0
  120. package/src/omega/url_graph/url_graph_load.js +69 -0
  121. package/src/omega/url_graph/url_graph_report.js +151 -0
  122. package/src/omega/url_graph/url_graph_sort.js +29 -0
  123. package/src/omega/url_graph/url_info_transformations.js +161 -0
  124. package/src/omega/url_graph.js +133 -0
  125. package/src/omega/url_mentions/css_url_mentions.js +63 -0
  126. package/src/omega/url_mentions/html_url_mentions.js +185 -0
  127. package/src/omega/url_mentions/js_module_url_mentions.js +91 -0
  128. package/src/omega/url_mentions/parse_url_mentions.js +37 -0
  129. package/src/omega/url_mentions/worker_classic_url_mentions.js +37 -0
  130. package/src/{internal/executing → test}/execute_plan.js +156 -211
  131. package/src/{execute_test_plan.js → test/execute_test_plan.js} +36 -81
  132. package/src/{internal/executing → test}/execution_colors.js +0 -0
  133. package/src/{internal/executing → test}/execution_steps.js +2 -8
  134. package/src/{internal/executing → test}/gc.js +0 -0
  135. package/src/test/logs_file_execution.js +223 -0
  136. package/dist/browser_client/asset-manifest.json +0 -4
  137. package/dist/browser_client/browser_client_fb33eaa4.js +0 -5320
  138. package/dist/browser_client/browser_client_fb33eaa4.js.map +0 -1089
  139. package/dist/build_manifest.js +0 -12
  140. package/dist/compile_proxy/asset-manifest.json +0 -4
  141. package/dist/compile_proxy/compile_proxy.html__inline__20_651d1e7b.js.map +0 -343
  142. package/dist/compile_proxy/compile_proxy_62f952c4.html +0 -2245
  143. package/dist/event_source_client/asset-manifest.json +0 -4
  144. package/dist/event_source_client/event_source_client_69f48287.js +0 -354
  145. package/dist/event_source_client/event_source_client_69f48287.js.map +0 -128
  146. package/dist/redirector/asset-manifest.json +0 -4
  147. package/dist/redirector/redirector.html__inline__12_171e07b4.js.map +0 -349
  148. package/dist/redirector/redirector_8117ec92.html +0 -2290
  149. package/dist/toolbar/asset-manifest.json +0 -13
  150. package/dist/toolbar/assets/compilation.css_7421bd55.map +0 -12
  151. package/dist/toolbar/assets/eventsource.css_c0c71e7b.map +0 -12
  152. package/dist/toolbar/assets/execution.css_f3377c10.map +0 -12
  153. package/dist/toolbar/assets/focus.css_896f3e45.map +0 -12
  154. package/dist/toolbar/assets/light_theme.css_5bff0336.map +0 -12
  155. package/dist/toolbar/assets/overflow_menu.css_9a0fc3d8.map +0 -12
  156. package/dist/toolbar/assets/settings.css_942b5a9e.map +0 -12
  157. package/dist/toolbar/assets/toolbar_main.css_b1c67dd7.map +0 -28
  158. package/dist/toolbar/assets/tooltip.css_a94a8bdd.map +0 -12
  159. package/dist/toolbar/toolbar_b0c9100c.html +0 -4976
  160. package/dist/toolbar/toolbar_main_f54c1bb0.js.map +0 -776
  161. package/dist/toolbar_injector/asset-manifest.json +0 -5
  162. package/dist/toolbar_injector/assets/jsenv_logo_192011c2.svg +0 -95
  163. package/dist/toolbar_injector/toolbar_injector_65b501eb.js +0 -976
  164. package/dist/toolbar_injector/toolbar_injector_65b501eb.js.map +0 -294
  165. package/helpers/babel/AsyncGenerator/AsyncGenerator.js +0 -81
  166. package/helpers/babel/AwaitValue/AwaitValue.js +0 -3
  167. package/helpers/babel/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -33
  168. package/helpers/babel/arrayLikeToArray/arrayLikeToArray.js +0 -7
  169. package/helpers/babel/arrayWithHoles/arrayWithHoles.js +0 -4
  170. package/helpers/babel/arrayWithoutHoles/arrayWithoutHoles.js +0 -6
  171. package/helpers/babel/assertThisInitialized/assertThisInitialized.js +0 -7
  172. package/helpers/babel/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -40
  173. package/helpers/babel/asyncIterator/asyncIterator.js +0 -65
  174. package/helpers/babel/asyncToGenerator/asyncToGenerator.js +0 -34
  175. package/helpers/babel/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -5
  176. package/helpers/babel/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -20
  177. package/helpers/babel/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -6
  178. package/helpers/babel/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -13
  179. package/helpers/babel/classCallCheck/classCallCheck.js +0 -5
  180. package/helpers/babel/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -5
  181. package/helpers/babel/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -6
  182. package/helpers/babel/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -7
  183. package/helpers/babel/classNameTDZError/classNameTDZError.js +0 -4
  184. package/helpers/babel/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -7
  185. package/helpers/babel/classPrivateFieldGet/classPrivateFieldGet.js +0 -7
  186. package/helpers/babel/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -6
  187. package/helpers/babel/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -5
  188. package/helpers/babel/classPrivateFieldSet/classPrivateFieldSet.js +0 -8
  189. package/helpers/babel/classPrivateMethodGet/classPrivateMethodGet.js +0 -6
  190. package/helpers/babel/classPrivateMethodSet/classPrivateMethodSet.js +0 -3
  191. package/helpers/babel/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -9
  192. package/helpers/babel/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -15
  193. package/helpers/babel/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -6
  194. package/helpers/babel/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -3
  195. package/helpers/babel/construct/construct.js +0 -16
  196. package/helpers/babel/createClass/createClass.js +0 -15
  197. package/helpers/babel/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -60
  198. package/helpers/babel/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -23
  199. package/helpers/babel/createRawReactElement/createRawReactElement.js +0 -50
  200. package/helpers/babel/createSuper/createSuper.js +0 -22
  201. package/helpers/babel/decorate/decorate.js +0 -403
  202. package/helpers/babel/defaults/defaults.js +0 -11
  203. package/helpers/babel/defineEnumerableProperties/defineEnumerableProperties.js +0 -23
  204. package/helpers/babel/defineProperty/defineProperty.js +0 -18
  205. package/helpers/babel/extends/extends.js +0 -14
  206. package/helpers/babel/get/get.js +0 -19
  207. package/helpers/babel/getPrototypeOf/getPrototypeOf.js +0 -4
  208. package/helpers/babel/inherits/inherits.js +0 -19
  209. package/helpers/babel/inheritsLoose/inheritsLoose.js +0 -7
  210. package/helpers/babel/initializerDefineProperty/initializerDefineProperty.js +0 -10
  211. package/helpers/babel/initializerWarningHelper/initializerWarningHelper.js +0 -6
  212. package/helpers/babel/instanceof/instanceof.js +0 -6
  213. package/helpers/babel/interopRequireDefault/interopRequireDefault.js +0 -3
  214. package/helpers/babel/interopRequireWildcard/interopRequireWildcard.js +0 -37
  215. package/helpers/babel/isNativeFunction/isNativeFunction.js +0 -4
  216. package/helpers/babel/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -21
  217. package/helpers/babel/iterableToArray/iterableToArray.js +0 -7
  218. package/helpers/babel/iterableToArrayLimit/iterableToArrayLimit.js +0 -36
  219. package/helpers/babel/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -10
  220. package/helpers/babel/jsx/jsx.js +0 -50
  221. package/helpers/babel/maybeArrayLike/maybeArrayLike.js +0 -10
  222. package/helpers/babel/newArrowCheck/newArrowCheck.js +0 -5
  223. package/helpers/babel/nonIterableRest/nonIterableRest.js +0 -5
  224. package/helpers/babel/nonIterableSpread/nonIterableSpread.js +0 -5
  225. package/helpers/babel/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -3
  226. package/helpers/babel/objectSpread/objectSpread.js +0 -23
  227. package/helpers/babel/objectSpread2/objectSpread2.js +0 -41
  228. package/helpers/babel/objectWithoutProperties/objectWithoutProperties.js +0 -19
  229. package/helpers/babel/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -13
  230. package/helpers/babel/possibleConstructorReturn/possibleConstructorReturn.js +0 -10
  231. package/helpers/babel/readOnlyError/readOnlyError.js +0 -4
  232. package/helpers/babel/readme.md +0 -8
  233. package/helpers/babel/set/set.js +0 -44
  234. package/helpers/babel/setPrototypeOf/setPrototypeOf.js +0 -6
  235. package/helpers/babel/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -8
  236. package/helpers/babel/slicedToArray/slicedToArray.js +0 -10
  237. package/helpers/babel/slicedToArrayLoose/slicedToArrayLoose.js +0 -13
  238. package/helpers/babel/superPropBase/superPropBase.js +0 -10
  239. package/helpers/babel/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -10
  240. package/helpers/babel/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -7
  241. package/helpers/babel/tdz/tdz.js +0 -4
  242. package/helpers/babel/temporalRef/temporalRef.js +0 -6
  243. package/helpers/babel/temporalUndefined/temporalUndefined.js +0 -3
  244. package/helpers/babel/toArray/toArray.js +0 -10
  245. package/helpers/babel/toConsumableArray/toConsumableArray.js +0 -10
  246. package/helpers/babel/toPrimitive/toPrimitive.js +0 -10
  247. package/helpers/babel/toPropertyKey/toPropertyKey.js +0 -6
  248. package/helpers/babel/typeof/typeof.js +0 -14
  249. package/helpers/babel/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -12
  250. package/helpers/babel/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -8
  251. package/helpers/babel/wrapNativeSuper/wrapNativeSuper.js +0 -30
  252. package/helpers/babel/wrapRegExp/wrapRegExp.js +0 -63
  253. package/helpers/babel/writeOnlyError/writeOnlyError.js +0 -4
  254. package/helpers/import-meta/import-meta-url-commonjs.js +0 -9
  255. package/helpers/import-meta/import-meta-url-global.js +0 -54
  256. package/src/build_project.js +0 -336
  257. package/src/commonjs_to_js_module.js +0 -180
  258. package/src/dev_server.js +0 -302
  259. package/src/execute.js +0 -184
  260. package/src/import_using_child_process.js +0 -68
  261. package/src/internal/browser_client/browser_client.js +0 -220
  262. package/src/internal/browser_client/browser_client_factory.js +0 -144
  263. package/src/internal/browser_client/browser_error_stack_remap.js +0 -43
  264. package/src/internal/browser_client/browser_system.js +0 -216
  265. package/src/internal/browser_client/module_namespace_transfer.js +0 -90
  266. package/src/internal/browser_detection/browser_detection.js +0 -65
  267. package/src/internal/browser_detection/detect_android.js +0 -13
  268. package/src/internal/browser_detection/detect_chrome.js +0 -28
  269. package/src/internal/browser_detection/detect_edge.js +0 -13
  270. package/src/internal/browser_detection/detect_electron.js +0 -1
  271. package/src/internal/browser_detection/detect_firefox.js +0 -17
  272. package/src/internal/browser_detection/detect_internet_explorer.js +0 -14
  273. package/src/internal/browser_detection/detect_ios.js +0 -19
  274. package/src/internal/browser_detection/detect_opera.js +0 -27
  275. package/src/internal/browser_detection/detect_safari.js +0 -13
  276. package/src/internal/browser_detection/user_agent_data.js +0 -25
  277. package/src/internal/browser_detection/util.js +0 -13
  278. package/src/internal/browser_launcher/browser_runtime_profile.js +0 -81
  279. package/src/internal/browser_launcher/execute_html_file.js +0 -355
  280. package/src/internal/browser_launcher/from_playwright.js +0 -320
  281. package/src/internal/browser_launcher/page_errors_and_logs.js +0 -77
  282. package/src/internal/browser_utils/fetch_and_eval.js +0 -27
  283. package/src/internal/browser_utils/fetch_and_eval_using_script.js +0 -47
  284. package/src/internal/browser_utils/fetch_browser.js +0 -34
  285. package/src/internal/browser_utils/fetch_json.js +0 -7
  286. package/src/internal/building/build_logs.js +0 -134
  287. package/src/internal/building/build_stats.js +0 -100
  288. package/src/internal/building/build_url_generator.js +0 -153
  289. package/src/internal/building/build_using_rollup.js +0 -359
  290. package/src/internal/building/css/apply_post_css.js +0 -55
  291. package/src/internal/building/css/jsenv_parse_css.js +0 -260
  292. package/src/internal/building/css/move_css_urls.js +0 -44
  293. package/src/internal/building/css/parse_css_urls.js +0 -38
  294. package/src/internal/building/css/postcss_plugin_url_visitor.js +0 -245
  295. package/src/internal/building/css/replace_css_urls.js +0 -68
  296. package/src/internal/building/global_format/es_to_system.js +0 -34
  297. package/src/internal/building/html/html_node_mutations.js +0 -29
  298. package/src/internal/building/html/html_scan.js +0 -70
  299. package/src/internal/building/html/jsenv_parse_html.js +0 -813
  300. package/src/internal/building/html/minify_html.js +0 -7
  301. package/src/internal/building/import_assertions/css_module.js +0 -43
  302. package/src/internal/building/import_references.js +0 -80
  303. package/src/internal/building/importmap/jsenv_parse_importmap.js +0 -28
  304. package/src/internal/building/js/babel_plugin_inline_worker_imports.js +0 -96
  305. package/src/internal/building/js/jsenv_parse_js.js +0 -122
  306. package/src/internal/building/js/minify_js.js +0 -33
  307. package/src/internal/building/js/transform_worker.js +0 -55
  308. package/src/internal/building/json/jsenv_parse_json.js +0 -11
  309. package/src/internal/building/parse_ressource.js +0 -207
  310. package/src/internal/building/ressource_builder.js +0 -1098
  311. package/src/internal/building/ressource_builder_util.js +0 -194
  312. package/src/internal/building/rollup_plugin_jsenv.js +0 -1965
  313. package/src/internal/building/sort_pathnames.js +0 -10
  314. package/src/internal/building/sourcemap/sourcemap_loader.js +0 -70
  315. package/src/internal/building/svg/jsenv_parse_svg.js +0 -112
  316. package/src/internal/building/url_fetcher.js +0 -85
  317. package/src/internal/building/url_loader.js +0 -127
  318. package/src/internal/building/url_trace.js +0 -229
  319. package/src/internal/building/url_versioning/resolve_import_url_helper.js +0 -12
  320. package/src/internal/building/url_versioning/url_versioning.js +0 -65
  321. package/src/internal/building/webmanifest/jsenv_parse_webmanifest.js +0 -48
  322. package/src/internal/compile_server/commonjs/rollup_plugin_commonjs_named_exports.js +0 -187
  323. package/src/internal/compile_server/compile_file.js +0 -273
  324. package/src/internal/compile_server/compile_server.js +0 -519
  325. package/src/internal/compile_server/compiled_file_service.js +0 -264
  326. package/src/internal/compile_server/html/html_ast.js +0 -534
  327. package/src/internal/compile_server/html/html_source_file_service.js +0 -453
  328. package/src/internal/compile_server/html/jsenv_compile_html.js +0 -674
  329. package/src/internal/compile_server/importmap/jsenv_compile_importmap.js +0 -28
  330. package/src/internal/compile_server/js/ansi_to_html.js +0 -9
  331. package/src/internal/compile_server/js/babelHelper.js +0 -145
  332. package/src/internal/compile_server/js/babel_parse_error.js +0 -9
  333. package/src/internal/compile_server/js/babel_plugin_global_this_as_jsenv_import.js +0 -34
  334. package/src/internal/compile_server/js/babel_plugin_import_assertions.js +0 -121
  335. package/src/internal/compile_server/js/babel_plugin_import_metadata.js +0 -18
  336. package/src/internal/compile_server/js/babel_plugin_import_visitor.js +0 -84
  337. package/src/internal/compile_server/js/babel_plugin_new_stylesheet_as_jsenv_import.js +0 -113
  338. package/src/internal/compile_server/js/babel_plugin_proxy_external_imports.js +0 -31
  339. package/src/internal/compile_server/js/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -48
  340. package/src/internal/compile_server/js/babel_plugin_replace_expressions.js +0 -101
  341. package/src/internal/compile_server/js/babel_plugin_systemjs_prepend.js +0 -23
  342. package/src/internal/compile_server/js/babel_plugin_transform_import_meta.js +0 -134
  343. package/src/internal/compile_server/js/babel_plugins.js +0 -37
  344. package/src/internal/compile_server/js/generateBabelHelper.js +0 -36
  345. package/src/internal/compile_server/js/js_transformer.js +0 -195
  346. package/src/internal/compile_server/js/jsenv_compile_js.js +0 -62
  347. package/src/internal/compile_server/js/load_babel_plugin_map_from_file.js +0 -49
  348. package/src/internal/compile_server/jsenv_directory/comparison_utils.js +0 -27
  349. package/src/internal/compile_server/jsenv_directory/compilation_result.js +0 -243
  350. package/src/internal/compile_server/jsenv_directory/compilation_result_from_build.js +0 -184
  351. package/src/internal/compile_server/jsenv_directory/compile_asset.js +0 -24
  352. package/src/internal/compile_server/jsenv_directory/compile_context.js +0 -60
  353. package/src/internal/compile_server/jsenv_directory/compile_profile.js +0 -217
  354. package/src/internal/compile_server/jsenv_directory/file_lock_registry.js +0 -24
  355. package/src/internal/compile_server/jsenv_directory/file_lock_registry.test.js +0 -47
  356. package/src/internal/compile_server/jsenv_directory/fs_optimized_for_cache.js +0 -57
  357. package/src/internal/compile_server/jsenv_directory/jsenv_directory.js +0 -183
  358. package/src/internal/compile_server/jsenv_directory/reuse_or_create_compiled_file.js +0 -269
  359. package/src/internal/compile_server/jsenv_directory/update_compile_cache.js +0 -131
  360. package/src/internal/compile_server/jsenv_directory/validate_compile_cache.js +0 -264
  361. package/src/internal/compile_server/sse_service/sse_service.js +0 -369
  362. package/src/internal/coverage/babel_plugin_instrument.js +0 -90
  363. package/src/internal/coverage/coverage_reporter_html_directory.js +0 -37
  364. package/src/internal/coverage/coverage_reporter_json_file.js +0 -22
  365. package/src/internal/coverage/coverage_reporter_text_log.js +0 -20
  366. package/src/internal/coverage/empty_coverage_factory.js +0 -70
  367. package/src/internal/coverage/file_by_file_coverage.js +0 -28
  368. package/src/internal/coverage/istanbul_coverage_composition.js +0 -28
  369. package/src/internal/coverage/istanbul_coverage_map_from_coverage.js +0 -16
  370. package/src/internal/coverage/list_files_not_covered.js +0 -20
  371. package/src/internal/coverage/missing_coverage.js +0 -46
  372. package/src/internal/coverage/report_to_coverage.js +0 -198
  373. package/src/internal/coverage/v8_and_istanbul.js +0 -38
  374. package/src/internal/coverage/v8_coverage_composition.js +0 -23
  375. package/src/internal/coverage/v8_coverage_from_directory.js +0 -86
  376. package/src/internal/coverage/v8_coverage_to_istanbul.js +0 -100
  377. package/src/internal/data_url.js +0 -54
  378. package/src/internal/dev_server/event_source_client/event_source_client.js +0 -63
  379. package/src/internal/dev_server/event_source_client/file_changes.js +0 -82
  380. package/src/internal/dev_server/event_source_client/livereload_preference.js +0 -13
  381. package/src/internal/dev_server/exploring/exploring.css +0 -237
  382. package/src/internal/dev_server/exploring/exploring.html +0 -79
  383. package/src/internal/dev_server/exploring/exploring.js +0 -243
  384. package/src/internal/dev_server/exploring/fetch_exploring_json.js +0 -19
  385. package/src/internal/dev_server/toolbar/compilation/compilation.css +0 -23
  386. package/src/internal/dev_server/toolbar/compilation/toolbar_compilation.js +0 -202
  387. package/src/internal/dev_server/toolbar/eventsource/toolbar_eventsource.js +0 -83
  388. package/src/internal/dev_server/toolbar/execution/toolbar_execution.js +0 -91
  389. package/src/internal/error_stack_remap/install_error_stack_remapping.js +0 -142
  390. package/src/internal/error_stack_remap/remap_call_site.js +0 -315
  391. package/src/internal/error_stack_remap/remap_stack.js +0 -218
  392. package/src/internal/error_stack_remap/stringify_stack.js +0 -9
  393. package/src/internal/executing/launch_and_execute.js +0 -458
  394. package/src/internal/executing/logs_file_execution.js +0 -160
  395. package/src/internal/executing/logs_plan_summary.js +0 -144
  396. package/src/internal/features/browser_feature_detection/browser_feature_detect_dynamic_import.js +0 -20
  397. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_css.js +0 -23
  398. package/src/internal/features/browser_feature_detection/browser_feature_detect_import_assertions_json.js +0 -25
  399. package/src/internal/features/browser_feature_detection/browser_feature_detect_importmap.js +0 -37
  400. package/src/internal/features/browser_feature_detection/browser_feature_detect_new_stylesheet.js +0 -9
  401. package/src/internal/features/browser_feature_detection/browser_feature_detect_top_level_await.js +0 -14
  402. package/src/internal/features/browser_feature_detection/browser_feature_detection.js +0 -89
  403. package/src/internal/features/browser_feature_detection/compile_proxy.html +0 -27
  404. package/src/internal/features/browser_feature_detection/execute_with_script_module.js +0 -24
  405. package/src/internal/features/features_compat_from_runtime.js +0 -38
  406. package/src/internal/features/features_compat_from_runtime_support.js +0 -31
  407. package/src/internal/features/features_compatibility.js +0 -37
  408. package/src/internal/features/node_feature_detection/feature_detect_dynamic_import.mjs +0 -5
  409. package/src/internal/features/node_feature_detection/feature_detect_top_level_await.mjs +0 -1
  410. package/src/internal/features/node_feature_detection/node_feature_detect_dynamic_import.js +0 -5
  411. package/src/internal/features/node_feature_detection/node_feature_detect_top_level_await.js +0 -16
  412. package/src/internal/features/node_feature_detection/node_feature_detection.js +0 -66
  413. package/src/internal/fetching.js +0 -28
  414. package/src/internal/import_resolution/default_extension.js +0 -40
  415. package/src/internal/import_resolution/import_resolver_importmap.js +0 -64
  416. package/src/internal/import_resolution/import_resolver_node.js +0 -254
  417. package/src/internal/import_resolution/importmap_default.js +0 -37
  418. package/src/internal/jsenv_builds.js +0 -19
  419. package/src/internal/jsenv_params_assertions.js +0 -12
  420. package/src/internal/jsenv_remote_directory.js +0 -156
  421. package/src/internal/logs/byte.js +0 -10
  422. package/src/internal/logs/byte_as_file_size.js +0 -9
  423. package/src/internal/logs/ms_as_duration.js +0 -12
  424. package/src/internal/memoize.js +0 -24
  425. package/src/internal/node_launcher/eval_source.js +0 -6
  426. package/src/internal/node_launcher/fetch_source.js +0 -8
  427. package/src/internal/node_launcher/node_error_stack_remap.js +0 -22
  428. package/src/internal/node_launcher/node_execution_dynamic_import.js +0 -75
  429. package/src/internal/node_launcher/node_execution_performance.js +0 -67
  430. package/src/internal/node_launcher/node_execution_systemjs.js +0 -125
  431. package/src/internal/node_launcher/node_runtime_report.js +0 -77
  432. package/src/internal/node_launcher/node_system.js +0 -192
  433. package/src/internal/node_launcher/perf_node.js +0 -13
  434. package/src/internal/node_launcher/process_options.js +0 -46
  435. package/src/internal/node_launcher/value_install.js +0 -14
  436. package/src/internal/origin_directory_converter.js +0 -62
  437. package/src/internal/promise_race.js +0 -19
  438. package/src/internal/redirector/redirector.html +0 -40
  439. package/src/internal/regexp_escape.js +0 -34
  440. package/src/internal/require.js +0 -3
  441. package/src/internal/response_validation.js +0 -130
  442. package/src/internal/runtime_client/module_registration.js +0 -207
  443. package/src/internal/runtime_client/s.js +0 -864
  444. package/src/internal/runtime_client/s.js.md +0 -1
  445. package/src/internal/runtime_support/jsenv_runtime_support.js +0 -15
  446. package/src/internal/runtime_support/runtime_support.js +0 -70
  447. package/src/internal/semantic_versioning/compare_versions.js +0 -28
  448. package/src/internal/semantic_versioning/highest_version.js +0 -11
  449. package/src/internal/semantic_versioning/is_above.js +0 -5
  450. package/src/internal/semantic_versioning/is_below.js +0 -5
  451. package/src/internal/semantic_versioning/is_equal.js +0 -3
  452. package/src/internal/semantic_versioning/lowest_version.js +0 -11
  453. package/src/internal/semantic_versioning/version_from_value.js +0 -42
  454. package/src/internal/sourcemap_utils.js +0 -112
  455. package/src/internal/template_string_escape.js +0 -20
  456. package/src/internal/url_conversion.js +0 -313
  457. package/src/internal/url_utils.js +0 -33
  458. package/src/internal/url_utils.test.js +0 -39
  459. package/src/internal/windows_file_path_utils.js +0 -16
  460. package/src/jsenv_file_urls.js +0 -35
  461. package/src/jsenv_service_worker_finalizer.js +0 -55
  462. package/src/json_to_js_module.js +0 -13
  463. package/src/node_runtime.js +0 -227
  464. package/src/require_using_child_process.js +0 -67
  465. package/src/text_to_js_module.js +0 -13
@@ -1,40 +0,0 @@
1
- export const applyDefaultExtension = (specifier, importer) => {
2
- if (!importer) {
3
- return specifier
4
- }
5
-
6
- const importerExtension = urlToExtension(importer)
7
- const fakeUrl = new URL(specifier, importer).href
8
- const specifierExtension = urlToExtension(fakeUrl)
9
- if (specifierExtension !== "") {
10
- return specifier
11
- }
12
-
13
- // I guess typescript still expect default extension to be .ts
14
- // in a tsx file.
15
- if (importerExtension === "tsx") {
16
- return `${specifier}.ts`
17
- }
18
-
19
- // extension magic
20
- return `${specifier}${importerExtension}`
21
- }
22
-
23
- const urlToExtension = (url) => {
24
- return pathnameToExtension(urlToPathname(url))
25
- }
26
-
27
- const urlToPathname = (url) => new URL(url).pathname
28
-
29
- const pathnameToExtension = (pathname) => {
30
- const slashLastIndex = pathname.lastIndexOf("/")
31
- if (slashLastIndex !== -1) {
32
- pathname = pathname.slice(slashLastIndex + 1)
33
- }
34
-
35
- const dotLastIndex = pathname.lastIndexOf(".")
36
- if (dotLastIndex === -1) return ""
37
- // if (dotLastIndex === pathname.length - 1) return ""
38
- const extension = pathname.slice(dotLastIndex)
39
- return extension
40
- }
@@ -1,64 +0,0 @@
1
- import { createDetailedMessage } from "@jsenv/logger"
2
- import { resolveImport } from "@jsenv/importmap/src/resolveImport.js"
3
-
4
- import { tryToFindProjectRelativeUrl } from "@jsenv/core/src/internal/runtime_client/module_registration.js"
5
-
6
- import { applyDefaultExtension } from "./default_extension.js"
7
-
8
- export const createImportResolverForImportmap = async ({
9
- // projectDirectoryUrl,
10
- compileServerOrigin,
11
- compileDirectoryRelativeUrl,
12
- importMap,
13
- importMapUrl,
14
- importDefaultExtension,
15
- onBareSpecifierError = () => {},
16
- }) => {
17
- const _resolveImport = (specifier, importer) => {
18
- if (importDefaultExtension) {
19
- specifier = applyDefaultExtension(specifier, importer)
20
- }
21
- return resolveImport({
22
- specifier,
23
- importer,
24
- importMap,
25
- createBareSpecifierError: ({ specifier, importer }) => {
26
- const bareSpecifierError = createBareSpecifierError({
27
- specifier,
28
- importer:
29
- tryToFindProjectRelativeUrl(importer, {
30
- compileServerOrigin,
31
- compileDirectoryRelativeUrl,
32
- }) || importer,
33
- importMapUrl:
34
- tryToFindProjectRelativeUrl(importMapUrl, {
35
- compileServerOrigin,
36
- compileDirectoryRelativeUrl,
37
- }) || importMapUrl,
38
- importMap,
39
- })
40
- onBareSpecifierError(bareSpecifierError)
41
- return bareSpecifierError
42
- },
43
- })
44
- }
45
-
46
- return { resolveImport: _resolveImport }
47
- }
48
-
49
- const createBareSpecifierError = ({ specifier, importer, importMapUrl }) => {
50
- const detailedMessage = createDetailedMessage("Unmapped bare specifier.", {
51
- specifier,
52
- importer,
53
- ...(importMapUrl
54
- ? {
55
- "how to fix": `Add a mapping for "${specifier}" into the importmap file at "${importMapUrl}"`,
56
- }
57
- : {
58
- "how to fix": `Add an importmap with a mapping for "${specifier}"`,
59
- "suggestion": `Generate importmap using https://github.com/jsenv/importmap-node-module`,
60
- }),
61
- })
62
-
63
- return new Error(detailedMessage)
64
- }
@@ -1,254 +0,0 @@
1
- import { createRequire } from "node:module"
2
- import {
3
- urlToExtension,
4
- resolveUrl,
5
- urlToRelativeUrl,
6
- readFile,
7
- } from "@jsenv/filesystem"
8
- import { isSpecifierForNodeCoreModule } from "@jsenv/importmap/src/isSpecifierForNodeCoreModule.js"
9
-
10
- import { jsenvCoreDirectoryUrl } from "@jsenv/core/src/jsenv_file_urls.js"
11
-
12
- import { applyDefaultExtension } from "./default_extension.js"
13
-
14
- export const createImportResolverForNode = async ({
15
- projectDirectoryUrl,
16
- compileServerOrigin,
17
- compileDirectoryRelativeUrl,
18
- importDefaultExtension,
19
- }) => {
20
- if (typeof import.meta.resolve === "undefined") {
21
- throw new Error(
22
- `import.meta.resolve is undefined, code must be executed with --experimental-import-meta-resolve`,
23
- )
24
- }
25
-
26
- const defaultModuleResolution = await determineModuleSystem(
27
- projectDirectoryUrl,
28
- )
29
-
30
- const resolveImport = async (specifier, importer) => {
31
- if (isSpecifierForNodeCoreModule(specifier)) {
32
- return specifier
33
- }
34
-
35
- if (importDefaultExtension) {
36
- specifier = applyDefaultExtension(specifier, importer)
37
- }
38
-
39
- if (specifier.startsWith("http:") || specifier.startsWith("https:")) {
40
- return specifier
41
- }
42
-
43
- // handle self reference inside jsenv itself, it is not allowed by Node.js
44
- // for some reason
45
- if (specifier.startsWith("@jsenv/core/")) {
46
- if (projectDirectoryUrl === jsenvCoreDirectoryUrl) {
47
- specifier = resolveUrl(
48
- specifier.slice("@jsenv/core/".length),
49
- projectDirectoryUrl,
50
- )
51
- }
52
- }
53
-
54
- const moduleResolutionAlgorithm = importer
55
- ? moduleResolutionFromImporter(importer) || defaultModuleResolution
56
- : defaultModuleResolution
57
-
58
- importer =
59
- importer || resolveUrl(compileDirectoryRelativeUrl, compileServerOrigin)
60
-
61
- if (moduleResolutionAlgorithm === "esm") {
62
- return resolveUsingNodeEsModuleAlgorithm(specifier, {
63
- projectDirectoryUrl,
64
- compileServerOrigin,
65
- compileDirectoryRelativeUrl,
66
- importer,
67
- })
68
- }
69
-
70
- return resolveUsingNodeCommonJsAlgorithm(specifier, {
71
- projectDirectoryUrl,
72
- compileServerOrigin,
73
- compileDirectoryRelativeUrl,
74
- importer,
75
- })
76
- }
77
-
78
- return { resolveImport, asProjectUrl, asOriginalUrl }
79
- }
80
-
81
- // https://nodejs.org/dist/latest-v16.x/docs/api/packages.html#packages_determining_module_system)
82
- const determineModuleSystem = async (projectDirectoryUrl) => {
83
- const inputTypeIsModule = process.execArgv.some(
84
- (argv) => argv === "--input-type=module",
85
- )
86
- if (inputTypeIsModule) {
87
- return "esm"
88
- }
89
-
90
- return moduleResolutionFromProjectPackage(projectDirectoryUrl)
91
- }
92
-
93
- const moduleResolutionFromProjectPackage = async (projectDirectoryUrl) => {
94
- const packageJsonFileUrl = new URL("package.json", projectDirectoryUrl)
95
- let packageJson
96
- try {
97
- packageJson = await readFile(packageJsonFileUrl, {
98
- as: "json",
99
- })
100
- } catch (e) {
101
- if (e && e.code === "ENOENT") {
102
- return "esm"
103
- }
104
- }
105
- if (packageJson.type === "module") {
106
- return "esm"
107
- }
108
- return "commonjs"
109
- }
110
-
111
- const moduleResolutionFromImporter = (importer) => {
112
- if (urlToExtension(importer) === ".cjs") {
113
- return "commonjs"
114
- }
115
-
116
- if (urlToExtension(importer) === ".mjs") {
117
- return "esm"
118
- }
119
-
120
- // we should read the nearest package.json and search for type
121
- return undefined
122
- }
123
-
124
- const resolveUsingNodeEsModuleAlgorithm = async (
125
- specifier,
126
- {
127
- projectDirectoryUrl,
128
- compileServerOrigin,
129
- compileDirectoryRelativeUrl,
130
- importer,
131
- },
132
- ) => {
133
- const importerFileUrl =
134
- asOriginalUrl(importer, {
135
- projectDirectoryUrl,
136
- compileServerOrigin,
137
- compileDirectoryRelativeUrl,
138
- }) || importer
139
-
140
- const importResolution = await import.meta.resolve(specifier, importerFileUrl)
141
- return transformResolvedUrl(importResolution, {
142
- importer,
143
- projectDirectoryUrl,
144
- compileServerOrigin,
145
- compileDirectoryRelativeUrl,
146
- })
147
- }
148
-
149
- const resolveUsingNodeCommonJsAlgorithm = (
150
- specifier,
151
- {
152
- projectDirectoryUrl,
153
- compileServerOrigin,
154
- compileDirectoryRelativeUrl,
155
- importer,
156
- },
157
- ) => {
158
- const importerFileUrl =
159
- asOriginalUrl(importer, {
160
- projectDirectoryUrl,
161
- compileDirectoryRelativeUrl,
162
- compileServerOrigin,
163
- }) || importer
164
- const require = createRequire(importerFileUrl)
165
- const requireResolution = require.resolve(specifier)
166
- return transformResolvedUrl(requireResolution, {
167
- importer,
168
- projectDirectoryUrl,
169
- compileDirectoryRelativeUrl,
170
- compileServerOrigin,
171
- })
172
- }
173
-
174
- const transformResolvedUrl = (
175
- url,
176
- {
177
- importer,
178
- projectDirectoryUrl,
179
- compileServerOrigin,
180
- compileDirectoryRelativeUrl,
181
- },
182
- ) => {
183
- const compileServerUrl = compileServerUrlFromOriginalUrl(url, {
184
- importer,
185
- projectDirectoryUrl,
186
- compileDirectoryRelativeUrl,
187
- compileServerOrigin,
188
- })
189
- return compileServerUrl
190
- }
191
-
192
- const asProjectUrl = (url, { projectDirectoryUrl, compileServerOrigin }) => {
193
- if (url.startsWith(projectDirectoryUrl)) {
194
- return url
195
- }
196
-
197
- if (url.startsWith(compileServerOrigin)) {
198
- return `${projectDirectoryUrl}${url.slice(
199
- `${compileServerOrigin}/`.length,
200
- )}`
201
- }
202
-
203
- return null
204
- }
205
-
206
- const asOriginalUrl = (
207
- url,
208
- { projectDirectoryUrl, compileDirectoryRelativeUrl, compileServerOrigin },
209
- ) => {
210
- if (!url.startsWith(`${compileServerOrigin}/`)) {
211
- return url
212
- }
213
-
214
- if (url === compileServerOrigin) {
215
- return projectDirectoryUrl
216
- }
217
-
218
- const afterOrigin = url.slice(`${compileServerOrigin}/`.length)
219
- if (!afterOrigin.startsWith(compileDirectoryRelativeUrl)) {
220
- return url
221
- }
222
-
223
- const afterCompileDirectory = afterOrigin.slice(
224
- compileDirectoryRelativeUrl.length,
225
- )
226
- return resolveUrl(afterCompileDirectory, projectDirectoryUrl)
227
- }
228
-
229
- const compileServerUrlFromOriginalUrl = (
230
- url,
231
- {
232
- importer,
233
- projectDirectoryUrl,
234
- compileDirectoryRelativeUrl,
235
- compileServerOrigin,
236
- },
237
- ) => {
238
- if (!url.startsWith(projectDirectoryUrl)) {
239
- return url
240
- }
241
-
242
- // si l'importer était compilé, compile aussi le fichier
243
- const compileDirectoryServerUrl = resolveUrl(
244
- compileDirectoryRelativeUrl,
245
- compileServerOrigin,
246
- )
247
- if (importer.startsWith(compileDirectoryServerUrl)) {
248
- const projectRelativeUrl = urlToRelativeUrl(url, projectDirectoryUrl)
249
- return resolveUrl(projectRelativeUrl, compileDirectoryServerUrl)
250
- }
251
-
252
- const projectRelativeUrl = urlToRelativeUrl(url, projectDirectoryUrl)
253
- return resolveUrl(projectRelativeUrl, compileDirectoryServerUrl)
254
- }
@@ -1,37 +0,0 @@
1
- /**
2
- * allows the following:
3
- *
4
- * import "@jsenv/core/helpers/regenerator-runtime/regenerator-runtime.js"
5
- * -> searches a file inside @jsenv/core/*
6
- *
7
- */
8
-
9
- import { urlToRelativeUrl, urlIsInsideOf, resolveUrl } from "@jsenv/filesystem"
10
-
11
- import { jsenvCoreDirectoryUrl } from "@jsenv/core/src/jsenv_file_urls.js"
12
-
13
- export const getDefaultImportmap = (
14
- url,
15
- { projectDirectoryUrl, compileDirectoryUrl },
16
- ) => {
17
- const jsenvCoreDirectoryRelativeUrl = urlToRelativeUrl(
18
- jsenvCoreDirectoryUrl,
19
- projectDirectoryUrl,
20
- )
21
- let jsenvCoreUrl
22
- if (compileDirectoryUrl && urlIsInsideOf(url, compileDirectoryUrl)) {
23
- jsenvCoreUrl = resolveUrl(
24
- jsenvCoreDirectoryRelativeUrl,
25
- compileDirectoryUrl,
26
- )
27
- } else {
28
- jsenvCoreUrl = jsenvCoreDirectoryUrl
29
- }
30
- const jsenvCoreRelativeUrl = urlToRelativeUrl(jsenvCoreUrl, url)
31
- const importmap = {
32
- imports: {
33
- "@jsenv/core/": `./${jsenvCoreRelativeUrl}`,
34
- },
35
- }
36
- return importmap
37
- }
@@ -1,19 +0,0 @@
1
- import { readFile } from "@jsenv/filesystem"
2
-
3
- import { jsenvCoreDirectoryUrl } from "@jsenv/core/src/jsenv_file_urls.js"
4
-
5
- export const getJsenvBuildUrl = async (buildRelativeUrlWithoutHash) => {
6
- try {
7
- const manifest = await readFile(
8
- new URL("./dist/manifest.json", jsenvCoreDirectoryUrl),
9
- { as: "json" },
10
- )
11
- const buildRelativeUrl = manifest[buildRelativeUrlWithoutHash]
12
- return new URL(buildRelativeUrl, jsenvCoreDirectoryUrl).href
13
- } catch (e) {
14
- if (e.code === "ENOENT") {
15
- return null
16
- }
17
- throw e
18
- }
19
- }
@@ -1,12 +0,0 @@
1
- import {
2
- assertAndNormalizeDirectoryUrl,
3
- assertDirectoryPresence,
4
- } from "@jsenv/filesystem"
5
-
6
- export const assertProjectDirectoryUrl = ({ projectDirectoryUrl }) => {
7
- return assertAndNormalizeDirectoryUrl(projectDirectoryUrl)
8
- }
9
-
10
- export const assertProjectDirectoryExists = ({ projectDirectoryUrl }) => {
11
- assertDirectoryPresence(projectDirectoryUrl)
12
- }
@@ -1,156 +0,0 @@
1
- import {
2
- urlIsInsideOf,
3
- urlToRelativeUrl,
4
- urlToRessource,
5
- normalizeStructuredMetaMap,
6
- urlToMeta,
7
- writeFile,
8
- } from "@jsenv/filesystem"
9
- import { validateResponseIntegrity } from "@jsenv/integrity"
10
-
11
- import { fetchUrl } from "@jsenv/core/src/internal/fetching.js"
12
-
13
- import { originDirectoryConverter } from "./origin_directory_converter.js"
14
-
15
- export const createJsenvRemoteDirectory = ({
16
- projectDirectoryUrl,
17
- jsenvDirectoryRelativeUrl,
18
- preservedUrls,
19
- }) => {
20
- const jsenvRemoteDirectoryUrl = `${projectDirectoryUrl}${jsenvDirectoryRelativeUrl}.remote/`
21
- const structuredMetaMap = normalizeStructuredMetaMap(
22
- { preserved: preservedUrls },
23
- projectDirectoryUrl,
24
- )
25
- const isPreservedUrl = (url) => {
26
- const meta = urlToMeta({ url, structuredMetaMap })
27
- return Boolean(meta.preserved)
28
- }
29
-
30
- const jsenvRemoteDirectory = {
31
- isPreservedUrl,
32
-
33
- isRemoteUrl: (url) => {
34
- return url.startsWith("http://") || url.startsWith("https://")
35
- },
36
-
37
- isFileUrlForRemoteUrl: (url) => {
38
- return urlIsInsideOf(url, jsenvRemoteDirectoryUrl)
39
- },
40
-
41
- fileUrlFromRemoteUrl: (remoteUrl) => {
42
- const origin = originFromUrlOrUrlPattern(remoteUrl)
43
- const ressource = urlToRessource(remoteUrl)
44
- const [pathname, search = ""] = ressource.split("?")
45
- const directoryName = originDirectoryConverter.toDirectoryName(origin)
46
- const fileRelativeUrl = `${directoryName}${
47
- pathname === "" ? "/" : pathname
48
- }`
49
- const fileUrl = `${jsenvRemoteDirectoryUrl}${fileRelativeUrl}${search}`
50
- return fileUrl
51
- },
52
-
53
- remoteUrlFromFileUrl: (fileUrl) => {
54
- const fileRelativeUrl = urlToRelativeUrl(fileUrl, jsenvRemoteDirectoryUrl)
55
- const firstSlashIndex = fileRelativeUrl.indexOf("/")
56
- const directoryName = fileRelativeUrl.slice(0, firstSlashIndex)
57
- const origin = originDirectoryConverter.fromDirectoryName(directoryName)
58
- const ressource = fileRelativeUrl.slice(firstSlashIndex)
59
- const remoteUrlObject = new URL(ressource, origin)
60
- remoteUrlObject.searchParams.delete("integrity")
61
- const remoteUrl = remoteUrlObject.href
62
- return remoteUrl
63
- },
64
-
65
- loadFileUrlFromRemote: async (url, request) => {
66
- const urlObject = new URL(url)
67
- const integrity = urlObject.searchParams.get("integrity")
68
- if (integrity) {
69
- urlObject.searchParams.delete("integrity")
70
- }
71
- const remoteUrl = jsenvRemoteDirectory.remoteUrlFromFileUrl(
72
- urlObject.href,
73
- )
74
- const requestHeadersToForward = { ...request.headers }
75
- delete requestHeadersToForward.host
76
- const response = await fetchUrl(remoteUrl, {
77
- mode: "cors",
78
- headers: requestHeadersToForward,
79
- })
80
- if (response.status !== 200) {
81
- throw createRemoteFetchError({
82
- code: "UNEXPECTED_STATUS",
83
- message: `unexpected status for ressource "${remoteUrl}", received ${response.status}`,
84
- })
85
- }
86
- const responseBodyAsBuffer = Buffer.from(await response.arrayBuffer())
87
- if (integrity) {
88
- try {
89
- validateResponseIntegrity(
90
- {
91
- url: response.url,
92
- type: response.type,
93
- dataRepresentation: responseBodyAsBuffer,
94
- },
95
- integrity,
96
- )
97
- } catch (e) {
98
- throw createRemoteFetchError({
99
- code: e.code,
100
- message: e.message,
101
- })
102
- }
103
- }
104
- await writeFile(url, responseBodyAsBuffer)
105
- return responseBodyAsBuffer
106
- },
107
- }
108
-
109
- return jsenvRemoteDirectory
110
- }
111
-
112
- const createRemoteFetchError = ({ message, code }) => {
113
- const error = new Error(message)
114
- error.code = "UNEXPECTED_REMOTE_URL_RESPONSE"
115
- error.asResponse = () => {
116
- const data = {
117
- code,
118
- message,
119
- }
120
- const json = JSON.stringify(data)
121
- return {
122
- status: 502,
123
- statusText: "Bad Gateway",
124
- headers: {
125
- "cache-control": "no-store",
126
- "content-length": Buffer.byteLength(json),
127
- "content-type": "application/json",
128
- },
129
- body: json,
130
- }
131
- }
132
- return error
133
- }
134
-
135
- const originFromUrlOrUrlPattern = (url) => {
136
- if (url.startsWith("http://")) {
137
- const slashAfterProtocol = url.indexOf("/", "http://".length + 1)
138
- if (slashAfterProtocol === -1) {
139
- return url
140
- }
141
- const origin = url.slice(0, slashAfterProtocol)
142
- return origin
143
- }
144
- if (url.startsWith("https://")) {
145
- const slashAfterProtocol = url.indexOf("/", "https://".length + 1)
146
- if (slashAfterProtocol === -1) {
147
- return url
148
- }
149
- const origin = url.slice(0, slashAfterProtocol)
150
- return origin
151
- }
152
- if (url.startsWith("file://")) {
153
- return "file://"
154
- }
155
- return new URL(url).origin
156
- }
@@ -1,10 +0,0 @@
1
- import { createRequire } from "module"
2
-
3
- const require = createRequire(import.meta.url)
4
-
5
- // https://github.com/visionmedia/bytes.js/
6
- const bytes = require("bytes")
7
-
8
- export const formatByte = (metricValue) => {
9
- return bytes(metricValue, { decimalPlaces: 2, unitSeparator: " " })
10
- }
@@ -1,9 +0,0 @@
1
- import { require } from "@jsenv/core/src/internal/require.js"
2
-
3
- const bytes = require("bytes")
4
-
5
- // https://github.com/visionmedia/bytes.js
6
-
7
- export const byteAsFileSize = (metricValue) => {
8
- return bytes(metricValue, { decimalPlaces: 2, unitSeparator: " " })
9
- }
@@ -1,12 +0,0 @@
1
- import { require } from "@jsenv/core/src/internal/require.js"
2
-
3
- const humanizeDuration = require("humanize-duration")
4
-
5
- export const msAsDuration = (ms) => {
6
- return humanizeDuration(ms, {
7
- largest: 2,
8
- maxDecimalPoints: ms < 0.1 ? 3 : ms < 1000 ? 2 : ms < 60000 ? 1 : 0,
9
- delimiter: " and ",
10
- // units: ["s"]
11
- })
12
- }
@@ -1,24 +0,0 @@
1
- export const memoize = (compute) => {
2
- let memoized = false
3
- let memoizedValue
4
-
5
- const fnWithMemoization = (...args) => {
6
- if (memoized) {
7
- return memoizedValue
8
- }
9
- // if compute is recursive wait for it to be fully done before storing the lockValue
10
- // so set locked later
11
- memoizedValue = compute(...args)
12
- memoized = true
13
- return memoizedValue
14
- }
15
-
16
- fnWithMemoization.forget = () => {
17
- const value = memoizedValue
18
- memoized = false
19
- memoizedValue = undefined
20
- return value
21
- }
22
-
23
- return fnWithMemoization
24
- }
@@ -1,6 +0,0 @@
1
- import { Script } from "node:vm"
2
-
3
- export const evalSource = (code, filePath) => {
4
- const script = new Script(code, { filename: filePath })
5
- return script.runInThisContext()
6
- }
@@ -1,8 +0,0 @@
1
- import { fetchUrl } from "@jsenv/core/src/internal/fetching.js"
2
-
3
- export const fetchSource = (url, options) => {
4
- return fetchUrl(url, {
5
- ignoreHttpsError: true,
6
- ...options,
7
- })
8
- }
@@ -1,22 +0,0 @@
1
- import { ensureWindowsDriveLetter, resolveUrl } from "@jsenv/filesystem"
2
-
3
- import { require } from "@jsenv/core/src/internal/require.js"
4
- import { installErrorStackRemapping } from "@jsenv/core/src/internal/error_stack_remap/install_error_stack_remapping.js"
5
-
6
- import { fetchSource } from "./fetch_source.js"
7
-
8
- export const installNodeErrorStackRemapping = ({
9
- projectDirectoryUrl,
10
- ...options
11
- }) => {
12
- const { SourceMapConsumer } = require("source-map")
13
-
14
- return installErrorStackRemapping({
15
- SourceMapConsumer,
16
- fetchFile: fetchSource,
17
- resolveFile: (specifier, importer = projectDirectoryUrl) => {
18
- return ensureWindowsDriveLetter(resolveUrl(specifier, importer), importer)
19
- },
20
- ...options,
21
- })
22
- }