@jsenv/core 27.0.0-alpha.94 → 27.0.1

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.
package/dist/js/s.js CHANGED
@@ -1,429 +1,629 @@
1
- /*
2
- * This file is a modified version of https://github.com/systemjs/systemjs/blob/main/dist/s.js
3
- * with the following changes:
4
- *
5
- * - Code can use aync/await, const, ... because an es5 version of this file is generated
6
- * - Can use document.currentScript because we don't support IE
7
- * - auto import inline System.register
8
- * - auto import first System.register in web workers
9
- * - queing events in web workers
10
- * - no support for importmap because jsenv don't need it
11
- */
12
-
13
- ;(function () {
14
- /* eslint-env browser */
15
- /* globals self */
16
-
17
- const loadRegistry = Object.create(null)
18
- const registerRegistry = Object.create(null)
19
- let inlineScriptCount = 0
20
- const System = {}
21
-
22
- const hasDocument = typeof document === "object"
23
- const envGlobal = self
24
- const isWorker =
25
- !hasDocument &&
26
- typeof envGlobal.WorkerGlobalScope === "function" &&
27
- envGlobal instanceof envGlobal.WorkerGlobalScope
28
- const isServiceWorker = isWorker && typeof self.skipWaiting === "function"
29
- envGlobal.System = System
30
-
31
- let baseUrl = envGlobal.location.href.split("#")[0].split("?")[0]
32
- const lastSlashIndex = baseUrl.lastIndexOf("/")
33
- if (lastSlashIndex !== -1) {
34
- baseUrl = baseUrl.slice(0, lastSlashIndex + 1)
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define([], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory();
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory();
11
+ global.s = mod.exports;
35
12
  }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function () {
14
+ "use strict";
36
15
 
37
- const resolveUrl = (specifier, baseUrl) => new URL(specifier, baseUrl).href
16
+ function _await(value, then, direct) {
17
+ if (direct) {
18
+ return then ? then(value) : value;
19
+ }
38
20
 
39
- if (hasDocument) {
40
- const baseElement = document.querySelector("base[href]")
41
- if (baseElement) {
42
- baseUrl = baseElement.href
21
+ if (!value || !value.then) {
22
+ value = Promise.resolve(value);
43
23
  }
44
- System.register = (deps, declare) => {
45
- if (!document.currentScript) {
46
- throw new Error("unexpected call to System.register (document.currentScript is undefined)")
24
+
25
+ return then ? value.then(then) : value;
26
+ }
27
+
28
+ function _async(f) {
29
+ return function () {
30
+ for (var args = [], i = 0; i < arguments.length; i++) {
31
+ args[i] = arguments[i];
47
32
  }
48
- if (document.currentScript.__s__) {
49
- registerRegistry[document.currentScript.src] = [deps, declare]
50
- return null
33
+
34
+ try {
35
+ return Promise.resolve(f.apply(this, args));
36
+ } catch (e) {
37
+ return Promise.reject(e);
51
38
  }
52
- const url =
53
- document.currentScript.src ||
54
- `${window.location.href}__inline_script__${++inlineScriptCount}`
55
- registerRegistry[url] = [deps, declare]
56
- return _import(url)
57
- }
58
- System.instantiate = (url) => {
59
- const script = createScript(url)
60
- return new Promise(function (resolve, reject) {
61
- let lastWindowErrorUrl
62
- let lastWindowError
63
- const windowErrorCallback = (event) => {
64
- lastWindowErrorUrl = event.filename
65
- lastWindowError = event.error
66
- }
67
- window.addEventListener("error", windowErrorCallback)
68
- script.addEventListener("error", () => {
69
- window.removeEventListener("error", windowErrorCallback)
70
- reject(`An error occured while loading url with <script> for ${url}`)
71
- })
72
- script.addEventListener("load", () => {
73
- window.removeEventListener("error", windowErrorCallback)
74
- document.head.removeChild(script)
75
- // Note that if an error occurs that isn't caught by this if statement,
76
- // that getRegister will return null and a "did not instantiate" error will be thrown.
77
- if (lastWindowErrorUrl === url) {
78
- reject(lastWindowError)
79
- } else {
80
- resolve()
81
- }
82
- })
83
- document.head.appendChild(script)
84
- })
39
+ };
40
+ }
41
+
42
+ function _empty() {}
43
+
44
+ function _awaitIgnored(value, direct) {
45
+ if (!direct) {
46
+ return value && value.then ? value.then(_empty) : Promise.resolve();
85
47
  }
86
- const createScript = (url) => {
87
- const script = document.createElement("script")
88
- script.async = true
89
- // Only add cross origin for actual cross origin
90
- // this is because Safari triggers for all
91
- // - https://bugs.webkit.org/show_bug.cgi?id=171566
92
- if (url.indexOf(`${self.location.origin}/`)) {
93
- script.crossOrigin = "anonymous"
94
- }
95
- script.__s__ = true
96
- script.src = url
97
- return script
48
+ }
49
+
50
+ function _invoke(body, then) {
51
+ var result = body();
52
+
53
+ if (result && result.then) {
54
+ return result.then(then);
98
55
  }
56
+
57
+ return then(result);
99
58
  }
100
- if (isWorker) {
101
- /*
102
- * SystemJs loads X files before executing the worker/service worker main file
103
- * It mean events dispatched during this phase could be missed
104
- * A warning like the one below is displayed in chrome devtools:
105
- * "Event handler of 'install' event must be added on the initial evaluation of worker script"
106
- * To fix that code below listen for these events early and redispatch them later
107
- * once the worker file is executed (the listeners are installed)
108
- */
109
- const firstImportCallbacks = []
110
- if (isServiceWorker) {
111
- // for service worker there is more events to listen
112
- // and, to get rid of the warning, we override self.addEventListener
113
- const eventsToCatch = ["message", "install", "activate", "fetch"]
114
- const eventCallbackProxies = {}
115
- const firstImportPromise = new Promise((resolve) => {
116
- firstImportCallbacks.push(resolve)
117
- })
118
- eventsToCatch.forEach((eventName) => {
119
- const eventsToDispatch = []
120
- const eventCallback = (event) => {
121
- const eventCallbackProxy = eventCallbackProxies[event.type]
122
- if (eventCallbackProxy) {
123
- eventCallbackProxy(event)
124
- } else {
125
- eventsToDispatch.push(event)
126
- event.waitUntil(firstImportPromise)
127
- }
128
- }
129
- self.addEventListener(eventName, eventCallback)
130
- firstImportCallbacks.push(() => {
131
- if (eventsToDispatch.length) {
132
- const eventCallbackProxy =
133
- eventCallbackProxies[eventsToDispatch[0].type]
134
- if (eventCallbackProxy) {
135
- eventsToDispatch.forEach((event) => {
136
- eventCallbackProxy(event)
137
- })
138
- }
139
- eventsToDispatch.length = 0
140
- }
141
- })
142
- })
143
-
144
- const addEventListener = self.addEventListener
145
- self.addEventListener = function (eventName, callback, options) {
146
- if (eventsToCatch.indexOf(eventName) > -1) {
147
- eventCallbackProxies[eventName] = callback
148
- return null
149
- }
150
- return addEventListener.call(self, eventName, callback, options)
151
- }
152
- } else {
153
- const eventsToCatch = ["message"]
154
- eventsToCatch.forEach((eventName) => {
155
- var eventQueue = []
156
- var eventCallback = (event) => {
157
- eventQueue.push(event)
158
- }
159
- self.addEventListener(eventName, eventCallback)
160
- firstImportCallbacks.push(() => {
161
- self.removeEventListener(eventName, eventCallback)
162
- eventQueue.forEach(function (event) {
163
- self.dispatchEvent(event)
164
- })
165
- eventQueue.length = 0
166
- })
167
- })
59
+
60
+ function _catch(body, recover) {
61
+ try {
62
+ var result = body();
63
+ } catch (e) {
64
+ return recover(e);
168
65
  }
169
66
 
170
- System.register = async (deps, declare) => {
171
- System.register = () => {
172
- throw new Error("unexpected call to System.register (called outside url instantiation)")
173
- }
174
- const url = self.location.href
175
- registerRegistry[url] = [deps, declare]
176
- const namespace = await _import(url)
177
- firstImportCallbacks.forEach((firstImportCallback) => {
178
- firstImportCallback()
179
- })
180
- firstImportCallbacks.length = 0
181
- return namespace
67
+ if (result && result.then) {
68
+ return result.then(void 0, recover);
182
69
  }
183
- System.instantiate = async (url) => {
184
- const response = await self.fetch(url, {
185
- credentials: "same-origin",
186
- })
187
- if (!response.ok) {
188
- throw Error(`Failed to fetch module at ${url}`)
189
- }
190
- let source = await response.text()
191
- if (source.indexOf("//# sourceURL=") < 0) {
192
- source += `\n//# sourceURL=${url}`
70
+
71
+ return result;
72
+ }
73
+
74
+ function _slicedToArray(arr, i) {
75
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
76
+ }
77
+
78
+ function _nonIterableRest() {
79
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
80
+ }
81
+
82
+ function _unsupportedIterableToArray(o, minLen) {
83
+ if (!o) return;
84
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
85
+ var n = Object.prototype.toString.call(o).slice(8, -1);
86
+ if (n === "Object" && o.constructor) n = o.constructor.name;
87
+ if (n === "Map" || n === "Set") return Array.from(o);
88
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
89
+ }
90
+
91
+ function _arrayLikeToArray(arr, len) {
92
+ if (len == null || len > arr.length) len = arr.length;
93
+
94
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
95
+ arr2[i] = arr[i];
96
+ }
97
+
98
+ return arr2;
99
+ }
100
+
101
+ function _iterableToArrayLimit(arr, i) {
102
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
103
+
104
+ if (_i == null) return;
105
+ var _arr = [];
106
+ var _n = true;
107
+ var _d = false;
108
+
109
+ var _s, _e;
110
+
111
+ try {
112
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
113
+ _arr.push(_s.value);
114
+
115
+ if (i && _arr.length === i) break;
193
116
  }
194
- const register = System.register
195
- System.register = (deps, declare) => {
196
- registerRegistry[url] = [deps, declare]
117
+ } catch (err) {
118
+ _d = true;
119
+ _e = err;
120
+ } finally {
121
+ try {
122
+ if (!_n && _i["return"] != null) _i["return"]();
123
+ } finally {
124
+ if (_d) throw _e;
197
125
  }
198
- ;(0, self.eval)(source)
199
- System.register = register
200
126
  }
127
+
128
+ return _arr;
201
129
  }
202
130
 
203
- const _import = (specifier, parentUrl) => {
204
- const url = resolveUrl(specifier, parentUrl)
205
- const load = getOrCreateLoad(url, parentUrl)
206
- return load.completionPromise || startExecution(load)
131
+ function _arrayWithHoles(arr) {
132
+ if (Array.isArray(arr)) return arr;
207
133
  }
208
134
 
209
- const getOrCreateLoad = (url, firstParentUrl) => {
210
- const existingLoad = loadRegistry[url]
211
- if (existingLoad) {
212
- return existingLoad
213
- }
135
+ function _typeof(obj) {
136
+ "@babel/helpers - typeof";
214
137
 
215
- const load = {
216
- url,
138
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
139
+ return typeof obj;
140
+ } : function (obj) {
141
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
142
+ }, _typeof(obj);
143
+ }
144
+
145
+ (function () {
146
+ /* eslint-env browser */
147
+
148
+ /* globals self */
149
+ var loadRegistry = Object.create(null);
150
+ var registerRegistry = Object.create(null);
151
+ var inlineScriptCount = 0;
152
+ var System = {};
153
+ var hasDocument = (typeof document === "undefined" ? "undefined" : _typeof(document)) === "object";
154
+ var envGlobal = self;
155
+ var isWorker = !hasDocument && typeof envGlobal.WorkerGlobalScope === "function" && envGlobal instanceof envGlobal.WorkerGlobalScope;
156
+ var isServiceWorker = isWorker && typeof self.skipWaiting === "function";
157
+ envGlobal.System = System;
158
+ var baseUrl = envGlobal.location.href.split("#")[0].split("?")[0];
159
+ var lastSlashIndex = baseUrl.lastIndexOf("/");
160
+
161
+ if (lastSlashIndex !== -1) {
162
+ baseUrl = baseUrl.slice(0, lastSlashIndex + 1);
217
163
  }
218
- loadRegistry[url] = load
219
164
 
220
- const importerSetters = []
221
- load.importerSetters = importerSetters
165
+ var resolveUrl = function resolveUrl(specifier, baseUrl) {
166
+ return new URL(specifier, baseUrl).href;
167
+ };
222
168
 
223
- const namespace = createNamespace()
224
- load.namespace = namespace
169
+ if (hasDocument) {
170
+ var baseElement = document.querySelector("base[href]");
225
171
 
226
- load.instantiatePromise = (async () => {
227
- try {
228
- let registration = registerRegistry[url]
229
- if (!registration) {
230
- const instantiateReturnValue = System.instantiate(url, firstParentUrl)
231
- if (instantiateReturnValue) {
232
- await instantiateReturnValue
233
- }
234
- registration = registerRegistry[url]
172
+ if (baseElement) {
173
+ baseUrl = baseElement.href;
174
+ }
175
+
176
+ System.register = function (deps, declare) {
177
+ if (!document.currentScript) {
178
+ throw new Error("unexpected call to System.register (document.currentScript is undefined)");
235
179
  }
236
- if (!registration) {
237
- throw new Error(`System.register() not called after executing ${url}`)
180
+
181
+ if (document.currentScript.__s__) {
182
+ registerRegistry[document.currentScript.src] = [deps, declare];
183
+ return null;
238
184
  }
239
185
 
240
- const _export = (firstArg, secondArg) => {
241
- load.hoistedExports = true
242
- let changed = false
243
- if (typeof firstArg === "string") {
244
- const name = firstArg
245
- const value = secondArg
246
- if (!(name in namespace) || namespace[name] !== value) {
247
- namespace[name] = value
248
- changed = true
186
+ var url = document.currentScript.src || "".concat(window.location.href, "__inline_script__").concat(++inlineScriptCount);
187
+ registerRegistry[url] = [deps, declare];
188
+ return _import2(url);
189
+ };
190
+
191
+ System.instantiate = function (url) {
192
+ var script = createScript(url);
193
+ return new Promise(function (resolve, reject) {
194
+ var lastWindowErrorUrl;
195
+ var lastWindowError;
196
+
197
+ var windowErrorCallback = function windowErrorCallback(event) {
198
+ lastWindowErrorUrl = event.filename;
199
+ lastWindowError = event.error;
200
+ };
201
+
202
+ window.addEventListener("error", windowErrorCallback);
203
+ script.addEventListener("error", function () {
204
+ window.removeEventListener("error", windowErrorCallback);
205
+ reject("An error occured while loading url with <script> for ".concat(url));
206
+ });
207
+ script.addEventListener("load", function () {
208
+ window.removeEventListener("error", windowErrorCallback);
209
+ document.head.removeChild(script); // Note that if an error occurs that isn't caught by this if statement,
210
+ // that getRegister will return null and a "did not instantiate" error will be thrown.
211
+
212
+ if (lastWindowErrorUrl === url) {
213
+ reject(lastWindowError);
214
+ } else {
215
+ resolve();
249
216
  }
250
- } else {
251
- Object.keys(firstArg).forEach((name) => {
252
- const value = firstArg[name]
253
- if (!(name in namespace) || namespace[name] !== value) {
254
- namespace[name] = value
255
- changed = true
256
- }
257
- })
258
- if (firstArg && firstArg.__esModule) {
259
- namespace.__esModule = firstArg.__esModule
217
+ });
218
+ document.head.appendChild(script);
219
+ });
220
+ };
221
+
222
+ var createScript = function createScript(url) {
223
+ var script = document.createElement("script");
224
+ script.async = true; // Only add cross origin for actual cross origin
225
+ // this is because Safari triggers for all
226
+ // - https://bugs.webkit.org/show_bug.cgi?id=171566
227
+
228
+ if (url.indexOf("".concat(self.location.origin, "/"))) {
229
+ script.crossOrigin = "anonymous";
230
+ }
231
+
232
+ script.__s__ = true;
233
+ script.src = url;
234
+ return script;
235
+ };
236
+ }
237
+
238
+ if (isWorker) {
239
+ /*
240
+ * SystemJs loads X files before executing the worker/service worker main file
241
+ * It mean events dispatched during this phase could be missed
242
+ * A warning like the one below is displayed in chrome devtools:
243
+ * "Event handler of 'install' event must be added on the initial evaluation of worker script"
244
+ * To fix that code below listen for these events early and redispatch them later
245
+ * once the worker file is executed (the listeners are installed)
246
+ */
247
+ var firstImportCallbacks = [];
248
+
249
+ if (isServiceWorker) {
250
+ // for service worker there is more events to listen
251
+ // and, to get rid of the warning, we override self.addEventListener
252
+ var eventsToCatch = ["message", "install", "activate", "fetch"];
253
+ var eventCallbackProxies = {};
254
+ var firstImportPromise = new Promise(function (resolve) {
255
+ firstImportCallbacks.push(resolve);
256
+ });
257
+ eventsToCatch.forEach(function (eventName) {
258
+ var eventsToDispatch = [];
259
+
260
+ var eventCallback = function eventCallback(event) {
261
+ var eventCallbackProxy = eventCallbackProxies[event.type];
262
+
263
+ if (eventCallbackProxy) {
264
+ eventCallbackProxy(event);
265
+ } else {
266
+ eventsToDispatch.push(event);
267
+ event.waitUntil(firstImportPromise);
260
268
  }
261
- }
262
- if (changed) {
263
- importerSetters.forEach((importerSetter) => {
264
- if (importerSetter) {
265
- importerSetter(namespace)
269
+ };
270
+
271
+ self.addEventListener(eventName, eventCallback);
272
+ firstImportCallbacks.push(function () {
273
+ if (eventsToDispatch.length) {
274
+ var eventCallbackProxy = eventCallbackProxies[eventsToDispatch[0].type];
275
+
276
+ if (eventCallbackProxy) {
277
+ eventsToDispatch.forEach(function (event) {
278
+ eventCallbackProxy(event);
279
+ });
266
280
  }
267
- })
281
+
282
+ eventsToDispatch.length = 0;
283
+ }
284
+ });
285
+ });
286
+ var addEventListener = self.addEventListener;
287
+
288
+ self.addEventListener = function (eventName, callback, options) {
289
+ if (eventsToCatch.indexOf(eventName) > -1) {
290
+ eventCallbackProxies[eventName] = callback;
291
+ return null;
268
292
  }
269
- return secondArg
270
- }
271
- const [deps, declare] = registration
272
- const { setters, execute = () => {} } = declare(_export, {
273
- import: (importId) => _import(importId, url),
274
- meta: createMeta(url),
275
- })
276
- load.deps = deps
277
- load.setters = setters
278
- load.execute = execute
279
- } catch (e) {
280
- load.error = e
281
- load.execute = null
293
+
294
+ return addEventListener.call(self, eventName, callback, options);
295
+ };
296
+ } else {
297
+ var _eventsToCatch = ["message"];
298
+
299
+ _eventsToCatch.forEach(function (eventName) {
300
+ var eventQueue = [];
301
+
302
+ var eventCallback = function eventCallback(event) {
303
+ eventQueue.push(event);
304
+ };
305
+
306
+ self.addEventListener(eventName, eventCallback);
307
+ firstImportCallbacks.push(function () {
308
+ self.removeEventListener(eventName, eventCallback);
309
+ eventQueue.forEach(function (event) {
310
+ self.dispatchEvent(event);
311
+ });
312
+ eventQueue.length = 0;
313
+ });
314
+ });
282
315
  }
283
- })()
284
-
285
- load.linkPromise = (async () => {
286
- await load.instantiatePromise
287
- const dependencyLoads = await Promise.all(
288
- load.deps.map(async (dep, index) => {
289
- const setter = load.setters[index]
290
- const dependencyUrl = resolveUrl(dep, url)
291
- const dependencyLoad = getOrCreateLoad(dependencyUrl, url)
292
- if (dependencyLoad.instantiatePromise) {
293
- await dependencyLoad.instantiatePromise
316
+
317
+ System.register = _async(function (deps, declare) {
318
+ System.register = function () {
319
+ throw new Error("unexpected call to System.register (called outside url instantiation)");
320
+ };
321
+
322
+ var url = self.location.href;
323
+ registerRegistry[url] = [deps, declare];
324
+ return _await(_import2(url), function (namespace) {
325
+ firstImportCallbacks.forEach(function (firstImportCallback) {
326
+ firstImportCallback();
327
+ });
328
+ firstImportCallbacks.length = 0;
329
+ return namespace;
330
+ });
331
+ });
332
+ System.instantiate = _async(function (url) {
333
+ return _await(self.fetch(url, {
334
+ credentials: "same-origin"
335
+ }), function (response) {
336
+ if (!response.ok) {
337
+ throw Error("Failed to fetch module at ".concat(url));
294
338
  }
295
- if (setter) {
296
- dependencyLoad.importerSetters.push(setter)
297
- if (
298
- dependencyLoad.hoistedExports ||
299
- !dependencyLoad.instantiatePromise
300
- ) {
301
- setter(dependencyLoad.namespace)
339
+
340
+ return _await(response.text(), function (source) {
341
+ if (source.indexOf("//# sourceURL=") < 0) {
342
+ source += "\n//# sourceURL=".concat(url);
302
343
  }
303
- }
304
- return dependencyLoad
305
- }),
306
- )
307
- load.dependencyLoads = dependencyLoads
308
- })()
309
344
 
310
- return load
311
- }
345
+ var register = System.register;
312
346
 
313
- const startExecution = async (load) => {
314
- load.completionPromise = (async () => {
315
- await instantiateAll(load, load, {})
316
- await postOrderExec(load, {})
317
- return load.namespace
318
- })()
319
- return load.completionPromise
320
- }
347
+ System.register = function (deps, declare) {
348
+ registerRegistry[url] = [deps, declare];
349
+ };
321
350
 
322
- const instantiateAll = async (load, parent, loaded) => {
323
- if (loaded[load.url]) {
324
- return
325
- }
326
- loaded[load.url] = true
327
- try {
328
- if (load.linkPromise) {
329
- // load.linkPromise is null once instantiated
330
- await load.linkPromise
331
- }
332
- // if (!load.parent || !load.parent.execute) {
333
- // load.parent = parent
334
- // }
335
- await Promise.all(
336
- load.dependencyLoads.map((dependencyLoad) => {
337
- return instantiateAll(dependencyLoad, parent, loaded)
338
- }),
339
- )
340
- } catch (error) {
341
- if (load.error) {
342
- throw error
343
- }
344
- load.execute = null
345
- throw error
351
+ (0, self.eval)(source);
352
+ System.register = register;
353
+ });
354
+ });
355
+ });
346
356
  }
347
- }
348
357
 
349
- const postOrderExec = async (load, seen) => {
350
- if (seen[load.url]) {
351
- return
352
- }
353
- seen[load.url] = true
354
- if (!load.execute) {
355
- if (load.error) {
356
- throw load.error
358
+ var _import2 = function _import(specifier, parentUrl) {
359
+ var url = resolveUrl(specifier, parentUrl);
360
+ var load = getOrCreateLoad(url, parentUrl);
361
+ return load.completionPromise || startExecution(load, parentUrl);
362
+ };
363
+
364
+ var getOrCreateLoad = function getOrCreateLoad(url, firstParentUrl) {
365
+ var existingLoad = loadRegistry[url];
366
+
367
+ if (existingLoad) {
368
+ return existingLoad;
357
369
  }
358
- if (load.executePromise) {
359
- await load.executePromise
370
+
371
+ var namespace = createNamespace();
372
+ var load = {
373
+ url: url,
374
+ deps: [],
375
+ dependencyLoads: [],
376
+ instantiatePromise: null,
377
+ linkPromise: null,
378
+ executePromise: null,
379
+ completionPromise: null,
380
+ importerSetters: [],
381
+ setters: [],
382
+ execute: null,
383
+ error: null,
384
+ hoistedExports: false,
385
+ namespace: namespace
386
+ };
387
+ loadRegistry[url] = load;
388
+ load.instantiatePromise = _async(function () {
389
+ return _catch(function () {
390
+ var registration = registerRegistry[url];
391
+ return _invoke(function () {
392
+ if (!registration) {
393
+ var instantiateReturnValue = System.instantiate(url, firstParentUrl);
394
+ return _invoke(function () {
395
+ if (instantiateReturnValue) {
396
+ return _awaitIgnored(instantiateReturnValue);
397
+ }
398
+ }, function () {
399
+ registration = registerRegistry[url];
400
+ });
401
+ }
402
+ }, function () {
403
+ if (!registration) {
404
+ throw new Error("System.register() not called after executing ".concat(url));
405
+ }
406
+
407
+ var _export = function _export(firstArg, secondArg) {
408
+ load.hoistedExports = true;
409
+ var changed = false;
410
+
411
+ if (typeof firstArg === "string") {
412
+ var name = firstArg;
413
+ var value = secondArg;
414
+
415
+ if (!(name in namespace) || namespace[name] !== value) {
416
+ namespace[name] = value;
417
+ changed = true;
418
+ }
419
+ } else {
420
+ Object.keys(firstArg).forEach(function (name) {
421
+ var value = firstArg[name];
422
+
423
+ if (!(name in namespace) || namespace[name] !== value) {
424
+ namespace[name] = value;
425
+ changed = true;
426
+ }
427
+ });
428
+
429
+ if (firstArg && firstArg.__esModule) {
430
+ namespace.__esModule = firstArg.__esModule;
431
+ }
432
+ }
433
+
434
+ if (changed) {
435
+ load.importerSetters.forEach(function (importerSetter) {
436
+ if (importerSetter) {
437
+ importerSetter(namespace);
438
+ }
439
+ });
440
+ }
441
+
442
+ return secondArg;
443
+ };
444
+
445
+ var _registration = registration,
446
+ _registration2 = _slicedToArray(_registration, 2),
447
+ deps = _registration2[0],
448
+ declare = _registration2[1];
449
+
450
+ var _declare = declare(_export, {
451
+ import: function _import(importId) {
452
+ return _import2(importId, url);
453
+ },
454
+ meta: createMeta(url)
455
+ }),
456
+ setters = _declare.setters,
457
+ _declare$execute = _declare.execute,
458
+ execute = _declare$execute === void 0 ? function () {} : _declare$execute;
459
+
460
+ load.deps = deps;
461
+ load.setters = setters;
462
+ load.execute = execute;
463
+ });
464
+ }, function (e) {
465
+ load.error = e;
466
+ load.execute = null;
467
+ });
468
+ })();
469
+ load.linkPromise = _async(function () {
470
+ return _await(load.instantiatePromise, function () {
471
+ return _await(Promise.all(load.deps.map(_async(function (dep, index) {
472
+ var setter = load.setters[index];
473
+ var dependencyUrl = resolveUrl(dep, url);
474
+ var dependencyLoad = getOrCreateLoad(dependencyUrl, url);
475
+ return _invoke(function () {
476
+ if (dependencyLoad.instantiatePromise) {
477
+ return _awaitIgnored(dependencyLoad.instantiatePromise);
478
+ }
479
+ }, function () {
480
+ if (setter) {
481
+ dependencyLoad.importerSetters.push(setter);
482
+
483
+ if (dependencyLoad.hoistedExports || !dependencyLoad.instantiatePromise) {
484
+ setter(dependencyLoad.namespace);
485
+ }
486
+ }
487
+
488
+ return dependencyLoad;
489
+ });
490
+ }))), function (dependencyLoads) {
491
+ load.dependencyLoads = dependencyLoads;
492
+ });
493
+ });
494
+ })();
495
+ return load;
496
+ };
497
+
498
+ var startExecution = _async(function (load, importerUrl) {
499
+ load.completionPromise = function () {
500
+ return _await(instantiateAll(load, load, {}), function () {
501
+ return _await(postOrderExec(load, importerUrl ? [importerUrl] : []), function () {
502
+ return load.namespace;
503
+ });
504
+ });
505
+ }();
506
+
507
+ return load.completionPromise;
508
+ });
509
+
510
+ var instantiateAll = _async(function (load, parent, loaded) {
511
+ if (loaded[load.url]) {
512
+ return;
360
513
  }
361
- return
362
- }
363
514
 
364
- // deps execute first, unless circular
365
- const depLoadPromises = []
366
- load.dependencyLoads.forEach((dependencyLoad) => {
367
- try {
368
- const depLoadPromise = postOrderExec(dependencyLoad, seen)
369
- if (depLoadPromise) {
370
- depLoadPromises.push(depLoadPromise)
515
+ loaded[load.url] = true;
516
+ return _catch(function () {
517
+ return _invoke(function () {
518
+ if (load.linkPromise) {
519
+ // load.linkPromise is null once instantiated
520
+ return _awaitIgnored(load.linkPromise);
521
+ }
522
+ }, function () {
523
+ return _awaitIgnored(Promise.all(load.dependencyLoads.map(function (dependencyLoad) {
524
+ return instantiateAll(dependencyLoad, parent, loaded);
525
+ })));
526
+ });
527
+ }, function (error) {
528
+ if (load.error) {
529
+ throw error;
371
530
  }
372
- } catch (err) {
373
- load.execute = null
374
- load.error = err
375
- throw err
376
- }
377
- })
378
- if (depLoadPromises.length) {
379
- await Promise.all(depLoadPromises)
380
- }
381
531
 
382
- try {
383
- const executeReturnValue = load.execute.call(nullContext)
384
- if (executeReturnValue) {
385
- load.executePromise = executeReturnValue.then(
386
- () => {
387
- load.executePromise = null
388
- load.completionPromise = load.namespace
389
- },
390
- (error) => {
391
- load.executePromise = null
392
- load.error = error
393
- throw error
394
- },
395
- )
396
- return
532
+ load.execute = null;
533
+ throw error;
534
+ });
535
+ });
536
+
537
+ var postOrderExec = function postOrderExec(load, importStack) {
538
+ if (importStack.indexOf(load.url) > -1) {
539
+ return undefined;
397
540
  }
398
- load.instantiatePromise = null
399
- load.linkPromise = null
400
- load.completionPromise = load.namespace
401
- } catch (error) {
402
- load.error = error
403
- throw error
404
- } finally {
405
- load.execute = null
406
- }
407
- }
408
541
 
409
- // the closest we can get to call(undefined)
410
- const nullContext = Object.freeze(Object.create(null))
542
+ if (!load.execute) {
543
+ if (load.error) {
544
+ throw load.error;
545
+ }
411
546
 
412
- const createMeta = (url) => {
413
- return {
414
- url,
415
- resolve: (id, parentUrl) => resolveUrl(id, parentUrl),
416
- }
417
- }
547
+ if (load.executePromise) {
548
+ return load.executePromise;
549
+ }
418
550
 
419
- const createNamespace =
420
- typeof Symbol !== "undefined" && Symbol.toStringTag
421
- ? () => {
422
- const namespace = Object.create(null)
423
- Object.defineProperty(namespace, Symbol.toStringTag, {
424
- value: "Module",
425
- })
426
- return namespace
551
+ return undefined;
552
+ } // deps execute first, unless circular
553
+
554
+
555
+ var depLoadPromises = [];
556
+ load.dependencyLoads.forEach(function (dependencyLoad) {
557
+ try {
558
+ var depImportStack = importStack.slice();
559
+ depImportStack.push(load.url);
560
+ var depLoadPromise = postOrderExec(dependencyLoad, depImportStack);
561
+
562
+ if (depLoadPromise) {
563
+ depLoadPromises.push(depLoadPromise);
564
+ }
565
+ } catch (err) {
566
+ load.execute = null;
567
+ load.error = err;
568
+ throw err;
427
569
  }
428
- : () => Object.create(null)
429
- })();
570
+ });
571
+ return _async(function () {
572
+ return _invoke(function () {
573
+ if (depLoadPromises.length) {
574
+ var allDepPromise = Promise.all(depLoadPromises);
575
+ return _awaitIgnored(allDepPromise);
576
+ }
577
+ }, function () {
578
+ try {
579
+ var executeReturnValue = load.execute.call(nullContext);
580
+
581
+ if (executeReturnValue) {
582
+ load.executePromise = executeReturnValue.then(function () {
583
+ load.executePromise = null;
584
+ load.completionPromise = load.namespace;
585
+ }, function (error) {
586
+ load.executePromise = null;
587
+ load.error = error;
588
+ throw error;
589
+ });
590
+ return;
591
+ }
592
+
593
+ load.instantiatePromise = null;
594
+ load.linkPromise = null;
595
+ load.completionPromise = load.namespace;
596
+ } catch (error) {
597
+ load.error = error;
598
+ throw error;
599
+ } finally {
600
+ load.execute = null;
601
+ }
602
+ });
603
+ })();
604
+ }; // the closest we can get to call(undefined)
605
+
606
+
607
+ var nullContext = Object.freeze(Object.create(null));
608
+
609
+ var createMeta = function createMeta(url) {
610
+ return {
611
+ url: url,
612
+ resolve: function resolve(id, parentUrl) {
613
+ return resolveUrl(id, parentUrl);
614
+ }
615
+ };
616
+ };
617
+
618
+ var createNamespace = typeof Symbol !== "undefined" && Symbol.toStringTag ? function () {
619
+ var namespace = Object.create(null);
620
+ Object.defineProperty(namespace, Symbol.toStringTag, {
621
+ value: "Module"
622
+ });
623
+ return namespace;
624
+ } : function () {
625
+ return Object.create(null);
626
+ };
627
+ })();
628
+ });
629
+ //# sourceMappingURL=s.js.map?as_js_classic