@jsenv/core 23.8.6 → 23.8.12

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.
@@ -1965,21 +1965,33 @@
1965
1965
  importer = _ref.importer,
1966
1966
  importMap = _ref.importMap,
1967
1967
  _ref$defaultExtension = _ref.defaultExtension,
1968
- defaultExtension = _ref$defaultExtension === void 0 ? true : _ref$defaultExtension,
1968
+ defaultExtension = _ref$defaultExtension === void 0 ? false : _ref$defaultExtension,
1969
1969
  createBareSpecifierError = _ref.createBareSpecifierError,
1970
1970
  _ref$onImportMapping = _ref.onImportMapping,
1971
1971
  onImportMapping = _ref$onImportMapping === void 0 ? function () {} : _ref$onImportMapping;
1972
- return applyDefaultExtension$1({
1973
- url: importMap ? applyImportMap({
1972
+ var url;
1973
+
1974
+ if (importMap) {
1975
+ url = applyImportMap({
1974
1976
  importMap: importMap,
1975
1977
  specifier: specifier,
1976
1978
  importer: importer,
1977
1979
  createBareSpecifierError: createBareSpecifierError,
1978
1980
  onImportMapping: onImportMapping
1979
- }) : resolveUrl(specifier, importer),
1980
- importer: importer,
1981
- defaultExtension: defaultExtension
1982
- });
1981
+ });
1982
+ } else {
1983
+ url = resolveUrl(specifier, importer);
1984
+ }
1985
+
1986
+ if (defaultExtension) {
1987
+ url = applyDefaultExtension$1({
1988
+ url: url,
1989
+ importer: importer,
1990
+ defaultExtension: defaultExtension
1991
+ });
1992
+ }
1993
+
1994
+ return url;
1983
1995
  };
1984
1996
 
1985
1997
  var applyDefaultExtension$1 = function applyDefaultExtension(_ref2) {
@@ -2265,7 +2277,7 @@
2265
2277
  specifier: specifier,
2266
2278
  importer: importer
2267
2279
  }, importMapUrl ? {
2268
- "how to fix": "Add a mapping for \"".concat(specifier, "\" into the importmap file at ").concat(importMapUrl)
2280
+ "how to fix": "Add a mapping for \"".concat(specifier, "\" into the importmap file at \"").concat(importMapUrl, "\"")
2269
2281
  } : {
2270
2282
  "how to fix": "Add an importmap with a mapping for \"".concat(specifier, "\""),
2271
2283
  "suggestion": "Generate importmap using https://github.com/jsenv/importmap-node-module"
@@ -3299,230 +3311,6 @@
3299
3311
  });
3300
3312
  });
3301
3313
 
3302
- var displayErrorInDocument = function displayErrorInDocument(error) {
3303
- var title = "An error occured";
3304
- var theme;
3305
- var message;
3306
-
3307
- if (error && error.parsingError) {
3308
- theme = "light";
3309
- var parsingError = error.parsingError;
3310
- message = errorToHTML(parsingError.messageHTML || escapeHtml(parsingError.message));
3311
- } else {
3312
- theme = "dark";
3313
- message = errorToHTML(error);
3314
- }
3315
-
3316
- var css = "\n .jsenv-console {\n background: rgba(0, 0, 0, 0.95);\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n z-index: 1000;\n box-sizing: border-box;\n padding: 1em;\n }\n\n .jsenv-console h1 {\n color: red;\n display: flex;\n align-items: center;\n }\n\n #button-close-jsenv-console {\n margin-left: 10px;\n }\n\n .jsenv-console pre {\n overflow: auto;\n max-width: 70em;\n /* avoid scrollbar to hide the text behind it */\n padding: 20px;\n }\n\n .jsenv-console pre[data-theme=\"dark\"] {\n background: #111;\n border: 1px solid #333;\n color: #eee;\n }\n\n .jsenv-console pre[data-theme=\"light\"] {\n background: #1E1E1E;\n border: 1px solid white;\n color: #EEEEEE;\n }\n\n .jsenv-console pre a {\n color: inherit;\n }\n ";
3317
- var html = "\n <style type=\"text/css\">".concat(css, "></style>\n <div class=\"jsenv-console\">\n <h1>").concat(title, " <button id=\"button-close-jsenv-console\">X</button></h1>\n <pre data-theme=\"").concat(theme, "\">").concat(message, "</pre>\n </div>\n ");
3318
- var removeJsenvConsole = appendHMTLInside(html, document.body);
3319
-
3320
- document.querySelector("#button-close-jsenv-console").onclick = function () {
3321
- removeJsenvConsole();
3322
- };
3323
- };
3324
-
3325
- var escapeHtml = function escapeHtml(string) {
3326
- return string.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
3327
- };
3328
-
3329
- var errorToHTML = function errorToHTML(error) {
3330
- var html;
3331
-
3332
- if (error && error instanceof Error) {
3333
- // stackTrace formatted by V8
3334
- if (Error.captureStackTrace) {
3335
- html = escapeHtml(error.stack);
3336
- } else {
3337
- // other stack trace such as firefox do not contain error.message
3338
- html = escapeHtml("".concat(error.message, "\n ").concat(error.stack));
3339
- }
3340
- } else if (typeof error === "string") {
3341
- html = error;
3342
- } else {
3343
- html = JSON.stringify(error);
3344
- }
3345
-
3346
- var htmlWithCorrectLineBreaks = html.replace(/\n/g, "\n");
3347
- var htmlWithLinks = stringToStringWithLink(htmlWithCorrectLineBreaks, {
3348
- transform: function transform(url) {
3349
- return {
3350
- href: url,
3351
- text: url
3352
- };
3353
- }
3354
- });
3355
- return htmlWithLinks;
3356
- }; // `Error: yo
3357
- // at Object.execute (http://127.0.0.1:57300/build/src/__test__/file-throw.js:9:13)
3358
- // at doExec (http://127.0.0.1:3000/src/__test__/file-throw.js:452:38)
3359
- // at postOrderExec (http://127.0.0.1:3000/src/__test__/file-throw.js:448:16)
3360
- // at http://127.0.0.1:3000/src/__test__/file-throw.js:399:18`.replace(/(?:https?|ftp|file):\/\/(.*+)$/gm, (...args) => {
3361
- // debugger
3362
- // })
3363
-
3364
-
3365
- var stringToStringWithLink = function stringToStringWithLink(source) {
3366
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
3367
- _ref$transform = _ref.transform,
3368
- transform = _ref$transform === void 0 ? function (url) {
3369
- return {
3370
- href: url,
3371
- text: url
3372
- };
3373
- } : _ref$transform;
3374
-
3375
- return source.replace(/(?:https?|ftp|file):\/\/\S+/gm, function (match) {
3376
- var linkHTML = "";
3377
- var lastChar = match[match.length - 1]; // hotfix because our url regex sucks a bit
3378
-
3379
- var endsWithSeparationChar = lastChar === ")" || lastChar === ":";
3380
-
3381
- if (endsWithSeparationChar) {
3382
- match = match.slice(0, -1);
3383
- }
3384
-
3385
- var lineAndColumnPattern = /:([0-9]+):([0-9]+)$/;
3386
- var lineAndColumMatch = match.match(lineAndColumnPattern);
3387
-
3388
- if (lineAndColumMatch) {
3389
- var lineAndColumnString = lineAndColumMatch[0];
3390
- var lineNumber = lineAndColumMatch[1];
3391
- var columnNumber = lineAndColumMatch[2];
3392
- var url = match.slice(0, -lineAndColumnString.length);
3393
-
3394
- var _transform = transform(url),
3395
- href = _transform.href,
3396
- text = _transform.text;
3397
-
3398
- linkHTML = link({
3399
- href: href,
3400
- text: "".concat(text, ":").concat(lineNumber, ":").concat(columnNumber)
3401
- });
3402
- } else {
3403
- var linePattern = /:([0-9]+)$/;
3404
- var lineMatch = match.match(linePattern);
3405
-
3406
- if (lineMatch) {
3407
- var lineString = lineMatch[0];
3408
- var _lineNumber = lineMatch[1];
3409
-
3410
- var _url = match.slice(0, -lineString.length);
3411
-
3412
- var _transform2 = transform(_url),
3413
- _href = _transform2.href,
3414
- _text = _transform2.text;
3415
-
3416
- linkHTML = link({
3417
- href: _href,
3418
- text: "".concat(_text, ":").concat(_lineNumber)
3419
- });
3420
- } else {
3421
- var _url2 = match;
3422
-
3423
- var _transform3 = transform(_url2),
3424
- _href2 = _transform3.href,
3425
- _text2 = _transform3.text;
3426
-
3427
- linkHTML = link({
3428
- href: _href2,
3429
- text: _text2
3430
- });
3431
- }
3432
- }
3433
-
3434
- if (endsWithSeparationChar) {
3435
- return "".concat(linkHTML).concat(lastChar);
3436
- }
3437
-
3438
- return linkHTML;
3439
- });
3440
- };
3441
-
3442
- var link = function link(_ref2) {
3443
- var href = _ref2.href,
3444
- _ref2$text = _ref2.text,
3445
- text = _ref2$text === void 0 ? href : _ref2$text;
3446
- return "<a href=\"".concat(href, "\">").concat(text, "</a>");
3447
- };
3448
-
3449
- var appendHMTLInside = function appendHMTLInside(html, parentNode) {
3450
- var temoraryParent = document.createElement("div");
3451
- temoraryParent.innerHTML = html;
3452
- return transferChildren(temoraryParent, parentNode);
3453
- };
3454
-
3455
- var transferChildren = function transferChildren(fromNode, toNode) {
3456
- var childNodes = [].slice.call(fromNode.childNodes, 0);
3457
- var i = 0;
3458
-
3459
- while (i < childNodes.length) {
3460
- toNode.appendChild(childNodes[i]);
3461
- i++;
3462
- }
3463
-
3464
- return function () {
3465
- var c = 0;
3466
-
3467
- while (c < childNodes.length) {
3468
- fromNode.appendChild(childNodes[c]);
3469
- c++;
3470
- }
3471
- };
3472
- };
3473
-
3474
- function _await$7(value, then, direct) {
3475
- if (direct) {
3476
- return then ? then(value) : value;
3477
- }
3478
-
3479
- if (!value || !value.then) {
3480
- value = Promise.resolve(value);
3481
- }
3482
-
3483
- return then ? value.then(then) : value;
3484
- }
3485
-
3486
- var _window = window,
3487
- Notification = _window.Notification;
3488
-
3489
- function _async$7(f) {
3490
- return function () {
3491
- for (var args = [], i = 0; i < arguments.length; i++) {
3492
- args[i] = arguments[i];
3493
- }
3494
-
3495
- try {
3496
- return Promise.resolve(f.apply(this, args));
3497
- } catch (e) {
3498
- return Promise.reject(e);
3499
- }
3500
- };
3501
- }
3502
-
3503
- var displayErrorNotificationNotAvailable = function displayErrorNotificationNotAvailable() {};
3504
-
3505
- var displayErrorNotificationImplementation = _async$7(function (error) {
3506
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
3507
- icon = _ref.icon;
3508
-
3509
- return _await$7(Notification.requestPermission(), function (permission) {
3510
- if (permission === "granted") {
3511
- var notification = new Notification("An error occured", {
3512
- lang: "en",
3513
- body: error.stack,
3514
- icon: icon
3515
- });
3516
-
3517
- notification.onclick = function () {
3518
- window.focus();
3519
- };
3520
- }
3521
- });
3522
- });
3523
-
3524
- var displayErrorNotification = typeof Notification === "function" ? displayErrorNotificationImplementation : displayErrorNotificationNotAvailable;
3525
-
3526
3314
  var makeNamespaceTransferable = function makeNamespaceTransferable(namespace) {
3527
3315
  var transferableNamespace = {};
3528
3316
  Object.keys(namespace).forEach(function (key) {
@@ -3602,7 +3390,7 @@
3602
3390
  var supportedTypes = ["Boolean", "Number", "String", "Date", "RegExp", "Blob", "FileList", "ImageData", "ImageBitmap", "ArrayBuffer"];
3603
3391
  var maybeTypes = ["Array", "Object", "Map", "Set"];
3604
3392
 
3605
- function _await$6(value, then, direct) {
3393
+ function _await$7(value, then, direct) {
3606
3394
  if (direct) {
3607
3395
  return then ? then(value) : value;
3608
3396
  }
@@ -3626,7 +3414,7 @@
3626
3414
  return then(result);
3627
3415
  }
3628
3416
 
3629
- function _async$6(f) {
3417
+ function _async$7(f) {
3630
3418
  return function () {
3631
3419
  for (var args = [], i = 0; i < arguments.length; i++) {
3632
3420
  args[i] = arguments[i];
@@ -3658,7 +3446,7 @@
3658
3446
  return value && value.then ? value.then(then) : then(value);
3659
3447
  }
3660
3448
 
3661
- var createBrowserRuntime = _async$6(function (_ref) {
3449
+ var createBrowserRuntime = _async$7(function (_ref) {
3662
3450
  var compileServerOrigin = _ref.compileServerOrigin,
3663
3451
  outDirectoryRelativeUrl = _ref.outDirectoryRelativeUrl,
3664
3452
  compileId = _ref.compileId;
@@ -3671,17 +3459,17 @@
3671
3459
  });
3672
3460
  };
3673
3461
 
3674
- var fetchJson = _async$6(function (url) {
3675
- return _await$6(fetchSource(url, {
3462
+ var fetchJson = _async$7(function (url) {
3463
+ return _await$7(fetchSource(url, {
3676
3464
  contentTypeExpected: "application/json"
3677
3465
  }), function (response) {
3678
- return _await$6(response.json());
3466
+ return _await$7(response.json());
3679
3467
  });
3680
3468
  });
3681
3469
 
3682
3470
  var outDirectoryUrl = "".concat(compileServerOrigin, "/").concat(outDirectoryRelativeUrl);
3683
3471
  var envUrl = String(new URL("env.json", outDirectoryUrl));
3684
- return _await$6(fetchJson(envUrl), function (_ref3) {
3472
+ return _await$7(fetchJson(envUrl), function (_ref3) {
3685
3473
  var importDefaultExtension = _ref3.importDefaultExtension;
3686
3474
  var compileDirectoryRelativeUrl = "".concat(outDirectoryRelativeUrl).concat(compileId, "/"); // if there is an importmap in the document we use it instead of fetching.
3687
3475
  // systemjs style with systemjs-importmap
@@ -3695,12 +3483,12 @@
3695
3483
  return _invoke$4(function () {
3696
3484
  if (importmapScript.src) {
3697
3485
  importMapUrl = importmapScript.src;
3698
- return _await$6(fetchSource(importMapUrl, {
3486
+ return _await$7(fetchSource(importMapUrl, {
3699
3487
  contentTypeExpected: "application/importmap+json"
3700
3488
  }), function (importmapFileResponse) {
3701
3489
  var _temp = importmapFileResponse.status === 404;
3702
3490
 
3703
- return _await$6(_temp ? {} : importmapFileResponse.json(), function (_importmapFileRespons) {
3491
+ return _await$7(_temp ? {} : importmapFileResponse.json(), function (_importmapFileRespons) {
3704
3492
  importmapRaw = _importmapFileRespons;
3705
3493
  }, _temp);
3706
3494
  });
@@ -3713,7 +3501,7 @@
3713
3501
  });
3714
3502
  }
3715
3503
  }, function () {
3716
- return _await$6(createImportResolverForImportmap({
3504
+ return _await$7(createImportResolverForImportmap({
3717
3505
  // projectDirectoryUrl,
3718
3506
  compileServerOrigin: compileServerOrigin,
3719
3507
  compileDirectoryRelativeUrl: compileDirectoryRelativeUrl,
@@ -3721,8 +3509,8 @@
3721
3509
  importMapUrl: importMapUrl,
3722
3510
  importDefaultExtension: importDefaultExtension
3723
3511
  }), function (importResolver) {
3724
- var importFile = _async$6(function (specifier) {
3725
- return _await$6(memoizedCreateBrowserSystem({
3512
+ var importFile = _async$7(function (specifier) {
3513
+ return _await$7(memoizedCreateBrowserSystem({
3726
3514
  compileServerOrigin: compileServerOrigin,
3727
3515
  compileDirectoryRelativeUrl: compileDirectoryRelativeUrl,
3728
3516
  fetchSource: fetchSource,
@@ -3732,16 +3520,10 @@
3732
3520
  });
3733
3521
  });
3734
3522
 
3735
- var executeFile = _async$6(function (specifier) {
3523
+ var executeFile = _async$7(function (specifier) {
3736
3524
  var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
3737
3525
  _ref4$transferableNam = _ref4.transferableNamespace,
3738
3526
  transferableNamespace = _ref4$transferableNam === void 0 ? false : _ref4$transferableNam,
3739
- _ref4$errorExposureIn = _ref4.errorExposureInConsole,
3740
- errorExposureInConsole = _ref4$errorExposureIn === void 0 ? true : _ref4$errorExposureIn,
3741
- _ref4$errorExposureIn2 = _ref4.errorExposureInNotification,
3742
- errorExposureInNotification = _ref4$errorExposureIn2 === void 0 ? false : _ref4$errorExposureIn2,
3743
- _ref4$errorExposureIn3 = _ref4.errorExposureInDocument,
3744
- errorExposureInDocument = _ref4$errorExposureIn3 === void 0 ? true : _ref4$errorExposureIn3,
3745
3527
  _ref4$executionExposu = _ref4.executionExposureOnWindow,
3746
3528
  executionExposureOnWindow = _ref4$executionExposu === void 0 ? false : _ref4$executionExposu,
3747
3529
  _ref4$errorTransform = _ref4.errorTransform,
@@ -3750,15 +3532,15 @@
3750
3532
  } : _ref4$errorTransform,
3751
3533
  measurePerformance = _ref4.measurePerformance;
3752
3534
 
3753
- return _await$6(memoizedCreateBrowserSystem({
3535
+ return _await$7(memoizedCreateBrowserSystem({
3754
3536
  compileServerOrigin: compileServerOrigin,
3755
3537
  compileDirectoryRelativeUrl: compileDirectoryRelativeUrl,
3756
3538
  fetchSource: fetchSource,
3757
3539
  importResolver: importResolver
3758
3540
  }), function (browserSystem) {
3759
- var importUsingSystemJs = _async$6(function () {
3541
+ var importUsingSystemJs = _async$7(function () {
3760
3542
  return _catch$3(function () {
3761
- return _await$6(browserSystem.import(specifier), function (namespace) {
3543
+ return _await$7(browserSystem.import(specifier), function (namespace) {
3762
3544
  if (transferableNamespace) {
3763
3545
  namespace = makeNamespaceTransferable(namespace);
3764
3546
  }
@@ -3766,40 +3548,28 @@
3766
3548
  return {
3767
3549
  status: "completed",
3768
3550
  namespace: namespace,
3769
- coverage: readCoverage()
3551
+ coverage: readCoverage$1()
3770
3552
  };
3771
3553
  });
3772
3554
  }, function (error) {
3773
3555
  var transformedError;
3774
3556
  return _continue$1(_catch$3(function () {
3775
- return _await$6(errorTransform(error), function (_errorTransform) {
3557
+ return _await$7(errorTransform(error), function (_errorTransform) {
3776
3558
  transformedError = _errorTransform;
3777
3559
  });
3778
3560
  }, function () {
3779
3561
  transformedError = error;
3780
3562
  }), function () {
3781
- if (errorExposureInConsole) {
3782
- displayErrorInConsole(transformedError);
3783
- }
3784
-
3785
- if (errorExposureInNotification) {
3786
- displayErrorNotification(transformedError);
3787
- }
3788
-
3789
- if (errorExposureInDocument) {
3790
- displayErrorInDocument(transformedError);
3791
- }
3792
-
3793
3563
  return {
3794
3564
  status: "errored",
3795
- exceptionSource: unevalException(transformedError),
3796
- coverage: readCoverage()
3565
+ error: transformedError,
3566
+ coverage: readCoverage$1()
3797
3567
  };
3798
3568
  });
3799
3569
  });
3800
3570
  });
3801
3571
 
3802
- return _await$6(measurePerformance ? measureAsyncFnPerf(importUsingSystemJs, "jsenv_file_import") : importUsingSystemJs(), function (executionResult) {
3572
+ return _await$7(measurePerformance ? measureAsyncFnPerf(importUsingSystemJs, "jsenv_file_import") : importUsingSystemJs(), function (executionResult) {
3803
3573
  if (executionExposureOnWindow) {
3804
3574
  window.__executionResult__ = executionResult;
3805
3575
  }
@@ -3819,14 +3589,10 @@
3819
3589
  });
3820
3590
  });
3821
3591
 
3822
- var readCoverage = function readCoverage() {
3592
+ var readCoverage$1 = function readCoverage() {
3823
3593
  return window.__coverage__;
3824
3594
  };
3825
3595
 
3826
- var displayErrorInConsole = function displayErrorInConsole(error) {
3827
- console.error(error);
3828
- };
3829
-
3830
3596
  var stackToString = function stackToString(stack, _ref) {
3831
3597
  var error = _ref.error,
3832
3598
  indent = _ref.indent;
@@ -3917,7 +3683,7 @@
3917
3683
  return string.replace(/\\/g, "/");
3918
3684
  };
3919
3685
 
3920
- function _await$5(value, then, direct) {
3686
+ function _await$6(value, then, direct) {
3921
3687
  if (direct) {
3922
3688
  return then ? then(value) : value;
3923
3689
  }
@@ -3939,7 +3705,7 @@
3939
3705
  return then(result);
3940
3706
  }
3941
3707
 
3942
- function _async$5(f) {
3708
+ function _async$6(f) {
3943
3709
  return function () {
3944
3710
  for (var args = [], i = 0; i < arguments.length; i++) {
3945
3711
  args[i] = arguments[i];
@@ -3953,7 +3719,7 @@
3953
3719
  };
3954
3720
  }
3955
3721
 
3956
- var remapCallSite = _async$5(function (callSite, _ref) {
3722
+ var remapCallSite = _async$6(function (callSite, _ref) {
3957
3723
  var _exit = false;
3958
3724
  var urlToSourcemapConsumer = _ref.urlToSourcemapConsumer,
3959
3725
  resolveFile = _ref.resolveFile,
@@ -3972,7 +3738,7 @@
3972
3738
  if (source) {
3973
3739
  var line = callSite.getLineNumber();
3974
3740
  var column = callSite.getColumnNumber() - 1;
3975
- return _await$5(remapSourcePosition({
3741
+ return _await$6(remapSourcePosition({
3976
3742
  source: source,
3977
3743
  line: line,
3978
3744
  column: column,
@@ -4017,7 +3783,7 @@
4017
3783
  return _invoke$3(function () {
4018
3784
  if (origin) {
4019
3785
  var callSiteClone = cloneCallSite(callSite);
4020
- return _await$5(remapEvalOrigin(origin, {
3786
+ return _await$6(remapEvalOrigin(origin, {
4021
3787
  resolveFile: resolveFile,
4022
3788
  urlToSourcemapConsumer: urlToSourcemapConsumer,
4023
3789
  readErrorStack: readErrorStack,
@@ -4158,7 +3924,7 @@
4158
3924
  // https://code.google.com/p/v8/source/browse/trunk/src/messages.js
4159
3925
 
4160
3926
 
4161
- var remapEvalOrigin = _async$5(function (origin, _ref3) {
3927
+ var remapEvalOrigin = _async$6(function (origin, _ref3) {
4162
3928
  var _exit3 = false;
4163
3929
  var resolveFile = _ref3.resolveFile,
4164
3930
  urlToSourcemapConsumer = _ref3.urlToSourcemapConsumer,
@@ -4170,7 +3936,7 @@
4170
3936
  var source = topLevelEvalMatch[2];
4171
3937
  var line = Number(topLevelEvalMatch[3]);
4172
3938
  var column = topLevelEvalMatch[4] - 1;
4173
- return _await$5(remapSourcePosition({
3939
+ return _await$6(remapSourcePosition({
4174
3940
  source: source,
4175
3941
  line: line,
4176
3942
  column: column,
@@ -4189,7 +3955,7 @@
4189
3955
  var nestedEvalMatch = /^eval at ([^(]+) \((.+)\)$/.exec(origin);
4190
3956
  return _invoke$3(function () {
4191
3957
  if (nestedEvalMatch) {
4192
- return _await$5(remapEvalOrigin(nestedEvalMatch[2], {
3958
+ return _await$6(remapEvalOrigin(nestedEvalMatch[2], {
4193
3959
  resolveFile: resolveFile,
4194
3960
  urlToSourcemapConsumer: urlToSourcemapConsumer,
4195
3961
  onFailure: onFailure
@@ -4204,7 +3970,7 @@
4204
3970
  });
4205
3971
  });
4206
3972
 
4207
- var remapSourcePosition = _async$5(function (_ref4) {
3973
+ var remapSourcePosition = _async$6(function (_ref4) {
4208
3974
  var source = _ref4.source,
4209
3975
  line = _ref4.line,
4210
3976
  column = _ref4.column,
@@ -4220,7 +3986,7 @@
4220
3986
  var url = sourceToUrl(source, {
4221
3987
  resolveFile: resolveFile
4222
3988
  });
4223
- return url ? _await$5(urlToSourcemapConsumer(url), function (sourceMapConsumer) {
3989
+ return url ? _await$6(urlToSourcemapConsumer(url), function (sourceMapConsumer) {
4224
3990
  if (!sourceMapConsumer) return position;
4225
3991
 
4226
3992
  try {
@@ -4288,7 +4054,7 @@
4288
4054
  return /^[a-zA-Z]{2,}:/.test(string);
4289
4055
  };
4290
4056
 
4291
- function _await$4(value, then, direct) {
4057
+ function _await$5(value, then, direct) {
4292
4058
  if (direct) {
4293
4059
  return then ? then(value) : value;
4294
4060
  }
@@ -4300,7 +4066,7 @@
4300
4066
  return then ? value.then(then) : value;
4301
4067
  }
4302
4068
 
4303
- function _async$4(f) {
4069
+ function _async$5(f) {
4304
4070
  return function () {
4305
4071
  for (var args = [], i = 0; i < arguments.length; i++) {
4306
4072
  args[i] = arguments[i];
@@ -4342,19 +4108,19 @@
4342
4108
  return value && value.then ? value.then(then) : then(value);
4343
4109
  }
4344
4110
 
4345
- var getOriginalCallsites = _async$4(function (_ref) {
4111
+ var getOriginalCallsites = _async$5(function (_ref) {
4346
4112
  var stack = _ref.stack,
4347
4113
  resolveFile = _ref.resolveFile,
4348
4114
  fetchFile = _ref.fetchFile,
4349
4115
  SourceMapConsumer = _ref.SourceMapConsumer,
4350
4116
  readErrorStack = _ref.readErrorStack,
4351
4117
  onFailure = _ref.onFailure;
4352
- var urlToSourcemapConsumer = memoizeByFirstArgStringValue(_async$4(function (stackTraceFileUrl) {
4118
+ var urlToSourcemapConsumer = memoizeByFirstArgStringValue(_async$5(function (stackTraceFileUrl) {
4353
4119
  var _exit = false;
4354
4120
  return stackTraceFileUrl.startsWith("node:") ? null : _catch$2(function () {
4355
4121
  var text;
4356
4122
  return _continue(_catch$2(function () {
4357
- return _await$4(fetchFile(stackTraceFileUrl), function (fileResponse) {
4123
+ return _await$5(fetchFile(stackTraceFileUrl), function (fileResponse) {
4358
4124
  var status = fileResponse.status;
4359
4125
 
4360
4126
  if (status !== 200) {
@@ -4370,7 +4136,7 @@
4370
4136
  return null;
4371
4137
  }
4372
4138
 
4373
- return _await$4(fileResponse.text(), function (_fileResponse$text) {
4139
+ return _await$5(fileResponse.text(), function (_fileResponse$text) {
4374
4140
  text = _fileResponse$text;
4375
4141
  });
4376
4142
  });
@@ -4400,7 +4166,7 @@
4400
4166
  type: "source-map"
4401
4167
  });
4402
4168
  return _catch$2(function () {
4403
- return _await$4(fetchFile(sourcemapUrl), function (sourcemapResponse) {
4169
+ return _await$5(fetchFile(sourcemapUrl), function (sourcemapResponse) {
4404
4170
  var _exit3 = false;
4405
4171
  var status = sourcemapResponse.status;
4406
4172
  return _invoke$2(function () {
@@ -4410,7 +4176,7 @@
4410
4176
  onFailure("sourcemap file not found at ".concat(sourcemapUrl));
4411
4177
  } else {
4412
4178
  var _temp2 = "unexpected response for sourcemap file.";
4413
- return _await$4(sourcemapResponse.text(), function (_sourcemapResponse$te) {
4179
+ return _await$5(sourcemapResponse.text(), function (_sourcemapResponse$te) {
4414
4180
  var _createDetailedMessag3;
4415
4181
 
4416
4182
  onFailure(createDetailedMessage(_temp2, (_createDetailedMessag3 = {}, _defineProperty(_createDetailedMessag3, "response status", status), _defineProperty(_createDetailedMessag3, "response text", _sourcemapResponse$te), _defineProperty(_createDetailedMessag3, "sourcemap url", sourcemapUrl), _createDetailedMessag3)));
@@ -4422,7 +4188,7 @@
4422
4188
  });
4423
4189
  }
4424
4190
  }, function (_result3) {
4425
- return _exit3 ? _result3 : _await$4(sourcemapResponse.text(), function (_sourcemapResponse$te2) {
4191
+ return _exit3 ? _result3 : _await$5(sourcemapResponse.text(), function (_sourcemapResponse$te2) {
4426
4192
  sourcemapString = _sourcemapResponse$te2;
4427
4193
  });
4428
4194
  });
@@ -4457,13 +4223,13 @@
4457
4223
  }
4458
4224
 
4459
4225
  var firstSourceMapSourceFailure = null;
4460
- return _await$4(Promise.all(sourceMap.sources.map(_async$4(function (source, index) {
4226
+ return _await$5(Promise.all(sourceMap.sources.map(_async$5(function (source, index) {
4461
4227
  if (index in sourcesContent) return;
4462
4228
  var sourcemapSourceUrl = resolveFile(source, sourcemapUrl, {
4463
4229
  type: "source"
4464
4230
  });
4465
4231
  return _catch$2(function () {
4466
- return _await$4(fetchFile(sourcemapSourceUrl), function (sourceResponse) {
4232
+ return _await$5(fetchFile(sourcemapSourceUrl), function (sourceResponse) {
4467
4233
  var _exit4 = false;
4468
4234
  var status = sourceResponse.status;
4469
4235
  return _invoke$2(function () {
@@ -4482,7 +4248,7 @@
4482
4248
  }
4483
4249
 
4484
4250
  var _temp4 = "unexpected response for sourcemap source.";
4485
- return _await$4(sourceResponse.text(), function (_sourceResponse$text) {
4251
+ return _await$5(sourceResponse.text(), function (_sourceResponse$text) {
4486
4252
  var _createDetailedMessag7;
4487
4253
 
4488
4254
  firstSourceMapSourceFailure = createDetailedMessage(_temp4, (_createDetailedMessag7 = {}, _defineProperty(_createDetailedMessag7, "response status", status), _defineProperty(_createDetailedMessag7, "response text", _sourceResponse$text), _defineProperty(_createDetailedMessag7, "sourcemap source url", sourcemapSourceUrl), _defineProperty(_createDetailedMessag7, "sourcemap url", sourcemapUrl), _createDetailedMessag7));
@@ -4490,7 +4256,7 @@
4490
4256
  });
4491
4257
  }
4492
4258
  }, function (_result6) {
4493
- return _exit4 ? _result6 : _await$4(sourceResponse.text(), function (sourceString) {
4259
+ return _exit4 ? _result6 : _await$5(sourceResponse.text(), function (sourceString) {
4494
4260
  sourcesContent[index] = sourceString;
4495
4261
  });
4496
4262
  });
@@ -4538,7 +4304,7 @@
4538
4304
  };
4539
4305
  };
4540
4306
 
4541
- function _await$3(value, then, direct) {
4307
+ function _await$4(value, then, direct) {
4542
4308
  if (direct) {
4543
4309
  return then ? then(value) : value;
4544
4310
  }
@@ -4574,7 +4340,7 @@
4574
4340
  return then(result);
4575
4341
  }
4576
4342
 
4577
- function _async$3(f) {
4343
+ function _async$4(f) {
4578
4344
  return function () {
4579
4345
  for (var args = [], i = 0; i < arguments.length; i++) {
4580
4346
  args[i] = arguments[i];
@@ -4663,7 +4429,7 @@
4663
4429
  });
4664
4430
  };
4665
4431
 
4666
- var getErrorOriginalStackString = _async$3(function (error) {
4432
+ var getErrorOriginalStackString = _async$4(function (error) {
4667
4433
  var _exit = false;
4668
4434
 
4669
4435
  var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
@@ -4688,7 +4454,7 @@
4688
4454
  return _invoke$1(function () {
4689
4455
  if (promise) {
4690
4456
  return _catch$1(function () {
4691
- return _await$3(promise, function (originalCallsites) {
4457
+ return _await$4(promise, function (originalCallsites) {
4692
4458
  errorRemapFailureCallbackMap.get(error);
4693
4459
  var firstCall = originalCallsites[0];
4694
4460
 
@@ -4728,7 +4494,7 @@
4728
4494
 
4729
4495
  var memoizeFetch = function memoizeFetch(fetchUrl) {
4730
4496
  var urlCache = {};
4731
- return _async$3(function (url) {
4497
+ return _async$4(function (url) {
4732
4498
  if (url in urlCache) {
4733
4499
  return urlCache[url];
4734
4500
  }
@@ -4739,7 +4505,7 @@
4739
4505
  });
4740
4506
  };
4741
4507
 
4742
- function _await$2(value, then, direct) {
4508
+ function _await$3(value, then, direct) {
4743
4509
  if (direct) {
4744
4510
  return then ? then(value) : value;
4745
4511
  }
@@ -4751,7 +4517,7 @@
4751
4517
  return then ? value.then(then) : value;
4752
4518
  }
4753
4519
 
4754
- function _async$2(f) {
4520
+ function _async$3(f) {
4755
4521
  return function () {
4756
4522
  for (var args = [], i = 0; i < arguments.length; i++) {
4757
4523
  args[i] = arguments[i];
@@ -4768,11 +4534,11 @@
4768
4534
  var installBrowserErrorStackRemapping = function installBrowserErrorStackRemapping() {
4769
4535
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4770
4536
  return installErrorStackRemapping(_objectSpread2({
4771
- fetchFile: _async$2(function (url) {
4537
+ fetchFile: _async$3(function (url) {
4772
4538
  // browser having Error.captureStackTrace got window.fetch
4773
4539
  // and this executes only when Error.captureStackTrace exists
4774
4540
  // so no need for polyfill or whatever here
4775
- return _await$2(window.fetch(url, {
4541
+ return _await$3(window.fetch(url, {
4776
4542
  // by default a script tag is in "no-cors"
4777
4543
  // so we also fetch url with "no-cors"
4778
4544
  mode: "no-cors"
@@ -4780,7 +4546,7 @@
4780
4546
  // we read response test before anything because once memoized fetch
4781
4547
  // gets annoying preventing you to read
4782
4548
  // body multiple times, even using response.clone()
4783
- return _await$2(response.text(), function (_text) {
4549
+ return _await$3(response.text(), function (_text) {
4784
4550
  return {
4785
4551
  status: response.status,
4786
4552
  url: response.url,
@@ -4813,7 +4579,7 @@
4813
4579
  return headers;
4814
4580
  };
4815
4581
 
4816
- function _await$1(value, then, direct) {
4582
+ function _await$2(value, then, direct) {
4817
4583
  if (direct) {
4818
4584
  return then ? then(value) : value;
4819
4585
  }
@@ -4825,7 +4591,7 @@
4825
4591
  return then ? value.then(then) : value;
4826
4592
  }
4827
4593
 
4828
- function _async$1(f) {
4594
+ function _async$2(f) {
4829
4595
  return function () {
4830
4596
  for (var args = [], i = 0; i < arguments.length; i++) {
4831
4597
  args[i] = arguments[i];
@@ -4839,16 +4605,16 @@
4839
4605
  };
4840
4606
  }
4841
4607
 
4842
- var fetchAndEvalUsingFetch = _async$1(function (url) {
4843
- return _await$1(fetchUrl(url), function (response) {
4608
+ var fetchAndEvalUsingFetch = _async$2(function (url) {
4609
+ return _await$2(fetchUrl(url), function (response) {
4844
4610
  return function () {
4845
4611
  if (response.status >= 200 && response.status <= 299) {
4846
- return _await$1(response.text(), function (text) {
4612
+ return _await$2(response.text(), function (text) {
4847
4613
  // eslint-disable-next-line no-eval
4848
4614
  window.eval(appendSourceURL(text, url));
4849
4615
  });
4850
4616
  } else {
4851
- return _await$1(response.text(), function (text) {
4617
+ return _await$2(response.text(), function (text) {
4852
4618
  var _createDetailedMessag;
4853
4619
 
4854
4620
  throw new Error(createDetailedMessage("Unexpected response for script.", (_createDetailedMessag = {}, _defineProperty(_createDetailedMessag, "script url", url), _defineProperty(_createDetailedMessag, "response body", text), _defineProperty(_createDetailedMessag, "response status", response.status), _createDetailedMessag)));
@@ -4862,6 +4628,232 @@
4862
4628
  return "".concat(code, "\n", "//#", " sourceURL=").concat(sourceURL);
4863
4629
  };
4864
4630
 
4631
+ /* eslint-env browser */
4632
+ var displayErrorInDocument = function displayErrorInDocument(error) {
4633
+ var title = "An error occured";
4634
+ var theme;
4635
+ var message;
4636
+
4637
+ if (error && error.parsingError) {
4638
+ theme = "light";
4639
+ var parsingError = error.parsingError;
4640
+ message = errorToHTML(parsingError.messageHTML || escapeHtml(parsingError.message));
4641
+ } else {
4642
+ theme = "dark";
4643
+ message = errorToHTML(error);
4644
+ }
4645
+
4646
+ var css = "\n .jsenv-console {\n background: rgba(0, 0, 0, 0.95);\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n z-index: 1000;\n box-sizing: border-box;\n padding: 1em;\n }\n\n .jsenv-console h1 {\n color: red;\n display: flex;\n align-items: center;\n }\n\n #button-close-jsenv-console {\n margin-left: 10px;\n }\n\n .jsenv-console pre {\n overflow: auto;\n max-width: 70em;\n /* avoid scrollbar to hide the text behind it */\n padding: 20px;\n }\n\n .jsenv-console pre[data-theme=\"dark\"] {\n background: #111;\n border: 1px solid #333;\n color: #eee;\n }\n\n .jsenv-console pre[data-theme=\"light\"] {\n background: #1E1E1E;\n border: 1px solid white;\n color: #EEEEEE;\n }\n\n .jsenv-console pre a {\n color: inherit;\n }\n ";
4647
+ var html = "\n <style type=\"text/css\">".concat(css, "></style>\n <div class=\"jsenv-console\">\n <h1>").concat(title, " <button id=\"button-close-jsenv-console\">X</button></h1>\n <pre data-theme=\"").concat(theme, "\">").concat(message, "</pre>\n </div>\n ");
4648
+ var removeJsenvConsole = appendHMTLInside(html, document.body);
4649
+
4650
+ document.querySelector("#button-close-jsenv-console").onclick = function () {
4651
+ removeJsenvConsole();
4652
+ };
4653
+ };
4654
+
4655
+ var escapeHtml = function escapeHtml(string) {
4656
+ return string.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
4657
+ };
4658
+
4659
+ var errorToHTML = function errorToHTML(error) {
4660
+ var html;
4661
+
4662
+ if (error && error instanceof Error) {
4663
+ // stackTrace formatted by V8
4664
+ if (Error.captureStackTrace) {
4665
+ html = escapeHtml(error.stack);
4666
+ } else {
4667
+ // other stack trace such as firefox do not contain error.message
4668
+ html = escapeHtml("".concat(error.message, "\n ").concat(error.stack));
4669
+ }
4670
+ } else if (typeof error === "string") {
4671
+ html = error;
4672
+ } else {
4673
+ html = JSON.stringify(error);
4674
+ }
4675
+
4676
+ var htmlWithCorrectLineBreaks = html.replace(/\n/g, "\n");
4677
+ var htmlWithLinks = stringToStringWithLink(htmlWithCorrectLineBreaks, {
4678
+ transform: function transform(url) {
4679
+ return {
4680
+ href: url,
4681
+ text: url
4682
+ };
4683
+ }
4684
+ });
4685
+ return htmlWithLinks;
4686
+ }; // `Error: yo
4687
+ // at Object.execute (http://127.0.0.1:57300/build/src/__test__/file-throw.js:9:13)
4688
+ // at doExec (http://127.0.0.1:3000/src/__test__/file-throw.js:452:38)
4689
+ // at postOrderExec (http://127.0.0.1:3000/src/__test__/file-throw.js:448:16)
4690
+ // at http://127.0.0.1:3000/src/__test__/file-throw.js:399:18`.replace(/(?:https?|ftp|file):\/\/(.*+)$/gm, (...args) => {
4691
+ // debugger
4692
+ // })
4693
+
4694
+
4695
+ var stringToStringWithLink = function stringToStringWithLink(source) {
4696
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
4697
+ _ref$transform = _ref.transform,
4698
+ transform = _ref$transform === void 0 ? function (url) {
4699
+ return {
4700
+ href: url,
4701
+ text: url
4702
+ };
4703
+ } : _ref$transform;
4704
+
4705
+ return source.replace(/(?:https?|ftp|file):\/\/\S+/gm, function (match) {
4706
+ var linkHTML = "";
4707
+ var lastChar = match[match.length - 1]; // hotfix because our url regex sucks a bit
4708
+
4709
+ var endsWithSeparationChar = lastChar === ")" || lastChar === ":";
4710
+
4711
+ if (endsWithSeparationChar) {
4712
+ match = match.slice(0, -1);
4713
+ }
4714
+
4715
+ var lineAndColumnPattern = /:([0-9]+):([0-9]+)$/;
4716
+ var lineAndColumMatch = match.match(lineAndColumnPattern);
4717
+
4718
+ if (lineAndColumMatch) {
4719
+ var lineAndColumnString = lineAndColumMatch[0];
4720
+ var lineNumber = lineAndColumMatch[1];
4721
+ var columnNumber = lineAndColumMatch[2];
4722
+ var url = match.slice(0, -lineAndColumnString.length);
4723
+
4724
+ var _transform = transform(url),
4725
+ href = _transform.href,
4726
+ text = _transform.text;
4727
+
4728
+ linkHTML = link({
4729
+ href: href,
4730
+ text: "".concat(text, ":").concat(lineNumber, ":").concat(columnNumber)
4731
+ });
4732
+ } else {
4733
+ var linePattern = /:([0-9]+)$/;
4734
+ var lineMatch = match.match(linePattern);
4735
+
4736
+ if (lineMatch) {
4737
+ var lineString = lineMatch[0];
4738
+ var _lineNumber = lineMatch[1];
4739
+
4740
+ var _url = match.slice(0, -lineString.length);
4741
+
4742
+ var _transform2 = transform(_url),
4743
+ _href = _transform2.href,
4744
+ _text = _transform2.text;
4745
+
4746
+ linkHTML = link({
4747
+ href: _href,
4748
+ text: "".concat(_text, ":").concat(_lineNumber)
4749
+ });
4750
+ } else {
4751
+ var _url2 = match;
4752
+
4753
+ var _transform3 = transform(_url2),
4754
+ _href2 = _transform3.href,
4755
+ _text2 = _transform3.text;
4756
+
4757
+ linkHTML = link({
4758
+ href: _href2,
4759
+ text: _text2
4760
+ });
4761
+ }
4762
+ }
4763
+
4764
+ if (endsWithSeparationChar) {
4765
+ return "".concat(linkHTML).concat(lastChar);
4766
+ }
4767
+
4768
+ return linkHTML;
4769
+ });
4770
+ };
4771
+
4772
+ var link = function link(_ref2) {
4773
+ var href = _ref2.href,
4774
+ _ref2$text = _ref2.text,
4775
+ text = _ref2$text === void 0 ? href : _ref2$text;
4776
+ return "<a href=\"".concat(href, "\">").concat(text, "</a>");
4777
+ };
4778
+
4779
+ var appendHMTLInside = function appendHMTLInside(html, parentNode) {
4780
+ var temoraryParent = document.createElement("div");
4781
+ temoraryParent.innerHTML = html;
4782
+ return transferChildren(temoraryParent, parentNode);
4783
+ };
4784
+
4785
+ var transferChildren = function transferChildren(fromNode, toNode) {
4786
+ var childNodes = [].slice.call(fromNode.childNodes, 0);
4787
+ var i = 0;
4788
+
4789
+ while (i < childNodes.length) {
4790
+ toNode.appendChild(childNodes[i]);
4791
+ i++;
4792
+ }
4793
+
4794
+ return function () {
4795
+ var c = 0;
4796
+
4797
+ while (c < childNodes.length) {
4798
+ fromNode.appendChild(childNodes[c]);
4799
+ c++;
4800
+ }
4801
+ };
4802
+ };
4803
+
4804
+ function _await$1(value, then, direct) {
4805
+ if (direct) {
4806
+ return then ? then(value) : value;
4807
+ }
4808
+
4809
+ if (!value || !value.then) {
4810
+ value = Promise.resolve(value);
4811
+ }
4812
+
4813
+ return then ? value.then(then) : value;
4814
+ }
4815
+
4816
+ /* eslint-env browser */
4817
+ var _window = window,
4818
+ Notification = _window.Notification;
4819
+
4820
+ function _async$1(f) {
4821
+ return function () {
4822
+ for (var args = [], i = 0; i < arguments.length; i++) {
4823
+ args[i] = arguments[i];
4824
+ }
4825
+
4826
+ try {
4827
+ return Promise.resolve(f.apply(this, args));
4828
+ } catch (e) {
4829
+ return Promise.reject(e);
4830
+ }
4831
+ };
4832
+ }
4833
+
4834
+ var displayErrorNotificationNotAvailable = function displayErrorNotificationNotAvailable() {};
4835
+
4836
+ var displayErrorNotificationImplementation = _async$1(function (error) {
4837
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
4838
+ icon = _ref.icon;
4839
+
4840
+ return _await$1(Notification.requestPermission(), function (permission) {
4841
+ if (permission === "granted") {
4842
+ var notification = new Notification("An error occured", {
4843
+ lang: "en",
4844
+ body: error.stack,
4845
+ icon: icon
4846
+ });
4847
+
4848
+ notification.onclick = function () {
4849
+ window.focus();
4850
+ };
4851
+ }
4852
+ });
4853
+ });
4854
+
4855
+ var displayErrorNotification = typeof Notification === "function" ? displayErrorNotificationImplementation : displayErrorNotificationNotAvailable;
4856
+
4865
4857
  function _await(value, then, direct) {
4866
4858
  if (direct) {
4867
4859
  return then ? then(value) : value;
@@ -4995,7 +4987,8 @@
4995
4987
  performance.measure("jsenv_file_import", "jsenv_file_import_start");
4996
4988
  var executionResult = {
4997
4989
  status: "completed",
4998
- namespace: namespace
4990
+ namespace: namespace,
4991
+ coverage: readCoverage()
4999
4992
  };
5000
4993
  return executionResult;
5001
4994
  });
@@ -5003,7 +4996,8 @@
5003
4996
  performance.measure("jsenv_file_import", "jsenv_file_import_start");
5004
4997
  var executionResult = {
5005
4998
  status: "errored",
5006
- exceptionSource: unevalException(e)
4999
+ error: e,
5000
+ coverage: readCoverage()
5007
5001
  };
5008
5002
  onExecutionError(executionResult, {
5009
5003
  currentScript: currentScript
@@ -5045,17 +5039,22 @@
5045
5039
  };
5046
5040
 
5047
5041
  var onExecutionError = function onExecutionError(executionResult, _ref) {
5048
- var currentScript = _ref.currentScript;
5049
- // eslint-disable-next-line no-eval
5050
- var originalError = window.eval(executionResult.exceptionSource);
5051
-
5052
- if (originalError.code === "NETWORK_FAILURE") {
5042
+ var currentScript = _ref.currentScript,
5043
+ _ref$errorExposureInC = _ref.errorExposureInConsole,
5044
+ errorExposureInConsole = _ref$errorExposureInC === void 0 ? true : _ref$errorExposureInC,
5045
+ _ref$errorExposureInN = _ref.errorExposureInNotification,
5046
+ errorExposureInNotification = _ref$errorExposureInN === void 0 ? false : _ref$errorExposureInN,
5047
+ _ref$errorExposureInD = _ref.errorExposureInDocument,
5048
+ errorExposureInDocument = _ref$errorExposureInD === void 0 ? true : _ref$errorExposureInD;
5049
+ var error = executionResult.error;
5050
+
5051
+ if (error.code === "NETWORK_FAILURE") {
5053
5052
  if (currentScript) {
5054
5053
  var errorEvent = new Event("error");
5055
5054
  currentScript.dispatchEvent(errorEvent);
5056
5055
  }
5057
5056
  } else {
5058
- var parsingError = originalError.parsingError;
5057
+ var parsingError = error.parsingError;
5059
5058
  var globalErrorEvent = new Event("error");
5060
5059
 
5061
5060
  if (parsingError) {
@@ -5064,14 +5063,29 @@
5064
5063
  globalErrorEvent.message = parsingError.message;
5065
5064
  globalErrorEvent.colno = parsingError.columnNumber;
5066
5065
  } else {
5067
- globalErrorEvent.filename = originalError.filename;
5068
- globalErrorEvent.lineno = originalError.lineno;
5069
- globalErrorEvent.message = originalError.message;
5070
- globalErrorEvent.colno = originalError.columnno;
5066
+ globalErrorEvent.filename = error.filename;
5067
+ globalErrorEvent.lineno = error.lineno;
5068
+ globalErrorEvent.message = error.message;
5069
+ globalErrorEvent.colno = error.columnno;
5071
5070
  }
5072
5071
 
5073
5072
  window.dispatchEvent(globalErrorEvent);
5074
5073
  }
5074
+
5075
+ if (errorExposureInConsole) {
5076
+ console.error(error);
5077
+ }
5078
+
5079
+ if (errorExposureInNotification) {
5080
+ displayErrorNotification(error);
5081
+ }
5082
+
5083
+ if (errorExposureInDocument) {
5084
+ displayErrorInDocument(error);
5085
+ }
5086
+
5087
+ executionResult.exceptionSource = unevalException(error);
5088
+ delete executionResult.error;
5075
5089
  };
5076
5090
 
5077
5091
  var getBrowserRuntime = memoize(_async(function () {
@@ -5129,6 +5143,11 @@
5129
5143
  });
5130
5144
  }));
5131
5145
  var livereloadingCallbacks = {};
5146
+
5147
+ var readCoverage = function readCoverage() {
5148
+ return window.__coverage__;
5149
+ };
5150
+
5132
5151
  window.__jsenv__ = {
5133
5152
  livereloadingCallbacks: livereloadingCallbacks,
5134
5153
  executionResultPromise: executionResultPromise,