@jsenv/core 27.0.0-alpha.62 → 27.0.0-alpha.65

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 (169) hide show
  1. package/dist/html/explorer.html +557 -0
  2. package/dist/js/controllable_file.mjs +227 -0
  3. package/dist/{event_source_client.js → js/event_source_client.js} +19 -244
  4. package/dist/js/global_this.js +32 -0
  5. package/dist/js/html_supervisor_installer.js +522 -0
  6. package/dist/js/html_supervisor_setup.js +79 -0
  7. package/dist/{import_meta_hot.js → js/import_meta_hot.js} +1 -3
  8. package/dist/js/inline_content.js +8 -0
  9. package/dist/js/new_stylesheet.js +409 -0
  10. package/dist/js/regenerator_runtime.js +721 -0
  11. package/dist/js/s.js +429 -0
  12. package/dist/main.js +13362 -0
  13. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/AsyncGenerator/AsyncGenerator.js +95 -0
  14. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/AwaitValue/AwaitValue.js +3 -0
  15. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +29 -0
  16. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +9 -0
  17. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/arrayWithHoles/arrayWithHoles.js +4 -0
  18. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +5 -0
  19. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/assertThisInitialized/assertThisInitialized.js +8 -0
  20. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +52 -0
  21. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/asyncIterator/asyncIterator.js +78 -0
  22. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/asyncToGenerator/asyncToGenerator.js +39 -0
  23. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +4 -0
  24. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +24 -0
  25. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +7 -0
  26. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +14 -0
  27. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classCallCheck/classCallCheck.js +5 -0
  28. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -0
  29. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -0
  30. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +8 -0
  31. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classNameTDZError/classNameTDZError.js +4 -0
  32. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -0
  33. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -0
  34. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +7 -0
  35. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -0
  36. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -0
  37. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +7 -0
  38. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +3 -0
  39. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -0
  40. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +9 -0
  41. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -0
  42. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -0
  43. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/construct/construct.js +15 -0
  44. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createClass/createClass.js +18 -0
  45. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +63 -0
  46. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +22 -0
  47. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createRawReactElement/createRawReactElement.js +50 -0
  48. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createSuper/createSuper.js +22 -0
  49. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/decorate/decorate.js +622 -0
  50. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/defaults/defaults.js +14 -0
  51. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +26 -0
  52. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/defineProperty/defineProperty.js +19 -0
  53. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/extends/extends.js +16 -0
  54. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/get/get.js +21 -0
  55. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -0
  56. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/inherits/inherits.js +21 -0
  57. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/inheritsLoose/inheritsLoose.js +6 -0
  58. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +10 -0
  59. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +3 -0
  60. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/instanceof/instanceof.js +7 -0
  61. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/interopRequireDefault/interopRequireDefault.js +5 -0
  62. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +49 -0
  63. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/isNativeFunction/isNativeFunction.js +4 -0
  64. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -0
  65. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/iterableToArray/iterableToArray.js +3 -0
  66. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +38 -0
  67. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +13 -0
  68. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/jsx/jsx.js +49 -0
  69. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/maybeArrayLike/maybeArrayLike.js +10 -0
  70. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/newArrowCheck/newArrowCheck.js +5 -0
  71. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/nonIterableRest/nonIterableRest.js +3 -0
  72. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/nonIterableSpread/nonIterableSpread.js +3 -0
  73. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -0
  74. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectSpread/objectSpread.js +22 -0
  75. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectSpread2/objectSpread2.js +41 -0
  76. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +20 -0
  77. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +15 -0
  78. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +10 -0
  79. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/readOnlyError/readOnlyError.js +4 -0
  80. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/readme.md +8 -0
  81. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/set/set.js +51 -0
  82. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/setPrototypeOf/setPrototypeOf.js +5 -0
  83. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -0
  84. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/slicedToArray/slicedToArray.js +5 -0
  85. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +7 -0
  86. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/superPropBase/superPropBase.js +10 -0
  87. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +11 -0
  88. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +8 -0
  89. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/tdz/tdz.js +4 -0
  90. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/temporalRef/temporalRef.js +5 -0
  91. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/temporalUndefined/temporalUndefined.js +3 -0
  92. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toArray/toArray.js +5 -0
  93. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toConsumableArray/toConsumableArray.js +5 -0
  94. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toPrimitive/toPrimitive.js +14 -0
  95. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toPropertyKey/toPropertyKey.js +5 -0
  96. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/typeof/typeof.js +7 -0
  97. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -0
  98. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +7 -0
  99. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +35 -0
  100. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/wrapRegExp/wrapRegExp.js +67 -0
  101. package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/writeOnlyError/writeOnlyError.js +4 -0
  102. package/dist/other/jsenv.png +0 -0
  103. package/main.js +1 -0
  104. package/package.json +18 -14
  105. package/src/build/build.js +169 -69
  106. package/src/build/build_urls_generator.js +18 -2
  107. package/src/build/inject_global_version_mappings.js +18 -5
  108. package/src/build/inject_service_worker_urls.js +1 -1
  109. package/src/build/resync_ressource_hints.js +56 -9
  110. package/src/build/start_build_server.js +41 -30
  111. package/src/dev/plugins/explorer/client/explorer.html +1 -1
  112. package/src/dev/start_dev_server.js +21 -5
  113. package/src/execute/execute.js +3 -0
  114. package/src/execute/runtimes/browsers/from_playwright.js +10 -0
  115. package/src/execute/runtimes/node/node_process.js +8 -0
  116. package/src/omega/errors.js +10 -7
  117. package/src/omega/kitchen.js +251 -340
  118. package/src/omega/server/file_service.js +34 -17
  119. package/src/omega/url_graph/url_graph_load.js +10 -17
  120. package/src/omega/url_graph/url_graph_report.js +2 -2
  121. package/src/omega/url_graph/url_info_transformations.js +1 -4
  122. package/src/omega/url_graph.js +7 -3
  123. package/src/omega/url_specifier_encoding.js +59 -0
  124. package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +5 -10
  125. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +1 -3
  126. package/src/plugins/bundling/js_module/bundle_js_module.js +66 -24
  127. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +171 -53
  128. package/src/plugins/html_supervisor/client/html_supervisor_installer.js +1 -1
  129. package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +9 -13
  130. package/src/plugins/http_urls/jsenv_plugin_http_urls.js +6 -6
  131. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +5 -10
  132. package/src/plugins/importmap/jsenv_plugin_importmap.js +2 -4
  133. package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +51 -42
  134. package/src/plugins/inline/jsenv_plugin_data_urls.js +1 -4
  135. package/src/plugins/inline/jsenv_plugin_html_inline_content.js +3 -5
  136. package/src/plugins/inline/jsenv_plugin_inline_query_param.js +1 -4
  137. package/src/plugins/inline/jsenv_plugin_js_inline_content.js +1 -4
  138. package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +16 -2
  139. package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +12 -0
  140. package/src/plugins/plugin_controller.js +17 -3
  141. package/src/plugins/plugins.js +15 -15
  142. package/src/plugins/transpilation/as_js_classic/client/s.js +362 -807
  143. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +20 -10
  144. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +302 -0
  145. package/src/plugins/transpilation/as_js_classic/{jsenv_plugin_workers_type_module_as_classic.js → jsenv_plugin_as_js_classic_workers.js} +2 -2
  146. package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +5 -2
  147. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +1 -2
  148. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +2 -0
  149. package/src/plugins/url_analysis/html/html_urls.js +3 -0
  150. package/src/plugins/url_analysis/js/js_urls.js +2 -1
  151. package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +87 -1
  152. package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +3 -0
  153. package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +0 -3
  154. package/src/test/execute_plan.js +34 -13
  155. package/src/test/execute_test_plan.js +2 -0
  156. package/src/test/logs_file_execution.js +47 -38
  157. package/dist/event_source_client.js.map +0 -188
  158. package/dist/html_supervisor_installer.js +0 -1236
  159. package/dist/html_supervisor_installer.js.map +0 -337
  160. package/dist/html_supervisor_setup.js +0 -95
  161. package/dist/html_supervisor_setup.js.map +0 -57
  162. package/dist/import_meta_hot.js.map +0 -42
  163. package/src/jsenv_root_directory_url.js +0 -1
  164. package/src/omega/compat/default_runtime_compat.js +0 -11
  165. package/src/plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +0 -61
  166. package/src/plugins/transpilation/as_js_classic/client/s.js.md +0 -1
  167. package/src/plugins/transpilation/as_js_classic/jsenv_plugin_script_type_module_as_classic.js +0 -270
  168. package/src/plugins/transpilation/babel/new_stylesheet/client/.eslintrc.cjs +0 -24
  169. package/src/plugins/transpilation/fetch_original_url_info.js +0 -30
@@ -19,31 +19,42 @@ import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
19
19
  import { injectQueryParams } from "@jsenv/utils/urls/url_utils.js"
20
20
  import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
21
21
  import { composeTwoSourcemaps } from "@jsenv/utils/sourcemap/sourcemap_composition_v3.js"
22
+ import { fetchOriginalUrlInfo } from "@jsenv/utils/graph/fetch_original_url_info.js"
22
23
 
23
- import { fetchOriginalUrlInfo } from "../fetch_original_url_info.js"
24
24
  import { babelPluginTransformImportMetaUrl } from "./helpers/babel_plugin_transform_import_meta_url.js"
25
- import { jsenvPluginScriptTypeModuleAsClassic } from "./jsenv_plugin_script_type_module_as_classic.js"
26
- import { jsenvPluginWorkersTypeModuleAsClassic } from "./jsenv_plugin_workers_type_module_as_classic.js"
25
+ import { jsenvPluginAsJsClassicHtml } from "./jsenv_plugin_as_js_classic_html.js"
26
+ import { jsenvPluginAsJsClassicWorkers } from "./jsenv_plugin_as_js_classic_workers.js"
27
27
 
28
28
  const require = createRequire(import.meta.url)
29
29
 
30
30
  export const jsenvPluginAsJsClassic = ({ systemJsInjection }) => {
31
- const systemJsClientFileUrl = new URL("./client/s.js", import.meta.url).href
31
+ const systemJsClientFileUrl = new URL(
32
+ "./client/s.js?js_classic",
33
+ import.meta.url,
34
+ ).href
32
35
 
33
36
  return [
34
- asJsClassic({ systemJsInjection, systemJsClientFileUrl }),
35
- jsenvPluginScriptTypeModuleAsClassic({
37
+ jsenvPluginAsJsClassicConversion({
38
+ systemJsInjection,
39
+ systemJsClientFileUrl,
40
+ }),
41
+ jsenvPluginAsJsClassicHtml({
36
42
  systemJsInjection,
37
43
  systemJsClientFileUrl,
38
44
  generateJsClassicFilename,
39
45
  }),
40
- jsenvPluginWorkersTypeModuleAsClassic({
46
+ jsenvPluginAsJsClassicWorkers({
41
47
  generateJsClassicFilename,
42
48
  }),
43
49
  ]
44
50
  }
45
51
 
46
- const asJsClassic = ({ systemJsInjection, systemJsClientFileUrl }) => {
52
+ // propagate ?as_js_classic to referenced urls
53
+ // and perform the conversion during fetchUrlContent
54
+ const jsenvPluginAsJsClassicConversion = ({
55
+ systemJsInjection,
56
+ systemJsClientFileUrl,
57
+ }) => {
47
58
  const propagateJsClassicSearchParam = (reference, context) => {
48
59
  const parentUrlInfo = context.urlGraph.getUrlInfo(reference.parentUrl)
49
60
  if (
@@ -60,9 +71,8 @@ const asJsClassic = ({ systemJsInjection, systemJsClientFileUrl }) => {
60
71
  }
61
72
 
62
73
  return {
63
- name: "jsenv:as_js_classic",
74
+ name: "jsenv:as_js_classic_conversion",
64
75
  appliesDuring: "*",
65
- // forward ?as_js_classic to referenced urls
66
76
  redirectUrl: {
67
77
  // We want to propagate transformation of js module to js classic to:
68
78
  // - import specifier (static/dynamic import + re-export)
@@ -0,0 +1,302 @@
1
+ import {
2
+ getHtmlNodeAttributeByName,
3
+ getHtmlNodeTextNode,
4
+ parseHtmlString,
5
+ removeHtmlNodeAttributeByName,
6
+ assignHtmlNodeAttributes,
7
+ stringifyHtmlAst,
8
+ visitHtmlAst,
9
+ htmlNodePosition,
10
+ setHtmlNodeGeneratedText,
11
+ injectScriptAsEarlyAsPossible,
12
+ createHtmlNode,
13
+ } from "@jsenv/utils/html_ast/html_ast.js"
14
+ import { generateInlineContentUrl } from "@jsenv/utils/urls/inline_content_url_generator.js"
15
+ import { injectQueryParamsIntoSpecifier } from "@jsenv/utils/urls/url_utils.js"
16
+
17
+ export const jsenvPluginAsJsClassicHtml = ({
18
+ systemJsInjection,
19
+ systemJsClientFileUrl,
20
+ generateJsClassicFilename,
21
+ }) => {
22
+ return {
23
+ name: "jsenv:as_js_classic_html",
24
+ appliesDuring: "*",
25
+ transformUrlContent: {
26
+ html: async (urlInfo, context) => {
27
+ const shouldTransformScriptTypeModule =
28
+ !context.isSupportedOnCurrentClients("script_type_module") ||
29
+ !context.isSupportedOnCurrentClients("import_dynamic")
30
+ const htmlAst = parseHtmlString(urlInfo.content)
31
+ const preloadAsScriptNodes = []
32
+ const modulePreloadNodes = []
33
+ const moduleScriptNodes = []
34
+ const classicScriptNodes = []
35
+ const visitLinkNodes = (node) => {
36
+ if (node.nodeName !== "link") {
37
+ return
38
+ }
39
+ const relAttribute = getHtmlNodeAttributeByName(node, "rel")
40
+ const rel = relAttribute ? relAttribute.value : undefined
41
+ if (rel === "modulepreload") {
42
+ modulePreloadNodes.push(node)
43
+ return
44
+ }
45
+ if (rel === "preload") {
46
+ const asAttribute = getHtmlNodeAttributeByName(node, "as")
47
+ const asValue = asAttribute ? asAttribute.value : undefined
48
+ if (asValue === "script") {
49
+ preloadAsScriptNodes.push(node)
50
+ }
51
+ return
52
+ }
53
+ }
54
+ const visitScriptNodes = (node) => {
55
+ if (node.nodeName !== "script") {
56
+ return
57
+ }
58
+ const typeAttribute = getHtmlNodeAttributeByName(node, "type")
59
+ const type = typeAttribute ? typeAttribute.value : undefined
60
+ if (type === "module") {
61
+ moduleScriptNodes.push(node)
62
+ return
63
+ }
64
+ if (type === undefined || type === "text/javascript") {
65
+ classicScriptNodes.push(node)
66
+ return
67
+ }
68
+ }
69
+ visitHtmlAst(htmlAst, (node) => {
70
+ visitLinkNodes(node)
71
+ visitScriptNodes(node)
72
+ })
73
+
74
+ const actions = []
75
+ const jsModuleUrls = []
76
+ const convertedUrls = []
77
+ const getReferenceAsJsClassic = async (
78
+ reference,
79
+ {
80
+ // we don't cook ressource hints
81
+ // because they might refer to ressource that will be modified during build
82
+ // It also means something else HAVE to reference that url in order to cook it
83
+ // so that the preload is deleted by "resync_ressource_hints.js" otherwise
84
+ cookIt = false,
85
+ } = {},
86
+ ) => {
87
+ const newReferenceProps = {
88
+ expectedType: "js_classic",
89
+ specifier: injectQueryParamsIntoSpecifier(reference.specifier, {
90
+ as_js_classic: "",
91
+ }),
92
+ filename: generateJsClassicFilename(reference.url),
93
+ }
94
+ const [newReference, newUrlInfo] = context.referenceUtils.update(
95
+ reference,
96
+ newReferenceProps,
97
+ )
98
+ const convertedUrl = newUrlInfo.url
99
+ if (!convertedUrls.includes(convertedUrl)) {
100
+ convertedUrls.push(convertedUrl)
101
+ }
102
+ if (cookIt) {
103
+ // during dev it means js modules will be cooked before server sends the HTML
104
+ // it's ok because:
105
+ // - during dev script_type_module are supported (dev use a recent browser)
106
+ // - even if browser is not supported it still works it's jus a bit slower
107
+ // because it needs to decide if systemjs will be injected or not
108
+ await context.cook(newUrlInfo, { reference: newReference })
109
+ }
110
+ return [newReference, newUrlInfo]
111
+ }
112
+
113
+ classicScriptNodes.forEach((classicScriptNode) => {
114
+ const srcAttribute = getHtmlNodeAttributeByName(
115
+ classicScriptNode,
116
+ "src",
117
+ )
118
+ if (srcAttribute) {
119
+ const reference = urlInfo.references.find(
120
+ (ref) =>
121
+ ref.generatedSpecifier === srcAttribute.value &&
122
+ ref.type === "script_src",
123
+ )
124
+ const urlObject = new URL(reference.url)
125
+ if (urlObject.searchParams.has("as_js_classic")) {
126
+ const convertedUrl = urlObject.href
127
+ convertedUrls.push(convertedUrl)
128
+ urlObject.searchParams.delete("as_js_classic")
129
+ const jsModuleUrl = urlObject.href
130
+ jsModuleUrls.push(jsModuleUrl)
131
+ actions.push(async () => {
132
+ const urlInfo = context.urlGraph.getUrlInfo(convertedUrl)
133
+ await context.cook(urlInfo, { reference })
134
+ })
135
+ }
136
+ }
137
+ })
138
+ moduleScriptNodes.forEach((moduleScriptNode) => {
139
+ const srcAttribute = getHtmlNodeAttributeByName(
140
+ moduleScriptNode,
141
+ "src",
142
+ )
143
+ if (srcAttribute) {
144
+ const reference = urlInfo.references.find(
145
+ (ref) =>
146
+ ref.generatedSpecifier === srcAttribute.value &&
147
+ ref.type === "script_src" &&
148
+ ref.expectedType === "js_module",
149
+ )
150
+ jsModuleUrls.push(reference.url)
151
+ if (shouldTransformScriptTypeModule) {
152
+ actions.push(async () => {
153
+ const [newReference] = await getReferenceAsJsClassic(
154
+ reference,
155
+ {
156
+ cookIt: true,
157
+ },
158
+ )
159
+ removeHtmlNodeAttributeByName(moduleScriptNode, "type")
160
+ srcAttribute.value = newReference.generatedSpecifier
161
+ })
162
+ }
163
+ return
164
+ }
165
+ if (shouldTransformScriptTypeModule) {
166
+ const textNode = getHtmlNodeTextNode(moduleScriptNode)
167
+ actions.push(async () => {
168
+ const { line, column, lineEnd, columnEnd, isOriginal } =
169
+ htmlNodePosition.readNodePosition(moduleScriptNode, {
170
+ preferOriginal: true,
171
+ })
172
+ let inlineScriptUrl = generateInlineContentUrl({
173
+ url: urlInfo.url,
174
+ extension: ".js",
175
+ line,
176
+ column,
177
+ lineEnd,
178
+ columnEnd,
179
+ })
180
+ const [inlineReference] = context.referenceUtils.foundInline({
181
+ node: moduleScriptNode,
182
+ type: "script_src",
183
+ expectedType: "js_module",
184
+ isOriginalPosition: isOriginal,
185
+ // we remove 1 to the line because imagine the following html:
186
+ // <script>console.log('ok')</script>
187
+ // -> content starts same line as <script>
188
+ specifierLine: line - 1,
189
+ specifierColumn: column,
190
+ specifier: inlineScriptUrl,
191
+ contentType: "application/javascript",
192
+ content: textNode.value,
193
+ })
194
+ const [, newUrlInfo] = await getReferenceAsJsClassic(
195
+ inlineReference,
196
+ { cookIt: true },
197
+ )
198
+ removeHtmlNodeAttributeByName(moduleScriptNode, "type")
199
+ setHtmlNodeGeneratedText(moduleScriptNode, {
200
+ generatedText: newUrlInfo.content,
201
+ generatedBy: "jsenv:as_js_classic_html",
202
+ })
203
+ })
204
+ }
205
+ })
206
+ if (shouldTransformScriptTypeModule) {
207
+ preloadAsScriptNodes.forEach((preloadAsScriptNode) => {
208
+ const hrefAttribute = getHtmlNodeAttributeByName(
209
+ preloadAsScriptNode,
210
+ "href",
211
+ )
212
+ const href = hrefAttribute.value
213
+ const reference = urlInfo.references.find(
214
+ (ref) =>
215
+ ref.generatedSpecifier === href &&
216
+ ref.type === "link_href" &&
217
+ ref.expectedType === undefined,
218
+ )
219
+ const expectedScriptType = jsModuleUrls.includes(reference.url)
220
+ ? "module"
221
+ : "classic"
222
+ if (expectedScriptType === "module") {
223
+ actions.push(async () => {
224
+ // reference modified by <script type="module"> conversion
225
+ let newReference
226
+ if (reference.next) {
227
+ newReference = reference.next
228
+ } else {
229
+ // when the url is not referenced by a <script type="module">
230
+ // we assume we want to preload "classic" but it might not be the case
231
+ // but it's unlikely to happen and people should use "modulepreload" in that case anyway
232
+ ;[newReference] = await getReferenceAsJsClassic(reference)
233
+ }
234
+ assignHtmlNodeAttributes(preloadAsScriptNode, {
235
+ href: newReference.generatedSpecifier,
236
+ })
237
+ removeHtmlNodeAttributeByName(
238
+ preloadAsScriptNode,
239
+ "crossorigin",
240
+ )
241
+ })
242
+ }
243
+ })
244
+ modulePreloadNodes.forEach((modulePreloadNode) => {
245
+ const hrefAttribute = getHtmlNodeAttributeByName(
246
+ modulePreloadNode,
247
+ "href",
248
+ )
249
+ const href = hrefAttribute.value
250
+ const reference = urlInfo.references.find(
251
+ (ref) =>
252
+ ref.generatedSpecifier === href &&
253
+ ref.type === "link_href" &&
254
+ ref.expectedType === "js_module",
255
+ )
256
+ actions.push(async () => {
257
+ let newReference
258
+ if (reference.next) {
259
+ newReference = reference.next
260
+ } else {
261
+ ;[newReference] = await getReferenceAsJsClassic(reference)
262
+ }
263
+ assignHtmlNodeAttributes(modulePreloadNode, {
264
+ rel: "preload",
265
+ as: "script",
266
+ href: newReference.generatedSpecifier,
267
+ })
268
+ })
269
+ })
270
+ }
271
+
272
+ if (actions.length === 0) {
273
+ return null
274
+ }
275
+ await Promise.all(actions.map((action) => action()))
276
+ if (systemJsInjection) {
277
+ const needsSystemJs = convertedUrls.some(
278
+ (convertedUrl) =>
279
+ context.urlGraph.getUrlInfo(convertedUrl).data.jsClassicFormat ===
280
+ "system",
281
+ )
282
+ if (needsSystemJs) {
283
+ const [systemJsReference] = context.referenceUtils.inject({
284
+ type: "script_src",
285
+ expectedType: "js_classic",
286
+ specifier: systemJsClientFileUrl,
287
+ })
288
+ injectScriptAsEarlyAsPossible(
289
+ htmlAst,
290
+ createHtmlNode({
291
+ "tagName": "script",
292
+ "src": systemJsReference.generatedSpecifier,
293
+ "injected-by": "jsenv:as_js_classic_html",
294
+ }),
295
+ )
296
+ }
297
+ }
298
+ return stringifyHtmlAst(htmlAst)
299
+ },
300
+ },
301
+ }
302
+ }
@@ -1,6 +1,6 @@
1
1
  import { injectQueryParams } from "@jsenv/utils/urls/url_utils.js"
2
2
 
3
- export const jsenvPluginWorkersTypeModuleAsClassic = ({
3
+ export const jsenvPluginAsJsClassicWorkers = ({
4
4
  generateJsClassicFilename,
5
5
  }) => {
6
6
  const updateReference = (reference) => {
@@ -19,7 +19,7 @@ export const jsenvPluginWorkersTypeModuleAsClassic = ({
19
19
  }
20
20
 
21
21
  return {
22
- name: "jsenv:workers_type_module_as_classic",
22
+ name: "jsenv:as_js_classic_workers",
23
23
  appliesDuring: "*",
24
24
  redirectUrl: {
25
25
  js_url_specifier: (reference, context) => {
@@ -7,7 +7,10 @@ import { babelPluginNewStylesheetAsJsenvImport } from "./new_stylesheet/babel_pl
7
7
  import { babelPluginGlobalThisAsJsenvImport } from "./global_this/babel_plugin_global_this_as_jsenv_import.js"
8
8
  import { babelPluginRegeneratorRuntimeAsJsenvImport } from "./regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js"
9
9
 
10
- export const jsenvPluginBabel = ({ getCustomBabelPlugins } = {}) => {
10
+ export const jsenvPluginBabel = ({
11
+ getCustomBabelPlugins,
12
+ babelHelpersAsImport = true,
13
+ } = {}) => {
11
14
  const transformWithBabel = async (urlInfo, context) => {
12
15
  const isJsModule = urlInfo.type === "js_module"
13
16
  const isWorker = urlInfo.subtype === "worker"
@@ -55,7 +58,7 @@ export const jsenvPluginBabel = ({ getCustomBabelPlugins } = {}) => {
55
58
  Object.assign(babelPluginStructure, getCustomBabelPlugins(context))
56
59
  }
57
60
 
58
- if (isJsModule) {
61
+ if (isJsModule && babelHelpersAsImport) {
59
62
  if (!isSupported("global_this")) {
60
63
  babelPluginStructure["global-this-as-jsenv-import"] = [
61
64
  babelPluginGlobalThisAsJsenvImport,
@@ -14,8 +14,7 @@ import { urlToFilename } from "@jsenv/filesystem"
14
14
 
15
15
  import { injectQueryParams } from "@jsenv/utils/urls/url_utils.js"
16
16
  import { JS_QUOTES } from "@jsenv/utils/string/js_quotes.js"
17
-
18
- import { fetchOriginalUrlInfo } from "../fetch_original_url_info.js"
17
+ import { fetchOriginalUrlInfo } from "@jsenv/utils/graph/fetch_original_url_info.js"
19
18
 
20
19
  export const jsenvPluginImportAssertions = () => {
21
20
  const updateReference = (reference, searchParam) => {
@@ -19,6 +19,7 @@ export const jsenvPluginTranspilation = ({
19
19
  jsModuleAsJsClassic = true,
20
20
  systemJsInjection = true,
21
21
  topLevelAwait = true,
22
+ babelHelpersAsImport = true,
22
23
  getCustomBabelPlugins,
23
24
  }) => {
24
25
  return [
@@ -28,6 +29,7 @@ export const jsenvPluginTranspilation = ({
28
29
  jsenvPluginBabel({
29
30
  topLevelAwait,
30
31
  getCustomBabelPlugins,
32
+ babelHelpersAsImport,
31
33
  }),
32
34
  // but the conversion from js_module to js_classic
33
35
  // we want to do it after bundling
@@ -51,6 +51,9 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
51
51
  })
52
52
  },
53
53
  })
54
+ if (actions.length === 0) {
55
+ return null
56
+ }
54
57
  await Promise.all(actions.map((action) => action()))
55
58
  return {
56
59
  content: stringifyHtmlAst(htmlAst),
@@ -51,10 +51,11 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
51
51
  typePropertyNode: jsMention.typePropertyNode,
52
52
  })
53
53
  actions.push(async () => {
54
+ const replacement = await referenceUtils.readGeneratedSpecifier(reference)
54
55
  magicSource.replace({
55
56
  start: jsMention.specifierStart,
56
57
  end: jsMention.specifierEnd,
57
- replacement: await referenceUtils.readGeneratedSpecifier(reference),
58
+ replacement,
58
59
  })
59
60
  if (reference.mutation) {
60
61
  reference.mutation(magicSource)
@@ -1,18 +1,104 @@
1
+ import {
2
+ normalizeStructuredMetaMap,
3
+ urlToMeta,
4
+ urlToRelativeUrl,
5
+ } from "@jsenv/filesystem"
6
+
1
7
  import { parseAndTransformHtmlUrls } from "./html/html_urls.js"
2
8
  import { parseAndTransformCssUrls } from "./css/css_urls.js"
3
9
  import { parseAndTransformJsUrls } from "./js/js_urls.js"
4
10
  import { parseAndTransformWebmanifestUrls } from "./webmanifest/webmanifest_urls.js"
5
11
 
6
- export const jsenvPluginUrlAnalysis = () => {
12
+ export const jsenvPluginUrlAnalysis = ({ rootDirectoryUrl, include }) => {
13
+ let getIncludeInfo = () => undefined
14
+ if (include) {
15
+ const includeMetaMap = normalizeStructuredMetaMap(
16
+ {
17
+ include,
18
+ },
19
+ rootDirectoryUrl,
20
+ )
21
+ getIncludeInfo = (url) => {
22
+ const meta = urlToMeta({
23
+ url,
24
+ structuredMetaMap: includeMetaMap,
25
+ })
26
+ return meta.include
27
+ }
28
+ }
29
+
7
30
  return {
8
31
  name: "jsenv:url_analysis",
9
32
  appliesDuring: "*",
33
+ redirectUrl: (reference) => {
34
+ if (reference.specifier[0] === "#") {
35
+ reference.shouldHandle = false
36
+ return
37
+ }
38
+ const includeInfo = getIncludeInfo(reference.url)
39
+ if (includeInfo === true) {
40
+ reference.shouldHandle = true
41
+ return
42
+ }
43
+ if (includeInfo === false) {
44
+ reference.shouldHandle = false
45
+ return
46
+ }
47
+ if (reference.url.startsWith("data:")) {
48
+ reference.shouldHandle = true
49
+ return
50
+ }
51
+ if (reference.url.startsWith("file:")) {
52
+ reference.shouldHandle = true
53
+ return
54
+ }
55
+ },
10
56
  transformUrlContent: {
11
57
  html: parseAndTransformHtmlUrls,
12
58
  css: parseAndTransformCssUrls,
13
59
  js_classic: parseAndTransformJsUrls,
14
60
  js_module: parseAndTransformJsUrls,
15
61
  webmanifest: parseAndTransformWebmanifestUrls,
62
+ directory: (urlInfo, context) => {
63
+ const originalDirectoryReference = findOriginalDirectoryReference(
64
+ urlInfo,
65
+ context,
66
+ )
67
+ const directoryRelativeUrl = urlToRelativeUrl(
68
+ urlInfo.url,
69
+ context.rootDirectoryUrl,
70
+ )
71
+ JSON.parse(urlInfo.content).forEach((directoryEntry) => {
72
+ context.referenceUtils.found({
73
+ type: "filesystem",
74
+ subtype: "directory_entry",
75
+ specifier: directoryEntry,
76
+ trace: `"${directoryRelativeUrl}${directoryEntry}" entry in directory referenced by ${originalDirectoryReference.trace}`,
77
+ })
78
+ })
79
+ },
16
80
  },
17
81
  }
18
82
  }
83
+
84
+ const findOriginalDirectoryReference = (urlInfo, context) => {
85
+ const findNonFileSystemAncestor = (urlInfo) => {
86
+ for (const dependentUrl of urlInfo.dependents) {
87
+ const dependentUrlInfo = context.urlGraph.getUrlInfo(dependentUrl)
88
+ if (dependentUrlInfo.type !== "directory") {
89
+ return [dependentUrlInfo, urlInfo]
90
+ }
91
+ const found = findNonFileSystemAncestor(dependentUrlInfo)
92
+ if (found) {
93
+ return found
94
+ }
95
+ }
96
+ return []
97
+ }
98
+ const [ancestor, child] = findNonFileSystemAncestor(urlInfo)
99
+ if (!ancestor) {
100
+ return null
101
+ }
102
+ const ref = ancestor.references.find((ref) => ref.url === child.url)
103
+ return ref
104
+ }
@@ -12,6 +12,9 @@ export const parseAndTransformWebmanifestUrls = async (urlInfo, context) => {
12
12
  icon.src = await context.referenceUtils.readGeneratedSpecifier(reference)
13
13
  })
14
14
  })
15
+ if (actions.length === 0) {
16
+ return null
17
+ }
15
18
  await Promise.all(actions.map((action) => action()))
16
19
  return JSON.stringify(manifest, null, " ")
17
20
  }
@@ -1,8 +1,5 @@
1
1
  export const jsenvPluginUrlResolution = () => {
2
2
  const urlResolver = (reference) => {
3
- if (reference.specifier[0] === "#") {
4
- reference.external = true
5
- }
6
3
  return new URL(
7
4
  reference.specifier,
8
5
  reference.baseUrl || reference.parentUrl,
@@ -25,11 +25,7 @@ import { run } from "@jsenv/core/src/execute/run.js"
25
25
 
26
26
  import { ensureGlobalGc } from "./gc.js"
27
27
  import { generateExecutionSteps } from "./execution_steps.js"
28
- import {
29
- formatExecuting,
30
- formatExecutionResult,
31
- createSummaryLog,
32
- } from "./logs_file_execution.js"
28
+ import { createExecutionLog, createSummaryLog } from "./logs_file_execution.js"
33
29
 
34
30
  export const executePlan = async (
35
31
  plan,
@@ -38,6 +34,7 @@ export const executePlan = async (
38
34
  handleSIGINT,
39
35
  logger,
40
36
  logSummary,
37
+ logTimeUsage,
41
38
  logMemoryHeapUsage,
42
39
  logFileRelativeUrl,
43
40
  completedExecutionLogMerging,
@@ -135,6 +132,7 @@ export const executePlan = async (
135
132
  urlGraph,
136
133
  scenario,
137
134
  sourcemaps,
135
+ runtimeCompat: runtimes,
138
136
  writeGeneratedFiles,
139
137
  plugins: [
140
138
  ...plugins,
@@ -142,6 +140,7 @@ export const executePlan = async (
142
140
  rootDirectoryUrl,
143
141
  urlGraph,
144
142
  scenario,
143
+ runtimeCompat: runtimes,
145
144
 
146
145
  htmlSupervisor: true,
147
146
  nodeEsmResolution,
@@ -326,17 +325,29 @@ export const executePlan = async (
326
325
  runtimeVersion,
327
326
  executionIndex,
328
327
  executionParams,
328
+ startMs: Date.now(),
329
+ executionResult: {
330
+ status: "executing",
331
+ },
329
332
  }
330
333
  let spinner
331
334
  if (executionSpinner) {
332
- spinner = startSpinner({
333
- log: executionLog,
334
- text: formatExecuting(beforeExecutionInfo, {
335
+ const renderSpinnerText = () =>
336
+ createExecutionLog(beforeExecutionInfo, {
335
337
  counters,
338
+ ...(logTimeUsage
339
+ ? {
340
+ timeEllapsed: Date.now() - startMs,
341
+ }
342
+ : {}),
336
343
  ...(logMemoryHeapUsage
337
344
  ? { memoryHeap: memoryUsage().heapUsed }
338
345
  : {}),
339
- }),
346
+ })
347
+ spinner = startSpinner({
348
+ log: executionLog,
349
+ text: renderSpinnerText(),
350
+ update: renderSpinnerText,
340
351
  })
341
352
  }
342
353
  beforeExecutionCallback(beforeExecutionInfo)
@@ -368,10 +379,15 @@ export const executePlan = async (
368
379
  }
369
380
  }
370
381
  counters.done++
371
- if (fileRelativeUrl in report === false) {
372
- report[fileRelativeUrl] = {}
382
+ const fileReport = report[fileRelativeUrl]
383
+ if (fileReport) {
384
+ fileReport[executionName] = executionResult
385
+ } else {
386
+ report[fileRelativeUrl] = {
387
+ [executionName]: executionResult,
388
+ }
373
389
  }
374
- report[fileRelativeUrl][executionName] = executionResult
390
+
375
391
  const afterExecutionInfo = {
376
392
  ...beforeExecutionInfo,
377
393
  endMs: Date.now(),
@@ -392,9 +408,14 @@ export const executePlan = async (
392
408
  global.gc()
393
409
  }
394
410
  if (executionLogsEnabled) {
395
- let log = formatExecutionResult(afterExecutionInfo, {
411
+ let log = createExecutionLog(afterExecutionInfo, {
396
412
  completedExecutionLogAbbreviation,
397
413
  counters,
414
+ ...(logTimeUsage
415
+ ? {
416
+ timeEllapsed: Date.now() - startMs,
417
+ }
418
+ : {}),
398
419
  ...(logMemoryHeapUsage
399
420
  ? { memoryHeap: memoryUsage().heapUsed }
400
421
  : {}),