@banta/sdk 4.6.6 → 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.
- package/bundles/banta-sdk.umd.js +216 -166
- package/bundles/banta-sdk.umd.js.map +1 -1
- package/bundles/banta-sdk.umd.min.js +1 -1
- package/bundles/banta-sdk.umd.min.js.map +1 -1
- package/esm2015/lib/banta-sdk.module.js +3 -2
- package/esm2015/lib/comments/attachment-scraper.directive.js +108 -0
- package/esm2015/lib/comments/comment-field/comment-field.component.js +2 -71
- package/esm2015/lib/comments/comments.module.js +4 -2
- package/esm2015/lib/emoji/emoji-selector-button.component.js +9 -5
- package/fesm2015/banta-sdk.js +116 -75
- package/fesm2015/banta-sdk.js.map +1 -1
- package/lib/comments/attachment-scraper.directive.d.ts +18 -0
- package/lib/comments/comment-field/comment-field.component.d.ts +0 -4
- package/lib/emoji/emoji-selector-button.component.d.ts +2 -0
- package/package.json +1 -1
package/fesm2015/banta-sdk.js
CHANGED
|
@@ -7029,6 +7029,8 @@ class EmojiSelectorButtonComponent {
|
|
|
7029
7029
|
this.overlay = overlay;
|
|
7030
7030
|
this._selected = new Subject();
|
|
7031
7031
|
this.showEmojiPanel = false;
|
|
7032
|
+
this.overlayX = 'end';
|
|
7033
|
+
this.overlayY = 'top';
|
|
7032
7034
|
}
|
|
7033
7035
|
get selected() {
|
|
7034
7036
|
return this._selected;
|
|
@@ -7061,8 +7063,8 @@ class EmojiSelectorButtonComponent {
|
|
|
7061
7063
|
{
|
|
7062
7064
|
originX: 'end',
|
|
7063
7065
|
originY: 'bottom',
|
|
7064
|
-
overlayX:
|
|
7065
|
-
overlayY:
|
|
7066
|
+
overlayX: this.overlayX,
|
|
7067
|
+
overlayY: this.overlayY
|
|
7066
7068
|
}
|
|
7067
7069
|
])
|
|
7068
7070
|
.withFlexibleDimensions(true),
|
|
@@ -7115,7 +7117,9 @@ EmojiSelectorButtonComponent.ctorParameters = () => [
|
|
|
7115
7117
|
];
|
|
7116
7118
|
EmojiSelectorButtonComponent.propDecorators = {
|
|
7117
7119
|
selectorPanelTemplate: [{ type: ViewChild, args: ['selectorPanelTemplate',] }],
|
|
7118
|
-
selected: [{ type: Output }]
|
|
7120
|
+
selected: [{ type: Output }],
|
|
7121
|
+
overlayX: [{ type: Input }],
|
|
7122
|
+
overlayY: [{ type: Input }]
|
|
7119
7123
|
};
|
|
7120
7124
|
|
|
7121
7125
|
const COMPONENTS$1 = [
|
|
@@ -9185,8 +9189,6 @@ class CommentFieldComponent {
|
|
|
9185
9189
|
this.sending = false;
|
|
9186
9190
|
this.expandError = false;
|
|
9187
9191
|
this._text = '';
|
|
9188
|
-
this.attachmentScrapeDebounce = 1500;
|
|
9189
|
-
this.attachmentFragments = new Map();
|
|
9190
9192
|
this.sendLabel = 'Send';
|
|
9191
9193
|
this.sendingLabel = 'Sending';
|
|
9192
9194
|
this.label = 'Post a comment';
|
|
@@ -9236,73 +9238,6 @@ class CommentFieldComponent {
|
|
|
9236
9238
|
}
|
|
9237
9239
|
set text(value) {
|
|
9238
9240
|
this._text = value;
|
|
9239
|
-
clearTimeout(this.attachmentScrapeTimeout);
|
|
9240
|
-
this.attachmentScrapeTimeout = setTimeout(() => this.scrapeAttachments(), this.attachmentScrapeDebounce);
|
|
9241
|
-
}
|
|
9242
|
-
scrapeAttachments() {
|
|
9243
|
-
let message = {
|
|
9244
|
-
likes: 0,
|
|
9245
|
-
message: this._text,
|
|
9246
|
-
sentAt: undefined,
|
|
9247
|
-
user: this.user,
|
|
9248
|
-
attachments: this.chatMessageAttachments
|
|
9249
|
-
};
|
|
9250
|
-
let foundFragments = [];
|
|
9251
|
-
for (let scraper of this.chatBackend.attachmentScrapers) {
|
|
9252
|
-
let fragments = scraper.findFragments(message);
|
|
9253
|
-
if (!fragments) {
|
|
9254
|
-
console.error(`Attachment fragment scraper ${scraper.constructor.name} is implemented incorrectly: Returned null instead of array`);
|
|
9255
|
-
continue;
|
|
9256
|
-
}
|
|
9257
|
-
for (let fragment of fragments) {
|
|
9258
|
-
foundFragments.push(fragment.text);
|
|
9259
|
-
if (!this.attachmentFragments.has(fragment.text)) {
|
|
9260
|
-
console.log(`Scraped new fragment:`);
|
|
9261
|
-
console.dir(fragment);
|
|
9262
|
-
this.attachmentFragments.set(fragment.text, {
|
|
9263
|
-
fragment,
|
|
9264
|
-
resolution: undefined
|
|
9265
|
-
});
|
|
9266
|
-
}
|
|
9267
|
-
}
|
|
9268
|
-
}
|
|
9269
|
-
// Remove fragments that are no longer in the message.
|
|
9270
|
-
let removedFragments = [];
|
|
9271
|
-
for (let [key] of this.attachmentFragments) {
|
|
9272
|
-
if (!foundFragments.includes(key))
|
|
9273
|
-
removedFragments.push(key);
|
|
9274
|
-
}
|
|
9275
|
-
for (let removedFragment of removedFragments) {
|
|
9276
|
-
console.log(`Removed fragment: ${removedFragment}`);
|
|
9277
|
-
this.attachmentFragments.delete(removedFragment);
|
|
9278
|
-
}
|
|
9279
|
-
// Process any fragments that are not yet resolved (or being
|
|
9280
|
-
// resolved)
|
|
9281
|
-
for (let [key, state] of this.attachmentFragments) {
|
|
9282
|
-
if (state.resolution)
|
|
9283
|
-
continue;
|
|
9284
|
-
state.resolution = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
9285
|
-
console.log(`Resolving fragment ${key}`);
|
|
9286
|
-
for (let resolver of this.chatBackend.attachmentResolvers) {
|
|
9287
|
-
console.log(`- Trying resolver ${resolver.constructor.name}...`);
|
|
9288
|
-
try {
|
|
9289
|
-
let attachment = yield resolver.resolveFragment(message, state.fragment);
|
|
9290
|
-
if (attachment) {
|
|
9291
|
-
console.log(`Resolved fragment ${key} into attachment:`);
|
|
9292
|
-
console.dir(attachment);
|
|
9293
|
-
this.chatMessageAttachments.push(attachment);
|
|
9294
|
-
resolve(attachment);
|
|
9295
|
-
break;
|
|
9296
|
-
}
|
|
9297
|
-
}
|
|
9298
|
-
catch (e) {
|
|
9299
|
-
console.error(`Caught error during attachment resolver ${resolver.constructor.name}:`);
|
|
9300
|
-
console.error(e);
|
|
9301
|
-
continue;
|
|
9302
|
-
}
|
|
9303
|
-
}
|
|
9304
|
-
}));
|
|
9305
|
-
}
|
|
9306
9241
|
}
|
|
9307
9242
|
get userAvatarUrl() {
|
|
9308
9243
|
var _a;
|
|
@@ -9554,7 +9489,7 @@ class CommentFieldComponent {
|
|
|
9554
9489
|
CommentFieldComponent.decorators = [
|
|
9555
9490
|
{ type: Component, args: [{
|
|
9556
9491
|
selector: 'banta-comment-field',
|
|
9557
|
-
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>",
|
|
9492
|
+
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>",
|
|
9558
9493
|
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}"]
|
|
9559
9494
|
},] }
|
|
9560
9495
|
];
|
|
@@ -9685,6 +9620,110 @@ AttachmentButtonComponent.propDecorators = {
|
|
|
9685
9620
|
attachmentError: [{ type: Output }]
|
|
9686
9621
|
};
|
|
9687
9622
|
|
|
9623
|
+
class AttachmentScraperDirective {
|
|
9624
|
+
constructor(elementRef, chatBackend) {
|
|
9625
|
+
this.elementRef = elementRef;
|
|
9626
|
+
this.chatBackend = chatBackend;
|
|
9627
|
+
this.attachments = [];
|
|
9628
|
+
this.attachmentsChanged = new BehaviorSubject([]);
|
|
9629
|
+
this.scrapeDebounce = 1500;
|
|
9630
|
+
this.fragments = new Map();
|
|
9631
|
+
}
|
|
9632
|
+
ngOnInit() {
|
|
9633
|
+
if (typeof window === 'undefined')
|
|
9634
|
+
return;
|
|
9635
|
+
this.element.addEventListener('keydown', () => {
|
|
9636
|
+
clearTimeout(this.scrapeTimeout);
|
|
9637
|
+
this.scrapeTimeout = setTimeout(() => this.scrape(), this.scrapeDebounce);
|
|
9638
|
+
});
|
|
9639
|
+
}
|
|
9640
|
+
get element() {
|
|
9641
|
+
var _a;
|
|
9642
|
+
return (_a = this.elementRef) === null || _a === void 0 ? void 0 : _a.nativeElement;
|
|
9643
|
+
}
|
|
9644
|
+
get text() {
|
|
9645
|
+
return this.element.value;
|
|
9646
|
+
}
|
|
9647
|
+
scrape() {
|
|
9648
|
+
let message = {
|
|
9649
|
+
likes: 0,
|
|
9650
|
+
message: this.text,
|
|
9651
|
+
sentAt: undefined,
|
|
9652
|
+
user: null,
|
|
9653
|
+
attachments: this.attachments
|
|
9654
|
+
};
|
|
9655
|
+
let foundFragments = [];
|
|
9656
|
+
for (let scraper of this.chatBackend.attachmentScrapers) {
|
|
9657
|
+
let fragments = scraper.findFragments(message);
|
|
9658
|
+
if (!fragments) {
|
|
9659
|
+
console.error(`Attachment fragment scraper ${scraper.constructor.name} is implemented incorrectly: Returned null instead of array`);
|
|
9660
|
+
continue;
|
|
9661
|
+
}
|
|
9662
|
+
for (let fragment of fragments) {
|
|
9663
|
+
foundFragments.push(fragment.text);
|
|
9664
|
+
if (!this.fragments.has(fragment.text)) {
|
|
9665
|
+
console.log(`Scraped new fragment:`);
|
|
9666
|
+
console.dir(fragment);
|
|
9667
|
+
this.fragments.set(fragment.text, {
|
|
9668
|
+
fragment,
|
|
9669
|
+
resolution: undefined
|
|
9670
|
+
});
|
|
9671
|
+
}
|
|
9672
|
+
}
|
|
9673
|
+
}
|
|
9674
|
+
// Remove fragments that are no longer in the message.
|
|
9675
|
+
let removedFragments = [];
|
|
9676
|
+
for (let [key] of this.fragments) {
|
|
9677
|
+
if (!foundFragments.includes(key))
|
|
9678
|
+
removedFragments.push(key);
|
|
9679
|
+
}
|
|
9680
|
+
for (let removedFragment of removedFragments) {
|
|
9681
|
+
console.log(`Removed fragment: ${removedFragment}`);
|
|
9682
|
+
this.fragments.delete(removedFragment);
|
|
9683
|
+
}
|
|
9684
|
+
// Process any fragments that are not yet resolved (or being
|
|
9685
|
+
// resolved)
|
|
9686
|
+
for (let [key, state] of this.fragments) {
|
|
9687
|
+
if (state.resolution)
|
|
9688
|
+
continue;
|
|
9689
|
+
state.resolution = new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
9690
|
+
console.log(`Resolving fragment ${key}`);
|
|
9691
|
+
for (let resolver of this.chatBackend.attachmentResolvers) {
|
|
9692
|
+
console.log(`- Trying resolver ${resolver.constructor.name}...`);
|
|
9693
|
+
try {
|
|
9694
|
+
let attachment = yield resolver.resolveFragment(message, state.fragment);
|
|
9695
|
+
if (attachment) {
|
|
9696
|
+
console.log(`Resolved fragment ${key} into attachment:`);
|
|
9697
|
+
console.dir(attachment);
|
|
9698
|
+
this.attachments.push(attachment);
|
|
9699
|
+
this.attachmentsChanged.next(this.attachments.slice());
|
|
9700
|
+
resolve(attachment);
|
|
9701
|
+
break;
|
|
9702
|
+
}
|
|
9703
|
+
}
|
|
9704
|
+
catch (e) {
|
|
9705
|
+
console.error(`Caught error during attachment resolver ${resolver.constructor.name}:`);
|
|
9706
|
+
console.error(e);
|
|
9707
|
+
continue;
|
|
9708
|
+
}
|
|
9709
|
+
}
|
|
9710
|
+
}));
|
|
9711
|
+
}
|
|
9712
|
+
}
|
|
9713
|
+
}
|
|
9714
|
+
AttachmentScraperDirective.decorators = [
|
|
9715
|
+
{ type: Directive, args: [{
|
|
9716
|
+
selector: '[attachmentScraper]'
|
|
9717
|
+
},] }
|
|
9718
|
+
];
|
|
9719
|
+
AttachmentScraperDirective.ctorParameters = () => [
|
|
9720
|
+
{ type: ElementRef },
|
|
9721
|
+
{ type: ChatBackendBase }
|
|
9722
|
+
];
|
|
9723
|
+
AttachmentScraperDirective.propDecorators = {
|
|
9724
|
+
attachmentsChanged: [{ type: Output }]
|
|
9725
|
+
};
|
|
9726
|
+
|
|
9688
9727
|
const COMPONENTS$3 = [
|
|
9689
9728
|
CommentComponent,
|
|
9690
9729
|
CommentViewComponent,
|
|
@@ -9693,7 +9732,8 @@ const COMPONENTS$3 = [
|
|
|
9693
9732
|
CommentFieldComponent,
|
|
9694
9733
|
CommentSortComponent,
|
|
9695
9734
|
AttachmentButtonComponent,
|
|
9696
|
-
BantaReplySendOptionsDirective
|
|
9735
|
+
BantaReplySendOptionsDirective,
|
|
9736
|
+
AttachmentScraperDirective
|
|
9697
9737
|
];
|
|
9698
9738
|
class CommentsModule {
|
|
9699
9739
|
}
|
|
@@ -10172,7 +10212,8 @@ BantaSdkModule.decorators = [
|
|
|
10172
10212
|
BantaLogoComponent,
|
|
10173
10213
|
LiveMessageComponent,
|
|
10174
10214
|
ChatModule,
|
|
10175
|
-
CommentsModule
|
|
10215
|
+
CommentsModule,
|
|
10216
|
+
EmojiModule
|
|
10176
10217
|
]
|
|
10177
10218
|
},] }
|
|
10178
10219
|
];
|