@jsenv/core 23.11.1 → 24.1.0-alpha.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.
@@ -1,80 +1,6 @@
1
1
  (function () {
2
2
  'use strict';
3
3
 
4
- // eslint-disable-next-line consistent-return
5
- var arrayWithHoles = (function (arr) {
6
- if (Array.isArray(arr)) return arr;
7
- });
8
-
9
- function _iterableToArrayLimit(arr, i) {
10
- // this is an expanded form of \`for...of\` that properly supports abrupt completions of
11
- // iterators etc. variable names have been minimised to reduce the size of this massive
12
- // helper. sometimes spec compliance is annoying :(
13
- //
14
- // _n = _iteratorNormalCompletion
15
- // _d = _didIteratorError
16
- // _e = _iteratorError
17
- // _i = _iterator
18
- // _s = _step
19
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
20
-
21
- if (_i == null) return;
22
- var _arr = [];
23
- var _n = true;
24
- var _d = false;
25
-
26
- var _s, _e;
27
-
28
- try {
29
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
30
- _arr.push(_s.value);
31
-
32
- if (i && _arr.length === i) break;
33
- }
34
- } catch (err) {
35
- _d = true;
36
- _e = err;
37
- } finally {
38
- try {
39
- if (!_n && _i["return"] != null) _i["return"]();
40
- } finally {
41
- if (_d) throw _e;
42
- }
43
- }
44
-
45
- return _arr;
46
- }
47
-
48
- /* eslint-disable no-eq-null, eqeqeq */
49
- function arrayLikeToArray(arr, len) {
50
- if (len == null || len > arr.length) len = arr.length;
51
- var arr2 = new Array(len);
52
-
53
- for (var i = 0; i < len; i++) {
54
- arr2[i] = arr[i];
55
- }
56
-
57
- return arr2;
58
- }
59
-
60
- /* eslint-disable consistent-return */
61
- function unsupportedIterableToArray(o, minLen) {
62
- if (!o) return;
63
- if (typeof o === "string") return arrayLikeToArray(o, minLen);
64
- var n = Object.prototype.toString.call(o).slice(8, -1);
65
- if (n === "Object" && o.constructor) n = o.constructor.name;
66
- if (n === "Map" || n === "Set") return Array.from(o);
67
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
68
- }
69
-
70
- var nonIterableRest = (function () {
71
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
72
- });
73
-
74
- var _slicedToArray = (function (arr, i) {
75
- return arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
76
- });
77
-
78
4
  var _defineProperty = (function (obj, key, value) {
79
5
  // Shortcircuit the slow defineProperty path when possible.
80
6
  // We are trying to avoid issues where setters defined on the
@@ -189,7 +115,7 @@
189
115
  return string;
190
116
  };
191
117
 
192
- function _await$5(value, then, direct) {
118
+ function _await$4(value, then, direct) {
193
119
  if (direct) {
194
120
  return then ? then(value) : value;
195
121
  }
@@ -201,7 +127,7 @@
201
127
  return then ? value.then(then) : value;
202
128
  }
203
129
 
204
- function _async$5(f) {
130
+ function _async$4(f) {
205
131
  return function () {
206
132
  for (var args = [], i = 0; i < arguments.length; i++) {
207
133
  args[i] = arguments[i];
@@ -228,7 +154,7 @@
228
154
  }
229
155
  }
230
156
 
231
- var fetchUsingXHR = _async$5(function (url) {
157
+ var fetchUsingXHR = _async$4(function (url) {
232
158
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
233
159
  signal = _ref.signal,
234
160
  _ref$method = _ref.method,
@@ -312,7 +238,7 @@
312
238
  }
313
239
 
314
240
  xhr.send(body);
315
- return _await$5(headersPromise, function () {
241
+ return _await$4(headersPromise, function () {
316
242
  // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseURL
317
243
  var responseUrl = "responseURL" in xhr ? xhr.responseURL : headers["x-request-url"];
318
244
  var responseStatus = xhr.status;
@@ -320,7 +246,7 @@
320
246
  var responseHeaders = getHeadersFromXHR(xhr);
321
247
 
322
248
  var readBody = function readBody() {
323
- return _await$5(bodyPromise, function () {
249
+ return _await$4(bodyPromise, function () {
324
250
  var status = xhr.status; // in Chrome on file:/// URLs, status is 0
325
251
 
326
252
  if (status === 0) {
@@ -356,7 +282,7 @@
356
282
  return _call$1(text, JSON.parse);
357
283
  };
358
284
 
359
- var blob = _async$5(function () {
285
+ var blob = _async$4(function () {
360
286
  if (!hasBlob) {
361
287
  throw new Error("blob not supported");
362
288
  }
@@ -393,7 +319,7 @@
393
319
  });
394
320
  };
395
321
 
396
- var formData = _async$5(function () {
322
+ var formData = _async$4(function () {
397
323
  if (!hasFormData) {
398
324
  throw new Error("formData not supported");
399
325
  }
@@ -574,7 +500,7 @@
574
500
  return form;
575
501
  };
576
502
 
577
- var blobToArrayBuffer = _async$5(function (blob) {
503
+ var blobToArrayBuffer = _async$4(function (blob) {
578
504
  var reader = new FileReader();
579
505
  var promise = fileReaderReady(reader);
580
506
  reader.readAsArrayBuffer(blob);
@@ -625,7 +551,7 @@
625
551
 
626
552
  var _excluded = ["mode"];
627
553
 
628
- function _await$4(value, then, direct) {
554
+ function _await$3(value, then, direct) {
629
555
  if (direct) {
630
556
  return then ? then(value) : value;
631
557
  }
@@ -637,14 +563,14 @@
637
563
  return then ? value.then(then) : value;
638
564
  }
639
565
 
640
- var fetchNative = _async$4(function (url) {
566
+ var fetchNative = _async$3(function (url) {
641
567
  var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
642
568
 
643
569
  var _ref$mode = _ref.mode,
644
570
  mode = _ref$mode === void 0 ? "cors" : _ref$mode,
645
571
  options = _objectWithoutProperties(_ref, _excluded);
646
572
 
647
- return _await$4(window.fetch(url, _objectSpread2({
573
+ return _await$3(window.fetch(url, _objectSpread2({
648
574
  mode: mode
649
575
  }, options)), function (response) {
650
576
  return {
@@ -671,7 +597,7 @@
671
597
  });
672
598
  });
673
599
 
674
- function _async$4(f) {
600
+ function _async$3(f) {
675
601
  return function () {
676
602
  for (var args = [], i = 0; i < arguments.length; i++) {
677
603
  args[i] = arguments[i];
@@ -695,7 +621,7 @@
695
621
 
696
622
  var fetchUrl = typeof window.fetch === "function" && typeof window.AbortController === "function" ? fetchNative : fetchUsingXHR;
697
623
 
698
- function _await$3(value, then, direct) {
624
+ function _await$2(value, then, direct) {
699
625
  if (direct) {
700
626
  return then ? then(value) : value;
701
627
  }
@@ -707,7 +633,7 @@
707
633
  return then ? value.then(then) : value;
708
634
  }
709
635
 
710
- function _async$3(f) {
636
+ function _async$2(f) {
711
637
  return function () {
712
638
  for (var args = [], i = 0; i < arguments.length; i++) {
713
639
  args[i] = arguments[i];
@@ -721,10 +647,10 @@
721
647
  };
722
648
  }
723
649
 
724
- var fetchJson = _async$3(function (url) {
650
+ var fetchJson = _async$2(function (url) {
725
651
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
726
- return _await$3(fetchUrl(url, options), function (response) {
727
- return _await$3(response.json());
652
+ return _await$2(fetchUrl(url, options), function (response) {
653
+ return _await$2(response.json());
728
654
  });
729
655
  });
730
656
 
@@ -1105,7 +1031,7 @@
1105
1031
  });
1106
1032
  };
1107
1033
 
1108
- function _await$2(value, then, direct) {
1034
+ function _await$1(value, then, direct) {
1109
1035
  if (direct) {
1110
1036
  return then ? then(value) : value;
1111
1037
  }
@@ -1117,7 +1043,7 @@
1117
1043
  return then ? value.then(then) : value;
1118
1044
  }
1119
1045
 
1120
- function _async$2(f) {
1046
+ function _async$1(f) {
1121
1047
  return function () {
1122
1048
  for (var args = [], i = 0; i < arguments.length; i++) {
1123
1049
  args[i] = arguments[i];
@@ -1154,7 +1080,7 @@
1154
1080
  return then(result);
1155
1081
  }
1156
1082
 
1157
- function _catch$1(body, recover) {
1083
+ function _catch(body, recover) {
1158
1084
  try {
1159
1085
  var result = body();
1160
1086
  } catch (e) {
@@ -1168,14 +1094,14 @@
1168
1094
  return result;
1169
1095
  }
1170
1096
 
1171
- var scanBrowserRuntimeFeatures = _async$2(function () {
1097
+ var scanBrowserRuntimeFeatures = _async$1(function () {
1172
1098
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1173
1099
  _ref$coverageHandledF = _ref.coverageHandledFromOutside,
1174
1100
  coverageHandledFromOutside = _ref$coverageHandledF === void 0 ? false : _ref$coverageHandledF,
1175
1101
  _ref$failFastOnFeatur = _ref.failFastOnFeatureDetection,
1176
1102
  failFastOnFeatureDetection = _ref$failFastOnFeatur === void 0 ? false : _ref$failFastOnFeatur;
1177
1103
 
1178
- return _await$2(fetchJson("/.jsenv/__compile_server_meta__.json"), function (_ref2) {
1104
+ return _await$1(fetchJson("/.jsenv/__compile_server_meta__.json"), function (_ref2) {
1179
1105
  var outDirectoryRelativeUrl = _ref2.outDirectoryRelativeUrl,
1180
1106
  inlineImportMapIntoHTML = _ref2.inlineImportMapIntoHTML,
1181
1107
  customCompilerPatterns = _ref2.customCompilerPatterns,
@@ -1194,12 +1120,12 @@
1194
1120
  cssImportAssertions: undefined,
1195
1121
  newStylesheet: undefined
1196
1122
  };
1197
- return _await$2(detectSupportedFeatures({
1123
+ return _await$1(detectSupportedFeatures({
1198
1124
  featuresReport: featuresReport,
1199
1125
  failFastOnFeatureDetection: failFastOnFeatureDetection,
1200
1126
  inlineImportMapIntoHTML: inlineImportMapIntoHTML
1201
1127
  }), function () {
1202
- return _await$2(pluginRequiredNamesFromGroupInfo(groupInfo, {
1128
+ return _await$1(pluginRequiredNamesFromGroupInfo(groupInfo, {
1203
1129
  featuresReport: featuresReport,
1204
1130
  coverageHandledFromOutside: coverageHandledFromOutside
1205
1131
  }), function (pluginRequiredNameArray) {
@@ -1219,14 +1145,14 @@
1219
1145
  });
1220
1146
  });
1221
1147
 
1222
- var detectSupportedFeatures = _async$2(function (_ref3) {
1148
+ var detectSupportedFeatures = _async$1(function (_ref3) {
1223
1149
  var featuresReport = _ref3.featuresReport,
1224
1150
  failFastOnFeatureDetection = _ref3.failFastOnFeatureDetection,
1225
1151
  inlineImportMapIntoHTML = _ref3.inlineImportMapIntoHTML;
1226
1152
  // start testing importmap support first and not in paralell
1227
1153
  // so that there is not module script loaded beore importmap is injected
1228
1154
  // it would log an error in chrome console and return undefined
1229
- return _await$2(supportsImportmap({
1155
+ return _await$1(supportsImportmap({
1230
1156
  // chrome supports inline but not remote importmap
1231
1157
  // https://github.com/WICG/import-maps/issues/235
1232
1158
  // at this stage we won't know if the html file will use
@@ -1257,7 +1183,7 @@
1257
1183
  });
1258
1184
  });
1259
1185
 
1260
- var pluginRequiredNamesFromGroupInfo = _async$2(function (groupInfo, _ref4) {
1186
+ var pluginRequiredNamesFromGroupInfo = _async$1(function (groupInfo, _ref4) {
1261
1187
  var featuresReport = _ref4.featuresReport,
1262
1188
  coverageHandledFromOutside = _ref4.coverageHandledFromOutside;
1263
1189
  var pluginRequiredNameArray = groupInfo.pluginRequiredNameArray;
@@ -1312,7 +1238,7 @@
1312
1238
  }
1313
1239
  };
1314
1240
 
1315
- var supportsImportmap = _async$2(function () {
1241
+ var supportsImportmap = _async$1(function () {
1316
1242
  var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1317
1243
  _ref5$remote = _ref5.remote,
1318
1244
  remote = _ref5$remote === void 0 ? true : _ref5$remote;
@@ -1354,10 +1280,10 @@
1354
1280
  });
1355
1281
  });
1356
1282
 
1357
- var supportsDynamicImport = _async$2(function () {
1283
+ var supportsDynamicImport = _async$1(function () {
1358
1284
  var moduleSource = asBase64Url("export default 42");
1359
- return _catch$1(function () {
1360
- return _await$2(import(moduleSource), function (namespace) {
1285
+ return _catch(function () {
1286
+ return _await$1(import(moduleSource), function (namespace) {
1361
1287
  return namespace.default === 42;
1362
1288
  });
1363
1289
  }, function () {
@@ -1365,10 +1291,10 @@
1365
1291
  });
1366
1292
  });
1367
1293
 
1368
- var supportsTopLevelAwait = _async$2(function () {
1294
+ var supportsTopLevelAwait = _async$1(function () {
1369
1295
  var moduleSource = asBase64Url("export default await Promise.resolve(42)");
1370
- return _catch$1(function () {
1371
- return _await$2(import(moduleSource), function (namespace) {
1296
+ return _catch(function () {
1297
+ return _await$1(import(moduleSource), function (namespace) {
1372
1298
  return namespace.default === 42;
1373
1299
  });
1374
1300
  }, function () {
@@ -1376,11 +1302,11 @@
1376
1302
  });
1377
1303
  });
1378
1304
 
1379
- var supportsJsonImportAssertions = _async$2(function () {
1305
+ var supportsJsonImportAssertions = _async$1(function () {
1380
1306
  var jsonBase64Url = asBase64Url("42", "application/json");
1381
1307
  var moduleSource = asBase64Url("export { default } from \"".concat(jsonBase64Url, "\" assert { type: \"json\" }"));
1382
- return _catch$1(function () {
1383
- return _await$2(import(moduleSource), function (namespace) {
1308
+ return _catch(function () {
1309
+ return _await$1(import(moduleSource), function (namespace) {
1384
1310
  return namespace.default === 42;
1385
1311
  });
1386
1312
  }, function () {
@@ -1388,11 +1314,11 @@
1388
1314
  });
1389
1315
  });
1390
1316
 
1391
- var supportsCssImportAssertions = _async$2(function () {
1317
+ var supportsCssImportAssertions = _async$1(function () {
1392
1318
  var cssBase64Url = asBase64Url("p { color: red; }", "text/css");
1393
1319
  var moduleSource = asBase64Url("export { default } from \"".concat(cssBase64Url, "\" assert { type: \"css\" }"));
1394
- return _catch$1(function () {
1395
- return _await$2(import(moduleSource), function (namespace) {
1320
+ return _catch(function () {
1321
+ return _await$1(import(moduleSource), function (namespace) {
1396
1322
  return namespace.default instanceof CSSStyleSheet;
1397
1323
  });
1398
1324
  }, function () {
@@ -1405,63 +1331,6 @@
1405
1331
  return "data:".concat(mimeType, ";base64,").concat(window.btoa(text));
1406
1332
  };
1407
1333
 
1408
- function _await$1(value, then, direct) {
1409
- if (direct) {
1410
- return then ? then(value) : value;
1411
- }
1412
-
1413
- if (!value || !value.then) {
1414
- value = Promise.resolve(value);
1415
- }
1416
-
1417
- return then ? value.then(then) : value;
1418
- }
1419
-
1420
- function _catch(body, recover) {
1421
- try {
1422
- var result = body();
1423
- } catch (e) {
1424
- return recover(e);
1425
- }
1426
-
1427
- if (result && result.then) {
1428
- return result.then(void 0, recover);
1429
- }
1430
-
1431
- return result;
1432
- }
1433
-
1434
- function _async$1(f) {
1435
- return function () {
1436
- for (var args = [], i = 0; i < arguments.length; i++) {
1437
- args[i] = arguments[i];
1438
- }
1439
-
1440
- try {
1441
- return Promise.resolve(f.apply(this, args));
1442
- } catch (e) {
1443
- return Promise.reject(e);
1444
- }
1445
- };
1446
- }
1447
-
1448
- var fetchExploringJson = _async$1(function () {
1449
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1450
- signal = _ref.signal;
1451
-
1452
- return _catch(function () {
1453
- return _await$1(fetchJson("/.jsenv/exploring.json", {
1454
- signal: signal
1455
- }));
1456
- }, function (e) {
1457
- if (signal && signal.aborted && e.name === "AbortError") {
1458
- throw e;
1459
- }
1460
-
1461
- throw new Error(createDetailedMessage("Cannot communicate with exploring server due to a network error", _defineProperty({}, "error stack", e.stack)));
1462
- });
1463
- });
1464
-
1465
1334
  function _await(value, then, direct) {
1466
1335
  if (direct) {
1467
1336
  return then ? then(value) : value;
@@ -1475,21 +1344,12 @@
1475
1344
  }
1476
1345
 
1477
1346
  var redirect = _async(function () {
1478
- return _await(Promise.all([scanBrowserRuntimeFeatures({
1347
+ var redirectTarget = new URLSearchParams(window.location.search).get("redirect");
1348
+ return _await(scanBrowserRuntimeFeatures({
1479
1349
  failFastOnFeatureDetection: true
1480
- }), fetchExploringJson()]), function (_ref) {
1481
- var _ref2 = _slicedToArray(_ref, 2),
1482
- browserRuntimeFeaturesReport = _ref2[0],
1483
- exploringHtmlFileRelativeUrl = _ref2[1].exploringHtmlFileRelativeUrl;
1484
-
1485
- if (browserRuntimeFeaturesReport.canAvoidCompilation) {
1486
- window.location.href = "/".concat(exploringHtmlFileRelativeUrl);
1487
- return;
1488
- }
1489
-
1490
- var outDirectoryRelativeUrl = browserRuntimeFeaturesReport.outDirectoryRelativeUrl,
1491
- compileId = browserRuntimeFeaturesReport.compileId;
1492
- window.location.href = "/".concat(outDirectoryRelativeUrl).concat(compileId, "/").concat(exploringHtmlFileRelativeUrl);
1350
+ }), function (browserRuntimeFeaturesReport) {
1351
+ var href = "".concat(getDirectoryUrl(browserRuntimeFeaturesReport)).concat(redirectTarget);
1352
+ window.location.href = href;
1493
1353
  });
1494
1354
  });
1495
1355
 
@@ -1507,6 +1367,18 @@
1507
1367
  };
1508
1368
  }
1509
1369
 
1370
+ var getDirectoryUrl = function getDirectoryUrl(_ref) {
1371
+ var canAvoidCompilation = _ref.canAvoidCompilation,
1372
+ outDirectoryRelativeUrl = _ref.outDirectoryRelativeUrl,
1373
+ compileId = _ref.compileId;
1374
+
1375
+ if (canAvoidCompilation) {
1376
+ return "/";
1377
+ }
1378
+
1379
+ return "/".concat(outDirectoryRelativeUrl).concat(compileId, "/");
1380
+ };
1381
+
1510
1382
  redirect();
1511
1383
 
1512
1384
  })();