@banta/sdk 4.4.3 → 4.4.6

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.
@@ -125,7 +125,9 @@
125
125
  function LightboxComponent() {
126
126
  }
127
127
  LightboxComponent.prototype.ngAfterViewInit = function () {
128
- document.body.appendChild(this.containerElement.nativeElement);
128
+ if (typeof window !== 'undefined') {
129
+ document.body.appendChild(this.containerElement.nativeElement);
130
+ }
129
131
  };
130
132
  LightboxComponent.prototype.ngOnDestroy = function () {
131
133
  this.containerElement.nativeElement.remove();
@@ -314,7 +316,7 @@
314
316
  BantaAttachmentComponent.decorators = [
315
317
  { type: core.Component, args: [{
316
318
  selector: 'banta-attachment',
317
- template: "<button type=\"button\" (click)=\"remove()\" mat-mini-fab color=\"primary\" class=\"remove-button\" *ngIf=\"editing\">\r\n <mat-icon>close</mat-icon>\r\n</button>\r\n\r\n<ng-container *ngIf=\"isError\">\r\n <mat-icon class=\"error\">close</mat-icon>\r\n <em class=\"error\">{{theErrorMessage}}</em>\r\n</ng-container>\r\n<ng-container *ngIf=\"!isError\">\r\n <ng-container *ngIf=\"isLoading\">\r\n <mat-spinner></mat-spinner>\r\n <em>{{loadingMessage}}</em>\r\n </ng-container>\r\n <ng-container *ngIf=\"!isLoading\">\r\n <iframe *ngIf=\"hasFrame\"\r\n sandbox=\"allow-scripts allow-popups allow-same-origin allow-presentation\" \r\n [src]=\"frameUrl | trustResourceUrl\"></iframe>\r\n <a *ngIf=\"attachment.type === 'card'\" class=\"card\" [href]=\"attachment.url\" target=\"_blank\" [class.has-image]=\"attachment.card.image\">\r\n <img \r\n *ngIf=\"attachment.card.image\"\r\n class=\"thumbnail\" \r\n [src]=\"attachment.card.image\"\r\n />\r\n <div class=\"description\">\r\n <h1>{{attachment.card.title}}</h1>\r\n <div>\r\n {{attachment.card.description}}\r\n </div>\r\n <cite>{{attachment.card.url}}</cite>\r\n </div>\r\n </a>\r\n <a class=\"image-attachment\" *ngIf=\"isImageAttachment\" href=\"javascript:;\" (click)=\"activate()\">\r\n <img [src]=\"attachment.url\" alt=\"Image Attachment\">\r\n </a>\r\n <blockquote *ngIf=\"attachment.type === 'tweet'\" \r\n class=\"twitter-tweet\">\r\n <p lang=\"en\" dir=\"ltr\"></p>\r\n <a href=\"https://twitter.com/seldo/status/1562553608083714050?ref_src=twsrc%5Etfw\"></a>\r\n </blockquote>\r\n </ng-container>\r\n</ng-container>",
319
+ template: "<button type=\"button\" (click)=\"remove()\" mat-mini-fab color=\"primary\" class=\"remove-button\" *ngIf=\"editing\">\r\n <mat-icon>close</mat-icon>\r\n</button>\r\n\r\n<ng-container *ngIf=\"isError\">\r\n <mat-icon class=\"error\">close</mat-icon>\r\n <em class=\"error\">{{theErrorMessage}}</em>\r\n</ng-container>\r\n<ng-container *ngIf=\"!isError\">\r\n <ng-container *ngIf=\"isLoading\">\r\n <mat-spinner></mat-spinner>\r\n <em>{{loadingMessage}}</em>\r\n </ng-container>\r\n <ng-container *ngIf=\"!isLoading\">\r\n <iframe *ngIf=\"hasFrame\"\r\n sandbox=\"allow-scripts allow-popups allow-same-origin allow-presentation\" \r\n [src]=\"frameUrl | trustResourceUrl\"></iframe>\r\n <a *ngIf=\"attachment.type === 'card'\" class=\"card\" [href]=\"attachment.url\" target=\"_blank\" [class.has-image]=\"attachment.card.image\">\r\n <img \r\n *ngIf=\"attachment.card.image\"\r\n class=\"thumbnail\" \r\n [src]=\"attachment.card.image\"\r\n />\r\n <div class=\"description\">\r\n <h1>{{attachment.card.title}}</h1>\r\n <div>\r\n {{attachment.card.description}}\r\n </div>\r\n <cite>{{attachment.card.url}}</cite>\r\n </div>\r\n </a>\r\n <a class=\"image-attachment\" *ngIf=\"isImageAttachment\" href=\"javascript:;\" (click)=\"activate()\">\r\n <img [src]=\"attachment.url\" alt=\"Image Attachment\">\r\n </a>\r\n <blockquote *ngIf=\"attachment.type === 'tweet'\" \r\n class=\"twitter-tweet\">\r\n <p lang=\"en\" dir=\"ltr\"></p>\r\n <a [href]=\"attachment.url\"></a>\r\n </blockquote>\r\n </ng-container>\r\n</ng-container>",
318
320
  styles: [":host{position:relative;display:block}:host.loading{outline:1px solid #333;padding:1em 0;width:300px;text-align:center}:host.loading mat-spinner{display:block;margin:0 auto .5em;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}a.card{display:flex;align-items:flex-start;gap:1em;width:100%;border:1px solid #666;border-radius:4px;padding:1em;box-sizing:border-box;background-color:#191919;margin:1em 0}a.card img{width:250px;aspect-ratio:16/9;-o-object-fit:cover;object-fit:cover;border-radius:10px}a.card.has-image h1{font-size:22px}a.card h1{min-width:0;margin:0 0 .5em;font-size:26px}a.card cite{min-width:0;opacity:.75;margin-top:1em;display:block;font-size:90%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}a.card .description{min-width:0}.remove-button{position:absolute;right:10px;top:10px;margin:0;z-index:1}a.image-attachment{width:300px;position:relative;text-align:center}a.image-attachment.with-border{outline:1px solid #333;padding:1em 0}a.image-attachment mat-spinner{display:block;margin:0 auto .5em;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}a.image-attachment mat-icon.error{display:block;font-size:48px;width:48px;height:48px;margin:0 auto .5em}a.image-attachment .error{color:#b76363}a.image-attachment img{width:300px;border-radius:10px;max-width:100%;max-height:20em;-o-object-fit:cover;object-fit:cover}iframe{border:none;width:100%;aspect-ratio:16/9}"]
319
321
  },] }
320
322
  ];
@@ -8247,7 +8249,7 @@
8247
8249
  user: null,
8248
8250
  sentAt: Date.now(),
8249
8251
  likes: 0,
8250
- url: location.href,
8252
+ url: typeof window !== 'undefined' ? location.href : undefined,
8251
8253
  message: text
8252
8254
  };
8253
8255
  _b.label = 1;
@@ -9088,20 +9090,23 @@
9088
9090
  });
9089
9091
  BantaCommentsComponent.prototype.ngAfterViewInit = function () {
9090
9092
  var _this = this;
9091
- var callback = function () {
9092
- var size = _this.elementRef.nativeElement.getBoundingClientRect();
9093
- _this.ngZone.run(function () {
9094
- _this.width = size.width;
9095
- _this.height = size.height;
9096
- });
9097
- };
9098
- this.resizeObserver = new ResizeObserver(callback);
9099
- this.resizeObserver.observe(this.elementRef.nativeElement);
9100
- callback();
9093
+ if (typeof window !== 'undefined') {
9094
+ var callback = function () {
9095
+ var size = _this.elementRef.nativeElement.getBoundingClientRect();
9096
+ _this.ngZone.run(function () {
9097
+ _this.width = size.width;
9098
+ _this.height = size.height;
9099
+ });
9100
+ };
9101
+ this.resizeObserver = new ResizeObserver(callback);
9102
+ this.resizeObserver.observe(this.elementRef.nativeElement);
9103
+ callback();
9104
+ }
9101
9105
  };
9102
9106
  BantaCommentsComponent.prototype.ngOnDestroy = function () {
9103
9107
  this._subs.unsubscribe();
9104
- this.resizeObserver.disconnect();
9108
+ if (this.resizeObserver)
9109
+ this.resizeObserver.disconnect();
9105
9110
  };
9106
9111
  BantaCommentsComponent.prototype.setSourceFromTopicID = function (topicID) {
9107
9112
  return __awaiter(this, void 0, void 0, function () {
@@ -9313,6 +9318,8 @@
9313
9318
  });
9314
9319
  // UI Interactions
9315
9320
  BantaCommentsComponent.prototype.scrollToComment = function (commentId) {
9321
+ if (typeof window === 'undefined')
9322
+ return;
9316
9323
  setTimeout(function () {
9317
9324
  var comment = document.querySelectorAll("[data-comment-id=\"" + commentId + "\"]");
9318
9325
  if (comment.length > 0) {
@@ -9415,25 +9422,31 @@
9415
9422
  return __generator(this, function (_d) {
9416
9423
  switch (_d.label) {
9417
9424
  case 0:
9425
+ if (!!this.user) return [3 /*break*/, 2];
9426
+ return [4 /*yield*/, this.showSignIn()];
9427
+ case 1:
9428
+ _d.sent();
9429
+ return [2 /*return*/];
9430
+ case 2:
9418
9431
  this._upvoted.next(message);
9419
9432
  message.transientState.liking = true;
9420
- _d.label = 1;
9421
- case 1:
9422
- _d.trys.push([1, 3, 4, 6]);
9433
+ _d.label = 3;
9434
+ case 3:
9435
+ _d.trys.push([3, 5, 6, 8]);
9423
9436
  return [4 /*yield*/, source.likeMessage(message.id)];
9424
- case 2:
9437
+ case 4:
9425
9438
  _d.sent();
9426
- return [3 /*break*/, 6];
9427
- case 3:
9439
+ return [3 /*break*/, 8];
9440
+ case 5:
9428
9441
  e_4 = _d.sent();
9429
9442
  this.handleBackendExceptionAsAlert(e_4, 'Could not like this message: ');
9430
- return [3 /*break*/, 6];
9431
- case 4: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 250); })];
9432
- case 5:
9443
+ return [3 /*break*/, 8];
9444
+ case 6: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 250); })];
9445
+ case 7:
9433
9446
  _d.sent();
9434
9447
  message.transientState.liking = false;
9435
9448
  return [7 /*endfinally*/];
9436
- case 6: return [2 /*return*/];
9449
+ case 8: return [2 /*return*/];
9437
9450
  }
9438
9451
  });
9439
9452
  });
@@ -9445,23 +9458,29 @@
9445
9458
  return __generator(this, function (_d) {
9446
9459
  switch (_d.label) {
9447
9460
  case 0:
9461
+ if (!!this.user) return [3 /*break*/, 2];
9462
+ return [4 /*yield*/, this.showSignIn()];
9463
+ case 1:
9464
+ _d.sent();
9465
+ return [2 /*return*/];
9466
+ case 2:
9448
9467
  this._upvoted.next(message);
9449
9468
  message.transientState.liking = true;
9450
9469
  if ((_a = message.userState) === null || _a === void 0 ? void 0 : _a.liked)
9451
9470
  message.likes = (message.likes || 0) - 1;
9452
- _d.label = 1;
9453
- case 1:
9454
- _d.trys.push([1, 3, , 4]);
9471
+ _d.label = 3;
9472
+ case 3:
9473
+ _d.trys.push([3, 5, , 6]);
9455
9474
  return [4 /*yield*/, source.unlikeMessage(message.id)];
9456
- case 2:
9475
+ case 4:
9457
9476
  _d.sent();
9458
- return [3 /*break*/, 4];
9459
- case 3:
9477
+ return [3 /*break*/, 6];
9478
+ case 5:
9460
9479
  e_5 = _d.sent();
9461
9480
  this.handleBackendExceptionAsAlert(e_5, 'Failed to unlike this message: ');
9462
- return [3 /*break*/, 4];
9463
- case 4: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 250); })];
9464
- case 5:
9481
+ return [3 /*break*/, 6];
9482
+ case 6: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 250); })];
9483
+ case 7:
9465
9484
  _d.sent();
9466
9485
  message.transientState.liking = false;
9467
9486
  return [2 /*return*/];
@@ -9578,20 +9597,26 @@
9578
9597
  return __generator(this, function (_d) {
9579
9598
  switch (_d.label) {
9580
9599
  case 0:
9600
+ if (!!this.user) return [3 /*break*/, 2];
9601
+ return [4 /*yield*/, this.showSignIn()];
9602
+ case 1:
9603
+ _d.sent();
9604
+ return [2 /*return*/];
9605
+ case 2:
9581
9606
  if (!confirm("Are you sure you want to delete this comment? You cannot undo this action."))
9582
9607
  return [2 /*return*/];
9583
- _d.label = 1;
9584
- case 1:
9585
- _d.trys.push([1, 3, , 4]);
9608
+ _d.label = 3;
9609
+ case 3:
9610
+ _d.trys.push([3, 5, , 6]);
9586
9611
  return [4 /*yield*/, this.source.deleteMessage(message.id)];
9587
- case 2:
9612
+ case 4:
9588
9613
  _d.sent();
9589
- return [3 /*break*/, 4];
9590
- case 3:
9614
+ return [3 /*break*/, 6];
9615
+ case 5:
9591
9616
  e_6 = _d.sent();
9592
9617
  this.handleBackendExceptionAsAlert(e_6, "Could not delete message: ");
9593
- return [3 /*break*/, 4];
9594
- case 4: return [2 /*return*/];
9618
+ return [3 /*break*/, 6];
9619
+ case 6: return [2 /*return*/];
9595
9620
  }
9596
9621
  });
9597
9622
  });
@@ -9602,16 +9627,22 @@
9602
9627
  return __generator(this, function (_d) {
9603
9628
  switch (_d.label) {
9604
9629
  case 0:
9605
- _d.trys.push([0, 2, , 3]);
9606
- return [4 /*yield*/, source.editMessage(message.id, newText)];
9630
+ if (!!this.user) return [3 /*break*/, 2];
9631
+ return [4 /*yield*/, this.showSignIn()];
9607
9632
  case 1:
9608
9633
  _d.sent();
9609
- return [3 /*break*/, 3];
9634
+ return [2 /*return*/];
9610
9635
  case 2:
9636
+ _d.trys.push([2, 4, , 5]);
9637
+ return [4 /*yield*/, source.editMessage(message.id, newText)];
9638
+ case 3:
9639
+ _d.sent();
9640
+ return [3 /*break*/, 5];
9641
+ case 4:
9611
9642
  e_7 = _d.sent();
9612
9643
  this.handleBackendExceptionAsAlert(e_7, 'Could not edit this message: ');
9613
9644
  return [2 /*return*/];
9614
- case 3:
9645
+ case 5:
9615
9646
  message.message = newText;
9616
9647
  message.transientState.editing = false;
9617
9648
  return [2 /*return*/];
@@ -9634,17 +9665,23 @@
9634
9665
  return __generator(this, function (_d) {
9635
9666
  switch (_d.label) {
9636
9667
  case 0:
9637
- _d.trys.push([0, 2, , 3]);
9638
- return [4 /*yield*/, this.source.editMessage(message.id, text)];
9668
+ if (!!this.user) return [3 /*break*/, 2];
9669
+ return [4 /*yield*/, this.showSignIn()];
9639
9670
  case 1:
9640
9671
  _d.sent();
9641
- message.transientState.editing = false;
9642
- return [3 /*break*/, 3];
9672
+ return [2 /*return*/];
9643
9673
  case 2:
9674
+ _d.trys.push([2, 4, , 5]);
9675
+ return [4 /*yield*/, this.source.editMessage(message.id, text)];
9676
+ case 3:
9677
+ _d.sent();
9678
+ message.transientState.editing = false;
9679
+ return [3 /*break*/, 5];
9680
+ case 4:
9644
9681
  e_8 = _d.sent();
9645
9682
  this.handleBackendExceptionAsAlert(e_8, "Could not edit message: ");
9646
- return [3 /*break*/, 3];
9647
- case 3: return [2 /*return*/];
9683
+ return [3 /*break*/, 5];
9684
+ case 5: return [2 /*return*/];
9648
9685
  }
9649
9686
  });
9650
9687
  });
@@ -10021,13 +10058,17 @@
10021
10058
  configurable: true
10022
10059
  });
10023
10060
  CommentFieldComponent.prototype.ngAfterViewInit = function () {
10024
- var root = document.body.querySelector('[ng-version]') || document.body;
10025
- root.appendChild(this.autocompleteEl.nativeElement);
10061
+ if (typeof window !== 'undefined') {
10062
+ var root = document.body.querySelector('[ng-version]') || document.body;
10063
+ root.appendChild(this.autocompleteEl.nativeElement);
10064
+ }
10026
10065
  };
10027
10066
  CommentFieldComponent.prototype.sendPermissionDenied = function (message) {
10028
10067
  this._permissionDeniedError.next(message);
10029
10068
  };
10030
10069
  CommentFieldComponent.prototype.showAutoComplete = function (options) {
10070
+ if (typeof window === 'undefined')
10071
+ return;
10031
10072
  this.autoCompleteSelected = 0;
10032
10073
  this.autocompleteOptions = options;
10033
10074
  var pos = this.autocompleteContainerEl.nativeElement.getBoundingClientRect();
@@ -10058,7 +10099,7 @@
10058
10099
  }, 5 * 1000);
10059
10100
  }, 100);
10060
10101
  // On mobile, just show an alert dialog
10061
- if (window.innerWidth < 430)
10102
+ if (typeof window !== 'undefined' && window.innerWidth < 430)
10062
10103
  alert(message);
10063
10104
  };
10064
10105
  Object.defineProperty(CommentFieldComponent.prototype, "isValidMessage", {
@@ -10249,7 +10290,7 @@
10249
10290
  message = {
10250
10291
  user: this.user,
10251
10292
  sentAt: Date.now(),
10252
- url: location.href,
10293
+ url: typeof window !== 'undefined' ? location.href : undefined,
10253
10294
  likes: 0,
10254
10295
  message: text,
10255
10296
  attachments: this.chatMessageAttachments.filter(function (x) { return x.url; })