@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
@@ -2,50 +2,50 @@
2
2
  // construct-style-sheets-polyfill@3.1.0
3
3
  // to keep in sync with https://github.com/calebdwilliams/construct-style-sheets
4
4
  // copy pasted into jsenv codebase to inject this code with more ease
5
- ;(function () {
6
- "use strict"
5
+ (function () {
6
+ "use strict";
7
7
 
8
8
  if (typeof document === "undefined" || "adoptedStyleSheets" in document) {
9
- return
9
+ return;
10
10
  }
11
11
 
12
- var hasShadyCss = "ShadyCSS" in window && !ShadyCSS.nativeShadow
13
- var bootstrapper = document.implementation.createHTMLDocument("")
14
- var closedShadowRootRegistry = new WeakMap()
15
- var _DOMException = typeof DOMException === "object" ? Error : DOMException
16
- var defineProperty = Object.defineProperty
17
- var forEach = Array.prototype.forEach
12
+ var hasShadyCss = "ShadyCSS" in window && !ShadyCSS.nativeShadow;
13
+ var bootstrapper = document.implementation.createHTMLDocument("");
14
+ var closedShadowRootRegistry = new WeakMap();
15
+ var _DOMException = typeof DOMException === "object" ? Error : DOMException;
16
+ var defineProperty = Object.defineProperty;
17
+ var forEach = Array.prototype.forEach;
18
18
 
19
- var importPattern = /@import.+?;?$/gm
19
+ var importPattern = /@import.+?;?$/gm;
20
20
  function rejectImports(contents) {
21
- var _contents = contents.replace(importPattern, "")
21
+ var _contents = contents.replace(importPattern, "");
22
22
  if (_contents !== contents) {
23
23
  console.warn(
24
24
  "@import rules are not allowed here. See https://github.com/WICG/construct-stylesheets/issues/119#issuecomment-588352418",
25
- )
25
+ );
26
26
  }
27
- return _contents.trim()
27
+ return _contents.trim();
28
28
  }
29
29
  function isElementConnected(element) {
30
30
  return "isConnected" in element
31
31
  ? element.isConnected
32
- : document.contains(element)
32
+ : document.contains(element);
33
33
  }
34
34
  function unique(arr) {
35
35
  return arr.filter(function (value, index) {
36
- return arr.indexOf(value) === index
37
- })
36
+ return arr.indexOf(value) === index;
37
+ });
38
38
  }
39
39
  function diff(arr1, arr2) {
40
40
  return arr1.filter(function (value) {
41
- return arr2.indexOf(value) === -1
42
- })
41
+ return arr2.indexOf(value) === -1;
42
+ });
43
43
  }
44
44
  function removeNode(node) {
45
- node.parentNode.removeChild(node)
45
+ node.parentNode.removeChild(node);
46
46
  }
47
47
  function getShadowRoot(element) {
48
- return element.shadowRoot || closedShadowRootRegistry.get(element)
48
+ return element.shadowRoot || closedShadowRootRegistry.get(element);
49
49
  }
50
50
 
51
51
  var cssStyleSheetMethods = [
@@ -53,159 +53,159 @@
53
53
  "deleteRule",
54
54
  "insertRule",
55
55
  "removeRule",
56
- ]
57
- var NonConstructedStyleSheet = CSSStyleSheet
58
- var nonConstructedProto = NonConstructedStyleSheet.prototype
56
+ ];
57
+ var NonConstructedStyleSheet = CSSStyleSheet;
58
+ var nonConstructedProto = NonConstructedStyleSheet.prototype;
59
59
  nonConstructedProto.replace = function () {
60
60
  return Promise.reject(
61
61
  new _DOMException(
62
62
  "Can't call replace on non-constructed CSSStyleSheets.",
63
63
  ),
64
- )
65
- }
64
+ );
65
+ };
66
66
  nonConstructedProto.replaceSync = function () {
67
67
  throw new _DOMException(
68
68
  "Failed to execute 'replaceSync' on 'CSSStyleSheet': Can't call replaceSync on non-constructed CSSStyleSheets.",
69
- )
70
- }
69
+ );
70
+ };
71
71
  function isCSSStyleSheetInstance(instance) {
72
72
  return typeof instance === "object"
73
73
  ? proto$1.isPrototypeOf(instance) ||
74
74
  nonConstructedProto.isPrototypeOf(instance)
75
- : false
75
+ : false;
76
76
  }
77
77
  function isNonConstructedStyleSheetInstance(instance) {
78
78
  return typeof instance === "object"
79
79
  ? nonConstructedProto.isPrototypeOf(instance)
80
- : false
80
+ : false;
81
81
  }
82
- var $basicStyleElement = new WeakMap()
83
- var $locations = new WeakMap()
84
- var $adoptersByLocation = new WeakMap()
85
- var $appliedMethods = new WeakMap()
82
+ var $basicStyleElement = new WeakMap();
83
+ var $locations = new WeakMap();
84
+ var $adoptersByLocation = new WeakMap();
85
+ var $appliedMethods = new WeakMap();
86
86
  function addAdopterLocation(sheet, location) {
87
- var adopter = document.createElement("style")
88
- $adoptersByLocation.get(sheet).set(location, adopter)
89
- $locations.get(sheet).push(location)
90
- return adopter
87
+ var adopter = document.createElement("style");
88
+ $adoptersByLocation.get(sheet).set(location, adopter);
89
+ $locations.get(sheet).push(location);
90
+ return adopter;
91
91
  }
92
92
  function getAdopterByLocation(sheet, location) {
93
- return $adoptersByLocation.get(sheet).get(location)
93
+ return $adoptersByLocation.get(sheet).get(location);
94
94
  }
95
95
  function removeAdopterLocation(sheet, location) {
96
- $adoptersByLocation.get(sheet).delete(location)
96
+ $adoptersByLocation.get(sheet).delete(location);
97
97
  $locations.set(
98
98
  sheet,
99
99
  $locations.get(sheet).filter(function (_location) {
100
- return _location !== location
100
+ return _location !== location;
101
101
  }),
102
- )
102
+ );
103
103
  }
104
104
  function restyleAdopter(sheet, adopter) {
105
105
  requestAnimationFrame(function () {
106
- adopter.textContent = $basicStyleElement.get(sheet).textContent
106
+ adopter.textContent = $basicStyleElement.get(sheet).textContent;
107
107
  $appliedMethods.get(sheet).forEach(function (command) {
108
- return adopter.sheet[command.method].apply(adopter.sheet, command.args)
109
- })
110
- })
108
+ return adopter.sheet[command.method].apply(adopter.sheet, command.args);
109
+ });
110
+ });
111
111
  }
112
112
  function checkInvocationCorrectness(self) {
113
113
  if (!$basicStyleElement.has(self)) {
114
- throw new TypeError("Illegal invocation")
114
+ throw new TypeError("Illegal invocation");
115
115
  }
116
116
  }
117
117
  function ConstructedStyleSheet() {
118
- var self = this
119
- var style = document.createElement("style")
120
- bootstrapper.body.appendChild(style)
121
- $basicStyleElement.set(self, style)
122
- $locations.set(self, [])
123
- $adoptersByLocation.set(self, new WeakMap())
124
- $appliedMethods.set(self, [])
118
+ var self = this;
119
+ var style = document.createElement("style");
120
+ bootstrapper.body.appendChild(style);
121
+ $basicStyleElement.set(self, style);
122
+ $locations.set(self, []);
123
+ $adoptersByLocation.set(self, new WeakMap());
124
+ $appliedMethods.set(self, []);
125
125
  }
126
- var proto$1 = ConstructedStyleSheet.prototype
126
+ var proto$1 = ConstructedStyleSheet.prototype;
127
127
  proto$1.replace = function replace(contents) {
128
128
  try {
129
- this.replaceSync(contents)
130
- return Promise.resolve(this)
129
+ this.replaceSync(contents);
130
+ return Promise.resolve(this);
131
131
  } catch (e) {
132
- return Promise.reject(e)
132
+ return Promise.reject(e);
133
133
  }
134
- }
134
+ };
135
135
  proto$1.replaceSync = function replaceSync(contents) {
136
- checkInvocationCorrectness(this)
136
+ checkInvocationCorrectness(this);
137
137
  if (typeof contents === "string") {
138
- var self_1 = this
139
- $basicStyleElement.get(self_1).textContent = rejectImports(contents)
140
- $appliedMethods.set(self_1, [])
138
+ var self_1 = this;
139
+ $basicStyleElement.get(self_1).textContent = rejectImports(contents);
140
+ $appliedMethods.set(self_1, []);
141
141
  $locations.get(self_1).forEach(function (location) {
142
142
  if (location.isConnected()) {
143
- restyleAdopter(self_1, getAdopterByLocation(self_1, location))
143
+ restyleAdopter(self_1, getAdopterByLocation(self_1, location));
144
144
  }
145
- })
145
+ });
146
146
  }
147
- }
147
+ };
148
148
  defineProperty(proto$1, "cssRules", {
149
149
  configurable: true,
150
150
  enumerable: true,
151
151
  get: function cssRules() {
152
- checkInvocationCorrectness(this)
153
- return $basicStyleElement.get(this).sheet.cssRules
152
+ checkInvocationCorrectness(this);
153
+ return $basicStyleElement.get(this).sheet.cssRules;
154
154
  },
155
- })
155
+ });
156
156
  defineProperty(proto$1, "media", {
157
157
  configurable: true,
158
158
  enumerable: true,
159
159
  get: function media() {
160
- checkInvocationCorrectness(this)
161
- return $basicStyleElement.get(this).sheet.media
160
+ checkInvocationCorrectness(this);
161
+ return $basicStyleElement.get(this).sheet.media;
162
162
  },
163
- })
163
+ });
164
164
  cssStyleSheetMethods.forEach(function (method) {
165
165
  proto$1[method] = function () {
166
- var self = this
167
- checkInvocationCorrectness(self)
168
- var args = arguments
169
- $appliedMethods.get(self).push({ method: method, args: args })
166
+ var self = this;
167
+ checkInvocationCorrectness(self);
168
+ var args = arguments;
169
+ $appliedMethods.get(self).push({ method: method, args: args });
170
170
  $locations.get(self).forEach(function (location) {
171
171
  if (location.isConnected()) {
172
- var sheet = getAdopterByLocation(self, location).sheet
173
- sheet[method].apply(sheet, args)
172
+ var sheet = getAdopterByLocation(self, location).sheet;
173
+ sheet[method].apply(sheet, args);
174
174
  }
175
- })
176
- var basicSheet = $basicStyleElement.get(self).sheet
177
- return basicSheet[method].apply(basicSheet, args)
178
- }
179
- })
175
+ });
176
+ var basicSheet = $basicStyleElement.get(self).sheet;
177
+ return basicSheet[method].apply(basicSheet, args);
178
+ };
179
+ });
180
180
  defineProperty(ConstructedStyleSheet, Symbol.hasInstance, {
181
181
  configurable: true,
182
182
  value: isCSSStyleSheetInstance,
183
- })
183
+ });
184
184
 
185
185
  var defaultObserverOptions = {
186
186
  childList: true,
187
187
  subtree: true,
188
- }
189
- var locations = new WeakMap()
188
+ };
189
+ var locations = new WeakMap();
190
190
  function getAssociatedLocation(element) {
191
- var location = locations.get(element)
191
+ var location = locations.get(element);
192
192
  if (!location) {
193
- location = new Location(element)
194
- locations.set(element, location)
193
+ location = new Location(element);
194
+ locations.set(element, location);
195
195
  }
196
- return location
196
+ return location;
197
197
  }
198
198
  function attachAdoptedStyleSheetProperty(constructor) {
199
199
  defineProperty(constructor.prototype, "adoptedStyleSheets", {
200
200
  configurable: true,
201
201
  enumerable: true,
202
202
  get: function () {
203
- return getAssociatedLocation(this).sheets
203
+ return getAssociatedLocation(this).sheets;
204
204
  },
205
205
  set: function (sheets) {
206
- getAssociatedLocation(this).update(sheets)
206
+ getAssociatedLocation(this).update(sheets);
207
207
  },
208
- })
208
+ });
209
209
  }
210
210
  function traverseWebComponents(node, callback) {
211
211
  var iter = document.createNodeIterator(
@@ -214,168 +214,168 @@
214
214
  function (foundNode) {
215
215
  return getShadowRoot(foundNode)
216
216
  ? NodeFilter.FILTER_ACCEPT
217
- : NodeFilter.FILTER_REJECT
217
+ : NodeFilter.FILTER_REJECT;
218
218
  },
219
219
  null,
220
220
  false,
221
- )
221
+ );
222
222
  for (var next = void 0; (next = iter.nextNode()); ) {
223
- callback(getShadowRoot(next))
223
+ callback(getShadowRoot(next));
224
224
  }
225
225
  }
226
- var $element = new WeakMap()
227
- var $uniqueSheets = new WeakMap()
228
- var $observer = new WeakMap()
226
+ var $element = new WeakMap();
227
+ var $uniqueSheets = new WeakMap();
228
+ var $observer = new WeakMap();
229
229
  function isExistingAdopter(self, element) {
230
230
  return (
231
231
  element instanceof HTMLStyleElement &&
232
232
  $uniqueSheets.get(self).some(function (sheet) {
233
- return getAdopterByLocation(sheet, self)
233
+ return getAdopterByLocation(sheet, self);
234
234
  })
235
- )
235
+ );
236
236
  }
237
237
  function getAdopterContainer(self) {
238
- var element = $element.get(self)
239
- return element instanceof Document ? element.body : element
238
+ var element = $element.get(self);
239
+ return element instanceof Document ? element.body : element;
240
240
  }
241
241
  function adopt(self) {
242
- var styleList = document.createDocumentFragment()
243
- var sheets = $uniqueSheets.get(self)
244
- var observer = $observer.get(self)
245
- var container = getAdopterContainer(self)
246
- observer.disconnect()
242
+ var styleList = document.createDocumentFragment();
243
+ var sheets = $uniqueSheets.get(self);
244
+ var observer = $observer.get(self);
245
+ var container = getAdopterContainer(self);
246
+ observer.disconnect();
247
247
  sheets.forEach(function (sheet) {
248
248
  styleList.appendChild(
249
249
  getAdopterByLocation(sheet, self) || addAdopterLocation(sheet, self),
250
- )
251
- })
252
- container.insertBefore(styleList, null)
253
- observer.observe(container, defaultObserverOptions)
250
+ );
251
+ });
252
+ container.insertBefore(styleList, null);
253
+ observer.observe(container, defaultObserverOptions);
254
254
  sheets.forEach(function (sheet) {
255
- restyleAdopter(sheet, getAdopterByLocation(sheet, self))
256
- })
255
+ restyleAdopter(sheet, getAdopterByLocation(sheet, self));
256
+ });
257
257
  }
258
258
  function Location(element) {
259
- var self = this
260
- self.sheets = []
261
- $element.set(self, element)
262
- $uniqueSheets.set(self, [])
259
+ var self = this;
260
+ self.sheets = [];
261
+ $element.set(self, element);
262
+ $uniqueSheets.set(self, []);
263
263
  $observer.set(
264
264
  self,
265
265
  new MutationObserver(function (mutations, observer) {
266
266
  if (!document) {
267
- observer.disconnect()
268
- return
267
+ observer.disconnect();
268
+ return;
269
269
  }
270
270
  mutations.forEach(function (mutation) {
271
271
  if (!hasShadyCss) {
272
272
  forEach.call(mutation.addedNodes, function (node) {
273
273
  if (!(node instanceof Element)) {
274
- return
274
+ return;
275
275
  }
276
276
  traverseWebComponents(node, function (root) {
277
- getAssociatedLocation(root).connect()
278
- })
279
- })
277
+ getAssociatedLocation(root).connect();
278
+ });
279
+ });
280
280
  }
281
281
  forEach.call(mutation.removedNodes, function (node) {
282
282
  if (!(node instanceof Element)) {
283
- return
283
+ return;
284
284
  }
285
285
  if (isExistingAdopter(self, node)) {
286
- adopt(self)
286
+ adopt(self);
287
287
  }
288
288
  if (!hasShadyCss) {
289
289
  traverseWebComponents(node, function (root) {
290
- getAssociatedLocation(root).disconnect()
291
- })
290
+ getAssociatedLocation(root).disconnect();
291
+ });
292
292
  }
293
- })
294
- })
293
+ });
294
+ });
295
295
  }),
296
- )
296
+ );
297
297
  }
298
298
  Location.prototype = {
299
299
  isConnected: function () {
300
- var element = $element.get(this)
300
+ var element = $element.get(this);
301
301
  return element instanceof Document
302
302
  ? element.readyState !== "loading"
303
- : isElementConnected(element.host)
303
+ : isElementConnected(element.host);
304
304
  },
305
305
  connect: function () {
306
- var container = getAdopterContainer(this)
307
- $observer.get(this).observe(container, defaultObserverOptions)
306
+ var container = getAdopterContainer(this);
307
+ $observer.get(this).observe(container, defaultObserverOptions);
308
308
  if ($uniqueSheets.get(this).length > 0) {
309
- adopt(this)
309
+ adopt(this);
310
310
  }
311
311
  traverseWebComponents(container, function (root) {
312
- getAssociatedLocation(root).connect()
313
- })
312
+ getAssociatedLocation(root).connect();
313
+ });
314
314
  },
315
315
  disconnect: function () {
316
- $observer.get(this).disconnect()
316
+ $observer.get(this).disconnect();
317
317
  },
318
318
  update: function (sheets) {
319
- var self = this
319
+ var self = this;
320
320
  var locationType =
321
- $element.get(self) === document ? "Document" : "ShadowRoot"
321
+ $element.get(self) === document ? "Document" : "ShadowRoot";
322
322
  if (!Array.isArray(sheets)) {
323
323
  throw new TypeError(
324
324
  "Failed to set the 'adoptedStyleSheets' property on " +
325
325
  locationType +
326
326
  ": Iterator getter is not callable.",
327
- )
327
+ );
328
328
  }
329
329
  if (!sheets.every(isCSSStyleSheetInstance)) {
330
330
  throw new TypeError(
331
331
  "Failed to set the 'adoptedStyleSheets' property on " +
332
332
  locationType +
333
333
  ": Failed to convert value to 'CSSStyleSheet'",
334
- )
334
+ );
335
335
  }
336
336
  if (sheets.some(isNonConstructedStyleSheetInstance)) {
337
337
  throw new TypeError(
338
338
  "Failed to set the 'adoptedStyleSheets' property on " +
339
339
  locationType +
340
340
  ": Can't adopt non-constructed stylesheets",
341
- )
341
+ );
342
342
  }
343
- self.sheets = sheets
344
- var oldUniqueSheets = $uniqueSheets.get(self)
345
- var uniqueSheets = unique(sheets)
346
- var removedSheets = diff(oldUniqueSheets, uniqueSheets)
343
+ self.sheets = sheets;
344
+ var oldUniqueSheets = $uniqueSheets.get(self);
345
+ var uniqueSheets = unique(sheets);
346
+ var removedSheets = diff(oldUniqueSheets, uniqueSheets);
347
347
  removedSheets.forEach(function (sheet) {
348
- removeNode(getAdopterByLocation(sheet, self))
349
- removeAdopterLocation(sheet, self)
350
- })
351
- $uniqueSheets.set(self, uniqueSheets)
348
+ removeNode(getAdopterByLocation(sheet, self));
349
+ removeAdopterLocation(sheet, self);
350
+ });
351
+ $uniqueSheets.set(self, uniqueSheets);
352
352
  if (self.isConnected() && uniqueSheets.length > 0) {
353
- adopt(self)
353
+ adopt(self);
354
354
  }
355
355
  },
356
- }
356
+ };
357
357
 
358
- window.CSSStyleSheet = ConstructedStyleSheet
359
- attachAdoptedStyleSheetProperty(Document)
358
+ window.CSSStyleSheet = ConstructedStyleSheet;
359
+ attachAdoptedStyleSheetProperty(Document);
360
360
  if ("ShadowRoot" in window) {
361
- attachAdoptedStyleSheetProperty(ShadowRoot)
362
- var proto = Element.prototype
363
- var attach_1 = proto.attachShadow
361
+ attachAdoptedStyleSheetProperty(ShadowRoot);
362
+ var proto = Element.prototype;
363
+ var attach_1 = proto.attachShadow;
364
364
  proto.attachShadow = function attachShadow(init) {
365
- var root = attach_1.call(this, init)
365
+ var root = attach_1.call(this, init);
366
366
  if (init.mode === "closed") {
367
- closedShadowRootRegistry.set(this, root)
367
+ closedShadowRootRegistry.set(this, root);
368
368
  }
369
- return root
370
- }
369
+ return root;
370
+ };
371
371
  }
372
- var documentLocation = getAssociatedLocation(document)
372
+ var documentLocation = getAssociatedLocation(document);
373
373
  if (documentLocation.isConnected()) {
374
- documentLocation.connect()
374
+ documentLocation.connect();
375
375
  } else {
376
376
  document.addEventListener(
377
377
  "DOMContentLoaded",
378
378
  documentLocation.connect.bind(documentLocation),
379
- )
379
+ );
380
380
  }
381
- })()
381
+ })();
@@ -1,10 +1,10 @@
1
- import { pathToFileURL } from "node:url"
2
- import { injectJsImport } from "@jsenv/ast"
1
+ import { pathToFileURL } from "node:url";
2
+ import { injectJsImport } from "@jsenv/ast";
3
3
 
4
4
  export const regeneratorRuntimeClientFileUrl = new URL(
5
5
  "./client/regenerator_runtime.js",
6
6
  import.meta.url,
7
- ).href
7
+ ).href;
8
8
 
9
9
  export const babelPluginRegeneratorRuntimeAsJsenvImport = (
10
10
  babel,
@@ -14,20 +14,20 @@ export const babelPluginRegeneratorRuntimeAsJsenvImport = (
14
14
  name: "regenerator-runtime-as-jsenv-import",
15
15
  visitor: {
16
16
  Identifier(path, opts) {
17
- const { filename } = opts
18
- const fileUrl = pathToFileURL(filename).href
17
+ const { filename } = opts;
18
+ const fileUrl = pathToFileURL(filename).href;
19
19
  if (fileUrl === regeneratorRuntimeClientFileUrl) {
20
- return
20
+ return;
21
21
  }
22
- const { node } = path
22
+ const { node } = path;
23
23
  if (node.name === "regeneratorRuntime") {
24
24
  injectJsImport({
25
25
  programPath: path.scope.getProgramParent().path,
26
26
  from: getImportSpecifier(regeneratorRuntimeClientFileUrl),
27
27
  sideEffect: true,
28
- })
28
+ });
29
29
  }
30
30
  },
31
31
  },
32
- }
33
- }
32
+ };
33
+ };
@@ -1,8 +1,8 @@
1
- import { createRequire } from "node:module"
2
- import { pathToFileURL } from "node:url"
3
- import { requireFromJsenv } from "@jsenv/core/src/helpers/require_from_jsenv.js"
1
+ import { createRequire } from "node:module";
2
+ import { pathToFileURL } from "node:url";
3
+ import { requireFromJsenv } from "@jsenv/core/src/helpers/require_from_jsenv.js";
4
4
 
5
- const babelPluginPackagePath = requireFromJsenv.resolve("@jsenv/babel-plugins")
6
- const babelPluginPackageUrl = pathToFileURL(babelPluginPackagePath)
5
+ const babelPluginPackagePath = requireFromJsenv.resolve("@jsenv/babel-plugins");
6
+ const babelPluginPackageUrl = pathToFileURL(babelPluginPackagePath);
7
7
 
8
- export const requireBabelPlugin = createRequire(babelPluginPackageUrl)
8
+ export const requireBabelPlugin = createRequire(babelPluginPackageUrl);
@@ -1,4 +1,4 @@
1
- import { fileURLToPath } from "node:url"
1
+ import { fileURLToPath } from "node:url";
2
2
 
3
3
  export const jsenvPluginCssTranspilation = () => {
4
4
  return {
@@ -6,21 +6,21 @@ export const jsenvPluginCssTranspilation = () => {
6
6
  appliesDuring: "*",
7
7
  transformUrlContent: {
8
8
  css: async (urlInfo, context) => {
9
- const { code, map } = await transpileCss(urlInfo, context)
9
+ const { code, map } = await transpileCss(urlInfo, context);
10
10
  return {
11
11
  content: String(code),
12
12
  sourcemap: map,
13
- }
13
+ };
14
14
  },
15
15
  },
16
- }
17
- }
16
+ };
17
+ };
18
18
 
19
19
  const transpileCss = async (urlInfo, context) => {
20
20
  // https://lightningcss.dev/docs.html
21
- const { transform } = await import("lightningcss")
21
+ const { transform } = await import("lightningcss");
22
22
 
23
- const targets = runtimeCompatToTargets(context.runtimeCompat)
23
+ const targets = runtimeCompatToTargets(context.runtimeCompat);
24
24
  const { code, map } = transform({
25
25
  filename: fileURLToPath(urlInfo.originalUrl),
26
26
  code: Buffer.from(urlInfo.content),
@@ -30,25 +30,25 @@ const transpileCss = async (urlInfo, context) => {
30
30
  nesting: true,
31
31
  customMedia: true,
32
32
  },
33
- })
34
- return { code, map }
35
- }
33
+ });
34
+ return { code, map };
35
+ };
36
36
 
37
37
  const runtimeCompatToTargets = (runtimeCompat) => {
38
- const targets = {}
39
- ;["chrome", "firefox", "ie", "opera", "safari"].forEach((runtimeName) => {
40
- const version = runtimeCompat[runtimeName]
38
+ const targets = {};
39
+ ["chrome", "firefox", "ie", "opera", "safari"].forEach((runtimeName) => {
40
+ const version = runtimeCompat[runtimeName];
41
41
  if (version) {
42
- targets[runtimeName] = versionToBits(version)
42
+ targets[runtimeName] = versionToBits(version);
43
43
  }
44
- })
45
- return targets
46
- }
44
+ });
45
+ return targets;
46
+ };
47
47
 
48
48
  const versionToBits = (version) => {
49
49
  const [major, minor = 0, patch = 0] = version
50
50
  .split("-")[0]
51
51
  .split(".")
52
- .map((v) => parseInt(v, 10))
53
- return (major << 16) | (minor << 8) | patch
54
- }
52
+ .map((v) => parseInt(v, 10));
53
+ return (major << 16) | (minor << 8) | patch;
54
+ };