@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,18 +1,18 @@
1
- import { readFileSync } from "node:fs"
2
- import { serveDirectory, composeTwoResponses } from "@jsenv/server"
3
- import { bufferToEtag } from "@jsenv/filesystem"
4
- import { asUrlWithoutSearch } from "@jsenv/urls"
5
- import { URL_META } from "@jsenv/url-meta"
1
+ import { readFileSync } from "node:fs";
2
+ import { serveDirectory, composeTwoResponses } from "@jsenv/server";
3
+ import { bufferToEtag } from "@jsenv/filesystem";
4
+ import { asUrlWithoutSearch } from "@jsenv/urls";
5
+ import { URL_META } from "@jsenv/url-meta";
6
6
 
7
- import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js"
8
- import { watchSourceFiles } from "../helpers/watch_source_files.js"
9
- import { createUrlGraph } from "../kitchen/url_graph.js"
10
- import { createKitchen } from "../kitchen/kitchen.js"
11
- import { RUNTIME_COMPAT } from "../kitchen/compat/runtime_compat.js"
12
- import { getCorePlugins } from "../plugins/plugins.js"
13
- import { explorerHtmlFileUrl } from "../plugins/explorer/jsenv_plugin_explorer.js"
14
- import { jsenvPluginServerEventsClientInjection } from "../plugins/server_events/jsenv_plugin_server_events_client_injection.js"
15
- import { parseUserAgentHeader } from "./user_agent.js"
7
+ import { WEB_URL_CONVERTER } from "../helpers/web_url_converter.js";
8
+ import { watchSourceFiles } from "../helpers/watch_source_files.js";
9
+ import { createUrlGraph } from "../kitchen/url_graph.js";
10
+ import { createKitchen } from "../kitchen/kitchen.js";
11
+ import { RUNTIME_COMPAT } from "../kitchen/compat/runtime_compat.js";
12
+ import { getCorePlugins } from "../plugins/plugins.js";
13
+ import { explorerHtmlFileUrl } from "../plugins/explorer/jsenv_plugin_explorer.js";
14
+ import { jsenvPluginServerEventsClientInjection } from "../plugins/server_events/jsenv_plugin_server_events_client_injection.js";
15
+ import { parseUserAgentHeader } from "./user_agent.js";
16
16
 
17
17
  export const createFileService = ({
18
18
  signal,
@@ -42,64 +42,64 @@ export const createFileService = ({
42
42
  sourcemapsSourcesContent,
43
43
  outDirectoryUrl,
44
44
  }) => {
45
- const clientFileChangeCallbackList = []
46
- const clientFilesPruneCallbackList = []
45
+ const clientFileChangeCallbackList = [];
46
+ const clientFilesPruneCallbackList = [];
47
47
  const stopWatchingSourceFiles = watchSourceFiles(
48
48
  sourceDirectoryUrl,
49
49
  (fileInfo) => {
50
50
  clientFileChangeCallbackList.forEach((callback) => {
51
- callback(fileInfo)
52
- })
51
+ callback(fileInfo);
52
+ });
53
53
  },
54
54
  {
55
55
  sourceFilesConfig,
56
56
  keepProcessAlive: false,
57
57
  cooldownBetweenFileEvents,
58
58
  },
59
- )
60
- serverStopCallbacks.push(stopWatchingSourceFiles)
59
+ );
60
+ serverStopCallbacks.push(stopWatchingSourceFiles);
61
61
 
62
62
  const getOrCreateContext = (request) => {
63
63
  const { runtimeName, runtimeVersion } = parseUserAgentHeader(
64
64
  request.headers["user-agent"] || "",
65
- )
66
- const runtimeId = `${runtimeName}@${runtimeVersion}`
67
- const existingContext = contextCache.get(runtimeId)
65
+ );
66
+ const runtimeId = `${runtimeName}@${runtimeVersion}`;
67
+ const existingContext = contextCache.get(runtimeId);
68
68
  if (existingContext) {
69
- return existingContext
69
+ return existingContext;
70
70
  }
71
71
  const watchAssociations = URL_META.resolveAssociations(
72
72
  { watch: stopWatchingSourceFiles.watchPatterns },
73
73
  sourceDirectoryUrl,
74
- )
74
+ );
75
75
  const urlGraph = createUrlGraph({
76
76
  name: runtimeId,
77
- })
77
+ });
78
78
  clientFileChangeCallbackList.push(({ url }) => {
79
79
  const onUrlInfo = (urlInfo) => {
80
- urlGraph.considerModified(urlInfo)
81
- }
82
- const exactUrlInfo = urlGraph.getUrlInfo(url)
80
+ urlGraph.considerModified(urlInfo);
81
+ };
82
+ const exactUrlInfo = urlGraph.getUrlInfo(url);
83
83
  if (exactUrlInfo) {
84
- onUrlInfo(exactUrlInfo)
84
+ onUrlInfo(exactUrlInfo);
85
85
  }
86
86
  urlGraph.urlInfoMap.forEach((urlInfo) => {
87
- if (urlInfo === exactUrlInfo) return
88
- const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url)
89
- if (urlWithoutSearch !== url) return
90
- if (exactUrlInfo && exactUrlInfo.dependents.has(urlInfo.url)) return
91
- onUrlInfo(urlInfo)
92
- })
93
- })
94
- const clientRuntimeCompat = { [runtimeName]: runtimeVersion }
87
+ if (urlInfo === exactUrlInfo) return;
88
+ const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
89
+ if (urlWithoutSearch !== url) return;
90
+ if (exactUrlInfo && exactUrlInfo.dependents.has(urlInfo.url)) return;
91
+ onUrlInfo(urlInfo);
92
+ });
93
+ });
94
+ const clientRuntimeCompat = { [runtimeName]: runtimeVersion };
95
95
 
96
- let defaultFileUrl
96
+ let defaultFileUrl;
97
97
  if (explorer) {
98
- defaultFileUrl = String(explorerHtmlFileUrl)
98
+ defaultFileUrl = String(explorerHtmlFileUrl);
99
99
  } else if (sourceMainFilePath) {
100
- defaultFileUrl = String(new URL(sourceMainFilePath, sourceDirectoryUrl))
100
+ defaultFileUrl = String(new URL(sourceMainFilePath, sourceDirectoryUrl));
101
101
  } else {
102
- defaultFileUrl = String(new URL("./index.html", sourceDirectoryUrl))
102
+ defaultFileUrl = String(new URL("./index.html", sourceDirectoryUrl));
103
103
  }
104
104
 
105
105
  const kitchen = createKitchen({
@@ -146,77 +146,77 @@ export const createFileService = ({
146
146
  outDirectoryUrl: outDirectoryUrl
147
147
  ? new URL(`${runtimeName}@${runtimeVersion}/`, outDirectoryUrl)
148
148
  : undefined,
149
- })
149
+ });
150
150
  urlGraph.createUrlInfoCallbackRef.current = (urlInfo) => {
151
151
  const { watch } = URL_META.applyAssociations({
152
152
  url: urlInfo.url,
153
153
  associations: watchAssociations,
154
- })
155
- urlInfo.isWatched = watch
154
+ });
155
+ urlInfo.isWatched = watch;
156
156
  // si une urlInfo dépends de pleins d'autres alors
157
157
  // on voudrait check chacune de ces url infos (package.json dans mon cas)
158
158
  urlInfo.isValid = () => {
159
159
  if (!urlInfo.url.startsWith("file:")) {
160
- return false
160
+ return false;
161
161
  }
162
162
  if (watch && urlInfo.contentEtag === undefined) {
163
163
  // we trust the watching mecanism
164
164
  // doing urlInfo.contentEtag = undefined
165
165
  // when file is modified
166
- return false
166
+ return false;
167
167
  }
168
168
  if (!watch && urlInfo.contentEtag) {
169
169
  // file is not watched, check the filesystem
170
- let fileContentAsBuffer
170
+ let fileContentAsBuffer;
171
171
  try {
172
- fileContentAsBuffer = readFileSync(new URL(urlInfo.url))
172
+ fileContentAsBuffer = readFileSync(new URL(urlInfo.url));
173
173
  } catch (e) {
174
174
  if (e.code === "ENOENT") {
175
175
  // we should consider calling urlGraph.deleteUrlInfo(urlInfo)
176
- urlInfo.originalContentEtag = undefined
177
- urlInfo.contentEtag = undefined
178
- return false
176
+ urlInfo.originalContentEtag = undefined;
177
+ urlInfo.contentEtag = undefined;
178
+ return false;
179
179
  }
180
- return false
180
+ return false;
181
181
  }
182
- const fileContentEtag = bufferToEtag(fileContentAsBuffer)
182
+ const fileContentEtag = bufferToEtag(fileContentAsBuffer);
183
183
  if (fileContentEtag !== urlInfo.originalContentEtag) {
184
184
  // we should consider calling urlGraph.considerModified(urlInfo)
185
- urlInfo.originalContentEtag = undefined
186
- urlInfo.contentEtag = undefined
187
- return false
185
+ urlInfo.originalContentEtag = undefined;
186
+ urlInfo.contentEtag = undefined;
187
+ return false;
188
188
  }
189
189
  }
190
190
  for (const implicitUrl of urlInfo.implicitUrls) {
191
- const implicitUrlInfo = context.urlGraph.getUrlInfo(implicitUrl)
191
+ const implicitUrlInfo = context.urlGraph.getUrlInfo(implicitUrl);
192
192
  if (implicitUrlInfo && !implicitUrlInfo.isValid()) {
193
- return false
193
+ return false;
194
194
  }
195
195
  }
196
- return true
197
- }
198
- }
196
+ return true;
197
+ };
198
+ };
199
199
  urlGraph.prunedUrlInfosCallbackRef.current = (urlInfos, firstUrlInfo) => {
200
200
  clientFilesPruneCallbackList.forEach((callback) => {
201
- callback(urlInfos, firstUrlInfo)
202
- })
203
- }
201
+ callback(urlInfos, firstUrlInfo);
202
+ });
203
+ };
204
204
  serverStopCallbacks.push(() => {
205
- kitchen.pluginController.callHooks("destroy", kitchen.kitchenContext)
206
- })
205
+ kitchen.pluginController.callHooks("destroy", kitchen.kitchenContext);
206
+ });
207
207
  server_events: {
208
- const allServerEvents = {}
208
+ const allServerEvents = {};
209
209
  kitchen.pluginController.plugins.forEach((plugin) => {
210
- const { serverEvents } = plugin
210
+ const { serverEvents } = plugin;
211
211
  if (serverEvents) {
212
212
  Object.keys(serverEvents).forEach((serverEventName) => {
213
213
  // we could throw on serverEvent name conflict
214
214
  // we could throw if serverEvents[serverEventName] is not a function
215
- allServerEvents[serverEventName] = serverEvents[serverEventName]
216
- })
215
+ allServerEvents[serverEventName] = serverEvents[serverEventName];
216
+ });
217
217
  }
218
- })
219
- const serverEventNames = Object.keys(allServerEvents)
218
+ });
219
+ const serverEventNames = Object.keys(allServerEvents);
220
220
  if (serverEventNames.length > 0) {
221
221
  Object.keys(allServerEvents).forEach((serverEventName) => {
222
222
  allServerEvents[serverEventName]({
@@ -227,14 +227,14 @@ export const createFileService = ({
227
227
  serverEventsDispatcher.dispatch({
228
228
  type: serverEventName,
229
229
  data,
230
- })
230
+ });
231
231
  },
232
- })
233
- })
232
+ });
233
+ });
234
234
  // "pushPlugin" so that event source client connection can be put as early as possible in html
235
235
  kitchen.pluginController.pushPlugin(
236
236
  jsenvPluginServerEventsClientInjection(),
237
- )
237
+ );
238
238
  }
239
239
  }
240
240
 
@@ -245,26 +245,26 @@ export const createFileService = ({
245
245
  runtimeVersion,
246
246
  urlGraph,
247
247
  kitchen,
248
- }
249
- contextCache.set(runtimeId, context)
250
- return context
251
- }
248
+ };
249
+ contextCache.set(runtimeId, context);
250
+ return context;
251
+ };
252
252
 
253
253
  return async (request) => {
254
- const { urlGraph, kitchen } = getOrCreateContext(request)
254
+ const { urlGraph, kitchen } = getOrCreateContext(request);
255
255
  const responseFromPlugin =
256
256
  await kitchen.pluginController.callAsyncHooksUntil(
257
257
  "serve",
258
258
  request,
259
259
  kitchen.kitchenContext,
260
- )
260
+ );
261
261
  if (responseFromPlugin) {
262
- return responseFromPlugin
262
+ return responseFromPlugin;
263
263
  }
264
- let reference
265
- const parentUrl = inferParentFromRequest(request, sourceDirectoryUrl)
264
+ let reference;
265
+ const parentUrl = inferParentFromRequest(request, sourceDirectoryUrl);
266
266
  if (parentUrl) {
267
- reference = urlGraph.inferReference(request.resource, parentUrl)
267
+ reference = urlGraph.inferReference(request.resource, parentUrl);
268
268
  }
269
269
  if (!reference) {
270
270
  const entryPoint = kitchen.injectReference({
@@ -272,17 +272,17 @@ export const createFileService = ({
272
272
  parentUrl: parentUrl || sourceDirectoryUrl,
273
273
  type: "http_request",
274
274
  specifier: request.resource,
275
- })
276
- reference = entryPoint[0]
275
+ });
276
+ reference = entryPoint[0];
277
277
  }
278
- const urlInfo = urlGraph.reuseOrCreateUrlInfo(reference.url)
279
- const ifNoneMatch = request.headers["if-none-match"]
280
- const urlInfoTargetedByCache = urlGraph.getParentIfInline(urlInfo)
278
+ const urlInfo = urlGraph.reuseOrCreateUrlInfo(reference.url);
279
+ const ifNoneMatch = request.headers["if-none-match"];
280
+ const urlInfoTargetedByCache = urlGraph.getParentIfInline(urlInfo);
281
281
 
282
282
  try {
283
283
  if (ifNoneMatch) {
284
284
  const [clientOriginalContentEtag, clientContentEtag] =
285
- ifNoneMatch.split("_")
285
+ ifNoneMatch.split("_");
286
286
  if (
287
287
  urlInfoTargetedByCache.originalContentEtag ===
288
288
  clientOriginalContentEtag &&
@@ -291,16 +291,16 @@ export const createFileService = ({
291
291
  ) {
292
292
  const headers = {
293
293
  "cache-control": `private,max-age=0,must-revalidate`,
294
- }
294
+ };
295
295
  Object.keys(urlInfo.headers).forEach((key) => {
296
296
  if (key !== "content-length") {
297
- headers[key] = urlInfo.headers[key]
297
+ headers[key] = urlInfo.headers[key];
298
298
  }
299
- })
299
+ });
300
300
  return {
301
301
  status: 304,
302
302
  headers,
303
- }
303
+ };
304
304
  }
305
305
  }
306
306
 
@@ -310,23 +310,23 @@ export const createFileService = ({
310
310
  !urlInfo.isInline &&
311
311
  urlInfo.type !== "sourcemap"
312
312
  ) {
313
- urlInfo.error = null
314
- urlInfo.sourcemap = null
315
- urlInfo.sourcemapIsWrong = null
316
- urlInfo.sourcemapReference = null
317
- urlInfo.content = null
318
- urlInfo.originalContent = null
319
- urlInfo.type = null
320
- urlInfo.subtype = null
321
- urlInfo.timing = {}
313
+ urlInfo.error = null;
314
+ urlInfo.sourcemap = null;
315
+ urlInfo.sourcemapIsWrong = null;
316
+ urlInfo.sourcemapReference = null;
317
+ urlInfo.content = null;
318
+ urlInfo.originalContent = null;
319
+ urlInfo.type = null;
320
+ urlInfo.subtype = null;
321
+ urlInfo.timing = {};
322
322
  }
323
323
  await kitchen.cook(urlInfo, {
324
324
  request,
325
325
  reference,
326
- })
327
- let { response } = urlInfo
326
+ });
327
+ let { response } = urlInfo;
328
328
  if (response) {
329
- return response
329
+ return response;
330
330
  }
331
331
  response = {
332
332
  url: reference.url,
@@ -351,23 +351,23 @@ export const createFileService = ({
351
351
  },
352
352
  body: urlInfo.content,
353
353
  timing: urlInfo.timing,
354
- }
354
+ };
355
355
  kitchen.pluginController.callHooks(
356
356
  "augmentResponse",
357
357
  { reference, urlInfo },
358
358
  kitchen.kitchenContext,
359
359
  (returnValue) => {
360
- response = composeTwoResponses(response, returnValue)
360
+ response = composeTwoResponses(response, returnValue);
361
361
  },
362
- )
363
- return response
362
+ );
363
+ return response;
364
364
  } catch (e) {
365
- urlInfo.error = e
366
- const originalError = e ? e.cause || e : e
365
+ urlInfo.error = e;
366
+ const originalError = e ? e.cause || e : e;
367
367
  if (originalError.asResponse) {
368
- return originalError.asResponse()
368
+ return originalError.asResponse();
369
369
  }
370
- const code = originalError.code
370
+ const code = originalError.code;
371
371
  if (code === "PARSE_ERROR") {
372
372
  // when possible let browser re-throw the syntax error
373
373
  // it's not possible to do that when url info content is not available
@@ -386,7 +386,7 @@ export const createFileService = ({
386
386
  "cache-control": "no-store",
387
387
  },
388
388
  body: urlInfo.content,
389
- }
389
+ };
390
390
  }
391
391
  return {
392
392
  url: reference.url,
@@ -397,7 +397,7 @@ export const createFileService = ({
397
397
  "cache-control": "no-store",
398
398
  },
399
399
  body: urlInfo.content,
400
- }
400
+ };
401
401
  }
402
402
  if (code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
403
403
  return serveDirectory(reference.url, {
@@ -406,14 +406,14 @@ export const createFileService = ({
406
406
  },
407
407
  canReadDirectory: true,
408
408
  rootDirectoryUrl: sourceDirectoryUrl,
409
- })
409
+ });
410
410
  }
411
411
  if (code === "NOT_ALLOWED") {
412
412
  return {
413
413
  url: reference.url,
414
414
  status: 403,
415
415
  statusText: originalError.reason,
416
- }
416
+ };
417
417
  }
418
418
  if (code === "NOT_FOUND") {
419
419
  return {
@@ -421,28 +421,28 @@ export const createFileService = ({
421
421
  status: 404,
422
422
  statusText: originalError.reason,
423
423
  statusMessage: originalError.message,
424
- }
424
+ };
425
425
  }
426
426
  return {
427
427
  url: reference.url,
428
428
  status: 500,
429
429
  statusText: e.reason,
430
430
  statusMessage: e.stack,
431
- }
431
+ };
432
432
  }
433
- }
434
- }
433
+ };
434
+ };
435
435
 
436
436
  const inferParentFromRequest = (request, sourceDirectoryUrl) => {
437
- const { referer } = request.headers
437
+ const { referer } = request.headers;
438
438
  if (!referer) {
439
- return null
439
+ return null;
440
440
  }
441
- const refererUrlObject = new URL(referer)
442
- refererUrlObject.searchParams.delete("hmr")
443
- refererUrlObject.searchParams.delete("v")
441
+ const refererUrlObject = new URL(referer);
442
+ refererUrlObject.searchParams.delete("hmr");
443
+ refererUrlObject.searchParams.delete("v");
444
444
  return WEB_URL_CONVERTER.asFileUrl(referer, {
445
445
  origin: request.origin,
446
446
  rootDirectoryUrl: sourceDirectoryUrl,
447
- })
448
- }
447
+ });
448
+ };