solid-panes 3.5.11 → 3.5.14

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,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -428,23 +428,23 @@ function _default(context) {
428
428
  }
429
429
 
430
430
  function _getDashboardItems() {
431
- _getDashboardItems = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
431
+ _getDashboardItems = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
432
432
  var me, div, _yield$Promise$all, _yield$Promise$all2, books, pods, getPods, _getPods, getAddressBooks, _getAddressBooks;
433
433
 
434
- return regeneratorRuntime.wrap(function _callee7$(_context8) {
434
+ return regeneratorRuntime.wrap(function _callee6$(_context7) {
435
435
  while (1) {
436
- switch (_context8.prev = _context8.next) {
436
+ switch (_context7.prev = _context7.next) {
437
437
  case 0:
438
438
  _getAddressBooks = function _getAddressBooks3() {
439
- _getAddressBooks = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
440
- var _context6;
439
+ _getAddressBooks = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
440
+ var _context5;
441
441
 
442
- return regeneratorRuntime.wrap(function _callee6$(_context7) {
442
+ return regeneratorRuntime.wrap(function _callee5$(_context6) {
443
443
  while (1) {
444
- switch (_context7.prev = _context7.next) {
444
+ switch (_context6.prev = _context6.next) {
445
445
  case 0:
446
- _context7.prev = 0;
447
- _context7.next = 3;
446
+ _context6.prev = 0;
447
+ _context6.next = 3;
448
448
  return UI.authn.findAppInstances({
449
449
  me: me,
450
450
  div: div,
@@ -452,8 +452,8 @@ function _default(context) {
452
452
  }, ns.vcard('AddressBook'));
453
453
 
454
454
  case 3:
455
- _context6 = _context7.sent;
456
- return _context7.abrupt("return", (_context6.instances || []).map(function (book, index) {
455
+ _context5 = _context6.sent;
456
+ return _context6.abrupt("return", (_context5.instances || []).map(function (book, index) {
457
457
  return {
458
458
  paneName: 'contact',
459
459
  tabName: "contact-".concat(index),
@@ -464,19 +464,19 @@ function _default(context) {
464
464
  }));
465
465
 
466
466
  case 7:
467
- _context7.prev = 7;
468
- _context7.t0 = _context7["catch"](0);
467
+ _context6.prev = 7;
468
+ _context6.t0 = _context6["catch"](0);
469
469
  console.error('oops in globalAppTabs AddressBook');
470
470
 
471
471
  case 10:
472
- return _context7.abrupt("return", []);
472
+ return _context6.abrupt("return", []);
473
473
 
474
474
  case 11:
475
475
  case "end":
476
- return _context7.stop();
476
+ return _context6.stop();
477
477
  }
478
478
  }
479
- }, _callee6, null, [[0, 7]]);
479
+ }, _callee5, null, [[0, 7]]);
480
480
  }));
481
481
  return _getAddressBooks.apply(this, arguments);
482
482
  };
@@ -486,183 +486,147 @@ function _default(context) {
486
486
  };
487
487
 
488
488
  _getPods = function _getPods3() {
489
- _getPods = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
490
- var addPodRoot, _addPodRoot, addPodRootFromUrl, _addPodRootFromUrl, pods;
489
+ _getPods = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
490
+ var addPodRoot, _addPodRoot, addPodRootFromUrl, _addPodRootFromUrl, pods, uri, podUrl;
491
491
 
492
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
492
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
493
493
  while (1) {
494
- switch (_context5.prev = _context5.next) {
494
+ switch (_context4.prev = _context4.next) {
495
495
  case 0:
496
496
  _addPodRootFromUrl = function _addPodRootFromUrl3() {
497
- _addPodRootFromUrl = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(url) {
497
+ _addPodRootFromUrl = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(url) {
498
498
  var podStorage;
499
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
499
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
500
500
  while (1) {
501
- switch (_context4.prev = _context4.next) {
501
+ switch (_context3.prev = _context3.next) {
502
502
  case 0:
503
503
  podStorage = new URL(url); // check that origin is not included in pods array
504
504
 
505
505
  if (pods.some(function (pod) {
506
506
  return pod.uri.includes(podStorage.origin);
507
507
  })) {
508
- _context4.next = 10;
508
+ _context3.next = 10;
509
509
  break;
510
510
  }
511
511
 
512
- _context4.t0 = podStorage.pathname === '/';
512
+ _context3.t0 = podStorage.pathname === '/';
513
513
 
514
- if (_context4.t0) {
515
- _context4.next = 7;
514
+ if (_context3.t0) {
515
+ _context3.next = 7;
516
516
  break;
517
517
  }
518
518
 
519
- _context4.next = 6;
519
+ _context3.next = 6;
520
520
  return addPodRoot(kb.sym("".concat(podStorage.origin, "/").concat(podStorage.pathname.split('/')[1], "/")));
521
521
 
522
522
  case 6:
523
- _context4.t0 = !_context4.sent;
523
+ _context3.t0 = !_context3.sent;
524
524
 
525
525
  case 7:
526
- if (!_context4.t0) {
527
- _context4.next = 10;
526
+ if (!_context3.t0) {
527
+ _context3.next = 10;
528
528
  break;
529
529
  }
530
530
 
531
- _context4.next = 10;
531
+ _context3.next = 10;
532
532
  return addPodRoot(kb.sym("".concat(podStorage.origin, "/")));
533
533
 
534
534
  case 10:
535
535
  case "end":
536
- return _context4.stop();
536
+ return _context3.stop();
537
537
  }
538
538
  }
539
- }, _callee4);
539
+ }, _callee3);
540
540
  }));
541
541
  return _addPodRootFromUrl.apply(this, arguments);
542
542
  };
543
543
 
544
- addPodRootFromUrl = function _addPodRootFromUrl2(_x7) {
544
+ addPodRootFromUrl = function _addPodRootFromUrl2(_x8) {
545
545
  return _addPodRootFromUrl.apply(this, arguments);
546
546
  };
547
547
 
548
548
  _addPodRoot = function _addPodRoot3() {
549
- _addPodRoot = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(pod) {
550
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
549
+ _addPodRoot = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(pod) {
550
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
551
551
  while (1) {
552
- switch (_context3.prev = _context3.next) {
552
+ switch (_context2.prev = _context2.next) {
553
553
  case 0:
554
- _context3.next = 2;
555
- return kb.fetcher.load(pod, {
556
- headers: {
557
- accept: 'text/turtle'
558
- }
559
- });
554
+ _context2.next = 2;
555
+ return checkForContainerRepresentation(pod);
560
556
 
561
557
  case 2:
562
558
  if (!kb.holds(pod, ns.rdf('type'), ns.space('Storage'), pod.doc())) {
563
- _context3.next = 5;
559
+ _context2.next = 5;
564
560
  break;
565
561
  }
566
562
 
567
563
  pods.push(pod);
568
- return _context3.abrupt("return", true);
564
+ return _context2.abrupt("return", true);
569
565
 
570
566
  case 5:
571
- return _context3.abrupt("return", false);
567
+ return _context2.abrupt("return", false);
572
568
 
573
569
  case 6:
574
570
  case "end":
575
- return _context3.stop();
571
+ return _context2.stop();
576
572
  }
577
573
  }
578
- }, _callee3);
574
+ }, _callee2);
579
575
  }));
580
576
  return _addPodRoot.apply(this, arguments);
581
577
  };
582
578
 
583
- addPodRoot = function _addPodRoot2(_x6) {
579
+ addPodRoot = function _addPodRoot2(_x7) {
584
580
  return _addPodRoot.apply(this, arguments);
585
581
  };
586
582
 
587
- _context5.prev = 4;
588
- _context5.next = 7;
583
+ _context4.prev = 4;
584
+ _context4.next = 7;
589
585
  return kb.fetcher.load(me.doc());
590
586
 
591
587
  case 7:
592
- _context5.next = 13;
588
+ _context4.next = 13;
593
589
  break;
594
590
 
595
591
  case 9:
596
- _context5.prev = 9;
597
- _context5.t0 = _context5["catch"](4);
598
- console.error('Unable to load profile', _context5.t0);
599
- return _context5.abrupt("return", []);
592
+ _context4.prev = 9;
593
+ _context4.t0 = _context4["catch"](4);
594
+ console.error('Unable to load profile', _context4.t0);
595
+ return _context4.abrupt("return", []);
600
596
 
601
597
  case 13:
602
598
  pods = kb.each(me, ns.space('storage'), null, me.doc());
603
- _context5.prev = 14;
604
-
605
- if (!pods.length) {
606
- _context5.next = 19;
607
- break;
608
- }
609
-
610
- // make sure container representation is loaded (when server returns index.html)
611
- // TODO reorder to have 'me' in first position
612
- pods.map( /*#__PURE__*/function () {
613
- var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(pod) {
614
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
615
- while (1) {
616
- switch (_context2.prev = _context2.next) {
617
- case 0:
618
- if (kb.any(pod, ns.ldp('contains'), undefined, pod.doc())) {
619
- _context2.next = 3;
620
- break;
621
- }
622
-
623
- _context2.next = 3;
624
- return kb.fetcher.load(pod, {
625
- headers: {
626
- accept: 'text/turtle'
627
- }
628
- });
629
-
630
- case 3:
631
- case "end":
632
- return _context2.stop();
633
- }
634
- }
635
- }, _callee2);
636
- }));
637
-
638
- return function (_x8) {
639
- return _ref.apply(this, arguments);
640
- };
641
- }());
642
- _context5.next = 21;
643
- break;
599
+ _context4.prev = 14;
600
+ // if uri then SolidOS is a browse.html web app
601
+ uri = new URL(window.location.href).searchParams.get('uri');
602
+ podUrl = uri || window.location.href;
603
+ _context4.next = 19;
604
+ return addPodRootFromUrl(podUrl.substring(0, podUrl.lastIndexOf('/') + 1));
644
605
 
645
606
  case 19:
646
- _context5.next = 21;
647
- return addPodRootFromUrl(me.uri);
607
+ _context4.next = 24;
608
+ break;
648
609
 
649
610
  case 21:
650
- _context5.next = 23;
651
- return addPodRootFromUrl(window.location.href.substring(0, window.location.href.lastIndexOf('/') + 1));
611
+ _context4.prev = 21;
612
+ _context4.t1 = _context4["catch"](14);
613
+ console.error('cannot load container', _context4.t1);
652
614
 
653
- case 23:
654
- _context5.next = 29;
655
- break;
615
+ case 24:
616
+ if (pods.length) {
617
+ _context4.next = 26;
618
+ break;
619
+ }
656
620
 
657
- case 25:
658
- _context5.prev = 25;
659
- _context5.t1 = _context5["catch"](14);
660
- console.error('cannot load container', _context5.t1);
661
- return _context5.abrupt("return", []);
621
+ return _context4.abrupt("return", []);
662
622
 
663
- case 29:
664
- return _context5.abrupt("return", pods.map(function (pod, index) {
665
- var label = pods.length > 1 ? pod.uri.split('//')[1].slice(0, -1) : 'Your storage';
623
+ case 26:
624
+ return _context4.abrupt("return", pods.map(function (pod, index) {
625
+ function split(item) {
626
+ return item.uri.split('//')[1].slice(0, -1);
627
+ }
628
+
629
+ var label = split(me).startsWith(split(pod)) ? 'Your storage' : split(pod);
666
630
  return {
667
631
  paneName: 'folder',
668
632
  tabName: "folder-".concat(index),
@@ -672,12 +636,12 @@ function _default(context) {
672
636
  };
673
637
  }));
674
638
 
675
- case 30:
639
+ case 27:
676
640
  case "end":
677
- return _context5.stop();
641
+ return _context4.stop();
678
642
  }
679
643
  }
680
- }, _callee5, null, [[4, 9], [14, 25]]);
644
+ }, _callee4, null, [[4, 9], [14, 21]]);
681
645
  }));
682
646
  return _getPods.apply(this, arguments);
683
647
  };
@@ -688,15 +652,15 @@ function _default(context) {
688
652
 
689
653
  me = UI.authn.currentUser();
690
654
  div = dom.createElement('div');
691
- _context8.next = 8;
655
+ _context7.next = 8;
692
656
  return Promise.all([getAddressBooks(), getPods()]);
693
657
 
694
658
  case 8:
695
- _yield$Promise$all = _context8.sent;
659
+ _yield$Promise$all = _context7.sent;
696
660
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
697
661
  books = _yield$Promise$all2[0];
698
662
  pods = _yield$Promise$all2[1];
699
- return _context8.abrupt("return", [{
663
+ return _context7.abrupt("return", [{
700
664
  paneName: 'home',
701
665
  label: 'Your stuff',
702
666
  icon: UI.icons.iconBase + 'noun_547570.svg'
@@ -712,10 +676,10 @@ function _default(context) {
712
676
 
713
677
  case 13:
714
678
  case "end":
715
- return _context8.stop();
679
+ return _context7.stop();
716
680
  }
717
681
  }
718
- }, _callee7);
682
+ }, _callee6);
719
683
  }));
720
684
  return _getDashboardItems.apply(this, arguments);
721
685
  }
@@ -734,68 +698,76 @@ function _default(context) {
734
698
  }
735
699
 
736
700
  function _showDashboard() {
737
- _showDashboard = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8() {
701
+ _showDashboard = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7() {
738
702
  var options,
739
703
  dashboardContainer,
740
704
  outlineContainer,
741
- tab,
705
+ _tab,
742
706
  dashboard,
707
+ tab,
743
708
  closeDashboard,
744
- _args8 = arguments;
745
- return regeneratorRuntime.wrap(function _callee8$(_context9) {
709
+ _args7 = arguments;
710
+
711
+ return regeneratorRuntime.wrap(function _callee7$(_context8) {
746
712
  while (1) {
747
- switch (_context9.prev = _context9.next) {
713
+ switch (_context8.prev = _context8.next) {
748
714
  case 0:
749
715
  closeDashboard = function _closeDashboard() {
750
716
  dashboardContainer.style.display = 'none';
751
717
  outlineContainer.style.display = 'inherit';
752
718
  };
753
719
 
754
- options = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
720
+ options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
755
721
  dashboardContainer = getDashboardContainer();
756
722
  outlineContainer = getOutlineContainer(); // reuse dashboard if already children already is inserted
757
723
 
758
724
  if (!(dashboardContainer.childNodes.length > 0 && options.pane)) {
759
- _context9.next = 12;
725
+ _context8.next = 12;
760
726
  break;
761
727
  }
762
728
 
763
729
  outlineContainer.style.display = 'none';
764
730
  dashboardContainer.style.display = 'inherit';
765
- tab = dashboardContainer.querySelector("[data-global-pane-name=\"".concat(options.pane, "\"]"));
731
+ _tab = dashboardContainer.querySelector("[data-global-pane-name=\"".concat(options.pane, "\"]"));
766
732
 
767
- if (!tab) {
768
- _context9.next = 11;
733
+ if (!_tab) {
734
+ _context8.next = 11;
769
735
  break;
770
736
  }
771
737
 
772
- tab.click();
773
- return _context9.abrupt("return");
738
+ _tab.click();
739
+
740
+ return _context8.abrupt("return");
774
741
 
775
742
  case 11:
776
743
  console.warn('Did not find the referred tab in global dashboard, will open first one');
777
744
 
778
745
  case 12:
779
- _context9.next = 14;
746
+ _context8.next = 14;
780
747
  return globalAppTabs({
781
748
  selectedTab: options.pane,
782
749
  onClose: closeDashboard
783
750
  });
784
751
 
785
752
  case 14:
786
- dashboard = _context9.sent;
753
+ dashboard = _context8.sent;
787
754
  // close the dashboard if user log out
788
755
  UI.authn.authSession.onLogout(closeDashboard); // finally - switch to showing dashboard
789
756
 
790
757
  outlineContainer.style.display = 'none';
791
758
  dashboardContainer.appendChild(dashboard);
759
+ tab = dashboardContainer.querySelector("[data-global-pane-name=\"".concat(options.pane, "\"]"));
760
+
761
+ if (tab) {
762
+ tab.click();
763
+ }
792
764
 
793
- case 18:
765
+ case 20:
794
766
  case "end":
795
- return _context9.stop();
767
+ return _context8.stop();
796
768
  }
797
769
  }
798
- }, _callee8);
770
+ }, _callee7);
799
771
  }));
800
772
  return _showDashboard.apply(this, arguments);
801
773
  }
@@ -826,7 +798,45 @@ function _default(context) {
826
798
  }();
827
799
  }
828
800
 
829
- function getRelevantPanes(_x, _x2) {
801
+ function checkForContainerRepresentation(_x) {
802
+ return _checkForContainerRepresentation.apply(this, arguments);
803
+ }
804
+
805
+ function _checkForContainerRepresentation() {
806
+ _checkForContainerRepresentation = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(subject) {
807
+ var response, containerTurtle;
808
+ return regeneratorRuntime.wrap(function _callee8$(_context9) {
809
+ while (1) {
810
+ switch (_context9.prev = _context9.next) {
811
+ case 0:
812
+ if (kb.any(subject, ns.ldp('contains'), undefined, subject.doc())) {
813
+ _context9.next = 6;
814
+ break;
815
+ }
816
+
817
+ _context9.next = 3;
818
+ return kb.fetcher.webOperation('GET', subject.uri, kb.fetcher.initFetchOptions(subject.uri, {
819
+ headers: {
820
+ accept: 'text/turtle'
821
+ }
822
+ }));
823
+
824
+ case 3:
825
+ response = _context9.sent;
826
+ containerTurtle = response.responseText;
827
+ $rdf.parse(containerTurtle, kb, subject.uri, 'text/turtle');
828
+
829
+ case 6:
830
+ case "end":
831
+ return _context9.stop();
832
+ }
833
+ }
834
+ }, _callee8);
835
+ }));
836
+ return _checkForContainerRepresentation.apply(this, arguments);
837
+ }
838
+
839
+ function getRelevantPanes(_x2, _x3) {
830
840
  return _getRelevantPanes.apply(this, arguments);
831
841
  }
832
842
 
@@ -837,39 +847,48 @@ function _default(context) {
837
847
  while (1) {
838
848
  switch (_context10.prev = _context10.next) {
839
849
  case 0:
850
+ if (!subject.uri.endsWith('/')) {
851
+ _context10.next = 3;
852
+ break;
853
+ }
854
+
855
+ _context10.next = 3;
856
+ return checkForContainerRepresentation(subject);
857
+
858
+ case 3:
840
859
  panes = context.session.paneRegistry;
841
860
  relevantPanes = panes.list.filter(function (pane) {
842
861
  return pane.label(subject, context) && !pane.global;
843
862
  });
844
863
 
845
864
  if (!(relevantPanes.length === 0)) {
846
- _context10.next = 4;
865
+ _context10.next = 7;
847
866
  break;
848
867
  }
849
868
 
850
869
  return _context10.abrupt("return", [panes.byName('internal')]);
851
870
 
852
- case 4:
853
- _context10.next = 6;
871
+ case 7:
872
+ _context10.next = 9;
854
873
  return UI.authn.filterAvailablePanes(relevantPanes);
855
874
 
856
- case 6:
875
+ case 9:
857
876
  filteredPanes = _context10.sent;
858
877
 
859
878
  if (!(filteredPanes.length === 0)) {
860
- _context10.next = 9;
879
+ _context10.next = 12;
861
880
  break;
862
881
  }
863
882
 
864
883
  return _context10.abrupt("return", [relevantPanes[0]]);
865
884
 
866
- case 9:
885
+ case 12:
867
886
  firstRelevantPaneIndex = panes.list.indexOf(relevantPanes[0]);
868
887
  firstFilteredPaneIndex = panes.list.indexOf(filteredPanes[0]); // if the first relevant pane is loaded before the panes available wrt role, we still want to offer the most relevant pane
869
888
 
870
889
  return _context10.abrupt("return", firstRelevantPaneIndex < firstFilteredPaneIndex ? [relevantPanes[0]].concat(filteredPanes) : filteredPanes);
871
890
 
872
- case 12:
891
+ case 15:
873
892
  case "end":
874
893
  return _context10.stop();
875
894
  }
@@ -885,7 +904,7 @@ function _default(context) {
885
904
  }) || relevantPanes[0];
886
905
  }
887
906
 
888
- function expandedHeaderTR(_x3, _x4, _x5) {
907
+ function expandedHeaderTR(_x4, _x5, _x6) {
889
908
  return _expandedHeaderTR.apply(this, arguments);
890
909
  } // expandedHeaderTR
891
910
  // / //////////////////////////////////////////////////////////////////////////