@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
@@ -319,7 +319,7 @@ h4 {
319
319
  </div>
320
320
  <script no-supervisor="">
321
321
  // eslint-disable-next-line no-undef
322
- const { rootDirectoryUrl, groups, files } = SERVER_PARAMS
322
+ const { rootDirectoryUrl, groups, files } = SERVER_PARAMS;
323
323
 
324
324
  const groupPreference = {
325
325
  has: () => localStorage.hasOwnProperty("explorer_active_group"),
@@ -329,30 +329,30 @@ h4 {
329
329
  : undefined,
330
330
  set: (value) =>
331
331
  localStorage.setItem("explorer_active_group", JSON.stringify(value)),
332
- }
332
+ };
333
333
  const directoryNameFromUrl = (directoryUrl) => {
334
334
  const slashLastIndex = directoryUrl.lastIndexOf(
335
335
  "/",
336
336
  // ignore last slash
337
337
  directoryUrl.length - 2,
338
- )
339
- if (slashLastIndex === -1) return ""
340
- return directoryUrl.slice(slashLastIndex + 1)
341
- }
338
+ );
339
+ if (slashLastIndex === -1) return "";
340
+ return directoryUrl.slice(slashLastIndex + 1);
341
+ };
342
342
  const urlToVisitFromRelativeUrl = (relativeUrl) => {
343
- return `${window.origin}/${relativeUrl}`
344
- }
343
+ return `${window.origin}/${relativeUrl}`;
344
+ };
345
345
 
346
346
  const fileListElement = document
347
347
  .querySelector(`[data-page="file-list"]`)
348
- .cloneNode(true)
349
- const directoryName = directoryNameFromUrl(rootDirectoryUrl)
350
- const span = fileListElement.querySelector("#directory_relative_url")
351
- span.title = rootDirectoryUrl
352
- span.textContent = directoryName
353
-
354
- const h4 = fileListElement.querySelector("h4")
355
- const ul = fileListElement.querySelector("ul")
348
+ .cloneNode(true);
349
+ const directoryName = directoryNameFromUrl(rootDirectoryUrl);
350
+ const span = fileListElement.querySelector("#directory_relative_url");
351
+ span.title = rootDirectoryUrl;
352
+ span.textContent = directoryName;
353
+
354
+ const h4 = fileListElement.querySelector("h4");
355
+ const ul = fileListElement.querySelector("ul");
356
356
  ul.innerHTML = files
357
357
  .map(
358
358
  (file) =>
@@ -366,10 +366,10 @@ h4 {
366
366
  </a>
367
367
  </li>`,
368
368
  )
369
- .join("")
369
+ .join("");
370
370
 
371
- const groupFieldset = fileListElement.querySelector("#filter-group-set")
372
- const groupNames = Object.keys(groups)
371
+ const groupFieldset = fileListElement.querySelector("#filter-group-set");
372
+ const groupNames = Object.keys(groups);
373
373
  groupFieldset.innerHTML = groupNames
374
374
  .map(
375
375
  (key) => `<label data-contains-hidden-input class="item">
@@ -377,45 +377,45 @@ h4 {
377
377
  <span>${key}</span>
378
378
  </label>`,
379
379
  )
380
- .join("")
380
+ .join("");
381
381
 
382
- const groupFromLocalStorage = groupPreference.get()
382
+ const groupFromLocalStorage = groupPreference.get();
383
383
  const currentGroup =
384
384
  groupFromLocalStorage && groupNames.includes(groupFromLocalStorage)
385
385
  ? groupFromLocalStorage
386
- : groupNames[0]
386
+ : groupNames[0];
387
387
  Array.from(groupFieldset.querySelectorAll("input")).forEach(
388
388
  (inputRadio) => {
389
- inputRadio.checked = inputRadio.value === currentGroup
389
+ inputRadio.checked = inputRadio.value === currentGroup;
390
390
  inputRadio.onchange = () => {
391
391
  if (inputRadio.checked) {
392
- groupPreference.set(inputRadio.value)
393
- enableGroup(inputRadio.value)
392
+ groupPreference.set(inputRadio.value);
393
+ enableGroup(inputRadio.value);
394
394
  }
395
- }
395
+ };
396
396
  },
397
- )
397
+ );
398
398
 
399
399
  const enableGroup = (groupName) => {
400
- const arrayOfElementToShow = []
401
- const arrayOfElementToHide = []
400
+ const arrayOfElementToShow = [];
401
+ const arrayOfElementToHide = [];
402
402
  files.forEach((file) => {
403
403
  const fileLink = fileListElement.querySelector(
404
404
  `a[data-relative-url="${file.relativeUrl}"]`,
405
- )
406
- const fileLi = fileLink.parentNode
405
+ );
406
+ const fileLi = fileLink.parentNode;
407
407
  if (file.meta[groupName]) {
408
- arrayOfElementToShow.push(fileLi)
408
+ arrayOfElementToShow.push(fileLi);
409
409
  } else {
410
- arrayOfElementToHide.push(fileLi)
410
+ arrayOfElementToHide.push(fileLi);
411
411
  }
412
- })
412
+ });
413
413
  arrayOfElementToShow.forEach((element) => {
414
- element.removeAttribute("data-force-hide")
415
- })
414
+ element.removeAttribute("data-force-hide");
415
+ });
416
416
  arrayOfElementToHide.forEach((element) => {
417
- element.setAttribute("data-force-hide", "")
418
- })
417
+ element.setAttribute("data-force-hide", "");
418
+ });
419
419
 
420
420
  h4.innerHTML =
421
421
  arrayOfElementToShow.length === 0
@@ -425,65 +425,65 @@ h4 {
425
425
  null,
426
426
  " ",
427
427
  )}</pre>`
428
- : `${arrayOfElementToShow.length} files found. Click on the one you want to execute`
429
- }
430
- enableGroup(currentGroup)
428
+ : `${arrayOfElementToShow.length} files found. Click on the one you want to execute`;
429
+ };
430
+ enableGroup(currentGroup);
431
431
 
432
- document.querySelector("main").appendChild(fileListElement)
432
+ document.querySelector("main").appendChild(fileListElement);
433
433
  </script>
434
434
  <script no-supervisor="">
435
435
  // make menu scrollable
436
436
  const getMenuWrapperSize = () => {
437
437
  return document.querySelector(".menu-wrapper").getBoundingClientRect()
438
- .width
439
- }
438
+ .width;
439
+ };
440
440
  const getMenuSize = () => {
441
- return document.querySelector(".menu").getBoundingClientRect().width
442
- }
441
+ return document.querySelector(".menu").getBoundingClientRect().width;
442
+ };
443
443
  const getMenuPosition = () => {
444
- return document.querySelector(".menu-wrapper").scrollLeft
445
- }
444
+ return document.querySelector(".menu-wrapper").scrollLeft;
445
+ };
446
446
 
447
- let menuWrapperSize = getMenuWrapperSize()
448
- let menuSize = getMenuSize()
449
- const menuVisibleSize = menuWrapperSize
450
- let menuInvisibleSize = menuSize - menuVisibleSize
451
- const scrollDuration = 300
452
- const leftPaddle = document.querySelector(".left-paddle")
453
- const rightPaddle = document.querySelector(".right-paddle")
447
+ let menuWrapperSize = getMenuWrapperSize();
448
+ let menuSize = getMenuSize();
449
+ const menuVisibleSize = menuWrapperSize;
450
+ let menuInvisibleSize = menuSize - menuVisibleSize;
451
+ const scrollDuration = 300;
452
+ const leftPaddle = document.querySelector(".left-paddle");
453
+ const rightPaddle = document.querySelector(".right-paddle");
454
454
 
455
455
  const handleMenuScroll = () => {
456
- menuInvisibleSize = menuSize - menuWrapperSize
457
- const menuPosition = getMenuPosition()
458
- const menuEndOffset = menuInvisibleSize
456
+ menuInvisibleSize = menuSize - menuWrapperSize;
457
+ const menuPosition = getMenuPosition();
458
+ const menuEndOffset = menuInvisibleSize;
459
459
  // show & hide the paddles, depending on scroll position
460
460
  if (menuPosition <= 0 && menuEndOffset <= 0) {
461
461
  // hide both paddles if the window is large enough to display all tabs
462
- leftPaddle.classList.add("hidden")
463
- rightPaddle.classList.add("hidden")
462
+ leftPaddle.classList.add("hidden");
463
+ rightPaddle.classList.add("hidden");
464
464
  } else if (menuPosition <= 0) {
465
- leftPaddle.classList.add("hidden")
466
- rightPaddle.classList.remove("hidden")
465
+ leftPaddle.classList.add("hidden");
466
+ rightPaddle.classList.remove("hidden");
467
467
  } else if (menuPosition < Math.floor(menuEndOffset)) {
468
468
  // show both paddles in the middle
469
- leftPaddle.classList.remove("hidden")
470
- rightPaddle.classList.remove("hidden")
469
+ leftPaddle.classList.remove("hidden");
470
+ rightPaddle.classList.remove("hidden");
471
471
  } else if (menuPosition >= Math.floor(menuEndOffset)) {
472
- leftPaddle.classList.remove("hidden")
473
- rightPaddle.classList.add("hidden")
472
+ leftPaddle.classList.remove("hidden");
473
+ rightPaddle.classList.add("hidden");
474
474
  }
475
- }
476
- handleMenuScroll()
475
+ };
476
+ handleMenuScroll();
477
477
 
478
478
  window.onresize = () => {
479
- menuWrapperSize = getMenuWrapperSize()
480
- menuSize = getMenuSize()
481
- handleMenuScroll()
482
- }
479
+ menuWrapperSize = getMenuWrapperSize();
480
+ menuSize = getMenuSize();
481
+ handleMenuScroll();
482
+ };
483
483
  // finally, what happens when we are actually scrolling the menu
484
484
  document.querySelector(".menu-wrapper").onscroll = () => {
485
- handleMenuScroll()
486
- }
485
+ handleMenuScroll();
486
+ };
487
487
 
488
488
  const startJavaScriptAnimation = ({
489
489
  duration = 300,
@@ -492,68 +492,68 @@ h4 {
492
492
  onCancel = () => {},
493
493
  onComplete = () => {},
494
494
  }) => {
495
- duration = parseInt(duration, 10)
496
- const startMs = performance.now()
497
- let currentRequestAnimationFrameId
498
- let done = false
499
- let rawProgress = 0
500
- let progress = 0
495
+ duration = parseInt(duration, 10);
496
+ const startMs = performance.now();
497
+ let currentRequestAnimationFrameId;
498
+ let done = false;
499
+ let rawProgress = 0;
500
+ let progress = 0;
501
501
  const handler = () => {
502
- currentRequestAnimationFrameId = null
503
- const nowMs = performance.now()
504
- rawProgress = Math.min((nowMs - startMs) / duration, 1)
505
- progress = timingFunction(rawProgress)
506
- done = rawProgress === 1
502
+ currentRequestAnimationFrameId = null;
503
+ const nowMs = performance.now();
504
+ rawProgress = Math.min((nowMs - startMs) / duration, 1);
505
+ progress = timingFunction(rawProgress);
506
+ done = rawProgress === 1;
507
507
  onProgress({
508
508
  done,
509
509
  rawProgress,
510
510
  progress,
511
- })
511
+ });
512
512
  if (done) {
513
- onComplete()
513
+ onComplete();
514
514
  } else {
515
515
  currentRequestAnimationFrameId =
516
- window.requestAnimationFrame(handler)
516
+ window.requestAnimationFrame(handler);
517
517
  }
518
- }
519
- handler()
518
+ };
519
+ handler();
520
520
  const stop = () => {
521
521
  if (currentRequestAnimationFrameId) {
522
- window.cancelAnimationFrame(currentRequestAnimationFrameId)
523
- currentRequestAnimationFrameId = null
522
+ window.cancelAnimationFrame(currentRequestAnimationFrameId);
523
+ currentRequestAnimationFrameId = null;
524
524
  }
525
525
  if (!done) {
526
- done = true
526
+ done = true;
527
527
  onCancel({
528
528
  rawProgress,
529
529
  progress,
530
- })
530
+ });
531
531
  }
532
- }
533
- return stop
534
- }
532
+ };
533
+ return stop;
534
+ };
535
535
  rightPaddle.onclick = () => {
536
- const scrollStart = document.querySelector(".menu-wrapper").scrollLeft
537
- const scrollEnd = scrollStart + menuWrapperSize
536
+ const scrollStart = document.querySelector(".menu-wrapper").scrollLeft;
537
+ const scrollEnd = scrollStart + menuWrapperSize;
538
538
  startJavaScriptAnimation({
539
539
  duration: scrollDuration,
540
540
  onProgress: ({ progress }) => {
541
541
  document.querySelector(".menu-wrapper").scrollLeft =
542
- scrollStart + (scrollEnd - scrollStart) * progress
542
+ scrollStart + (scrollEnd - scrollStart) * progress;
543
543
  },
544
- })
545
- }
544
+ });
545
+ };
546
546
  leftPaddle.onclick = () => {
547
- const scrollStart = document.querySelector(".menu-wrapper").scrollLeft
548
- const scrollEnd = scrollStart - menuWrapperSize
547
+ const scrollStart = document.querySelector(".menu-wrapper").scrollLeft;
548
+ const scrollEnd = scrollStart - menuWrapperSize;
549
549
  startJavaScriptAnimation({
550
550
  duration: scrollDuration,
551
551
  onProgress: ({ progress }) => {
552
552
  document.querySelector(".menu-wrapper").scrollLeft =
553
- scrollStart + (scrollEnd - scrollStart) * progress
553
+ scrollStart + (scrollEnd - scrollStart) * progress;
554
554
  },
555
- })
556
- }
555
+ });
556
+ };
557
557
  </script>
558
558
  </body>
559
559
  </html>
@@ -1,4 +1,7 @@
1
1
  /* eslint-disable */
2
+ // construct-style-sheets-polyfill@3.1.0
3
+ // to keep in sync with https://github.com/calebdwilliams/construct-style-sheets
4
+ // copy pasted into jsenv codebase to inject this code with more ease
2
5
  (function () {
3
6
 
4
7
  if (typeof document === "undefined" || "adoptedStyleSheets" in document) {