@banta/sdk 4.4.1 → 4.4.2
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/banta-sdk.metadata.json +1 -1
- package/bundles/banta-sdk.umd.js +189 -116
- 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/attachment-scraper.js +2 -87
- package/esm2015/lib/banta-sdk.module.js +23 -1
- package/esm2015/lib/chat-backend-base.js +1 -6
- package/esm2015/lib/common/attachment/attachment.component.js +29 -3
- package/esm2015/lib/giphy-attachments.js +20 -0
- package/esm2015/lib/index.js +6 -1
- package/esm2015/lib/tweet-attachments.js +16 -0
- package/esm2015/lib/url-attachments.js +46 -0
- package/esm2015/lib/youtube-attachments.js +25 -0
- package/fesm2015/banta-sdk.js +149 -92
- package/fesm2015/banta-sdk.js.map +1 -1
- package/lib/attachment-scraper.d.ts +0 -15
- package/lib/banta-sdk.module.d.ts +2 -0
- package/lib/chat-backend-base.d.ts +2 -2
- package/lib/common/attachment/attachment.component.d.ts +4 -0
- package/lib/giphy-attachments.d.ts +5 -0
- package/lib/index.d.ts +5 -0
- package/lib/tweet-attachments.d.ts +5 -0
- package/lib/url-attachments.d.ts +11 -0
- package/lib/youtube-attachments.d.ts +5 -0
- package/package.json +1 -1
package/banta-sdk.metadata.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"__symbolic":"module","version":4,"exports":[{"from":"./common"},{"from":"./emoji"},{"from":"./banta/banta.component"},{"from":"./banta-logo.component"},{"from":"./chat"},{"from":"./live-message.component"},{"from":"./comments"},{"from":"./chat-backend-base"},{"from":"./chat-source-base"},{"from":"./chat-backend"},{"from":"./chat-source"},{"from":"./sdk-options"},{"from":"./banta-sdk.module"}],"metadata":{},"origins":{},"importAs":"@banta/sdk"}
|
|
1
|
+
{"__symbolic":"module","version":4,"exports":[{"from":"./common"},{"from":"./emoji"},{"from":"./banta/banta.component"},{"from":"./banta-logo.component"},{"from":"./chat"},{"from":"./live-message.component"},{"from":"./comments"},{"from":"./chat-backend-base"},{"from":"./chat-source-base"},{"from":"./chat-backend"},{"from":"./chat-source"},{"from":"./sdk-options"},{"from":"./attachment-scraper"},{"from":"./url-attachments"},{"from":"./youtube-attachments"},{"from":"./giphy-attachments"},{"from":"./tweet-attachments"},{"from":"./banta-sdk.module"}],"metadata":{},"origins":{},"importAs":"@banta/sdk"}
|
package/bundles/banta-sdk.umd.js
CHANGED
|
@@ -237,6 +237,15 @@
|
|
|
237
237
|
this.removed = new rxjs.Subject();
|
|
238
238
|
this.activated = new rxjs.Subject();
|
|
239
239
|
}
|
|
240
|
+
BantaAttachmentComponent.prototype.ngOnInit = function () {
|
|
241
|
+
if (typeof window !== 'undefined') {
|
|
242
|
+
setTimeout(function () {
|
|
243
|
+
if (!window['twttr'])
|
|
244
|
+
return;
|
|
245
|
+
window['twttr'].widgets.load();
|
|
246
|
+
}, 100);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
240
249
|
BantaAttachmentComponent.prototype.activate = function () {
|
|
241
250
|
this.activated.next();
|
|
242
251
|
};
|
|
@@ -276,15 +285,40 @@
|
|
|
276
285
|
enumerable: false,
|
|
277
286
|
configurable: true
|
|
278
287
|
});
|
|
288
|
+
Object.defineProperty(BantaAttachmentComponent.prototype, "hasFrame", {
|
|
289
|
+
get: function () {
|
|
290
|
+
if (!this.attachment)
|
|
291
|
+
return false;
|
|
292
|
+
return this.attachment.type === 'iframe' || (this.attachment.type === 'card'
|
|
293
|
+
&& this.attachment.card.player);
|
|
294
|
+
},
|
|
295
|
+
enumerable: false,
|
|
296
|
+
configurable: true
|
|
297
|
+
});
|
|
298
|
+
Object.defineProperty(BantaAttachmentComponent.prototype, "frameUrl", {
|
|
299
|
+
get: function () {
|
|
300
|
+
if (!this.attachment)
|
|
301
|
+
return undefined;
|
|
302
|
+
if (this.attachment.type === 'iframe') {
|
|
303
|
+
return this.attachment.url;
|
|
304
|
+
}
|
|
305
|
+
else if (this.attachment.type === 'card') {
|
|
306
|
+
return this.attachment.card.player;
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
enumerable: false,
|
|
310
|
+
configurable: true
|
|
311
|
+
});
|
|
279
312
|
return BantaAttachmentComponent;
|
|
280
313
|
}());
|
|
281
314
|
BantaAttachmentComponent.decorators = [
|
|
282
315
|
{ type: core.Component, args: [{
|
|
283
316
|
selector: 'banta-attachment',
|
|
284
|
-
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
|
|
285
|
-
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}a.card img{width:
|
|
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>",
|
|
318
|
+
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}"]
|
|
286
319
|
},] }
|
|
287
320
|
];
|
|
321
|
+
BantaAttachmentComponent.ctorParameters = function () { return []; };
|
|
288
322
|
BantaAttachmentComponent.propDecorators = {
|
|
289
323
|
attachment: [{ type: core.Input }],
|
|
290
324
|
loading: [{ type: core.Input }],
|
|
@@ -7425,123 +7459,11 @@
|
|
|
7425
7459
|
},] }
|
|
7426
7460
|
];
|
|
7427
7461
|
|
|
7428
|
-
var URL_REGEX = new RegExp('(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?', 'ig');
|
|
7429
|
-
var UrlAttachmentScraper = /** @class */ (function () {
|
|
7430
|
-
function UrlAttachmentScraper() {
|
|
7431
|
-
}
|
|
7432
|
-
UrlAttachmentScraper.prototype.findFragments = function (message) {
|
|
7433
|
-
var _a;
|
|
7434
|
-
// If a message already has a URL attachment, don't add another one.
|
|
7435
|
-
if (message.attachments && message.attachments.filter(function (x) { return x.type === 'url'; }).length > 0)
|
|
7436
|
-
return null;
|
|
7437
|
-
return (Array.from((_a = message.message.match(URL_REGEX)) !== null && _a !== void 0 ? _a : []))
|
|
7438
|
-
.reduce(function (a, item) { return (a.includes(item) ? undefined : a.push(item), a); }, [])
|
|
7439
|
-
.map(function (url) { return ({
|
|
7440
|
-
text: url,
|
|
7441
|
-
offset: message.message.indexOf(url),
|
|
7442
|
-
type: 'url'
|
|
7443
|
-
}); });
|
|
7444
|
-
};
|
|
7445
|
-
return UrlAttachmentScraper;
|
|
7446
|
-
}());
|
|
7447
|
-
var GiphyAttachmentResolver = /** @class */ (function () {
|
|
7448
|
-
function GiphyAttachmentResolver() {
|
|
7449
|
-
}
|
|
7450
|
-
GiphyAttachmentResolver.prototype.resolveFragment = function (message, fragment) {
|
|
7451
|
-
var _a;
|
|
7452
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
7453
|
-
var gifId;
|
|
7454
|
-
return __generator(this, function (_b) {
|
|
7455
|
-
if (fragment.type === 'url' && fragment.text.startsWith('https://giphy.com/gifs')) {
|
|
7456
|
-
gifId = (_a = /[^-\/]+$/.exec(fragment.text)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
7457
|
-
if (!gifId)
|
|
7458
|
-
return [2 /*return*/, null];
|
|
7459
|
-
return [2 /*return*/, {
|
|
7460
|
-
type: 'iframe',
|
|
7461
|
-
url: "https://giphy.com/embed/" + gifId,
|
|
7462
|
-
style: 'inline'
|
|
7463
|
-
}];
|
|
7464
|
-
}
|
|
7465
|
-
return [2 /*return*/, null];
|
|
7466
|
-
});
|
|
7467
|
-
});
|
|
7468
|
-
};
|
|
7469
|
-
return GiphyAttachmentResolver;
|
|
7470
|
-
}());
|
|
7471
|
-
var YouTubeAttachmentResolver = /** @class */ (function () {
|
|
7472
|
-
function YouTubeAttachmentResolver() {
|
|
7473
|
-
}
|
|
7474
|
-
YouTubeAttachmentResolver.prototype.resolveFragment = function (message, fragment) {
|
|
7475
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
7476
|
-
var videoId, match;
|
|
7477
|
-
return __generator(this, function (_b) {
|
|
7478
|
-
if (fragment.type !== 'url')
|
|
7479
|
-
return [2 /*return*/, null];
|
|
7480
|
-
if (fragment.text.match(/https?:\/\/(www\.)?youtube.com\/watch\?v=/)) {
|
|
7481
|
-
match = /watch\?v=([^&]+)/.exec(fragment.text);
|
|
7482
|
-
if (match) {
|
|
7483
|
-
videoId = match[1];
|
|
7484
|
-
}
|
|
7485
|
-
}
|
|
7486
|
-
if (videoId) {
|
|
7487
|
-
return [2 /*return*/, {
|
|
7488
|
-
type: 'iframe',
|
|
7489
|
-
url: "https://www.youtube.com/embed/" + videoId,
|
|
7490
|
-
style: 'block'
|
|
7491
|
-
}];
|
|
7492
|
-
}
|
|
7493
|
-
return [2 /*return*/, null];
|
|
7494
|
-
});
|
|
7495
|
-
});
|
|
7496
|
-
};
|
|
7497
|
-
return YouTubeAttachmentResolver;
|
|
7498
|
-
}());
|
|
7499
|
-
var UrlAttachmentResolver = /** @class */ (function () {
|
|
7500
|
-
function UrlAttachmentResolver(backend) {
|
|
7501
|
-
this.backend = backend;
|
|
7502
|
-
}
|
|
7503
|
-
UrlAttachmentResolver.prototype.resolveFragment = function (message, fragment) {
|
|
7504
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
7505
|
-
var urlCard;
|
|
7506
|
-
return __generator(this, function (_b) {
|
|
7507
|
-
switch (_b.label) {
|
|
7508
|
-
case 0:
|
|
7509
|
-
if (fragment.type !== 'url')
|
|
7510
|
-
return [2 /*return*/, null];
|
|
7511
|
-
return [4 /*yield*/, this.backend.getCardForUrl(fragment.text)];
|
|
7512
|
-
case 1:
|
|
7513
|
-
urlCard = _b.sent();
|
|
7514
|
-
if (urlCard) {
|
|
7515
|
-
return [2 /*return*/, {
|
|
7516
|
-
type: 'card',
|
|
7517
|
-
url: fragment.text,
|
|
7518
|
-
card: urlCard,
|
|
7519
|
-
style: 'block'
|
|
7520
|
-
}];
|
|
7521
|
-
}
|
|
7522
|
-
return [2 /*return*/];
|
|
7523
|
-
}
|
|
7524
|
-
});
|
|
7525
|
-
});
|
|
7526
|
-
};
|
|
7527
|
-
return UrlAttachmentResolver;
|
|
7528
|
-
}());
|
|
7529
|
-
UrlAttachmentResolver.decorators = [
|
|
7530
|
-
{ type: core.Injectable }
|
|
7531
|
-
];
|
|
7532
|
-
UrlAttachmentResolver.ctorParameters = function () { return [
|
|
7533
|
-
{ type: ChatBackendBase }
|
|
7534
|
-
]; };
|
|
7535
|
-
|
|
7536
7462
|
var ChatBackendBase = /** @class */ (function () {
|
|
7537
7463
|
function ChatBackendBase() {
|
|
7538
7464
|
this._userChanged = new rxjs.BehaviorSubject(null);
|
|
7539
7465
|
this._attachmentScrapers = [];
|
|
7540
7466
|
this._attachmentResolvers = [];
|
|
7541
|
-
this.registerAttachmentScraper(new UrlAttachmentScraper());
|
|
7542
|
-
this.registerAttachmentResolver(new GiphyAttachmentResolver());
|
|
7543
|
-
this.registerAttachmentResolver(new YouTubeAttachmentResolver());
|
|
7544
|
-
this.registerAttachmentResolver(new UrlAttachmentResolver(this));
|
|
7545
7467
|
}
|
|
7546
7468
|
Object.defineProperty(ChatBackendBase.prototype, "userChanged", {
|
|
7547
7469
|
get: function () {
|
|
@@ -10951,8 +10873,151 @@
|
|
|
10951
10873
|
{ type: undefined, decorators: [{ type: core.Inject, args: [BANTA_SDK_OPTIONS,] }] }
|
|
10952
10874
|
]; };
|
|
10953
10875
|
|
|
10876
|
+
var URL_REGEX = new RegExp('(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?', 'ig');
|
|
10877
|
+
var UrlAttachmentScraper = /** @class */ (function () {
|
|
10878
|
+
function UrlAttachmentScraper() {
|
|
10879
|
+
}
|
|
10880
|
+
UrlAttachmentScraper.prototype.findFragments = function (message) {
|
|
10881
|
+
var _a;
|
|
10882
|
+
// If a message already has a URL attachment, don't add another one.
|
|
10883
|
+
if (message.attachments && message.attachments.filter(function (x) { return x.type === 'url'; }).length > 0)
|
|
10884
|
+
return null;
|
|
10885
|
+
return (Array.from((_a = message.message.match(URL_REGEX)) !== null && _a !== void 0 ? _a : []))
|
|
10886
|
+
.reduce(function (a, item) { return (a.includes(item) ? undefined : a.push(item), a); }, [])
|
|
10887
|
+
.map(function (url) { return ({
|
|
10888
|
+
text: url,
|
|
10889
|
+
offset: message.message.indexOf(url),
|
|
10890
|
+
type: 'url'
|
|
10891
|
+
}); });
|
|
10892
|
+
};
|
|
10893
|
+
return UrlAttachmentScraper;
|
|
10894
|
+
}());
|
|
10895
|
+
var UrlAttachmentResolver = /** @class */ (function () {
|
|
10896
|
+
function UrlAttachmentResolver(backend) {
|
|
10897
|
+
this.backend = backend;
|
|
10898
|
+
}
|
|
10899
|
+
UrlAttachmentResolver.prototype.resolveFragment = function (message, fragment) {
|
|
10900
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10901
|
+
var urlCard;
|
|
10902
|
+
return __generator(this, function (_b) {
|
|
10903
|
+
switch (_b.label) {
|
|
10904
|
+
case 0:
|
|
10905
|
+
if (fragment.type !== 'url')
|
|
10906
|
+
return [2 /*return*/, null];
|
|
10907
|
+
return [4 /*yield*/, this.backend.getCardForUrl(fragment.text)];
|
|
10908
|
+
case 1:
|
|
10909
|
+
urlCard = _b.sent();
|
|
10910
|
+
if (urlCard) {
|
|
10911
|
+
return [2 /*return*/, {
|
|
10912
|
+
type: 'card',
|
|
10913
|
+
url: fragment.text,
|
|
10914
|
+
card: urlCard,
|
|
10915
|
+
style: 'block'
|
|
10916
|
+
}];
|
|
10917
|
+
}
|
|
10918
|
+
return [2 /*return*/];
|
|
10919
|
+
}
|
|
10920
|
+
});
|
|
10921
|
+
});
|
|
10922
|
+
};
|
|
10923
|
+
return UrlAttachmentResolver;
|
|
10924
|
+
}());
|
|
10925
|
+
UrlAttachmentResolver.decorators = [
|
|
10926
|
+
{ type: core.Injectable }
|
|
10927
|
+
];
|
|
10928
|
+
UrlAttachmentResolver.ctorParameters = function () { return [
|
|
10929
|
+
{ type: ChatBackendBase }
|
|
10930
|
+
]; };
|
|
10931
|
+
|
|
10932
|
+
var YouTubeAttachmentResolver = /** @class */ (function () {
|
|
10933
|
+
function YouTubeAttachmentResolver() {
|
|
10934
|
+
}
|
|
10935
|
+
YouTubeAttachmentResolver.prototype.resolveFragment = function (message, fragment) {
|
|
10936
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10937
|
+
var videoId, match;
|
|
10938
|
+
return __generator(this, function (_a) {
|
|
10939
|
+
if (fragment.type !== 'url')
|
|
10940
|
+
return [2 /*return*/, null];
|
|
10941
|
+
if (fragment.text.match(/https?:\/\/(www\.)?youtube.com\/watch\?v=/)) {
|
|
10942
|
+
match = /watch\?v=([^&]+)/.exec(fragment.text);
|
|
10943
|
+
if (match) {
|
|
10944
|
+
videoId = match[1];
|
|
10945
|
+
}
|
|
10946
|
+
}
|
|
10947
|
+
if (videoId) {
|
|
10948
|
+
return [2 /*return*/, {
|
|
10949
|
+
type: 'iframe',
|
|
10950
|
+
url: "https://www.youtube.com/embed/" + videoId,
|
|
10951
|
+
style: 'block'
|
|
10952
|
+
}];
|
|
10953
|
+
}
|
|
10954
|
+
return [2 /*return*/, null];
|
|
10955
|
+
});
|
|
10956
|
+
});
|
|
10957
|
+
};
|
|
10958
|
+
return YouTubeAttachmentResolver;
|
|
10959
|
+
}());
|
|
10960
|
+
|
|
10961
|
+
var GiphyAttachmentResolver = /** @class */ (function () {
|
|
10962
|
+
function GiphyAttachmentResolver() {
|
|
10963
|
+
}
|
|
10964
|
+
GiphyAttachmentResolver.prototype.resolveFragment = function (message, fragment) {
|
|
10965
|
+
var _a;
|
|
10966
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10967
|
+
var gifId;
|
|
10968
|
+
return __generator(this, function (_b) {
|
|
10969
|
+
if (fragment.type === 'url' && fragment.text.startsWith('https://giphy.com/gifs')) {
|
|
10970
|
+
gifId = (_a = /[^-\/]+$/.exec(fragment.text)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
10971
|
+
if (!gifId)
|
|
10972
|
+
return [2 /*return*/, null];
|
|
10973
|
+
return [2 /*return*/, {
|
|
10974
|
+
type: 'iframe',
|
|
10975
|
+
url: "https://giphy.com/embed/" + gifId,
|
|
10976
|
+
style: 'inline'
|
|
10977
|
+
}];
|
|
10978
|
+
}
|
|
10979
|
+
return [2 /*return*/, null];
|
|
10980
|
+
});
|
|
10981
|
+
});
|
|
10982
|
+
};
|
|
10983
|
+
return GiphyAttachmentResolver;
|
|
10984
|
+
}());
|
|
10985
|
+
|
|
10986
|
+
var TweetAttachmentResolver = /** @class */ (function () {
|
|
10987
|
+
function TweetAttachmentResolver() {
|
|
10988
|
+
}
|
|
10989
|
+
TweetAttachmentResolver.prototype.resolveFragment = function (message, fragment) {
|
|
10990
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10991
|
+
return __generator(this, function (_a) {
|
|
10992
|
+
if (fragment.type === 'url' && fragment.text.startsWith('https://twitter.com/')) {
|
|
10993
|
+
return [2 /*return*/, {
|
|
10994
|
+
type: 'tweet',
|
|
10995
|
+
url: fragment.text,
|
|
10996
|
+
style: 'block'
|
|
10997
|
+
}];
|
|
10998
|
+
}
|
|
10999
|
+
return [2 /*return*/, null];
|
|
11000
|
+
});
|
|
11001
|
+
});
|
|
11002
|
+
};
|
|
11003
|
+
return TweetAttachmentResolver;
|
|
11004
|
+
}());
|
|
11005
|
+
|
|
10954
11006
|
var BantaSdkModule = /** @class */ (function () {
|
|
10955
|
-
function BantaSdkModule() {
|
|
11007
|
+
function BantaSdkModule(chatBackend) {
|
|
11008
|
+
if (typeof window !== 'undefined') {
|
|
11009
|
+
if (!document.querySelector('script[src="https://platform.twitter.com/widgets.js"]')) {
|
|
11010
|
+
var script = document.createElement('script');
|
|
11011
|
+
script.src = 'https://platform.twitter.com/widgets.js';
|
|
11012
|
+
script.async = true;
|
|
11013
|
+
document.body.appendChild(script);
|
|
11014
|
+
}
|
|
11015
|
+
}
|
|
11016
|
+
chatBackend.registerAttachmentScraper(new UrlAttachmentScraper());
|
|
11017
|
+
chatBackend.registerAttachmentResolver(new GiphyAttachmentResolver());
|
|
11018
|
+
chatBackend.registerAttachmentResolver(new YouTubeAttachmentResolver());
|
|
11019
|
+
chatBackend.registerAttachmentResolver(new TweetAttachmentResolver());
|
|
11020
|
+
chatBackend.registerAttachmentResolver(new UrlAttachmentResolver(chatBackend));
|
|
10956
11021
|
}
|
|
10957
11022
|
BantaSdkModule.configure = function (options) {
|
|
10958
11023
|
return {
|
|
@@ -11002,7 +11067,10 @@
|
|
|
11002
11067
|
CommentsModule
|
|
11003
11068
|
]
|
|
11004
11069
|
},] }
|
|
11005
|
-
];
|
|
11070
|
+
];
|
|
11071
|
+
BantaSdkModule.ctorParameters = function () { return [
|
|
11072
|
+
{ type: ChatBackendBase }
|
|
11073
|
+
]; };
|
|
11006
11074
|
|
|
11007
11075
|
/*
|
|
11008
11076
|
* Public API Surface of sdk
|
|
@@ -11040,11 +11108,16 @@
|
|
|
11040
11108
|
exports.EmojiModule = EmojiModule;
|
|
11041
11109
|
exports.EmojiSelectorButtonComponent = EmojiSelectorButtonComponent;
|
|
11042
11110
|
exports.EmojiSelectorPanelComponent = EmojiSelectorPanelComponent;
|
|
11111
|
+
exports.GiphyAttachmentResolver = GiphyAttachmentResolver;
|
|
11043
11112
|
exports.LightboxComponent = LightboxComponent;
|
|
11044
11113
|
exports.LiveChatMessageComponent = LiveChatMessageComponent;
|
|
11045
11114
|
exports.LiveCommentComponent = LiveCommentComponent;
|
|
11046
11115
|
exports.LiveMessageComponent = LiveMessageComponent;
|
|
11047
11116
|
exports.TimestampComponent = TimestampComponent;
|
|
11117
|
+
exports.TweetAttachmentResolver = TweetAttachmentResolver;
|
|
11118
|
+
exports.UrlAttachmentResolver = UrlAttachmentResolver;
|
|
11119
|
+
exports.UrlAttachmentScraper = UrlAttachmentScraper;
|
|
11120
|
+
exports.YouTubeAttachmentResolver = YouTubeAttachmentResolver;
|
|
11048
11121
|
exports.lazyConnection = lazyConnection;
|
|
11049
11122
|
|
|
11050
11123
|
Object.defineProperty(exports, '__esModule', { value: true });
|