@jsenv/core 35.0.2 → 35.0.4

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 (118) 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/dist/jsenv_core.js +15 -17
  5. package/package.json +1 -1
  6. package/src/build/build.js +589 -587
  7. package/src/build/build_urls_generator.js +44 -44
  8. package/src/build/graph_utils.js +14 -14
  9. package/src/build/jsenv_plugin_line_break_normalization.js +6 -6
  10. package/src/build/line_break_unix.js +11 -11
  11. package/src/build/start_build_server.js +37 -37
  12. package/src/build/version_generator.js +7 -7
  13. package/src/build/version_mappings_injection.js +23 -23
  14. package/src/dev/file_service.js +136 -135
  15. package/src/dev/start_dev_server.js +56 -56
  16. package/src/dev/user_agent.js +8 -8
  17. package/src/helpers/basic_fetch.js +24 -24
  18. package/src/helpers/command/command.js +28 -28
  19. package/src/helpers/lookup_package_directory.js +19 -16
  20. package/src/helpers/ping_server.js +17 -17
  21. package/src/helpers/require_from_jsenv.js +2 -2
  22. package/src/helpers/watch_source_files.js +9 -9
  23. package/src/helpers/web_url_converter.js +10 -10
  24. package/src/helpers/worker_reload.js +27 -27
  25. package/src/kitchen/compat/features_compatibility.js +1 -1
  26. package/src/kitchen/compat/runtime_compat.js +26 -24
  27. package/src/kitchen/errors.js +75 -75
  28. package/src/kitchen/fetched_content_compliance.js +8 -8
  29. package/src/kitchen/kitchen.js +251 -250
  30. package/src/kitchen/url_graph/sort_by_dependencies.js +17 -17
  31. package/src/kitchen/url_graph/url_graph_loader.js +30 -30
  32. package/src/kitchen/url_graph/url_graph_report.js +57 -57
  33. package/src/kitchen/url_graph/url_info_transformations.js +77 -77
  34. package/src/kitchen/url_graph.js +121 -121
  35. package/src/kitchen/url_specifier_encoding.js +21 -21
  36. package/src/kitchen/web_workers.js +5 -5
  37. package/src/main.js +3 -3
  38. package/src/plugins/autoreload/client/autoreload.js +96 -96
  39. package/src/plugins/autoreload/client/reload.js +56 -56
  40. package/src/plugins/autoreload/client/url_helpers.js +13 -13
  41. package/src/plugins/autoreload/jsenv_plugin_autoreload.js +5 -5
  42. package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +9 -9
  43. package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +61 -60
  44. package/src/plugins/autoreload/jsenv_plugin_hmr.js +15 -15
  45. package/src/plugins/cache_control/jsenv_plugin_cache_control.js +5 -5
  46. package/src/plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +57 -57
  47. package/src/plugins/explorer/client/explorer.html +107 -107
  48. package/src/plugins/explorer/jsenv_plugin_explorer.js +23 -25
  49. package/src/plugins/file_urls/jsenv_plugin_file_urls.js +60 -60
  50. package/src/plugins/global_scenarios/jsenv_plugin_global_scenarios.js +5 -5
  51. package/src/plugins/http_urls/jsenv_plugin_http_urls.js +3 -3
  52. package/src/plugins/import_meta_hot/babel_plugin_metadata_import_meta_hot.js +35 -35
  53. package/src/plugins/import_meta_hot/client/import_meta_hot.js +26 -26
  54. package/src/plugins/import_meta_hot/html_hot_dependencies.js +43 -43
  55. package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +44 -40
  56. package/src/plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +35 -35
  57. package/src/plugins/import_meta_url/client/import_meta_url_browser.js +21 -21
  58. package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +3 -3
  59. package/src/plugins/importmap/jsenv_plugin_importmap.js +54 -54
  60. package/src/plugins/inline_content_analysis/client/inline_content.js +3 -3
  61. package/src/plugins/inline_content_analysis/jsenv_plugin_data_urls.js +26 -26
  62. package/src/plugins/inline_content_analysis/jsenv_plugin_html_inline_content_analysis.js +47 -47
  63. package/src/plugins/inline_content_analysis/jsenv_plugin_inline_content_analysis.js +9 -9
  64. package/src/plugins/inline_content_analysis/jsenv_plugin_js_inline_content_analysis.js +101 -101
  65. package/src/plugins/inlining/jsenv_plugin_inlining.js +9 -9
  66. package/src/plugins/inlining/jsenv_plugin_inlining_as_data_url.js +11 -11
  67. package/src/plugins/inlining/jsenv_plugin_inlining_into_html.js +48 -46
  68. package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +4 -4
  69. package/src/plugins/plugin_controller.js +124 -124
  70. package/src/plugins/plugins.js +30 -30
  71. package/src/plugins/ribbon/client/ribbon.js +6 -6
  72. package/src/plugins/ribbon/jsenv_plugin_ribbon.js +15 -15
  73. package/src/plugins/server_events/client/connection_manager.js +52 -52
  74. package/src/plugins/server_events/client/event_source_connection.js +36 -36
  75. package/src/plugins/server_events/client/events_manager.js +37 -37
  76. package/src/plugins/server_events/client/server_events_client.js +7 -7
  77. package/src/plugins/server_events/client/web_socket_connection.js +39 -39
  78. package/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js +9 -9
  79. package/src/plugins/server_events/server_events_dispatcher.js +43 -43
  80. package/src/plugins/supervisor/client/supervisor.js +455 -450
  81. package/src/plugins/supervisor/html_supervisor_injection.js +64 -62
  82. package/src/plugins/supervisor/js_supervisor_injection.js +67 -67
  83. package/src/plugins/supervisor/jsenv_plugin_supervisor.js +54 -51
  84. package/src/plugins/transpilation/as_js_module/convert_js_classic_to_js_module.js +13 -13
  85. package/src/plugins/transpilation/as_js_module/jsenv_plugin_as_js_module.js +19 -19
  86. package/src/plugins/transpilation/babel/global_this/babel_plugin_global_this_as_jsenv_import.js +10 -10
  87. package/src/plugins/transpilation/babel/global_this/client/global_this.js +8 -8
  88. package/src/plugins/transpilation/babel/helpers/babel_plugin_babel_helpers_as_jsenv_imports.js +16 -16
  89. package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +36 -36
  90. package/src/plugins/transpilation/babel/helpers/babel_plugins_compatibility.js +3 -3
  91. package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +24 -24
  92. package/src/plugins/transpilation/babel/new_stylesheet/babel_plugin_new_stylesheet_as_jsenv_import.js +44 -44
  93. package/src/plugins/transpilation/babel/new_stylesheet/client/new_stylesheet.js +166 -166
  94. package/src/plugins/transpilation/babel/regenerator_runtime/babel_plugin_regenerator_runtime_as_jsenv_import.js +10 -10
  95. package/src/plugins/transpilation/babel/require_babel_plugin.js +6 -6
  96. package/src/plugins/transpilation/css/jsenv_plugin_css_transpilation.js +20 -20
  97. package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +62 -62
  98. package/src/plugins/transpilation/js_module_fallback/client/s.js +214 -209
  99. package/src/plugins/transpilation/js_module_fallback/convert_js_module_to_js_classic.js +45 -45
  100. package/src/plugins/transpilation/js_module_fallback/helpers/babel_plugin_transform_import_meta_resolve.js +6 -6
  101. package/src/plugins/transpilation/js_module_fallback/helpers/babel_plugin_transform_import_meta_url.js +17 -17
  102. package/src/plugins/transpilation/js_module_fallback/helpers-string.js +1 -1
  103. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_conversion.js +32 -32
  104. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback.js +17 -17
  105. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_inside_html.js +63 -63
  106. package/src/plugins/transpilation/js_module_fallback/jsenv_plugin_js_module_fallback_on_workers.js +15 -15
  107. package/src/plugins/transpilation/jsenv_plugin_import_meta_resolve.js +20 -20
  108. package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +23 -23
  109. package/src/plugins/transpilation/jsenv_plugin_transpilation.js +11 -11
  110. package/src/plugins/url_analysis/css/css_urls.js +12 -12
  111. package/src/plugins/url_analysis/html/html_urls.js +85 -85
  112. package/src/plugins/url_analysis/js/js_urls.js +16 -16
  113. package/src/plugins/url_analysis/jsenv_plugin_reference_expected_types.js +16 -16
  114. package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +40 -40
  115. package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +12 -12
  116. package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +36 -36
  117. package/src/plugins/url_resolution/node_esm_resolver.js +26 -26
  118. package/src/plugins/url_version/jsenv_plugin_url_version.js +11 -11
@@ -8,8 +8,8 @@
8
8
  * - replaced by undefined (import.meta.dev but it's build; the goal is to ensure it's tree-shaked)
9
9
  */
10
10
 
11
- import { createMagicSource } from "@jsenv/sourcemap"
12
- import { applyBabelPlugins } from "@jsenv/ast"
11
+ import { createMagicSource } from "@jsenv/sourcemap";
12
+ import { applyBabelPlugins } from "@jsenv/ast";
13
13
 
14
14
  export const jsenvPluginImportMetaScenarios = () => {
15
15
  return {
@@ -22,80 +22,80 @@ export const jsenvPluginImportMetaScenarios = () => {
22
22
  !urlInfo.content.includes("import.meta.test") &&
23
23
  !urlInfo.content.includes("import.meta.build")
24
24
  ) {
25
- return null
25
+ return null;
26
26
  }
27
27
  const { metadata } = await applyBabelPlugins({
28
28
  babelPlugins: [babelPluginMetadataImportMetaScenarios],
29
29
  urlInfo,
30
- })
31
- const { dev = [], build = [] } = metadata.importMetaScenarios
32
- const replacements = []
30
+ });
31
+ const { dev = [], build = [] } = metadata.importMetaScenarios;
32
+ const replacements = [];
33
33
  const replace = (path, value) => {
34
- replacements.push({ path, value })
35
- }
34
+ replacements.push({ path, value });
35
+ };
36
36
  if (context.build) {
37
37
  // during build ensure replacement for tree-shaking
38
38
  dev.forEach((path) => {
39
- replace(path, "undefined")
40
- })
39
+ replace(path, "undefined");
40
+ });
41
41
  build.forEach((path) => {
42
- replace(path, "true")
43
- })
42
+ replace(path, "true");
43
+ });
44
44
  } else {
45
45
  // during dev we can let "import.meta.build" untouched
46
46
  // it will be evaluated to undefined.
47
47
  // Moreover it can be surprising to see some "undefined"
48
48
  // when source file contains "import.meta.build"
49
49
  dev.forEach((path) => {
50
- replace(path, "true")
51
- })
50
+ replace(path, "true");
51
+ });
52
52
  }
53
- const magicSource = createMagicSource(urlInfo.content)
53
+ const magicSource = createMagicSource(urlInfo.content);
54
54
  replacements.forEach(({ path, value }) => {
55
55
  magicSource.replace({
56
56
  start: path.node.start,
57
57
  end: path.node.end,
58
58
  replacement: value,
59
- })
60
- })
61
- return magicSource.toContentAndSourcemap()
59
+ });
60
+ });
61
+ return magicSource.toContentAndSourcemap();
62
62
  },
63
63
  },
64
- }
65
- }
64
+ };
65
+ };
66
66
 
67
67
  const babelPluginMetadataImportMetaScenarios = () => {
68
68
  return {
69
69
  name: "metadata-import-meta-scenarios",
70
70
  visitor: {
71
71
  Program(programPath, state) {
72
- const importMetas = {}
72
+ const importMetas = {};
73
73
  programPath.traverse({
74
74
  MemberExpression(path) {
75
- const { node } = path
76
- const { object } = node
75
+ const { node } = path;
76
+ const { object } = node;
77
77
  if (object.type !== "MetaProperty") {
78
- return
78
+ return;
79
79
  }
80
- const { property: objectProperty } = object
80
+ const { property: objectProperty } = object;
81
81
  if (objectProperty.name !== "meta") {
82
- return
82
+ return;
83
83
  }
84
- const { property } = node
85
- const { name } = property
86
- const importMetaPaths = importMetas[name]
84
+ const { property } = node;
85
+ const { name } = property;
86
+ const importMetaPaths = importMetas[name];
87
87
  if (importMetaPaths) {
88
- importMetaPaths.push(path)
88
+ importMetaPaths.push(path);
89
89
  } else {
90
- importMetas[name] = [path]
90
+ importMetas[name] = [path];
91
91
  }
92
92
  },
93
- })
93
+ });
94
94
  state.file.metadata.importMetaScenarios = {
95
95
  dev: importMetas.dev,
96
96
  build: importMetas.build,
97
- }
97
+ };
98
98
  },
99
99
  },
100
- }
101
- }
100
+ };
101
+ };
@@ -1,51 +1,51 @@
1
1
  const getCurrentScriptSrc = () => {
2
- const { currentScript } = document
3
- if (currentScript) return currentScript.src
2
+ const { currentScript } = document;
3
+ if (currentScript) return currentScript.src;
4
4
 
5
5
  // https://github.com/amiller-gh/currentScript-polyfill
6
6
 
7
7
  const scripts = Array.prototype.slice.call(
8
8
  document.getElementsByTagName("script"),
9
- )
9
+ );
10
10
 
11
11
  const readyScript = scripts.find((script) => {
12
- return script.readyState === "interactive"
13
- })
14
- if (readyScript) return readyScript
12
+ return script.readyState === "interactive";
13
+ });
14
+ if (readyScript) return readyScript;
15
15
 
16
16
  try {
17
- throw new Error()
17
+ throw new Error();
18
18
  } catch (err) {
19
19
  // Find the second match for the "at" string to get file src url from stack.
20
20
  // Specifically works with the format of stack traces in IE.
21
- const stackDetails = /.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(err.stack)
22
- const scriptLocation = (stackDetails || [false])[1]
23
- const line = (stackDetails || [false])[2]
21
+ const stackDetails = /.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(err.stack);
22
+ const scriptLocation = (stackDetails || [false])[1];
23
+ const line = (stackDetails || [false])[2];
24
24
  const currentLocation = document.location.href.replace(
25
25
  document.location.hash,
26
26
  "",
27
- )
27
+ );
28
28
 
29
29
  if (scriptLocation === currentLocation) {
30
- const source = document.documentElement.outerHTML
30
+ const source = document.documentElement.outerHTML;
31
31
  const codeRegExp = new RegExp(
32
32
  `(?:[^\\n]+?\\n){0,${
33
33
  line - 2
34
34
  }}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*`,
35
35
  "i",
36
- )
37
- const code = source.replace(codeRegExp, "$1").trim()
36
+ );
37
+ const code = source.replace(codeRegExp, "$1").trim();
38
38
 
39
39
  return scripts.find((script) => {
40
- return script.innerHTML && script.innerHTML.trim() === code
41
- })
40
+ return script.innerHTML && script.innerHTML.trim() === code;
41
+ });
42
42
  }
43
43
 
44
44
  return scripts.find((script) => {
45
- return script.src === scriptLocation
46
- })
45
+ return script.src === scriptLocation;
46
+ });
47
47
  }
48
- }
48
+ };
49
49
 
50
- const url = getCurrentScriptSrc()
51
- export { url }
50
+ const url = getCurrentScriptSrc();
51
+ export { url };
@@ -1,9 +1,9 @@
1
1
  /* global __filename */
2
2
 
3
- const filenameContainsBackSlashes = __filename.indexOf("\\") > -1
3
+ const filenameContainsBackSlashes = __filename.indexOf("\\") > -1;
4
4
 
5
5
  const url = filenameContainsBackSlashes
6
6
  ? `file:///${__filename.replace(/\\/g, "/")}`
7
- : `file://${__filename}`
7
+ : `file://${__filename}`;
8
8
 
9
- export { url }
9
+ export { url };
@@ -21,8 +21,8 @@ import {
21
21
  resolveImport,
22
22
  composeTwoImportMaps,
23
23
  normalizeImportMap,
24
- } from "@jsenv/importmap"
25
- import { generateInlineContentUrl } from "@jsenv/urls"
24
+ } from "@jsenv/importmap";
25
+ import { generateInlineContentUrl } from "@jsenv/urls";
26
26
  import {
27
27
  parseHtmlString,
28
28
  stringifyHtmlAst,
@@ -33,26 +33,26 @@ import {
33
33
  getHtmlNodeText,
34
34
  setHtmlNodeText,
35
35
  removeHtmlNode,
36
- } from "@jsenv/ast"
36
+ } from "@jsenv/ast";
37
37
 
38
38
  export const jsenvPluginImportmap = () => {
39
- let finalImportmap = null
40
- const importmaps = {}
39
+ let finalImportmap = null;
40
+ const importmaps = {};
41
41
  const onHtmlImportmapParsed = (importmap, htmlUrl) => {
42
42
  importmaps[htmlUrl] = importmap
43
43
  ? normalizeImportMap(importmap, htmlUrl)
44
- : null
44
+ : null;
45
45
  finalImportmap = Object.keys(importmaps).reduce((previous, url) => {
46
- const importmap = importmaps[url]
46
+ const importmap = importmaps[url];
47
47
  if (!previous) {
48
- return importmap
48
+ return importmap;
49
49
  }
50
50
  if (!importmap) {
51
- return previous
51
+ return previous;
52
52
  }
53
- return composeTwoImportMaps(previous, importmap)
54
- }, null)
55
- }
53
+ return composeTwoImportMaps(previous, importmap);
54
+ }, null);
55
+ };
56
56
 
57
57
  return {
58
58
  name: "jsenv:importmap",
@@ -60,22 +60,22 @@ export const jsenvPluginImportmap = () => {
60
60
  resolveUrl: {
61
61
  js_import: (reference) => {
62
62
  if (!finalImportmap) {
63
- return null
63
+ return null;
64
64
  }
65
65
  try {
66
- let fromMapping = false
66
+ let fromMapping = false;
67
67
  const result = resolveImport({
68
68
  specifier: reference.specifier,
69
69
  importer: reference.parentUrl,
70
70
  importMap: finalImportmap,
71
71
  onImportMapping: () => {
72
- fromMapping = true
72
+ fromMapping = true;
73
73
  },
74
- })
74
+ });
75
75
  if (fromMapping) {
76
- return result
76
+ return result;
77
77
  }
78
- return null
78
+ return null;
79
79
  } catch (e) {
80
80
  if (e.message.includes("bare specifier")) {
81
81
  // in theory we should throw to be compliant with web behaviour
@@ -83,34 +83,34 @@ export const jsenvPluginImportmap = () => {
83
83
  // and let a chance to other plugins to handle the bare specifier
84
84
  // (node esm resolution)
85
85
  // and we want importmap to be prio over node esm so we cannot put this plugin after
86
- return null
86
+ return null;
87
87
  }
88
- throw e
88
+ throw e;
89
89
  }
90
90
  },
91
91
  },
92
92
  transformUrlContent: {
93
93
  html: async (htmlUrlInfo, context) => {
94
- const htmlAst = parseHtmlString(htmlUrlInfo.content)
94
+ const htmlAst = parseHtmlString(htmlUrlInfo.content);
95
95
  const importmap = findHtmlNode(htmlAst, (node) => {
96
96
  if (node.nodeName !== "script") {
97
- return false
97
+ return false;
98
98
  }
99
- const type = getHtmlNodeAttribute(node, "type")
99
+ const type = getHtmlNodeAttribute(node, "type");
100
100
  if (type === undefined || type !== "importmap") {
101
- return false
101
+ return false;
102
102
  }
103
- return true
104
- })
103
+ return true;
104
+ });
105
105
  if (!importmap) {
106
- onHtmlImportmapParsed(null, htmlUrlInfo.url)
107
- return null
106
+ onHtmlImportmapParsed(null, htmlUrlInfo.url);
107
+ return null;
108
108
  }
109
109
  const handleInlineImportmap = async (importmap, htmlNodeText) => {
110
110
  const { line, column, lineEnd, columnEnd, isOriginal } =
111
111
  getHtmlNodePosition(importmap, {
112
112
  preferOriginal: true,
113
- })
113
+ });
114
114
  const inlineImportmapUrl = generateInlineContentUrl({
115
115
  url: htmlUrlInfo.url,
116
116
  extension: ".importmap",
@@ -118,7 +118,7 @@ export const jsenvPluginImportmap = () => {
118
118
  column,
119
119
  lineEnd,
120
120
  columnEnd,
121
- })
121
+ });
122
122
  const [inlineImportmapReference, inlineImportmapUrlInfo] =
123
123
  context.referenceUtils.foundInline({
124
124
  type: "script",
@@ -128,21 +128,21 @@ export const jsenvPluginImportmap = () => {
128
128
  specifier: inlineImportmapUrl,
129
129
  contentType: "application/importmap+json",
130
130
  content: htmlNodeText,
131
- })
131
+ });
132
132
  await context.cook(inlineImportmapUrlInfo, {
133
133
  reference: inlineImportmapReference,
134
- })
134
+ });
135
135
  setHtmlNodeText(importmap, inlineImportmapUrlInfo.content, {
136
136
  indentation: "auto",
137
- })
137
+ });
138
138
  setHtmlNodeAttributes(importmap, {
139
139
  "jsenv-cooked-by": "jsenv:importmap",
140
- })
140
+ });
141
141
  onHtmlImportmapParsed(
142
142
  JSON.parse(inlineImportmapUrlInfo.content),
143
143
  htmlUrlInfo.url,
144
- )
145
- }
144
+ );
145
+ };
146
146
  const handleImportmapWithSrc = async (importmap, src) => {
147
147
  // Browser would throw on remote importmap
148
148
  // and won't sent a request to the server for it
@@ -151,30 +151,30 @@ export const jsenvPluginImportmap = () => {
151
151
  // when parsing the HTML
152
152
  const importmapReference = context.referenceUtils.find(
153
153
  (ref) => ref.generatedSpecifier === src,
154
- )
154
+ );
155
155
  const importmapUrlInfo = context.urlGraph.getUrlInfo(
156
156
  importmapReference.url,
157
- )
157
+ );
158
158
  await context.cook(importmapUrlInfo, {
159
159
  reference: importmapReference,
160
- })
160
+ });
161
161
  onHtmlImportmapParsed(
162
162
  JSON.parse(importmapUrlInfo.content),
163
163
  htmlUrlInfo.url,
164
- )
164
+ );
165
165
  setHtmlNodeText(importmap, importmapUrlInfo.content, {
166
166
  indentation: "auto",
167
- })
167
+ });
168
168
  setHtmlNodeAttributes(importmap, {
169
169
  "src": undefined,
170
170
  "jsenv-inlined-by": "jsenv:importmap",
171
171
  "inlined-from-src": src,
172
- })
172
+ });
173
173
 
174
174
  const { line, column, lineEnd, columnEnd, isOriginal } =
175
175
  getHtmlNodePosition(importmap, {
176
176
  preferOriginal: true,
177
- })
177
+ });
178
178
  const inlineImportmapUrl = generateInlineContentUrl({
179
179
  url: htmlUrlInfo.url,
180
180
  extension: ".importmap",
@@ -182,7 +182,7 @@ export const jsenvPluginImportmap = () => {
182
182
  column,
183
183
  lineEnd,
184
184
  columnEnd,
185
- })
185
+ });
186
186
  context.referenceUtils.becomesInline(importmapReference, {
187
187
  line: line - 1,
188
188
  column,
@@ -190,16 +190,16 @@ export const jsenvPluginImportmap = () => {
190
190
  specifier: inlineImportmapUrl,
191
191
  contentType: "application/importmap+json",
192
192
  content: importmapUrlInfo.content,
193
- })
194
- }
193
+ });
194
+ };
195
195
 
196
- const src = getHtmlNodeAttribute(importmap, "src")
196
+ const src = getHtmlNodeAttribute(importmap, "src");
197
197
  if (src) {
198
- await handleImportmapWithSrc(importmap, src)
198
+ await handleImportmapWithSrc(importmap, src);
199
199
  } else {
200
- const htmlNodeText = getHtmlNodeText(importmap)
200
+ const htmlNodeText = getHtmlNodeText(importmap);
201
201
  if (htmlNodeText) {
202
- await handleInlineImportmap(importmap, htmlNodeText)
202
+ await handleInlineImportmap(importmap, htmlNodeText);
203
203
  }
204
204
  }
205
205
  // once this plugin knows the importmap, it will use it
@@ -208,12 +208,12 @@ export const jsenvPluginImportmap = () => {
208
208
  // In dev/test we keep importmap into the HTML to see it even if useless
209
209
  // Duing build we get rid of it
210
210
  if (context.build) {
211
- removeHtmlNode(importmap)
211
+ removeHtmlNode(importmap);
212
212
  }
213
213
  return {
214
214
  content: stringifyHtmlAst(htmlAst),
215
- }
215
+ };
216
216
  },
217
217
  },
218
- }
219
- }
218
+ };
219
+ };
@@ -1,6 +1,6 @@
1
1
  function InlineContent(content, { type = "text/plain" }) {
2
- this.text = content
3
- this.type = type
2
+ this.text = content;
3
+ this.type = type;
4
4
  }
5
5
 
6
- export { InlineContent }
6
+ export { InlineContent };
@@ -1,5 +1,5 @@
1
- import { DATA_URL } from "@jsenv/urls"
2
- import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js"
1
+ import { DATA_URL } from "@jsenv/urls";
2
+ import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
3
3
 
4
4
  export const jsenvPluginDataUrls = () => {
5
5
  return {
@@ -7,37 +7,37 @@ export const jsenvPluginDataUrls = () => {
7
7
  appliesDuring: "*",
8
8
  resolveUrl: (reference) => {
9
9
  if (!reference.specifier.startsWith("data:")) {
10
- return null
10
+ return null;
11
11
  }
12
- return reference.specifier
12
+ return reference.specifier;
13
13
  },
14
14
  fetchUrlContent: (urlInfo) => {
15
15
  if (!urlInfo.url.startsWith("data:")) {
16
- return null
16
+ return null;
17
17
  }
18
18
  const {
19
19
  contentType,
20
20
  base64Flag,
21
21
  data: urlData,
22
- } = DATA_URL.parse(urlInfo.url)
23
- urlInfo.data.base64Flag = base64Flag
22
+ } = DATA_URL.parse(urlInfo.url);
23
+ urlInfo.data.base64Flag = base64Flag;
24
24
  return {
25
25
  content: contentFromUrlData({ contentType, base64Flag, urlData }),
26
26
  contentType,
27
- }
27
+ };
28
28
  },
29
29
  formatUrl: (reference, context) => {
30
30
  if (!reference.generatedUrl.startsWith("data:")) {
31
- return null
31
+ return null;
32
32
  }
33
33
  if (reference.type === "sourcemap_comment") {
34
- return null
34
+ return null;
35
35
  }
36
36
  return (async () => {
37
- const urlInfo = context.urlGraph.getUrlInfo(reference.url)
38
- await context.cook(urlInfo, { reference })
37
+ const urlInfo = context.urlGraph.getUrlInfo(reference.url);
38
+ await context.cook(urlInfo, { reference });
39
39
  if (urlInfo.originalContent === urlInfo.content) {
40
- return reference.generatedUrl
40
+ return reference.generatedUrl;
41
41
  }
42
42
  const specifier = DATA_URL.stringify({
43
43
  contentType: urlInfo.contentType,
@@ -45,27 +45,27 @@ export const jsenvPluginDataUrls = () => {
45
45
  data: urlInfo.data.base64Flag
46
46
  ? dataToBase64(urlInfo.content)
47
47
  : String(urlInfo.content),
48
- })
49
- return specifier
50
- })()
48
+ });
49
+ return specifier;
50
+ })();
51
51
  },
52
- }
53
- }
52
+ };
53
+ };
54
54
 
55
55
  const contentFromUrlData = ({ contentType, base64Flag, urlData }) => {
56
56
  if (CONTENT_TYPE.isTextual(contentType)) {
57
57
  if (base64Flag) {
58
- return base64ToString(urlData)
58
+ return base64ToString(urlData);
59
59
  }
60
- return urlData
60
+ return urlData;
61
61
  }
62
62
  if (base64Flag) {
63
- return base64ToBuffer(urlData)
63
+ return base64ToBuffer(urlData);
64
64
  }
65
- return Buffer.from(urlData)
66
- }
65
+ return Buffer.from(urlData);
66
+ };
67
67
 
68
- const base64ToBuffer = (base64String) => Buffer.from(base64String, "base64")
68
+ const base64ToBuffer = (base64String) => Buffer.from(base64String, "base64");
69
69
  const base64ToString = (base64String) =>
70
- Buffer.from(base64String, "base64").toString("utf8")
71
- const dataToBase64 = (data) => Buffer.from(data).toString("base64")
70
+ Buffer.from(base64String, "base64").toString("utf8");
71
+ const dataToBase64 = (data) => Buffer.from(data).toString("base64");