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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/main.js +4 -0
  2. package/package.json +17 -14
  3. package/readme.md +4 -12
  4. package/src/build/build.js +690 -429
  5. package/src/build/build_urls_generator.js +33 -21
  6. package/src/build/graph_utils.js +31 -0
  7. package/src/build/{inject_version_mappings.js → inject_global_version_mappings.js} +33 -15
  8. package/src/build/inject_service_worker_urls.js +79 -0
  9. package/src/build/resync_ressource_hints.js +68 -0
  10. package/src/build/start_build_server.js +201 -0
  11. package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +2 -2
  12. package/src/dev/plugins/toolbar/jsenv_plugin_toolbar.js +3 -1
  13. package/src/dev/start_dev_server.js +58 -26
  14. package/src/execute/execute.js +30 -4
  15. package/src/execute/run.js +19 -56
  16. package/src/execute/runtimes/browsers/from_playwright.js +201 -147
  17. package/src/execute/runtimes/node/controllable_file.mjs +26 -10
  18. package/src/execute/runtimes/node/node_execution_performance.js +67 -0
  19. package/src/execute/runtimes/node/node_process.js +280 -39
  20. package/src/omega/{runtime_support/default_runtime_support.js → compat/default_runtime_compat.js} +3 -5
  21. package/src/omega/{runtime_support/features_compatibility.js → compat/features_compats.js} +66 -4
  22. package/src/omega/compat/runtime_compat.js +50 -0
  23. package/src/omega/errors.js +51 -58
  24. package/src/omega/fetched_content_compliance.js +24 -0
  25. package/src/omega/file_url_converter.js +8 -50
  26. package/src/omega/kitchen.js +409 -286
  27. package/src/omega/server/file_service.js +9 -11
  28. package/src/omega/url_graph/url_graph_load.js +14 -7
  29. package/src/omega/url_graph/url_graph_report.js +17 -15
  30. package/src/omega/url_graph.js +32 -10
  31. package/src/omega/web_workers.js +42 -0
  32. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/autoreload_preference.js +0 -0
  33. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/event_source_client.js +2 -2
  34. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/reload.js +0 -0
  35. package/src/{dev/plugins/autoreload → plugins/autoreload/dev_sse}/client/url_helpers.js +0 -0
  36. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +41 -0
  37. package/src/{dev/plugins/autoreload/jsenv_plugin_autoreload.js → plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js} +27 -168
  38. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +25 -0
  39. package/src/plugins/autoreload/jsenv_plugin_hmr.js +35 -0
  40. package/src/plugins/bundling/css/bundle_css.js +21 -0
  41. package/src/plugins/bundling/js_classic_workers/bundle_js_classic_workers.js +13 -0
  42. package/src/{build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js → plugins/bundling/js_module/bundle_js_module.js} +120 -79
  43. package/src/plugins/bundling/jsenv_plugin_bundling.js +51 -0
  44. package/src/{omega/core_plugins → plugins}/commonjs_globals/jsenv_plugin_commonjs_globals.js +48 -41
  45. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +66 -0
  46. package/src/{omega/core_plugins → plugins}/filesystem_magic/jsenv_plugin_filesystem_magic.js +7 -4
  47. package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_document.js +0 -0
  48. package/src/{omega/core_plugins → plugins}/html_supervisor/client/error_in_notification.js +0 -0
  49. package/src/{omega/core_plugins → plugins}/html_supervisor/client/html_supervisor_installer.js +3 -2
  50. package/src/{omega/core_plugins → plugins}/html_supervisor/client/html_supervisor_setup.js +0 -0
  51. package/src/{omega/core_plugins → plugins}/html_supervisor/client/perf_browser.js +0 -0
  52. package/src/{omega/core_plugins → plugins}/html_supervisor/client/uneval_exception.js +0 -0
  53. package/src/{omega/core_plugins → plugins}/html_supervisor/jsenv_plugin_html_supervisor.js +38 -46
  54. package/src/plugins/http_urls/jsenv_plugin_http_urls.js +12 -0
  55. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/babel_plugin_metadata_import_meta_hot.js +4 -5
  56. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/client/import_meta_hot.js +3 -1
  57. package/src/{dev/plugins/autoreload → plugins/import_meta_hot}/html_hot_dependencies.js +2 -2
  58. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +98 -0
  59. package/src/{omega/core_plugins → plugins}/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +26 -8
  60. package/src/plugins/import_meta_url/client/import_meta_url_browser.js +52 -0
  61. package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +9 -0
  62. package/src/{omega/core_plugins → plugins}/importmap/jsenv_plugin_importmap.js +37 -31
  63. package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +25 -0
  64. package/src/{omega/core_plugins → plugins}/inline/client/inline_content.js +0 -0
  65. package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_data_urls.js +18 -14
  66. package/src/{omega/core_plugins/inline/jsenv_plugin_js_and_css_inside_html.js → plugins/inline/jsenv_plugin_html_inline_content.js} +61 -40
  67. package/src/plugins/inline/jsenv_plugin_inline.js +36 -0
  68. package/src/{omega/core_plugins → plugins}/inline/jsenv_plugin_inline_query_param.js +6 -6
  69. package/src/plugins/inline/jsenv_plugin_js_inline_content.js +263 -0
  70. package/src/plugins/leading_slash/jsenv_plugin_leading_slash.js +13 -0
  71. package/src/plugins/minification/css/minify_css.js +9 -0
  72. package/src/plugins/minification/html/minify_html.js +15 -0
  73. package/src/{build/plugins/minify_js/jsenv_plugin_minify_js.js → plugins/minification/js/minify_js.js} +6 -22
  74. package/src/plugins/minification/jsenv_plugin_minification.js +78 -0
  75. package/src/plugins/minification/json/minify_json.js +8 -0
  76. package/src/{omega/core_plugins → plugins}/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +15 -15
  77. package/src/{omega → plugins}/plugin_controller.js +18 -10
  78. package/src/plugins/plugins.js +73 -0
  79. package/src/plugins/transpilation/as_js_classic/client/s.js +808 -0
  80. package/src/plugins/transpilation/as_js_classic/client/s.js.md +1 -0
  81. package/src/plugins/transpilation/as_js_classic/helpers/babel_plugin_transform_import_meta_url.js +47 -0
  82. package/src/plugins/transpilation/as_js_classic/helpers/systemjs_old.js +43 -0
  83. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +183 -0
  84. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_script_type_module_as_classic.js +256 -0
  85. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_workers_type_module_as_classic.js +139 -0
  86. package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +0 -0
  87. package/src/{omega/core_plugins → plugins/transpilation}/babel/global_this/client/global_this.js +0 -0
  88. package/src/{omega/core_plugins/babel/babel_helper → plugins/transpilation/babel/helpers}/babel_plugin_babel_helpers_as_jsenv_imports.js +1 -2
  89. package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +161 -0
  90. package/src/{omega/core_plugins → plugins/transpilation}/babel/helpers/babel_plugins_compatibility.js +0 -0
  91. package/src/{omega/core_plugins → plugins/transpilation}/babel/jsenv_plugin_babel.js +38 -22
  92. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +30 -6
  93. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/.eslintrc.cjs +0 -0
  94. package/src/{omega/core_plugins → plugins/transpilation}/babel/new_stylesheet/client/new_stylesheet.js +0 -0
  95. package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +0 -0
  96. package/src/{omega/core_plugins → plugins/transpilation}/babel/regenerator_runtime/client/regenerator_runtime.js +0 -0
  97. package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +18 -0
  98. package/src/plugins/transpilation/fetch_original_url_info.js +30 -0
  99. package/src/{omega/core_plugins → plugins/transpilation}/import_assertions/helpers/babel_plugin_metadata_import_assertions.js +0 -0
  100. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +225 -0
  101. package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +37 -0
  102. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +44 -0
  103. package/src/plugins/url_references/css/css_urls.js +49 -0
  104. package/src/plugins/url_references/html/html_urls.js +273 -0
  105. package/src/plugins/url_references/js/js_urls.js +163 -0
  106. package/src/plugins/url_references/jsenv_plugin_url_references.js +18 -0
  107. package/src/plugins/url_references/webmanifest/webmanifest_urls.js +17 -0
  108. package/src/{omega/core_plugins → plugins}/url_resolution/jsenv_plugin_url_resolution.js +12 -5
  109. package/src/{omega/core_plugins → plugins}/url_version/jsenv_plugin_url_version.js +8 -8
  110. package/src/test/execute_plan.js +25 -11
  111. package/src/test/execute_test_plan.js +14 -1
  112. package/src/test/logs_file_execution.js +8 -7
  113. package/src/build/plugins/minify_html/jsenv_plugin_minify_html.js +0 -30
  114. package/src/dev/plugins/autoreload/client/event_source_connection.js +0 -195
  115. package/src/dev/plugins/autoreload/sse_service.js +0 -149
  116. package/src/execute/runtimes/node/controlled_process.js +0 -316
  117. package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +0 -29
  118. package/src/omega/core_plugins/babel/babel_helper/client/.eslintrc.cjs +0 -24
  119. package/src/omega/core_plugins/babel/babel_helper/client/AsyncGenerator/AsyncGenerator.js +0 -81
  120. package/src/omega/core_plugins/babel/babel_helper/client/AwaitValue/AwaitValue.js +0 -3
  121. package/src/omega/core_plugins/babel/babel_helper/client/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -33
  122. package/src/omega/core_plugins/babel/babel_helper/client/arrayLikeToArray/arrayLikeToArray.js +0 -7
  123. package/src/omega/core_plugins/babel/babel_helper/client/arrayWithHoles/arrayWithHoles.js +0 -4
  124. package/src/omega/core_plugins/babel/babel_helper/client/arrayWithoutHoles/arrayWithoutHoles.js +0 -6
  125. package/src/omega/core_plugins/babel/babel_helper/client/assertThisInitialized/assertThisInitialized.js +0 -7
  126. package/src/omega/core_plugins/babel/babel_helper/client/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -40
  127. package/src/omega/core_plugins/babel/babel_helper/client/asyncIterator/asyncIterator.js +0 -65
  128. package/src/omega/core_plugins/babel/babel_helper/client/asyncToGenerator/asyncToGenerator.js +0 -34
  129. package/src/omega/core_plugins/babel/babel_helper/client/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -5
  130. package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -20
  131. package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -6
  132. package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -13
  133. package/src/omega/core_plugins/babel/babel_helper/client/classCallCheck/classCallCheck.js +0 -5
  134. package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -5
  135. package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -6
  136. package/src/omega/core_plugins/babel/babel_helper/client/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -7
  137. package/src/omega/core_plugins/babel/babel_helper/client/classNameTDZError/classNameTDZError.js +0 -4
  138. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -7
  139. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldGet/classPrivateFieldGet.js +0 -7
  140. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -6
  141. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -5
  142. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldSet/classPrivateFieldSet.js +0 -8
  143. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodGet/classPrivateMethodGet.js +0 -6
  144. package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodSet/classPrivateMethodSet.js +0 -3
  145. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -9
  146. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -15
  147. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -6
  148. package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -3
  149. package/src/omega/core_plugins/babel/babel_helper/client/construct/construct.js +0 -16
  150. package/src/omega/core_plugins/babel/babel_helper/client/createClass/createClass.js +0 -15
  151. package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -60
  152. package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -23
  153. package/src/omega/core_plugins/babel/babel_helper/client/createRawReactElement/createRawReactElement.js +0 -50
  154. package/src/omega/core_plugins/babel/babel_helper/client/createSuper/createSuper.js +0 -22
  155. package/src/omega/core_plugins/babel/babel_helper/client/decorate/decorate.js +0 -403
  156. package/src/omega/core_plugins/babel/babel_helper/client/defaults/defaults.js +0 -11
  157. package/src/omega/core_plugins/babel/babel_helper/client/defineEnumerableProperties/defineEnumerableProperties.js +0 -23
  158. package/src/omega/core_plugins/babel/babel_helper/client/defineProperty/defineProperty.js +0 -18
  159. package/src/omega/core_plugins/babel/babel_helper/client/extends/extends.js +0 -14
  160. package/src/omega/core_plugins/babel/babel_helper/client/get/get.js +0 -19
  161. package/src/omega/core_plugins/babel/babel_helper/client/getPrototypeOf/getPrototypeOf.js +0 -4
  162. package/src/omega/core_plugins/babel/babel_helper/client/inherits/inherits.js +0 -19
  163. package/src/omega/core_plugins/babel/babel_helper/client/inheritsLoose/inheritsLoose.js +0 -7
  164. package/src/omega/core_plugins/babel/babel_helper/client/initializerDefineProperty/initializerDefineProperty.js +0 -10
  165. package/src/omega/core_plugins/babel/babel_helper/client/initializerWarningHelper/initializerWarningHelper.js +0 -6
  166. package/src/omega/core_plugins/babel/babel_helper/client/instanceof/instanceof.js +0 -6
  167. package/src/omega/core_plugins/babel/babel_helper/client/interopRequireDefault/interopRequireDefault.js +0 -3
  168. package/src/omega/core_plugins/babel/babel_helper/client/interopRequireWildcard/interopRequireWildcard.js +0 -37
  169. package/src/omega/core_plugins/babel/babel_helper/client/isNativeFunction/isNativeFunction.js +0 -4
  170. package/src/omega/core_plugins/babel/babel_helper/client/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -21
  171. package/src/omega/core_plugins/babel/babel_helper/client/iterableToArray/iterableToArray.js +0 -7
  172. package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimit/iterableToArrayLimit.js +0 -36
  173. package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -10
  174. package/src/omega/core_plugins/babel/babel_helper/client/jsx/jsx.js +0 -50
  175. package/src/omega/core_plugins/babel/babel_helper/client/maybeArrayLike/maybeArrayLike.js +0 -10
  176. package/src/omega/core_plugins/babel/babel_helper/client/newArrowCheck/newArrowCheck.js +0 -5
  177. package/src/omega/core_plugins/babel/babel_helper/client/nonIterableRest/nonIterableRest.js +0 -5
  178. package/src/omega/core_plugins/babel/babel_helper/client/nonIterableSpread/nonIterableSpread.js +0 -5
  179. package/src/omega/core_plugins/babel/babel_helper/client/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -3
  180. package/src/omega/core_plugins/babel/babel_helper/client/objectSpread/objectSpread.js +0 -23
  181. package/src/omega/core_plugins/babel/babel_helper/client/objectSpread2/objectSpread2.js +0 -41
  182. package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutProperties/objectWithoutProperties.js +0 -19
  183. package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -13
  184. package/src/omega/core_plugins/babel/babel_helper/client/possibleConstructorReturn/possibleConstructorReturn.js +0 -10
  185. package/src/omega/core_plugins/babel/babel_helper/client/readOnlyError/readOnlyError.js +0 -4
  186. package/src/omega/core_plugins/babel/babel_helper/client/readme.md +0 -8
  187. package/src/omega/core_plugins/babel/babel_helper/client/set/set.js +0 -44
  188. package/src/omega/core_plugins/babel/babel_helper/client/setPrototypeOf/setPrototypeOf.js +0 -6
  189. package/src/omega/core_plugins/babel/babel_helper/client/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -8
  190. package/src/omega/core_plugins/babel/babel_helper/client/slicedToArray/slicedToArray.js +0 -10
  191. package/src/omega/core_plugins/babel/babel_helper/client/slicedToArrayLoose/slicedToArrayLoose.js +0 -13
  192. package/src/omega/core_plugins/babel/babel_helper/client/superPropBase/superPropBase.js +0 -10
  193. package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -10
  194. package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -7
  195. package/src/omega/core_plugins/babel/babel_helper/client/tdz/tdz.js +0 -4
  196. package/src/omega/core_plugins/babel/babel_helper/client/temporalRef/temporalRef.js +0 -6
  197. package/src/omega/core_plugins/babel/babel_helper/client/temporalUndefined/temporalUndefined.js +0 -3
  198. package/src/omega/core_plugins/babel/babel_helper/client/toArray/toArray.js +0 -10
  199. package/src/omega/core_plugins/babel/babel_helper/client/toConsumableArray/toConsumableArray.js +0 -10
  200. package/src/omega/core_plugins/babel/babel_helper/client/toPrimitive/toPrimitive.js +0 -10
  201. package/src/omega/core_plugins/babel/babel_helper/client/toPropertyKey/toPropertyKey.js +0 -6
  202. package/src/omega/core_plugins/babel/babel_helper/client/typeof/typeof.js +0 -14
  203. package/src/omega/core_plugins/babel/babel_helper/client/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -12
  204. package/src/omega/core_plugins/babel/babel_helper/client/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -8
  205. package/src/omega/core_plugins/babel/babel_helper/client/wrapNativeSuper/wrapNativeSuper.js +0 -30
  206. package/src/omega/core_plugins/babel/babel_helper/client/wrapRegExp/wrapRegExp.js +0 -63
  207. package/src/omega/core_plugins/babel/babel_helper/client/writeOnlyError/writeOnlyError.js +0 -4
  208. package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +0 -187
  209. package/src/omega/core_plugins/file_urls/jsenv_plugin_file_urls.js +0 -67
  210. package/src/omega/core_plugins/import_assertions/helpers/json_module.js +0 -12
  211. package/src/omega/core_plugins/import_assertions/helpers/text_module.js +0 -6
  212. package/src/omega/core_plugins/import_assertions/jsenv_plugin_import_assertions.js +0 -211
  213. package/src/omega/core_plugins/inline/jsenv_plugin_inline.js +0 -13
  214. package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +0 -210
  215. package/src/omega/core_plugins/leading_slash/jsenv_plugin_leading_slash.js +0 -12
  216. package/src/omega/core_plugins.js +0 -39
  217. package/src/omega/runtime_support/runtime_support.js +0 -20
  218. package/src/omega/url_mentions/css_url_mentions.js +0 -63
  219. package/src/omega/url_mentions/html_url_mentions.js +0 -185
  220. package/src/omega/url_mentions/js_module_url_mentions.js +0 -91
  221. package/src/omega/url_mentions/parse_url_mentions.js +0 -37
  222. package/src/omega/url_mentions/worker_classic_url_mentions.js +0 -37
@@ -1,187 +0,0 @@
1
- import { createRequire } from "node:module"
2
-
3
- import { getBabelHelperFileUrl } from "../babel_helper/babel_helper_directory.js"
4
- import { babelPluginCompatMap } from "./babel_plugins_compatibility.js"
5
-
6
- const require = createRequire(import.meta.url)
7
-
8
- export const getBaseBabelPluginStructure = ({
9
- url,
10
- isSupportedOnRuntime,
11
- usesTopLevelAwait,
12
- // // https://github.com/rpetrich/babel-plugin-transform-async-to-promises/blob/92755ff8c943c97596523e586b5fa515c2e99326/async-to-promises.ts#L55
13
- topLevelAwait = "simple",
14
- isJsModule,
15
- }) => {
16
- const isBabelPluginNeeded = (babelPluginName) => {
17
- return !isSupportedOnRuntime(
18
- babelPluginName,
19
- babelPluginCompatMap[babelPluginName],
20
- )
21
- }
22
-
23
- const babelPluginStructure = {}
24
- if (isBabelPluginNeeded("proposal-numeric-separator")) {
25
- babelPluginStructure[
26
- "proposal-numeric-separator"
27
- ] = require("@babel/plugin-proposal-numeric-separator")
28
- }
29
- if (isBabelPluginNeeded("proposal-json-strings")) {
30
- babelPluginStructure[
31
- "proposal-json-strings"
32
- ] = require("@babel/plugin-proposal-json-strings")
33
- }
34
- if (isBabelPluginNeeded("proposal-object-rest-spread")) {
35
- babelPluginStructure[
36
- "proposal-object-rest-spread"
37
- ] = require("@babel/plugin-proposal-object-rest-spread")
38
- }
39
- if (isBabelPluginNeeded("proposal-optional-catch-binding")) {
40
- babelPluginStructure[
41
- "proposal-optional-catch-binding"
42
- ] = require("@babel/plugin-proposal-optional-catch-binding")
43
- }
44
- if (isBabelPluginNeeded("proposal-unicode-property-regex")) {
45
- babelPluginStructure[
46
- "proposal-unicode-property-regex"
47
- ] = require("@babel/plugin-proposal-unicode-property-regex")
48
- }
49
- if (
50
- isJsModule &&
51
- usesTopLevelAwait &&
52
- !isSupportedOnRuntime("top_level_await")
53
- ) {
54
- babelPluginStructure["transform-async-to-promises"] = [
55
- require("babel-plugin-transform-async-to-promises"),
56
- {
57
- topLevelAwait,
58
- },
59
- ]
60
- } else if (isBabelPluginNeeded("transform-async-to-promises")) {
61
- babelPluginStructure[
62
- "transform-async-to-promises"
63
- ] = require("babel-plugin-transform-async-to-promises")
64
- }
65
- if (isBabelPluginNeeded("transform-arrow-functions")) {
66
- babelPluginStructure[
67
- "transform-arrow-functions"
68
- ] = require("@babel/plugin-transform-arrow-functions")
69
- }
70
- if (isBabelPluginNeeded("transform-block-scoped-functions")) {
71
- babelPluginStructure[
72
- "transform-block-scoped-functions"
73
- ] = require("@babel/plugin-transform-block-scoped-functions")
74
- }
75
- if (isBabelPluginNeeded("transform-block-scoping")) {
76
- babelPluginStructure[
77
- "transform-block-scoping"
78
- ] = require("@babel/plugin-transform-block-scoping")
79
- }
80
- if (isBabelPluginNeeded("transform-classes")) {
81
- babelPluginStructure[
82
- "transform-classes"
83
- ] = require("@babel/plugin-transform-classes")
84
- }
85
- if (isBabelPluginNeeded("transform-computed-properties")) {
86
- babelPluginStructure[
87
- "transform-computed-properties"
88
- ] = require("@babel/plugin-transform-computed-properties")
89
- }
90
- if (isBabelPluginNeeded("transform-destructuring")) {
91
- babelPluginStructure[
92
- "transform-destructuring"
93
- ] = require("@babel/plugin-transform-destructuring")
94
- }
95
- if (isBabelPluginNeeded("transform-dotall-regex")) {
96
- babelPluginStructure[
97
- "transform-dotall-regex"
98
- ] = require("@babel/plugin-transform-dotall-regex")
99
- }
100
- if (isBabelPluginNeeded("transform-duplicate-keys")) {
101
- babelPluginStructure[
102
- "transform-duplicate-keys"
103
- ] = require("@babel/plugin-transform-duplicate-keys")
104
- }
105
- if (isBabelPluginNeeded("transform-exponentiation-operator")) {
106
- babelPluginStructure[
107
- "transform-exponentiation-operator"
108
- ] = require("@babel/plugin-transform-exponentiation-operator")
109
- }
110
- if (isBabelPluginNeeded("transform-for-of")) {
111
- babelPluginStructure[
112
- "transform-for-of"
113
- ] = require("@babel/plugin-transform-for-of")
114
- }
115
- if (isBabelPluginNeeded("transform-function-name")) {
116
- babelPluginStructure[
117
- "transform-function-name"
118
- ] = require("@babel/plugin-transform-function-name")
119
- }
120
- if (isBabelPluginNeeded("transform-literals")) {
121
- babelPluginStructure[
122
- "transform-literals"
123
- ] = require("@babel/plugin-transform-literals")
124
- }
125
- if (isBabelPluginNeeded("transform-new-target")) {
126
- babelPluginStructure[
127
- "transform-new-target"
128
- ] = require("@babel/plugin-transform-new-target")
129
- }
130
- if (isBabelPluginNeeded("transform-object-super")) {
131
- babelPluginStructure[
132
- "transform-object-super"
133
- ] = require("@babel/plugin-transform-object-super")
134
- }
135
- if (isBabelPluginNeeded("transform-parameters")) {
136
- babelPluginStructure[
137
- "transform-parameters"
138
- ] = require("@babel/plugin-transform-parameters")
139
- }
140
- if (isBabelPluginNeeded("transform-regenerator")) {
141
- babelPluginStructure["transform-regenerator"] = [
142
- require("@babel/plugin-transform-regenerator"),
143
- {
144
- asyncGenerators: true,
145
- generators: true,
146
- async: false,
147
- },
148
- ]
149
- }
150
- if (isBabelPluginNeeded("transform-shorthand-properties")) {
151
- babelPluginStructure["transform-shorthand-properties"] = [
152
- require("@babel/plugin-transform-shorthand-properties"),
153
- ]
154
- }
155
- if (isBabelPluginNeeded("transform-spread")) {
156
- babelPluginStructure["transform-spread"] = [
157
- require("@babel/plugin-transform-spread"),
158
- ]
159
- }
160
- if (isBabelPluginNeeded("transform-sticky-regex")) {
161
- babelPluginStructure["transform-sticky-regex"] = [
162
- require("@babel/plugin-transform-sticky-regex"),
163
- ]
164
- }
165
- if (isBabelPluginNeeded("transform-template-literals")) {
166
- babelPluginStructure["transform-template-literals"] = [
167
- require("@babel/plugin-transform-template-literals"),
168
- ]
169
- }
170
- if (
171
- isBabelPluginNeeded("transform-typeof-symbol") &&
172
- // prevent "typeof" to be injected into itself:
173
- // - not needed
174
- // - would create infinite attempt to transform typeof
175
- url !== getBabelHelperFileUrl("typeof")
176
- ) {
177
- babelPluginStructure["transform-typeof-symbol"] = [
178
- require("@babel/plugin-transform-typeof-symbol"),
179
- ]
180
- }
181
- if (isBabelPluginNeeded("transform-unicode-regex")) {
182
- babelPluginStructure["transform-unicode-regex"] = [
183
- require("@babel/plugin-transform-unicode-regex"),
184
- ]
185
- }
186
- return babelPluginStructure
187
- }
@@ -1,67 +0,0 @@
1
- import { readFileSync } from "node:fs"
2
- import { urlToContentType } from "@jsenv/server"
3
- import {
4
- urlIsInsideOf,
5
- urlToRelativeUrl,
6
- fileSystemRootUrl,
7
- } from "@jsenv/filesystem"
8
- import { ContentType } from "@jsenv/utils/src/content_type.js"
9
-
10
- export const jsenvPluginFileUrls = () => {
11
- return [jsenvPluginResolveAbsoluteFileUrls(), jsenvPluginLoadFileUrls()]
12
- }
13
-
14
- const jsenvPluginResolveAbsoluteFileUrls = () => {
15
- return {
16
- name: "jsenv:resolve_absolute_file_urls",
17
- appliesDuring: {
18
- // during dev and test it's a browser running the code
19
- // so absolute file urls needs to be relativized
20
- dev: true,
21
- test: true,
22
- // during build it's fine to use file:// urls
23
- build: false,
24
- },
25
- resolve: ({ specifier }, { rootDirectoryUrl }) => {
26
- if (!specifier.startsWith("/@fs/")) {
27
- return null
28
- }
29
- const url = new URL(specifier.slice("/@fs".length), rootDirectoryUrl).href
30
- return url
31
- },
32
- formatReferencedUrl: ({ url }, { rootDirectoryUrl }) => {
33
- if (!url.startsWith("file:")) {
34
- return null
35
- }
36
- const specifier = urlIsInsideOf(url, rootDirectoryUrl)
37
- ? `/${urlToRelativeUrl(url, rootDirectoryUrl)}`
38
- : `/@fs/${url.slice(fileSystemRootUrl.length)}`
39
- return specifier
40
- },
41
- }
42
- }
43
-
44
- const jsenvPluginLoadFileUrls = () => {
45
- return {
46
- name: "jsenv:load_file_urls",
47
- appliesDuring: "*",
48
- load: ({ url }) => {
49
- if (!url.startsWith("file:")) {
50
- return null
51
- }
52
- const urlObject = new URL(url)
53
- const fileBuffer = readFileSync(urlObject)
54
- const contentType = urlToContentType(url)
55
- if (ContentType.isTextual(contentType)) {
56
- return {
57
- contentType,
58
- content: String(fileBuffer),
59
- }
60
- }
61
- return {
62
- contentType,
63
- content: fileBuffer,
64
- }
65
- },
66
- }
67
- }
@@ -1,12 +0,0 @@
1
- export const convertJsonTextToJavascriptModule = ({ content }) => {
2
- // here we could do the following
3
- // return export default jsonText
4
- // This would return valid js, that would be minified later
5
- // however we will prefer using JSON.parse because it's faster
6
- // for js engine to parse JSON than JS
7
-
8
- return {
9
- contentType: "application/javascript",
10
- content: `export default JSON.parse(${JSON.stringify(content.trim())})`,
11
- }
12
- }
@@ -1,6 +0,0 @@
1
- export const convertTextToJavascriptModule = ({ content }) => {
2
- return {
3
- contentType: "application/javascript",
4
- content: `export default ${JSON.stringify(content)}`,
5
- }
6
- }
@@ -1,211 +0,0 @@
1
- import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
2
- import { ContentType } from "@jsenv/utils/src/content_type.js"
3
- import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
4
- import { injectQueryParamsIntoSpecifier } from "@jsenv/utils/urls/url_utils.js"
5
- import { JS_QUOTES } from "@jsenv/utils/string/js_quotes.js"
6
-
7
- import { babelPluginMetadataImportAssertions } from "./helpers/babel_plugin_metadata_import_assertions.js"
8
- import { convertJsonTextToJavascriptModule } from "./helpers/json_module.js"
9
- import { convertTextToJavascriptModule } from "./helpers/text_module.js"
10
-
11
- export const jsenvPluginImportAssertions = () => {
12
- const importAssertions = [
13
- {
14
- name: "jsenv:import_assertions",
15
- appliesDuring: "*",
16
- transform: {
17
- js_module: async (
18
- { url, generatedUrl, content },
19
- { scenario, isSupportedOnRuntime, referenceUtils },
20
- ) => {
21
- const importTypesToHandle = getImportTypesToHandle({
22
- scenario,
23
- isSupportedOnRuntime,
24
- })
25
- if (importTypesToHandle.length === 0) {
26
- return null
27
- }
28
- const { metadata } = await applyBabelPlugins({
29
- babelPlugins: [babelPluginMetadataImportAssertions],
30
- url,
31
- generatedUrl,
32
- content,
33
- })
34
- const { importAssertions } = metadata
35
- const magicSource = createMagicSource(content)
36
- importAssertions.forEach((importAssertion) => {
37
- const assertType = importAssertion.assert.type
38
- if (!importTypesToHandle.includes(assertType)) {
39
- return
40
- }
41
- const { path } = importAssertion
42
- const { node } = path
43
- const importType = `${assertType}_module`
44
- if (node.type === "CallExpression") {
45
- const importSpecifierPath = path.get("arguments")[0]
46
- const specifier = importSpecifierPath.node.value
47
- const newSpecifier = injectQueryParamsIntoSpecifier(specifier, {
48
- [importType]: "",
49
- })
50
- const [newReference, newUrlInfo] = referenceUtils.updateSpecifier(
51
- JSON.stringify(specifier),
52
- newSpecifier,
53
- )
54
- newUrlInfo.data.importType = importType
55
- magicSource.replace({
56
- start: importSpecifierPath.node.start,
57
- end: importSpecifierPath.node.end,
58
- replacement: newReference.generatedSpecifier,
59
- })
60
- const secondArgPath = path.get("arguments")[1]
61
- magicSource.remove({
62
- start: secondArgPath.node.start,
63
- end: secondArgPath.node.end,
64
- })
65
- return
66
- }
67
- const importSpecifierPath = path.get("source")
68
- const specifier = importSpecifierPath.node.value
69
- const newSpecifier = injectQueryParamsIntoSpecifier(specifier, {
70
- [importType]: "",
71
- })
72
- const [newReference, newUrlInfo] = referenceUtils.updateSpecifier(
73
- JSON.stringify(specifier),
74
- newSpecifier,
75
- )
76
- newUrlInfo.data.importType = importType
77
- magicSource.replace({
78
- start: importSpecifierPath.node.start,
79
- end: importSpecifierPath.node.end,
80
- replacement: newReference.generatedSpecifier,
81
- })
82
- const assertionsPath = path.get("assertions")[0]
83
- magicSource.remove({
84
- start: assertionsPath.node.start,
85
- end: assertionsPath.node.end,
86
- })
87
- })
88
- return magicSource.toContentAndSourcemap()
89
- },
90
- },
91
- },
92
- ]
93
-
94
- const importTypeJson = {
95
- name: "jsenv:import_type_json",
96
- appliesDuring: "*",
97
- finalize: ({ url, contentType, content }) => {
98
- if (!new URL(url).searchParams.has("json_module")) {
99
- return null
100
- }
101
- if (contentType !== "application/json") {
102
- throw new Error(
103
- `Unexpected content type on ${url}, should be "application/json" but got ${contentType}`,
104
- )
105
- }
106
- return convertJsonTextToJavascriptModule({
107
- content,
108
- })
109
- },
110
- }
111
-
112
- // not standard but I expect this to happen one day?
113
- const importTypeText = {
114
- name: "jsenv:import_type_text",
115
- appliesDuring: "*",
116
- finalize: ({ url, contentType, content }) => {
117
- if (!new URL(url).searchParams.has("text_module")) {
118
- return null
119
- }
120
- if (ContentType.isTextual(contentType)) {
121
- throw new Error(
122
- `Unexpected content type on ${url}, should be "text/*" but got ${contentType}`,
123
- )
124
- }
125
- return convertTextToJavascriptModule({
126
- content,
127
- })
128
- },
129
- }
130
-
131
- return [
132
- importAssertions,
133
- importTypeJson,
134
- jsenvPluginImportTypeCss(),
135
- importTypeText,
136
- ]
137
- }
138
-
139
- const jsenvPluginImportTypeCss = () => {
140
- const inlineContentClientFileUrl = new URL(
141
- "../inline/client/inline_content.js",
142
- import.meta.url,
143
- ).href
144
-
145
- return {
146
- name: "jsenv:import_type_css",
147
- appliesDuring: "*",
148
- // load the original css url
149
- load: ({ data }, { urlGraph, load }) => {
150
- if (data.importType !== "css_module") {
151
- return null
152
- }
153
- return load({
154
- reference: data.originalReference,
155
- urlInfo: urlGraph.getUrlInfo(data.originalReference.url),
156
- })
157
- },
158
- transform: ({ url, data, contentType, content }, { referenceUtils }) => {
159
- if (data.importType !== "css_module") {
160
- return null
161
- }
162
- if (contentType !== "text/css") {
163
- throw new Error(
164
- `Unexpected content type on ${url}, should be "text/css" but got ${contentType}`,
165
- )
166
- }
167
- const [reference] = referenceUtils.inject({
168
- type: "js_import_export",
169
- specifier: inlineContentClientFileUrl,
170
- })
171
- const cssText = JS_QUOTES.escapeSpecialChars(content, {
172
- // If template string is choosen and runtime do not support template literals
173
- // it's ok because "jsenv:new_inline_content" plugin executes after this one
174
- // and convert template strings into raw strings
175
- canUseTemplateString: true,
176
- })
177
- return {
178
- type: "js_module",
179
- contentType: "application/javascript",
180
- content: `import { InlineContent } from ${reference.generatedSpecifier}
181
-
182
- const css = new InlineContent(${cssText}, { type: "text/css" })
183
- const stylesheet = new CSSStyleSheet()
184
- stylesheet.replaceSync(css.text)
185
- export default stylesheet`,
186
- }
187
- },
188
- }
189
- }
190
-
191
- const getImportTypesToHandle = ({ scenario, isSupportedOnRuntime }) => {
192
- // during build always replace import assertions with the js:
193
- // - means rollup can bundle more js file together
194
- // - means url versioning can work for css inlined in js
195
- // - avoid rollup to see import assertions
196
- // We would have to tell rollup to ignore import with assertion
197
- if (scenario === "build") {
198
- return ["json", "css", "text"]
199
- }
200
- const importTypes = []
201
- if (!isSupportedOnRuntime("import_type_json")) {
202
- importTypes.push("json")
203
- }
204
- if (!isSupportedOnRuntime("import_type_css")) {
205
- importTypes.push("css")
206
- }
207
- if (!isSupportedOnRuntime("import_type_text")) {
208
- importTypes.push("text")
209
- }
210
- return importTypes
211
- }
@@ -1,13 +0,0 @@
1
- import { jsenvPluginJsAndCssInsideHtml } from "./jsenv_plugin_js_and_css_inside_html.js"
2
- import { jsenvPluginNewInlineContent } from "./jsenv_plugin_new_inline_content.js"
3
- import { jsenvPluginDataUrls } from "./jsenv_plugin_data_urls.js"
4
- import { jsenvPluginInlineQueryParam } from "./jsenv_plugin_inline_query_param.js"
5
-
6
- export const jsenvPluginInline = ({ allowEscapeForVersioning } = {}) => {
7
- return [
8
- jsenvPluginJsAndCssInsideHtml(),
9
- jsenvPluginNewInlineContent({ allowEscapeForVersioning }),
10
- jsenvPluginDataUrls(),
11
- jsenvPluginInlineQueryParam(),
12
- ]
13
- }