@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
@@ -10,93 +10,93 @@
10
10
  * - no support for importmap because jsenv don't need it
11
11
  */
12
12
 
13
- ;(function () {
13
+ (function () {
14
14
  /* eslint-env browser */
15
15
 
16
- const loadRegistry = Object.create(null)
17
- const registerRegistry = Object.create(null)
18
- let inlineScriptCount = 0
19
- const System = {}
16
+ const loadRegistry = Object.create(null);
17
+ const registerRegistry = Object.create(null);
18
+ let inlineScriptCount = 0;
19
+ const System = {};
20
20
 
21
- const hasDocument = typeof document === "object"
22
- const envGlobal = self
21
+ const hasDocument = typeof document === "object";
22
+ const envGlobal = self;
23
23
  const isWorker =
24
24
  !hasDocument &&
25
25
  typeof envGlobal.WorkerGlobalScope === "function" &&
26
- envGlobal instanceof envGlobal.WorkerGlobalScope
27
- const isServiceWorker = isWorker && typeof self.skipWaiting === "function"
28
- envGlobal.System = System
26
+ envGlobal instanceof envGlobal.WorkerGlobalScope;
27
+ const isServiceWorker = isWorker && typeof self.skipWaiting === "function";
28
+ envGlobal.System = System;
29
29
 
30
- let baseUrl = envGlobal.location.href.split("#")[0].split("?")[0]
31
- const lastSlashIndex = baseUrl.lastIndexOf("/")
30
+ let baseUrl = envGlobal.location.href.split("#")[0].split("?")[0];
31
+ const lastSlashIndex = baseUrl.lastIndexOf("/");
32
32
  if (lastSlashIndex !== -1) {
33
- baseUrl = baseUrl.slice(0, lastSlashIndex + 1)
33
+ baseUrl = baseUrl.slice(0, lastSlashIndex + 1);
34
34
  }
35
35
 
36
- const resolveUrl = (specifier, baseUrl) => new URL(specifier, baseUrl).href
36
+ const resolveUrl = (specifier, baseUrl) => new URL(specifier, baseUrl).href;
37
37
 
38
38
  if (hasDocument) {
39
- const baseElement = document.querySelector("base[href]")
39
+ const baseElement = document.querySelector("base[href]");
40
40
  if (baseElement) {
41
- baseUrl = baseElement.href
41
+ baseUrl = baseElement.href;
42
42
  }
43
43
  System.register = (deps, declare) => {
44
44
  if (!document.currentScript) {
45
45
  throw new Error(
46
46
  "unexpected call to System.register (document.currentScript is undefined)",
47
- )
47
+ );
48
48
  }
49
49
  if (document.currentScript.__s__) {
50
- registerRegistry[document.currentScript.src] = [deps, declare]
51
- return null
50
+ registerRegistry[document.currentScript.src] = [deps, declare];
51
+ return null;
52
52
  }
53
53
  const url =
54
54
  document.currentScript.src ||
55
- `${window.location.href}__inline_script__${++inlineScriptCount}`
56
- registerRegistry[url] = [deps, declare]
57
- return _import(url)
58
- }
55
+ `${window.location.href}__inline_script__${++inlineScriptCount}`;
56
+ registerRegistry[url] = [deps, declare];
57
+ return _import(url);
58
+ };
59
59
  System.instantiate = (url) => {
60
- const script = createScript(url)
60
+ const script = createScript(url);
61
61
  return new Promise(function (resolve, reject) {
62
- let lastWindowErrorUrl
63
- let lastWindowError
62
+ let lastWindowErrorUrl;
63
+ let lastWindowError;
64
64
  const windowErrorCallback = (event) => {
65
- lastWindowErrorUrl = event.filename
66
- lastWindowError = event.error
67
- }
68
- window.addEventListener("error", windowErrorCallback)
65
+ lastWindowErrorUrl = event.filename;
66
+ lastWindowError = event.error;
67
+ };
68
+ window.addEventListener("error", windowErrorCallback);
69
69
  script.addEventListener("error", () => {
70
- window.removeEventListener("error", windowErrorCallback)
71
- reject(`An error occured while loading url with <script> for ${url}`)
72
- })
70
+ window.removeEventListener("error", windowErrorCallback);
71
+ reject(`An error occured while loading url with <script> for ${url}`);
72
+ });
73
73
  script.addEventListener("load", () => {
74
- window.removeEventListener("error", windowErrorCallback)
75
- document.head.removeChild(script)
74
+ window.removeEventListener("error", windowErrorCallback);
75
+ document.head.removeChild(script);
76
76
  // Note that if an error occurs that isn't caught by this if statement,
77
77
  // that getRegister will return null and a "did not instantiate" error will be thrown.
78
78
  if (lastWindowErrorUrl === url) {
79
- reject(lastWindowError)
79
+ reject(lastWindowError);
80
80
  } else {
81
- resolve()
81
+ resolve();
82
82
  }
83
- })
84
- document.head.appendChild(script)
85
- })
86
- }
83
+ });
84
+ document.head.appendChild(script);
85
+ });
86
+ };
87
87
  const createScript = (url) => {
88
- const script = document.createElement("script")
89
- script.async = true
88
+ const script = document.createElement("script");
89
+ script.async = true;
90
90
  // Only add cross origin for actual cross origin
91
91
  // this is because Safari triggers for all
92
92
  // - https://bugs.webkit.org/show_bug.cgi?id=171566
93
93
  if (url.indexOf(`${self.location.origin}/`)) {
94
- script.crossOrigin = "anonymous"
94
+ script.crossOrigin = "anonymous";
95
95
  }
96
- script.__s__ = true
97
- script.src = url
98
- return script
99
- }
96
+ script.__s__ = true;
97
+ script.src = url;
98
+ return script;
99
+ };
100
100
  }
101
101
  if (isWorker) {
102
102
  /*
@@ -107,120 +107,120 @@
107
107
  * To fix that code below listen for these events early and redispatch them later
108
108
  * once the worker file is executed (the listeners are installed)
109
109
  */
110
- const firstImportCallbacks = []
110
+ const firstImportCallbacks = [];
111
111
  if (isServiceWorker) {
112
112
  // for service worker there is more events to listen
113
113
  // and, to get rid of the warning, we override self.addEventListener
114
- const eventsToCatch = ["message", "install", "activate", "fetch"]
115
- const eventCallbackProxies = {}
114
+ const eventsToCatch = ["message", "install", "activate", "fetch"];
115
+ const eventCallbackProxies = {};
116
116
  const firstImportPromise = new Promise((resolve) => {
117
- firstImportCallbacks.push(resolve)
118
- })
117
+ firstImportCallbacks.push(resolve);
118
+ });
119
119
  eventsToCatch.forEach((eventName) => {
120
- const eventsToDispatch = []
120
+ const eventsToDispatch = [];
121
121
  const eventCallback = (event) => {
122
- const eventCallbackProxy = eventCallbackProxies[event.type]
122
+ const eventCallbackProxy = eventCallbackProxies[event.type];
123
123
  if (eventCallbackProxy) {
124
- eventCallbackProxy(event)
124
+ eventCallbackProxy(event);
125
125
  } else {
126
- eventsToDispatch.push(event)
127
- event.waitUntil(firstImportPromise)
126
+ eventsToDispatch.push(event);
127
+ event.waitUntil(firstImportPromise);
128
128
  }
129
- }
130
- self.addEventListener(eventName, eventCallback)
129
+ };
130
+ self.addEventListener(eventName, eventCallback);
131
131
  firstImportCallbacks.push(() => {
132
132
  if (eventsToDispatch.length) {
133
133
  const eventCallbackProxy =
134
- eventCallbackProxies[eventsToDispatch[0].type]
134
+ eventCallbackProxies[eventsToDispatch[0].type];
135
135
  if (eventCallbackProxy) {
136
136
  eventsToDispatch.forEach((event) => {
137
- eventCallbackProxy(event)
138
- })
137
+ eventCallbackProxy(event);
138
+ });
139
139
  }
140
- eventsToDispatch.length = 0
140
+ eventsToDispatch.length = 0;
141
141
  }
142
- })
143
- })
142
+ });
143
+ });
144
144
 
145
- const addEventListener = self.addEventListener
145
+ const addEventListener = self.addEventListener;
146
146
  self.addEventListener = function (eventName, callback, options) {
147
147
  if (eventsToCatch.indexOf(eventName) > -1) {
148
- eventCallbackProxies[eventName] = callback
149
- return null
148
+ eventCallbackProxies[eventName] = callback;
149
+ return null;
150
150
  }
151
- return addEventListener.call(self, eventName, callback, options)
152
- }
151
+ return addEventListener.call(self, eventName, callback, options);
152
+ };
153
153
  } else {
154
- const eventsToCatch = ["message"]
154
+ const eventsToCatch = ["message"];
155
155
  eventsToCatch.forEach((eventName) => {
156
- var eventQueue = []
156
+ var eventQueue = [];
157
157
  var eventCallback = (event) => {
158
- eventQueue.push(event)
159
- }
160
- self.addEventListener(eventName, eventCallback)
158
+ eventQueue.push(event);
159
+ };
160
+ self.addEventListener(eventName, eventCallback);
161
161
  firstImportCallbacks.push(() => {
162
- self.removeEventListener(eventName, eventCallback)
162
+ self.removeEventListener(eventName, eventCallback);
163
163
  eventQueue.forEach(function (event) {
164
- self.dispatchEvent(event)
165
- })
166
- eventQueue.length = 0
167
- })
168
- })
164
+ self.dispatchEvent(event);
165
+ });
166
+ eventQueue.length = 0;
167
+ });
168
+ });
169
169
  }
170
170
 
171
171
  System.register = async (deps, declare) => {
172
172
  System.register = () => {
173
173
  throw new Error(
174
174
  "unexpected call to System.register (called outside url instantiation)",
175
- )
176
- }
177
- const url = self.location.href
178
- registerRegistry[url] = [deps, declare]
179
- const namespace = await _import(url)
175
+ );
176
+ };
177
+ const url = self.location.href;
178
+ registerRegistry[url] = [deps, declare];
179
+ const namespace = await _import(url);
180
180
  firstImportCallbacks.forEach((firstImportCallback) => {
181
- firstImportCallback()
182
- })
183
- firstImportCallbacks.length = 0
184
- return namespace
185
- }
181
+ firstImportCallback();
182
+ });
183
+ firstImportCallbacks.length = 0;
184
+ return namespace;
185
+ };
186
186
  System.instantiate = async (url) => {
187
187
  const response = await self.fetch(url, {
188
188
  credentials: "same-origin",
189
- })
189
+ });
190
190
  if (!response.ok) {
191
- throw Error(`Failed to fetch module at ${url}`)
191
+ throw Error(`Failed to fetch module at ${url}`);
192
192
  }
193
- let source = await response.text()
193
+ let source = await response.text();
194
194
  if (source.indexOf("//# sourceURL=") < 0) {
195
- source += `\n//# sourceURL=${url}`
195
+ source += `\n//# sourceURL=${url}`;
196
196
  }
197
- const register = System.register
197
+ const register = System.register;
198
198
  System.register = (deps, declare) => {
199
- registerRegistry[url] = [deps, declare]
200
- }
201
- ;(0, self.eval)(source)
202
- System.register = register
203
- }
199
+ registerRegistry[url] = [deps, declare];
200
+ };
201
+ (0, self.eval)(source);
202
+ System.register = register;
203
+ };
204
204
  }
205
205
 
206
206
  const _import = (specifier, parentUrl) => {
207
- const url = resolveUrl(specifier, parentUrl)
208
- const load = getOrCreateLoad(url, parentUrl)
207
+ const url = resolveUrl(specifier, parentUrl);
208
+ const load = getOrCreateLoad(url, parentUrl);
209
209
  if (load.completionPromise) {
210
210
  if (load.completionPromise === load.namespace) {
211
- return Promise.resolve(load.namespace)
211
+ return Promise.resolve(load.namespace);
212
212
  }
213
- return load.completionPromise
213
+ return load.completionPromise;
214
214
  }
215
- return startExecution(load, parentUrl)
216
- }
215
+ return startExecution(load, parentUrl);
216
+ };
217
217
 
218
218
  const getOrCreateLoad = (url, firstParentUrl) => {
219
- const existingLoad = loadRegistry[url]
219
+ const existingLoad = loadRegistry[url];
220
220
  if (existingLoad) {
221
- return existingLoad
221
+ return existingLoad;
222
222
  }
223
- const namespace = createNamespace()
223
+ const namespace = createNamespace();
224
224
  const load = {
225
225
  url,
226
226
  deps: [],
@@ -235,210 +235,215 @@
235
235
  error: null,
236
236
  hoistedExports: false,
237
237
  namespace,
238
- }
239
- loadRegistry[url] = load
238
+ };
239
+ loadRegistry[url] = load;
240
240
  load.instantiatePromise = (async () => {
241
241
  try {
242
- let registration = registerRegistry[url]
242
+ let registration = registerRegistry[url];
243
243
  if (!registration) {
244
- const instantiateReturnValue = System.instantiate(url, firstParentUrl)
244
+ const instantiateReturnValue = System.instantiate(
245
+ url,
246
+ firstParentUrl,
247
+ );
245
248
  if (instantiateReturnValue) {
246
- await instantiateReturnValue
249
+ await instantiateReturnValue;
247
250
  }
248
- registration = registerRegistry[url]
251
+ registration = registerRegistry[url];
249
252
  }
250
253
  if (!registration) {
251
- throw new Error(`System.register() not called after executing ${url}`)
254
+ throw new Error(
255
+ `System.register() not called after executing ${url}`,
256
+ );
252
257
  }
253
258
 
254
259
  const _export = (firstArg, secondArg) => {
255
- load.hoistedExports = true
256
- let changed = false
260
+ load.hoistedExports = true;
261
+ let changed = false;
257
262
  if (typeof firstArg === "string") {
258
- const name = firstArg
259
- const value = secondArg
263
+ const name = firstArg;
264
+ const value = secondArg;
260
265
  if (!(name in namespace) || namespace[name] !== value) {
261
- namespace[name] = value
262
- changed = true
266
+ namespace[name] = value;
267
+ changed = true;
263
268
  }
264
269
  } else {
265
270
  Object.keys(firstArg).forEach((name) => {
266
- const value = firstArg[name]
271
+ const value = firstArg[name];
267
272
  if (!(name in namespace) || namespace[name] !== value) {
268
- namespace[name] = value
269
- changed = true
273
+ namespace[name] = value;
274
+ changed = true;
270
275
  }
271
- })
276
+ });
272
277
  if (firstArg && firstArg.__esModule) {
273
- namespace.__esModule = firstArg.__esModule
278
+ namespace.__esModule = firstArg.__esModule;
274
279
  }
275
280
  }
276
281
  if (changed) {
277
282
  load.importerSetters.forEach((importerSetter) => {
278
283
  if (importerSetter) {
279
- importerSetter(namespace)
284
+ importerSetter(namespace);
280
285
  }
281
- })
286
+ });
282
287
  }
283
- return secondArg
284
- }
285
- const [deps, declare] = registration
288
+ return secondArg;
289
+ };
290
+ const [deps, declare] = registration;
286
291
  const { setters, execute = () => {} } = declare(_export, {
287
292
  import: (importId) => _import(importId, url),
288
293
  meta: createMeta(url),
289
- })
290
- load.deps = deps
291
- load.setters = setters
292
- load.execute = execute
294
+ });
295
+ load.deps = deps;
296
+ load.setters = setters;
297
+ load.execute = execute;
293
298
  } catch (e) {
294
- load.error = e
295
- load.execute = null
299
+ load.error = e;
300
+ load.execute = null;
296
301
  }
297
- })()
302
+ })();
298
303
  load.linkPromise = (async () => {
299
- await load.instantiatePromise
304
+ await load.instantiatePromise;
300
305
  const dependencyLoads = await Promise.all(
301
306
  load.deps.map(async (dep, index) => {
302
- const setter = load.setters[index]
303
- const dependencyUrl = resolveUrl(dep, url)
304
- const dependencyLoad = getOrCreateLoad(dependencyUrl, url)
307
+ const setter = load.setters[index];
308
+ const dependencyUrl = resolveUrl(dep, url);
309
+ const dependencyLoad = getOrCreateLoad(dependencyUrl, url);
305
310
  if (dependencyLoad.instantiatePromise) {
306
- await dependencyLoad.instantiatePromise
311
+ await dependencyLoad.instantiatePromise;
307
312
  }
308
313
  if (setter) {
309
- dependencyLoad.importerSetters.push(setter)
314
+ dependencyLoad.importerSetters.push(setter);
310
315
  if (
311
316
  dependencyLoad.hoistedExports ||
312
317
  !dependencyLoad.instantiatePromise
313
318
  ) {
314
- setter(dependencyLoad.namespace)
319
+ setter(dependencyLoad.namespace);
315
320
  }
316
321
  }
317
- return dependencyLoad
322
+ return dependencyLoad;
318
323
  }),
319
- )
320
- load.dependencyLoads = dependencyLoads
321
- })()
322
- return load
323
- }
324
+ );
325
+ load.dependencyLoads = dependencyLoads;
326
+ })();
327
+ return load;
328
+ };
324
329
 
325
330
  const startExecution = async (load, importerUrl) => {
326
331
  load.completionPromise = (async () => {
327
- await instantiateAll(load, load, {})
328
- await postOrderExec(load, importerUrl ? [importerUrl] : [])
329
- return load.namespace
330
- })()
331
- return load.completionPromise
332
- }
332
+ await instantiateAll(load, load, {});
333
+ await postOrderExec(load, importerUrl ? [importerUrl] : []);
334
+ return load.namespace;
335
+ })();
336
+ return load.completionPromise;
337
+ };
333
338
 
334
339
  const instantiateAll = async (load, parent, loaded) => {
335
340
  if (loaded[load.url]) {
336
- return
341
+ return;
337
342
  }
338
- loaded[load.url] = true
343
+ loaded[load.url] = true;
339
344
  try {
340
345
  if (load.linkPromise) {
341
346
  // load.linkPromise is null once instantiated
342
- await load.linkPromise
347
+ await load.linkPromise;
343
348
  }
344
349
  await Promise.all(
345
350
  load.dependencyLoads.map((dependencyLoad) => {
346
- return instantiateAll(dependencyLoad, parent, loaded)
351
+ return instantiateAll(dependencyLoad, parent, loaded);
347
352
  }),
348
- )
353
+ );
349
354
  } catch (error) {
350
355
  if (load.error) {
351
- throw error
356
+ throw error;
352
357
  }
353
- load.execute = null
354
- throw error
358
+ load.execute = null;
359
+ throw error;
355
360
  }
356
- }
361
+ };
357
362
 
358
363
  const postOrderExec = (load, importStack) => {
359
364
  if (importStack.indexOf(load.url) > -1) {
360
- return undefined
365
+ return undefined;
361
366
  }
362
367
  if (!load.execute) {
363
368
  if (load.error) {
364
- throw load.error
369
+ throw load.error;
365
370
  }
366
371
  if (load.executePromise) {
367
- return load.executePromise
372
+ return load.executePromise;
368
373
  }
369
- return undefined
374
+ return undefined;
370
375
  }
371
376
 
372
377
  // deps execute first, unless circular
373
- const execute = load.execute
374
- load.execute = null
375
- const depLoadPromises = []
378
+ const execute = load.execute;
379
+ load.execute = null;
380
+ const depLoadPromises = [];
376
381
  load.dependencyLoads.forEach((dependencyLoad) => {
377
382
  try {
378
- const depImportStack = importStack.slice()
379
- depImportStack.push(load.url)
380
- const depLoadPromise = postOrderExec(dependencyLoad, depImportStack)
383
+ const depImportStack = importStack.slice();
384
+ depImportStack.push(load.url);
385
+ const depLoadPromise = postOrderExec(dependencyLoad, depImportStack);
381
386
  if (depLoadPromise) {
382
- depLoadPromises.push(depLoadPromise)
387
+ depLoadPromises.push(depLoadPromise);
383
388
  }
384
389
  } catch (err) {
385
- load.error = err
386
- throw err
390
+ load.error = err;
391
+ throw err;
387
392
  }
388
- })
393
+ });
389
394
 
390
395
  return (async () => {
391
396
  if (depLoadPromises.length) {
392
- const allDepPromise = Promise.all(depLoadPromises)
393
- await allDepPromise
397
+ const allDepPromise = Promise.all(depLoadPromises);
398
+ await allDepPromise;
394
399
  }
395
400
 
396
401
  try {
397
- const executeReturnValue = execute.call(nullContext)
402
+ const executeReturnValue = execute.call(nullContext);
398
403
  if (executeReturnValue) {
399
404
  load.executePromise = executeReturnValue.then(
400
405
  () => {
401
- load.executePromise = null
402
- load.completionPromise = load.namespace
406
+ load.executePromise = null;
407
+ load.completionPromise = load.namespace;
403
408
  },
404
409
  (error) => {
405
- load.executePromise = null
406
- load.error = error
407
- throw error
410
+ load.executePromise = null;
411
+ load.error = error;
412
+ throw error;
408
413
  },
409
- )
410
- return
414
+ );
415
+ return;
411
416
  }
412
- load.instantiatePromise = null
413
- load.linkPromise = null
414
- load.completionPromise = load.namespace
417
+ load.instantiatePromise = null;
418
+ load.linkPromise = null;
419
+ load.completionPromise = load.namespace;
415
420
  } catch (error) {
416
- load.error = error
417
- throw error
421
+ load.error = error;
422
+ throw error;
418
423
  } finally {
419
- load.execute = null
424
+ load.execute = null;
420
425
  }
421
- })()
422
- }
426
+ })();
427
+ };
423
428
 
424
429
  // the closest we can get to call(undefined)
425
- const nullContext = Object.freeze(Object.create(null))
430
+ const nullContext = Object.freeze(Object.create(null));
426
431
 
427
432
  const createMeta = (url) => {
428
433
  return {
429
434
  url,
430
435
  resolve: (id) => resolveUrl(id, url),
431
- }
432
- }
436
+ };
437
+ };
433
438
 
434
439
  const createNamespace =
435
440
  typeof Symbol !== "undefined" && Symbol.toStringTag
436
441
  ? () => {
437
- const namespace = Object.create(null)
442
+ const namespace = Object.create(null);
438
443
  Object.defineProperty(namespace, Symbol.toStringTag, {
439
444
  value: "Module",
440
- })
441
- return namespace
445
+ });
446
+ return namespace;
442
447
  }
443
- : () => Object.create(null)
444
- })()
448
+ : () => Object.create(null);
449
+ })();