@jsenv/core 35.0.3 → 35.0.5

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 (117) hide show
  1. package/dist/html/explorer.html +107 -107
  2. package/dist/js/new_stylesheet.js +3 -0
  3. package/dist/js/s.js.map +3 -3
  4. package/package.json +2 -2
  5. package/src/build/build.js +589 -587
  6. package/src/build/build_urls_generator.js +44 -44
  7. package/src/build/graph_utils.js +14 -14
  8. package/src/build/jsenv_plugin_line_break_normalization.js +6 -6
  9. package/src/build/line_break_unix.js +11 -11
  10. package/src/build/start_build_server.js +37 -37
  11. package/src/build/version_generator.js +7 -7
  12. package/src/build/version_mappings_injection.js +23 -23
  13. package/src/dev/file_service.js +132 -132
  14. package/src/dev/start_dev_server.js +56 -56
  15. package/src/dev/user_agent.js +8 -8
  16. package/src/helpers/basic_fetch.js +24 -24
  17. package/src/helpers/command/command.js +28 -28
  18. package/src/helpers/lookup_package_directory.js +19 -16
  19. package/src/helpers/ping_server.js +17 -17
  20. package/src/helpers/require_from_jsenv.js +2 -2
  21. package/src/helpers/watch_source_files.js +9 -9
  22. package/src/helpers/web_url_converter.js +10 -10
  23. package/src/helpers/worker_reload.js +27 -27
  24. package/src/kitchen/compat/features_compatibility.js +1 -1
  25. package/src/kitchen/compat/runtime_compat.js +26 -24
  26. package/src/kitchen/errors.js +75 -75
  27. package/src/kitchen/fetched_content_compliance.js +8 -8
  28. package/src/kitchen/kitchen.js +251 -250
  29. package/src/kitchen/url_graph/sort_by_dependencies.js +17 -17
  30. package/src/kitchen/url_graph/url_graph_loader.js +30 -30
  31. package/src/kitchen/url_graph/url_graph_report.js +57 -57
  32. package/src/kitchen/url_graph/url_info_transformations.js +77 -77
  33. package/src/kitchen/url_graph.js +121 -121
  34. package/src/kitchen/url_specifier_encoding.js +21 -21
  35. package/src/kitchen/web_workers.js +5 -5
  36. package/src/main.js +3 -3
  37. package/src/plugins/autoreload/client/autoreload.js +96 -96
  38. package/src/plugins/autoreload/client/reload.js +56 -56
  39. package/src/plugins/autoreload/client/url_helpers.js +13 -13
  40. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +5 -5
  41. package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +9 -9
  42. package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +61 -60
  43. package/src/plugins/autoreload/jsenv_plugin_hmr.js +15 -15
  44. package/src/plugins/cache_control/jsenv_plugin_cache_control.js +5 -5
  45. package/src/plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +57 -57
  46. package/src/plugins/explorer/client/explorer.html +107 -107
  47. package/src/plugins/explorer/jsenv_plugin_explorer.js +20 -20
  48. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +60 -60
  49. package/src/plugins/global_scenarios/jsenv_plugin_global_scenarios.js +5 -5
  50. package/src/plugins/http_urls/jsenv_plugin_http_urls.js +3 -3
  51. package/src/plugins/import_meta_hot/babel_plugin_metadata_import_meta_hot.js +35 -35
  52. package/src/plugins/import_meta_hot/client/import_meta_hot.js +26 -26
  53. package/src/plugins/import_meta_hot/html_hot_dependencies.js +43 -43
  54. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +44 -40
  55. package/src/plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +35 -35
  56. package/src/plugins/import_meta_url/client/import_meta_url_browser.js +21 -21
  57. package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +3 -3
  58. package/src/plugins/importmap/jsenv_plugin_importmap.js +54 -54
  59. package/src/plugins/inline_content_analysis/client/inline_content.js +3 -3
  60. package/src/plugins/inline_content_analysis/jsenv_plugin_data_urls.js +26 -26
  61. package/src/plugins/inline_content_analysis/jsenv_plugin_html_inline_content_analysis.js +47 -47
  62. package/src/plugins/inline_content_analysis/jsenv_plugin_inline_content_analysis.js +9 -9
  63. package/src/plugins/inline_content_analysis/jsenv_plugin_js_inline_content_analysis.js +101 -101
  64. package/src/plugins/inlining/jsenv_plugin_inlining.js +9 -9
  65. package/src/plugins/inlining/jsenv_plugin_inlining_as_data_url.js +11 -11
  66. package/src/plugins/inlining/jsenv_plugin_inlining_into_html.js +48 -46
  67. package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +4 -4
  68. package/src/plugins/plugin_controller.js +124 -124
  69. package/src/plugins/plugins.js +27 -27
  70. package/src/plugins/ribbon/client/ribbon.js +6 -6
  71. package/src/plugins/ribbon/jsenv_plugin_ribbon.js +15 -15
  72. package/src/plugins/server_events/client/connection_manager.js +52 -52
  73. package/src/plugins/server_events/client/event_source_connection.js +36 -36
  74. package/src/plugins/server_events/client/events_manager.js +37 -37
  75. package/src/plugins/server_events/client/server_events_client.js +7 -7
  76. package/src/plugins/server_events/client/web_socket_connection.js +39 -39
  77. package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +9 -9
  78. package/src/plugins/server_events/server_events_dispatcher.js +43 -43
  79. package/src/plugins/supervisor/client/supervisor.js +455 -450
  80. package/src/plugins/supervisor/html_supervisor_injection.js +64 -62
  81. package/src/plugins/supervisor/js_supervisor_injection.js +67 -67
  82. package/src/plugins/supervisor/jsenv_plugin_supervisor.js +54 -51
  83. package/src/plugins/transpilation/as_js_module/convert_js_classic_to_js_module.js +13 -13
  84. package/src/plugins/transpilation/as_js_module/jsenv_plugin_as_js_module.js +19 -19
  85. package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +10 -10
  86. package/src/plugins/transpilation/babel/global_this/client/global_this.js +8 -8
  87. package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +16 -16
  88. package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +36 -36
  89. package/src/plugins/transpilation/babel/helpers/babel_plugins_compatibility.js +3 -3
  90. package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +24 -24
  91. package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +44 -44
  92. package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +166 -166
  93. package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +10 -10
  94. package/src/plugins/transpilation/babel/require_babel_plugin.js +6 -6
  95. package/src/plugins/transpilation/css/jsenv_plugin_css_transpilation.js +20 -20
  96. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +62 -62
  97. package/src/plugins/transpilation/js_module_fallback/client/s.js +214 -209
  98. package/src/plugins/transpilation/js_module_fallback/convert_js_module_to_js_classic.js +45 -45
  99. package/src/plugins/transpilation/js_module_fallback/helpers/babel_plugin_transform_import_meta_resolve.js +6 -6
  100. package/src/plugins/transpilation/js_module_fallback/helpers/babel_plugin_transform_import_meta_url.js +17 -17
  101. package/src/plugins/transpilation/js_module_fallback/helpers-string.js +1 -1
  102. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_conversion.js +32 -32
  103. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback.js +17 -17
  104. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js +63 -63
  105. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_on_workers.js +15 -15
  106. package/src/plugins/transpilation/jsenv_plugin_import_meta_resolve.js +20 -20
  107. package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +23 -23
  108. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +11 -11
  109. package/src/plugins/url_analysis/css/css_urls.js +12 -12
  110. package/src/plugins/url_analysis/html/html_urls.js +85 -85
  111. package/src/plugins/url_analysis/js/js_urls.js +16 -16
  112. package/src/plugins/url_analysis/jsenv_plugin_reference_expected_types.js +16 -16
  113. package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +40 -40
  114. package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +12 -12
  115. package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +35 -35
  116. package/src/plugins/url_resolution/node_esm_resolver.js +26 -26
  117. package/src/plugins/url_version/jsenv_plugin_url_version.js +11 -11
@@ -1,21 +1,21 @@
1
- import { urlToFilename, urlToRelativeUrl } from "@jsenv/urls"
2
- import { memoizeByFirstArgument } from "@jsenv/utils/src/memoize/memoize_by_first_argument.js"
1
+ import { urlToFilename, urlToRelativeUrl } from "@jsenv/urls";
2
+ import { memoizeByFirstArgument } from "@jsenv/utils/src/memoize/memoize_by_first_argument.js";
3
3
 
4
4
  export const createBuildUrlsGenerator = ({
5
5
  buildDirectoryUrl,
6
6
  assetsDirectory,
7
7
  }) => {
8
- const cache = {}
8
+ const cache = {};
9
9
 
10
10
  const getUrlName = (url, urlInfo) => {
11
11
  if (!urlInfo) {
12
- return urlToFilename(url)
12
+ return urlToFilename(url);
13
13
  }
14
14
  if (urlInfo.filename) {
15
- return urlInfo.filename
15
+ return urlInfo.filename;
16
16
  }
17
- return urlToFilename(url)
18
- }
17
+ return urlToFilename(url);
18
+ };
19
19
 
20
20
  const generate = memoizeByFirstArgument((url, { urlInfo, parentUrlInfo }) => {
21
21
  const directoryPath = determineDirectoryPath({
@@ -23,35 +23,35 @@ export const createBuildUrlsGenerator = ({
23
23
  assetsDirectory,
24
24
  urlInfo,
25
25
  parentUrlInfo,
26
- })
27
- let names = cache[directoryPath]
26
+ });
27
+ let names = cache[directoryPath];
28
28
  if (!names) {
29
- names = []
30
- cache[directoryPath] = names
29
+ names = [];
30
+ cache[directoryPath] = names;
31
31
  }
32
- const urlObject = new URL(url)
33
- let { search, hash } = urlObject
34
- let name = getUrlName(url, urlInfo)
35
- let [basename, extension] = splitFileExtension(name)
36
- extension = extensionMappings[extension] || extension
37
- let nameCandidate = `${basename}${extension}` // reconstruct name in case extension was normalized
38
- let integer = 1
32
+ const urlObject = new URL(url);
33
+ let { search, hash } = urlObject;
34
+ let name = getUrlName(url, urlInfo);
35
+ let [basename, extension] = splitFileExtension(name);
36
+ extension = extensionMappings[extension] || extension;
37
+ let nameCandidate = `${basename}${extension}`; // reconstruct name in case extension was normalized
38
+ let integer = 1;
39
39
  // eslint-disable-next-line no-constant-condition
40
40
  while (true) {
41
41
  if (!names.includes(nameCandidate)) {
42
- names.push(nameCandidate)
43
- break
42
+ names.push(nameCandidate);
43
+ break;
44
44
  }
45
- integer++
46
- nameCandidate = `${basename}${integer}${extension}`
45
+ integer++;
46
+ nameCandidate = `${basename}${integer}${extension}`;
47
47
  }
48
- return `${buildDirectoryUrl}${directoryPath}${nameCandidate}${search}${hash}`
49
- })
48
+ return `${buildDirectoryUrl}${directoryPath}${nameCandidate}${search}${hash}`;
49
+ });
50
50
 
51
51
  return {
52
52
  generate,
53
- }
54
- }
53
+ };
54
+ };
55
55
 
56
56
  // It's best to generate files with an extension representing what is inside the file
57
57
  // and after build js files contains solely js (js or typescript is gone).
@@ -63,15 +63,15 @@ const extensionMappings = {
63
63
  ".jsx": ".js",
64
64
  ".ts": ".js",
65
65
  ".tsx": ".js",
66
- }
66
+ };
67
67
 
68
68
  const splitFileExtension = (filename) => {
69
- const dotLastIndex = filename.lastIndexOf(".")
69
+ const dotLastIndex = filename.lastIndexOf(".");
70
70
  if (dotLastIndex === -1) {
71
- return [filename, ""]
71
+ return [filename, ""];
72
72
  }
73
- return [filename.slice(0, dotLastIndex), filename.slice(dotLastIndex)]
74
- }
73
+ return [filename.slice(0, dotLastIndex), filename.slice(dotLastIndex)];
74
+ };
75
75
 
76
76
  const determineDirectoryPath = ({
77
77
  buildDirectoryUrl,
@@ -80,40 +80,40 @@ const determineDirectoryPath = ({
80
80
  parentUrlInfo,
81
81
  }) => {
82
82
  if (urlInfo.type === "directory") {
83
- return ""
83
+ return "";
84
84
  }
85
85
  if (parentUrlInfo && parentUrlInfo.type === "directory") {
86
86
  const parentDirectoryPath = urlToRelativeUrl(
87
87
  parentUrlInfo.url,
88
88
  buildDirectoryUrl,
89
- )
90
- return parentDirectoryPath
89
+ );
90
+ return parentDirectoryPath;
91
91
  }
92
92
  if (urlInfo.isInline) {
93
93
  const parentDirectoryPath = determineDirectoryPath({
94
94
  buildDirectoryUrl,
95
95
  assetsDirectory,
96
96
  urlInfo: parentUrlInfo,
97
- })
98
- return parentDirectoryPath
97
+ });
98
+ return parentDirectoryPath;
99
99
  }
100
100
  if (urlInfo.isEntryPoint) {
101
- return ""
101
+ return "";
102
102
  }
103
103
  if (urlInfo.type === "importmap") {
104
- return ""
104
+ return "";
105
105
  }
106
106
  if (urlInfo.type === "html") {
107
- return `${assetsDirectory}html/`
107
+ return `${assetsDirectory}html/`;
108
108
  }
109
109
  if (urlInfo.type === "css") {
110
- return `${assetsDirectory}css/`
110
+ return `${assetsDirectory}css/`;
111
111
  }
112
112
  if (urlInfo.type === "js_module" || urlInfo.type === "js_classic") {
113
- return `${assetsDirectory}js/`
113
+ return `${assetsDirectory}js/`;
114
114
  }
115
115
  if (urlInfo.type === "json") {
116
- return `${assetsDirectory}json/`
116
+ return `${assetsDirectory}json/`;
117
117
  }
118
- return `${assetsDirectory}other/`
119
- }
118
+ return `${assetsDirectory}other/`;
119
+ };
@@ -1,34 +1,34 @@
1
1
  export const GRAPH = {
2
2
  map: (graph, callback) => {
3
- const array = []
3
+ const array = [];
4
4
  graph.urlInfoMap.forEach((urlInfo) => {
5
- array.push(callback(urlInfo))
6
- })
7
- return array
5
+ array.push(callback(urlInfo));
6
+ });
7
+ return array;
8
8
  },
9
9
 
10
10
  forEach: (graph, callback) => {
11
- graph.urlInfoMap.forEach(callback)
11
+ graph.urlInfoMap.forEach(callback);
12
12
  },
13
13
 
14
14
  filter: (graph, callback) => {
15
- const urlInfos = []
15
+ const urlInfos = [];
16
16
  graph.urlInfoMap.forEach((urlInfo) => {
17
17
  if (callback(urlInfo)) {
18
- urlInfos.push(urlInfo)
18
+ urlInfos.push(urlInfo);
19
19
  }
20
- })
21
- return urlInfos
20
+ });
21
+ return urlInfos;
22
22
  },
23
23
 
24
24
  find: (graph, callback) => {
25
- let found = null
25
+ let found = null;
26
26
  for (const urlInfo of graph.urlInfoMap.values()) {
27
27
  if (callback(urlInfo)) {
28
- found = urlInfo
29
- break
28
+ found = urlInfo;
29
+ break;
30
30
  }
31
31
  }
32
- return found
32
+ return found;
33
33
  },
34
- }
34
+ };
@@ -1,6 +1,6 @@
1
- import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js"
1
+ import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
2
2
 
3
- import { ensureUnixLineBreaks } from "./line_break_unix.js"
3
+ import { ensureUnixLineBreaks } from "./line_break_unix.js";
4
4
 
5
5
  export const jsenvPluginLineBreakNormalization = () => {
6
6
  return {
@@ -8,9 +8,9 @@ export const jsenvPluginLineBreakNormalization = () => {
8
8
  appliesDuring: "build",
9
9
  transformUrlContent: (urlInfo) => {
10
10
  if (CONTENT_TYPE.isTextual(urlInfo.contentType)) {
11
- return ensureUnixLineBreaks(urlInfo.content)
11
+ return ensureUnixLineBreaks(urlInfo.content);
12
12
  }
13
- return null
13
+ return null;
14
14
  },
15
- }
16
- }
15
+ };
16
+ };
@@ -1,26 +1,26 @@
1
1
  export const ensureUnixLineBreaks = (stringOrBuffer) => {
2
2
  if (typeof stringOrBuffer === "string") {
3
- const stringWithLinuxBreaks = stringOrBuffer.replace(/\r\n/g, "\n")
4
- return stringWithLinuxBreaks
3
+ const stringWithLinuxBreaks = stringOrBuffer.replace(/\r\n/g, "\n");
4
+ return stringWithLinuxBreaks;
5
5
  }
6
- return ensureUnixLineBreaksOnBuffer(stringOrBuffer)
7
- }
6
+ return ensureUnixLineBreaksOnBuffer(stringOrBuffer);
7
+ };
8
8
 
9
9
  // https://github.com/nodejs/help/issues/1738#issuecomment-458460503
10
10
  const ensureUnixLineBreaksOnBuffer = (buffer) => {
11
- const int32Array = new Int32Array(buffer, 0, buffer.length)
11
+ const int32Array = new Int32Array(buffer, 0, buffer.length);
12
12
  const int32ArrayWithLineBreaksNormalized = int32Array.filter(
13
13
  (element, index, typedArray) => {
14
14
  if (element === 0x0d) {
15
15
  if (typedArray[index + 1] === 0x0a) {
16
16
  // Windows -> Unix
17
- return false
17
+ return false;
18
18
  }
19
19
  // Mac OS -> Unix
20
- typedArray[index] = 0x0a
20
+ typedArray[index] = 0x0a;
21
21
  }
22
- return true
22
+ return true;
23
23
  },
24
- )
25
- return Buffer.from(int32ArrayWithLineBreaksNormalized)
26
- }
24
+ );
25
+ return Buffer.from(int32ArrayWithLineBreaksNormalized);
26
+ };
@@ -13,17 +13,17 @@
13
13
  * we want to be in the user shoes and we should not alter build files.
14
14
  */
15
15
 
16
- import { existsSync } from "node:fs"
16
+ import { existsSync } from "node:fs";
17
17
  import {
18
18
  jsenvAccessControlAllowedHeaders,
19
19
  startServer,
20
20
  fetchFileSystem,
21
21
  jsenvServiceCORS,
22
22
  jsenvServiceErrorHandler,
23
- } from "@jsenv/server"
24
- import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem"
25
- import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
26
- import { createLogger, createTaskLog } from "@jsenv/log"
23
+ } from "@jsenv/server";
24
+ import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
25
+ import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
26
+ import { createLogger, createTaskLog } from "@jsenv/log";
27
27
 
28
28
  /**
29
29
  * Start a server for build files.
@@ -51,44 +51,44 @@ export const startBuildServer = async ({
51
51
  }) => {
52
52
  // params validation
53
53
  {
54
- const unexpectedParamNames = Object.keys(rest)
54
+ const unexpectedParamNames = Object.keys(rest);
55
55
  if (unexpectedParamNames.length > 0) {
56
56
  throw new TypeError(
57
57
  `${unexpectedParamNames.join(",")}: there is no such param`,
58
- )
58
+ );
59
59
  }
60
60
  buildDirectoryUrl = assertAndNormalizeDirectoryUrl(
61
61
  buildDirectoryUrl,
62
62
  "buildDirectoryUrl",
63
- )
63
+ );
64
64
 
65
65
  if (buildMainFilePath) {
66
66
  if (typeof buildMainFilePath !== "string") {
67
67
  throw new TypeError(
68
68
  `buildMainFilePath must be a string, got ${buildMainFilePath}`,
69
- )
69
+ );
70
70
  }
71
71
  if (buildMainFilePath[0] === "/") {
72
- buildMainFilePath = buildMainFilePath.slice(1)
72
+ buildMainFilePath = buildMainFilePath.slice(1);
73
73
  } else {
74
74
  const buildMainFileUrl = new URL(buildMainFilePath, buildDirectoryUrl)
75
- .href
75
+ .href;
76
76
  if (!buildMainFileUrl.startsWith(buildDirectoryUrl)) {
77
77
  throw new Error(
78
78
  `buildMainFilePath must be relative, got ${buildMainFilePath}`,
79
- )
79
+ );
80
80
  }
81
- buildMainFilePath = buildMainFileUrl.slice(buildDirectoryUrl.length)
81
+ buildMainFilePath = buildMainFileUrl.slice(buildDirectoryUrl.length);
82
82
  }
83
83
  if (!existsSync(new URL(buildMainFilePath, buildDirectoryUrl))) {
84
- buildMainFilePath = null
84
+ buildMainFilePath = null;
85
85
  }
86
86
  }
87
87
  }
88
88
 
89
- const logger = createLogger({ logLevel })
90
- const operation = Abort.startOperation()
91
- operation.addAbortSignal(signal)
89
+ const logger = createLogger({ logLevel });
90
+ const operation = Abort.startOperation();
91
+ operation.addAbortSignal(signal);
92
92
  if (handleSIGINT) {
93
93
  operation.addAbortSource((abort) => {
94
94
  return raceProcessTeardownEvents(
@@ -96,13 +96,13 @@ export const startBuildServer = async ({
96
96
  SIGINT: true,
97
97
  },
98
98
  abort,
99
- )
100
- })
99
+ );
100
+ });
101
101
  }
102
102
 
103
103
  const startBuildServerTask = createTaskLog("start build server", {
104
104
  disabled: !logger.levels.info,
105
- })
105
+ });
106
106
  const server = await startServer({
107
107
  signal,
108
108
  stopOnExit: false,
@@ -142,33 +142,33 @@ export const startBuildServer = async ({
142
142
  sendErrorDetails: true,
143
143
  }),
144
144
  ],
145
- })
146
- startBuildServerTask.done()
145
+ });
146
+ startBuildServerTask.done();
147
147
  if (hostname) {
148
- delete server.origins.localip
149
- delete server.origins.externalip
148
+ delete server.origins.localip;
149
+ delete server.origins.externalip;
150
150
  }
151
- logger.info(``)
151
+ logger.info(``);
152
152
  Object.keys(server.origins).forEach((key) => {
153
- logger.info(`- ${server.origins[key]}`)
154
- })
155
- logger.info(``)
153
+ logger.info(`- ${server.origins[key]}`);
154
+ });
155
+ logger.info(``);
156
156
  return {
157
157
  origin: server.origin,
158
158
  stop: () => {
159
- server.stop()
159
+ server.stop();
160
160
  },
161
- }
162
- }
161
+ };
162
+ };
163
163
 
164
164
  const createBuildFilesService = ({ buildDirectoryUrl, buildMainFilePath }) => {
165
165
  return (request) => {
166
- const urlIsVersioned = new URL(request.url).searchParams.has("v")
166
+ const urlIsVersioned = new URL(request.url).searchParams.has("v");
167
167
  if (buildMainFilePath && request.resource === "/") {
168
168
  request = {
169
169
  ...request,
170
170
  resource: `/${buildMainFilePath}`,
171
- }
171
+ };
172
172
  }
173
173
  return fetchFileSystem(
174
174
  new URL(request.resource.slice(1), buildDirectoryUrl),
@@ -182,8 +182,8 @@ const createBuildFilesService = ({ buildDirectoryUrl, buildMainFilePath }) => {
182
182
  rootDirectoryUrl: buildDirectoryUrl,
183
183
  canReadDirectory: true,
184
184
  },
185
- )
186
- }
187
- }
185
+ );
186
+ };
187
+ };
188
188
 
189
- const SECONDS_IN_30_DAYS = 60 * 60 * 24 * 30
189
+ const SECONDS_IN_30_DAYS = 60 * 60 * 24 * 30;
@@ -1,19 +1,19 @@
1
- import { createHash } from "node:crypto"
1
+ import { createHash } from "node:crypto";
2
2
 
3
3
  // https://github.com/rollup/rollup/blob/19e50af3099c2f627451a45a84e2fa90d20246d5/src/utils/FileEmitter.ts#L47
4
4
  // https://github.com/rollup/rollup/blob/5a5391971d695c808eed0c5d7d2c6ccb594fc689/src/Chunk.ts#L870
5
5
  export const createVersionGenerator = () => {
6
- const hash = createHash("sha256")
6
+ const hash = createHash("sha256");
7
7
 
8
8
  return {
9
9
  augmentWithContent: (content) => {
10
- hash.update(content)
10
+ hash.update(content);
11
11
  },
12
12
  augment: (value) => {
13
- hash.update(value)
13
+ hash.update(value);
14
14
  },
15
15
  generate: () => {
16
- return hash.digest("hex").slice(0, 8)
16
+ return hash.digest("hex").slice(0, 8);
17
17
  },
18
- }
19
- }
18
+ };
19
+ };
@@ -1,37 +1,37 @@
1
1
  // https://bundlers.tooling.report/hashing/avoid-cascade/
2
2
 
3
- import { createMagicSource } from "@jsenv/sourcemap"
3
+ import { createMagicSource } from "@jsenv/sourcemap";
4
4
  import {
5
5
  parseHtmlString,
6
6
  injectHtmlNodeAsEarlyAsPossible,
7
7
  createHtmlNode,
8
8
  stringifyHtmlAst,
9
- } from "@jsenv/ast"
9
+ } from "@jsenv/ast";
10
10
 
11
- import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js"
11
+ import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js";
12
12
 
13
13
  export const injectVersionMappingsAsGlobal = async ({
14
14
  urlInfo,
15
15
  kitchen,
16
16
  versionMappings,
17
17
  }) => {
18
- const injector = injectors[urlInfo.type]
18
+ const injector = injectors[urlInfo.type];
19
19
  if (injector) {
20
20
  const { content, sourcemap } = await injector(urlInfo, {
21
21
  versionMappings,
22
22
  minification: kitchen.kitchenContext.minification,
23
- })
23
+ });
24
24
  kitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
25
25
  content,
26
26
  sourcemap,
27
- })
27
+ });
28
28
  }
29
- }
29
+ };
30
30
  const injectors = {
31
31
  html: (urlInfo, { versionMappings, minification }) => {
32
32
  const htmlAst = parseHtmlString(urlInfo.content, {
33
33
  storeOriginalPositions: false,
34
- })
34
+ });
35
35
  injectHtmlNodeAsEarlyAsPossible(
36
36
  htmlAst,
37
37
  createHtmlNode({
@@ -42,23 +42,23 @@ const injectors = {
42
42
  }),
43
43
  }),
44
44
  "jsenv:versioning",
45
- )
45
+ );
46
46
  return {
47
47
  content: stringifyHtmlAst(htmlAst),
48
- }
48
+ };
49
49
  },
50
50
  js_classic: (...args) => jsInjector(...args),
51
51
  js_module: (...args) => jsInjector(...args),
52
- }
52
+ };
53
53
  const jsInjector = (urlInfo, { versionMappings, minification }) => {
54
- const magicSource = createMagicSource(urlInfo.content)
54
+ const magicSource = createMagicSource(urlInfo.content);
55
55
  const code = generateClientCodeForVersionMappings(versionMappings, {
56
56
  globalName: isWebWorkerUrlInfo(urlInfo) ? "self" : "window",
57
57
  minification,
58
- })
59
- magicSource.prepend(`${code}\n\n`)
60
- return magicSource.toContentAndSourcemap()
61
- }
58
+ });
59
+ magicSource.prepend(`${code}\n\n`);
60
+ return magicSource.toContentAndSourcemap();
61
+ };
62
62
  const generateClientCodeForVersionMappings = (
63
63
  versionMappings,
64
64
  { globalName, minification },
@@ -66,15 +66,15 @@ const generateClientCodeForVersionMappings = (
66
66
  if (minification) {
67
67
  return `;(function(){var m = ${JSON.stringify(
68
68
  versionMappings,
69
- )}; ${globalName}.__v__ = function (s) { return m[s] || s }; })();`
69
+ )}; ${globalName}.__v__ = function (s) { return m[s] || s }; })();`;
70
70
  }
71
71
  return `;(function() {
72
72
  var __versionMappings__ = ${JSON.stringify(versionMappings, null, " ")};
73
73
  ${globalName}.__v__ = function (specifier) {
74
74
  return __versionMappings__[specifier] || specifier
75
75
  };
76
- })();`
77
- }
76
+ })();`;
77
+ };
78
78
 
79
79
  export const injectVersionMappingsAsImportmap = async ({
80
80
  urlInfo,
@@ -83,7 +83,7 @@ export const injectVersionMappingsAsImportmap = async ({
83
83
  }) => {
84
84
  const htmlAst = parseHtmlString(urlInfo.content, {
85
85
  storeOriginalPositions: false,
86
- })
86
+ });
87
87
  // jsenv_plugin_importmap.js is removing importmap during build
88
88
  // it means at this point we know HTML has no importmap in it
89
89
  // we can safely inject one
@@ -97,8 +97,8 @@ export const injectVersionMappingsAsImportmap = async ({
97
97
  : JSON.stringify({ imports: versionMappings }, null, " "),
98
98
  }),
99
99
  "jsenv:versioning",
100
- )
100
+ );
101
101
  kitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
102
102
  content: stringifyHtmlAst(htmlAst),
103
- })
104
- }
103
+ });
104
+ };