@banta/sdk 4.7.11 → 4.7.12
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.
|
@@ -6,5 +6,6 @@ export * from './trust-resource-url.pipe';
|
|
|
6
6
|
export * from './mention-linker.pipe';
|
|
7
7
|
export * from './attachment/attachment.component';
|
|
8
8
|
export * from './attachments/attachments.component';
|
|
9
|
+
export * from './timer-pool.service';
|
|
9
10
|
export * from './common.module';
|
|
10
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
11
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9zZGsvc3JjL2xpYi9jb21tb24vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxtQkFBbUIsQ0FBQztBQUNsQyxjQUFjLHVCQUF1QixDQUFDO0FBQ3RDLGNBQWMsK0JBQStCLENBQUM7QUFDOUMsY0FBYyx5QkFBeUIsQ0FBQztBQUN4QyxjQUFjLDJCQUEyQixDQUFDO0FBQzFDLGNBQWMsdUJBQXVCLENBQUM7QUFDdEMsY0FBYyxtQ0FBbUMsQ0FBQztBQUNsRCxjQUFjLHFDQUFxQyxDQUFDO0FBQ3BELGNBQWMsc0JBQXNCLENBQUM7QUFFckMsY0FBYyxpQkFBaUIsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vbGF6eS1jb25uZWN0aW9uJztcclxuZXhwb3J0ICogZnJvbSAnLi90aW1lc3RhbXAuY29tcG9uZW50JztcclxuZXhwb3J0ICogZnJvbSAnLi9saWdodGJveC9saWdodGJveC5jb21wb25lbnQnO1xyXG5leHBvcnQgKiBmcm9tICcuL21hcmtkb3duLXRvLWh0bWwucGlwZSc7XHJcbmV4cG9ydCAqIGZyb20gJy4vdHJ1c3QtcmVzb3VyY2UtdXJsLnBpcGUnO1xyXG5leHBvcnQgKiBmcm9tICcuL21lbnRpb24tbGlua2VyLnBpcGUnO1xyXG5leHBvcnQgKiBmcm9tICcuL2F0dGFjaG1lbnQvYXR0YWNobWVudC5jb21wb25lbnQnO1xyXG5leHBvcnQgKiBmcm9tICcuL2F0dGFjaG1lbnRzL2F0dGFjaG1lbnRzLmNvbXBvbmVudCc7XHJcbmV4cG9ydCAqIGZyb20gJy4vdGltZXItcG9vbC5zZXJ2aWNlJztcclxuXHJcbmV4cG9ydCAqIGZyb20gJy4vY29tbW9uLm1vZHVsZSc7Il19
|
package/fesm2015/banta-sdk.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Observable, Subject, BehaviorSubject, Subscription } from 'rxjs';
|
|
2
2
|
import { publish, take } from 'rxjs/operators';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Component, Input, ViewChild, Pipe, Inject, Optional, Output, HostBinding, NgModule, ViewChildren, Directive, TemplateRef, ContentChild, Injectable } from '@angular/core';
|
|
4
|
+
import { Component, Input, ViewChild, Pipe, Inject, Optional, Output, HostBinding, NgModule, ViewChildren, Directive, TemplateRef, ContentChild, Injectable as Injectable$1 } from '@angular/core';
|
|
5
5
|
import * as i1 from 'projects/sdk/src/lib/common/timer-pool.service';
|
|
6
|
-
import { TimerPool } from 'projects/sdk/src/lib/common/timer-pool.service';
|
|
6
|
+
import { TimerPool as TimerPool$1 } from 'projects/sdk/src/lib/common/timer-pool.service';
|
|
7
7
|
import * as i2 from '@angular/common';
|
|
8
8
|
import { CommonModule } from '@angular/common';
|
|
9
9
|
import * as i2$1 from '@angular/material/icon';
|
|
@@ -17,6 +17,9 @@ import * as i4 from '@angular/material/progress-spinner';
|
|
|
17
17
|
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
18
18
|
import * as i6 from '@angular/material/button';
|
|
19
19
|
import { MatButtonModule } from '@angular/material/button';
|
|
20
|
+
import { __decorate, __awaiter } from 'tslib';
|
|
21
|
+
import * as i1$3 from '@banta/common';
|
|
22
|
+
import { Injectable, CommentsOrder, SocketRPC, RpcEvent, DurableSocket } from '@banta/common';
|
|
20
23
|
import * as i4$1 from '@angular/forms';
|
|
21
24
|
import { FormsModule } from '@angular/forms';
|
|
22
25
|
import * as i6$1 from '@angular/material/form-field';
|
|
@@ -27,15 +30,12 @@ import * as i1$2 from '@angular/cdk/overlay';
|
|
|
27
30
|
import { OverlayModule } from '@angular/cdk/overlay';
|
|
28
31
|
import * as i4$2 from '@angular/cdk/portal';
|
|
29
32
|
import { PortalModule } from '@angular/cdk/portal';
|
|
30
|
-
import { __awaiter, __decorate } from 'tslib';
|
|
31
33
|
import * as i2$4 from '@angular/material/dialog';
|
|
32
34
|
import { MatDialogModule } from '@angular/material/dialog';
|
|
33
35
|
import * as i7$1 from '@angular/material/menu';
|
|
34
36
|
import { MatMenuModule } from '@angular/material/menu';
|
|
35
37
|
import * as i11 from '@angular/material/tooltip';
|
|
36
38
|
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
37
|
-
import * as i1$3 from '@banta/common';
|
|
38
|
-
import { CommentsOrder, SocketRPC, RpcEvent, DurableSocket } from '@banta/common';
|
|
39
39
|
import * as i2$3 from '@angular/router';
|
|
40
40
|
import * as i3$3 from '@angular/material/snack-bar';
|
|
41
41
|
import { MatSnackBarModule } from '@angular/material/snack-bar';
|
|
@@ -524,6 +524,89 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
524
524
|
type: Output
|
|
525
525
|
}] } });
|
|
526
526
|
|
|
527
|
+
/**
|
|
528
|
+
* Provides a way to hook in to a shared set of timers, instead of creating a timer per instance.
|
|
529
|
+
* This is very useful for cases where the update is not extremely time-sensitive, but happens at scale.
|
|
530
|
+
* The principal use case is the TimestampComponent. When several hundred (or several thousand) comments are
|
|
531
|
+
* being displayed, we do not want to trigger thousands of independent relative timestamp updates, because over
|
|
532
|
+
* time the updates will saturate the CPU since they don't perfectly align.
|
|
533
|
+
*/
|
|
534
|
+
let TimerPool = class TimerPool {
|
|
535
|
+
constructor() {
|
|
536
|
+
this.subscriptions = new Map();
|
|
537
|
+
this.newSubscriptions = new Map();
|
|
538
|
+
this.removedSubscriptions = new Map();
|
|
539
|
+
}
|
|
540
|
+
addTimer(interval, callback) {
|
|
541
|
+
var _a;
|
|
542
|
+
if (interval <= 0) {
|
|
543
|
+
console.warn(`Refusing to set timer with interval of ${interval}!`);
|
|
544
|
+
return () => { };
|
|
545
|
+
}
|
|
546
|
+
let state;
|
|
547
|
+
let sizeWas = this.subscriptions.size;
|
|
548
|
+
if (!this.subscriptions.has(interval)) {
|
|
549
|
+
state = { subscribers: [] };
|
|
550
|
+
state.handle = setInterval(() => {
|
|
551
|
+
console.debug(`[Banta/TimerPool] Notifying ${state.subscribers.length} subs [${interval}ms]`);
|
|
552
|
+
state.subscribers.forEach(sub => sub());
|
|
553
|
+
}, interval);
|
|
554
|
+
this.subscriptions.set(interval, state);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
state = this.subscriptions.get(interval);
|
|
558
|
+
}
|
|
559
|
+
state.subscribers.push(callback);
|
|
560
|
+
// Debug information //////////////////////////
|
|
561
|
+
//
|
|
562
|
+
if (!this.newSubscriptions.has(interval))
|
|
563
|
+
this.newSubscriptions.set(interval, 0);
|
|
564
|
+
this.newSubscriptions.set(interval, ((_a = this.newSubscriptions.get(interval)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
565
|
+
clearTimeout(this.newSubscriptionsNotice);
|
|
566
|
+
this.newSubscriptionsNotice = setTimeout(() => {
|
|
567
|
+
for (let [interval, count] of this.newSubscriptions) {
|
|
568
|
+
console.debug(`[Banta/TimerPool] ${count} new subscriptions to ${interval}ms [${state.subscribers.length} total]`);
|
|
569
|
+
}
|
|
570
|
+
this.newSubscriptions.clear();
|
|
571
|
+
});
|
|
572
|
+
//
|
|
573
|
+
///////////////////////////////////////////////
|
|
574
|
+
if (sizeWas === 0) {
|
|
575
|
+
console.debug(`[Banta/TimerPool] No longer idle.`);
|
|
576
|
+
}
|
|
577
|
+
// Unsubscribe function
|
|
578
|
+
return () => {
|
|
579
|
+
var _a;
|
|
580
|
+
let state = this.subscriptions.get(interval);
|
|
581
|
+
let index = state.subscribers.indexOf(callback);
|
|
582
|
+
if (index >= 0)
|
|
583
|
+
state.subscribers.splice(index, 1);
|
|
584
|
+
if (state.subscribers.length === 0) {
|
|
585
|
+
clearInterval(state.handle);
|
|
586
|
+
this.subscriptions.delete(interval);
|
|
587
|
+
}
|
|
588
|
+
if (!this.removedSubscriptions.has(interval))
|
|
589
|
+
this.removedSubscriptions.set(interval, 0);
|
|
590
|
+
this.removedSubscriptions.set(interval, ((_a = this.removedSubscriptions.get(interval)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
591
|
+
// Debug information ////////////////////////////////////////////////////////////////////
|
|
592
|
+
clearTimeout(this.removedSubscriptionsNotice);
|
|
593
|
+
this.removedSubscriptionsNotice = setTimeout(() => {
|
|
594
|
+
var _a, _b;
|
|
595
|
+
for (let [interval, count] of this.removedSubscriptions) {
|
|
596
|
+
let state = this.subscriptions.get(interval);
|
|
597
|
+
console.debug(`[Banta/TimerPool] ${count} unsubscribed from ${interval}ms [${(_b = (_a = state === null || state === void 0 ? void 0 : state.subscribers) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0} remain]`);
|
|
598
|
+
}
|
|
599
|
+
if (this.subscriptions.size === 0)
|
|
600
|
+
console.debug(`[Banta/TimerPool] All subscriptions have been removed. Now idle.`);
|
|
601
|
+
this.removedSubscriptions.clear();
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
TimerPool = __decorate([
|
|
607
|
+
Injectable()
|
|
608
|
+
], TimerPool);
|
|
609
|
+
|
|
527
610
|
const COMPONENTS$3 = [
|
|
528
611
|
TimestampComponent,
|
|
529
612
|
LightboxComponent,
|
|
@@ -538,7 +621,7 @@ class BantaCommonModule {
|
|
|
538
621
|
return {
|
|
539
622
|
ngModule: BantaCommonModule,
|
|
540
623
|
providers: [
|
|
541
|
-
TimerPool
|
|
624
|
+
TimerPool$1
|
|
542
625
|
]
|
|
543
626
|
};
|
|
544
627
|
}
|
|
@@ -10506,7 +10589,7 @@ class ChatBackend extends ChatBackendBase {
|
|
|
10506
10589
|
ChatBackend.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ChatBackend, deps: [{ token: BANTA_SDK_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10507
10590
|
ChatBackend.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ChatBackend });
|
|
10508
10591
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: ChatBackend, decorators: [{
|
|
10509
|
-
type: Injectable
|
|
10592
|
+
type: Injectable$1
|
|
10510
10593
|
}], ctorParameters: function () {
|
|
10511
10594
|
return [{ type: undefined, decorators: [{
|
|
10512
10595
|
type: Inject,
|
|
@@ -10553,7 +10636,7 @@ class UrlAttachmentResolver {
|
|
|
10553
10636
|
UrlAttachmentResolver.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UrlAttachmentResolver, deps: [{ token: ChatBackendBase }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10554
10637
|
UrlAttachmentResolver.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UrlAttachmentResolver });
|
|
10555
10638
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: UrlAttachmentResolver, decorators: [{
|
|
10556
|
-
type: Injectable
|
|
10639
|
+
type: Injectable$1
|
|
10557
10640
|
}], ctorParameters: function () { return [{ type: ChatBackendBase }]; } });
|
|
10558
10641
|
|
|
10559
10642
|
class YouTubeAttachmentResolver {
|
|
@@ -10741,5 +10824,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImpo
|
|
|
10741
10824
|
* Generated bundle index. Do not edit.
|
|
10742
10825
|
*/
|
|
10743
10826
|
|
|
10744
|
-
export { AttachmentButtonComponent, AttachmentScraperDirective, BANTA_SDK_OPTIONS, BantaAttachmentComponent, BantaAttachmentsComponent, BantaChatComponent, BantaCommentsComponent, BantaCommonModule, BantaComponent, BantaLogoComponent, BantaMarkdownToHtmlPipe, BantaMentionLinkerPipe, BantaReplySendOptionsDirective, BantaSdkModule, BantaTrustResourceUrlPipe, ChatBackend, ChatBackendBase, ChatMessageComponent, ChatModule, ChatSource, ChatViewComponent, CommentComponent, CommentFieldComponent, CommentSortComponent, CommentViewComponent, CommentsModule, EMOJIS, EmojiModule, EmojiSelectorButtonComponent, EmojiSelectorPanelComponent, GiphyAttachmentResolver, LightboxComponent, LiveChatMessageComponent, LiveCommentComponent, LiveMessageComponent, TimestampComponent, TweetAttachmentResolver, UrlAttachmentResolver, UrlAttachmentScraper, YouTubeAttachmentResolver, lazyConnection };
|
|
10827
|
+
export { AttachmentButtonComponent, AttachmentScraperDirective, BANTA_SDK_OPTIONS, BantaAttachmentComponent, BantaAttachmentsComponent, BantaChatComponent, BantaCommentsComponent, BantaCommonModule, BantaComponent, BantaLogoComponent, BantaMarkdownToHtmlPipe, BantaMentionLinkerPipe, BantaReplySendOptionsDirective, BantaSdkModule, BantaTrustResourceUrlPipe, ChatBackend, ChatBackendBase, ChatMessageComponent, ChatModule, ChatSource, ChatViewComponent, CommentComponent, CommentFieldComponent, CommentSortComponent, CommentViewComponent, CommentsModule, EMOJIS, EmojiModule, EmojiSelectorButtonComponent, EmojiSelectorPanelComponent, GiphyAttachmentResolver, LightboxComponent, LiveChatMessageComponent, LiveCommentComponent, LiveMessageComponent, TimerPool, TimestampComponent, TweetAttachmentResolver, UrlAttachmentResolver, UrlAttachmentScraper, YouTubeAttachmentResolver, lazyConnection };
|
|
10745
10828
|
//# sourceMappingURL=banta-sdk.mjs.map
|