@banta/sdk 4.6.7 → 4.6.8

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.
@@ -7408,6 +7408,8 @@
7408
7408
  this.overlay = overlay;
7409
7409
  this._selected = new rxjs.Subject();
7410
7410
  this.showEmojiPanel = false;
7411
+ this.overlayX = 'end';
7412
+ this.overlayY = 'top';
7411
7413
  }
7412
7414
  Object.defineProperty(EmojiSelectorButtonComponent.prototype, "selected", {
7413
7415
  get: function () {
@@ -7449,8 +7451,8 @@
7449
7451
  {
7450
7452
  originX: 'end',
7451
7453
  originY: 'bottom',
7452
- overlayX: 'end',
7453
- overlayY: 'top'
7454
+ overlayX: this.overlayX,
7455
+ overlayY: this.overlayY
7454
7456
  }
7455
7457
  ])
7456
7458
  .withFlexibleDimensions(true),
@@ -7485,7 +7487,9 @@
7485
7487
  ]; };
7486
7488
  EmojiSelectorButtonComponent.propDecorators = {
7487
7489
  selectorPanelTemplate: [{ type: core.ViewChild, args: ['selectorPanelTemplate',] }],
7488
- selected: [{ type: core.Output }]
7490
+ selected: [{ type: core.Output }],
7491
+ overlayX: [{ type: core.Input }],
7492
+ overlayY: [{ type: core.Input }]
7489
7493
  };
7490
7494
 
7491
7495
  var COMPONENTS$1 = [
@@ -10256,8 +10260,6 @@
10256
10260
  this.sending = false;
10257
10261
  this.expandError = false;
10258
10262
  this._text = '';
10259
- this.attachmentScrapeDebounce = 1500;
10260
- this.attachmentFragments = new Map();
10261
10263
  this.sendLabel = 'Send';
10262
10264
  this.sendingLabel = 'Sending';
10263
10265
  this.label = 'Post a comment';
@@ -10312,166 +10314,11 @@
10312
10314
  return this._text;
10313
10315
  },
10314
10316
  set: function (value) {
10315
- var _this = this;
10316
10317
  this._text = value;
10317
- clearTimeout(this.attachmentScrapeTimeout);
10318
- this.attachmentScrapeTimeout = setTimeout(function () { return _this.scrapeAttachments(); }, this.attachmentScrapeDebounce);
10319
10318
  },
10320
10319
  enumerable: false,
10321
10320
  configurable: true
10322
10321
  });
10323
- CommentFieldComponent.prototype.scrapeAttachments = function () {
10324
- var e_1, _b, e_2, _c, e_3, _d, e_4, _e, e_5, _f;
10325
- var _this = this;
10326
- var message = {
10327
- likes: 0,
10328
- message: this._text,
10329
- sentAt: undefined,
10330
- user: this.user,
10331
- attachments: this.chatMessageAttachments
10332
- };
10333
- var foundFragments = [];
10334
- try {
10335
- for (var _g = __values(this.chatBackend.attachmentScrapers), _h = _g.next(); !_h.done; _h = _g.next()) {
10336
- var scraper = _h.value;
10337
- var fragments = scraper.findFragments(message);
10338
- if (!fragments) {
10339
- console.error("Attachment fragment scraper " + scraper.constructor.name + " is implemented incorrectly: Returned null instead of array");
10340
- continue;
10341
- }
10342
- try {
10343
- for (var fragments_1 = (e_2 = void 0, __values(fragments)), fragments_1_1 = fragments_1.next(); !fragments_1_1.done; fragments_1_1 = fragments_1.next()) {
10344
- var fragment = fragments_1_1.value;
10345
- foundFragments.push(fragment.text);
10346
- if (!this.attachmentFragments.has(fragment.text)) {
10347
- console.log("Scraped new fragment:");
10348
- console.dir(fragment);
10349
- this.attachmentFragments.set(fragment.text, {
10350
- fragment: fragment,
10351
- resolution: undefined
10352
- });
10353
- }
10354
- }
10355
- }
10356
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
10357
- finally {
10358
- try {
10359
- if (fragments_1_1 && !fragments_1_1.done && (_c = fragments_1.return)) _c.call(fragments_1);
10360
- }
10361
- finally { if (e_2) throw e_2.error; }
10362
- }
10363
- }
10364
- }
10365
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
10366
- finally {
10367
- try {
10368
- if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
10369
- }
10370
- finally { if (e_1) throw e_1.error; }
10371
- }
10372
- // Remove fragments that are no longer in the message.
10373
- var removedFragments = [];
10374
- try {
10375
- for (var _j = __values(this.attachmentFragments), _k = _j.next(); !_k.done; _k = _j.next()) {
10376
- var _l = __read(_k.value, 1), key = _l[0];
10377
- if (!foundFragments.includes(key))
10378
- removedFragments.push(key);
10379
- }
10380
- }
10381
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
10382
- finally {
10383
- try {
10384
- if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
10385
- }
10386
- finally { if (e_3) throw e_3.error; }
10387
- }
10388
- try {
10389
- for (var removedFragments_1 = __values(removedFragments), removedFragments_1_1 = removedFragments_1.next(); !removedFragments_1_1.done; removedFragments_1_1 = removedFragments_1.next()) {
10390
- var removedFragment = removedFragments_1_1.value;
10391
- console.log("Removed fragment: " + removedFragment);
10392
- this.attachmentFragments.delete(removedFragment);
10393
- }
10394
- }
10395
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
10396
- finally {
10397
- try {
10398
- if (removedFragments_1_1 && !removedFragments_1_1.done && (_e = removedFragments_1.return)) _e.call(removedFragments_1);
10399
- }
10400
- finally { if (e_4) throw e_4.error; }
10401
- }
10402
- var _loop_1 = function (key, state) {
10403
- if (state.resolution)
10404
- return "continue";
10405
- state.resolution = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
10406
- var _b, _c, resolver, attachment, e_6, e_7_1;
10407
- var e_7, _d;
10408
- return __generator(this, function (_e) {
10409
- switch (_e.label) {
10410
- case 0:
10411
- console.log("Resolving fragment " + key);
10412
- _e.label = 1;
10413
- case 1:
10414
- _e.trys.push([1, 8, 9, 10]);
10415
- _b = __values(this.chatBackend.attachmentResolvers), _c = _b.next();
10416
- _e.label = 2;
10417
- case 2:
10418
- if (!!_c.done) return [3 /*break*/, 7];
10419
- resolver = _c.value;
10420
- console.log("- Trying resolver " + resolver.constructor.name + "...");
10421
- _e.label = 3;
10422
- case 3:
10423
- _e.trys.push([3, 5, , 6]);
10424
- return [4 /*yield*/, resolver.resolveFragment(message, state.fragment)];
10425
- case 4:
10426
- attachment = _e.sent();
10427
- if (attachment) {
10428
- console.log("Resolved fragment " + key + " into attachment:");
10429
- console.dir(attachment);
10430
- this.chatMessageAttachments.push(attachment);
10431
- resolve(attachment);
10432
- return [3 /*break*/, 7];
10433
- }
10434
- return [3 /*break*/, 6];
10435
- case 5:
10436
- e_6 = _e.sent();
10437
- console.error("Caught error during attachment resolver " + resolver.constructor.name + ":");
10438
- console.error(e_6);
10439
- return [3 /*break*/, 6];
10440
- case 6:
10441
- _c = _b.next();
10442
- return [3 /*break*/, 2];
10443
- case 7: return [3 /*break*/, 10];
10444
- case 8:
10445
- e_7_1 = _e.sent();
10446
- e_7 = { error: e_7_1 };
10447
- return [3 /*break*/, 10];
10448
- case 9:
10449
- try {
10450
- if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
10451
- }
10452
- finally { if (e_7) throw e_7.error; }
10453
- return [7 /*endfinally*/];
10454
- case 10: return [2 /*return*/];
10455
- }
10456
- });
10457
- }); });
10458
- };
10459
- try {
10460
- // Process any fragments that are not yet resolved (or being
10461
- // resolved)
10462
- for (var _m = __values(this.attachmentFragments), _o = _m.next(); !_o.done; _o = _m.next()) {
10463
- var _p = __read(_o.value, 2), key = _p[0], state = _p[1];
10464
- _loop_1(key, state);
10465
- }
10466
- }
10467
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
10468
- finally {
10469
- try {
10470
- if (_o && !_o.done && (_f = _m.return)) _f.call(_m);
10471
- }
10472
- finally { if (e_5) throw e_5.error; }
10473
- }
10474
- };
10475
10322
  Object.defineProperty(CommentFieldComponent.prototype, "userAvatarUrl", {
10476
10323
  get: function () {
10477
10324
  var _a;
@@ -10705,7 +10552,7 @@
10705
10552
  };
10706
10553
  CommentFieldComponent.prototype.sendMessage = function () {
10707
10554
  return __awaiter(this, void 0, void 0, function () {
10708
- var text, message, e_8;
10555
+ var text, message, e_1;
10709
10556
  var _this = this;
10710
10557
  return __generator(this, function (_b) {
10711
10558
  switch (_b.label) {
@@ -10738,11 +10585,11 @@
10738
10585
  this.chatMessageAttachments = [];
10739
10586
  return [3 /*break*/, 6];
10740
10587
  case 4:
10741
- e_8 = _b.sent();
10588
+ e_1 = _b.sent();
10742
10589
  return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(function () { return resolve(); }, 1000); })];
10743
10590
  case 5:
10744
10591
  _b.sent();
10745
- this.indicateError(e_8.message);
10592
+ this.indicateError(e_1.message);
10746
10593
  return [3 /*break*/, 6];
10747
10594
  case 6: return [3 /*break*/, 8];
10748
10595
  case 7:
@@ -10780,7 +10627,7 @@
10780
10627
  CommentFieldComponent.decorators = [
10781
10628
  { type: core.Component, args: [{
10782
10629
  selector: 'banta-comment-field',
10783
- template: "<form class=\"new-message\" (submit)=\"sendMessage()\">\r\n <div class=\"avatar-container\">\r\n <a href=\"javascript:;\"\r\n class=\"avatar\"\r\n (click)=\"showEditAvatar()\"\r\n [style.background-image]=\"'url(' + userAvatarUrl + ')'\"\r\n ></a>\r\n </div>\r\n <div class=\"text-container\">\r\n <div class=\"field-container\">\r\n <div class=\"field-row\">\r\n <mat-form-field class=\"message-field\" appearance=\"outline\" floatLabel=\"always\">\r\n <mat-label>{{label}}</mat-label>\r\n <textarea\r\n #textarea\r\n name=\"message\"\r\n [placeholder]=\"placeholder\"\r\n matInput\r\n cdkTextareaAutosize\r\n [maxlength]=\"maxLength\"\r\n (keydown)=\"onKeyDown($event)\"\r\n (blur)=\"onBlur()\"\r\n [disabled]=\"sending\"\r\n [(ngModel)]=\"text\"></textarea>\r\n </mat-form-field>\r\n <div class=\"options-line\">\r\n <mat-spinner *ngIf=\"sending\" class=\"icon loading\" diameter=\"18\" strokeWidth=\"2\"></mat-spinner>\r\n <div *ngIf=\"sendError\" class=\"error-message\" [class.expanded]=\"expandError\" [matTooltip]=\"sendError.message\" (click)=\"alertError()\">\r\n <mat-icon *ngIf=\"sendError\">error</mat-icon>\r\n {{sendError.message}}\r\n </div>\r\n <div *ngIf=\"!sendError && transientMessage\" class=\"transient-message\" [class.expanded]=\"true\" [matTooltip]=\"transientMessage\" (click)=\"alertError()\">\r\n <mat-spinner [inline]=\"true\" [diameter]=\"15\"></mat-spinner>\r\n {{transientMessage}}\r\n </div>\r\n <div class=\"spacer\"></div>\r\n <div class=\"custom\">\r\n <ng-content></ng-content>\r\n </div>\r\n <banta-attachment-button \r\n *ngIf=\"allowAttachments\"\r\n (addedAttachment)=\"addedAttachment($event)\"\r\n (attachmentError)=\"attachmentError($event)\"\r\n ></banta-attachment-button>\r\n <emoji-selector-button (selected)=\"insertEmoji($event)\"></emoji-selector-button>\r\n </div>\r\n \r\n </div>\r\n <div #autocompleteContainer class=\"autocomplete-container\">\r\n <div #autocomplete class=\"autocomplete\" [class.visible]=\"autocompleteVisible\">\r\n\r\n <div>\r\n <strong>{{completionPrefix}}</strong>...\r\n </div>\r\n <a\r\n mat-button\r\n *ngFor=\"let option of autocompleteOptions; index as index\"\r\n (click)=\"activateAutoComplete(option)\"\r\n [class.active]=\"autoCompleteSelected === index\"\r\n >\r\n {{option.label}}\r\n </a>\r\n </div>\r\n </div>\r\n\r\n <banta-attachments \r\n [attachments]=\"chatMessageAttachments\"\r\n [editing]=\"true\"\r\n (remove)=\"removeAttachment($event)\"\r\n ></banta-attachments>\r\n </div>\r\n </div>\r\n <div class=\"actions\">\r\n <ng-container *ngIf=\"!user\">\r\n <button\r\n mat-raised-button\r\n color=\"primary\"\r\n type=\"button\"\r\n (click)=\"showSignIn()\"\r\n >{{signInLabel}}</button>\r\n </ng-container>\r\n <ng-container *ngIf=\"user\">\r\n <button\r\n mat-raised-button\r\n class=\"send\"\r\n color=\"primary\"\r\n [disabled]=\"!sendButtonEnabled\"\r\n >\r\n <ng-container *ngIf=\"canComment\">\r\n <mat-icon *ngIf=\"!sending\">chevron_right</mat-icon>\r\n <mat-spinner *ngIf=\"sending\" class=\"icon\" diameter=\"18\" strokeWidth=\"2\"></mat-spinner>\r\n </ng-container>\r\n <span class=\"label\">\r\n <ng-container *ngIf=\"!canComment\">\r\n {{permissionDeniedLabel}}\r\n </ng-container>\r\n <ng-container *ngIf=\"canComment\">\r\n <ng-container *ngIf=\"!sending\">\r\n {{sendLabel}}\r\n </ng-container>\r\n <ng-container *ngIf=\"sending\">\r\n {{sendingLabel}}\r\n </ng-container>\r\n </ng-container>\r\n </span>\r\n </button>\r\n </ng-container>\r\n </div>\r\n</form>",
10630
+ template: "<form class=\"new-message\" (submit)=\"sendMessage()\">\r\n <div class=\"avatar-container\">\r\n <a href=\"javascript:;\"\r\n class=\"avatar\"\r\n (click)=\"showEditAvatar()\"\r\n [style.background-image]=\"'url(' + userAvatarUrl + ')'\"\r\n ></a>\r\n </div>\r\n <div class=\"text-container\">\r\n <div class=\"field-container\">\r\n <div class=\"field-row\">\r\n <mat-form-field class=\"message-field\" appearance=\"outline\" floatLabel=\"always\">\r\n <mat-label>{{label}}</mat-label>\r\n <textarea\r\n #textarea\r\n name=\"message\"\r\n attachmentScraper\r\n (attachmentsChanged)=\"chatMessageAttachments = $event\"\r\n [placeholder]=\"placeholder\"\r\n matInput\r\n cdkTextareaAutosize\r\n [maxlength]=\"maxLength\"\r\n (keydown)=\"onKeyDown($event)\"\r\n (blur)=\"onBlur()\"\r\n [disabled]=\"sending\"\r\n [(ngModel)]=\"text\"></textarea>\r\n </mat-form-field>\r\n <div class=\"options-line\">\r\n <mat-spinner *ngIf=\"sending\" class=\"icon loading\" diameter=\"18\" strokeWidth=\"2\"></mat-spinner>\r\n <div *ngIf=\"sendError\" class=\"error-message\" [class.expanded]=\"expandError\" [matTooltip]=\"sendError.message\" (click)=\"alertError()\">\r\n <mat-icon *ngIf=\"sendError\">error</mat-icon>\r\n {{sendError.message}}\r\n </div>\r\n <div *ngIf=\"!sendError && transientMessage\" class=\"transient-message\" [class.expanded]=\"true\" [matTooltip]=\"transientMessage\" (click)=\"alertError()\">\r\n <mat-spinner [inline]=\"true\" [diameter]=\"15\"></mat-spinner>\r\n {{transientMessage}}\r\n </div>\r\n <div class=\"spacer\"></div>\r\n <div class=\"custom\">\r\n <ng-content></ng-content>\r\n </div>\r\n <banta-attachment-button \r\n *ngIf=\"allowAttachments\"\r\n (addedAttachment)=\"addedAttachment($event)\"\r\n (attachmentError)=\"attachmentError($event)\"\r\n ></banta-attachment-button>\r\n <emoji-selector-button (selected)=\"insertEmoji($event)\"></emoji-selector-button>\r\n </div>\r\n \r\n </div>\r\n <div #autocompleteContainer class=\"autocomplete-container\">\r\n <div #autocomplete class=\"autocomplete\" [class.visible]=\"autocompleteVisible\">\r\n\r\n <div>\r\n <strong>{{completionPrefix}}</strong>...\r\n </div>\r\n <a\r\n mat-button\r\n *ngFor=\"let option of autocompleteOptions; index as index\"\r\n (click)=\"activateAutoComplete(option)\"\r\n [class.active]=\"autoCompleteSelected === index\"\r\n >\r\n {{option.label}}\r\n </a>\r\n </div>\r\n </div>\r\n\r\n <banta-attachments \r\n [attachments]=\"chatMessageAttachments\"\r\n [editing]=\"true\"\r\n (remove)=\"removeAttachment($event)\"\r\n ></banta-attachments>\r\n </div>\r\n </div>\r\n <div class=\"actions\">\r\n <ng-container *ngIf=\"!user\">\r\n <button\r\n mat-raised-button\r\n color=\"primary\"\r\n type=\"button\"\r\n (click)=\"showSignIn()\"\r\n >{{signInLabel}}</button>\r\n </ng-container>\r\n <ng-container *ngIf=\"user\">\r\n <button\r\n mat-raised-button\r\n class=\"send\"\r\n color=\"primary\"\r\n [disabled]=\"!sendButtonEnabled\"\r\n >\r\n <ng-container *ngIf=\"canComment\">\r\n <mat-icon *ngIf=\"!sending\">chevron_right</mat-icon>\r\n <mat-spinner *ngIf=\"sending\" class=\"icon\" diameter=\"18\" strokeWidth=\"2\"></mat-spinner>\r\n </ng-container>\r\n <span class=\"label\">\r\n <ng-container *ngIf=\"!canComment\">\r\n {{permissionDeniedLabel}}\r\n </ng-container>\r\n <ng-container *ngIf=\"canComment\">\r\n <ng-container *ngIf=\"!sending\">\r\n {{sendLabel}}\r\n </ng-container>\r\n <ng-container *ngIf=\"sending\">\r\n {{sendingLabel}}\r\n </ng-container>\r\n </ng-container>\r\n </span>\r\n </button>\r\n </ng-container>\r\n </div>\r\n</form>",
10784
10631
  styles: ["@-webkit-keyframes comment-field-appear{0%{transform:translateY(128px);opacity:0}to{transform:translate(0);opacity:1}}@keyframes comment-field-appear{0%{transform:translateY(128px);opacity:0}to{transform:translate(0);opacity:1}}:host{margin:0 2em 0 0;display:block;-webkit-animation-name:comment-field-appear;animation-name:comment-field-appear;-webkit-animation-duration:.8s;animation-duration:.8s;-webkit-animation-delay:.4s;animation-delay:.4s;-webkit-animation-fill-mode:both;animation-fill-mode:both;position:relative;z-index:20}.avatar-container{width:calc(48px + 1.75em);display:flex;justify-content:flex-end;flex-shrink:0}.avatar-container .avatar{width:48px;height:48px;background:#000;border-radius:100%;background-size:cover;background-repeat:no-repeat;background-position:50%;margin-top:.75em;margin-right:.75em}form{display:flex;padding:.5em;align-items:center}form .text-container{position:relative;display:flex;flex-grow:1;min-width:0}form .text-container textarea{font-size:14pt;width:100%}form .text-container textarea[disabled]{opacity:.5}form .text-container mat-spinner.loading{position:absolute;left:.5em;bottom:.5em}form .text-container .options-line{display:flex;align-items:center}form .text-container .options-line>*{flex-shrink:0}form .text-container .options-line .transient-message{display:flex;flex-direction:row;align-items:center;gap:.5em}form .text-container .options-line .error-message{left:.5em;bottom:.5em;color:#683333;overflow-x:hidden;max-width:1.5em;white-space:nowrap;transition:max-width 2s ease-in-out;text-overflow:ellipsis;overflow:hidden;flex-shrink:1}form .text-container .options-line .error-message.expanded,form .text-container .options-line .error-message:hover{max-width:100%}form .text-container .options-line .error-message mat-icon{vertical-align:middle}form input[type=text]{background:#000;color:#fff;border:1px solid #333;width:100%;height:1em}form .actions{margin-left:1em;flex-shrink:0}form button{display:block;margin:0 0 0 auto}form.new-message{display:flex;align-items:flex-start;min-width:0}form.new-message .field-container{flex-grow:1;display:flex;flex-direction:column;min-width:0}form.new-message mat-form-field{width:100%}form.new-message mat-form-field ::ng-deep .mat-form-field-wrapper{padding-bottom:0}form.new-message button{margin:1.25em 0 0}button.send{min-width:9em}textarea{max-height:7em}.autocomplete-container{width:calc(100% - 2em);position:relative;pointer-events:none;top:-2em}.autocomplete{visibility:hidden;pointer-events:none;position:absolute;background:#333;padding:.5em;display:flex;flex-direction:column;z-index:100}.autocomplete.visible{visibility:visible;pointer-events:auto}.autocomplete a{width:100%;text-align:left}.autocomplete a.active{background:#555}.image-attachments-container{display:flex;gap:20px}.image-attachments-container .image-attachment{width:300px;position:relative;text-align:center}.image-attachments-container .image-attachment.with-border{outline:1px solid #333;padding:1em 0}.image-attachments-container .image-attachment mat-spinner{display:block;margin:0 auto .5em;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}.image-attachments-container .image-attachment mat-icon.error{display:block;font-size:48px;width:48px;height:48px;margin:0 auto .5em}.image-attachments-container .image-attachment .error{color:#b76363}.image-attachments-container .image-attachment img{width:300px;border-radius:10px}.image-attachments-container .image-attachment .remove-img{position:absolute;right:10px;top:10px;margin:0}.card-attachment,.field-row{position:relative}.card-attachment a{display:flex;align-items:flex-start;gap:1em;width:100%;border:1px solid #666;border-radius:4px;padding:2em;box-sizing:border-box;background-color:#191919}.card-attachment a img{width:300px;aspect-ratio:16/9;-o-object-fit:cover;object-fit:cover;border-radius:10px}.card-attachment a h1{margin:0;font-size:30px}.card-attachment .remove-img{position:absolute;right:10px;top:10px;margin:0}@media (max-width:500px){:host{margin:0}.avatar-container{width:auto;flex-shrink:0}.avatar-container .avatar{width:32px;height:32px;margin-top:1.5em}:host.can-comment button.send .label,:host:not(.can-comment) .text-container,:host:not(.can-comment) mat-form-field.message-field{display:none}button.send{min-width:auto;margin-top:1.5em}}:host-context(.banta-mobile) :host{margin:0}:host-context(.banta-mobile) .avatar-container{width:auto;flex-shrink:0}:host-context(.banta-mobile) .avatar-container .avatar{width:32px;height:32px;margin-top:1.5em}:host-context(.banta-mobile) :host.can-comment button.send .label,:host-context(.banta-mobile) :host:not(.can-comment) .text-container,:host-context(.banta-mobile) :host:not(.can-comment) mat-form-field.message-field{display:none}:host-context(.banta-mobile) button.send{min-width:auto;margin-top:1.5em}"]
10785
10632
  },] }
10786
10633
  ];
@@ -10942,6 +10789,207 @@
10942
10789
  attachmentError: [{ type: core.Output }]
10943
10790
  };
10944
10791
 
10792
+ var AttachmentScraperDirective = /** @class */ (function () {
10793
+ function AttachmentScraperDirective(elementRef, chatBackend) {
10794
+ this.elementRef = elementRef;
10795
+ this.chatBackend = chatBackend;
10796
+ this.attachments = [];
10797
+ this.attachmentsChanged = new rxjs.BehaviorSubject([]);
10798
+ this.scrapeDebounce = 1500;
10799
+ this.fragments = new Map();
10800
+ }
10801
+ AttachmentScraperDirective.prototype.ngOnInit = function () {
10802
+ var _this = this;
10803
+ if (typeof window === 'undefined')
10804
+ return;
10805
+ this.element.addEventListener('keydown', function () {
10806
+ clearTimeout(_this.scrapeTimeout);
10807
+ _this.scrapeTimeout = setTimeout(function () { return _this.scrape(); }, _this.scrapeDebounce);
10808
+ });
10809
+ };
10810
+ Object.defineProperty(AttachmentScraperDirective.prototype, "element", {
10811
+ get: function () {
10812
+ var _a;
10813
+ return (_a = this.elementRef) === null || _a === void 0 ? void 0 : _a.nativeElement;
10814
+ },
10815
+ enumerable: false,
10816
+ configurable: true
10817
+ });
10818
+ Object.defineProperty(AttachmentScraperDirective.prototype, "text", {
10819
+ get: function () {
10820
+ return this.element.value;
10821
+ },
10822
+ enumerable: false,
10823
+ configurable: true
10824
+ });
10825
+ AttachmentScraperDirective.prototype.scrape = function () {
10826
+ var e_1, _b, e_2, _c, e_3, _d, e_4, _e, e_5, _f;
10827
+ var _this = this;
10828
+ var message = {
10829
+ likes: 0,
10830
+ message: this.text,
10831
+ sentAt: undefined,
10832
+ user: null,
10833
+ attachments: this.attachments
10834
+ };
10835
+ var foundFragments = [];
10836
+ try {
10837
+ for (var _g = __values(this.chatBackend.attachmentScrapers), _h = _g.next(); !_h.done; _h = _g.next()) {
10838
+ var scraper = _h.value;
10839
+ var fragments = scraper.findFragments(message);
10840
+ if (!fragments) {
10841
+ console.error("Attachment fragment scraper " + scraper.constructor.name + " is implemented incorrectly: Returned null instead of array");
10842
+ continue;
10843
+ }
10844
+ try {
10845
+ for (var fragments_1 = (e_2 = void 0, __values(fragments)), fragments_1_1 = fragments_1.next(); !fragments_1_1.done; fragments_1_1 = fragments_1.next()) {
10846
+ var fragment = fragments_1_1.value;
10847
+ foundFragments.push(fragment.text);
10848
+ if (!this.fragments.has(fragment.text)) {
10849
+ console.log("Scraped new fragment:");
10850
+ console.dir(fragment);
10851
+ this.fragments.set(fragment.text, {
10852
+ fragment: fragment,
10853
+ resolution: undefined
10854
+ });
10855
+ }
10856
+ }
10857
+ }
10858
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
10859
+ finally {
10860
+ try {
10861
+ if (fragments_1_1 && !fragments_1_1.done && (_c = fragments_1.return)) _c.call(fragments_1);
10862
+ }
10863
+ finally { if (e_2) throw e_2.error; }
10864
+ }
10865
+ }
10866
+ }
10867
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
10868
+ finally {
10869
+ try {
10870
+ if (_h && !_h.done && (_b = _g.return)) _b.call(_g);
10871
+ }
10872
+ finally { if (e_1) throw e_1.error; }
10873
+ }
10874
+ // Remove fragments that are no longer in the message.
10875
+ var removedFragments = [];
10876
+ try {
10877
+ for (var _j = __values(this.fragments), _k = _j.next(); !_k.done; _k = _j.next()) {
10878
+ var _l = __read(_k.value, 1), key = _l[0];
10879
+ if (!foundFragments.includes(key))
10880
+ removedFragments.push(key);
10881
+ }
10882
+ }
10883
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
10884
+ finally {
10885
+ try {
10886
+ if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
10887
+ }
10888
+ finally { if (e_3) throw e_3.error; }
10889
+ }
10890
+ try {
10891
+ for (var removedFragments_1 = __values(removedFragments), removedFragments_1_1 = removedFragments_1.next(); !removedFragments_1_1.done; removedFragments_1_1 = removedFragments_1.next()) {
10892
+ var removedFragment = removedFragments_1_1.value;
10893
+ console.log("Removed fragment: " + removedFragment);
10894
+ this.fragments.delete(removedFragment);
10895
+ }
10896
+ }
10897
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
10898
+ finally {
10899
+ try {
10900
+ if (removedFragments_1_1 && !removedFragments_1_1.done && (_e = removedFragments_1.return)) _e.call(removedFragments_1);
10901
+ }
10902
+ finally { if (e_4) throw e_4.error; }
10903
+ }
10904
+ var _loop_1 = function (key, state) {
10905
+ if (state.resolution)
10906
+ return "continue";
10907
+ state.resolution = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
10908
+ var _b, _c, resolver, attachment, e_6, e_7_1;
10909
+ var e_7, _d;
10910
+ return __generator(this, function (_e) {
10911
+ switch (_e.label) {
10912
+ case 0:
10913
+ console.log("Resolving fragment " + key);
10914
+ _e.label = 1;
10915
+ case 1:
10916
+ _e.trys.push([1, 8, 9, 10]);
10917
+ _b = __values(this.chatBackend.attachmentResolvers), _c = _b.next();
10918
+ _e.label = 2;
10919
+ case 2:
10920
+ if (!!_c.done) return [3 /*break*/, 7];
10921
+ resolver = _c.value;
10922
+ console.log("- Trying resolver " + resolver.constructor.name + "...");
10923
+ _e.label = 3;
10924
+ case 3:
10925
+ _e.trys.push([3, 5, , 6]);
10926
+ return [4 /*yield*/, resolver.resolveFragment(message, state.fragment)];
10927
+ case 4:
10928
+ attachment = _e.sent();
10929
+ if (attachment) {
10930
+ console.log("Resolved fragment " + key + " into attachment:");
10931
+ console.dir(attachment);
10932
+ this.attachments.push(attachment);
10933
+ this.attachmentsChanged.next(this.attachments.slice());
10934
+ resolve(attachment);
10935
+ return [3 /*break*/, 7];
10936
+ }
10937
+ return [3 /*break*/, 6];
10938
+ case 5:
10939
+ e_6 = _e.sent();
10940
+ console.error("Caught error during attachment resolver " + resolver.constructor.name + ":");
10941
+ console.error(e_6);
10942
+ return [3 /*break*/, 6];
10943
+ case 6:
10944
+ _c = _b.next();
10945
+ return [3 /*break*/, 2];
10946
+ case 7: return [3 /*break*/, 10];
10947
+ case 8:
10948
+ e_7_1 = _e.sent();
10949
+ e_7 = { error: e_7_1 };
10950
+ return [3 /*break*/, 10];
10951
+ case 9:
10952
+ try {
10953
+ if (_c && !_c.done && (_d = _b.return)) _d.call(_b);
10954
+ }
10955
+ finally { if (e_7) throw e_7.error; }
10956
+ return [7 /*endfinally*/];
10957
+ case 10: return [2 /*return*/];
10958
+ }
10959
+ });
10960
+ }); });
10961
+ };
10962
+ try {
10963
+ // Process any fragments that are not yet resolved (or being
10964
+ // resolved)
10965
+ for (var _m = __values(this.fragments), _o = _m.next(); !_o.done; _o = _m.next()) {
10966
+ var _p = __read(_o.value, 2), key = _p[0], state = _p[1];
10967
+ _loop_1(key, state);
10968
+ }
10969
+ }
10970
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
10971
+ finally {
10972
+ try {
10973
+ if (_o && !_o.done && (_f = _m.return)) _f.call(_m);
10974
+ }
10975
+ finally { if (e_5) throw e_5.error; }
10976
+ }
10977
+ };
10978
+ return AttachmentScraperDirective;
10979
+ }());
10980
+ AttachmentScraperDirective.decorators = [
10981
+ { type: core.Directive, args: [{
10982
+ selector: '[attachmentScraper]'
10983
+ },] }
10984
+ ];
10985
+ AttachmentScraperDirective.ctorParameters = function () { return [
10986
+ { type: core.ElementRef },
10987
+ { type: ChatBackendBase }
10988
+ ]; };
10989
+ AttachmentScraperDirective.propDecorators = {
10990
+ attachmentsChanged: [{ type: core.Output }]
10991
+ };
10992
+
10945
10993
  var COMPONENTS$3 = [
10946
10994
  CommentComponent,
10947
10995
  CommentViewComponent,
@@ -10950,7 +10998,8 @@
10950
10998
  CommentFieldComponent,
10951
10999
  CommentSortComponent,
10952
11000
  AttachmentButtonComponent,
10953
- BantaReplySendOptionsDirective
11001
+ BantaReplySendOptionsDirective,
11002
+ AttachmentScraperDirective
10954
11003
  ];
10955
11004
  var CommentsModule = /** @class */ (function () {
10956
11005
  function CommentsModule() {