@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,20 +8,20 @@ import {
8
8
  analyzeScriptNode,
9
9
  parseSrcSet,
10
10
  stringifyHtmlAst,
11
- } from "@jsenv/ast"
11
+ } from "@jsenv/ast";
12
12
 
13
13
  export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
14
- const url = urlInfo.originalUrl
15
- const content = urlInfo.content
14
+ const url = urlInfo.originalUrl;
15
+ const content = urlInfo.content;
16
16
  const htmlAst = parseHtmlString(content, {
17
17
  storeOriginalPositions: context.dev,
18
- })
18
+ });
19
19
  const mentions = visitHtmlUrls({
20
20
  url,
21
21
  htmlAst,
22
- })
23
- const mutations = []
24
- const actions = []
22
+ });
23
+ const mutations = [];
24
+ const actions = [];
25
25
  for (const mention of mentions) {
26
26
  const {
27
27
  type,
@@ -35,15 +35,15 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
35
35
  attributeName,
36
36
  debug,
37
37
  specifier,
38
- } = mention
39
- const { crossorigin, integrity } = readFetchMetas(node)
38
+ } = mention;
39
+ const { crossorigin, integrity } = readFetchMetas(node);
40
40
  const isResourceHint = [
41
41
  "preconnect",
42
42
  "dns-prefetch",
43
43
  "prefetch",
44
44
  "preload",
45
45
  "modulepreload",
46
- ].includes(subtype)
46
+ ].includes(subtype);
47
47
  const [reference] = context.referenceUtils.found({
48
48
  type,
49
49
  subtype,
@@ -57,44 +57,44 @@ export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
57
57
  crossorigin,
58
58
  integrity,
59
59
  debug,
60
- })
60
+ });
61
61
  actions.push(async () => {
62
- await context.referenceUtils.readGeneratedSpecifier(reference)
62
+ await context.referenceUtils.readGeneratedSpecifier(reference);
63
63
  mutations.push(() => {
64
64
  setHtmlNodeAttributes(node, {
65
65
  [attributeName]: reference.generatedSpecifier,
66
- })
67
- })
68
- })
66
+ });
67
+ });
68
+ });
69
69
  }
70
70
  if (actions.length > 0) {
71
- await Promise.all(actions.map((action) => action()))
71
+ await Promise.all(actions.map((action) => action()));
72
72
  }
73
73
  if (mutations.length === 0) {
74
- return null
74
+ return null;
75
75
  }
76
- mutations.forEach((mutation) => mutation())
77
- return stringifyHtmlAst(htmlAst)
78
- }
76
+ mutations.forEach((mutation) => mutation());
77
+ return stringifyHtmlAst(htmlAst);
78
+ };
79
79
 
80
- const crossOriginCompatibleTagNames = ["script", "link", "img", "source"]
81
- const integrityCompatibleTagNames = ["script", "link", "img", "source"]
80
+ const crossOriginCompatibleTagNames = ["script", "link", "img", "source"];
81
+ const integrityCompatibleTagNames = ["script", "link", "img", "source"];
82
82
  const readFetchMetas = (node) => {
83
- const meta = {}
83
+ const meta = {};
84
84
  if (crossOriginCompatibleTagNames.includes(node.nodeName)) {
85
- const crossorigin = getHtmlNodeAttribute(node, "crossorigin") !== undefined
86
- meta.crossorigin = crossorigin
85
+ const crossorigin = getHtmlNodeAttribute(node, "crossorigin") !== undefined;
86
+ meta.crossorigin = crossorigin;
87
87
  }
88
88
  if (integrityCompatibleTagNames.includes(node.nodeName)) {
89
- const integrity = getHtmlNodeAttribute(node, "integrity")
90
- meta.integrity = integrity
89
+ const integrity = getHtmlNodeAttribute(node, "integrity");
90
+ meta.integrity = integrity;
91
91
  }
92
- return meta
93
- }
92
+ return meta;
93
+ };
94
94
 
95
95
  const visitHtmlUrls = ({ url, htmlAst }) => {
96
- const mentions = []
97
- const finalizeCallbacks = []
96
+ const mentions = [];
97
+ const finalizeCallbacks = [];
98
98
  const addMention = ({
99
99
  type,
100
100
  subtype,
@@ -103,20 +103,20 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
103
103
  attributeName,
104
104
  specifier,
105
105
  }) => {
106
- let position
106
+ let position;
107
107
  if (getHtmlNodeAttribute(node, "jsenv-cooked-by")) {
108
108
  // when generated from inline content,
109
109
  // line, column is not "src" nor "inlined-from-src" but "original-position"
110
- position = getHtmlNodePosition(node)
110
+ position = getHtmlNodePosition(node);
111
111
  } else {
112
- position = getHtmlNodeAttributePosition(node, attributeName)
112
+ position = getHtmlNodeAttributePosition(node, attributeName);
113
113
  }
114
114
  const {
115
115
  line,
116
116
  column,
117
117
  // originalLine, originalColumn
118
- } = position
119
- const debug = getHtmlNodeAttribute(node, "jsenv-debug") !== undefined
118
+ } = position;
119
+ const debug = getHtmlNodeAttribute(node, "jsenv-debug") !== undefined;
120
120
  const mention = {
121
121
  type,
122
122
  subtype,
@@ -128,19 +128,19 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
128
128
  node,
129
129
  attributeName,
130
130
  debug,
131
- }
132
- mentions.push(mention)
133
- return mention
134
- }
131
+ };
132
+ mentions.push(mention);
133
+ return mention;
134
+ };
135
135
  const visitAttributeAsUrlSpecifier = ({ node, attributeName, ...rest }) => {
136
- const value = getHtmlNodeAttribute(node, attributeName)
136
+ const value = getHtmlNodeAttribute(node, attributeName);
137
137
  if (value) {
138
138
  if (
139
139
  getHtmlNodeAttribute(node, "jsenv-inlined-by") === "jsenv:importmap"
140
140
  ) {
141
141
  // during build the importmap is inlined
142
142
  // and shoud not be considered as a dependency anymore
143
- return null
143
+ return null;
144
144
  }
145
145
  return addMention({
146
146
  ...rest,
@@ -151,42 +151,42 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
151
151
  attributeName === "inlined-from-href"
152
152
  ? new URL(value, url).href
153
153
  : value,
154
- })
154
+ });
155
155
  }
156
156
  if (attributeName === "src") {
157
157
  return visitAttributeAsUrlSpecifier({
158
158
  ...rest,
159
159
  node,
160
160
  attributeName: "inlined-from-src",
161
- })
161
+ });
162
162
  }
163
163
  if (attributeName === "href") {
164
164
  return visitAttributeAsUrlSpecifier({
165
165
  ...rest,
166
166
  node,
167
167
  attributeName: "inlined-from-href",
168
- })
168
+ });
169
169
  }
170
- return null
171
- }
170
+ return null;
171
+ };
172
172
  const visitSrcset = ({ type, node }) => {
173
- const srcset = getHtmlNodeAttribute(node, "srcset")
173
+ const srcset = getHtmlNodeAttribute(node, "srcset");
174
174
  if (srcset) {
175
- const srcCandidates = parseSrcSet(srcset)
175
+ const srcCandidates = parseSrcSet(srcset);
176
176
  srcCandidates.forEach((srcCandidate) => {
177
177
  addMention({
178
178
  type,
179
179
  node,
180
180
  attributeName: "srcset",
181
181
  specifier: srcCandidate.specifier,
182
- })
183
- })
182
+ });
183
+ });
184
184
  }
185
- }
185
+ };
186
186
  visitHtmlNodes(htmlAst, {
187
187
  link: (node) => {
188
- const rel = getHtmlNodeAttribute(node, "rel")
189
- const type = getHtmlNodeAttribute(node, "type")
188
+ const rel = getHtmlNodeAttribute(node, "rel");
189
+ const type = getHtmlNodeAttribute(node, "type");
190
190
  const mention = visitAttributeAsUrlSpecifier({
191
191
  type: "link_href",
192
192
  subtype: rel,
@@ -194,22 +194,22 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
194
194
  attributeName: "href",
195
195
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload#including_a_mime_type
196
196
  expectedContentType: type,
197
- })
197
+ });
198
198
 
199
199
  if (mention) {
200
200
  finalizeCallbacks.push(() => {
201
- mention.expectedType = decideLinkExpectedType(mention, mentions)
202
- })
201
+ mention.expectedType = decideLinkExpectedType(mention, mentions);
202
+ });
203
203
  }
204
204
  },
205
205
  // style: () => {},
206
206
  script: (node) => {
207
- const { type } = analyzeScriptNode(node)
207
+ const { type } = analyzeScriptNode(node);
208
208
  if (type === "text") {
209
209
  // ignore <script type="whatever" src="./file.js">
210
210
  // per HTML spec https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-type
211
211
  // this will be handled by jsenv_plugin_html_inline_content_analysis
212
- return
212
+ return;
213
213
  }
214
214
  visitAttributeAsUrlSpecifier({
215
215
  type: "script",
@@ -217,43 +217,43 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
217
217
  expectedType: type,
218
218
  node,
219
219
  attributeName: "src",
220
- })
220
+ });
221
221
  },
222
222
  a: (node) => {
223
223
  visitAttributeAsUrlSpecifier({
224
224
  type: "a_href",
225
225
  node,
226
226
  attributeName: "href",
227
- })
227
+ });
228
228
  },
229
229
  iframe: (node) => {
230
230
  visitAttributeAsUrlSpecifier({
231
231
  type: "iframe_src",
232
232
  node,
233
233
  attributeName: "src",
234
- })
234
+ });
235
235
  },
236
236
  img: (node) => {
237
237
  visitAttributeAsUrlSpecifier({
238
238
  type: "img_src",
239
239
  node,
240
240
  attributeName: "src",
241
- })
241
+ });
242
242
  visitSrcset({
243
243
  type: "img_srcset",
244
244
  node,
245
- })
245
+ });
246
246
  },
247
247
  source: (node) => {
248
248
  visitAttributeAsUrlSpecifier({
249
249
  type: "source_src",
250
250
  node,
251
251
  attributeName: "src",
252
- })
252
+ });
253
253
  visitSrcset({
254
254
  type: "source_srcset",
255
255
  node,
256
- })
256
+ });
257
257
  },
258
258
  // svg <image> tag
259
259
  image: (node) => {
@@ -261,53 +261,53 @@ const visitHtmlUrls = ({ url, htmlAst }) => {
261
261
  type: "image_href",
262
262
  node,
263
263
  attributeName: "href",
264
- })
264
+ });
265
265
  },
266
266
  use: (node) => {
267
267
  visitAttributeAsUrlSpecifier({
268
268
  type: "use_href",
269
269
  node,
270
270
  attributeName: "href",
271
- })
271
+ });
272
272
  },
273
- })
273
+ });
274
274
  finalizeCallbacks.forEach((finalizeCallback) => {
275
- finalizeCallback()
276
- })
277
- return mentions
278
- }
275
+ finalizeCallback();
276
+ });
277
+ return mentions;
278
+ };
279
279
 
280
280
  const decideLinkExpectedType = (linkMention, mentions) => {
281
- const rel = getHtmlNodeAttribute(linkMention.node, "rel")
281
+ const rel = getHtmlNodeAttribute(linkMention.node, "rel");
282
282
  if (rel === "webmanifest") {
283
- return "webmanifest"
283
+ return "webmanifest";
284
284
  }
285
285
  if (rel === "modulepreload") {
286
- return "js_module"
286
+ return "js_module";
287
287
  }
288
288
  if (rel === "stylesheet") {
289
- return "css"
289
+ return "css";
290
290
  }
291
291
  if (rel === "preload") {
292
292
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types/preload#what_types_of_content_can_be_preloaded
293
- const as = getHtmlNodeAttribute(linkMention.node, "as")
293
+ const as = getHtmlNodeAttribute(linkMention.node, "as");
294
294
  if (as === "document") {
295
- return "html"
295
+ return "html";
296
296
  }
297
297
  if (as === "style") {
298
- return "css"
298
+ return "css";
299
299
  }
300
300
  if (as === "script") {
301
301
  const firstScriptOnThisUrl = mentions.find(
302
302
  (mentionCandidate) =>
303
303
  mentionCandidate.url === linkMention.url &&
304
304
  mentionCandidate.type === "script",
305
- )
305
+ );
306
306
  if (firstScriptOnThisUrl) {
307
- return firstScriptOnThisUrl.expectedType
307
+ return firstScriptOnThisUrl.expectedType;
308
308
  }
309
- return undefined
309
+ return undefined;
310
310
  }
311
311
  }
312
- return undefined
313
- }
312
+ return undefined;
313
+ };
@@ -1,7 +1,7 @@
1
- import { createMagicSource } from "@jsenv/sourcemap"
2
- import { parseJsUrls } from "@jsenv/ast"
1
+ import { createMagicSource } from "@jsenv/sourcemap";
2
+ import { parseJsUrls } from "@jsenv/ast";
3
3
 
4
- import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js"
4
+ import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js";
5
5
 
6
6
  export const parseAndTransformJsUrls = async (urlInfo, context) => {
7
7
  const jsMentions = await parseJsUrls({
@@ -9,15 +9,15 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
9
9
  url: urlInfo.originalUrl,
10
10
  isJsModule: urlInfo.type === "js_module",
11
11
  isWebWorker: isWebWorkerUrlInfo(urlInfo),
12
- })
13
- const actions = []
14
- const magicSource = createMagicSource(urlInfo.content)
12
+ });
13
+ const actions = [];
14
+ const magicSource = createMagicSource(urlInfo.content);
15
15
  for (const jsMention of jsMentions) {
16
16
  if (
17
17
  jsMention.subtype === "import_static" ||
18
18
  jsMention.subtype === "import_dynamic"
19
19
  ) {
20
- urlInfo.data.usesImport = true
20
+ urlInfo.data.usesImport = true;
21
21
  }
22
22
  const [reference] = context.referenceUtils.found({
23
23
  node: jsMention.node,
@@ -42,24 +42,24 @@ export const parseAndTransformJsUrls = async (urlInfo, context) => {
42
42
  assert: jsMention.assert,
43
43
  assertNode: jsMention.assertNode,
44
44
  typePropertyNode: jsMention.typePropertyNode,
45
- })
45
+ });
46
46
  actions.push(async () => {
47
47
  const replacement = await context.referenceUtils.readGeneratedSpecifier(
48
48
  reference,
49
- )
49
+ );
50
50
  magicSource.replace({
51
51
  start: jsMention.start,
52
52
  end: jsMention.end,
53
53
  replacement,
54
- })
54
+ });
55
55
  if (reference.mutation) {
56
- reference.mutation(magicSource)
56
+ reference.mutation(magicSource);
57
57
  }
58
- })
58
+ });
59
59
  }
60
60
  if (actions.length > 0) {
61
- await Promise.all(actions.map((action) => action()))
61
+ await Promise.all(actions.map((action) => action()));
62
62
  }
63
- const { content, sourcemap } = magicSource.toContentAndSourcemap()
64
- return { content, sourcemap }
65
- }
63
+ const { content, sourcemap } = magicSource.toContentAndSourcemap();
64
+ return { content, sourcemap };
65
+ };
@@ -1,24 +1,24 @@
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
3
  export const jsenvPluginReferenceExpectedTypes = () => {
4
4
  const redirectJsUrls = (reference) => {
5
- const urlObject = new URL(reference.url)
6
- const { searchParams } = urlObject
5
+ const urlObject = new URL(reference.url);
6
+ const { searchParams } = urlObject;
7
7
 
8
8
  if (searchParams.has("entry_point")) {
9
- reference.isEntryPoint = true
9
+ reference.isEntryPoint = true;
10
10
  }
11
11
  if (searchParams.has("js_classic")) {
12
- reference.expectedType = "js_classic"
12
+ reference.expectedType = "js_classic";
13
13
  } else if (
14
14
  searchParams.has("js_module_fallback") ||
15
15
  searchParams.has("as_js_classic")
16
16
  ) {
17
- reference.expectedType = "js_classic"
17
+ reference.expectedType = "js_classic";
18
18
  } else if (searchParams.has("as_js_module")) {
19
- reference.expectedType = "js_module"
19
+ reference.expectedType = "js_module";
20
20
  } else if (searchParams.has("js_module")) {
21
- reference.expectedType = "js_module"
21
+ reference.expectedType = "js_module";
22
22
  } else if (
23
23
  reference.type === "js_url" &&
24
24
  reference.expectedType === undefined &&
@@ -27,18 +27,18 @@ export const jsenvPluginReferenceExpectedTypes = () => {
27
27
  // by default, js referenced by new URL is considered as "js_module"
28
28
  // in case this is not desired code must use "?js_classic" like
29
29
  // new URL('./file.js?js_classic', import.meta.url)
30
- reference.expectedType = "js_module"
30
+ reference.expectedType = "js_module";
31
31
  }
32
32
 
33
33
  if (searchParams.has("worker")) {
34
- reference.expectedSubtype = "worker"
34
+ reference.expectedSubtype = "worker";
35
35
  } else if (searchParams.has("service_worker")) {
36
- reference.expectedSubtype = "service_worker"
36
+ reference.expectedSubtype = "service_worker";
37
37
  } else if (searchParams.has("shared_worker")) {
38
- reference.expectedSubtype = "shared_worker"
38
+ reference.expectedSubtype = "shared_worker";
39
39
  }
40
- return urlObject.href
41
- }
40
+ return urlObject.href;
41
+ };
42
42
 
43
43
  return {
44
44
  name: "jsenv:reference_expected_types",
@@ -48,5 +48,5 @@ export const jsenvPluginReferenceExpectedTypes = () => {
48
48
  js_url: redirectJsUrls,
49
49
  js_import: redirectJsUrls,
50
50
  },
51
- }
52
- }
51
+ };
52
+ };
@@ -1,11 +1,11 @@
1
- import { URL_META } from "@jsenv/url-meta"
2
- import { urlToRelativeUrl } from "@jsenv/urls"
1
+ import { URL_META } from "@jsenv/url-meta";
2
+ import { urlToRelativeUrl } from "@jsenv/urls";
3
3
 
4
- import { jsenvPluginReferenceExpectedTypes } from "./jsenv_plugin_reference_expected_types.js"
5
- import { parseAndTransformHtmlUrls } from "./html/html_urls.js"
6
- import { parseAndTransformCssUrls } from "./css/css_urls.js"
7
- import { parseAndTransformJsUrls } from "./js/js_urls.js"
8
- import { parseAndTransformWebmanifestUrls } from "./webmanifest/webmanifest_urls.js"
4
+ import { jsenvPluginReferenceExpectedTypes } from "./jsenv_plugin_reference_expected_types.js";
5
+ import { parseAndTransformHtmlUrls } from "./html/html_urls.js";
6
+ import { parseAndTransformCssUrls } from "./css/css_urls.js";
7
+ import { parseAndTransformJsUrls } from "./js/js_urls.js";
8
+ import { parseAndTransformWebmanifestUrls } from "./webmanifest/webmanifest_urls.js";
9
9
 
10
10
  export const jsenvPluginUrlAnalysis = ({
11
11
  rootDirectoryUrl,
@@ -13,16 +13,16 @@ export const jsenvPluginUrlAnalysis = ({
13
13
  supportedProtocols = ["file:", "data:", "virtual:", "http:", "https:"],
14
14
  }) => {
15
15
  // eslint-disable-next-line no-unused-vars
16
- let getIncludeInfo = (url) => undefined
16
+ let getIncludeInfo = (url) => undefined;
17
17
  if (include) {
18
18
  const associations = URL_META.resolveAssociations(
19
19
  { include },
20
20
  rootDirectoryUrl,
21
- )
21
+ );
22
22
  getIncludeInfo = (url) => {
23
- const { include } = URL_META.applyAssociations({ url, associations })
24
- return include
25
- }
23
+ const { include } = URL_META.applyAssociations({ url, associations });
24
+ return include;
25
+ };
26
26
  }
27
27
 
28
28
  return [
@@ -31,7 +31,7 @@ export const jsenvPluginUrlAnalysis = ({
31
31
  appliesDuring: "*",
32
32
  redirectUrl: (reference) => {
33
33
  if (reference.shouldHandle !== undefined) {
34
- return
34
+ return;
35
35
  }
36
36
  if (
37
37
  reference.specifier[0] === "#" &&
@@ -41,24 +41,24 @@ export const jsenvPluginUrlAnalysis = ({
41
41
  // to resolve them (https://nodejs.org/api/packages.html#imports for instance)
42
42
  reference.type !== "js_import"
43
43
  ) {
44
- reference.shouldHandle = false
45
- return
44
+ reference.shouldHandle = false;
45
+ return;
46
46
  }
47
- const includeInfo = getIncludeInfo(reference.url)
47
+ const includeInfo = getIncludeInfo(reference.url);
48
48
  if (includeInfo === true) {
49
- reference.shouldHandle = true
50
- return
49
+ reference.shouldHandle = true;
50
+ return;
51
51
  }
52
52
  if (includeInfo === false) {
53
- reference.shouldHandle = false
54
- return
53
+ reference.shouldHandle = false;
54
+ return;
55
55
  }
56
- const { protocol } = new URL(reference.url)
56
+ const { protocol } = new URL(reference.url);
57
57
  const protocolIsSupported = supportedProtocols.some(
58
58
  (supportedProtocol) => protocol === supportedProtocol,
59
- )
59
+ );
60
60
  if (protocolIsSupported) {
61
- reference.shouldHandle = true
61
+ reference.shouldHandle = true;
62
62
  }
63
63
  },
64
64
  transformUrlContent: {
@@ -71,11 +71,11 @@ export const jsenvPluginUrlAnalysis = ({
71
71
  const originalDirectoryReference = findOriginalDirectoryReference(
72
72
  urlInfo,
73
73
  context,
74
- )
74
+ );
75
75
  const directoryRelativeUrl = urlToRelativeUrl(
76
76
  urlInfo.url,
77
77
  context.rootDirectoryUrl,
78
- )
78
+ );
79
79
  JSON.parse(urlInfo.content).forEach((directoryEntryName) => {
80
80
  context.referenceUtils.found({
81
81
  type: "filesystem",
@@ -84,33 +84,33 @@ export const jsenvPluginUrlAnalysis = ({
84
84
  trace: {
85
85
  message: `"${directoryRelativeUrl}${directoryEntryName}" entry in directory referenced by ${originalDirectoryReference.trace.message}`,
86
86
  },
87
- })
88
- })
87
+ });
88
+ });
89
89
  },
90
90
  },
91
91
  },
92
92
  jsenvPluginReferenceExpectedTypes(),
93
- ]
94
- }
93
+ ];
94
+ };
95
95
 
96
96
  const findOriginalDirectoryReference = (urlInfo, context) => {
97
97
  const findNonFileSystemAncestor = (urlInfo) => {
98
98
  for (const dependentUrl of urlInfo.dependents) {
99
- const dependentUrlInfo = context.urlGraph.getUrlInfo(dependentUrl)
99
+ const dependentUrlInfo = context.urlGraph.getUrlInfo(dependentUrl);
100
100
  if (dependentUrlInfo.type !== "directory") {
101
- return [dependentUrlInfo, urlInfo]
101
+ return [dependentUrlInfo, urlInfo];
102
102
  }
103
- const found = findNonFileSystemAncestor(dependentUrlInfo)
103
+ const found = findNonFileSystemAncestor(dependentUrlInfo);
104
104
  if (found) {
105
- return found
105
+ return found;
106
106
  }
107
107
  }
108
- return []
109
- }
110
- const [ancestor, child] = findNonFileSystemAncestor(urlInfo)
108
+ return [];
109
+ };
110
+ const [ancestor, child] = findNonFileSystemAncestor(urlInfo);
111
111
  if (!ancestor) {
112
- return null
112
+ return null;
113
113
  }
114
- const ref = ancestor.references.find((ref) => ref.url === child.url)
115
- return ref
116
- }
114
+ const ref = ancestor.references.find((ref) => ref.url === child.url);
115
+ return ref;
116
+ };
@@ -1,21 +1,21 @@
1
1
  export const parseAndTransformWebmanifestUrls = async (urlInfo, context) => {
2
- const content = urlInfo.content
3
- const manifest = JSON.parse(content)
4
- const actions = []
5
- const { icons = [] } = manifest
2
+ const content = urlInfo.content;
3
+ const manifest = JSON.parse(content);
4
+ const actions = [];
5
+ const { icons = [] } = manifest;
6
6
  icons.forEach((icon) => {
7
7
  const [reference] = context.referenceUtils.found({
8
8
  type: "webmanifest_icon_src",
9
9
  specifier: icon.src,
10
- })
10
+ });
11
11
  actions.push(async () => {
12
- icon.src = await context.referenceUtils.readGeneratedSpecifier(reference)
13
- })
14
- })
12
+ icon.src = await context.referenceUtils.readGeneratedSpecifier(reference);
13
+ });
14
+ });
15
15
 
16
16
  if (actions.length === 0) {
17
- return null
17
+ return null;
18
18
  }
19
- await Promise.all(actions.map((action) => action()))
20
- return JSON.stringify(manifest, null, " ")
21
- }
19
+ await Promise.all(actions.map((action) => action()));
20
+ return JSON.stringify(manifest, null, " ");
21
+ };