solid-ui 3.0.4-729805d → 3.0.4-7c010e4

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/solid-ui.js CHANGED
@@ -9522,6 +9522,13 @@ var _solidLogicSingleton$2 = external_SolidLogic_.solidLogicSingleton.typeIndex,
9522
9522
  loadAllTypeIndexes = _solidLogicSingleton$2.loadAllTypeIndexes,
9523
9523
  getScopedAppsFromIndex = _solidLogicSingleton$2.getScopedAppsFromIndex,
9524
9524
  deleteTypeIndexRegistration = _solidLogicSingleton$2.deleteTypeIndexRegistration;
9525
+ function formatDynamicError(error, contextLabel) {
9526
+ var e = error;
9527
+ var name = (e === null || e === void 0 ? void 0 : e.name) || 'Error';
9528
+ var status = typeof (e === null || e === void 0 ? void 0 : e.status) === 'number' ? " (HTTP ".concat(e.status, ")") : '';
9529
+ var message = e !== null && e !== void 0 && e.message ? String(e.message) : typeof error === 'string' ? error : 'No additional details provided';
9530
+ return "".concat(contextLabel, ": ").concat(name).concat(status, " - ").concat(message);
9531
+ }
9525
9532
 
9526
9533
  /**
9527
9534
  * Resolves with the logged in user's WebID
@@ -9592,78 +9599,100 @@ function _ensureLoadedPreferences() {
9592
9599
  return ensureLoadedProfile(context);
9593
9600
  case 2:
9594
9601
  context = _context4.sent;
9595
- _context4.next = 3;
9596
- return loadPreferences(context.me);
9602
+ if (context.me) {
9603
+ _context4.next = 3;
9604
+ break;
9605
+ }
9606
+ context.preferencesFileError = 'Not logged in, so preferences were not loaded.';
9607
+ return _context4.abrupt("return", context);
9597
9608
  case 3:
9609
+ _context4.next = 4;
9610
+ return loadPreferences(context.me);
9611
+ case 4:
9598
9612
  preferencesFile = _context4.sent;
9599
9613
  if (progressDisplay) {
9600
9614
  progressDisplay.parentNode.removeChild(progressDisplay);
9601
9615
  }
9602
9616
  context.preferencesFile = preferencesFile;
9603
- _context4.next = 11;
9617
+ _context4.next = 13;
9604
9618
  break;
9605
- case 4:
9606
- _context4.prev = 4;
9619
+ case 5:
9620
+ _context4.prev = 5;
9607
9621
  _t4 = _context4["catch"](1);
9608
9622
  if (!(_t4 instanceof external_SolidLogic_.UnauthorizedError)) {
9609
- _context4.next = 5;
9610
- break;
9611
- }
9612
- m2 = 'Oops — you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.';
9613
- log_alert(m2);
9614
- _context4.next = 11;
9615
- break;
9616
- case 5:
9617
- if (!(_t4 instanceof external_SolidLogic_.CrossOriginForbiddenError)) {
9618
9623
  _context4.next = 6;
9619
9624
  break;
9620
9625
  }
9621
- m2 = "Unauthorized: Assuming preference file blocked for origin ".concat(window.location.origin);
9626
+ m2 = 'Oops you are not authenticated (properly logged in), so SolidOS cannot read your preferences file. Try logging out and then logging back in.';
9622
9627
  context.preferencesFileError = m2;
9628
+ log_alert(m2);
9623
9629
  return _context4.abrupt("return", context);
9624
9630
  case 6:
9625
- if (!(_t4 instanceof external_SolidLogic_.SameOriginForbiddenError)) {
9631
+ if (!(_t4 instanceof external_SolidLogic_.CrossOriginForbiddenError)) {
9626
9632
  _context4.next = 7;
9627
9633
  break;
9628
9634
  }
9629
- m2 = 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.';
9630
- src_debug/* warn */.R8(m2);
9635
+ m2 = "Unauthorized: preference file request was blocked for origin ".concat(window.location.origin, ".");
9636
+ context.preferencesFileError = m2;
9631
9637
  return _context4.abrupt("return", context);
9632
9638
  case 7:
9633
- if (!(_t4 instanceof external_SolidLogic_.NotEditableError)) {
9639
+ if (!(_t4 instanceof external_SolidLogic_.SameOriginForbiddenError)) {
9634
9640
  _context4.next = 8;
9635
9641
  break;
9636
9642
  }
9637
- m2 = 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
9643
+ m2 = 'You are not authorized to read your preference file from this app context.';
9644
+ context.preferencesFileError = m2;
9638
9645
  src_debug/* warn */.R8(m2);
9639
9646
  return _context4.abrupt("return", context);
9640
9647
  case 8:
9641
- if (!(_t4 instanceof external_SolidLogic_.WebOperationError)) {
9648
+ if (!(_t4 instanceof external_SolidLogic_.NotEditableError)) {
9642
9649
  _context4.next = 9;
9643
9650
  break;
9644
9651
  }
9645
- m2 = 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
9652
+ m2 = 'You are not authorized to edit your preference file from this app context.';
9653
+ context.preferencesFileError = m2;
9646
9654
  src_debug/* warn */.R8(m2);
9647
- _context4.next = 11;
9648
- break;
9655
+ return _context4.abrupt("return", context);
9649
9656
  case 9:
9650
- if (!(_t4 instanceof external_SolidLogic_.FetchError)) {
9657
+ if (!(_t4 instanceof external_SolidLogic_.WebOperationError)) {
9651
9658
  _context4.next = 10;
9652
9659
  break;
9653
9660
  }
9654
- m2 = "Strange: Error ".concat(_t4.status, " trying to read your preference file.").concat(_t4.message);
9655
- log_alert(m2);
9656
- _context4.next = 11;
9657
- break;
9661
+ m2 = formatDynamicError(_t4, 'Preference file web operation failed');
9662
+ context.preferencesFileError = m2;
9663
+ src_debug/* warn */.R8(m2);
9664
+ return _context4.abrupt("return", context);
9658
9665
  case 10:
9659
- throw new Error("(via loadPrefs) ".concat(_t4));
9666
+ if (!(_t4 instanceof external_SolidLogic_.FetchError)) {
9667
+ _context4.next = 12;
9668
+ break;
9669
+ }
9670
+ if (!(_t4.status === 404)) {
9671
+ _context4.next = 11;
9672
+ break;
9673
+ }
9674
+ m2 = 'Your preferences file was not found (404). It may not exist yet.';
9675
+ context.preferencesFileError = m2;
9676
+ src_debug/* warn */.R8(m2);
9677
+ return _context4.abrupt("return", context);
9660
9678
  case 11:
9679
+ m2 = formatDynamicError(_t4, 'Error reading your preferences file');
9680
+ context.preferencesFileError = m2;
9681
+ src_debug/* warn */.R8(m2);
9682
+ log_alert(m2);
9661
9683
  return _context4.abrupt("return", context);
9662
9684
  case 12:
9685
+ m2 = formatDynamicError(_t4, 'Unexpected error while loading preferences');
9686
+ context.preferencesFileError = m2;
9687
+ src_debug/* error */.z3(m2);
9688
+ return _context4.abrupt("return", context);
9689
+ case 13:
9690
+ return _context4.abrupt("return", context);
9691
+ case 14:
9663
9692
  case "end":
9664
9693
  return _context4.stop();
9665
9694
  }
9666
- }, _callee4, null, [[1, 4]]);
9695
+ }, _callee4, null, [[1, 5]]);
9667
9696
  }));
9668
9697
  return _ensureLoadedPreferences.apply(this, arguments);
9669
9698
  }
@@ -9678,7 +9707,7 @@ function ensureLoadedProfile(_x2) {
9678
9707
  */
9679
9708
  function _ensureLoadedProfile() {
9680
9709
  _ensureLoadedProfile = asyncToGenerator_asyncToGenerator(/*#__PURE__*/regenerator_default().mark(function _callee5(context) {
9681
- var logInContext, _t5;
9710
+ var logInContext, message, _message, _t5;
9682
9711
  return regenerator_default().wrap(function (_context5) {
9683
9712
  while (1) switch (_context5.prev = _context5.next) {
9684
9713
  case 0:
@@ -9697,7 +9726,9 @@ function _ensureLoadedProfile() {
9697
9726
  _context5.next = 3;
9698
9727
  break;
9699
9728
  }
9700
- throw new Error('Could not log in');
9729
+ message = 'Could not log in; skipping profile load.';
9730
+ src_debug/* log */.Rm(message);
9731
+ return _context5.abrupt("return", context);
9701
9732
  case 3:
9702
9733
  _context5.next = 4;
9703
9734
  return loadProfile(logInContext.me);
@@ -9708,10 +9739,11 @@ function _ensureLoadedProfile() {
9708
9739
  case 5:
9709
9740
  _context5.prev = 5;
9710
9741
  _t5 = _context5["catch"](1);
9742
+ _message = formatDynamicError(_t5, 'Unable to load your profile');
9711
9743
  if (context.div && context.dom) {
9712
- context.div.appendChild(errorMessageBlock(context.dom, _t5.message));
9744
+ context.div.appendChild(errorMessageBlock(context.dom, _message));
9713
9745
  }
9714
- throw new Error("Can't log in: ".concat(_t5));
9746
+ throw new Error(_message);
9715
9747
  case 6:
9716
9748
  return _context5.abrupt("return", context);
9717
9749
  case 7:
@@ -10633,7 +10665,7 @@ function getUserRoles() {
10633
10665
  */
10634
10666
  function _getUserRoles() {
10635
10667
  _getUserRoles = asyncToGenerator_asyncToGenerator(/*#__PURE__*/regenerator_default().mark(function _callee0() {
10636
- var _yield$ensureLoadedPr, me, preferencesFile, preferencesFileError, _t0;
10668
+ var _yield$ensureLoadedPr, me, preferencesFile, preferencesFileError, authState, _t0;
10637
10669
  return regenerator_default().wrap(function (_context1) {
10638
10670
  while (1) switch (_context1.prev = _context1.next) {
10639
10671
  case 0:
@@ -10645,23 +10677,30 @@ function _getUserRoles() {
10645
10677
  me = _yield$ensureLoadedPr.me;
10646
10678
  preferencesFile = _yield$ensureLoadedPr.preferencesFile;
10647
10679
  preferencesFileError = _yield$ensureLoadedPr.preferencesFileError;
10648
- if (!(!preferencesFile || preferencesFileError)) {
10680
+ if (!preferencesFileError) {
10649
10681
  _context1.next = 2;
10650
10682
  break;
10651
10683
  }
10652
10684
  throw new Error(preferencesFileError);
10653
10685
  case 2:
10654
- return _context1.abrupt("return", external_SolidLogic_.solidLogicSingleton.store.each(me, src_ns.rdf('type'), null, preferencesFile.doc()));
10686
+ if (preferencesFile) {
10687
+ _context1.next = 3;
10688
+ break;
10689
+ }
10690
+ authState = me ? "logged in as ".concat(me.value || me.uri) : 'not logged in';
10691
+ throw new Error("Preferences file unavailable (".concat(authState, ")"));
10655
10692
  case 3:
10656
- _context1.prev = 3;
10693
+ return _context1.abrupt("return", external_SolidLogic_.solidLogicSingleton.store.each(me, src_ns.rdf('type'), null, preferencesFile.doc()));
10694
+ case 4:
10695
+ _context1.prev = 4;
10657
10696
  _t0 = _context1["catch"](0);
10658
- src_debug/* warn */.R8('Unable to fetch your preferences - this was the error: ', _t0);
10697
+ src_debug/* warn */.R8(formatDynamicError(_t0, 'Unable to fetch your preferences'));
10659
10698
  return _context1.abrupt("return", []);
10660
- case 4:
10699
+ case 5:
10661
10700
  case "end":
10662
10701
  return _context1.stop();
10663
10702
  }
10664
- }, _callee0, null, [[0, 3]]);
10703
+ }, _callee0, null, [[0, 4]]);
10665
10704
  }));
10666
10705
  return _getUserRoles.apply(this, arguments);
10667
10706
  }