@jsenv/core 26.0.1 → 27.0.0-alpha.2

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 +737 -0
  5. package/src/build/build_urls_generator.js +64 -0
  6. package/src/build/inject_version_mappings.js +62 -0
  7. package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +225 -0
  8. package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +30 -0
  9. package/src/build/plugins/minify_js/jsenv_plugin_minify_js.js +47 -0
  10. package/src/dev/plugins/autoreload/babel_plugin_metadata_import_meta_hot.js +98 -0
  11. package/src/dev/plugins/autoreload/client/autoreload_preference.js +11 -0
  12. package/src/dev/plugins/autoreload/client/event_source_client.js +186 -0
  13. package/src/{internal/dev_server/event_source_client → dev/plugins/autoreload/client}/event_source_connection.js +21 -25
  14. package/src/dev/plugins/autoreload/client/import_meta_hot.js +80 -0
  15. package/src/dev/plugins/autoreload/client/reload.js +101 -0
  16. package/src/dev/plugins/autoreload/client/url_helpers.js +20 -0
  17. package/src/dev/plugins/autoreload/html_hot_dependencies.js +156 -0
  18. package/src/dev/plugins/autoreload/jsenv_plugin_autoreload.js +374 -0
  19. package/src/dev/plugins/autoreload/sse_service.js +149 -0
  20. package/src/dev/plugins/explorer/client/explorer.html +607 -0
  21. package/src/{internal → dev/plugins/explorer/client}/jsenv.png +0 -0
  22. package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +74 -0
  23. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/animation/toolbar_animation.js +0 -0
  24. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/eventsource/eventsource.css +2 -2
  25. package/src/dev/plugins/toolbar/client/eventsource/toolbar_eventsource.js +57 -0
  26. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/execution/execution.css +0 -0
  27. package/src/dev/plugins/toolbar/client/execution/toolbar_execution.js +88 -0
  28. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/focus.css +0 -0
  29. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/focus/toolbar_focus.js +0 -0
  30. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/jsenv_logo.svg +0 -0
  31. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/notification/toolbar_notification.js +0 -0
  32. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/overflow_menu.css +0 -0
  33. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/responsive/toolbar_responsive.js +0 -0
  34. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/settings.css +0 -0
  35. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/settings/toolbar_settings.js +1 -0
  36. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/jsenv_theme.css +1 -15
  37. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/light_theme.css +0 -17
  38. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/theme/toolbar_theme.js +0 -0
  39. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar.html +40 -199
  40. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_injector.js +8 -28
  41. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.css +0 -24
  42. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/toolbar_main.js +10 -56
  43. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.css +1 -1
  44. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/tooltip/tooltip.js +0 -0
  45. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/animation.js +0 -0
  46. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/dom.js +0 -0
  47. package/src/{internal/browser_utils → dev/plugins/toolbar/client/util}/fetch_using_xhr.js +0 -0
  48. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/fetching.js +2 -4
  49. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/iframe_to_parent_href.js +0 -0
  50. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/jsenv_logger.js +0 -0
  51. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/preferences.js +0 -0
  52. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/responsive.js +0 -0
  53. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/util/util.js +0 -0
  54. package/src/{internal/dev_server/toolbar → dev/plugins/toolbar/client}/variant/variant.js +0 -0
  55. package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +62 -0
  56. package/src/dev/start_dev_server.js +105 -0
  57. package/src/execute/execute.js +132 -0
  58. package/src/execute/run.js +208 -0
  59. package/src/execute/runtimes/browsers/chromium.js +8 -0
  60. package/src/execute/runtimes/browsers/firefox.js +7 -0
  61. package/src/execute/runtimes/browsers/from_playwright.js +464 -0
  62. package/src/{browser_runtimes.js → execute/runtimes/browsers/webkit.js} +4 -18
  63. package/src/{internal/node_launcher/child_process_options.js → execute/runtimes/node/child_exec_options.js} +25 -36
  64. package/src/{internal/node_launcher/node_controllable_file.mjs → execute/runtimes/node/controllable_file.mjs} +1 -18
  65. package/src/{internal/node_launcher/node_controllable_process.js → execute/runtimes/node/controlled_process.js} +128 -150
  66. package/src/execute/runtimes/node/exec_options.js +44 -0
  67. package/src/{internal/node_launcher → execute/runtimes/node}/kill_process_tree.js +3 -1
  68. package/src/execute/runtimes/node/node_process.js +92 -0
  69. package/src/execute/runtimes/node/node_worker_thread.js +28 -0
  70. package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +29 -0
  71. package/src/{internal/compile_server/js → omega/core_plugins/babel/babel_helper}/babel_plugin_babel_helpers_as_jsenv_imports.js +15 -19
  72. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/.eslintrc.cjs +0 -0
  73. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AsyncGenerator/AsyncGenerator.js +0 -0
  74. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/AwaitValue/AwaitValue.js +0 -0
  75. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -0
  76. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayLikeToArray/arrayLikeToArray.js +0 -0
  77. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithHoles/arrayWithHoles.js +0 -0
  78. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/arrayWithoutHoles/arrayWithoutHoles.js +0 -0
  79. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/assertThisInitialized/assertThisInitialized.js +0 -0
  80. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -0
  81. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncIterator/asyncIterator.js +0 -0
  82. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/asyncToGenerator/asyncToGenerator.js +0 -0
  83. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -0
  84. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -0
  85. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -0
  86. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -0
  87. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCallCheck/classCallCheck.js +0 -0
  88. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -0
  89. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -0
  90. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -0
  91. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classNameTDZError/classNameTDZError.js +0 -0
  92. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -0
  93. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldGet/classPrivateFieldGet.js +0 -0
  94. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -0
  95. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -0
  96. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateFieldSet/classPrivateFieldSet.js +0 -0
  97. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodGet/classPrivateMethodGet.js +0 -0
  98. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classPrivateMethodSet/classPrivateMethodSet.js +0 -0
  99. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -0
  100. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -0
  101. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -0
  102. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -0
  103. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/construct/construct.js +0 -0
  104. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createClass/createClass.js +0 -0
  105. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -0
  106. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -0
  107. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createRawReactElement/createRawReactElement.js +0 -0
  108. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/createSuper/createSuper.js +0 -0
  109. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/decorate/decorate.js +0 -0
  110. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defaults/defaults.js +0 -0
  111. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineEnumerableProperties/defineEnumerableProperties.js +0 -0
  112. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/defineProperty/defineProperty.js +0 -0
  113. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/extends/extends.js +0 -0
  114. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/get/get.js +0 -0
  115. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/getPrototypeOf/getPrototypeOf.js +0 -0
  116. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inherits/inherits.js +0 -0
  117. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/inheritsLoose/inheritsLoose.js +0 -0
  118. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerDefineProperty/initializerDefineProperty.js +0 -0
  119. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/initializerWarningHelper/initializerWarningHelper.js +0 -0
  120. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/instanceof/instanceof.js +0 -0
  121. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireDefault/interopRequireDefault.js +0 -0
  122. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/interopRequireWildcard/interopRequireWildcard.js +0 -0
  123. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeFunction/isNativeFunction.js +0 -0
  124. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -0
  125. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArray/iterableToArray.js +0 -0
  126. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimit/iterableToArrayLimit.js +0 -0
  127. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -0
  128. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/jsx/jsx.js +0 -0
  129. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/maybeArrayLike/maybeArrayLike.js +0 -0
  130. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/newArrowCheck/newArrowCheck.js +0 -0
  131. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableRest/nonIterableRest.js +0 -0
  132. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/nonIterableSpread/nonIterableSpread.js +0 -0
  133. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -0
  134. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread/objectSpread.js +0 -0
  135. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectSpread2/objectSpread2.js +0 -0
  136. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutProperties/objectWithoutProperties.js +0 -0
  137. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -0
  138. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/possibleConstructorReturn/possibleConstructorReturn.js +0 -0
  139. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readOnlyError/readOnlyError.js +0 -0
  140. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/readme.md +0 -0
  141. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/set/set.js +0 -0
  142. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/setPrototypeOf/setPrototypeOf.js +0 -0
  143. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -0
  144. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArray/slicedToArray.js +0 -0
  145. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/slicedToArrayLoose/slicedToArrayLoose.js +0 -0
  146. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/superPropBase/superPropBase.js +0 -0
  147. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -0
  148. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -0
  149. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/tdz/tdz.js +0 -0
  150. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalRef/temporalRef.js +0 -0
  151. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/temporalUndefined/temporalUndefined.js +0 -0
  152. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toArray/toArray.js +0 -0
  153. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toConsumableArray/toConsumableArray.js +0 -0
  154. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPrimitive/toPrimitive.js +0 -0
  155. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/toPropertyKey/toPropertyKey.js +0 -0
  156. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/typeof/typeof.js +0 -0
  157. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -0
  158. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -0
  159. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapNativeSuper/wrapNativeSuper.js +0 -0
  160. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/wrapRegExp/wrapRegExp.js +0 -0
  161. package/{helpers/babel → src/omega/core_plugins/babel/babel_helper/client}/writeOnlyError/writeOnlyError.js +0 -0
  162. package/src/omega/core_plugins/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +35 -0
  163. package/{helpers/global-this/global-this.js → src/omega/core_plugins/babel/global_this/client/global_this.js} +0 -0
  164. package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +187 -0
  165. package/src/{internal/features → omega/core_plugins/babel/helpers}/babel_plugins_compatibility.js +1 -24
  166. package/src/omega/core_plugins/babel/jsenv_plugin_babel.js +97 -0
  167. package/src/omega/core_plugins/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +117 -0
  168. package/src/omega/core_plugins/babel/new_stylesheet/client/.eslintrc.cjs +24 -0
  169. package/{helpers/new_stylesheet → src/omega/core_plugins/babel/new_stylesheet/client}/new_stylesheet.js +0 -0
  170. package/src/omega/core_plugins/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +34 -0
  171. package/{helpers/regenerator-runtime/regenerator-runtime.js → src/omega/core_plugins/babel/regenerator_runtime/client/regenerator_runtime.js} +0 -0
  172. package/src/omega/core_plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +169 -0
  173. package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +67 -0
  174. package/src/omega/core_plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +58 -0
  175. package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_document.js +10 -16
  176. package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/error_in_notification.js +0 -0
  177. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_installer.js +168 -0
  178. package/src/omega/core_plugins/html_supervisor/client/html_supervisor_setup.js +77 -0
  179. package/src/{internal/browser_client → omega/core_plugins/html_supervisor/client}/perf_browser.js +0 -0
  180. package/src/{internal/runtime_client → omega/core_plugins/html_supervisor/client}/uneval_exception.js +0 -0
  181. package/src/omega/core_plugins/html_supervisor/jsenv_plugin_html_supervisor.js +233 -0
  182. package/src/omega/core_plugins/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +98 -0
  183. package/src/{internal/building/import_assertions → omega/core_plugins/import_assertions/helpers}/json_module.js +3 -2
  184. package/src/omega/core_plugins/import_assertions/helpers/text_module.js +6 -0
  185. package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +211 -0
  186. package/src/omega/core_plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +80 -0
  187. package/src/omega/core_plugins/importmap/jsenv_plugin_importmap.js +212 -0
  188. package/src/omega/core_plugins/inline/client/inline_content.js +6 -0
  189. package/src/omega/core_plugins/inline/jsenv_plugin_data_urls.js +70 -0
  190. package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +13 -0
  191. package/src/omega/core_plugins/inline/jsenv_plugin_inline_query_param.js +42 -0
  192. package/src/omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js +142 -0
  193. package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +210 -0
  194. package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +12 -0
  195. package/src/omega/core_plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +77 -0
  196. package/src/omega/core_plugins/url_resolution/jsenv_plugin_url_resolution.js +28 -0
  197. package/src/omega/core_plugins/url_version/jsenv_plugin_url_version.js +50 -0
  198. package/src/omega/core_plugins.js +39 -0
  199. package/src/omega/errors.js +168 -0
  200. package/src/omega/file_url_converter.js +63 -0
  201. package/src/omega/kitchen.js +777 -0
  202. package/src/omega/omega_server.js +129 -0
  203. package/src/omega/plugin_controller.js +240 -0
  204. package/src/omega/runtime_support/default_runtime_support.js +13 -0
  205. package/src/omega/runtime_support/features_compatibility.js +91 -0
  206. package/src/omega/runtime_support/runtime_support.js +20 -0
  207. package/src/omega/server/file_service.js +155 -0
  208. package/src/omega/server/user_agent.js +22 -0
  209. package/src/omega/url_graph/url_graph_load.js +68 -0
  210. package/src/omega/url_graph/url_graph_report.js +151 -0
  211. package/src/omega/url_graph/url_graph_sort.js +29 -0
  212. package/src/omega/url_graph/url_info_transformations.js +161 -0
  213. package/src/omega/url_graph.js +132 -0
  214. package/src/omega/url_mentions/css_url_mentions.js +63 -0
  215. package/src/omega/url_mentions/html_url_mentions.js +185 -0
  216. package/src/omega/url_mentions/js_module_url_mentions.js +91 -0
  217. package/src/omega/url_mentions/parse_url_mentions.js +37 -0
  218. package/src/omega/url_mentions/worker_classic_url_mentions.js +37 -0
  219. package/src/{internal/executing → test}/execute_plan.js +154 -211
  220. package/src/{execute_test_plan.js → test/execute_test_plan.js} +26 -81
  221. package/src/{internal/executing → test}/execution_colors.js +0 -0
  222. package/src/{internal/executing → test}/execution_steps.js +2 -8
  223. package/src/{internal/executing → test}/gc.js +0 -0
  224. package/src/test/logs_file_execution.js +223 -0
  225. package/dist/browser_client/asset-manifest.json +0 -4
  226. package/dist/browser_client/browser_client_fb33eaa4.js +0 -5320
  227. package/dist/browser_client/browser_client_fb33eaa4.js.map +0 -1089
  228. package/dist/build_manifest.js +0 -12
  229. package/dist/compile_proxy/asset-manifest.json +0 -4
  230. package/dist/compile_proxy/compile_proxy.html__inline__20_651d1e7b.js.map +0 -343
  231. package/dist/compile_proxy/compile_proxy_62f952c4.html +0 -2245
  232. package/dist/event_source_client/asset-manifest.json +0 -4
  233. package/dist/event_source_client/event_source_client_69f48287.js +0 -354
  234. package/dist/event_source_client/event_source_client_69f48287.js.map +0 -128
  235. package/dist/redirector/asset-manifest.json +0 -4
  236. package/dist/redirector/redirector.html__inline__12_171e07b4.js.map +0 -349
  237. package/dist/redirector/redirector_8117ec92.html +0 -2290
  238. package/dist/toolbar/asset-manifest.json +0 -13
  239. package/dist/toolbar/assets/compilation.css_7421bd55.map +0 -12
  240. package/dist/toolbar/assets/eventsource.css_c0c71e7b.map +0 -12
  241. package/dist/toolbar/assets/execution.css_f3377c10.map +0 -12
  242. package/dist/toolbar/assets/focus.css_896f3e45.map +0 -12
  243. package/dist/toolbar/assets/light_theme.css_5bff0336.map +0 -12
  244. package/dist/toolbar/assets/overflow_menu.css_9a0fc3d8.map +0 -12
  245. package/dist/toolbar/assets/settings.css_942b5a9e.map +0 -12
  246. package/dist/toolbar/assets/toolbar_main.css_b1c67dd7.map +0 -28
  247. package/dist/toolbar/assets/tooltip.css_a94a8bdd.map +0 -12
  248. package/dist/toolbar/toolbar_b0c9100c.html +0 -4976
  249. package/dist/toolbar/toolbar_main_f54c1bb0.js.map +0 -776
  250. package/dist/toolbar_injector/asset-manifest.json +0 -5
  251. package/dist/toolbar_injector/assets/jsenv_logo_192011c2.svg +0 -95
  252. package/dist/toolbar_injector/toolbar_injector_65b501eb.js +0 -976
  253. package/dist/toolbar_injector/toolbar_injector_65b501eb.js.map +0 -294
  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,269 +0,0 @@
1
- import { timeStart, timeFunction } from "@jsenv/server"
2
- import { urlToFileSystemPath, readFile } from "@jsenv/filesystem"
3
- import { createDetailedMessage } from "@jsenv/logger"
4
-
5
- import { validateCompileCache } from "./validate_compile_cache.js"
6
- import { getMetaJsonFileUrl } from "./compile_asset.js"
7
- import { createLockRegistry } from "./file_lock_registry.js"
8
-
9
- const { lockForRessource } = createLockRegistry()
10
-
11
- export const reuseOrCreateCompiledFile = async ({
12
- logger,
13
-
14
- projectDirectoryUrl,
15
- originalFileUrl,
16
- compiledFileUrl = originalFileUrl,
17
- jsenvRemoteDirectory,
18
-
19
- compileCacheStrategy,
20
- compileCacheSourcesValidation,
21
- compileCacheAssetsValidation,
22
- request,
23
- compile,
24
- }) => {
25
- if (typeof projectDirectoryUrl !== "string") {
26
- throw new TypeError(
27
- `projectDirectoryUrl must be a string, got ${projectDirectoryUrl}`,
28
- )
29
- }
30
- if (typeof originalFileUrl !== "string") {
31
- throw new TypeError(
32
- `originalFileUrl must be a string, got ${originalFileUrl}`,
33
- )
34
- }
35
- if (!originalFileUrl.startsWith(projectDirectoryUrl)) {
36
- throw new Error(
37
- createDetailedMessage(`origin file must be inside project`, {
38
- ["original file url"]: originalFileUrl,
39
- ["project directory url"]: projectDirectoryUrl,
40
- }),
41
- )
42
- }
43
- if (typeof compiledFileUrl !== "string") {
44
- throw new TypeError(
45
- `compiledFileUrl must be a string, got ${compiledFileUrl}`,
46
- )
47
- }
48
- if (!compiledFileUrl.startsWith(projectDirectoryUrl)) {
49
- throw new Error(
50
- createDetailedMessage(`compiled file must be inside project`, {
51
- ["compiled file url"]: compiledFileUrl,
52
- ["project directory url"]: projectDirectoryUrl,
53
- }),
54
- )
55
- }
56
- if (typeof compile !== "function") {
57
- throw new TypeError(`compile must be a function, got ${compile}`)
58
- }
59
-
60
- const lockTimeEnd = timeStart("lock")
61
- return startAsap(
62
- async () => {
63
- const lockTiming = lockTimeEnd()
64
- const { meta, compileResult, compileResultStatus, timing } =
65
- await computeCompileReport({
66
- projectDirectoryUrl,
67
- originalFileUrl,
68
- compiledFileUrl,
69
- jsenvRemoteDirectory,
70
-
71
- compile,
72
- compileCacheStrategy,
73
- compileCacheSourcesValidation,
74
- compileCacheAssetsValidation,
75
- request,
76
- logger,
77
- })
78
-
79
- return {
80
- meta,
81
- compileResult,
82
- compileResultStatus,
83
- timing: {
84
- ...lockTiming,
85
- ...timing,
86
- },
87
- }
88
- },
89
- {
90
- compiledFileUrl,
91
- logger,
92
- },
93
- )
94
- }
95
-
96
- const computeCompileReport = async ({
97
- // projectDirectoryUrl,
98
- logger,
99
- originalFileUrl,
100
- compiledFileUrl,
101
- jsenvRemoteDirectory,
102
-
103
- compile,
104
- compileCacheStrategy,
105
- compileCacheSourcesValidation,
106
- compileCacheAssetsValidation,
107
- request,
108
- }) => {
109
- const [readCacheTiming, cacheValidity] = await timeFunction(
110
- "read cache",
111
- () => {
112
- // if (!useFilesystemAsCache) {
113
- // return {
114
- // isValid: false,
115
- // code: "META_FILE_NOT_FOUND",
116
- // meta: {
117
- // isValid: false,
118
- // code: "META_FILE_NOT_FOUND",
119
- // },
120
- // }
121
- // }
122
- return validateCompileCache({
123
- logger,
124
- compiledFileUrl,
125
- compileCacheStrategy,
126
- compileCacheSourcesValidation,
127
- compileCacheAssetsValidation,
128
- request,
129
- })
130
- },
131
- )
132
-
133
- if (!cacheValidity.isValid) {
134
- if (cacheValidity.code === "SOURCES_EMPTY") {
135
- logger.warn(`WARNING: meta.sources is empty for ${compiledFileUrl}`)
136
- }
137
-
138
- const metaIsValid = cacheValidity.meta ? cacheValidity.meta.isValid : false
139
-
140
- const fetchOriginalFile = async () => {
141
- // The original file might be behind an http url.
142
- // In that case jsenv try first to read file from filesystem
143
- // in ".jsenv/.http/" directory. If not found, the url
144
- // is fetched and file is written in that ".jsenv/.http/" directory.
145
- // After that the only way to re-fetch this ressource is
146
- // to delete the content of ".jsenv/.http/"
147
- try {
148
- const code = await readFile(originalFileUrl)
149
- return { code }
150
- } catch (e) {
151
- // when file is not found and the file is referenced with an http url
152
- if (
153
- e &&
154
- e.code === "ENOENT" &&
155
- jsenvRemoteDirectory.isFileUrlForRemoteUrl(originalFileUrl)
156
- ) {
157
- const responseBodyAsBuffer =
158
- await jsenvRemoteDirectory.loadFileUrlFromRemote(
159
- originalFileUrl,
160
- request,
161
- )
162
- const code = String(responseBodyAsBuffer)
163
- return { code }
164
- }
165
- throw e
166
- }
167
- }
168
- const { code } = await fetchOriginalFile()
169
- const [compileTiming, compileResult] = await timeFunction("compile", () =>
170
- callCompile({
171
- logger,
172
- originalFileUrl,
173
- code,
174
- compile,
175
- }),
176
- )
177
-
178
- return {
179
- meta: metaIsValid ? cacheValidity.meta.data : null,
180
- compileResult,
181
- compileResultStatus: metaIsValid ? "updated" : "created",
182
- timing: {
183
- ...readCacheTiming,
184
- ...compileTiming,
185
- },
186
- }
187
- }
188
-
189
- const meta = cacheValidity.meta.data
190
- const { contentType, sources, assets, dependencies } = meta
191
- return {
192
- meta,
193
- compileResult: {
194
- compiledSource: String(
195
- cacheValidity.compiledFile.data.compiledSourceBuffer,
196
- ),
197
- compiledEtag: cacheValidity.compiledFile.data.compiledEtag,
198
- compiledMtime: cacheValidity.compiledFile.data.compiledMtime,
199
- contentType,
200
- sources,
201
- assets,
202
- dependencies,
203
- },
204
- compileResultStatus: "cached",
205
- timing: {
206
- ...readCacheTiming,
207
- },
208
- }
209
- }
210
-
211
- const callCompile = async ({ logger, code, originalFileUrl, compile }) => {
212
- logger.debug(`compile ${originalFileUrl}`)
213
- const compileReturnValue = await compile({ code })
214
- if (typeof compileReturnValue !== "object" || compileReturnValue === null) {
215
- throw new TypeError(
216
- `compile must return an object, got ${compileReturnValue}`,
217
- )
218
- }
219
- const {
220
- contentType,
221
- compiledSource,
222
- sources = [],
223
- sourcesContent = [],
224
- assets = [],
225
- assetsContent = [],
226
- dependencies = [],
227
- responseHeaders,
228
- } = compileReturnValue
229
- if (typeof contentType !== "string") {
230
- throw new TypeError(
231
- `compile must return a contentType string, got ${contentType}`,
232
- )
233
- }
234
- if (typeof compiledSource !== "string") {
235
- throw new TypeError(
236
- `compile must return a compiledSource string, got ${compiledSource}`,
237
- )
238
- }
239
- return {
240
- contentType,
241
- compiledSource,
242
- sources,
243
- sourcesContent,
244
- assets,
245
- assetsContent,
246
- dependencies,
247
- responseHeaders,
248
- }
249
- }
250
-
251
- const startAsap = async (fn, { logger, compiledFileUrl }) => {
252
- const metaJsonFileUrl = getMetaJsonFileUrl(compiledFileUrl)
253
- const metaJsonFilePath = urlToFileSystemPath(metaJsonFileUrl)
254
-
255
- logger.debug(`lock ${metaJsonFilePath}`)
256
- // in case this process try to concurrently access meta we wait for previous to be done
257
- const unlockLocal = await lockForRessource(metaJsonFilePath)
258
-
259
- let unlockInterProcessLock = () => {}
260
-
261
- try {
262
- return await fn()
263
- } finally {
264
- // we want to unlock in case of error too
265
- logger.debug(`unlock ${metaJsonFilePath}`)
266
- unlockLocal()
267
- unlockInterProcessLock()
268
- }
269
- }
@@ -1,131 +0,0 @@
1
- import {
2
- urlToRelativeUrl,
3
- urlToFileSystemPath,
4
- bufferToEtag,
5
- } from "@jsenv/filesystem"
6
- import { utimesSync } from "node:fs"
7
-
8
- import { writeFileContent, testFilePresence } from "./fs_optimized_for_cache.js"
9
- import { getMetaJsonFileUrl } from "./compile_asset.js"
10
-
11
- export const updateCompileCache = async ({
12
- logger,
13
- jsenvDirectory,
14
- meta,
15
- compiledFileUrl,
16
- compileResult,
17
- compileResultStatus,
18
- }) => {
19
- const isNew = compileResultStatus === "created"
20
- const isUpdated = compileResultStatus === "updated"
21
- if (!isNew && !isUpdated) {
22
- return
23
- }
24
- const {
25
- compiledSource,
26
- contentType,
27
- sources,
28
- sourcesContent,
29
- assets,
30
- assetsContent,
31
- dependencies,
32
- } = compileResult
33
- const promises = []
34
- // ensure source that does not leads to concrete files are not capable to invalidate the cache
35
- const sourcesToRemove = sources.filter((sourceFileUrl) => {
36
- return (
37
- sourceFileUrl.startsWith("file://") && !testFilePresence(sourceFileUrl)
38
- )
39
- })
40
- const sourceNotFoundCount = sourcesToRemove.length
41
- if (sourceNotFoundCount > 0) {
42
- logger.warn(`SOURCE_META_NOT_FOUND: ${sourceNotFoundCount} source file(s) not found.
43
- --- consequence ---
44
- cache will be reused even if one of the source file is modified
45
- --- source files not found ---
46
- ${sourcesToRemove.join(`\n`)}`)
47
- sourcesToRemove.forEach((url) => {
48
- const sourceIndex = sources.indexOf(url)
49
- if (sourceIndex) {
50
- sources.splice(sourceIndex, 1)
51
- sourcesContent.splice(sourceIndex, 1)
52
- }
53
- })
54
- }
55
- const { writeCompiledSourceFile = true, writeAssetsFile = true } =
56
- compileResult
57
- if (writeCompiledSourceFile) {
58
- logger.debug(
59
- `write compiled file at ${urlToFileSystemPath(compiledFileUrl)}`,
60
- )
61
- promises.push(
62
- writeFileContent(compiledFileUrl, compiledSource, {
63
- fileLikelyNotFound: isNew,
64
- }).then(() => {
65
- const mtime = compileResult.compiledMtime
66
- // when compileResult.compiledMtime do not exists it means
67
- // the client is not interested in it so
68
- // -> moment we write the file is not important
69
- // -> There is no need to update mtime
70
- if (mtime) {
71
- utimesSync(
72
- urlToFileSystemPath(compiledFileUrl),
73
- new Date(mtime),
74
- new Date(mtime),
75
- )
76
- }
77
- }),
78
- )
79
- }
80
- if (writeAssetsFile) {
81
- promises.push(
82
- ...assets.map((assetFileUrl, index) => {
83
- logger.debug(
84
- `write compiled file asset at ${urlToFileSystemPath(assetFileUrl)}`,
85
- )
86
- return writeFileContent(assetFileUrl, assetsContent[index], {
87
- fileLikelyNotFound: isNew,
88
- })
89
- }),
90
- )
91
- }
92
- const metaJsonFileUrl = getMetaJsonFileUrl(compiledFileUrl)
93
- let latestMeta
94
- const sourceAndAssetProps = {
95
- sources: sources.map((source) => urlToRelativeUrl(source, metaJsonFileUrl)),
96
- sourcesEtag: sourcesContent.map((sourceContent) =>
97
- bufferToEtag(Buffer.from(sourceContent)),
98
- ),
99
- assets: assets.map((asset) => urlToRelativeUrl(asset, metaJsonFileUrl)),
100
- assetsEtag: assetsContent.map((assetContent) =>
101
- bufferToEtag(Buffer.from(assetContent)),
102
- ),
103
- dependencies: dependencies.filter((dep) => {
104
- return !dep.startsWith("data:")
105
- }),
106
- }
107
- if (isNew) {
108
- latestMeta = {
109
- contentType,
110
- ...sourceAndAssetProps,
111
- createdMs: Number(Date.now()),
112
- lastModifiedMs: Number(Date.now()),
113
- }
114
- } else if (isUpdated) {
115
- latestMeta = {
116
- ...meta,
117
- ...sourceAndAssetProps,
118
- lastModifiedMs: Number(Date.now()),
119
- }
120
- }
121
- logger.debug(
122
- `write compiled file meta at ${urlToFileSystemPath(metaJsonFileUrl)}`,
123
- )
124
- promises.push(
125
- writeFileContent(metaJsonFileUrl, JSON.stringify(latestMeta, null, " "), {
126
- fileLikelyNotFound: isNew,
127
- }),
128
- )
129
- promises.push(jsenvDirectory.compiledFileWriteSignal.onwrite())
130
- await Promise.all(promises)
131
- }
@@ -1,264 +0,0 @@
1
- import { fileURLToPath } from "node:url"
2
- import { readFileSync, statSync } from "node:fs"
3
- import { resolveUrl, bufferToEtag } from "@jsenv/filesystem"
4
-
5
- export const validateCompileCache = async ({
6
- compiledFileUrl,
7
- compileCacheStrategy,
8
- compileCacheSourcesValidation = true,
9
- // When "compileCacheAssetsValidation" is enabled, code ensures that
10
- // - asset file exists
11
- // - asset file content matches an etag generated when the file was compiled
12
- // In practice a compiled file asset is a sourcemap file or a coverage.json file.
13
- // It's unlikely that something or someone would update an asset file
14
- // and even when it happens it would be a bit strict to invalidate the cache
15
- // so by default "compileCacheAssetsValidation" is disabled
16
- // to avoid checking things for nothing
17
- compileCacheAssetsValidation = false,
18
- request,
19
- }) => {
20
- const validity = { isValid: true }
21
-
22
- const metaJsonFileUrl = `${compiledFileUrl}__asset__meta.json`
23
- const metaValidity = await validateMetaFile(metaJsonFileUrl)
24
- mergeValidity(validity, "meta", metaValidity)
25
- if (!validity.isValid) {
26
- return validity
27
- }
28
-
29
- const compiledFileValidation = await validateCompiledFile({
30
- compiledFileUrl,
31
- request,
32
- compileCacheStrategy,
33
- })
34
- mergeValidity(validity, "compiledFile", compiledFileValidation)
35
- if (!validity.isValid) {
36
- return validity
37
- }
38
-
39
- const meta = metaValidity.data
40
- const [sourcesValidity, assetsValidity] = await Promise.all([
41
- compileCacheSourcesValidation
42
- ? validateSources({
43
- meta,
44
- metaJsonFileUrl,
45
- })
46
- : { isValid: true, code: "SOURCES_VALIDATION_DISABLED" },
47
- compileCacheAssetsValidation
48
- ? validateAssets({
49
- meta,
50
- metaJsonFileUrl,
51
- })
52
- : { isValid: true, code: "ASSETS_VALIDATION_DISABLED" },
53
- ])
54
- mergeValidity(validity, "sources", sourcesValidity)
55
- if (!validity.valid) {
56
- return validity
57
- }
58
- mergeValidity(validity, "assets", assetsValidity)
59
-
60
- return validity
61
- }
62
-
63
- const mergeValidity = (parentValidity, childValidityName, childValidity) => {
64
- parentValidity.isValid = childValidity.isValid
65
- if (childValidity.code) parentValidity.code = childValidity.code
66
- parentValidity[childValidityName] = childValidity
67
- }
68
-
69
- const validateMetaFile = async (metaJsonFileUrl) => {
70
- const validity = { isValid: true, data: {} }
71
-
72
- let metaJsonBuffer
73
- try {
74
- metaJsonBuffer = readFileSync(fileURLToPath(metaJsonFileUrl))
75
- } catch (error) {
76
- if (error && error.code === "ENOENT") {
77
- validity.isValid = false
78
- validity.code = "META_FILE_NOT_FOUND"
79
- return validity
80
- }
81
- throw error
82
- }
83
-
84
- const metaJsonString = String(metaJsonBuffer)
85
- let meta
86
- try {
87
- meta = JSON.parse(metaJsonString)
88
- } catch (error) {
89
- if (error && error.name === "SyntaxError") {
90
- validity.isValid = false
91
- validity.code = "META_FILE_SYNTAX_ERROR"
92
- return validity
93
- }
94
- throw error
95
- }
96
-
97
- validity.data = meta
98
- if (meta.sources.length === 0) {
99
- validity.isValid = false
100
- validity.code = "SOURCES_EMPTY"
101
- return validity
102
- }
103
-
104
- return validity
105
- }
106
-
107
- const validateCompiledFile = async ({
108
- compiledFileUrl,
109
- compileCacheStrategy,
110
- request,
111
- }) => {
112
- const validity = { isValid: true, data: {} }
113
-
114
- const clientCacheDisabled = request.headers["cache-control"] === "no-cache"
115
-
116
- try {
117
- const compiledSourceBuffer = readFileSync(fileURLToPath(compiledFileUrl))
118
- validity.data.compiledSourceBuffer = compiledSourceBuffer
119
-
120
- if (!clientCacheDisabled && compileCacheStrategy === "etag") {
121
- const compiledEtag = bufferToEtag(compiledSourceBuffer)
122
- validity.data.compiledEtag = compiledEtag
123
- const ifNoneMatch = request.headers["if-none-match"]
124
- if (ifNoneMatch && ifNoneMatch !== compiledEtag) {
125
- validity.isValid = false
126
- validity.code = "COMPILED_FILE_ETAG_MISMATCH"
127
- return validity
128
- }
129
- }
130
-
131
- if (!clientCacheDisabled && compileCacheStrategy === "mtime") {
132
- const stats = statSync(fileURLToPath(compiledFileUrl))
133
- const compiledMtime = Math.floor(stats.mtimeMs)
134
- validity.data.compiledMtime = compiledMtime
135
-
136
- const ifModifiedSince = request.headers["if-modified-since"]
137
- let ifModifiedSinceDate
138
- try {
139
- ifModifiedSinceDate = new Date(ifModifiedSince)
140
- } catch (e) {
141
- ifModifiedSinceDate = null
142
- // ideally we should rather respond with
143
- // 400 "if-modified-since header is not a valid date"
144
- }
145
-
146
- if (
147
- ifModifiedSinceDate &&
148
- ifModifiedSinceDate < dateToSecondsPrecision(compiledMtime)
149
- ) {
150
- validity.isValid = false
151
- validity.code = "COMPILED_FILE_MTIME_OUTDATED"
152
- return validity
153
- }
154
- }
155
-
156
- return validity
157
- } catch (error) {
158
- if (error && error.code === "ENOENT") {
159
- validity.isValid = false
160
- validity.code = "COMPILED_FILE_NOT_FOUND"
161
- return validity
162
- }
163
- throw error
164
- }
165
- }
166
-
167
- const validateSources = async ({ meta, metaJsonFileUrl }) => {
168
- const sourcesValidity = { isValid: true }
169
- await Promise.all(
170
- meta.sources.map(async (source, index) => {
171
- const sourceValidity = await validateSource({
172
- metaJsonFileUrl,
173
- source,
174
- eTag: meta.sourcesEtag[index],
175
- })
176
- mergeValidity(sourcesValidity, source, sourceValidity)
177
- }),
178
- )
179
- return sourcesValidity
180
- }
181
-
182
- const validateSource = async ({ metaJsonFileUrl, source, eTag }) => {
183
- const validity = { isValid: true, data: {} }
184
- const sourceFileUrl = resolveUrl(source, metaJsonFileUrl)
185
-
186
- try {
187
- const sourceBuffer = readFileSync(fileURLToPath(sourceFileUrl))
188
- const sourceETag = bufferToEtag(sourceBuffer)
189
- validity.data.sourceBuffer = sourceBuffer
190
- validity.data.sourceETag = sourceETag
191
-
192
- if (sourceETag !== eTag) {
193
- validity.isValid = false
194
- validity.code = "SOURCE_ETAG_MISMATCH"
195
- return validity
196
- }
197
-
198
- return validity
199
- } catch (e) {
200
- if (e && e.code === "ENOENT") {
201
- // missing source invalidates the cache because
202
- // we cannot check its validity
203
- // HOWEVER inside writeMeta we will check if a source can be found
204
- // when it cannot we will not put it as a dependency
205
- // to invalidate the cache.
206
- // It is important because some files are constructed on other files
207
- // which are not truly on the filesystem
208
- // (IN theory the above happens only for convertCommonJsWithRollup because jsenv
209
- // always have a concrete file especially to avoid that kind of thing)
210
- validity.isValid = false
211
- validity.code = "SOURCE_NOT_FOUND"
212
- return validity
213
- }
214
- throw e
215
- }
216
- }
217
-
218
- const validateAssets = async ({ metaJsonFileUrl, meta }) => {
219
- const assetsValidity = { isValid: true }
220
- await Promise.all(
221
- meta.assets.map(async (asset, index) => {
222
- const assetValidity = await validateAsset({
223
- asset,
224
- metaJsonFileUrl,
225
- eTag: meta.assetsEtag[index],
226
- })
227
- mergeValidity(assetsValidity, asset, assetValidity)
228
- }),
229
- )
230
- return assetsValidity
231
- }
232
-
233
- const validateAsset = async ({ asset, metaJsonFileUrl, eTag }) => {
234
- const validity = { isValid: true, data: {} }
235
- const assetFileUrl = resolveUrl(asset, metaJsonFileUrl)
236
-
237
- try {
238
- const assetBuffer = readFileSync(fileURLToPath(assetFileUrl))
239
- const assetContentETag = bufferToEtag(assetBuffer)
240
- validity.data.buffer = assetBuffer
241
- validity.data.etag = assetContentETag
242
-
243
- if (eTag !== assetContentETag) {
244
- validity.isValid = false
245
- validity.code = "ASSET_ETAG_MISMATCH"
246
- return validity
247
- }
248
-
249
- return validity
250
- } catch (error) {
251
- if (error && error.code === "ENOENT") {
252
- validity.isValid = false
253
- validity.code = "ASSET_FILE_NOT_FOUND"
254
- return validity
255
- }
256
- throw error
257
- }
258
- }
259
-
260
- const dateToSecondsPrecision = (date) => {
261
- const dateWithSecondsPrecision = new Date(date)
262
- dateWithSecondsPrecision.setMilliseconds(0)
263
- return dateWithSecondsPrecision
264
- }