@jsenv/core 36.1.3 → 36.2.0

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