solid-ui 2.4.28-6a319caf → 2.4.28-6c36e718

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.
Files changed (64) hide show
  1. package/dist/805.solid-ui.min.js +1 -1
  2. package/dist/805.solid-ui.min.js.map +1 -1
  3. package/dist/solid-ui.js +1347 -2025
  4. package/dist/solid-ui.js.map +1 -1
  5. package/dist/solid-ui.min.js +1 -1
  6. package/dist/solid-ui.min.js.map +1 -1
  7. package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js +1955 -1955
  8. package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +1 -1
  9. package/lib/chat/bookmarks.js +7 -6
  10. package/lib/chat/bookmarks.js.map +1 -1
  11. package/lib/chat/chatLogic.js +65 -249
  12. package/lib/chat/chatLogic.js.map +1 -1
  13. package/lib/chat/dateFolder.js +126 -129
  14. package/lib/chat/dateFolder.js.map +1 -1
  15. package/lib/chat/infinite.js +423 -637
  16. package/lib/chat/infinite.js.map +1 -1
  17. package/lib/chat/message.js +193 -332
  18. package/lib/chat/message.js.map +1 -1
  19. package/lib/chat/messageTools.js +277 -463
  20. package/lib/chat/messageTools.js.map +1 -1
  21. package/lib/chat/signature.d.ts +2 -0
  22. package/lib/chat/signature.d.ts.map +1 -1
  23. package/lib/chat/signature.js +70 -1
  24. package/lib/chat/signature.js.map +1 -1
  25. package/lib/chat/thread.js +209 -299
  26. package/lib/chat/thread.js.map +1 -1
  27. package/lib/header/index.js +0 -5
  28. package/lib/header/index.js.map +1 -1
  29. package/lib/log.js +5 -5
  30. package/lib/log.js.map +1 -1
  31. package/lib/login/login.d.ts.map +1 -1
  32. package/lib/login/login.js +31 -65
  33. package/lib/login/login.js.map +1 -1
  34. package/lib/pad.js +1 -4
  35. package/lib/pad.js.map +1 -1
  36. package/lib/participation.js +1 -2
  37. package/lib/participation.js.map +1 -1
  38. package/lib/preferences.js +0 -4
  39. package/lib/preferences.js.map +1 -1
  40. package/lib/utils/headerFooterHelpers.js +0 -2
  41. package/lib/utils/headerFooterHelpers.js.map +1 -1
  42. package/lib/utils/keyHelpers/accessData.d.ts +2 -2
  43. package/lib/utils/keyHelpers/accessData.d.ts.map +1 -1
  44. package/lib/utils/keyHelpers/accessData.js +131 -51
  45. package/lib/utils/keyHelpers/accessData.js.map +1 -1
  46. package/lib/versionInfo.js +6 -6
  47. package/lib/versionInfo.js.map +1 -1
  48. package/lib/widgets/buttons.js +2 -0
  49. package/lib/widgets/buttons.js.map +1 -1
  50. package/lib/widgets/forms/autocomplete/autocompleteBar.js +1 -8
  51. package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
  52. package/lib/widgets/forms/autocomplete/autocompletePicker.js +3 -8
  53. package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
  54. package/lib/widgets/forms/autocomplete/language.js +0 -5
  55. package/lib/widgets/forms/autocomplete/language.js.map +1 -1
  56. package/lib/widgets/forms.js +1 -4
  57. package/lib/widgets/forms.js.map +1 -1
  58. package/lib/widgets/peoplePicker.js +0 -11
  59. package/lib/widgets/peoplePicker.js.map +1 -1
  60. package/package.json +2 -5
  61. package/lib/utils/keyHelpers/otherHelpers.d.ts +0 -3
  62. package/lib/utils/keyHelpers/otherHelpers.d.ts.map +0 -1
  63. package/lib/utils/keyHelpers/otherHelpers.js +0 -23
  64. package/lib/utils/keyHelpers/otherHelpers.js.map +0 -1
package/dist/solid-ui.js CHANGED
@@ -2249,6 +2249,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
2249
2249
  * @packageDocumentation
2250
2250
  */
2251
2251
 
2252
+ /* global alert confirm */
2253
+
2252
2254
  // pull in first avoid cross-refs
2253
2255
 
2254
2256
  var UI = {
@@ -2341,8 +2343,7 @@ function _findBookmarkDocument() {
2341
2343
  }
2342
2344
  userContext.bookmarkDocument = userContext.instances[0];
2343
2345
  if (userContext.instances.length > 1) {
2344
- debug.warn('More than one bookmark file! ' + userContext.instances); // @@ todo - deal with > 1
2345
- // Note: should pick up community bookmarks as well
2346
+ alert('More than one bookmark file! ' + userContext.instances);
2346
2347
  }
2347
2348
  _context.next = 28;
2348
2349
  break;
@@ -2363,7 +2364,7 @@ function _findBookmarkDocument() {
2363
2364
  case 18:
2364
2365
  _context.prev = 18;
2365
2366
  _context.t0 = _context["catch"](12);
2366
- debug.warn("Can't make fresh bookmark file:" + _context.t0);
2367
+ alert.error("Can't make fresh bookmark file:" + _context.t0);
2367
2368
  return _context.abrupt("return", userContext);
2368
2369
  case 22:
2369
2370
  _context.next = 24;
@@ -2373,7 +2374,7 @@ function _findBookmarkDocument() {
2373
2374
  _context.next = 28;
2374
2375
  break;
2375
2376
  case 27:
2376
- debug.warn('You seem to have no bookmark file, nor even a profile file!');
2377
+ alert('You seem to have no bookmark file and not even a profile file.');
2377
2378
  case 28:
2378
2379
  return _context.abrupt("return", userContext);
2379
2380
  case 29:
@@ -2428,7 +2429,7 @@ function _addBookmark() {
2428
2429
  _context2.prev = 14;
2429
2430
  _context2.t0 = _context2["catch"](9);
2430
2431
  msg = 'Making bookmark: ' + _context2.t0;
2431
- debug.warn(msg);
2432
+ alert.error(msg);
2432
2433
  return _context2.abrupt("return", null);
2433
2434
  case 19:
2434
2435
  return _context2.abrupt("return", bookmark);
@@ -2481,7 +2482,7 @@ function _toggleBookmark() {
2481
2482
  _context3.prev = 15;
2482
2483
  _context3.t0 = _context3["catch"](8);
2483
2484
  debug.error('Cant delete bookmark:' + _context3.t0);
2484
- debug.warn('Cannot delete bookmark:' + _context3.t0);
2485
+ alert('Cant delete bookmark:' + _context3.t0);
2485
2486
  case 19:
2486
2487
  i++;
2487
2488
  _context3.next = 7;
@@ -2576,7 +2577,6 @@ Object.defineProperty(exports, "__esModule", ({
2576
2577
  }));
2577
2578
  exports.ChatChannel = void 0;
2578
2579
  exports._createIfNotExists = _createIfNotExists;
2579
- exports.allVersions = allVersions;
2580
2580
  exports.isDeleted = isDeleted;
2581
2581
  exports.isHidden = isHidden;
2582
2582
  exports.isReplaced = isReplaced;
@@ -2654,9 +2654,8 @@ var ChatChannel = /*#__PURE__*/function () {
2654
2654
  var _this = this;
2655
2655
  var oldMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2656
2656
  var deleteIt = arguments.length > 2 ? arguments[2] : undefined;
2657
- var thread = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
2658
2657
  return /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
2659
- var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, oldMsgMaker, oldMsgMostRecentVersion, oldMsgThread, errMsg, privateKey, sig, _errMsg;
2658
+ var sts, now, timestamp, dateStamp, chatDocument, message, me, msg, oldMsgMaker, errMsg, privateKey, sig, _errMsg;
2660
2659
  return _regenerator["default"].wrap(function _callee2$(_context2) {
2661
2660
  while (1) switch (_context2.prev = _context2.next) {
2662
2661
  case 0:
@@ -2670,88 +2669,73 @@ var ChatChannel = /*#__PURE__*/function () {
2670
2669
  msg = (0, _signature.getBlankMsg)();
2671
2670
  msg.id = message.uri;
2672
2671
  if (!oldMsg) {
2673
- _context2.next = 27;
2672
+ _context2.next = 22;
2674
2673
  break;
2675
2674
  }
2676
2675
  // edit message replaces old one
2677
2676
  oldMsgMaker = _solidLogic.store.any(oldMsg, ns.foaf('maker')); // may not be needed here, but needed on READ
2678
2677
  if (!(oldMsgMaker.uri === me.uri)) {
2679
- _context2.next = 21;
2678
+ _context2.next = 16;
2680
2679
  break;
2681
2680
  }
2682
- _context2.next = 14;
2683
- return mostRecentVersion(oldMsg);
2684
- case 14:
2685
- oldMsgMostRecentVersion = _context2.sent;
2686
- sts.push($rdf.st(oldMsgMostRecentVersion, ns.dct('isReplacedBy'), message, chatDocument));
2687
- // if oldMsg has_reply => add has_reply to message
2688
- oldMsgThread = _solidLogic.store.any(oldMsgMostRecentVersion, ns.sioc('has_reply'));
2689
- if (oldMsgThread) {
2690
- sts.push($rdf.st(message, ns.sioc('has_reply'), oldMsgThread, chatDocument));
2691
- }
2681
+ sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument));
2692
2682
  if (deleteIt) {
2693
2683
  // we need to add a specific signature, else anyone can delete a msg ?
2694
2684
  sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
2695
2685
  }
2696
- _context2.next = 25;
2686
+ _context2.next = 20;
2697
2687
  break;
2698
- case 21:
2688
+ case 16:
2699
2689
  errMsg = 'Error you cannot delete/edit a message from someone else : \n' + oldMsgMaker.uri;
2700
2690
  debug.warn(errMsg);
2701
2691
  alert(errMsg);
2702
2692
  throw new Error(errMsg);
2703
- case 25:
2704
- _context2.next = 28;
2693
+ case 20:
2694
+ _context2.next = 23;
2705
2695
  break;
2706
- case 27:
2696
+ case 22:
2707
2697
  // link new message to channel
2708
2698
  sts.push($rdf.st(_this.channel, ns.wf('message'), message, chatDocument));
2709
- case 28:
2699
+ case 23:
2710
2700
  sts.push($rdf.st(message, ns.sioc('content'), _solidLogic.store.literal(text), chatDocument));
2711
2701
  msg.content = text;
2712
2702
  sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
2713
2703
  msg.created = dateStamp.value;
2714
2704
  if (!me) {
2715
- _context2.next = 40;
2705
+ _context2.next = 35;
2716
2706
  break;
2717
2707
  }
2718
2708
  sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
2719
2709
  msg.maker = me.uri;
2720
2710
  // privateKey the cached private key of me, cached in store
2721
- _context2.next = 37;
2711
+ _context2.next = 32;
2722
2712
  return (0, _keys.getPrivateKey)(me);
2723
- case 37:
2713
+ case 32:
2724
2714
  privateKey = _context2.sent;
2725
2715
  // me.uri)
2726
2716
  sig = (0, _signature.signMsg)(msg, privateKey);
2727
2717
  sts.push($rdf.st(message, $rdf.sym("".concat(_signature.SEC, "proofValue")), $rdf.lit(sig), chatDocument));
2728
- case 40:
2729
- if (thread) {
2730
- sts.push($rdf.st(thread, ns.sioc('has_member'), message, chatDocument));
2731
- if (!thread.doc().sameTerm(message.doc())) {
2732
- sts.push($rdf.st(thread, ns.sioc('has_member'), message, thread.doc()));
2733
- }
2734
- }
2735
- _context2.prev = 41;
2736
- _context2.next = 44;
2737
- return _solidLogic.store.updater.updateMany([], sts);
2738
- case 44:
2739
- _context2.next = 52;
2718
+ case 35:
2719
+ _context2.prev = 35;
2720
+ _context2.next = 38;
2721
+ return _solidLogic.store.updater.update([], sts);
2722
+ case 38:
2723
+ _context2.next = 46;
2740
2724
  break;
2741
- case 46:
2742
- _context2.prev = 46;
2743
- _context2.t0 = _context2["catch"](41);
2725
+ case 40:
2726
+ _context2.prev = 40;
2727
+ _context2.t0 = _context2["catch"](35);
2744
2728
  _errMsg = 'Error saving chat message: ' + _context2.t0;
2745
2729
  debug.warn(_errMsg);
2746
2730
  alert(_errMsg);
2747
2731
  throw new Error(_errMsg);
2748
- case 52:
2732
+ case 46:
2749
2733
  return _context2.abrupt("return", message);
2750
- case 53:
2734
+ case 47:
2751
2735
  case "end":
2752
2736
  return _context2.stop();
2753
2737
  }
2754
- }, _callee2, null, [[41, 46]]);
2738
+ }, _callee2, null, [[35, 40]]);
2755
2739
  })();
2756
2740
  });
2757
2741
  function updateMessage(_x2) {
@@ -2781,187 +2765,26 @@ var ChatChannel = /*#__PURE__*/function () {
2781
2765
  return _deleteMessage.apply(this, arguments);
2782
2766
  }
2783
2767
  return deleteMessage;
2784
- }() // Create a new thread of replies to the thread root message
2785
- // or return one which already exists
2786
- }, {
2787
- key: "createThread",
2788
- value: function () {
2789
- var _createThread = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(threadRoot) {
2790
- var already, thread, insert;
2791
- return _regenerator["default"].wrap(function _callee4$(_context4) {
2792
- while (1) switch (_context4.prev = _context4.next) {
2793
- case 0:
2794
- already = _solidLogic.store.each(threadRoot, ns.sioc('has_reply'), null, threadRoot.doc()).filter(function (thread) {
2795
- return _solidLogic.store.holds(thread, ns.rdf('type'), ns.sioc('Thread'), thread.doc());
2796
- });
2797
- if (!(already.length > 0)) {
2798
- _context4.next = 3;
2799
- break;
2800
- }
2801
- return _context4.abrupt("return", already[0]);
2802
- case 3:
2803
- thread = $rdf.sym(threadRoot.uri + '-thread');
2804
- insert = [$rdf.st(thread, ns.rdf('type'), ns.sioc('Thread'), thread.doc()), $rdf.st(threadRoot, ns.sioc('has_reply'), thread, thread.doc())];
2805
- _context4.next = 7;
2806
- return _solidLogic.store.updater.update([], insert);
2807
- case 7:
2808
- return _context4.abrupt("return", thread);
2809
- case 8:
2810
- case "end":
2811
- return _context4.stop();
2812
- }
2813
- }, _callee4);
2814
- }));
2815
- function createThread(_x4) {
2816
- return _createThread.apply(this, arguments);
2817
- }
2818
- return createThread;
2819
2768
  }()
2820
2769
  }]);
2821
2770
  return ChatChannel;
2822
2771
  }(); // class ChatChannel
2823
- // ////////// Utility functions
2824
- // Have to not loop forever if fed loops
2825
2772
  exports.ChatChannel = ChatChannel;
2826
- function allVersions(_x5) {
2827
- return _allVersions.apply(this, arguments);
2828
- }
2829
- function _allVersions() {
2830
- _allVersions = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(message) {
2831
- var versions, done, m, prev, next;
2832
- return _regenerator["default"].wrap(function _callee5$(_context5) {
2833
- while (1) switch (_context5.prev = _context5.next) {
2834
- case 0:
2835
- versions = [message];
2836
- done = {};
2837
- done[message.uri] = true;
2838
- m = message;
2839
- case 4:
2840
- if (false) {}
2841
- // earlier?
2842
- prev = _solidLogic.store.any(null, ns.dct('isReplacedBy'), m, m.doc());
2843
- if (!(!prev || done[prev.uri])) {
2844
- _context5.next = 8;
2845
- break;
2846
- }
2847
- return _context5.abrupt("break", 15);
2848
- case 8:
2849
- _context5.next = 10;
2850
- return _solidLogic.store.fetcher.load(prev);
2851
- case 10:
2852
- versions.unshift(prev);
2853
- done[prev.uri] = true;
2854
- m = prev;
2855
- _context5.next = 4;
2856
- break;
2857
- case 15:
2858
- m = message;
2859
- case 16:
2860
- if (false) {}
2861
- // later?
2862
- next = _solidLogic.store.any(m, ns.dct('isReplacedBy'), null, m.doc());
2863
- if (!(!next || done[next.uri])) {
2864
- _context5.next = 20;
2865
- break;
2866
- }
2867
- return _context5.abrupt("break", 25);
2868
- case 20:
2869
- versions.push(next);
2870
- done[next.uri] = true;
2871
- m = next;
2872
- _context5.next = 16;
2873
- break;
2874
- case 25:
2875
- return _context5.abrupt("return", versions);
2876
- case 26:
2877
- case "end":
2878
- return _context5.stop();
2879
- }
2880
- }, _callee5);
2881
- }));
2882
- return _allVersions.apply(this, arguments);
2883
- }
2884
- function originalVersion(_x6) {
2885
- return _originalVersion.apply(this, arguments);
2886
- }
2887
- function _originalVersion() {
2888
- _originalVersion = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(message) {
2889
- var msg, done;
2890
- return _regenerator["default"].wrap(function _callee6$(_context6) {
2891
- while (1) switch (_context6.prev = _context6.next) {
2892
- case 0:
2893
- msg = message;
2894
- done = {}; // done[message.uri] = true
2895
- case 2:
2896
- if (!msg) {
2897
- _context6.next = 13;
2898
- break;
2899
- }
2900
- if (!done[msg.uri]) {
2901
- _context6.next = 6;
2902
- break;
2903
- }
2904
- debug.error('originalVersion: verion loop' + message);
2905
- return _context6.abrupt("return", message);
2906
- case 6:
2907
- done[msg.uri] = true;
2908
- message = msg;
2909
- _context6.next = 10;
2910
- return _solidLogic.store.fetcher.load(message);
2911
- case 10:
2912
- msg = _solidLogic.store.any(null, ns.dct('isReplacedBy'), message, message.doc());
2913
- _context6.next = 2;
2914
- break;
2915
- case 13:
2916
- return _context6.abrupt("return", message);
2917
- case 14:
2918
- case "end":
2919
- return _context6.stop();
2920
- }
2921
- }, _callee6);
2922
- }));
2923
- return _originalVersion.apply(this, arguments);
2924
- }
2925
- function mostRecentVersion(_x7) {
2926
- return _mostRecentVersion.apply(this, arguments);
2773
+ function originalVersion(message) {
2774
+ var msg = message;
2775
+ while (msg) {
2776
+ message = msg;
2777
+ msg = _solidLogic.store.any(null, ns.dct('isReplacedBy'), message, message.doc());
2778
+ }
2779
+ return message;
2927
2780
  }
2928
- function _mostRecentVersion() {
2929
- _mostRecentVersion = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(message) {
2930
- var msg, done;
2931
- return _regenerator["default"].wrap(function _callee7$(_context7) {
2932
- while (1) switch (_context7.prev = _context7.next) {
2933
- case 0:
2934
- msg = message;
2935
- done = {};
2936
- case 2:
2937
- if (!msg) {
2938
- _context7.next = 13;
2939
- break;
2940
- }
2941
- if (!done[msg.uri]) {
2942
- _context7.next = 6;
2943
- break;
2944
- }
2945
- debug.error('mostRecentVersion: verion loop' + message);
2946
- return _context7.abrupt("return", message);
2947
- case 6:
2948
- done[msg.uri] = true;
2949
- message = msg;
2950
- _context7.next = 10;
2951
- return _solidLogic.store.fetcher.load(message);
2952
- case 10:
2953
- msg = _solidLogic.store.any(message, ns.dct('isReplacedBy'), null, message.doc());
2954
- _context7.next = 2;
2955
- break;
2956
- case 13:
2957
- return _context7.abrupt("return", message);
2958
- case 14:
2959
- case "end":
2960
- return _context7.stop();
2961
- }
2962
- }, _callee7);
2963
- }));
2964
- return _mostRecentVersion.apply(this, arguments);
2781
+ function mostRecentVersion(message) {
2782
+ var msg = message;
2783
+ while (msg) {
2784
+ message = msg;
2785
+ msg = _solidLogic.store.any(message, ns.dct('isReplacedBy'), null, message.doc());
2786
+ }
2787
+ return message;
2965
2788
  }
2966
2789
  function isDeleted(message) {
2967
2790
  return _solidLogic.store.holds(message, ns.schema('dateDeleted'), null, message.doc());
@@ -2980,62 +2803,62 @@ function nick(person) {
2980
2803
  if (s) return '' + s.value;
2981
2804
  return '' + utils.label(person);
2982
2805
  }
2983
- function _createIfNotExists(_x8) {
2806
+ function _createIfNotExists(_x4) {
2984
2807
  return _createIfNotExists2.apply(this, arguments);
2985
2808
  } // ends
2986
2809
  function _createIfNotExists2() {
2987
2810
  _createIfNotExists2 = (0, _asyncToGenerator2["default"])(function (doc) {
2988
2811
  var contentType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'text/turtle';
2989
2812
  var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
2990
- return /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
2813
+ return /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
2991
2814
  var response;
2992
- return _regenerator["default"].wrap(function _callee8$(_context8) {
2993
- while (1) switch (_context8.prev = _context8.next) {
2815
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
2816
+ while (1) switch (_context4.prev = _context4.next) {
2994
2817
  case 0:
2995
- _context8.prev = 0;
2996
- _context8.next = 3;
2818
+ _context4.prev = 0;
2819
+ _context4.next = 3;
2997
2820
  return _solidLogic.store.fetcher.load(doc);
2998
2821
  case 3:
2999
- response = _context8.sent;
3000
- _context8.next = 26;
2822
+ response = _context4.sent;
2823
+ _context4.next = 26;
3001
2824
  break;
3002
2825
  case 6:
3003
- _context8.prev = 6;
3004
- _context8.t0 = _context8["catch"](0);
3005
- if (!(_context8.t0.response.status === 404)) {
3006
- _context8.next = 24;
2826
+ _context4.prev = 6;
2827
+ _context4.t0 = _context4["catch"](0);
2828
+ if (!(_context4.t0.response.status === 404)) {
2829
+ _context4.next = 24;
3007
2830
  break;
3008
2831
  }
3009
2832
  debug.log('createIfNotExists: doc does NOT exist, will create... ' + doc);
3010
- _context8.prev = 10;
3011
- _context8.next = 13;
2833
+ _context4.prev = 10;
2834
+ _context4.next = 13;
3012
2835
  return _solidLogic.store.fetcher.webOperation('PUT', doc.uri, {
3013
2836
  data: data,
3014
2837
  contentType: contentType
3015
2838
  });
3016
2839
  case 13:
3017
- response = _context8.sent;
3018
- _context8.next = 20;
2840
+ response = _context4.sent;
2841
+ _context4.next = 20;
3019
2842
  break;
3020
2843
  case 16:
3021
- _context8.prev = 16;
3022
- _context8.t1 = _context8["catch"](10);
3023
- debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context8.t1);
3024
- throw _context8.t1;
2844
+ _context4.prev = 16;
2845
+ _context4.t1 = _context4["catch"](10);
2846
+ debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context4.t1);
2847
+ throw _context4.t1;
3025
2848
  case 20:
3026
2849
  delete _solidLogic.store.fetcher.requested[doc.uri]; // delete cached 404 error
3027
2850
  // debug.log('createIfNotExists doc created ok ' + doc)
3028
- return _context8.abrupt("return", response);
2851
+ return _context4.abrupt("return", response);
3029
2852
  case 24:
3030
- debug.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context8.t0);
3031
- throw _context8.t0;
2853
+ debug.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context4.t0);
2854
+ throw _context4.t0;
3032
2855
  case 26:
3033
- return _context8.abrupt("return", response);
2856
+ return _context4.abrupt("return", response);
3034
2857
  case 27:
3035
2858
  case "end":
3036
- return _context8.stop();
2859
+ return _context4.stop();
3037
2860
  }
3038
- }, _callee8, null, [[0, 6], [10, 16]]);
2861
+ }, _callee4, null, [[0, 6], [10, 16]]);
3039
2862
  })();
3040
2863
  });
3041
2864
  return _createIfNotExists2.apply(this, arguments);
@@ -3059,11 +2882,10 @@ Object.defineProperty(exports, "__esModule", ({
3059
2882
  value: true
3060
2883
  }));
3061
2884
  exports.DateFolder = void 0;
3062
- exports.emptyLeaf = emptyLeaf;
3063
2885
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
2886
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
3064
2887
  var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js"));
3065
2888
  var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js"));
3066
- var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
3067
2889
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
3068
2890
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
3069
2891
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
@@ -3076,29 +2898,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
3076
2898
  *
3077
2899
  */
3078
2900
  // pull in first avoid cross-refs
3079
- function emptyLeaf(_x) {
3080
- return _emptyLeaf.apply(this, arguments);
3081
- }
3082
2901
  /**
3083
2902
  * Track back through the YYYY/MM/DD tree to find the previous/next day
3084
2903
  */
3085
- function _emptyLeaf() {
3086
- _emptyLeaf = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(leafDocument) {
3087
- return _regenerator["default"].wrap(function _callee5$(_context5) {
3088
- while (1) switch (_context5.prev = _context5.next) {
3089
- case 0:
3090
- _context5.next = 2;
3091
- return _solidLogic.store.fetcher.load(leafDocument);
3092
- case 2:
3093
- return _context5.abrupt("return", !(_solidLogic.store.statementsMatching(null, ns.dct('created'), null, leafDocument).length > 0));
3094
- case 3:
3095
- case "end":
3096
- return _context5.stop();
3097
- }
3098
- }, _callee5);
3099
- }));
3100
- return _emptyLeaf.apply(this, arguments);
3101
- }
3102
2904
  var DateFolder = /*#__PURE__*/function () {
3103
2905
  function DateFolder(rootThing, leafFileName, membershipProperty) {
3104
2906
  (0, _classCallCheck2["default"])(this, DateFolder);
@@ -3137,22 +2939,61 @@ var DateFolder = /*#__PURE__*/function () {
3137
2939
  }, {
3138
2940
  key: "loadPrevious",
3139
2941
  value: function () {
3140
- var _loadPrevious = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(date, backwards) {
3141
- var previousPeriod, _previousPeriod, folder, found, leafDocument, nextDate;
3142
- return _regenerator["default"].wrap(function _callee2$(_context2) {
3143
- while (1) switch (_context2.prev = _context2.next) {
2942
+ var _loadPrevious = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(date, backwards) {
2943
+ var thisDateFolder, previousPeriod, _previousPeriod, folder, found, doc;
2944
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
2945
+ while (1) switch (_context3.prev = _context3.next) {
3144
2946
  case 0:
3145
2947
  _previousPeriod = function _previousPeriod3() {
3146
- _previousPeriod = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(file, level) {
3147
- var younger, suitable, lastOrFirst, parent, siblings, _folder, uncle, cousins, result;
3148
- return _regenerator["default"].wrap(function _callee$(_context) {
3149
- while (1) switch (_context.prev = _context.next) {
2948
+ _previousPeriod = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(file, level) {
2949
+ var younger, suitable, lastNonEmpty, _lastNonEmpty, parent, siblings, _folder, uncle, cousins, result;
2950
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
2951
+ while (1) switch (_context2.prev = _context2.next) {
3150
2952
  case 0:
3151
- lastOrFirst = function _lastOrFirst(siblings) {
3152
- siblings = siblings.filter(suitable);
3153
- siblings.sort(); // chronological order
3154
- if (!backwards) siblings.reverse();
3155
- return siblings.pop(); // date folder
2953
+ _lastNonEmpty = function _lastNonEmpty3() {
2954
+ _lastNonEmpty = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(siblings) {
2955
+ var _folder2, leafDocument;
2956
+ return _regenerator["default"].wrap(function _callee$(_context) {
2957
+ while (1) switch (_context.prev = _context.next) {
2958
+ case 0:
2959
+ siblings = siblings.filter(suitable);
2960
+ siblings.sort(); // chronological order
2961
+ if (!backwards) siblings.reverse();
2962
+ if (!(level !== 3)) {
2963
+ _context.next = 5;
2964
+ break;
2965
+ }
2966
+ return _context.abrupt("return", siblings.pop());
2967
+ case 5:
2968
+ if (!siblings.length) {
2969
+ _context.next = 14;
2970
+ break;
2971
+ }
2972
+ _folder2 = siblings.pop();
2973
+ leafDocument = _solidLogic.store.sym(_folder2.uri + thisDateFolder.leafFileName);
2974
+ _context.next = 10;
2975
+ return _solidLogic.store.fetcher.load(leafDocument);
2976
+ case 10:
2977
+ if (!(_solidLogic.store.statementsMatching(null, ns.dct('created'), null, leafDocument).length > 0)) {
2978
+ _context.next = 12;
2979
+ break;
2980
+ }
2981
+ return _context.abrupt("return", _folder2);
2982
+ case 12:
2983
+ _context.next = 5;
2984
+ break;
2985
+ case 14:
2986
+ return _context.abrupt("return", null);
2987
+ case 15:
2988
+ case "end":
2989
+ return _context.stop();
2990
+ }
2991
+ }, _callee);
2992
+ }));
2993
+ return _lastNonEmpty.apply(this, arguments);
2994
+ };
2995
+ lastNonEmpty = function _lastNonEmpty2(_x5) {
2996
+ return _lastNonEmpty.apply(this, arguments);
3156
2997
  };
3157
2998
  suitable = function _suitable(x) {
3158
2999
  var tail = x.uri.slice(0, -1).split('/').slice(-1)[0];
@@ -3165,115 +3006,97 @@ var DateFolder = /*#__PURE__*/function () {
3165
3006
  };
3166
3007
  // debug.log(' previousPeriod level' + level + ' file ' + file)
3167
3008
  parent = file.dir();
3168
- _context.prev = 4;
3169
- _context.next = 7;
3009
+ _context2.prev = 5;
3010
+ _context2.next = 8;
3170
3011
  return _solidLogic.store.fetcher.load(parent);
3171
- case 7:
3012
+ case 8:
3172
3013
  siblings = _solidLogic.store.each(parent, ns.ldp('contains'));
3173
3014
  siblings = siblings.filter(younger);
3174
- _folder = lastOrFirst(siblings);
3015
+ _context2.next = 12;
3016
+ return lastNonEmpty(siblings);
3017
+ case 12:
3018
+ _folder = _context2.sent;
3175
3019
  if (!_folder) {
3176
- _context.next = 12;
3020
+ _context2.next = 15;
3177
3021
  break;
3178
3022
  }
3179
- return _context.abrupt("return", _folder);
3180
- case 12:
3181
- debug.log(' parent no suitable offspring ' + parent);
3182
- _context.next = 23;
3183
- break;
3023
+ return _context2.abrupt("return", _folder);
3184
3024
  case 15:
3185
- _context.prev = 15;
3186
- _context.t0 = _context["catch"](4);
3187
- if (!(_context.t0.response && _context.t0.response.status && _context.t0.response.status === 404)) {
3188
- _context.next = 21;
3025
+ _context2.next = 25;
3026
+ break;
3027
+ case 17:
3028
+ _context2.prev = 17;
3029
+ _context2.t0 = _context2["catch"](5);
3030
+ if (!(_context2.t0.response && _context2.t0.response.status && _context2.t0.response.status === 404)) {
3031
+ _context2.next = 23;
3189
3032
  break;
3190
3033
  }
3191
3034
  debug.log('Error 404 for chat parent file ' + parent);
3192
- _context.next = 23;
3035
+ _context2.next = 25;
3193
3036
  break;
3194
- case 21:
3037
+ case 23:
3195
3038
  debug.log('*** Error NON 404 for chat parent file ' + parent);
3196
3039
  // statusTR.appendChild(widgets.errorMessageBlock(dom, err, 'pink'))
3197
- throw new Error("*** ".concat(_context.t0.message, " for chat folder ").concat(parent));
3198
- case 23:
3040
+ throw new Error("*** ".concat(_context2.t0.message, " for chat folder ").concat(parent));
3041
+ case 25:
3199
3042
  if (!(level === 0)) {
3200
- _context.next = 26;
3043
+ _context2.next = 27;
3201
3044
  break;
3202
3045
  }
3203
- debug.log('loadPrevious: returning as level is zero');
3204
- return _context.abrupt("return", null);
3205
- case 26:
3206
- _context.next = 28;
3046
+ return _context2.abrupt("return", null);
3047
+ case 27:
3048
+ _context2.next = 29;
3207
3049
  return previousPeriod(parent, level - 1);
3208
- case 28:
3209
- uncle = _context.sent;
3050
+ case 29:
3051
+ uncle = _context2.sent;
3210
3052
  if (uncle) {
3211
- _context.next = 32;
3053
+ _context2.next = 32;
3212
3054
  break;
3213
3055
  }
3214
- debug.log(' previousPeriod: nothing left before. ', parent);
3215
- return _context.abrupt("return", null);
3056
+ return _context2.abrupt("return", null);
3216
3057
  case 32:
3217
- _context.next = 34;
3058
+ _context2.next = 34;
3218
3059
  return _solidLogic.store.fetcher.load(uncle);
3219
3060
  case 34:
3220
3061
  cousins = _solidLogic.store.each(uncle, ns.ldp('contains'));
3221
- result = lastOrFirst(cousins);
3222
- debug.log(' previousPeriod: returning cousins at level ' + level, cousins);
3223
- debug.log(' previousPeriod: returning result at level ' + level, result);
3224
- return _context.abrupt("return", result);
3062
+ _context2.next = 37;
3063
+ return lastNonEmpty(cousins);
3064
+ case 37:
3065
+ result = _context2.sent;
3066
+ return _context2.abrupt("return", result);
3225
3067
  case 39:
3226
3068
  case "end":
3227
- return _context.stop();
3069
+ return _context2.stop();
3228
3070
  }
3229
- }, _callee, null, [[4, 15]]);
3071
+ }, _callee2, null, [[5, 17]]);
3230
3072
  }));
3231
3073
  return _previousPeriod.apply(this, arguments);
3232
3074
  };
3233
- previousPeriod = function _previousPeriod2(_x4, _x5) {
3075
+ previousPeriod = function _previousPeriod2(_x3, _x4) {
3234
3076
  return _previousPeriod.apply(this, arguments);
3235
- }; // previousPeriod
3077
+ };
3078
+ thisDateFolder = this;
3079
+ // previousPeriod
3236
3080
  folder = this.leafDocumentFromDate(date).dir();
3237
- case 3:
3238
- if (false) {}
3239
- _context2.next = 6;
3081
+ _context3.next = 6;
3240
3082
  return previousPeriod(folder, 3);
3241
3083
  case 6:
3242
- found = _context2.sent;
3084
+ found = _context3.sent;
3243
3085
  if (!found) {
3244
- _context2.next = 22;
3245
- break;
3246
- }
3247
- leafDocument = _solidLogic.store.sym(found.uri + this.leafFileName);
3248
- nextDate = this.dateFromLeafDocument(leafDocument);
3249
- _context2.next = 12;
3250
- return emptyLeaf(leafDocument);
3251
- case 12:
3252
- if (_context2.sent) {
3253
- _context2.next = 16;
3086
+ _context3.next = 10;
3254
3087
  break;
3255
3088
  }
3256
- return _context2.abrupt("return", nextDate);
3257
- case 16:
3258
- debug.log(' loadPrevious: skipping empty ' + leafDocument);
3259
- date = nextDate;
3260
- folder = this.leafDocumentFromDate(date).dir();
3261
- debug.log(' loadPrevious: moved back to ' + folder);
3262
- case 20:
3263
- _context2.next = 23;
3264
- break;
3265
- case 22:
3266
- return _context2.abrupt("return", null);
3267
- case 23:
3268
- _context2.next = 3;
3269
- break;
3270
- case 25:
3089
+ doc = _solidLogic.store.sym(found.uri + this.leafFileName);
3090
+ return _context3.abrupt("return", this.dateFromLeafDocument(doc));
3091
+ case 10:
3092
+ return _context3.abrupt("return", null);
3093
+ case 11:
3271
3094
  case "end":
3272
- return _context2.stop();
3095
+ return _context3.stop();
3273
3096
  }
3274
- }, _callee2, this);
3097
+ }, _callee3, this);
3275
3098
  }));
3276
- function loadPrevious(_x2, _x3) {
3099
+ function loadPrevious(_x, _x2) {
3277
3100
  return _loadPrevious.apply(this, arguments);
3278
3101
  }
3279
3102
  return loadPrevious;
@@ -3281,16 +3104,16 @@ var DateFolder = /*#__PURE__*/function () {
3281
3104
  }, {
3282
3105
  key: "firstLeaf",
3283
3106
  value: function () {
3284
- var _firstLeaf = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(backwards) {
3107
+ var _firstLeaf = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(backwards) {
3285
3108
  var folderStore, folderFetcher, earliestSubfolder, _earliestSubfolder, y, month, d, leafDocument, leafObjects, msg, sortMe;
3286
- return _regenerator["default"].wrap(function _callee4$(_context4) {
3287
- while (1) switch (_context4.prev = _context4.next) {
3109
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
3110
+ while (1) switch (_context5.prev = _context5.next) {
3288
3111
  case 0:
3289
3112
  _earliestSubfolder = function _earliestSubfolder3() {
3290
- _earliestSubfolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(parent) {
3113
+ _earliestSubfolder = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(parent) {
3291
3114
  var suitable, kids;
3292
- return _regenerator["default"].wrap(function _callee3$(_context3) {
3293
- while (1) switch (_context3.prev = _context3.next) {
3115
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
3116
+ while (1) switch (_context4.prev = _context4.next) {
3294
3117
  case 0:
3295
3118
  suitable = function _suitable2(x) {
3296
3119
  var tail = x.uri.slice(0, -1).split('/').slice(-1)[0];
@@ -3300,7 +3123,7 @@ var DateFolder = /*#__PURE__*/function () {
3300
3123
  debug.log(' parent ' + parent);
3301
3124
  delete folderFetcher.requested[parent.uri];
3302
3125
  // try {
3303
- _context3.next = 5;
3126
+ _context4.next = 5;
3304
3127
  return folderFetcher.load(parent, {
3305
3128
  force: true
3306
3129
  });
@@ -3311,19 +3134,19 @@ var DateFolder = /*#__PURE__*/function () {
3311
3134
  kids = folderStore.each(parent, ns.ldp('contains'));
3312
3135
  kids = kids.filter(suitable);
3313
3136
  if (!(kids.length === 0)) {
3314
- _context3.next = 9;
3137
+ _context4.next = 9;
3315
3138
  break;
3316
3139
  }
3317
3140
  throw new Error(' @@@ No children to parent2 ' + parent);
3318
3141
  case 9:
3319
3142
  kids.sort();
3320
3143
  if (backwards) kids.reverse();
3321
- return _context3.abrupt("return", kids[0]);
3144
+ return _context4.abrupt("return", kids[0]);
3322
3145
  case 12:
3323
3146
  case "end":
3324
- return _context3.stop();
3147
+ return _context4.stop();
3325
3148
  }
3326
- }, _callee3);
3149
+ }, _callee4);
3327
3150
  }));
3328
3151
  return _earliestSubfolder.apply(this, arguments);
3329
3152
  };
@@ -3333,25 +3156,25 @@ var DateFolder = /*#__PURE__*/function () {
3333
3156
  // backwards -> last leafObject
3334
3157
  folderStore = $rdf.graph();
3335
3158
  folderFetcher = new $rdf.Fetcher(folderStore);
3336
- _context4.next = 6;
3159
+ _context5.next = 6;
3337
3160
  return earliestSubfolder(this.root.dir());
3338
3161
  case 6:
3339
- y = _context4.sent;
3340
- _context4.next = 9;
3162
+ y = _context5.sent;
3163
+ _context5.next = 9;
3341
3164
  return earliestSubfolder(y);
3342
3165
  case 9:
3343
- month = _context4.sent;
3344
- _context4.next = 12;
3166
+ month = _context5.sent;
3167
+ _context5.next = 12;
3345
3168
  return earliestSubfolder(month);
3346
3169
  case 12:
3347
- d = _context4.sent;
3170
+ d = _context5.sent;
3348
3171
  leafDocument = $rdf.sym(d.uri + 'chat.ttl');
3349
- _context4.next = 16;
3172
+ _context5.next = 16;
3350
3173
  return folderFetcher.load(leafDocument);
3351
3174
  case 16:
3352
3175
  leafObjects = folderStore.each(this.root, this.membershipProperty, null, leafDocument);
3353
3176
  if (!(leafObjects.length === 0)) {
3354
- _context4.next = 21;
3177
+ _context5.next = 21;
3355
3178
  break;
3356
3179
  }
3357
3180
  msg = ' INCONSISTENCY -- no chat leafObject in file ' + leafDocument;
@@ -3364,12 +3187,12 @@ var DateFolder = /*#__PURE__*/function () {
3364
3187
  sortMe.sort();
3365
3188
  if (backwards) sortMe.reverse();
3366
3189
  debug.log((backwards ? 'Latest' : 'Earliest') + ' leafObject is ' + sortMe[0][1]);
3367
- return _context4.abrupt("return", sortMe[0][1]);
3190
+ return _context5.abrupt("return", sortMe[0][1]);
3368
3191
  case 26:
3369
3192
  case "end":
3370
- return _context4.stop();
3193
+ return _context5.stop();
3371
3194
  }
3372
- }, _callee4, this);
3195
+ }, _callee5, this);
3373
3196
  }));
3374
3197
  function firstLeaf(_x6) {
3375
3198
  return _firstLeaf.apply(this, arguments);
@@ -3413,17 +3236,19 @@ var _chatLogic = __webpack_require__(/*! ./chatLogic */ "./lib/chat/chatLogic.js
3413
3236
  var _message = __webpack_require__(/*! ./message */ "./lib/chat/message.js");
3414
3237
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
3415
3238
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
3416
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
3417
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3418
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /**
3419
- * Contains the [[infiniteMessageArea]] class
3420
- * @packageDocumentation
3421
- */ // import { findBookmarkDocument } from './bookmarks'
3239
+ /**
3240
+ * Contains the [[infiniteMessageArea]] class
3241
+ * @packageDocumentation
3242
+ */
3243
+ // import { findBookmarkDocument } from './bookmarks'
3422
3244
  // pull in first avoid cross-refs
3245
+
3423
3246
  // import * as style from '../style'
3424
3247
  // import * as utils from '../utils'
3248
+
3425
3249
  // import * as pad from '../pad'
3426
3250
  // import { DateFolder } from './dateFolder'
3251
+
3427
3252
  // const UI = { authn, icons, ns, media, pad, $rdf, store, style, utils, widgets }
3428
3253
 
3429
3254
  function desktopNotification(str) {
@@ -3451,9 +3276,34 @@ function desktopNotification(str) {
3451
3276
  /**
3452
3277
  * Renders a chat message inside a `messageTable`
3453
3278
  */
3454
- function insertMessageIntoTable(_x, _x2, _x3, _x4, _x5, _x6) {
3455
- return _insertMessageIntoTable.apply(this, arguments);
3279
+ function insertMessageIntoTable(channelObject, messageTable, message, fresh, options, userContext) {
3280
+ var messageRow = (0, _message.renderMessageRow)(channelObject, message, fresh, options, userContext);
3281
+
3282
+ // const message = messageRow.AJAR_subject
3283
+ if (options.selectedMessage && options.selectedMessage.sameTerm(message)) {
3284
+ messageRow.style.backgroundColor = 'yellow';
3285
+ options.selectedElement = messageRow;
3286
+ messageTable.selectedElement = messageRow;
3287
+ }
3288
+ var done = false;
3289
+ for (var ele = messageTable.firstChild;; ele = ele.nextSibling) {
3290
+ if (!ele) {
3291
+ // empty
3292
+ break;
3293
+ }
3294
+ var newestFirst = options.newestfirst === true;
3295
+ var dateString = messageRow.AJAR_date;
3296
+ if (dateString > ele.AJAR_date && newestFirst || dateString < ele.AJAR_date && !newestFirst) {
3297
+ messageTable.insertBefore(messageRow, ele);
3298
+ done = true;
3299
+ break;
3300
+ }
3301
+ }
3302
+ if (!done) {
3303
+ messageTable.appendChild(messageRow);
3304
+ }
3456
3305
  }
3306
+
3457
3307
  /**
3458
3308
  * Common code for a chat (discussion area of messages about something)
3459
3309
  * This version runs over a series of files for different time periods
@@ -3476,70 +3326,20 @@ function insertMessageIntoTable(_x, _x2, _x3, _x4, _x5, _x6) {
3476
3326
  - inlineImageHeightEms: The height (in ems) of images expaned from their URIs in the chat.
3477
3327
 
3478
3328
  */
3479
- function _insertMessageIntoTable() {
3480
- _insertMessageIntoTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(channelObject, messageTable, message, fresh, options, userContext) {
3481
- var messageRow, done, ele, newestFirst, dateString;
3482
- return _regenerator["default"].wrap(function _callee$(_context) {
3483
- while (1) switch (_context.prev = _context.next) {
3484
- case 0:
3485
- _context.next = 2;
3486
- return (0, _message.renderMessageRow)(channelObject, message, fresh, options, userContext);
3487
- case 2:
3488
- messageRow = _context.sent;
3489
- // const message = messageRow.AJAR_subject
3490
- if (options.selectedMessage && options.selectedMessage.sameTerm(message)) {
3491
- messageRow.style.backgroundColor = 'yellow';
3492
- options.selectedElement = messageRow;
3493
- messageTable.selectedElement = messageRow;
3494
- }
3495
- done = false;
3496
- ele = messageTable.firstChild;
3497
- case 6:
3498
- if (ele) {
3499
- _context.next = 8;
3500
- break;
3501
- }
3502
- return _context.abrupt("break", 17);
3503
- case 8:
3504
- newestFirst = options.newestfirst === true;
3505
- dateString = messageRow.AJAR_date;
3506
- if (!(dateString > ele.AJAR_date && newestFirst || dateString < ele.AJAR_date && !newestFirst)) {
3507
- _context.next = 14;
3508
- break;
3509
- }
3510
- messageTable.insertBefore(messageRow, ele);
3511
- done = true;
3512
- return _context.abrupt("break", 17);
3513
- case 14:
3514
- ele = ele.nextSibling;
3515
- _context.next = 6;
3516
- break;
3517
- case 17:
3518
- if (!done) {
3519
- messageTable.appendChild(messageRow);
3520
- }
3521
- case 18:
3522
- case "end":
3523
- return _context.stop();
3524
- }
3525
- }, _callee);
3526
- }));
3527
- return _insertMessageIntoTable.apply(this, arguments);
3528
- }
3529
- function infiniteMessageArea(_x7, _x8, _x9, _x10) {
3329
+ function infiniteMessageArea(_x, _x2, _x3, _x4) {
3530
3330
  return _infiniteMessageArea.apply(this, arguments);
3531
3331
  }
3532
3332
  function _infiniteMessageArea() {
3533
- _infiniteMessageArea = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(dom, wasStore, chatChannel, options) {
3534
- var syncMessages, _syncMessages, addMessage, _addMessage, insertPreviousMessages, _insertPreviousMessages, removePreviousMessages, createMessageTable, _createMessageTable, renderMessageTable, _renderMessageTable, addNewChatDocumentIfNewDay, _addNewChatDocumentIfNewDay, appendCurrentMessages, _appendCurrentMessages, loadMoreWhereNeeded, _loadMoreWhereNeeded, loadInitialContent, _loadInitialContent, newestFirst, channelObject, dateFolder, div, statusArea, userContext, liveMessageTable, threadRootMessage, earliest, latest, thread, threadTime, lock;
3535
- return _regenerator["default"].wrap(function _callee15$(_context15) {
3536
- while (1) switch (_context15.prev = _context15.next) {
3333
+ _infiniteMessageArea = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(dom, wasStore, chatChannel, options) {
3334
+ var syncMessages, addMessage, insertPreviousMessages, _insertPreviousMessages, removePreviousMessages, createMessageTable, _createMessageTable, renderMessageTable, addNewChatDocumentIfNewDay, _addNewChatDocumentIfNewDay, appendCurrentMessages, _appendCurrentMessages, loadMoreWhereNeeded, _loadMoreWhereNeeded, loadInitialContent, _loadInitialContent, newestFirst, channelObject, dateFolder, div, statusArea, userContext, liveMessageTable, earliest, latest, lock;
3335
+ return _regenerator["default"].wrap(function _callee12$(_context12) {
3336
+ while (1) switch (_context12.prev = _context12.next) {
3537
3337
  case 0:
3538
3338
  _loadInitialContent = function _loadInitialContent3() {
3539
- _loadInitialContent = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
3540
- var yank, fixScroll, live, selectedDocument, threadRootDocument, initialDocment, now, todayDocument, selectedMessageTable, selectedDate;
3541
- return _regenerator["default"].wrap(function _callee14$(_context14) {
3542
- while (1) switch (_context14.prev = _context14.next) {
3339
+ _loadInitialContent = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
3340
+ var yank, fixScroll, live, selectedDocument, now, todayDocument, selectedMessageTable, selectedDate;
3341
+ return _regenerator["default"].wrap(function _callee11$(_context11) {
3342
+ while (1) switch (_context11.prev = _context11.next) {
3543
3343
  case 0:
3544
3344
  fixScroll = function _fixScroll() {
3545
3345
  if (options.selectedElement) {
@@ -3553,59 +3353,51 @@ function _infiniteMessageArea() {
3553
3353
  }
3554
3354
  };
3555
3355
  yank = function _yank() {
3556
- if (selectedMessageTable && selectedMessageTable.selectedElement) {
3557
- selectedMessageTable.selectedElement.scrollIntoView({
3558
- block: 'center'
3559
- });
3560
- }
3561
- }; // During initial load ONLY keep scroll to selected thing or bottom
3356
+ selectedMessageTable.selectedElement.scrollIntoView({
3357
+ block: 'center'
3358
+ });
3359
+ };
3562
3360
  if (options.selectedMessage) {
3563
3361
  selectedDocument = options.selectedMessage.doc();
3564
- }
3565
- if (threadRootMessage) {
3566
- threadRootDocument = threadRootMessage.doc();
3567
- }
3568
- initialDocment = selectedDocument || threadRootDocument;
3569
- if (initialDocment) {
3570
3362
  now = new Date();
3571
3363
  todayDocument = dateFolder.leafDocumentFromDate(now);
3572
- live = todayDocument.sameTerm(initialDocment);
3364
+ live = todayDocument.sameTerm(selectedDocument);
3573
3365
  }
3574
- if (!(initialDocment && !live)) {
3575
- _context14.next = 18;
3366
+ if (!(options.selectedMessage && !live)) {
3367
+ _context11.next = 15;
3576
3368
  break;
3577
3369
  }
3578
- selectedDate = dateFolder.dateFromLeafDocument(initialDocment);
3579
- _context14.next = 10;
3370
+ selectedDate = dateFolder.dateFromLeafDocument(selectedDocument);
3371
+ _context11.next = 7;
3580
3372
  return createMessageTable(selectedDate, live);
3581
- case 10:
3582
- selectedMessageTable = _context14.sent;
3373
+ case 7:
3374
+ selectedMessageTable = _context11.sent;
3583
3375
  div.appendChild(selectedMessageTable);
3584
3376
  earliest.messageTable = selectedMessageTable;
3585
3377
  latest.messageTable = selectedMessageTable;
3586
3378
  yank();
3587
3379
  setTimeout(yank, 1000); // @@ kludge - restore position distubed by other cHANGES
3588
- _context14.next = 22;
3380
+ _context11.next = 19;
3589
3381
  break;
3590
- case 18:
3591
- _context14.next = 20;
3382
+ case 15:
3383
+ _context11.next = 17;
3592
3384
  return appendCurrentMessages();
3593
- case 20:
3385
+ case 17:
3594
3386
  earliest.messageTable = liveMessageTable;
3595
3387
  latest.messageTable = liveMessageTable;
3596
- case 22:
3597
- _context14.next = 24;
3388
+ case 19:
3389
+ _context11.next = 21;
3598
3390
  return loadMoreWhereNeeded(null, fixScroll);
3599
- case 24:
3391
+ case 21:
3600
3392
  div.addEventListener('scroll', loadMoreWhereNeeded);
3601
3393
  if (options.solo) {
3602
3394
  document.body.addEventListener('scroll', loadMoreWhereNeeded);
3603
3395
  }
3604
- case 26:
3396
+ case 23:
3605
3397
  case "end":
3606
- return _context14.stop();
3398
+ return _context11.stop();
3607
3399
  }
3608
- }, _callee14);
3400
+ }, _callee11);
3609
3401
  }));
3610
3402
  return _loadInitialContent.apply(this, arguments);
3611
3403
  };
@@ -3613,16 +3405,16 @@ function _infiniteMessageArea() {
3613
3405
  return _loadInitialContent.apply(this, arguments);
3614
3406
  };
3615
3407
  _loadMoreWhereNeeded = function _loadMoreWhereNeeded3() {
3616
- _loadMoreWhereNeeded = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(event, fixScroll) {
3408
+ _loadMoreWhereNeeded = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(event, fixScroll) {
3617
3409
  var freeze, magicZone, done, scrollBottom, scrollTop;
3618
- return _regenerator["default"].wrap(function _callee13$(_context13) {
3619
- while (1) switch (_context13.prev = _context13.next) {
3410
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
3411
+ while (1) switch (_context10.prev = _context10.next) {
3620
3412
  case 0:
3621
3413
  if (!lock) {
3622
- _context13.next = 2;
3414
+ _context10.next = 2;
3623
3415
  break;
3624
3416
  }
3625
- return _context13.abrupt("return");
3417
+ return _context10.abrupt("return");
3626
3418
  case 2:
3627
3419
  lock = true;
3628
3420
  freeze = !fixScroll;
@@ -3630,36 +3422,36 @@ function _infiniteMessageArea() {
3630
3422
  // const bottom = div.scrollHeight - top - div.clientHeight
3631
3423
  case 5:
3632
3424
  if (!(div.scrollTop < magicZone && earliest.messageTable && !earliest.messageTable.initial && earliest.messageTable.extendBackwards)) {
3633
- _context13.next = 21;
3425
+ _context10.next = 21;
3634
3426
  break;
3635
3427
  }
3636
3428
  if (!(div.scrollHeight === 0)) {
3637
- _context13.next = 10;
3429
+ _context10.next = 10;
3638
3430
  break;
3639
3431
  }
3640
- // debug.log(' chat/loadMoreWhereNeeded: trying later...')
3432
+ // console.log(' chat/loadMoreWhereNeeded: trying later...')
3641
3433
  setTimeout(loadMoreWhereNeeded, 2000); // couple be less
3642
3434
  lock = false;
3643
- return _context13.abrupt("return");
3435
+ return _context10.abrupt("return");
3644
3436
  case 10:
3645
- // debug.log(' chat/loadMoreWhereNeeded: Going now')
3437
+ // console.log(' chat/loadMoreWhereNeeded: Going now')
3646
3438
  scrollBottom = div.scrollHeight - div.scrollTop;
3647
3439
  debug.log('infinite scroll: adding above: top ' + div.scrollTop);
3648
- _context13.next = 14;
3440
+ _context10.next = 14;
3649
3441
  return earliest.messageTable.extendBackwards();
3650
3442
  case 14:
3651
- done = _context13.sent;
3443
+ done = _context10.sent;
3652
3444
  if (freeze) {
3653
3445
  div.scrollTop = div.scrollHeight - scrollBottom;
3654
3446
  }
3655
3447
  if (fixScroll) fixScroll();
3656
3448
  if (!done) {
3657
- _context13.next = 19;
3449
+ _context10.next = 19;
3658
3450
  break;
3659
3451
  }
3660
- return _context13.abrupt("break", 21);
3452
+ return _context10.abrupt("break", 21);
3661
3453
  case 19:
3662
- _context13.next = 5;
3454
+ _context10.next = 5;
3663
3455
  break;
3664
3456
  case 21:
3665
3457
  if (!(options.selectedMessage &&
@@ -3669,15 +3461,15 @@ function _infiniteMessageArea() {
3669
3461
  latest.messageTable && !latest.messageTable["final"] &&
3670
3462
  // there is more data to come
3671
3463
  latest.messageTable.extendForwards)) {
3672
- _context13.next = 33;
3464
+ _context10.next = 33;
3673
3465
  break;
3674
3466
  }
3675
3467
  scrollTop = div.scrollTop;
3676
3468
  debug.log('infinite scroll: adding below: bottom: ' + (div.scrollHeight - div.scrollTop - div.clientHeight));
3677
- _context13.next = 26;
3469
+ _context10.next = 26;
3678
3470
  return latest.messageTable.extendForwards();
3679
3471
  case 26:
3680
- done = _context13.sent;
3472
+ done = _context10.sent;
3681
3473
  // then add more data on the bottom
3682
3474
  if (freeze) {
3683
3475
  div.scrollTop = scrollTop; // while adding below keep same things in view
@@ -3685,66 +3477,63 @@ function _infiniteMessageArea() {
3685
3477
 
3686
3478
  if (fixScroll) fixScroll();
3687
3479
  if (!done) {
3688
- _context13.next = 31;
3480
+ _context10.next = 31;
3689
3481
  break;
3690
3482
  }
3691
- return _context13.abrupt("break", 33);
3483
+ return _context10.abrupt("break", 33);
3692
3484
  case 31:
3693
- _context13.next = 21;
3485
+ _context10.next = 21;
3694
3486
  break;
3695
3487
  case 33:
3696
3488
  lock = false;
3697
3489
  case 34:
3698
3490
  case "end":
3699
- return _context13.stop();
3491
+ return _context10.stop();
3700
3492
  }
3701
- }, _callee13);
3493
+ }, _callee10);
3702
3494
  }));
3703
3495
  return _loadMoreWhereNeeded.apply(this, arguments);
3704
3496
  };
3705
- loadMoreWhereNeeded = function _loadMoreWhereNeeded2(_x20, _x21) {
3497
+ loadMoreWhereNeeded = function _loadMoreWhereNeeded2(_x10, _x11) {
3706
3498
  return _loadMoreWhereNeeded.apply(this, arguments);
3707
3499
  };
3708
3500
  _appendCurrentMessages = function _appendCurrentMessage2() {
3709
- _appendCurrentMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
3501
+ _appendCurrentMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
3710
3502
  var now, chatDocument, messageTable;
3711
- return _regenerator["default"].wrap(function _callee12$(_context12) {
3712
- while (1) switch (_context12.prev = _context12.next) {
3503
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
3504
+ while (1) switch (_context9.prev = _context9.next) {
3713
3505
  case 0:
3714
3506
  now = new Date();
3715
3507
  chatDocument = dateFolder.leafDocumentFromDate(now); /// ///////////////////////////////////////////////////////////
3716
- _context12.next = 4;
3508
+ _context9.next = 4;
3717
3509
  return createMessageTable(now, true);
3718
3510
  case 4:
3719
- messageTable = _context12.sent;
3511
+ messageTable = _context9.sent;
3720
3512
  div.appendChild(messageTable);
3721
- div.refresh = /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
3722
- return _regenerator["default"].wrap(function _callee11$(_context11) {
3723
- while (1) switch (_context11.prev = _context11.next) {
3513
+ div.refresh = /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
3514
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
3515
+ while (1) switch (_context8.prev = _context8.next) {
3724
3516
  case 0:
3725
- _context11.next = 2;
3517
+ _context8.next = 2;
3726
3518
  return addNewChatDocumentIfNewDay(new Date());
3727
3519
  case 2:
3728
- _context11.next = 4;
3729
- return syncMessages(chatChannel, messageTable);
3730
- case 4:
3731
- // @@ livemessagetable??
3520
+ syncMessages(chatChannel, messageTable); // @@ livemessagetable??
3732
3521
  desktopNotification(chatChannel);
3733
- case 5:
3522
+ case 4:
3734
3523
  case "end":
3735
- return _context11.stop();
3524
+ return _context8.stop();
3736
3525
  }
3737
- }, _callee11);
3526
+ }, _callee8);
3738
3527
  })); // The short chat version the live update listening is done in the pane but we do it in the widget @@
3739
3528
  _solidLogic.store.updater.addDownstreamChangeListener(chatDocument, div.refresh); // Live update
3740
3529
  liveMessageTable = messageTable;
3741
3530
  latest.messageTable = liveMessageTable;
3742
- return _context12.abrupt("return", messageTable);
3531
+ return _context9.abrupt("return", messageTable);
3743
3532
  case 11:
3744
3533
  case "end":
3745
- return _context12.stop();
3534
+ return _context9.stop();
3746
3535
  }
3747
- }, _callee12);
3536
+ }, _callee9);
3748
3537
  }));
3749
3538
  return _appendCurrentMessages.apply(this, arguments);
3750
3539
  };
@@ -3752,15 +3541,15 @@ function _infiniteMessageArea() {
3752
3541
  return _appendCurrentMessages.apply(this, arguments);
3753
3542
  };
3754
3543
  _addNewChatDocumentIfNewDay = function _addNewChatDocumentIf2() {
3755
- _addNewChatDocumentIfNewDay = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10() {
3544
+ _addNewChatDocumentIfNewDay = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
3756
3545
  var newChatDocument, oldChatDocument, sts;
3757
- return _regenerator["default"].wrap(function _callee10$(_context10) {
3758
- while (1) switch (_context10.prev = _context10.next) {
3546
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
3547
+ while (1) switch (_context7.prev = _context7.next) {
3759
3548
  case 0:
3760
3549
  // @@ Remove listener from previous table as it is now static
3761
3550
  newChatDocument = dateFolder.leafDocumentFromDate(new Date());
3762
3551
  if (newChatDocument.sameTerm(latest.messageTable.chatDocument)) {
3763
- _context10.next = 7;
3552
+ _context7.next = 7;
3764
3553
  break;
3765
3554
  }
3766
3555
  // It is a new day
@@ -3769,7 +3558,7 @@ function _infiniteMessageArea() {
3769
3558
  delete liveMessageTable.inputRow;
3770
3559
  }
3771
3560
  oldChatDocument = latest.messageTable.chatDocument;
3772
- _context10.next = 6;
3561
+ _context7.next = 6;
3773
3562
  return appendCurrentMessages();
3774
3563
  case 6:
3775
3564
  // Adding a link in the document will ping listeners to add the new block too
@@ -3783,323 +3572,286 @@ function _infiniteMessageArea() {
3783
3572
  }
3784
3573
  case 7:
3785
3574
  case "end":
3786
- return _context10.stop();
3575
+ return _context7.stop();
3787
3576
  }
3788
- }, _callee10);
3577
+ }, _callee7);
3789
3578
  }));
3790
3579
  return _addNewChatDocumentIfNewDay.apply(this, arguments);
3791
3580
  };
3792
3581
  addNewChatDocumentIfNewDay = function _addNewChatDocumentIf() {
3793
3582
  return _addNewChatDocumentIfNewDay.apply(this, arguments);
3794
3583
  };
3795
- _renderMessageTable = function _renderMessageTable3() {
3796
- _renderMessageTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(date, live) {
3797
- var scrollBackbutton, scrollForwardButton, extendBackwards, _extendBackwards, setScrollBackbuttonIcon, extendForwards, _extendForwards, setScrollForwardButtonIcon, scrollForwardButtonHandler, _scrollForwardButtonHandler, messageTable, chatDocument, tr, test, titleTR, scrollBackbuttonCell, dateCell, scrollForwardButtonCell, sts, _iterator2, _step2, st;
3798
- return _regenerator["default"].wrap(function _callee9$(_context9) {
3799
- while (1) switch (_context9.prev = _context9.next) {
3800
- case 0:
3801
- _scrollForwardButtonHandler = function _scrollForwardButtonH2() {
3802
- _scrollForwardButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_event) {
3803
- return _regenerator["default"].wrap(function _callee8$(_context8) {
3804
- while (1) switch (_context8.prev = _context8.next) {
3805
- case 0:
3806
- if (!messageTable.extendedForwards) {
3807
- _context8.next = 6;
3808
- break;
3809
- }
3810
- removePreviousMessages(false, messageTable);
3811
- messageTable.extendedForwards = false;
3812
- setScrollForwardButtonIcon();
3813
- _context8.next = 9;
3814
- break;
3815
- case 6:
3816
- _context8.next = 8;
3817
- return extendForwards();
3818
- case 8:
3819
- // async
3820
- latest.messageTable.scrollIntoView(newestFirst);
3821
- case 9:
3822
- case "end":
3823
- return _context8.stop();
3824
- }
3825
- }, _callee8);
3826
- }));
3827
- return _scrollForwardButtonHandler.apply(this, arguments);
3828
- };
3829
- scrollForwardButtonHandler = function _scrollForwardButtonH(_x22) {
3830
- return _scrollForwardButtonHandler.apply(this, arguments);
3831
- };
3832
- setScrollForwardButtonIcon = function _setScrollForwardButt() {
3833
- if (!scrollForwardButton) return;
3834
- var sense = messageTable.extendedForwards ? !newestFirst : newestFirst; // noun_T-Block_1114657_000000.svg
3835
- var scrollForwardIcon = messageTable["final"] ? 'noun_T-Block_1114657_000000.svg' : getScrollForwardButtonIcon(sense);
3836
- scrollForwardButton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollForwardIcon);
3837
- function getScrollForwardButtonIcon(sense) {
3838
- return !sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
3839
- }
3840
- };
3841
- _extendForwards = function _extendForwards3() {
3842
- _extendForwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
3843
- var done;
3844
- return _regenerator["default"].wrap(function _callee7$(_context7) {
3845
- while (1) switch (_context7.prev = _context7.next) {
3846
- case 0:
3847
- _context7.next = 2;
3848
- return insertPreviousMessages(false);
3849
- case 2:
3850
- done = _context7.sent;
3851
- return _context7.abrupt("return", done);
3852
- case 4:
3853
- case "end":
3854
- return _context7.stop();
3855
- }
3856
- }, _callee7);
3857
- }));
3858
- return _extendForwards.apply(this, arguments);
3859
- };
3860
- extendForwards = function _extendForwards2() {
3861
- return _extendForwards.apply(this, arguments);
3862
- };
3863
- setScrollBackbuttonIcon = function _setScrollBackbuttonI() {
3864
- if (!scrollBackbutton) {
3865
- return;
3866
- }
3867
- var sense = messageTable.extendedBack ? !newestFirst : newestFirst;
3868
- var scrollBackIcon = messageTable.initial ? 'noun_T-Block_1114655_000000.svg' : getScrollbackIcon(sense);
3869
- scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollBackIcon);
3870
- function getScrollbackIcon(sense) {
3871
- return sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
3872
- }
3873
- };
3874
- _extendBackwards = function _extendBackwards3() {
3875
- _extendBackwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
3876
- var done;
3877
- return _regenerator["default"].wrap(function _callee6$(_context6) {
3878
- while (1) switch (_context6.prev = _context6.next) {
3879
- case 0:
3880
- _context6.next = 2;
3881
- return insertPreviousMessages(true);
3882
- case 2:
3883
- done = _context6.sent;
3884
- if (done) {
3885
- if (scrollBackbutton) {
3886
- scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + 'noun_T-Block_1114655_000000.svg'); // T
3887
- scrollBackbutton.disabled = true;
3888
- }
3889
- messageTable.initial = true;
3890
- } else {
3891
- messageTable.extendedBack = true;
3892
- }
3893
- setScrollBackbuttonIcon();
3894
- return _context6.abrupt("return", done);
3895
- case 6:
3896
- case "end":
3897
- return _context6.stop();
3898
- }
3899
- }, _callee6);
3900
- }));
3901
- return _extendBackwards.apply(this, arguments);
3902
- };
3903
- extendBackwards = function _extendBackwards2() {
3904
- return _extendBackwards.apply(this, arguments);
3905
- };
3906
- scrollBackbutton = null; // was let
3907
- scrollForwardButton = null; // was let
3908
- /// ///////////////// Scroll down adding more above
3909
- /// ////////////// Scroll up adding more below
3910
- /// ///////////////////////
3911
- /*
3912
- options = options || {}
3913
- options.authorDateOnLeft = true
3914
- const newestFirst = options.newestFirst === '1' || options.newestFirst === true // hack for now
3915
- const channelObject = new ChatChannel(chatChannel, options)
3916
- const dateFolder = channelObject.dateFolder
3917
- const div = dom.createElement('div')
3918
- const statusArea = div.appendChild(dom.createElement('div'))
3919
- const userContext = { dom, statusArea, div: statusArea } // logged on state, pointers to user's stuff
3920
- */
3921
- debug.log('Options for called message Area', options);
3922
- messageTable = dom.createElement('table');
3923
- messageTable.style.width = '100%'; // fill the pane div
3924
- messageTable.extendBackwards = extendBackwards; // Make function available to scroll stuff
3925
- messageTable.extendForwards = extendForwards; // Make function available to scroll stuff
3584
+ renderMessageTable = function _renderMessageTable(date, live) {
3585
+ var scrollBackbutton;
3586
+ var scrollForwardButton;
3926
3587
 
3927
- messageTable.date = date;
3928
- chatDocument = dateFolder.leafDocumentFromDate(date);
3929
- messageTable.chatDocument = chatDocument;
3930
- messageTable.fresh = false;
3931
- messageTable.setAttribute('style', 'width: 100%;'); // fill that div!
3932
- if (live) {
3933
- messageTable["final"] = true;
3934
- liveMessageTable = messageTable;
3935
- latest.messageTable = messageTable;
3936
- tr = (0, _message.renderMessageEditor)(channelObject, messageTable, userContext, options);
3937
- if (newestFirst) {
3938
- messageTable.insertBefore(tr, messageTable.firstChild); // If newestFirst
3588
+ /// ///////////////// Scroll down adding more above
3589
+ function extendBackwards() {
3590
+ return _extendBackwards.apply(this, arguments);
3591
+ }
3592
+ function _extendBackwards() {
3593
+ _extendBackwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
3594
+ var done;
3595
+ return _regenerator["default"].wrap(function _callee$(_context) {
3596
+ while (1) switch (_context.prev = _context.next) {
3597
+ case 0:
3598
+ _context.next = 2;
3599
+ return insertPreviousMessages(true);
3600
+ case 2:
3601
+ done = _context.sent;
3602
+ if (done) {
3603
+ if (scrollBackbutton) {
3604
+ scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + 'noun_T-Block_1114655_000000.svg'); // T
3605
+ scrollBackbutton.disabled = true;
3606
+ }
3607
+ messageTable.initial = true;
3939
3608
  } else {
3940
- messageTable.appendChild(tr); // not newestFirst
3609
+ messageTable.extendedBack = true;
3941
3610
  }
3942
-
3943
- messageTable.inputRow = tr;
3944
- }
3945
-
3946
- /// ///// Infinite scroll
3947
- //
3948
- // @@ listen for swipe past end event not just button
3949
- test = true;
3950
- if (test) {
3951
- // ws options.infinite but need for non-infinite
3952
- titleTR = dom.createElement('tr');
3953
- scrollBackbuttonCell = titleTR.appendChild(dom.createElement('td')); // up traingles: noun_1369237.svg
3954
- // down triangles: noun_1369241.svg
3955
- /*
3956
- const scrollBackIcon = newestFirst
3957
- ? 'noun_1369241.svg'
3958
- : 'noun_1369237.svg' // down and up arrows respoctively
3959
- scrollBackbutton = widgets.button(
3960
- dom,
3961
- icons.iconBase + scrollBackIcon,
3962
- 'Previous messages ...'
3963
- )
3964
- scrollBackbuttonCell.style = 'width:3em; height:3em;'
3965
- scrollBackbutton.addEventListener('click', scrollBackbuttonHandler, false)
3966
- messageTable.extendedBack = false
3967
- scrollBackbuttonCell.appendChild(scrollBackbutton)
3968
- setScrollBackbuttonIcon()
3969
- */
3970
- dateCell = titleTR.appendChild(dom.createElement('td'));
3971
- dateCell.style = 'text-align: center; vertical-align: middle; color: #888; font-style: italic;';
3972
- dateCell.textContent = widgets.shortDate(date.toISOString(), true); // no time, only date
3973
-
3974
- // @@@@@@@@@@@ todo move this button to other end of message cell, o
3975
- scrollForwardButtonCell = titleTR.appendChild(dom.createElement('td'));
3976
- if (options.includeRemoveButton) {
3977
- scrollForwardButtonCell.appendChild(widgets.cancelButton(dom, function (_e) {
3978
- div.parentNode.removeChild(div);
3979
- }));
3611
+ setScrollBackbuttonIcon();
3612
+ return _context.abrupt("return", done);
3613
+ case 6:
3614
+ case "end":
3615
+ return _context.stop();
3616
+ }
3617
+ }, _callee);
3618
+ }));
3619
+ return _extendBackwards.apply(this, arguments);
3620
+ }
3621
+ function setScrollBackbuttonIcon() {
3622
+ if (!scrollBackbutton) {
3623
+ return;
3624
+ }
3625
+ var sense = messageTable.extendedBack ? !newestFirst : newestFirst;
3626
+ var scrollBackIcon = messageTable.initial ? 'noun_T-Block_1114655_000000.svg' : getScrollbackIcon(sense);
3627
+ scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollBackIcon);
3628
+ function getScrollbackIcon(sense) {
3629
+ return sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
3630
+ }
3631
+ }
3632
+ function scrollBackbuttonHandler(_x8) {
3633
+ return _scrollBackbuttonHandler.apply(this, arguments);
3634
+ } /// ////////////// Scroll up adding more below
3635
+ function _scrollBackbuttonHandler() {
3636
+ _scrollBackbuttonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_event) {
3637
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
3638
+ while (1) switch (_context2.prev = _context2.next) {
3639
+ case 0:
3640
+ if (!messageTable.extendedBack) {
3641
+ _context2.next = 6;
3642
+ break;
3980
3643
  }
3981
- /*
3982
- const scrollForwardIcon = newestFirst
3983
- ? 'noun_1369241.svg'
3984
- : 'noun_1369237.svg' // down and up arrows respoctively
3985
- scrollForwardButton = widgets.button(
3986
- dom,
3987
- icons.iconBase + scrollForwardIcon,
3988
- 'Later messages ...'
3989
- )
3990
- scrollForwardButtonCell.appendChild(scrollForwardButton)
3991
- scrollForwardButtonCell.style = 'width:3em; height:3em;'
3992
- scrollForwardButton.addEventListener(
3993
- 'click',
3994
- scrollForwardButtonHandler,
3995
- false
3996
- )
3997
- messageTable.extendedForward = false
3998
- setScrollForwardButtonIcon()
3999
- */
4000
- messageTable.extendedForwards = false;
4001
- if (!newestFirst) {
4002
- // opposite end from the entry field
4003
- messageTable.insertBefore(titleTR, messageTable.firstChild); // If not newestFirst
3644
+ removePreviousMessages(true, messageTable);
3645
+ messageTable.extendedBack = false;
3646
+ setScrollBackbuttonIcon();
3647
+ _context2.next = 8;
3648
+ break;
3649
+ case 6:
3650
+ _context2.next = 8;
3651
+ return extendBackwards();
3652
+ case 8:
3653
+ case "end":
3654
+ return _context2.stop();
3655
+ }
3656
+ }, _callee2);
3657
+ }));
3658
+ return _scrollBackbuttonHandler.apply(this, arguments);
3659
+ }
3660
+ function extendForwards() {
3661
+ return _extendForwards.apply(this, arguments);
3662
+ }
3663
+ function _extendForwards() {
3664
+ _extendForwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
3665
+ var done;
3666
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
3667
+ while (1) switch (_context3.prev = _context3.next) {
3668
+ case 0:
3669
+ _context3.next = 2;
3670
+ return insertPreviousMessages(false);
3671
+ case 2:
3672
+ done = _context3.sent;
3673
+ if (done) {
3674
+ scrollForwardButton.firstChild.setAttribute('src', _iconBase.icons.iconBase + 'noun_T-Block_1114655_000000.svg');
3675
+ scrollForwardButton.disabled = true;
3676
+ messageTable["final"] = true;
4004
3677
  } else {
4005
- messageTable.appendChild(titleTR); // newestFirst
3678
+ messageTable.extendedForwards = true;
4006
3679
  }
4007
- }
4008
- sts = _solidLogic.store.statementsMatching(null, ns.wf('message'), null, chatDocument);
4009
- if (!live && sts.length === 0) {
4010
- // not todays
4011
- // no need buttomns at the moment
4012
- // messageTable.style.visibility = 'collapse' // Hide files with no messages
4013
- }
4014
- _iterator2 = _createForOfIteratorHelper(sts);
4015
- _context9.prev = 26;
4016
- _iterator2.s();
4017
- case 28:
4018
- if ((_step2 = _iterator2.n()).done) {
4019
- _context9.next = 34;
3680
+ setScrollForwardButtonIcon();
3681
+ return _context3.abrupt("return", done);
3682
+ case 6:
3683
+ case "end":
3684
+ return _context3.stop();
3685
+ }
3686
+ }, _callee3);
3687
+ }));
3688
+ return _extendForwards.apply(this, arguments);
3689
+ }
3690
+ function setScrollForwardButtonIcon() {
3691
+ var sense = messageTable.extendedForwards ? !newestFirst : newestFirst; // noun_T-Block_1114657_000000.svg
3692
+ var scrollForwardIcon = messageTable["final"] ? 'noun_T-Block_1114657_000000.svg' : getScrollForwardButtonIcon(sense);
3693
+ scrollForwardButton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollForwardIcon);
3694
+ function getScrollForwardButtonIcon(sense) {
3695
+ return !sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
3696
+ }
3697
+ }
3698
+ function scrollForwardButtonHandler(_x9) {
3699
+ return _scrollForwardButtonHandler.apply(this, arguments);
3700
+ } /// ///////////////////////
3701
+ /*
3702
+ options = options || {}
3703
+ options.authorDateOnLeft = true
3704
+ const newestFirst = options.newestFirst === '1' || options.newestFirst === true // hack for now
3705
+ const channelObject = new ChatChannel(chatChannel, options)
3706
+ const dateFolder = channelObject.dateFolder
3707
+ const div = dom.createElement('div')
3708
+ const statusArea = div.appendChild(dom.createElement('div'))
3709
+ const userContext = { dom, statusArea, div: statusArea } // logged on state, pointers to user's stuff
3710
+ */
3711
+ function _scrollForwardButtonHandler() {
3712
+ _scrollForwardButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_event) {
3713
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
3714
+ while (1) switch (_context4.prev = _context4.next) {
3715
+ case 0:
3716
+ if (!messageTable.extendedForwards) {
3717
+ _context4.next = 6;
3718
+ break;
3719
+ }
3720
+ removePreviousMessages(false, messageTable);
3721
+ messageTable.extendedForwards = false;
3722
+ setScrollForwardButtonIcon();
3723
+ _context4.next = 9;
4020
3724
  break;
4021
- }
4022
- st = _step2.value;
4023
- _context9.next = 32;
4024
- return addMessage(st.object, messageTable);
4025
- case 32:
4026
- _context9.next = 28;
4027
- break;
4028
- case 34:
4029
- _context9.next = 39;
4030
- break;
4031
- case 36:
4032
- _context9.prev = 36;
4033
- _context9.t0 = _context9["catch"](26);
4034
- _iterator2.e(_context9.t0);
4035
- case 39:
4036
- _context9.prev = 39;
4037
- _iterator2.f();
4038
- return _context9.finish(39);
4039
- case 42:
4040
- messageTable.fresh = true;
4041
-
4042
- // loadMessageTable(messageTable, chatDocument)
4043
- messageTable.fresh = false;
4044
- return _context9.abrupt("return", messageTable);
4045
- case 45:
4046
- case "end":
4047
- return _context9.stop();
4048
- }
4049
- }, _callee9, null, [[26, 36, 39, 42]]);
4050
- }));
4051
- return _renderMessageTable.apply(this, arguments);
4052
- };
4053
- renderMessageTable = function _renderMessageTable2(_x18, _x19) {
4054
- return _renderMessageTable.apply(this, arguments);
3725
+ case 6:
3726
+ _context4.next = 8;
3727
+ return extendForwards();
3728
+ case 8:
3729
+ // async
3730
+ latest.messageTable.scrollIntoView(newestFirst);
3731
+ case 9:
3732
+ case "end":
3733
+ return _context4.stop();
3734
+ }
3735
+ }, _callee4);
3736
+ }));
3737
+ return _scrollForwardButtonHandler.apply(this, arguments);
3738
+ }
3739
+ var messageTable = dom.createElement('table');
3740
+ messageTable.extendBackwards = extendBackwards; // Make function available to scroll stuff
3741
+ messageTable.extendForwards = extendForwards; // Make function available to scroll stuff
3742
+
3743
+ messageTable.date = date;
3744
+ var chatDocument = dateFolder.leafDocumentFromDate(date);
3745
+ messageTable.chatDocument = chatDocument;
3746
+ messageTable.fresh = false;
3747
+ messageTable.setAttribute('style', 'width: 100%;'); // fill that div!
3748
+ if (live) {
3749
+ messageTable["final"] = true;
3750
+ liveMessageTable = messageTable;
3751
+ latest.messageTable = messageTable;
3752
+ var tr = (0, _message.renderMessageEditor)(channelObject, messageTable, userContext, options);
3753
+ if (newestFirst) {
3754
+ messageTable.insertBefore(tr, messageTable.firstChild); // If newestFirst
3755
+ } else {
3756
+ messageTable.appendChild(tr); // not newestFirst
3757
+ }
3758
+
3759
+ messageTable.inputRow = tr;
3760
+ }
3761
+
3762
+ /// ///// Infinite scroll
3763
+ //
3764
+ // @@ listen for swipe past end event not just button
3765
+ if (options.infinite) {
3766
+ var scrollBackbuttonTR = dom.createElement('tr');
3767
+ var scrollBackbuttonCell = scrollBackbuttonTR.appendChild(dom.createElement('td'));
3768
+ // up traingles: noun_1369237.svg
3769
+ // down triangles: noun_1369241.svg
3770
+ var scrollBackIcon = newestFirst ? 'noun_1369241.svg' : 'noun_1369237.svg'; // down and up arrows respoctively
3771
+ scrollBackbutton = widgets.button(dom, _iconBase.icons.iconBase + scrollBackIcon, 'Previous messages ...');
3772
+ scrollBackbuttonCell.style = 'width:3em; height:3em;';
3773
+ scrollBackbutton.addEventListener('click', scrollBackbuttonHandler, false);
3774
+ messageTable.extendedBack = false;
3775
+ scrollBackbuttonCell.appendChild(scrollBackbutton);
3776
+ setScrollBackbuttonIcon();
3777
+ var dateCell = scrollBackbuttonTR.appendChild(dom.createElement('td'));
3778
+ dateCell.style = 'text-align: center; vertical-align: middle; color: #888; font-style: italic;';
3779
+ dateCell.textContent = widgets.shortDate(date.toISOString(), true); // no time, only date
3780
+
3781
+ // @@@@@@@@@@@ todo move this button to other end of message cell, o
3782
+ var scrollForwardButtonCell = scrollBackbuttonTR.appendChild(dom.createElement('td'));
3783
+ var scrollForwardIcon = newestFirst ? 'noun_1369241.svg' : 'noun_1369237.svg'; // down and up arrows respoctively
3784
+ scrollForwardButton = widgets.button(dom, _iconBase.icons.iconBase + scrollForwardIcon, 'Later messages ...');
3785
+ scrollForwardButtonCell.appendChild(scrollForwardButton);
3786
+ scrollForwardButtonCell.style = 'width:3em; height:3em;';
3787
+ scrollForwardButton.addEventListener('click', scrollForwardButtonHandler, false);
3788
+ messageTable.extendedForward = false;
3789
+ setScrollForwardButtonIcon();
3790
+ messageTable.extendedForwards = false;
3791
+ if (!newestFirst) {
3792
+ // opposite end from the entry field
3793
+ messageTable.insertBefore(scrollBackbuttonTR, messageTable.firstChild); // If not newestFirst
3794
+ } else {
3795
+ messageTable.appendChild(scrollBackbuttonTR); // newestFirst
3796
+ }
3797
+ }
3798
+
3799
+ var sts = _solidLogic.store.statementsMatching(null, ns.wf('message'), null, chatDocument);
3800
+ if (!live && sts.length === 0) {
3801
+ // not todays
3802
+ // no need buttomns at the moment
3803
+ // messageTable.style.visibility = 'collapse' // Hide files with no messages
3804
+ }
3805
+ sts.forEach(function (st) {
3806
+ addMessage(st.object, messageTable);
3807
+ });
3808
+ messageTable.fresh = true;
3809
+
3810
+ // loadMessageTable(messageTable, chatDocument)
3811
+ messageTable.fresh = false;
3812
+ return messageTable;
4055
3813
  };
4056
3814
  _createMessageTable = function _createMessageTable3() {
4057
- _createMessageTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(date, live) {
3815
+ _createMessageTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(date, live) {
4058
3816
  var chatDocument, messageTable, statusTR;
4059
- return _regenerator["default"].wrap(function _callee5$(_context5) {
4060
- while (1) switch (_context5.prev = _context5.next) {
3817
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
3818
+ while (1) switch (_context6.prev = _context6.next) {
4061
3819
  case 0:
4062
3820
  debug.log(' createMessageTable for ' + date);
4063
3821
  chatDocument = dateFolder.leafDocumentFromDate(date);
4064
- _context5.prev = 2;
4065
- _context5.next = 5;
3822
+ _context6.prev = 2;
3823
+ _context6.next = 5;
4066
3824
  return _solidLogic.store.fetcher.load(chatDocument);
4067
3825
  case 5:
4068
- _context5.next = 21;
3826
+ _context6.next = 19;
4069
3827
  break;
4070
3828
  case 7:
4071
- _context5.prev = 7;
4072
- _context5.t0 = _context5["catch"](2);
3829
+ _context6.prev = 7;
3830
+ _context6.t0 = _context6["catch"](2);
4073
3831
  messageTable = dom.createElement('table');
4074
3832
  statusTR = messageTable.appendChild(dom.createElement('tr')); // ### find status in exception
4075
- if (!(_context5.t0.response && _context5.t0.response.status && _context5.t0.response.status === 404)) {
4076
- _context5.next = 18;
3833
+ if (!(_context6.t0.response && _context6.t0.response.status && _context6.t0.response.status === 404)) {
3834
+ _context6.next = 16;
4077
3835
  break;
4078
3836
  }
4079
3837
  debug.log('Error 404 for chat file ' + chatDocument);
4080
- _context5.next = 15;
4081
- return renderMessageTable(date, live);
4082
- case 15:
4083
- return _context5.abrupt("return", _context5.sent);
4084
- case 18:
3838
+ return _context6.abrupt("return", renderMessageTable(date, live));
3839
+ case 16:
4085
3840
  debug.log('*** Error NON 404 for chat file ' + chatDocument);
4086
- statusTR.appendChild(widgets.errorMessageBlock(dom, _context5.t0, 'pink'));
3841
+ statusTR.appendChild(widgets.errorMessageBlock(dom, _context6.t0, 'pink'));
3842
+ case 18:
3843
+ return _context6.abrupt("return", statusTR);
3844
+ case 19:
3845
+ return _context6.abrupt("return", renderMessageTable(date, live));
4087
3846
  case 20:
4088
- return _context5.abrupt("return", statusTR);
4089
- case 21:
4090
- _context5.next = 23;
4091
- return renderMessageTable(date, live);
4092
- case 23:
4093
- return _context5.abrupt("return", _context5.sent);
4094
- case 24:
4095
3847
  case "end":
4096
- return _context5.stop();
3848
+ return _context6.stop();
4097
3849
  }
4098
- }, _callee5, null, [[2, 7]]);
3850
+ }, _callee6, null, [[2, 7]]);
4099
3851
  }));
4100
3852
  return _createMessageTable.apply(this, arguments);
4101
3853
  };
4102
- createMessageTable = function _createMessageTable2(_x16, _x17) {
3854
+ createMessageTable = function _createMessageTable2(_x6, _x7) {
4103
3855
  return _createMessageTable.apply(this, arguments);
4104
3856
  };
4105
3857
  removePreviousMessages = function _removePreviousMessag(backwards, messageTable) {
@@ -4118,48 +3870,32 @@ function _infiniteMessageArea() {
4118
3870
  extr.messageTable = messageTable;
4119
3871
  };
4120
3872
  _insertPreviousMessages = function _insertPreviousMessag2() {
4121
- _insertPreviousMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(backwards) {
3873
+ _insertPreviousMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(backwards) {
4122
3874
  var extremity, date, live, todayDoc, doc, newMessageTable;
4123
- return _regenerator["default"].wrap(function _callee4$(_context4) {
4124
- while (1) switch (_context4.prev = _context4.next) {
3875
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
3876
+ while (1) switch (_context5.prev = _context5.next) {
4125
3877
  case 0:
4126
3878
  extremity = backwards ? earliest : latest;
4127
3879
  date = extremity.messageTable.date; // day in mssecs
4128
- // Are we at the top of a thread?
4129
- if (!(backwards && earliest.limit && date <= earliest.limit)) {
4130
- _context4.next = 7;
4131
- break;
4132
- }
4133
- if (liveMessageTable) {
4134
- _context4.next = 6;
4135
- break;
4136
- }
4137
- _context4.next = 6;
4138
- return appendCurrentMessages();
4139
- case 6:
4140
- return _context4.abrupt("return", true);
4141
- case 7:
4142
- debug.log(' insertPreviousMessages: loadPrevious given date ' + date);
4143
- _context4.next = 10;
3880
+ _context5.next = 4;
4144
3881
  return dateFolder.loadPrevious(date, backwards);
4145
- case 10:
4146
- date = _context4.sent;
3882
+ case 4:
3883
+ date = _context5.sent;
4147
3884
  // backwards
4148
- debug.log(' insertPreviousMessages: loadPrevious returns date ' + date);
4149
3885
  debug.log("insertPreviousMessages: from ".concat(backwards ? 'backwards' : 'forwards', " loadPrevious: ").concat(date));
4150
3886
  if (!(!date && !backwards && !liveMessageTable)) {
4151
- _context4.next = 16;
3887
+ _context5.next = 9;
4152
3888
  break;
4153
3889
  }
4154
- _context4.next = 16;
3890
+ _context5.next = 9;
4155
3891
  return appendCurrentMessages();
4156
- case 16:
3892
+ case 9:
4157
3893
  if (date) {
4158
- _context4.next = 18;
3894
+ _context5.next = 11;
4159
3895
  break;
4160
3896
  }
4161
- return _context4.abrupt("return", true);
4162
- case 18:
3897
+ return _context5.abrupt("return", true);
3898
+ case 11:
4163
3899
  // done
4164
3900
  live = false;
4165
3901
  if (!backwards) {
@@ -4167,10 +3903,10 @@ function _infiniteMessageArea() {
4167
3903
  doc = dateFolder.leafDocumentFromDate(date);
4168
3904
  live = doc.sameTerm(todayDoc); // Is this todays?
4169
3905
  }
4170
- _context4.next = 22;
3906
+ _context5.next = 15;
4171
3907
  return createMessageTable(date, live);
4172
- case 22:
4173
- newMessageTable = _context4.sent;
3908
+ case 15:
3909
+ newMessageTable = _context5.sent;
4174
3910
  extremity.messageTable = newMessageTable; // move pointer to earliest
4175
3911
  if (backwards ? newestFirst : !newestFirst) {
4176
3912
  // put on bottom or top
@@ -4179,181 +3915,64 @@ function _infiniteMessageArea() {
4179
3915
  // put on top as we scroll back
4180
3916
  div.insertBefore(newMessageTable, div.firstChild);
4181
3917
  }
4182
- return _context4.abrupt("return", live);
4183
- case 26:
3918
+ return _context5.abrupt("return", live);
3919
+ case 19:
4184
3920
  case "end":
4185
- return _context4.stop();
3921
+ return _context5.stop();
4186
3922
  }
4187
- }, _callee4);
3923
+ }, _callee5);
4188
3924
  }));
4189
3925
  return _insertPreviousMessages.apply(this, arguments);
4190
3926
  };
4191
- insertPreviousMessages = function _insertPreviousMessag(_x15) {
3927
+ insertPreviousMessages = function _insertPreviousMessag(_x5) {
4192
3928
  return _insertPreviousMessages.apply(this, arguments);
4193
3929
  };
4194
- _addMessage = function _addMessage3() {
4195
- _addMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(message, messageTable) {
4196
- var thread, id;
4197
- return _regenerator["default"].wrap(function _callee3$(_context3) {
4198
- while (1) switch (_context3.prev = _context3.next) {
4199
- case 0:
4200
- if (!((0, _chatLogic.isDeleted)(message) && !options.showDeletedMessages)) {
4201
- _context3.next = 2;
4202
- break;
4203
- }
4204
- return _context3.abrupt("return");
4205
- case 2:
4206
- /* if (isReplaced(message)) { //
4207
- return // this is old version
4208
- } */
4209
- thread = _solidLogic.store.any(null, ns.sioc('has_member'), message, message.doc());
4210
- id = _solidLogic.store.any(message, ns.sioc('id'), null, message.doc());
4211
- if (id && !thread) {
4212
- thread = _solidLogic.store.any(null, ns.sioc('has_member'), id, message.doc());
4213
- }
4214
- if (!options.thread) {
4215
- _context3.next = 18;
4216
- break;
4217
- }
4218
- if (!_solidLogic.store.holds(message, ns.sioc('has_reply'), options.thread)) {
4219
- _context3.next = 10;
4220
- break;
4221
- }
4222
- // root of thread
4223
- debug.log(' addMessage: displaying root of thread ' + thread);
4224
- _context3.next = 16;
4225
- break;
4226
- case 10:
4227
- if (!(thread && thread.sameTerm(options.thread))) {
4228
- _context3.next = 14;
4229
- break;
4230
- }
4231
- debug.log(' addMessage: Displaying body of thread ' + message.uri.slice(-10));
4232
- _context3.next = 16;
4233
- break;
4234
- case 14:
4235
- debug.log(' addMessage: Suppress non-thread message in thread table ' + message.uri.slice(-10));
4236
- return _context3.abrupt("return");
4237
- case 16:
4238
- _context3.next = 24;
4239
- break;
4240
- case 18:
4241
- if (!thread) {
4242
- _context3.next = 23;
4243
- break;
4244
- }
4245
- debug.log(' addMessage: Suppress thread message in non-thread table ' + message.uri.slice(-10));
4246
- return _context3.abrupt("return");
4247
- case 23:
4248
- debug.log(' addMessage: Normal non-thread message in non-thread table ' + message.uri.slice(-10));
4249
- case 24:
4250
- _context3.next = 26;
4251
- return insertMessageIntoTable(channelObject, messageTable, message, messageTable.fresh, options, userContext);
4252
- case 26:
4253
- case "end":
4254
- return _context3.stop();
4255
- }
4256
- }, _callee3);
4257
- }));
4258
- return _addMessage.apply(this, arguments);
4259
- };
4260
- addMessage = function _addMessage2(_x13, _x14) {
4261
- return _addMessage.apply(this, arguments);
4262
- };
4263
- _syncMessages = function _syncMessages3() {
4264
- _syncMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(chatChannel, messageTable) {
4265
- var displayed, ele, ele2, messages, stored, _iterator, _step, m;
4266
- return _regenerator["default"].wrap(function _callee2$(_context2) {
4267
- while (1) switch (_context2.prev = _context2.next) {
4268
- case 0:
4269
- displayed = {};
4270
- for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
4271
- if (ele.AJAR_subject) {
4272
- displayed[ele.AJAR_subject.uri] = true;
4273
- }
4274
- }
4275
- messages = _solidLogic.store.each(chatChannel, ns.wf('message'), null, messageTable.chatDocument);
4276
- stored = {};
4277
- _iterator = _createForOfIteratorHelper(messages);
4278
- _context2.prev = 5;
4279
- _iterator.s();
4280
- case 7:
4281
- if ((_step = _iterator.n()).done) {
4282
- _context2.next = 15;
4283
- break;
4284
- }
4285
- m = _step.value;
4286
- stored[m.uri] = true;
4287
- if (displayed[m.uri]) {
4288
- _context2.next = 13;
4289
- break;
4290
- }
4291
- _context2.next = 13;
4292
- return addMessage(m, messageTable);
4293
- case 13:
4294
- _context2.next = 7;
4295
- break;
4296
- case 15:
4297
- _context2.next = 20;
4298
- break;
4299
- case 17:
4300
- _context2.prev = 17;
4301
- _context2.t0 = _context2["catch"](5);
4302
- _iterator.e(_context2.t0);
4303
- case 20:
4304
- _context2.prev = 20;
4305
- _iterator.f();
4306
- return _context2.finish(20);
4307
- case 23:
4308
- // eslint-disable-next-line space-in-parens
4309
- for (ele = messageTable.firstChild; ele;) {
4310
- ele2 = ele.nextSibling;
4311
- if (ele.AJAR_subject && !stored[ele.AJAR_subject.uri]) {
4312
- messageTable.removeChild(ele);
4313
- }
4314
- ele = ele2;
4315
- }
4316
- for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
4317
- if (ele.AJAR_subject) {
4318
- // Refresh thumbs up etc
4319
- widgets.refreshTree(ele); // Things inside may have changed too
4320
- }
4321
- }
4322
- case 25:
4323
- case "end":
4324
- return _context2.stop();
4325
- }
4326
- }, _callee2, null, [[5, 17, 20, 23]]);
4327
- }));
4328
- return _syncMessages.apply(this, arguments);
3930
+ addMessage = function _addMessage(message, messageTable) {
3931
+ var latest = (0, _chatLogic.mostRecentVersion)(message);
3932
+ // const content = store.any(latest, ns.sioc('content'))
3933
+ if ((0, _chatLogic.isDeleted)(latest) && !options.showDeletedMessages) {
3934
+ return; // ignore deleted messaged -- @@ could also leave a placeholder
3935
+ }
3936
+
3937
+ insertMessageIntoTable(channelObject, messageTable, message, messageTable.fresh, options, userContext); // fresh from elsewhere
4329
3938
  };
4330
- syncMessages = function _syncMessages2(_x11, _x12) {
4331
- return _syncMessages.apply(this, arguments);
4332
- }; // ///////////////////////////////////////////////////////////////////////
4333
- // syncMessages
4334
- // Called once per original message displayed
4335
- /* Add a new messageTable at the top/bottom
4336
- */
4337
- /* Remove message tables earlier than this one
4338
- */
4339
- /* Load and render message table
4340
- ** @returns DOM element generates
4341
- */
4342
- // renderMessageTable
4343
- /*
4344
- function messageCount () {
4345
- var n = 0
4346
- const tables = div.children
4347
- for (let i = 0; i < tables.length; i++) {
4348
- n += tables[i].children.length - 1
4349
- // debug.log(' table length:' + tables[i].children.length)
3939
+ syncMessages = function _syncMessages(about, messageTable) {
3940
+ var displayed = {};
3941
+ var ele, ele2;
3942
+ for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
3943
+ if (ele.AJAR_subject) {
3944
+ displayed[ele.AJAR_subject.uri] = true;
3945
+ }
4350
3946
  }
4351
- return n
4352
- }
4353
- */
4354
- /* Add the live message block with entry field for today
4355
- */
3947
+ var messages = _solidLogic.store.statementsMatching(about, ns.wf('message'), null, messageTable.chatDocument).map(function (st) {
3948
+ return st.object;
3949
+ });
3950
+ var stored = {};
3951
+ messages.forEach(function (m) {
3952
+ stored[m.uri] = true;
3953
+ if (!displayed[m.uri]) {
3954
+ addMessage(m, messageTable);
3955
+ }
3956
+ });
3957
+
3958
+ // eslint-disable-next-line space-in-parens
3959
+ for (ele = messageTable.firstChild; ele;) {
3960
+ ele2 = ele.nextSibling;
3961
+ if (ele.AJAR_subject && !stored[ele.AJAR_subject.uri]) {
3962
+ messageTable.removeChild(ele);
3963
+ }
3964
+ ele = ele2;
3965
+ }
3966
+ for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
3967
+ if (ele.AJAR_subject) {
3968
+ // Refresh thumbs up etc
3969
+ widgets.refreshTree(ele); // Things inside may have changed too
3970
+ }
3971
+ }
3972
+ };
3973
+
4356
3974
  // Body of main function
3975
+
4357
3976
  options = options || {};
4358
3977
  options.authorDateOnLeft = false; // @@ make a user optiosn
4359
3978
  newestFirst = options.newestFirst === '1' || options.newestFirst === true; // hack for now
@@ -4367,33 +3986,23 @@ function _infiniteMessageArea() {
4367
3986
  statusArea: statusArea,
4368
3987
  div: statusArea
4369
3988
  }; // logged on state, pointers to user's stuff
3989
+ // const messageTable = dom.createElement('table') // @@ check does this go in renderMessageTable
4370
3990
  earliest = {
4371
3991
  messageTable: null
4372
3992
  }; // Stuff about each end of the loaded days
4373
3993
  latest = {
4374
3994
  messageTable: null
4375
3995
  };
4376
- if (options.thread) {
4377
- thread = options.thread;
4378
- threadRootMessage = _solidLogic.store.any(null, ns.sioc('has_reply'), thread, thread.doc());
4379
- if (threadRootMessage) {
4380
- threadTime = _solidLogic.store.any(threadRootMessage, ns.dct('created'), null, threadRootMessage.doc());
4381
- if (threadTime) {
4382
- earliest.limit = new Date(threadTime.value);
4383
- debug.log(' inifinite: thread start at ' + earliest.limit);
4384
- }
4385
- }
4386
- }
4387
3996
  lock = false;
4388
- _context15.next = 34;
3997
+ _context12.next = 30;
4389
3998
  return loadInitialContent();
4390
- case 34:
4391
- return _context15.abrupt("return", div);
4392
- case 35:
3999
+ case 30:
4000
+ return _context12.abrupt("return", div);
4001
+ case 31:
4393
4002
  case "end":
4394
- return _context15.stop();
4003
+ return _context12.stop();
4395
4004
  }
4396
- }, _callee15);
4005
+ }, _callee12);
4397
4006
  }));
4398
4007
  return _infiniteMessageArea.apply(this, arguments);
4399
4008
  }
@@ -4665,7 +4274,6 @@ exports.renderMessageEditor = renderMessageEditor;
4665
4274
  exports.renderMessageRow = renderMessageRow;
4666
4275
  exports.switchToEditor = switchToEditor;
4667
4276
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
4668
- var _defineProperty2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"));
4669
4277
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
4670
4278
  var _infinite = __webpack_require__(/*! ./infinite */ "./lib/chat/infinite.js");
4671
4279
  var _messageTools = __webpack_require__(/*! ./messageTools */ "./lib/chat/messageTools.js");
@@ -4685,14 +4293,9 @@ var _signature = __webpack_require__(/*! ./signature */ "./lib/chat/signature.js
4685
4293
  var _keys = __webpack_require__(/*! ./keys */ "./lib/chat/keys.js");
4686
4294
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
4687
4295
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
4688
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4689
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4690
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
4296
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
4691
4297
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4692
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /** UI code for individual messages: display them, edit them
4693
- *
4694
- * @packageDocumentation
4695
- */ /* global $rdf */
4298
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4696
4299
  var dom = window.document;
4697
4300
  var messageBodyStyle = style.messageBodyStyle;
4698
4301
  var label = utils.label;
@@ -4792,275 +4395,158 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
4792
4395
  * @param userContext
4793
4396
  * @returns Message Row HTML Table Element
4794
4397
  */
4795
- function renderMessageRow(_x, _x2, _x3, _x4, _x5) {
4796
- return _renderMessageRow.apply(this, arguments);
4398
+ function renderMessageRow(channelObject, message, fresh, options, userContext) {
4399
+ var unsignedMessage = false;
4400
+ var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
4401
+ var creator = _solidLogic.store.any(message, ns.foaf('maker'));
4402
+ var date = _solidLogic.store.any(message, ns.dct('created'));
4403
+ var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
4404
+ var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
4405
+
4406
+ // use latest content if same owner, else use original
4407
+ var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
4408
+ var content = _solidLogic.store.any(msgId, ns.sioc('content'));
4409
+ var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue")));
4410
+
4411
+ // set message object
4412
+ var msg = (0, _signature.getBlankMsg)();
4413
+ msg.id = msgId.uri;
4414
+ msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
4415
+ msg.content = content.value;
4416
+ msg.maker = creator.uri;
4417
+
4418
+ // unsigned message
4419
+ if (!(signature !== null && signature !== void 0 && signature.value)) {
4420
+ unsignedMessage = true;
4421
+ debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
4422
+ } else {
4423
+ // signed message, get public key and check signature
4424
+ (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4425
+ debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4426
+ if (!publicKey) {
4427
+ // TODO try to recreate the publicKey
4428
+ // if(me.uri === creator.uri) await getPrivateKey(creator)
4429
+ debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4430
+ }
4431
+ // check that publicKey is a valid hex string
4432
+ var regex = /[0-9A-Fa-f]{6}/g;
4433
+ if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
4434
+ // verify signature
4435
+ else if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature === null || signature === void 0 ? void 0 : signature.value, msg, publicKey)) debug.warn('invalid signature\n' + msg.id);
4436
+ });
4437
+ }
4438
+ var originalMessage = (0, _chatLogic.originalVersion)(message);
4439
+ var edited = !message.sameTerm(originalMessage);
4440
+ var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
4441
+
4442
+ var messageRow = dom.createElement('tr');
4443
+ if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
4444
+ messageRow.AJAR_date = sortDate.value;
4445
+ messageRow.AJAR_subject = message;
4446
+ var td1 = dom.createElement('td');
4447
+ messageRow.appendChild(td1);
4448
+ if (!options.authorDateOnLeft) {
4449
+ var img = dom.createElement('img');
4450
+ img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
4451
+ widgets.setImage(img, creator);
4452
+ td1.appendChild(img);
4453
+ } else {
4454
+ creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
4455
+ }
4456
+ var bothDates = widgets.shortDate(sortDate.value);
4457
+ if (edited) {
4458
+ bothDates += ' ... ' + widgets.shortDate(date.value);
4459
+ }
4460
+
4461
+ // Render the content ot the message itself
4462
+ var td2 = messageRow.appendChild(dom.createElement('td'));
4463
+ if (!options.authorDateOnLeft) {
4464
+ creatorAndDateHorizontal(td2, creator, bothDates,
4465
+ // widgets.shortDate(dateString)
4466
+ message);
4467
+ }
4468
+ var text = content.value.trim();
4469
+ var isURI = /^https?:\/[^ <>]*$/i.test(text);
4470
+ var para = null;
4471
+ if (isURI) {
4472
+ var isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
4473
+ if (isImage && options.expandImagesInline) {
4474
+ var _img = elementForImageURI(text, options);
4475
+ td2.appendChild(_img);
4476
+ } else {
4477
+ // Link but not Image
4478
+ var anc = td2.appendChild(dom.createElement('a'));
4479
+ para = anc.appendChild(dom.createElement('p'));
4480
+ anc.href = text;
4481
+ para.textContent = text;
4482
+ td2.appendChild(anc);
4483
+ }
4484
+ } else {
4485
+ // text
4486
+ para = dom.createElement('p');
4487
+ td2.appendChild(para);
4488
+ para.textContent = text;
4489
+ }
4490
+ if (para) {
4491
+ var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
4492
+ para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
4493
+ }
4494
+ function getBgColor(fresh) {
4495
+ return fresh ? '#e8ffe8' : 'white';
4496
+ }
4497
+
4498
+ // Sentiment strip
4499
+ var strip = (0, _messageTools.sentimentStripLinked)(message, message.doc());
4500
+ if (strip.children.length) {
4501
+ td2.appendChild(dom.createElement('br'));
4502
+ td2.appendChild(strip);
4503
+ }
4504
+
4505
+ // Message tool bar button
4506
+ var td3 = dom.createElement('td');
4507
+ messageRow.appendChild(td3);
4508
+ var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
4509
+ td3.appendChild(toolsButton);
4510
+ toolsButton.addEventListener('click', function (_event) {
4511
+ if (messageRow.toolTR) {
4512
+ // already got a toolbar? Toogle
4513
+ messageRow.parentNode.removeChild(messageRow.toolTR);
4514
+ delete messageRow.toolTR;
4515
+ return;
4516
+ }
4517
+ var toolsTR = dom.createElement('tr');
4518
+ var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
4519
+ tools.style = 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;'; // @@ fix
4520
+ if (messageRow.nextSibling) {
4521
+ messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
4522
+ } else {
4523
+ messageRow.parentElement.appendChild(toolsTR);
4524
+ }
4525
+ messageRow.toolTR = toolsTR;
4526
+ toolsTR.appendChild(dom.createElement('td')); // left
4527
+ var toolsTD = toolsTR.appendChild(dom.createElement('td'));
4528
+ toolsTR.appendChild(dom.createElement('td')); // right
4529
+ toolsTD.appendChild(tools);
4530
+ });
4531
+ return messageRow;
4797
4532
  } // END OF RENDERMESSAGE
4798
- function _renderMessageRow() {
4799
- _renderMessageRow = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(channelObject, message, fresh, options, userContext) {
4800
- var unsignedMessage, colorizeByAuthor, creator, date, latestVersion, latestVersionCreator, msgId, content, versions, replies, thread, straightReplies, _iterator2, _step2, reply, signature, msg, originalMessage, edited, sortDate, messageRow, td1, img, bothDates, td2, text, isURI, para, isImage, _img, anc, bgcolor, getBgColor, strip, td3, toolsButton;
4801
- return _regenerator["default"].wrap(function _callee9$(_context10) {
4802
- while (1) switch (_context10.prev = _context10.next) {
4803
- case 0:
4804
- getBgColor = function _getBgColor(fresh) {
4805
- return fresh ? '#e8ffe8' : 'white';
4806
- };
4807
- unsignedMessage = false;
4808
- colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true; // const id = store.any(latestVersion, ns.sioc('id'))
4809
- // const replies = store.each(latestVersion, ns.sioc('has_reply'))
4810
- creator = _solidLogic.store.any(message, ns.foaf('maker'));
4811
- date = _solidLogic.store.any(message, ns.dct('created'));
4812
- _context10.next = 7;
4813
- return (0, _chatLogic.mostRecentVersion)(message);
4814
- case 7:
4815
- latestVersion = _context10.sent;
4816
- debug.log('@@@@ alain mostRecentVersion');
4817
- debug.log(message);
4818
- debug.log(latestVersion);
4819
- latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker')); // use latest content if same owner, else use original
4820
- // this is may be too strict. Should we find latest valid version if any ?
4821
- debug.log('@@@@ alain creator');
4822
- debug.log(creator);
4823
- debug.log(latestVersionCreator);
4824
- msgId = creator.uri === (latestVersionCreator === null || latestVersionCreator === void 0 ? void 0 : latestVersionCreator.uri) ? latestVersion : message;
4825
- content = _solidLogic.store.any(msgId, ns.sioc('content'));
4826
- _context10.next = 19;
4827
- return (0, _chatLogic.allVersions)(msgId);
4828
- case 19:
4829
- versions = _context10.sent;
4830
- if (versions.length > 1) {
4831
- debug.log('renderMessageRow versions: ', versions.join(', '));
4832
- }
4833
- // be tolerant in accepting replies on any version of a message
4834
- replies = versions.map(function (version) {
4835
- return _solidLogic.store.each(version, ns.sioc('has_reply'));
4836
- }).flat();
4837
- thread = null;
4838
- straightReplies = [];
4839
- _iterator2 = _createForOfIteratorHelper(replies);
4840
- try {
4841
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4842
- reply = _step2.value;
4843
- if (_solidLogic.store.holds(reply, ns.rdf('type'), ns.sioc('Thread'))) {
4844
- thread = reply;
4845
- debug.log('renderMessageRow: found thread: ' + thread);
4846
- } else {
4847
- straightReplies.push(reply);
4848
- }
4849
- }
4850
- } catch (err) {
4851
- _iterator2.e(err);
4852
- } finally {
4853
- _iterator2.f();
4854
- }
4855
- if (straightReplies.length > 1) {
4856
- debug.log('renderMessageRow: found normal replies: ', straightReplies);
4857
- }
4858
- debug.log('@@@@ is thread');
4859
- if (!thread) {
4860
- // thread = store.any(message, ns.sioc('has_reply'))
4861
- thread = _solidLogic.store.any(null, ns.sioc('has_member'), message);
4862
- }
4863
- // get signature
4864
- signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue"))); // set proof message object
4865
- msg = (0, _signature.getBlankMsg)();
4866
- msg.id = msgId.uri;
4867
- msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
4868
- msg.content = content.value;
4869
- msg.maker = creator.uri;
4870
-
4871
- // verify signature
4872
- if (!(signature !== null && signature !== void 0 && signature.value)) {
4873
- // unsigned message
4874
- unsignedMessage = true;
4875
- debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
4876
- } else {
4877
- // signed message, get public key and check signature
4878
- (0, _keys.getPublicKey)(creator).then(function (publicKey) {
4879
- debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
4880
- if (!publicKey) {
4881
- debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
4882
- }
4883
- // check that publicKey is a valid hex string
4884
- var regex = /[0-9A-Fa-f]{6}/g;
4885
- if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
4886
- // verify signature
4887
- else if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature === null || signature === void 0 ? void 0 : signature.value, msg, publicKey)) debug.warn('invalid signature\n' + msg.id);
4888
- });
4889
- }
4890
- _context10.next = 38;
4891
- return (0, _chatLogic.originalVersion)(message);
4892
- case 38:
4893
- originalMessage = _context10.sent;
4894
- edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
4895
- // @@@ kludge!
4896
- sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) || _solidLogic.store.the(message, ns.dct('created'), null, message.doc()); // In message
4897
- messageRow = dom.createElement('tr');
4898
- if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
4899
- messageRow.AJAR_date = sortDate.value;
4900
- messageRow.AJAR_subject = message;
4901
- td1 = dom.createElement('td');
4902
- messageRow.appendChild(td1);
4903
- if (!options.authorDateOnLeft) {
4904
- img = dom.createElement('img');
4905
- img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
4906
- widgets.setImage(img, creator);
4907
- td1.appendChild(img);
4908
- } else {
4909
- creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
4910
- }
4911
- bothDates = widgets.shortDate(sortDate.value);
4912
- if (edited) {
4913
- bothDates += ' ... ' + widgets.shortDate(date.value);
4914
- }
4915
4533
 
4916
- // Render the content ot the message itself
4917
- td2 = messageRow.appendChild(dom.createElement('td'));
4918
- if (!options.authorDateOnLeft) {
4919
- creatorAndDateHorizontal(td2, creator, bothDates,
4920
- // widgets.shortDate(dateString)
4921
- message);
4922
- }
4923
- text = content ? content.value.trim() : '??? no content?';
4924
- isURI = /^https?:\/[^ <>]*$/i.test(text);
4925
- para = null;
4926
- if (isURI) {
4927
- isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
4928
- if (isImage && options.expandImagesInline) {
4929
- _img = elementForImageURI(text, options);
4930
- td2.appendChild(_img);
4931
- } else {
4932
- // Link but not Image
4933
- anc = td2.appendChild(dom.createElement('a'));
4934
- para = anc.appendChild(dom.createElement('p'));
4935
- anc.href = text;
4936
- para.textContent = text;
4937
- td2.appendChild(anc);
4938
- }
4939
- } else {
4940
- // text
4941
- para = dom.createElement('p');
4942
- td2.appendChild(para);
4943
- para.textContent = text;
4944
- }
4945
- if (para) {
4946
- bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
4947
- para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
4948
- }
4949
- _context10.next = 59;
4950
- return (0, _messageTools.sentimentStripLinked)(message, message.doc());
4951
- case 59:
4952
- strip = _context10.sent;
4953
- if (strip.children.length) {
4954
- td2.appendChild(dom.createElement('br'));
4955
- td2.appendChild(strip);
4956
- }
4957
-
4958
- // Message tool bar button
4959
- td3 = dom.createElement('td');
4960
- messageRow.appendChild(td3);
4961
- toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
4962
- td3.appendChild(toolsButton);
4963
- toolsButton.addEventListener('click', /*#__PURE__*/function () {
4964
- var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_event) {
4965
- var toolsTR, tools, toolsTD;
4966
- return _regenerator["default"].wrap(function _callee8$(_context9) {
4967
- while (1) switch (_context9.prev = _context9.next) {
4968
- case 0:
4969
- if (!messageRow.toolTR) {
4970
- _context9.next = 4;
4971
- break;
4972
- }
4973
- // already got a toolbar? Toogle
4974
- messageRow.parentNode.removeChild(messageRow.toolTR);
4975
- delete messageRow.toolTR;
4976
- return _context9.abrupt("return");
4977
- case 4:
4978
- toolsTR = dom.createElement('tr');
4979
- _context9.next = 7;
4980
- return (0, _messageTools.messageToolbar)(message, messageRow, _objectSpread(_objectSpread({}, userContext), {}, {
4981
- chatOptions: options
4982
- }), channelObject);
4983
- case 7:
4984
- tools = _context9.sent;
4985
- tools.style = 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;'; // @@ fix
4986
- if (messageRow.nextSibling) {
4987
- messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
4988
- } else {
4989
- messageRow.parentElement.appendChild(toolsTR);
4990
- }
4991
- messageRow.toolTR = toolsTR;
4992
- toolsTR.appendChild(dom.createElement('td')); // left
4993
- toolsTD = toolsTR.appendChild(dom.createElement('td'));
4994
- toolsTR.appendChild(dom.createElement('td')); // right
4995
- toolsTD.appendChild(tools);
4996
- case 15:
4997
- case "end":
4998
- return _context9.stop();
4999
- }
5000
- }, _callee8);
5001
- }));
5002
- return function (_x20) {
5003
- return _ref4.apply(this, arguments);
5004
- };
5005
- }());
5006
- if (thread && options.showThread) {
5007
- debug.log(' message has thread ' + thread);
5008
- td3.appendChild(widgets.button(dom, _iconBase.icons.iconBase + 'noun_1180164.svg',
5009
- // right arrow .. @@ think of stg better
5010
- 'see thread', function (_e) {
5011
- debug.log('@@@@ Calling showThread thread ' + thread);
5012
- options.showThread(thread, options);
5013
- }));
5014
- }
5015
- return _context10.abrupt("return", messageRow);
5016
- case 68:
5017
- case "end":
5018
- return _context10.stop();
5019
- }
5020
- }, _callee9);
5021
- }));
5022
- return _renderMessageRow.apply(this, arguments);
5023
- }
5024
- function switchToEditor(_x6, _x7, _x8, _x9) {
5025
- return _switchToEditor.apply(this, arguments);
4534
+ function switchToEditor(messageRow, message, channelObject, userContext) {
4535
+ var messageTable = messageRow.parentNode;
4536
+ var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
4537
+ messageTable.insertBefore(editRow, messageRow);
4538
+ editRow.originalRow = messageRow;
4539
+ messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
5026
4540
  }
5027
4541
  /* Control for a new message -- or editing an old message ***************
5028
4542
  *
5029
4543
  */
5030
- function _switchToEditor() {
5031
- _switchToEditor = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(messageRow, message, channelObject, userContext) {
5032
- var messageTable, editRow;
5033
- return _regenerator["default"].wrap(function _callee10$(_context11) {
5034
- while (1) switch (_context11.prev = _context11.next) {
5035
- case 0:
5036
- messageTable = messageRow.parentNode;
5037
- _context11.t0 = renderMessageEditor;
5038
- _context11.t1 = channelObject;
5039
- _context11.t2 = messageTable;
5040
- _context11.t3 = userContext;
5041
- _context11.t4 = channelObject.options;
5042
- _context11.next = 8;
5043
- return (0, _chatLogic.mostRecentVersion)(message);
5044
- case 8:
5045
- _context11.t5 = _context11.sent;
5046
- editRow = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t3, _context11.t4, _context11.t5);
5047
- messageTable.insertBefore(editRow, messageRow);
5048
- editRow.originalRow = messageRow;
5049
- messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
5050
- case 13:
5051
- case "end":
5052
- return _context11.stop();
5053
- }
5054
- }, _callee10);
5055
- }));
5056
- return _switchToEditor.apply(this, arguments);
5057
- }
5058
4544
  function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
5059
4545
  function revertEditing(messageEditor) {
5060
4546
  messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
5061
4547
  messageEditor.parentNode.removeChild(messageEditor);
5062
4548
  }
5063
- function handleFieldInput(_x10) {
4549
+ function handleFieldInput(_x) {
5064
4550
  return _handleFieldInput.apply(this, arguments);
5065
4551
  }
5066
4552
  function _handleFieldInput() {
@@ -5078,86 +4564,70 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
5078
4564
  }));
5079
4565
  return _handleFieldInput.apply(this, arguments);
5080
4566
  }
5081
- function sendMessage(_x11, _x12) {
4567
+ function sendMessage(_x2, _x3) {
5082
4568
  return _sendMessage.apply(this, arguments);
5083
4569
  } // sendMessage
5084
4570
  // DRAG AND DROP
5085
4571
  function _sendMessage() {
5086
- _sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(text, fromMainField) {
5087
- var sendComplete, _sendComplete, message, statusArea;
5088
- return _regenerator["default"].wrap(function _callee7$(_context8) {
5089
- while (1) switch (_context8.prev = _context8.next) {
4572
+ _sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
4573
+ var sendComplete, message, statusArea;
4574
+ return _regenerator["default"].wrap(function _callee6$(_context7) {
4575
+ while (1) switch (_context7.prev = _context7.next) {
5090
4576
  case 0:
5091
- _sendComplete = function _sendComplete3() {
5092
- _sendComplete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(message, _text2) {
5093
- var oldRow;
5094
- return _regenerator["default"].wrap(function _callee6$(_context7) {
5095
- while (1) switch (_context7.prev = _context7.next) {
5096
- case 0:
5097
- _context7.next = 2;
5098
- return (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext);
5099
- case 2:
5100
- // not green
5101
-
5102
- if (originalMessage) {
5103
- // editing another message
5104
- oldRow = messageEditor.originalRow; // oldRow.style.display = '' // restore read-only version, re-attack
5105
- if (oldRow.parentNode) {
5106
- oldRow.parentNode.removeChild(oldRow); // No longer needed old version
5107
- } else {
5108
- debug.warn('No parentNode on old message ' + oldRow.textContent);
5109
- oldRow.style.backgroundColor = '#fee';
5110
- oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
5111
- }
4577
+ sendComplete = function _sendComplete(message, _text2) {
4578
+ (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
4579
+
4580
+ if (originalMessage) {
4581
+ // editing another message
4582
+ var oldRow = messageEditor.originalRow;
4583
+ // oldRow.style.display = '' // restore read-only version, re-attack
4584
+ if (oldRow.parentNode) {
4585
+ oldRow.parentNode.removeChild(oldRow); // No longer needed old version
4586
+ } else {
4587
+ debug.warn('No parentNode on old message ' + oldRow.textContent);
4588
+ oldRow.style.backgroundColor = '#fee';
4589
+ oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
4590
+ }
5112
4591
 
5113
- messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
5114
- } else {
5115
- if (fromMainField) {
5116
- field.value = ''; // clear from out for reuse
5117
- field.setAttribute('style', messageBodyStyle);
5118
- field.disabled = false;
5119
- field.scrollIntoView(options.newestFirst); // allign bottom (top)
5120
- field.focus(); // Start typing next line immediately
5121
- field.select();
5122
- }
5123
- }
5124
- // await channelObject.div.refresh() // Add new day if nec @@ add back
5125
- case 3:
5126
- case "end":
5127
- return _context7.stop();
5128
- }
5129
- }, _callee6);
5130
- }));
5131
- return _sendComplete.apply(this, arguments);
4592
+ messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
4593
+ } else {
4594
+ if (fromMainField) {
4595
+ field.value = ''; // clear from out for reuse
4596
+ field.setAttribute('style', messageBodyStyle);
4597
+ field.disabled = false;
4598
+ field.scrollIntoView(options.newestFirst); // allign bottom (top)
4599
+ field.focus(); // Start typing next line immediately
4600
+ field.select();
4601
+ }
4602
+ }
4603
+ // await channelObject.div.refresh() // Add new day if nec @@ add back
5132
4604
  };
5133
- sendComplete = function _sendComplete2(_x18, _x19) {
5134
- return _sendComplete.apply(this, arguments);
5135
- }; // const me = authn.currentUser() // Must be logged on or wuld have got login button
4605
+
4606
+ // const me = authn.currentUser() // Must be logged on or wuld have got login button
5136
4607
  if (fromMainField) {
5137
4608
  field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
5138
4609
  field.disabled = true;
5139
4610
  }
5140
- _context8.prev = 3;
5141
- _context8.next = 6;
5142
- return channelObject.updateMessage(text, originalMessage, null, options.thread);
5143
- case 6:
5144
- message = _context8.sent;
5145
- _context8.next = 14;
4611
+ _context7.prev = 2;
4612
+ _context7.next = 5;
4613
+ return channelObject.updateMessage(text, originalMessage);
4614
+ case 5:
4615
+ message = _context7.sent;
4616
+ _context7.next = 13;
5146
4617
  break;
5147
- case 9:
5148
- _context8.prev = 9;
5149
- _context8.t0 = _context8["catch"](3);
4618
+ case 8:
4619
+ _context7.prev = 8;
4620
+ _context7.t0 = _context7["catch"](2);
5150
4621
  statusArea = userContext.statusArea || messageEditor;
5151
- statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context8.t0));
5152
- return _context8.abrupt("return");
4622
+ statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
4623
+ return _context7.abrupt("return");
4624
+ case 13:
4625
+ sendComplete(message, text);
5153
4626
  case 14:
5154
- _context8.next = 16;
5155
- return sendComplete(message, text);
5156
- case 16:
5157
4627
  case "end":
5158
- return _context8.stop();
4628
+ return _context7.stop();
5159
4629
  }
5160
- }, _callee7, null, [[3, 9]]);
4630
+ }, _callee6, null, [[2, 8]]);
5161
4631
  }));
5162
4632
  return _sendMessage.apply(this, arguments);
5163
4633
  }
@@ -5176,7 +4646,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
5176
4646
  }
5177
4647
  }, _callee);
5178
4648
  }));
5179
- return function (_x13, _x14) {
4649
+ return function (_x4, _x5) {
5180
4650
  return _ref.apply(this, arguments);
5181
4651
  };
5182
4652
  }());
@@ -5220,7 +4690,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
5220
4690
  }
5221
4691
  }, _callee2, null, [[1, 11, 14, 17]]);
5222
4692
  }));
5223
- return function droppedURIHandler(_x15) {
4693
+ return function droppedURIHandler(_x6) {
5224
4694
  return _ref2.apply(this, arguments);
5225
4695
  };
5226
4696
  }();
@@ -5231,7 +4701,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
5231
4701
  imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
5232
4702
  return imageDoc;
5233
4703
  }
5234
- function tookPicture(_x16) {
4704
+ function tookPicture(_x7) {
5235
4705
  return _tookPicture.apply(this, arguments);
5236
4706
  } // Body of turnOnInput
5237
4707
  function _tookPicture() {
@@ -5308,7 +4778,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
5308
4778
  }
5309
4779
  }, _callee3);
5310
4780
  }));
5311
- return function (_x17) {
4781
+ return function (_x8) {
5312
4782
  return _ref3.apply(this, arguments);
5313
4783
  };
5314
4784
  }(), false);
@@ -5370,7 +4840,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
5370
4840
  turnOnInput();
5371
4841
  Object.assign(context, userContext);
5372
4842
  (0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {
5373
- // debug.log('Bookmark file: ' + context.bookmarkDocument)
4843
+ // console.log('Bookmark file: ' + context.bookmarkDocument)
5374
4844
  });
5375
4845
  });
5376
4846
  return messageEditor;
@@ -5393,15 +4863,12 @@ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_m
5393
4863
  Object.defineProperty(exports, "__esModule", ({
5394
4864
  value: true
5395
4865
  }));
5396
- exports.ActionClassFromEmoji = ActionClassFromEmoji;
5397
- exports.emojiFromAction = emojiFromAction;
5398
- exports.emojiFromActionClass = emojiFromActionClass;
5399
4866
  exports.messageToolbar = messageToolbar;
5400
4867
  exports.sentimentStrip = sentimentStrip;
5401
4868
  exports.sentimentStripLinked = sentimentStripLinked;
5402
4869
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
5403
- var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"));
5404
4870
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
4871
+ var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"));
5405
4872
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
5406
4873
  var _iconBase = __webpack_require__(/*! ../iconBase */ "./lib/iconBase.js");
5407
4874
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
@@ -5429,6 +4896,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
5429
4896
  // import * as pad from '../pad'
5430
4897
  // pull in first avoid cross-refs
5431
4898
  // import * as style from '../style'
4899
+
5432
4900
  var dom = window.document;
5433
4901
 
5434
4902
  // THE UNUSED ICONS are here as reminders for possible future functionality
@@ -5441,46 +4909,30 @@ var PENCIL_ICON = 'noun_253504.svg'; // edit a message
5441
4909
  // const SPANNER_ICON = 'noun_344563.svg' -> settings
5442
4910
  var THUMBS_UP_ICON = 'noun_1384132.svg';
5443
4911
  var THUMBS_DOWN_ICON = 'noun_1384135.svg';
5444
- var REPLY_ICON = 'noun-reply-5506924.svg';
5445
4912
  /**
5446
4913
  * Emoji in Unicode
5447
4914
  */
5448
- var emojiMap = {};
5449
- emojiMap[ns.schema('AgreeAction')] = '👍';
5450
- emojiMap[ns.schema('DisagreeAction')] = '👎';
5451
- emojiMap[ns.schema('EndorseAction')] = '⭐️';
5452
- emojiMap[ns.schema('LikeAction')] = '❤️';
5453
- function emojiFromActionClass(action) {
5454
- return emojiMap[action] || null;
5455
- }
5456
- function ActionClassFromEmoji(emoji) {
5457
- for (var a in emojiMap) {
5458
- if (emojiMap[a] === emoji) {
5459
- return rdf.sym(a.slice(1, -1)); // remove < >
5460
- }
5461
- }
5462
-
5463
- return null;
5464
- }
5465
-
5466
- // Allow the action to give its own emoji as content,
5467
- // or get the emoji from the class of action.
5468
- function emojiFromAction(action) {
5469
- var content = _solidLogic.store.any(action, ns.sioc('content'), null, action.doc());
5470
- if (content) return content;
5471
- var klass = _solidLogic.store.any(action, ns.rdf('type'), null, action.doc());
5472
- if (klass) {
5473
- var em = emojiFromActionClass(klass);
5474
- if (em) return em;
5475
- }
5476
- return '⬜️';
5477
- }
4915
+ var emoji = {};
4916
+ emoji[ns.schema('AgreeAction')] = '👍';
4917
+ emoji[ns.schema('DisagreeAction')] = '👎';
4918
+ emoji[ns.schema('EndorseAction')] = '⭐️';
4919
+ emoji[ns.schema('LikeAction')] = '❤️';
5478
4920
 
5479
4921
  /**
5480
4922
  * Create strip of sentiments expressed
5481
4923
  */
5482
- function sentimentStrip(_x, _x2) {
5483
- return _sentimentStrip.apply(this, arguments);
4924
+ function sentimentStrip(target, doc) {
4925
+ // alain seems not used
4926
+ var latest = (0, _chatLogic.mostRecentVersion)(target);
4927
+ var actions = _solidLogic.store.holds(latest, ns.schema('dateDeleted').value, null, latest.doc()) ? _solidLogic.store.each(null, ns.schema('target'), target, doc) : [];
4928
+ var sentiments = actions.map(function (a) {
4929
+ return _solidLogic.store.any(a, ns.rdf('type'), null, doc);
4930
+ });
4931
+ sentiments.sort();
4932
+ var strings = sentiments.map(function (x) {
4933
+ return emoji[x] || '';
4934
+ });
4935
+ return dom.createTextNode(strings.join(' '));
5484
4936
  }
5485
4937
  /**
5486
4938
  * Create strip of sentiments expressed, with hyperlinks
@@ -5488,444 +4940,276 @@ function sentimentStrip(_x, _x2) {
5488
4940
  * @param target {NamedNode} - The thing about which they are expressed
5489
4941
  * @param doc {NamedNode} - The document in which they are expressed
5490
4942
  */
5491
- function _sentimentStrip() {
5492
- _sentimentStrip = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(target, doc) {
5493
- var versions, actions, strings;
5494
- return _regenerator["default"].wrap(function _callee$(_context) {
5495
- while (1) switch (_context.prev = _context.next) {
5496
- case 0:
5497
- _context.next = 2;
5498
- return (0, _chatLogic.allVersions)(target);
5499
- case 2:
5500
- versions = _context.sent;
5501
- debug.log('sentimentStrip Versions for ' + target, versions);
5502
- actions = versions.map(function (version) {
5503
- return _solidLogic.store.each(null, ns.schema('target'), version, doc);
5504
- }).flat();
5505
- debug.log('sentimentStrip: Actions for ' + target, actions);
5506
- strings = actions.map(function (action) {
5507
- return emojiFromAction(action) || '';
5508
- });
5509
- return _context.abrupt("return", dom.createTextNode(strings.join(' ')));
5510
- case 8:
5511
- case "end":
5512
- return _context.stop();
4943
+ function sentimentStripLinked(target, doc) {
4944
+ var strip = dom.createElement('span');
4945
+ function refresh() {
4946
+ strip.innerHTML = '';
4947
+ var actions = (0, _chatLogic.mostRecentVersion)(target).uri !== ns.schema('dateDeleted').uri ? _solidLogic.store.each(null, ns.schema('target'), target, doc) : [];
4948
+ var sentiments = actions.map(function (a) {
4949
+ return [_solidLogic.store.any(a, ns.rdf('type'), null, doc), _solidLogic.store.any(a, ns.schema('agent'), null, doc)];
4950
+ });
4951
+ sentiments.sort();
4952
+ sentiments.forEach(function (ss) {
4953
+ var _ss = (0, _slicedToArray2["default"])(ss, 2),
4954
+ theClass = _ss[0],
4955
+ agent = _ss[1];
4956
+ var res;
4957
+ if (agent) {
4958
+ res = dom.createElement('a');
4959
+ res.setAttribute('href', agent.uri);
4960
+ } else {
4961
+ res = dom.createTextNode('');
5513
4962
  }
5514
- }, _callee);
5515
- }));
5516
- return _sentimentStrip.apply(this, arguments);
5517
- }
5518
- function sentimentStripLinked(_x3, _x4) {
5519
- return _sentimentStripLinked.apply(this, arguments);
4963
+ res.textContent = emoji[theClass] || '*';
4964
+ strip.appendChild(res);
4965
+ });
4966
+ }
4967
+ refresh();
4968
+ strip.refresh = refresh;
4969
+ return strip;
5520
4970
  }
5521
4971
  /**
5522
4972
  * Creates a message toolbar component
5523
4973
  */
5524
- function _sentimentStripLinked() {
5525
- _sentimentStripLinked = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(target, doc) {
5526
- var strip, refresh, _refresh;
5527
- return _regenerator["default"].wrap(function _callee3$(_context3) {
5528
- while (1) switch (_context3.prev = _context3.next) {
5529
- case 0:
5530
- _refresh = function _refresh3() {
5531
- _refresh = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
5532
- var versions, actions, sentiments;
5533
- return _regenerator["default"].wrap(function _callee2$(_context2) {
5534
- while (1) switch (_context2.prev = _context2.next) {
5535
- case 0:
5536
- strip.innerHTML = '';
5537
- if (!(0, _chatLogic.isDeleted)(target)) {
5538
- _context2.next = 3;
5539
- break;
5540
- }
5541
- return _context2.abrupt("return", strip);
5542
- case 3:
5543
- _context2.next = 5;
5544
- return (0, _chatLogic.allVersions)(target);
5545
- case 5:
5546
- versions = _context2.sent;
5547
- debug.log('sentimentStripLinked: Versions for ' + target, versions);
5548
- actions = versions.map(function (version) {
5549
- return _solidLogic.store.each(null, ns.schema('target'), version, doc);
5550
- }).flat();
5551
- debug.log('sentimentStripLinked: Actions for ' + target, actions);
5552
- if (!(actions.length === 0)) {
5553
- _context2.next = 11;
5554
- break;
5555
- }
5556
- return _context2.abrupt("return", strip);
5557
- case 11:
5558
- sentiments = actions.map(function (a) {
5559
- return [_solidLogic.store.any(a, ns.rdf('type'), null, doc), _solidLogic.store.any(a, ns.sioc('content'), null, doc), _solidLogic.store.any(a, ns.schema('agent'), null, doc)];
5560
- });
5561
- debug.log(' Actions sentiments ', sentiments);
5562
- sentiments.sort();
5563
- sentiments.forEach(function (ss) {
5564
- var _ss = (0, _slicedToArray2["default"])(ss, 3),
5565
- theClass = _ss[0],
5566
- content = _ss[1],
5567
- agent = _ss[2];
5568
- var res;
5569
- if (agent) {
5570
- res = dom.createElement('a');
5571
- res.setAttribute('href', agent.uri);
5572
- } else {
5573
- res = dom.createTextNode('');
5574
- }
5575
- res.textContent = content || emojiMap[theClass] || '⬜️';
5576
- strip.appendChild(res);
5577
- });
5578
- debug.log(' Actions strip ', strip);
5579
- case 16:
5580
- case "end":
5581
- return _context2.stop();
5582
- }
5583
- }, _callee2);
5584
- }));
5585
- return _refresh.apply(this, arguments);
5586
- };
5587
- refresh = function _refresh2() {
5588
- return _refresh.apply(this, arguments);
5589
- };
5590
- strip = dom.createElement('span');
5591
- refresh().then(debug.log('sentimentStripLinked: sentimentStripLinked async refreshed'));
5592
- strip.refresh = refresh;
5593
- return _context3.abrupt("return", strip);
5594
- case 6:
5595
- case "end":
5596
- return _context3.stop();
5597
- }
5598
- }, _callee3);
5599
- }));
5600
- return _sentimentStripLinked.apply(this, arguments);
5601
- }
5602
- function messageToolbar(_x5, _x6, _x7, _x8) {
5603
- return _messageToolbar.apply(this, arguments);
5604
- }
5605
- function _messageToolbar() {
5606
- _messageToolbar = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(message, messageRow, userContext, channelObject) {
5607
- var deleteMessage, _deleteMessage, editMessage, _editMessage, replyInThread, _replyInThread, div, closeToolbar, deleteThingThen, _deleteThingThen, me, sentimentButton, context1, cancelButton;
5608
- return _regenerator["default"].wrap(function _callee10$(_context10) {
5609
- while (1) switch (_context10.prev = _context10.next) {
5610
- case 0:
5611
- sentimentButton = function _sentimentButton(context, target, icon, actionClass, doc, mutuallyExclusive) {
5612
- function setColor() {
5613
- button.style.backgroundColor = action ? 'yellow' : 'white';
5614
- }
5615
- var button = widgets.button(dom, icon, utils.label(actionClass), /*#__PURE__*/function () {
5616
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_event) {
5617
- var insertMe, dirty, i, a;
5618
- return _regenerator["default"].wrap(function _callee4$(_context4) {
5619
- while (1) switch (_context4.prev = _context4.next) {
5620
- case 0:
5621
- if (!action) {
5622
- _context4.next = 7;
5623
- break;
5624
- }
5625
- _context4.next = 3;
5626
- return deleteThingThen(action);
5627
- case 3:
5628
- action = null;
5629
- setColor();
5630
- _context4.next = 25;
5631
- break;
5632
- case 7:
5633
- // no action
5634
- action = widgets.newThing(doc);
5635
- insertMe = [rdf.st(action, ns.schema('agent'), context.me, doc), rdf.st(action, ns.rdf('type'), actionClass, doc), rdf.st(action, ns.schema('target'), target, doc)];
5636
- _context4.next = 11;
5637
- return _solidLogic.store.updater.update([], insertMe);
5638
- case 11:
5639
- setColor();
5640
- if (!mutuallyExclusive) {
5641
- _context4.next = 25;
5642
- break;
5643
- }
5644
- // Delete incompative sentiments
5645
- dirty = false;
5646
- i = 0;
5647
- case 15:
5648
- if (!(i < mutuallyExclusive.length)) {
5649
- _context4.next = 24;
5650
- break;
5651
- }
5652
- a = existingAction(mutuallyExclusive[i]);
5653
- if (!a) {
5654
- _context4.next = 21;
5655
- break;
5656
- }
5657
- _context4.next = 20;
5658
- return deleteThingThen(a);
5659
- case 20:
5660
- // but how refresh? refreshTree the parent?
5661
- dirty = true;
5662
- case 21:
5663
- i++;
5664
- _context4.next = 15;
5665
- break;
5666
- case 24:
5667
- if (dirty) {
5668
- // widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
5669
- widgets.refreshTree(messageRow); // requires them all to be immediate siblings
5670
- }
5671
- case 25:
5672
- case "end":
5673
- return _context4.stop();
5674
- }
5675
- }, _callee4);
5676
- }));
5677
- return function (_x11) {
5678
- return _ref.apply(this, arguments);
5679
- };
5680
- }());
5681
- function existingAction(actionClass) {
5682
- var actions = _solidLogic.store.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
5683
- return _solidLogic.store.holds(x, ns.rdf('type'), actionClass, doc);
5684
- }).filter(function (x) {
5685
- return _solidLogic.store.holds(x, ns.schema('target'), target, doc);
5686
- });
5687
- return actions.length ? actions[0] : null;
4974
+ function messageToolbar(message, messageRow, userContext, channelObject) {
4975
+ function deleteMessage() {
4976
+ return _deleteMessage.apply(this, arguments);
4977
+ }
4978
+ function _deleteMessage() {
4979
+ _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
4980
+ var author, msg, area;
4981
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
4982
+ while (1) switch (_context2.prev = _context2.next) {
4983
+ case 0:
4984
+ author = _solidLogic.store.any(message, ns.foaf('maker'));
4985
+ if (me) {
4986
+ _context2.next = 5;
4987
+ break;
5688
4988
  }
5689
- function refresh() {
5690
- action = existingAction(actionClass);
5691
- setColor();
4989
+ alert('You can\'t delete the message, you are not logged in.');
4990
+ _context2.next = 22;
4991
+ break;
4992
+ case 5:
4993
+ if (!me.sameTerm(author)) {
4994
+ _context2.next = 21;
4995
+ break;
5692
4996
  }
5693
- var action;
5694
- button.refresh = refresh; // If the file changes, refresh live
5695
- refresh();
5696
- return button;
5697
- };
5698
- _deleteThingThen = function _deleteThingThen3() {
5699
- _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(x) {
5700
- return _regenerator["default"].wrap(function _callee9$(_context9) {
5701
- while (1) switch (_context9.prev = _context9.next) {
5702
- case 0:
5703
- _context9.next = 2;
5704
- return _solidLogic.store.updater.update(_solidLogic.store.connectedStatements(x), []);
5705
- case 2:
5706
- case "end":
5707
- return _context9.stop();
5708
- }
5709
- }, _callee9);
5710
- }));
5711
- return _deleteThingThen.apply(this, arguments);
5712
- };
5713
- deleteThingThen = function _deleteThingThen2(_x10) {
5714
- return _deleteThingThen.apply(this, arguments);
5715
- };
5716
- closeToolbar = function _closeToolbar() {
5717
- div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
5718
- };
5719
- _replyInThread = function _replyInThread3() {
5720
- _replyInThread = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
5721
- var thread, options;
5722
- return _regenerator["default"].wrap(function _callee8$(_context8) {
5723
- while (1) switch (_context8.prev = _context8.next) {
5724
- case 0:
5725
- _context8.next = 2;
5726
- return channelObject.createThread(message);
5727
- case 2:
5728
- thread = _context8.sent;
5729
- options = userContext.chatOptions;
5730
- if (options) {
5731
- _context8.next = 6;
5732
- break;
5733
- }
5734
- throw new Error('replyInThread: missing options');
5735
- case 6:
5736
- options.showThread(thread, options);
5737
- closeToolbar(); // a one-off action
5738
- case 8:
5739
- case "end":
5740
- return _context8.stop();
5741
- }
5742
- }, _callee8);
5743
- }));
5744
- return _replyInThread.apply(this, arguments);
5745
- };
5746
- replyInThread = function _replyInThread2() {
5747
- return _replyInThread.apply(this, arguments);
5748
- };
5749
- _editMessage = function _editMessage3() {
5750
- _editMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(messageRow) {
5751
- return _regenerator["default"].wrap(function _callee7$(_context7) {
5752
- while (1) switch (_context7.prev = _context7.next) {
5753
- case 0:
5754
- if (!(me.value === _solidLogic.store.any(message, ns.foaf('maker')).value)) {
5755
- _context7.next = 4;
5756
- break;
5757
- }
5758
- closeToolbar(); // edit is a one-off action
5759
- _context7.next = 4;
5760
- return (0, _message.switchToEditor)(messageRow, message, channelObject, userContext);
5761
- case 4:
5762
- case "end":
5763
- return _context7.stop();
5764
- }
5765
- }, _callee7);
5766
- }));
5767
- return _editMessage.apply(this, arguments);
5768
- };
5769
- editMessage = function _editMessage2(_x9) {
5770
- return _editMessage.apply(this, arguments);
5771
- };
5772
- _deleteMessage = function _deleteMessage3() {
5773
- _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
5774
- var author, msg, area;
5775
- return _regenerator["default"].wrap(function _callee6$(_context6) {
5776
- while (1) switch (_context6.prev = _context6.next) {
5777
- case 0:
5778
- author = _solidLogic.store.any(message, ns.foaf('maker'));
5779
- if (me) {
5780
- _context6.next = 5;
5781
- break;
5782
- }
5783
- alert('You can\'t delete the message, you are not logged in.');
5784
- _context6.next = 22;
5785
- break;
5786
- case 5:
5787
- if (!me.sameTerm(author)) {
5788
- _context6.next = 21;
5789
- break;
5790
- }
5791
- _context6.prev = 6;
5792
- _context6.next = 9;
5793
- return channelObject.deleteMessage(message);
5794
- case 9:
5795
- _context6.next = 18;
5796
- break;
5797
- case 11:
5798
- _context6.prev = 11;
5799
- _context6.t0 = _context6["catch"](6);
5800
- msg = 'Error deleting messaage ' + _context6.t0;
5801
- debug.warn(msg);
5802
- alert(msg);
5803
- area = userContext.statusArea || messageRow.parentNode;
5804
- area.appendChild(widgets.errorMessageBlock(dom, msg));
5805
- case 18:
5806
- messageRow.parentNode.removeChild(messageRow);
5807
- _context6.next = 22;
5808
- break;
5809
- case 21:
5810
- alert('You can\'t delete the message, you are not logged in as the author, ' + author);
5811
- case 22:
5812
- closeToolbar();
5813
- case 23:
5814
- case "end":
5815
- return _context6.stop();
5816
- }
5817
- }, _callee6, null, [[6, 11]]);
5818
- }));
5819
- return _deleteMessage.apply(this, arguments);
5820
- };
5821
- deleteMessage = function _deleteMessage2() {
5822
- return _deleteMessage.apply(this, arguments);
5823
- }; // alain: TODO allow chat owner to fully delete message + sentiments and replacing messages
5824
- div = dom.createElement('div'); // is message deleted ?
5825
- _context10.next = 13;
5826
- return (0, _chatLogic.mostRecentVersion)(message).value;
5827
- case 13:
5828
- _context10.t0 = _context10.sent;
5829
- _context10.t1 = ns.schema('dateDeleted').value;
5830
- if (!(_context10.t0 === _context10.t1)) {
5831
- _context10.next = 17;
4997
+ _context2.prev = 6;
4998
+ _context2.next = 9;
4999
+ return channelObject.deleteMessage(message);
5000
+ case 9:
5001
+ _context2.next = 18;
5832
5002
  break;
5833
- }
5834
- return _context10.abrupt("return", div);
5835
- case 17:
5836
- // Things only the original author can do
5837
- me = _solidLogic.authn.currentUser(); // If already logged on
5838
- if (me && _solidLogic.store.holds(message, ns.foaf('maker'), me)) {
5839
- // button to delete the message
5840
- div.appendChild(widgets.deleteButtonWithCheck(dom, div, 'message', deleteMessage));
5841
- // button to edit the message
5842
- div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + PENCIL_ICON, 'edit', function () {
5843
- return editMessage(messageRow);
5844
- }));
5845
- } // if mine
5846
- // Things anyone can do if they have a bookmark list async
5847
- /*
5848
- var bookmarkButton = await bookmarks.renderBookmarksButton(userContext)
5849
- if (bookmarkButton) {
5850
- div.appendChild(bookmarkButton)
5851
- }
5852
- */
5853
- // Things anyone can do if they have a bookmark list
5003
+ case 11:
5004
+ _context2.prev = 11;
5005
+ _context2.t0 = _context2["catch"](6);
5006
+ msg = 'Error deleting messaage ' + _context2.t0;
5007
+ debug.warn(msg);
5008
+ alert(msg);
5009
+ area = userContext.statusArea || messageRow.parentNode;
5010
+ area.appendChild(widgets.errorMessageBlock(dom, msg));
5011
+ case 18:
5012
+ messageRow.parentNode.removeChild(messageRow);
5013
+ _context2.next = 22;
5014
+ break;
5015
+ case 21:
5016
+ alert('You can\'t delete the message, you are not logged in as the author, ' + author);
5017
+ case 22:
5018
+ closeToolbar();
5019
+ case 23:
5020
+ case "end":
5021
+ return _context2.stop();
5022
+ }
5023
+ }, _callee2, null, [[6, 11]]);
5024
+ }));
5025
+ return _deleteMessage.apply(this, arguments);
5026
+ }
5027
+ function editMessage(_x) {
5028
+ return _editMessage.apply(this, arguments);
5029
+ } // alain TODO allow chat owner to fully delete message + sentiments and replacing messages
5030
+ function _editMessage() {
5031
+ _editMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(messageRow) {
5032
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
5033
+ while (1) switch (_context3.prev = _context3.next) {
5034
+ case 0:
5035
+ if (me.value === _solidLogic.store.any(message, ns.foaf('maker')).value) {
5036
+ closeToolbar(); // edit is a one-off action
5037
+ (0, _message.switchToEditor)(messageRow, message, channelObject, userContext);
5038
+ }
5039
+ case 1:
5040
+ case "end":
5041
+ return _context3.stop();
5042
+ }
5043
+ }, _callee3);
5044
+ }));
5045
+ return _editMessage.apply(this, arguments);
5046
+ }
5047
+ var div = dom.createElement('div');
5048
+ // is message deleted ?
5049
+ if ((0, _chatLogic.mostRecentVersion)(message).value === ns.schema('dateDeleted').value) return div;
5050
+ function closeToolbar() {
5051
+ div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
5052
+ }
5053
+ function deleteThingThen(_x2) {
5054
+ return _deleteThingThen.apply(this, arguments);
5055
+ } // Things only the original author can do
5056
+ function _deleteThingThen() {
5057
+ _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(x) {
5058
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
5059
+ while (1) switch (_context4.prev = _context4.next) {
5060
+ case 0:
5061
+ _context4.next = 2;
5062
+ return _solidLogic.store.updater.update(_solidLogic.store.connectedStatements(x), []);
5063
+ case 2:
5064
+ case "end":
5065
+ return _context4.stop();
5066
+ }
5067
+ }, _callee4);
5068
+ }));
5069
+ return _deleteThingThen.apply(this, arguments);
5070
+ }
5071
+ var me = _solidLogic.authn.currentUser(); // If already logged on
5072
+ if (me && _solidLogic.store.holds(message, ns.foaf('maker'), me)) {
5073
+ // button to delete the message
5074
+ div.appendChild(widgets.deleteButtonWithCheck(dom, div, 'message', deleteMessage));
5075
+ // button to edit the message
5076
+ div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + PENCIL_ICON, 'edit', function () {
5077
+ return editMessage(messageRow);
5078
+ }));
5079
+ } // if mine
5080
+ // Things anyone can do if they have a bookmark list async
5081
+ /*
5082
+ var bookmarkButton = await bookmarks.renderBookmarksButton(userContext)
5083
+ if (bookmarkButton) {
5084
+ div.appendChild(bookmarkButton)
5085
+ }
5086
+ */
5087
+ // Things anyone can do if they have a bookmark list
5854
5088
 
5855
- (0, _bookmarks.renderBookmarksButton)(userContext).then(function (bookmarkButton) {
5856
- if (bookmarkButton) div.appendChild(bookmarkButton);
5857
- });
5089
+ (0, _bookmarks.renderBookmarksButton)(userContext).then(function (bookmarkButton) {
5090
+ if (bookmarkButton) div.appendChild(bookmarkButton);
5091
+ });
5858
5092
 
5859
- /** Button to allow user to express a sentiment (like, endorse, etc) about a target
5860
- *
5861
- * @param context {Object} - Provide dom and me
5862
- * @param target {NamedNode} - The thing the user expresses an opnion about
5863
- * @param icon {uristring} - The icon to be used for the button
5864
- * @param actionClass {NamedNode} - The RDF class - typically a subclass of schema:Action
5865
- * @param doc - {NamedNode} - the Solid document iunto which the data should be written
5866
- * @param mutuallyExclusive {Array<NamedNode>} - Any RDF classes of sentimentswhich are mutiually exclusive
5867
- */
5868
-
5869
- // THUMBS_UP_ICON
5870
- // https://schema.org/AgreeAction
5871
- me = _solidLogic.authn.currentUser(); // If already logged on
5872
- _context10.t2 = me;
5873
- if (!_context10.t2) {
5874
- _context10.next = 28;
5875
- break;
5876
- }
5877
- _context10.next = 25;
5878
- return (0, _chatLogic.mostRecentVersion)(message).value;
5879
- case 25:
5880
- _context10.t3 = _context10.sent;
5881
- _context10.t4 = ns.schema('dateDeleted').value;
5882
- _context10.t2 = _context10.t3 !== _context10.t4;
5883
- case 28:
5884
- if (!_context10.t2) {
5885
- _context10.next = 32;
5886
- break;
5093
+ /** Button to allow user to express a sentiment (like, endorse, etc) about a target
5094
+ *
5095
+ * @param context {Object} - Provide dom and me
5096
+ * @param target {NamedNode} - The thing the user expresses an opnion about
5097
+ * @param icon {uristring} - The icon to be used for the button
5098
+ * @param actionClass {NamedNode} - The RDF class - typically a subclass of schema:Action
5099
+ * @param doc - {NamedNode} - the Solid document iunto which the data should be written
5100
+ * @param mutuallyExclusive {Array<NamedNode>} - Any RDF classes of sentimentswhich are mutiually exclusive
5101
+ */
5102
+ function sentimentButton(context, target, icon, actionClass, doc, mutuallyExclusive) {
5103
+ function setColor() {
5104
+ button.style.backgroundColor = action ? 'yellow' : 'white';
5105
+ }
5106
+ var button = widgets.button(dom, icon, utils.label(actionClass), /*#__PURE__*/function () {
5107
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_event) {
5108
+ var insertMe, dirty, i, a;
5109
+ return _regenerator["default"].wrap(function _callee$(_context) {
5110
+ while (1) switch (_context.prev = _context.next) {
5111
+ case 0:
5112
+ if (!action) {
5113
+ _context.next = 7;
5114
+ break;
5115
+ }
5116
+ _context.next = 3;
5117
+ return deleteThingThen(action);
5118
+ case 3:
5119
+ action = null;
5120
+ setColor();
5121
+ _context.next = 25;
5122
+ break;
5123
+ case 7:
5124
+ // no action
5125
+ action = widgets.newThing(doc);
5126
+ insertMe = [rdf.st(action, ns.schema('agent'), context.me, doc), rdf.st(action, ns.rdf('type'), actionClass, doc), rdf.st(action, ns.schema('target'), target, doc)];
5127
+ _context.next = 11;
5128
+ return _solidLogic.store.updater.update([], insertMe);
5129
+ case 11:
5130
+ setColor();
5131
+ if (!mutuallyExclusive) {
5132
+ _context.next = 25;
5133
+ break;
5134
+ }
5135
+ // Delete incompative sentiments
5136
+ dirty = false;
5137
+ i = 0;
5138
+ case 15:
5139
+ if (!(i < mutuallyExclusive.length)) {
5140
+ _context.next = 24;
5141
+ break;
5142
+ }
5143
+ a = existingAction(mutuallyExclusive[i]);
5144
+ if (!a) {
5145
+ _context.next = 21;
5146
+ break;
5147
+ }
5148
+ _context.next = 20;
5149
+ return deleteThingThen(a);
5150
+ case 20:
5151
+ // but how refresh? refreshTree the parent?
5152
+ dirty = true;
5153
+ case 21:
5154
+ i++;
5155
+ _context.next = 15;
5156
+ break;
5157
+ case 24:
5158
+ if (dirty) {
5159
+ // widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
5160
+ widgets.refreshTree(messageRow); // requires them all to be immediate siblings
5161
+ }
5162
+ case 25:
5163
+ case "end":
5164
+ return _context.stop();
5887
5165
  }
5888
- context1 = {
5889
- me: me,
5890
- dom: dom,
5891
- div: div
5892
- };
5893
- div.appendChild(sentimentButton(context1, message,
5894
- // @@ TODO use widgets.sentimentButton
5895
- _iconBase.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')]));
5896
- // Thumbs down
5897
- div.appendChild(sentimentButton(context1, message, _iconBase.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
5898
- case 32:
5899
- // Reply buttton
5166
+ }, _callee);
5167
+ }));
5168
+ return function (_x3) {
5169
+ return _ref.apply(this, arguments);
5170
+ };
5171
+ }());
5172
+ function existingAction(actionClass) {
5173
+ var actions = _solidLogic.store.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
5174
+ return _solidLogic.store.holds(x, ns.rdf('type'), actionClass, doc);
5175
+ }).filter(function (x) {
5176
+ return _solidLogic.store.holds(x, ns.schema('target'), target, doc);
5177
+ });
5178
+ return actions.length ? actions[0] : null;
5179
+ }
5180
+ function refresh() {
5181
+ action = existingAction(actionClass);
5182
+ setColor();
5183
+ }
5184
+ var action;
5185
+ button.refresh = refresh; // If the file changes, refresh live
5186
+ refresh();
5187
+ return button;
5188
+ }
5900
5189
 
5901
- if (_solidLogic.store.any(message, ns.dct('created'))) {
5902
- // Looks like a messsage? Bar can be used for other things
5903
- div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + REPLY_ICON, 'Reply in thread', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
5904
- return _regenerator["default"].wrap(function _callee5$(_context5) {
5905
- while (1) switch (_context5.prev = _context5.next) {
5906
- case 0:
5907
- _context5.next = 2;
5908
- return replyInThread();
5909
- case 2:
5910
- case "end":
5911
- return _context5.stop();
5912
- }
5913
- }, _callee5);
5914
- }))));
5915
- }
5916
- // X button to remove the tool UI itself
5917
- cancelButton = div.appendChild(widgets.cancelButton(dom));
5918
- cancelButton.style["float"] = 'right';
5919
- cancelButton.firstChild.style.opacity = '0.3';
5920
- cancelButton.addEventListener('click', closeToolbar);
5921
- return _context10.abrupt("return", div);
5922
- case 38:
5923
- case "end":
5924
- return _context10.stop();
5925
- }
5926
- }, _callee10);
5927
- }));
5928
- return _messageToolbar.apply(this, arguments);
5190
+ // THUMBS_UP_ICON
5191
+ // https://schema.org/AgreeAction
5192
+ me = _solidLogic.authn.currentUser(); // If already logged on
5193
+ // debug.log('Actions 3' + mostRecentVersion(message).value + ' ' + ns.schema('dateDeleted').value + ' ' + (mostRecentVersion(message).value !== ns.schema('dateDeleted').value))
5194
+
5195
+ if (me && (0, _chatLogic.mostRecentVersion)(message).value !== ns.schema('dateDeleted').value) {
5196
+ var context1 = {
5197
+ me: me,
5198
+ dom: dom,
5199
+ div: div
5200
+ };
5201
+ div.appendChild(sentimentButton(context1, message,
5202
+ // @@ TODO use widgets.sentimentButton
5203
+ _iconBase.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')]));
5204
+ // Thumbs down
5205
+ div.appendChild(sentimentButton(context1, message, _iconBase.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
5206
+ }
5207
+ // X button to remove the tool UI itself
5208
+ var cancelButton = div.appendChild(widgets.cancelButton(dom));
5209
+ cancelButton.style["float"] = 'right';
5210
+ cancelButton.firstChild.style.opacity = '0.3';
5211
+ cancelButton.addEventListener('click', closeToolbar);
5212
+ return div;
5929
5213
  }
5930
5214
  //# sourceMappingURL=messageTools.js.map
5931
5215
 
@@ -5953,27 +5237,96 @@ exports.verifySignature = verifySignature;
5953
5237
  var _secp256k = __webpack_require__(/*! @noble/curves/secp256k1 */ "./node_modules/@noble/curves/secp256k1.js");
5954
5238
  var _utils = __webpack_require__(/*! @noble/hashes/utils */ "./node_modules/@noble/hashes/utils.js");
5955
5239
  var _sha = __webpack_require__(/*! @noble/hashes/sha256 */ "./node_modules/@noble/hashes/sha256.js");
5240
+ // import {utf8Encoder} from './utils'
5241
+ // import { getPublicKey } from './keys'
5242
+
5956
5243
  var utf8Decoder = new TextDecoder('utf-8');
5957
5244
  exports.utf8Decoder = utf8Decoder;
5958
5245
  var utf8Encoder = new TextEncoder();
5959
5246
  exports.utf8Encoder = utf8Encoder;
5960
5247
  var SEC = 'https://w3id.org/security#'; // Proof, VerificationMethod
5248
+ // export const CERT = 'http://www.w3.org/ns/auth/cert#' // PrivateKey, PublicKey, key
5249
+
5250
+ /* eslint-disable no-unused-vars */
5251
+ /* export enum Kind {
5252
+ Metadata = 0,
5253
+ Text = 1,
5254
+ RecommendRelay = 2,
5255
+ Contacts = 3,
5256
+ EncryptedDirectMessage = 4,
5257
+ EventDeletion = 5,
5258
+ Reaction = 7,
5259
+ BadgeAward = 8,
5260
+ ChannelCreation = 40,
5261
+ ChannelMetadata = 41,
5262
+ ChannelMessage = 42,
5263
+ ChannelHideMessage = 43,
5264
+ ChannelMuteUser = 44,
5265
+ Report = 1984,
5266
+ ZapRequest = 9734,
5267
+ Zap = 9735,
5268
+ RelayList = 10002,
5269
+ ClientAuth = 22242,
5270
+ BadgeDefinition = 30008,
5271
+ ProfileBadge = 30009,
5272
+ Article = 30023
5273
+ } */
5961
5274
  exports.SEC = SEC;
5962
5275
  function getBlankMsg() {
5963
5276
  return {
5964
5277
  id: '',
5965
5278
  created: '',
5279
+ dateDeleted: '',
5280
+ // TODO to remove if not used
5966
5281
  content: '',
5967
- maker: ''
5282
+ maker: '',
5283
+ sig: '' // TODO to remove if not used
5968
5284
  };
5969
5285
  }
5286
+
5287
+ /* export function finishMsg (t: MsgTemplate, privateKey: string): Message {
5288
+ // to update to chat message triples
5289
+ const message = t as Message
5290
+ // message.pubkey = getPublicKey(privateKey)
5291
+ message.id = getMsgHash(message)
5292
+ message.sig = signMsg(message, privateKey)
5293
+ return message
5294
+ } */
5295
+
5970
5296
  function serializeMsg(msg) {
5297
+ // to update to chat messages triples
5298
+ /* if (!validateMsg(msg))
5299
+ throw new Error("can't serialize message with wrong or missing properties") */
5300
+
5971
5301
  return JSON.stringify(msg);
5972
5302
  }
5973
5303
  function getMsgHash(message) {
5974
5304
  var msgHash = (0, _sha.sha256)(utf8Encoder.encode(serializeMsg(message)));
5975
5305
  return (0, _utils.bytesToHex)(msgHash);
5976
5306
  }
5307
+
5308
+ // const isRecord = (obj: unknown): obj is Record<string, unknown> => obj instanceof Object
5309
+
5310
+ /* export function validateMsg<T> (message: T): message is T & UnsignedMsg {
5311
+ if (!isRecord(message)) return false
5312
+ if (typeof message.kind !== 'number') return false
5313
+ if (typeof message.content !== 'string') return false
5314
+ if (typeof message.created_at !== 'number') return false
5315
+ if (typeof message.pubkey !== 'string') return false
5316
+ if (!message.pubkey.match(/^[a-f0-9]{64}$/)) return false
5317
+
5318
+ if (!Array.isArray(message.tags)) return false
5319
+ for (let i = 0; i < message.tags.length; i++) {
5320
+ let tag = message.tags[i]
5321
+ if (!Array.isArray(tag)) return false
5322
+ for (let j = 0; j < tag.length; j++) {
5323
+ if (typeof tag[j] === 'object') return false
5324
+ }
5325
+ }
5326
+
5327
+ return true
5328
+ } */
5329
+
5977
5330
  function verifySignature(sig, message, pubKey) {
5978
5331
  return _secp256k.schnorr.verify(sig, getMsgHash(message), pubKey);
5979
5332
  }
@@ -6519,11 +5872,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
6519
5872
  */
6520
5873
  var DEFAULT_HELP_MENU_ICON = _index.icons.iconBase + 'noun_help.svg';
6521
5874
  var DEFAUL_SOLID_ICON_URL = 'https://solidproject.org/assets/img/solid-emblem.svg';
6522
-
6523
- /*
6524
- HeaderOptions allow for customizing the logo and menu list. If a logo is not provided the default
6525
- is solid. Menulist will always show a link to logout and to the users profile.
6526
- */
6527
5875
  /**
6528
5876
  * Initialize header component, the header object returned depends on whether the user is authenticated.
6529
5877
  * @param store the data store
@@ -7197,7 +6545,10 @@ var TDEBUG = 32;
7197
6545
  var TALL = 63;
7198
6546
 
7199
6547
  /** @internal */
7200
- var LogLevel = /*#__PURE__*/function (LogLevel) {
6548
+ var LogLevel;
6549
+ /** @internal */
6550
+ exports.LogLevel = LogLevel;
6551
+ (function (LogLevel) {
7201
6552
  LogLevel[LogLevel["Error"] = 1] = "Error";
7202
6553
  LogLevel[LogLevel["Warning"] = 2] = "Warning";
7203
6554
  LogLevel[LogLevel["Message"] = 4] = "Message";
@@ -7205,10 +6556,7 @@ var LogLevel = /*#__PURE__*/function (LogLevel) {
7205
6556
  LogLevel[LogLevel["Info"] = 16] = "Info";
7206
6557
  LogLevel[LogLevel["Debug"] = 32] = "Debug";
7207
6558
  LogLevel[LogLevel["All"] = 63] = "All";
7208
- return LogLevel;
7209
- }({});
7210
- /** @internal */
7211
- exports.LogLevel = LogLevel;
6559
+ })(LogLevel || (exports.LogLevel = LogLevel = {}));
7212
6560
  var _level = TERROR + TWARN + TMESG;
7213
6561
  /** @internal */
7214
6562
  var _ascending = false;
@@ -7417,30 +6765,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
7417
6765
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
7418
6766
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
7419
6767
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7420
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /* eslint-disable camelcase */ /**
7421
- * Signing in, signing up, profile and preferences reloading
7422
- * Type index management
7423
- *
7424
- * Many functions in this module take a context object which
7425
- * holds various RDF symbols, add to it, and return a promise of it.
7426
- *
7427
- * * `me` RDF symbol for the user's WebID
7428
- * * `publicProfile` The user's public profile, iff loaded
7429
- * * `preferencesFile` The user's personal preference file, iff loaded
7430
- * * `index.public` The user's public type index file
7431
- * * `index.private` The user's private type index file
7432
- *
7433
- * Not RDF symbols:
7434
- * * `noun` A string in english for the type of thing -- like "address book"
7435
- * * `instance` An array of nodes which are existing instances
7436
- * * `containers` An array of nodes of containers of instances
7437
- * * `div` A DOM element where UI can be displayed
7438
- * * `statusArea` A DOM element (opt) progress stuff can be displayed, or error messages
7439
- * *
7440
- * * Vocabulary: "load" loads a file if it exists;
7441
- * * 'Ensure" CREATES the file if it does not exist (if it can) and then loads it.
7442
- * @packageDocumentation
7443
- */ // eslint-disable-next-line camelcase
6768
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7444
6769
  var store = _solidLogic.solidLogicSingleton.store;
7445
6770
  var _solidLogicSingleton$ = _solidLogic.solidLogicSingleton.profile,
7446
6771
  loadPreferences = _solidLogicSingleton$.loadPreferences,
@@ -7506,104 +6831,93 @@ function ensureLoadedPreferences(_x) {
7506
6831
  // used to be logInLoadProfile
7507
6832
  function _ensureLoadedPreferences() {
7508
6833
  _ensureLoadedPreferences = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(context) {
7509
- var statusArea, progressDisplay, complain, preferencesFile, m2;
6834
+ var progressDisplay, preferencesFile, m2;
7510
6835
  return _regenerator["default"].wrap(function _callee4$(_context4) {
7511
6836
  while (1) switch (_context4.prev = _context4.next) {
7512
6837
  case 0:
7513
- complain = function _complain(message) {
7514
- message = "ensureLoadedPreferences: ".concat(message);
7515
- if (statusArea) {
7516
- // statusArea.innerHTML = ''
7517
- statusArea.appendChild(widgets.errorMessageBlock(context.dom, message));
7518
- }
7519
- debug.log(message);
7520
- // reject(new Error(message))
7521
- };
7522
6838
  if (!context.preferencesFile) {
7523
- _context4.next = 3;
6839
+ _context4.next = 2;
7524
6840
  break;
7525
6841
  }
7526
6842
  return _context4.abrupt("return", Promise.resolve(context));
7527
- case 3:
7528
- // already done
7529
- statusArea = context.statusArea || context.div || null;
7530
- _context4.prev = 4;
7531
- _context4.next = 7;
6843
+ case 2:
6844
+ _context4.prev = 2;
6845
+ _context4.next = 5;
7532
6846
  return ensureLoadedProfile(context);
7533
- case 7:
6847
+ case 5:
7534
6848
  context = _context4.sent;
7535
- _context4.next = 10;
6849
+ _context4.next = 8;
7536
6850
  return loadPreferences(context.me);
7537
- case 10:
6851
+ case 8:
7538
6852
  preferencesFile = _context4.sent;
7539
6853
  if (progressDisplay) {
7540
6854
  progressDisplay.parentNode.removeChild(progressDisplay);
7541
6855
  }
7542
6856
  context.preferencesFile = preferencesFile;
7543
- _context4.next = 51;
6857
+ _context4.next = 49;
7544
6858
  break;
7545
- case 15:
7546
- _context4.prev = 15;
7547
- _context4.t0 = _context4["catch"](4);
6859
+ case 13:
6860
+ _context4.prev = 13;
6861
+ _context4.t0 = _context4["catch"](2);
7548
6862
  if (!(_context4.t0 instanceof _solidLogic.UnauthorizedError)) {
7549
- _context4.next = 22;
6863
+ _context4.next = 20;
7550
6864
  break;
7551
6865
  }
7552
6866
  m2 = 'Ooops - you are not authenticated (properly logged in) to for me to read your preference file. Try loggin out and logging in?';
7553
6867
  (0, _log.alert)(m2);
7554
- _context4.next = 51;
6868
+ _context4.next = 49;
7555
6869
  break;
7556
- case 22:
6870
+ case 20:
7557
6871
  if (!(_context4.t0 instanceof _solidLogic.CrossOriginForbiddenError)) {
7558
- _context4.next = 28;
6872
+ _context4.next = 26;
7559
6873
  break;
7560
6874
  }
7561
6875
  m2 = "Unauthorized: Assuming preference file blocked for origin ".concat(window.location.origin);
7562
6876
  context.preferencesFileError = m2;
7563
6877
  return _context4.abrupt("return", context);
7564
- case 28:
6878
+ case 26:
7565
6879
  if (!(_context4.t0 instanceof _solidLogic.SameOriginForbiddenError)) {
7566
- _context4.next = 34;
6880
+ _context4.next = 32;
7567
6881
  break;
7568
6882
  }
7569
6883
  m2 = 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.';
7570
6884
  debug.warn(m2);
7571
6885
  return _context4.abrupt("return", context);
7572
- case 34:
6886
+ case 32:
7573
6887
  if (!(_context4.t0 instanceof _solidLogic.NotEditableError)) {
7574
- _context4.next = 40;
6888
+ _context4.next = 38;
7575
6889
  break;
7576
6890
  }
7577
6891
  m2 = 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
7578
6892
  debug.warn(m2);
7579
6893
  return _context4.abrupt("return", context);
7580
- case 40:
6894
+ case 38:
7581
6895
  if (!(_context4.t0 instanceof _solidLogic.WebOperationError)) {
7582
- _context4.next = 45;
6896
+ _context4.next = 43;
7583
6897
  break;
7584
6898
  }
7585
6899
  m2 = 'You are not authorized to edit your preference file. This may be because you are using an untrusted web app.';
7586
6900
  debug.warn(m2);
7587
- _context4.next = 51;
6901
+ _context4.next = 49;
7588
6902
  break;
7589
- case 45:
6903
+ case 43:
7590
6904
  if (!(_context4.t0 instanceof _solidLogic.FetchError)) {
7591
- _context4.next = 50;
6905
+ _context4.next = 48;
7592
6906
  break;
7593
6907
  }
7594
6908
  m2 = "Strange: Error ".concat(_context4.t0.status, " trying to read your preference file.").concat(_context4.t0.message);
7595
6909
  (0, _log.alert)(m2);
7596
- _context4.next = 51;
6910
+ _context4.next = 49;
7597
6911
  break;
7598
- case 50:
6912
+ case 48:
7599
6913
  throw new Error("(via loadPrefs) ".concat(_context4.t0));
7600
- case 51:
6914
+ case 49:
7601
6915
  return _context4.abrupt("return", context);
7602
- case 52:
6916
+ case 50:
7603
6917
  case "end":
7604
6918
  return _context4.stop();
7605
6919
  }
7606
- }, _callee4, null, [[4, 15]]);
6920
+ }, _callee4, null, [[2, 13]]);
7607
6921
  }));
7608
6922
  return _ensureLoadedPreferences.apply(this, arguments);
7609
6923
  }
@@ -9557,10 +8871,7 @@ var _participation = __webpack_require__(/*! ./participation */ "./lib/participa
9557
8871
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
9558
8872
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
9559
8873
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
9560
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** **************
9561
- * Notepad Widget
9562
- */ /** @module pad
9563
- */
8874
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
9564
8875
  var store = _solidLogic.solidLogicSingleton.store;
9565
8876
  var PAD = (0, _rdflib.Namespace)('http://www.w3.org/ns/pim/pad#');
9566
8877
  /**
@@ -10381,8 +9692,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
10381
9692
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10382
9693
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10383
9694
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
10384
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /* Manage a UI for the particpation of a person in any thing
10385
- */ // import { currentUser } from './authn/authn'
9695
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10386
9696
  var ParticipationTableElement = /*#__PURE__*/function (_HTMLTableElement) {
10387
9697
  (0, _inherits2["default"])(ParticipationTableElement, _HTMLTableElement);
10388
9698
  var _super = _createSuper(ParticipationTableElement);
@@ -10642,10 +9952,6 @@ function recordSharedPreferences(subject, context) {
10642
9952
  return new Promise(function (resolve, reject) {
10643
9953
  var sharedPreferences = kb.any(subject, ns.ui('sharedPreferences'));
10644
9954
  if (!sharedPreferences) {
10645
- if (!kb.updater.editable(subject.doc())) {
10646
- debug.log(" Cant make shared preferences, may not change ".concat(subject.doc));
10647
- resolve(context);
10648
- }
10649
9955
  var sp = $rdf.sym(subject.doc().uri + '#SharedPreferences');
10650
9956
  var ins = [$rdf.st(subject, ns.ui('sharedPreferences'), sp, subject.doc())];
10651
9957
  debug.log('Creating shared preferences ' + sp);
@@ -13245,8 +12551,6 @@ var _ = __webpack_require__(/*! .. */ "./lib/index.js");
13245
12551
  Copied from mashlib/src/global/metadata.ts
13246
12552
  */
13247
12553
 
13248
- /* @ts-ignore no-console */
13249
-
13250
12554
  /**
13251
12555
  * @ignore exporting this only for the unit test
13252
12556
  */
@@ -13963,96 +13267,176 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
13963
13267
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../../debug */ "./lib/debug.js"));
13964
13268
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
13965
13269
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
13966
- var _otherHelpers = __webpack_require__(/*! ./otherHelpers */ "./lib/utils/keyHelpers/otherHelpers.js");
13967
13270
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13968
13271
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13969
- var pubKeyUrl = function pubKeyUrl(webId) {
13970
- var url;
13971
- try {
13972
- var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
13973
- url = "".concat(root, "/profile/keys/publicKey.ttl");
13974
- } catch (err) {
13975
- debug.error(err);
13272
+ /* export const getPodRoot = async (webId: NamedNode) => {
13273
+ const webIdURL = new URL(webId.uri)
13274
+ // find storages in webId document
13275
+ await store.fetcher.load(webId.uri)
13276
+ const storages = store.each(webId, ns.space('storage'), null, webId.doc())
13277
+ var podRoot: NamedNode | undefined
13278
+ if (!storages?.length) {
13279
+ // find storage recursively in webId URL
13280
+ let path = webIdURL.pathname
13281
+ while (path.length) {
13282
+ path = path.substring(0, path.lastIndexOf('/'))
13283
+ podRoot = store.sym(webIdURL.origin + path + '/')
13284
+ const res = await store.fetcher.webOperation('HEAD', podRoot.uri)
13285
+ if (res.headers.get('link')?.includes(ns.space('Storage').value)) break
13286
+ if (!path) debug.warn(`Current user storage not found for\n${webId}`)
13287
+ }
13288
+ } else {
13289
+ // give preference to storage in webId root
13290
+ podRoot = storages.find((storage) => webIdURL.origin === new URL(storage.value).origin) as NamedNode
13291
+ if (!podRoot) podRoot = storages[0] as NamedNode
13976
13292
  }
13977
- return url;
13978
- };
13293
+
13294
+ return podRoot as NamedNode
13295
+ } */
13296
+
13297
+ var pubKeyUrl = /*#__PURE__*/function () {
13298
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId) {
13299
+ var _store$any, _parentSettings;
13300
+ var parentSettings;
13301
+ return _regenerator["default"].wrap(function _callee$(_context) {
13302
+ while (1) switch (_context.prev = _context.next) {
13303
+ case 0:
13304
+ parentSettings = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
13305
+ parentSettings = (_parentSettings = parentSettings) === null || _parentSettings === void 0 ? void 0 : _parentSettings.split('/').slice(0, -2).join('/');
13306
+ if (parentSettings) {
13307
+ _context.next = 4;
13308
+ break;
13309
+ }
13310
+ throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
13311
+ case 4:
13312
+ return _context.abrupt("return", "".concat(parentSettings, "/profile/keys/publicKey.ttl"));
13313
+ case 5:
13314
+ case "end":
13315
+ return _context.stop();
13316
+ }
13317
+ }, _callee);
13318
+ }));
13319
+ return function pubKeyUrl(_x) {
13320
+ return _ref.apply(this, arguments);
13321
+ };
13322
+ }();
13979
13323
  exports.pubKeyUrl = pubKeyUrl;
13980
- var privKeyUrl = function privKeyUrl(webId) {
13981
- var url;
13982
- try {
13983
- var root = (0, _otherHelpers.getRootIfPreferencesExist)(webId);
13984
- url = "".concat(root, "/keys/privateKey.ttl");
13985
- } catch (err) {
13986
- debug.error(err);
13987
- }
13988
- return url;
13989
- };
13990
- exports.privKeyUrl = privKeyUrl;
13991
- function getExistingPublicKey(_x, _x2) {
13324
+ function getExistingPublicKey(_x2, _x3) {
13992
13325
  return _getExistingPublicKey.apply(this, arguments);
13993
13326
  }
13994
13327
  function _getExistingPublicKey() {
13995
- _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(webId, publicKeyUrl) {
13996
- return _regenerator["default"].wrap(function _callee$(_context) {
13997
- while (1) switch (_context.prev = _context.next) {
13328
+ _getExistingPublicKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, publicKeyUrl) {
13329
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
13330
+ while (1) switch (_context3.prev = _context3.next) {
13998
13331
  case 0:
13999
- _context.next = 2;
13332
+ _context3.next = 2;
14000
13333
  return getKeyIfExists(webId, publicKeyUrl, 'publicKey');
14001
13334
  case 2:
14002
- return _context.abrupt("return", _context.sent);
13335
+ return _context3.abrupt("return", _context3.sent);
14003
13336
  case 3:
14004
13337
  case "end":
14005
- return _context.stop();
13338
+ return _context3.stop();
14006
13339
  }
14007
- }, _callee);
13340
+ }, _callee3);
14008
13341
  }));
14009
13342
  return _getExistingPublicKey.apply(this, arguments);
14010
13343
  }
14011
- function getExistingPrivateKey(_x3, _x4) {
13344
+ var privKeyUrl = /*#__PURE__*/function () {
13345
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId) {
13346
+ var _store$any2, _settings;
13347
+ var settings;
13348
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
13349
+ while (1) switch (_context2.prev = _context2.next) {
13350
+ case 0:
13351
+ settings = (_store$any2 = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any2 === void 0 ? void 0 : _store$any2.value;
13352
+ settings = (_settings = settings) === null || _settings === void 0 ? void 0 : _settings.split('/').slice(0, -1).join('/');
13353
+ if (settings) {
13354
+ _context2.next = 4;
13355
+ break;
13356
+ }
13357
+ throw new Error("prefererencesFile is expected to exist in ".concat(webId.doc));
13358
+ case 4:
13359
+ return _context2.abrupt("return", "".concat(settings, "/keys/privateKey.ttl"));
13360
+ case 5:
13361
+ case "end":
13362
+ return _context2.stop();
13363
+ }
13364
+ }, _callee2);
13365
+ }));
13366
+ return function privKeyUrl(_x4) {
13367
+ return _ref2.apply(this, arguments);
13368
+ };
13369
+ }();
13370
+ exports.privKeyUrl = privKeyUrl;
13371
+ function getExistingPrivateKey(_x5, _x6) {
14012
13372
  return _getExistingPrivateKey.apply(this, arguments);
14013
13373
  }
14014
13374
  function _getExistingPrivateKey() {
14015
- _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(webId, privateKeyUrl) {
14016
- return _regenerator["default"].wrap(function _callee2$(_context2) {
14017
- while (1) switch (_context2.prev = _context2.next) {
13375
+ _getExistingPrivateKey = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(webId, privateKeyUrl) {
13376
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
13377
+ while (1) switch (_context4.prev = _context4.next) {
14018
13378
  case 0:
14019
- _context2.next = 2;
13379
+ _context4.next = 2;
14020
13380
  return getKeyIfExists(webId, privateKeyUrl, 'privateKey');
14021
13381
  case 2:
14022
- return _context2.abrupt("return", _context2.sent);
13382
+ return _context4.abrupt("return", _context4.sent);
14023
13383
  case 3:
14024
13384
  case "end":
14025
- return _context2.stop();
13385
+ return _context4.stop();
14026
13386
  }
14027
- }, _callee2);
13387
+ }, _callee4);
14028
13388
  }));
14029
13389
  return _getExistingPrivateKey.apply(this, arguments);
14030
13390
  }
14031
- function getKeyIfExists(_x5, _x6, _x7) {
13391
+ function getKeyIfExists(_x7, _x8, _x9) {
14032
13392
  return _getKeyIfExists.apply(this, arguments);
14033
13393
  }
14034
13394
  function _getKeyIfExists() {
14035
- _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(webId, keyUrl, keyType) {
13395
+ _getKeyIfExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(webId, keyUrl, keyType) {
14036
13396
  var key;
14037
- return _regenerator["default"].wrap(function _callee3$(_context3) {
14038
- while (1) switch (_context3.prev = _context3.next) {
13397
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
13398
+ while (1) switch (_context5.prev = _context5.next) {
14039
13399
  case 0:
14040
- _context3.prev = 0;
14041
- _context3.next = 3;
13400
+ _context5.prev = 0;
13401
+ _context5.next = 3;
14042
13402
  return _solidLogic.store.fetcher.load(keyUrl);
14043
13403
  case 3:
14044
13404
  key = _solidLogic.store.any(webId, ns.solid(keyType)); // store.sym(CERT + keyType))
14045
- return _context3.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
13405
+ return _context5.abrupt("return", key === null || key === void 0 ? void 0 : key.value);
14046
13406
  case 7:
14047
- _context3.prev = 7;
14048
- _context3.t0 = _context3["catch"](0);
14049
- debug.error('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context3.t0);
14050
- return _context3.abrupt("return", undefined);
14051
- case 11:
13407
+ _context5.prev = 7;
13408
+ _context5.t0 = _context5["catch"](0);
13409
+ if (!(_context5.t0.response.status === 404)) {
13410
+ _context5.next = 24;
13411
+ break;
13412
+ }
13413
+ debug.log('createIfNotExists: doc does NOT exist, will create... ' + keyUrl);
13414
+ _context5.prev = 11;
13415
+ _context5.next = 14;
13416
+ return _solidLogic.store.fetcher.webOperation('PUT', keyUrl, {
13417
+ data: '',
13418
+ contentType: 'text/turtle'
13419
+ });
13420
+ case 14:
13421
+ _context5.next = 20;
13422
+ break;
13423
+ case 16:
13424
+ _context5.prev = 16;
13425
+ _context5.t1 = _context5["catch"](11);
13426
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t1);
13427
+ throw _context5.t1;
13428
+ case 20:
13429
+ delete _solidLogic.store.fetcher.requested[keyUrl]; // delete cached 404 error
13430
+ // debug.log('createIfNotExists doc created ok ' + doc)
13431
+ return _context5.abrupt("return", undefined);
13432
+ case 24:
13433
+ debug.log('createIfNotExists doc FAILED: ' + keyUrl + ': ' + _context5.t0);
13434
+ throw _context5.t0;
13435
+ case 26:
14052
13436
  case "end":
14053
- return _context3.stop();
13437
+ return _context5.stop();
14054
13438
  }
14055
- }, _callee3, null, [[0, 7]]);
13439
+ }, _callee5, null, [[0, 7], [11, 16]]);
14056
13440
  }));
14057
13441
  return _getKeyIfExists.apply(this, arguments);
14058
13442
  }
@@ -14163,39 +13547,6 @@ exports.keyAclBody = keyAclBody;
14163
13547
 
14164
13548
  /***/ }),
14165
13549
 
14166
- /***/ "./lib/utils/keyHelpers/otherHelpers.js":
14167
- /*!**********************************************!*\
14168
- !*** ./lib/utils/keyHelpers/otherHelpers.js ***!
14169
- \**********************************************/
14170
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
14171
-
14172
- "use strict";
14173
-
14174
-
14175
- var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
14176
- Object.defineProperty(exports, "__esModule", ({
14177
- value: true
14178
- }));
14179
- exports.getRootIfPreferencesExist = void 0;
14180
- var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
14181
- var ns = _interopRequireWildcard(__webpack_require__(/*! ../../ns */ "./lib/ns.js"));
14182
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14183
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
14184
- // Will rename this file later. We will probably be using solid-logic anyway
14185
- // moved it out so I can mock
14186
-
14187
- var getRootIfPreferencesExist = function getRootIfPreferencesExist(webId) {
14188
- var _store$any, _root;
14189
- var root = (_store$any = _solidLogic.store.any(webId, ns.space('preferencesFile'), null, webId.doc())) === null || _store$any === void 0 ? void 0 : _store$any.value;
14190
- root = (_root = root) === null || _root === void 0 ? void 0 : _root.split('/').slice(0, -2).join('/');
14191
- if (!root) throw new Error("prefererencesFile is expected to exist in ".concat(webId));
14192
- return root;
14193
- };
14194
- exports.getRootIfPreferencesExist = getRootIfPreferencesExist;
14195
- //# sourceMappingURL=otherHelpers.js.map
14196
-
14197
- /***/ }),
14198
-
14199
13550
  /***/ "./lib/utils/label.js":
14200
13551
  /*!****************************!*\
14201
13552
  !*** ./lib/utils/label.js ***!
@@ -14324,22 +13675,22 @@ Object.defineProperty(exports, "__esModule", ({
14324
13675
  }));
14325
13676
  exports.versionInfo = void 0;
14326
13677
  var versionInfo = {
14327
- buildTime: '2023-06-03T23:48:25Z',
14328
- commit: '6a319caf69ef4ecc171a5adcb375dea108d002c2',
13678
+ buildTime: '2023-07-05T09:50:00Z',
13679
+ commit: '6c36e7182fc9724f99aa6766d7eef2a32f100bdb',
14329
13680
  npmInfo: {
14330
13681
  'solid-ui': '2.4.28',
14331
13682
  npm: '8.19.4',
14332
- node: '16.20.0',
13683
+ node: '16.20.1',
14333
13684
  v8: '9.4.146.26-node.26',
14334
13685
  uv: '1.43.0',
14335
13686
  zlib: '1.2.11',
14336
13687
  brotli: '1.0.9',
14337
- ares: '1.19.0',
13688
+ ares: '1.19.1',
14338
13689
  modules: '93',
14339
13690
  nghttp2: '1.47.0',
14340
13691
  napi: '8',
14341
- llhttp: '6.0.10',
14342
- openssl: '1.1.1t+quic',
13692
+ llhttp: '6.0.11',
13693
+ openssl: '1.1.1u+quic',
14343
13694
  cldr: '41.0',
14344
13695
  icu: '71.1',
14345
13696
  tz: '2022f',
@@ -14427,7 +13778,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
14427
13778
  * UI Widgets such as buttons
14428
13779
  * @packageDocumentation
14429
13780
  */
13781
+
14430
13782
  /* global alert */
13783
+
14431
13784
  var iconBase = _iconBase.icons.iconBase;
14432
13785
  var cancelIconURI = iconBase + 'noun_1180156.svg'; // black X
14433
13786
  var checkIconURI = iconBase + 'noun_1180158.svg'; // green checkmark; Continue
@@ -16110,10 +15463,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16110
15463
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16111
15464
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
16112
15465
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16113
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /* F O R M S
16114
- *
16115
- * A Vanilla Dom implementation of the form language
16116
- */ /* eslint-disable multiline-ternary */ /* global alert */ // Note default export
15466
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16117
15467
  var checkMarkCharacter = "\u2713";
16118
15468
  var cancelCharacter = "\u2715";
16119
15469
  var dashCharacter = '-';
@@ -18109,14 +17459,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
18109
17459
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18110
17460
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
18111
17461
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18112
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /* The Autocomplete Control with decorations
18113
-
18114
- This control has the buttons which control the state between editing, viewing, searching, accepting
18115
- and so on. See the state diagram in the documentation. The AUtocomplete Picker does the main work.
18116
-
18117
- */
18118
- // dbpediaParameters
18119
-
17462
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18120
17463
  var WEBID_NOUN = 'Solid ID';
18121
17464
  var GREEN_PLUS = _iconBase.icons.iconBase + 'noun_34653_green.svg';
18122
17465
  var SEARCH_ICON = _iconBase.icons.iconBase + 'noun_Search_875351.svg';
@@ -18662,11 +18005,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
18662
18005
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18663
18006
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
18664
18007
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18665
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /* Autocomplete Picker: Create and edit data using public data
18666
- **
18667
- ** As the data source is passed as a parameter, all kinds of APIa and query services can be used
18668
- **
18669
- */
18008
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
18670
18009
  var AUTOCOMPLETE_THRESHOLD = 4; // don't check until this many characters typed
18671
18010
  var AUTOCOMPLETE_ROWS = 20; // 20?
18672
18011
  var AUTOCOMPLETE_ROWS_STRETCH = 40;
@@ -18766,8 +18105,7 @@ function _renderAutoComplete() {
18766
18105
  };
18767
18106
  }());
18768
18107
  return row;
18769
- }; // console.log('@@ refreshList called')
18770
- // rowForBinding
18108
+ };
18771
18109
  if (!inputEventHandlerLock) {
18772
18110
  _context7.next = 5;
18773
18111
  break;
@@ -19020,7 +18358,7 @@ function _renderAutoComplete() {
19020
18358
  // errorMessageBlock will log the stack to the console
19021
18359
  style.setStyle(errorRow, 'autocompleteRowStyle');
19022
18360
  errorRow.style.padding = '1em';
19023
- }; // refreshList
18361
+ };
19024
18362
  // initialiize
19025
18363
  // const queryParams: QueryParameters = acOptions.queryParams
19026
18364
  targetClass = acOptions.targetClass;
@@ -19120,11 +18458,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
19120
18458
  // import * as logic from '../index'
19121
18459
  // import { authn } from '../../../authn/index'
19122
18460
 
19123
- // import { Binding } from '../widgets/forms/autocomplete/publicData'
19124
- // import { nativeNameForLanguageCode, englishNameForLanguageCode } from './nativeNameForLanguageCode'
19125
-
19126
- // const { currentUser } = logic.authn
19127
-
19128
18461
  var languageCodeURIBase = 'https://www.w3.org/ns/iana/language-code/'; /// @@ unsupported on the web (2021)
19129
18462
  exports.languageCodeURIBase = languageCodeURIBase;
19130
18463
  var defaultPreferredLanguages = ['en', 'fr', 'de', 'it', 'ar'];
@@ -21235,17 +20568,6 @@ var _iconBase = __webpack_require__(/*! ../iconBase */ "./lib/iconBase.js");
21235
20568
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
21236
20569
  var _solidLogic = __webpack_require__(/*! solid-logic */ "./node_modules/solid-logic/lib/index.js");
21237
20570
  var _templateObject;
21238
- /**
21239
- *
21240
- * People Picker Pane
21241
- *
21242
- * This pane offers a mechanism for selecting a set of individuals, groups, or
21243
- * organizations to take some action on.
21244
- *
21245
- * Assumptions
21246
- * - Assumes that the user has a type index entry for vcard:AddressBook. @@ bad assuption
21247
- *
21248
- */
21249
20571
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21250
20572
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21251
20573
  var kb = _solidLogic.solidLogicSingleton.store;