@onecx/accelerator 7.0.0-rc.11 → 7.0.0-rc.13
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/package.json +2 -2
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/lib/declarations.d.ts +15 -0
- package/src/lib/declarations.js +2 -0
- package/src/lib/declarations.js.map +1 -1
- package/src/lib/topic/mocks/broadcast-channel.mock.d.ts +10 -0
- package/src/lib/topic/mocks/broadcast-channel.mock.js +34 -0
- package/src/lib/topic/mocks/broadcast-channel.mock.js.map +1 -0
- package/src/lib/topic/topic-message.js +4 -0
- package/src/lib/topic/topic-message.js.map +1 -1
- package/src/lib/topic/topic-publisher.d.ts +4 -0
- package/src/lib/topic/topic-publisher.js +28 -2
- package/src/lib/topic/topic-publisher.js.map +1 -1
- package/src/lib/topic/topic.d.ts +32 -3
- package/src/lib/topic/topic.js +146 -37
- package/src/lib/topic/topic.js.map +1 -1
- package/src/lib/utils/logs.utils.d.ts +5 -0
- package/src/lib/utils/logs.utils.js +38 -0
- package/src/lib/utils/logs.utils.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onecx/accelerator",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.13",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"tslib": "^2.6.3",
|
|
11
11
|
"rxjs": "^7.8.1",
|
|
12
12
|
"@nx/devkit": "^20.3.0",
|
|
13
|
-
"@onecx/nx-migration-utils": "^7.0.0-rc.
|
|
13
|
+
"@onecx/nx-migration-utils": "^7.0.0-rc.13"
|
|
14
14
|
},
|
|
15
15
|
"type": "commonjs",
|
|
16
16
|
"main": "./src/index.js",
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './lib/topic/topic';
|
|
2
2
|
export * from './lib/topic/mocks/fake-topic';
|
|
3
|
+
export * from './lib/topic/mocks/broadcast-channel.mock';
|
|
3
4
|
export * from './lib/topic/syncable-topic';
|
|
4
5
|
export * from './lib/topic/topic-publisher';
|
|
5
6
|
export * from './lib/utils/path.utils';
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./lib/topic/topic"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./lib/topic/mocks/fake-topic"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/topic/mocks/broadcast-channel.mock"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./lib/topic/syncable-topic"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./lib/topic/topic-publisher"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./lib/utils/path.utils"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/accelerator/src/index.ts"],"names":[],"mappings":";;;AAAA,4DAAiC;AACjC,uEAA4C;AAC5C,qEAA0C;AAC1C,sEAA2C;AAC3C,iEAAsC;AACtC,iEAAsC;AACtC,oEAAyC;AACzC,8EAAmD;AACnD,2FAAgE;AAChE,+DAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/accelerator/src/index.ts"],"names":[],"mappings":";;;AAAA,4DAAiC;AACjC,uEAA4C;AAC5C,mFAAwD;AACxD,qEAA0C;AAC1C,sEAA2C;AAC3C,iEAAsC;AACtC,iEAAsC;AACtC,oEAAyC;AACzC,8EAAmD;AACnD,2FAAgE;AAChE,+DAAoC"}
|
|
@@ -9,6 +9,21 @@ declare global {
|
|
|
9
9
|
};
|
|
10
10
|
topic?: {
|
|
11
11
|
debug?: string[];
|
|
12
|
+
statsEnabled?: boolean;
|
|
13
|
+
stats?: {
|
|
14
|
+
messagesPublished?: {
|
|
15
|
+
[topicName: string]: {
|
|
16
|
+
TopicNext: number;
|
|
17
|
+
TopicGet: number;
|
|
18
|
+
TopicResolve: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
instancesCreated?: {
|
|
22
|
+
[topicName: string]: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
useBroadcastChannel?: boolean;
|
|
26
|
+
initDate?: number;
|
|
12
27
|
};
|
|
13
28
|
};
|
|
14
29
|
}
|
package/src/lib/declarations.js
CHANGED
|
@@ -5,5 +5,7 @@ window['@onecx/accelerator'].gatherer ??= {};
|
|
|
5
5
|
window['@onecx/accelerator'].gatherer.promises ??= {};
|
|
6
6
|
window['@onecx/accelerator'].gatherer.debug ??= [];
|
|
7
7
|
window['@onecx/accelerator'].topic ??= {};
|
|
8
|
+
window['@onecx/accelerator'].topic.useBroadcastChannel ??= true;
|
|
9
|
+
window['@onecx/accelerator'].topic.initDate ??= Date.now();
|
|
8
10
|
exports.default = globalThis;
|
|
9
11
|
//# sourceMappingURL=declarations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../../../../libs/accelerator/src/lib/declarations.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"declarations.js","sourceRoot":"","sources":["../../../../../libs/accelerator/src/lib/declarations.ts"],"names":[],"mappings":";;AA2BA,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAA;AACnC,MAAM,CAAC,oBAAoB,CAAC,CAAC,QAAQ,KAAK,EAAE,CAAA;AAC5C,MAAM,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,QAAQ,KAAK,EAAE,CAAA;AACrD,MAAM,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAA;AAClD,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,KAAK,EAAE,CAAA;AACzC,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,mBAAmB,KAAK,IAAI,CAAA;AAC/D,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC,GAAG,EAAE,CAAA;AAE1D,kBAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class BroadcastChannelMock {
|
|
2
|
+
name: string;
|
|
3
|
+
static listeners: Record<string, ((m: any) => any)[]>;
|
|
4
|
+
static asyncCalls: boolean;
|
|
5
|
+
listener: ((m: any) => any) | undefined;
|
|
6
|
+
constructor(name: string);
|
|
7
|
+
postMessage(m: any): void;
|
|
8
|
+
addEventListener(event: string, listener: (m: any) => any): void;
|
|
9
|
+
close(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BroadcastChannelMock = void 0;
|
|
4
|
+
class BroadcastChannelMock {
|
|
5
|
+
name;
|
|
6
|
+
static listeners = {}; // NOSONAR
|
|
7
|
+
static asyncCalls = false; // NOSONAR
|
|
8
|
+
listener;
|
|
9
|
+
constructor(name) {
|
|
10
|
+
this.name = name;
|
|
11
|
+
}
|
|
12
|
+
postMessage(m) {
|
|
13
|
+
if (BroadcastChannelMock.asyncCalls) {
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
16
|
+
BroadcastChannelMock.listeners[this.name]?.forEach((l) => l({ data: m, stopImmediatePropagation: () => { }, stopPropagation: () => { } }));
|
|
17
|
+
}, 0);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
21
|
+
BroadcastChannelMock.listeners[this.name]?.forEach((l) => l({ data: m, stopImmediatePropagation: () => { }, stopPropagation: () => { } }));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
addEventListener(event, listener) {
|
|
25
|
+
this.listener = listener;
|
|
26
|
+
BroadcastChannelMock.listeners[this.name] ??= [];
|
|
27
|
+
BroadcastChannelMock.listeners[this.name].push(listener);
|
|
28
|
+
}
|
|
29
|
+
close() {
|
|
30
|
+
BroadcastChannelMock.listeners[this.name] = BroadcastChannelMock.listeners[this.name].filter((l) => l !== this.listener);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.BroadcastChannelMock = BroadcastChannelMock;
|
|
34
|
+
//# sourceMappingURL=broadcast-channel.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast-channel.mock.js","sourceRoot":"","sources":["../../../../../../../libs/accelerator/src/lib/topic/mocks/broadcast-channel.mock.ts"],"names":[],"mappings":";;;AAAA,MAAa,oBAAoB;IAKV;IAJZ,MAAM,CAAC,SAAS,GAAwC,EAAE,CAAA,CAAC,UAAU;IACrE,MAAM,CAAC,UAAU,GAAG,KAAK,CAAA,CAAC,UAAU;IAC3C,QAAQ,CAA+B;IAEvC,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAI,CAAC;IAEpC,WAAW,CAAC,CAAM;QACd,IAAI,oBAAoB,CAAC,UAAU,EAAE,CAAC;YAClC,UAAU,CAAC,GAAG,EAAE;gBACZ,gEAAgE;gBAChE,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,wBAAwB,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;YAC9I,CAAC,EAAE,CAAC,CAAC,CAAA;QACT,CAAC;aAAM,CAAC;YACJ,gEAAgE;YAChE,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,wBAAwB,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;QAC9I,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,KAAa,EAAE,QAAyB;QACrD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACjD,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC5D,CAAC;IAED,KAAK;QACD,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC5H,CAAC;;AA3BL,oDA4BC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TopicMessage = void 0;
|
|
4
|
+
const logs_utils_1 = require("../utils/logs.utils");
|
|
4
5
|
const message_1 = require("./message");
|
|
5
6
|
class TopicMessage extends message_1.Message {
|
|
6
7
|
name;
|
|
@@ -9,6 +10,9 @@ class TopicMessage extends message_1.Message {
|
|
|
9
10
|
super(type);
|
|
10
11
|
this.name = name;
|
|
11
12
|
this.version = version;
|
|
13
|
+
if ((0, logs_utils_1.isStatsEnabled)()) {
|
|
14
|
+
(0, logs_utils_1.increaseMessageCount)(this.name, type);
|
|
15
|
+
}
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
exports.TopicMessage = TopicMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic-message.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/topic/topic-message.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;
|
|
1
|
+
{"version":3,"file":"topic-message.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/topic/topic-message.ts"],"names":[],"mappings":";;;AAAA,oDAA0E;AAC1E,uCAAmC;AAGnC,MAAa,YAAa,SAAQ,iBAAO;IAG9B;IACA;IAHT,YACE,IAAsB,EACf,IAAY,EACZ,OAAe;QAEtB,KAAK,CAAC,IAAI,CAAC,CAAA;QAHJ,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;QAGtB,IAAI,IAAA,2BAAc,GAAE,EAAE,CAAC;YACrB,IAAA,iCAAoB,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;CACF;AAXD,oCAWC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { TopicMessage } from './topic-message';
|
|
1
2
|
export declare class TopicPublisher<T> {
|
|
2
3
|
name: string;
|
|
3
4
|
version: number;
|
|
4
5
|
protected publishPromiseResolver: Record<number, () => void>;
|
|
6
|
+
protected publishBroadcastChannel: BroadcastChannel | undefined;
|
|
5
7
|
constructor(name: string, version: number);
|
|
6
8
|
publish(value: T): Promise<void>;
|
|
9
|
+
protected createBroadcastChannel(): void;
|
|
10
|
+
protected sendMessage(message: TopicMessage): void;
|
|
7
11
|
}
|
|
@@ -7,20 +7,46 @@ class TopicPublisher {
|
|
|
7
7
|
name;
|
|
8
8
|
version;
|
|
9
9
|
publishPromiseResolver = {};
|
|
10
|
+
publishBroadcastChannel;
|
|
10
11
|
constructor(name, version) {
|
|
11
12
|
this.name = name;
|
|
12
13
|
this.version = version;
|
|
13
14
|
}
|
|
14
15
|
publish(value) {
|
|
15
16
|
const message = new topic_data_message_1.TopicDataMessage("TopicNext" /* TopicMessageType.TopicNext */, this.name, this.version, value);
|
|
16
|
-
|
|
17
|
+
this.sendMessage(message);
|
|
17
18
|
const resolveMessage = new topic_resolve_message_1.TopicResolveMessage("TopicResolve" /* TopicMessageType.TopicResolve */, this.name, this.version, message.id);
|
|
18
19
|
const promise = new Promise((resolve) => {
|
|
19
20
|
this.publishPromiseResolver[message.id] = resolve;
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
this.sendMessage(resolveMessage);
|
|
22
23
|
return promise;
|
|
23
24
|
}
|
|
25
|
+
createBroadcastChannel() {
|
|
26
|
+
if (this.publishBroadcastChannel) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (window['@onecx/accelerator']?.topic?.useBroadcastChannel) {
|
|
30
|
+
if (typeof BroadcastChannel === 'undefined') {
|
|
31
|
+
console.log('BroadcastChannel not supported. Disabling BroadcastChannel for topic publisher');
|
|
32
|
+
window['@onecx/accelerator'] ??= {};
|
|
33
|
+
window['@onecx/accelerator'].topic ??= {};
|
|
34
|
+
window['@onecx/accelerator'].topic.useBroadcastChannel = false;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.publishBroadcastChannel = new BroadcastChannel(`Topic-${this.name}|${this.version}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
sendMessage(message) {
|
|
42
|
+
this.createBroadcastChannel();
|
|
43
|
+
if (window['@onecx/accelerator']?.topic?.useBroadcastChannel) {
|
|
44
|
+
this.publishBroadcastChannel?.postMessage(message);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
window.postMessage(message, '*');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
24
50
|
}
|
|
25
51
|
exports.TopicPublisher = TopicPublisher;
|
|
26
52
|
//# sourceMappingURL=topic-publisher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic-publisher.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/topic/topic-publisher.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;
|
|
1
|
+
{"version":3,"file":"topic-publisher.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/topic/topic-publisher.ts"],"names":[],"mappings":";;;AAAA,6DAAuD;AAGvD,mEAA6D;AAE7D,MAAa,cAAc;IAKhB;IACA;IALC,sBAAsB,GAA+B,EAAE,CAAA;IACvD,uBAAuB,CAA8B;IAE/D,YACS,IAAY,EACZ,OAAe;QADf,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAQ;IACrB,CAAC;IAEG,OAAO,CAAC,KAAQ;QACrB,MAAM,OAAO,GAAG,IAAI,qCAAgB,+CAAgC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACnG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QACzB,MAAM,cAAc,GAAG,IAAI,2CAAmB,qDAAgC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;QAClH,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAC5C,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAA;QACnD,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAA;QAChC,OAAO,OAAO,CAAA;IAChB,CAAC;IAES,sBAAsB;QAC9B,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YACjC,OAAM;QACR,CAAC;QAED,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;YAC7D,IAAI,OAAO,gBAAgB,KAAK,WAAW,EAAE,CAAC;gBAC5C,OAAO,CAAC,GAAG,CAAC,gFAAgF,CAAC,CAAA;gBAC7F,MAAM,CAAC,oBAAoB,CAAC,KAAK,EAAE,CAAA;gBACnC,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,KAAK,EAAE,CAAA;gBACzC,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAA;YAChE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,uBAAuB,GAAG,IAAI,gBAAgB,CAAC,SAAS,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;YAC3F,CAAC;QACH,CAAC;IACH,CAAC;IAES,WAAW,CAAC,OAAqB;QACzC,IAAI,CAAC,sBAAsB,EAAE,CAAA;QAC7B,IAAI,MAAM,CAAC,oBAAoB,CAAC,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC;YAC7D,IAAI,CAAC,uBAAuB,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;QACpD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QAClC,CAAC;IACH,CAAC;CACF;AA7CD,wCA6CC"}
|
package/src/lib/topic/topic.d.ts
CHANGED
|
@@ -7,11 +7,14 @@ export declare class Topic<T> extends TopicPublisher<T> implements Subscribable<
|
|
|
7
7
|
protected data: BehaviorSubject<TopicDataMessage<T> | undefined>;
|
|
8
8
|
protected isInit: boolean;
|
|
9
9
|
private resolveInitPromise;
|
|
10
|
-
private
|
|
10
|
+
private readonly windowEventListener;
|
|
11
|
+
protected readonly readBroadcastChannel: BroadcastChannel | undefined;
|
|
11
12
|
constructor(name: string, version: number, sendGetMessage?: boolean);
|
|
12
13
|
get isInitialized(): Promise<void>;
|
|
13
14
|
asObservable(): Observable<T>;
|
|
14
|
-
subscribe(observerOrNext?: Partial<Observer<T>> | ((value: T) => void)
|
|
15
|
+
subscribe(observerOrNext?: Partial<Observer<T>> | ((value: T) => void)): Subscription;
|
|
16
|
+
/** @deprecated is deprecated in rxjs. This is only here to be compatible with the interface. */
|
|
17
|
+
subscribe(next?: ((value: T) => void) | null, error?: ((error: any) => void) | null, complete?: (() => void) | null): Subscription;
|
|
15
18
|
pipe(): Observable<T>;
|
|
16
19
|
pipe<A>(op1: UnaryFunction<Observable<T>, A>): A;
|
|
17
20
|
pipe<A, B>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>): B;
|
|
@@ -24,6 +27,32 @@ export declare class Topic<T> extends TopicPublisher<T> implements Subscribable<
|
|
|
24
27
|
pipe<A, B, C, D, E, F, G, H, I>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>): I;
|
|
25
28
|
pipe<A, B, C, D, E, F, G, H, I>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>, ...operations: OperatorFunction<any, any>[]): Observable<unknown>;
|
|
26
29
|
pipe<A, B, C, D, E, F, G, H, I>(op1: UnaryFunction<Observable<T>, A>, op2: UnaryFunction<A, B>, op3: UnaryFunction<B, C>, op4: UnaryFunction<C, D>, op5: UnaryFunction<D, E>, op6: UnaryFunction<E, F>, op7: UnaryFunction<F, G>, op8: UnaryFunction<G, H>, op9: UnaryFunction<H, I>, ...operations: UnaryFunction<any, any>[]): unknown;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated source is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
32
|
+
*/
|
|
33
|
+
get source(): Observable<any> | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* @deprecated operator is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
36
|
+
*/
|
|
37
|
+
get operator(): import("rxjs").Operator<any, T> | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* @deprecated lift is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
40
|
+
*/
|
|
41
|
+
lift<R>(operator: OperatorFunction<T, R>): Observable<R>;
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated foreach is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
44
|
+
*/
|
|
45
|
+
forEach(next: (value: T) => void, thisArg?: any): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated toPromise is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
48
|
+
*/
|
|
49
|
+
toPromise(): Promise<T | undefined>;
|
|
27
50
|
destroy(): void;
|
|
28
|
-
private
|
|
51
|
+
private onWindowMessage;
|
|
52
|
+
private onBroadcastChannelMessage;
|
|
53
|
+
private disableBroadcastChannel;
|
|
54
|
+
private isLogEnabled;
|
|
55
|
+
private handleTopicResolveMessage;
|
|
56
|
+
private handleTopicGetMessage;
|
|
57
|
+
private handleTopicNextMessage;
|
|
29
58
|
}
|
package/src/lib/topic/topic.js
CHANGED
|
@@ -6,21 +6,53 @@ const rxjs_1 = require("rxjs");
|
|
|
6
6
|
const topic_message_1 = require("./topic-message");
|
|
7
7
|
const topic_publisher_1 = require("./topic-publisher");
|
|
8
8
|
require("../declarations");
|
|
9
|
+
const logs_utils_1 = require("../utils/logs.utils");
|
|
9
10
|
class Topic extends topic_publisher_1.TopicPublisher {
|
|
10
11
|
isInitializedPromise;
|
|
11
12
|
data = new rxjs_1.BehaviorSubject(undefined);
|
|
12
13
|
isInit = false;
|
|
13
14
|
resolveInitPromise;
|
|
14
|
-
|
|
15
|
+
windowEventListener = (m) => this.onWindowMessage(m);
|
|
16
|
+
readBroadcastChannel;
|
|
15
17
|
constructor(name, version, sendGetMessage = true) {
|
|
16
18
|
super(name, version);
|
|
19
|
+
window['@onecx/accelerator'] ??= {};
|
|
20
|
+
window['@onecx/accelerator'].topic ??= {};
|
|
21
|
+
window['@onecx/accelerator'].topic.initDate ??= Date.now();
|
|
22
|
+
if (window['@onecx/accelerator']?.topic?.useBroadcastChannel) {
|
|
23
|
+
if (typeof BroadcastChannel === 'undefined') {
|
|
24
|
+
console.log('BroadcastChannel not supported. Disabling BroadcastChannel for topic');
|
|
25
|
+
window['@onecx/accelerator'] ??= {};
|
|
26
|
+
window['@onecx/accelerator'].topic ??= {};
|
|
27
|
+
window['@onecx/accelerator'].topic.useBroadcastChannel = false;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.readBroadcastChannel = new BroadcastChannel(`Topic-${this.name}|${this.version}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if ((0, logs_utils_1.isStatsEnabled)()) {
|
|
34
|
+
(0, logs_utils_1.increaseInstanceCount)(this.name);
|
|
35
|
+
}
|
|
17
36
|
this.isInitializedPromise = new Promise((resolve) => {
|
|
18
37
|
this.resolveInitPromise = resolve;
|
|
19
38
|
});
|
|
20
|
-
window.addEventListener('message', this.
|
|
39
|
+
window.addEventListener('message', this.windowEventListener);
|
|
40
|
+
this.readBroadcastChannel?.addEventListener('message', (m) => this.onBroadcastChannelMessage(m));
|
|
21
41
|
if (sendGetMessage) {
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
if (window['@onecx/accelerator'].topic.initDate &&
|
|
43
|
+
Date.now() - window['@onecx/accelerator'].topic.initDate < 2000) {
|
|
44
|
+
// Delay the get message a bit to give other topics time to initialize
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
if (!this.isInit) {
|
|
47
|
+
const message = new topic_message_1.TopicMessage("TopicGet" /* TopicMessageType.TopicGet */, this.name, this.version);
|
|
48
|
+
this.sendMessage(message);
|
|
49
|
+
}
|
|
50
|
+
}, 100);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const message = new topic_message_1.TopicMessage("TopicGet" /* TopicMessageType.TopicGet */, this.name, this.version);
|
|
54
|
+
this.sendMessage(message);
|
|
55
|
+
}
|
|
24
56
|
}
|
|
25
57
|
}
|
|
26
58
|
get isInitialized() {
|
|
@@ -35,56 +67,133 @@ class Topic extends topic_publisher_1.TopicPublisher {
|
|
|
35
67
|
pipe(...operations) {
|
|
36
68
|
return this.asObservable().pipe(...operations);
|
|
37
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated source is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
72
|
+
*/
|
|
73
|
+
get source() {
|
|
74
|
+
return this.asObservable().source;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated operator is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
78
|
+
*/
|
|
79
|
+
get operator() {
|
|
80
|
+
return this.asObservable().operator;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated lift is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
84
|
+
*/
|
|
85
|
+
lift(operator) {
|
|
86
|
+
return this.asObservable().lift(operator);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated foreach is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
90
|
+
*/
|
|
91
|
+
forEach(next, thisArg) {
|
|
92
|
+
return this.asObservable().forEach(next, thisArg);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated toPromise is deprecated in rxjs. This is only here to be compatible with the interface.
|
|
96
|
+
*/
|
|
97
|
+
toPromise() {
|
|
98
|
+
return this.asObservable().toPromise();
|
|
99
|
+
}
|
|
38
100
|
destroy() {
|
|
39
|
-
window.removeEventListener('message', this.
|
|
101
|
+
window.removeEventListener('message', this.windowEventListener, true);
|
|
102
|
+
this.readBroadcastChannel?.close();
|
|
103
|
+
this.publishBroadcastChannel?.close();
|
|
40
104
|
}
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
m.data?.version === this.version) {
|
|
45
|
-
console.log('Topic', this.name, ':', this.version, 'received message', m.data);
|
|
105
|
+
onWindowMessage(m) {
|
|
106
|
+
if (this.isLogEnabled() && m.data?.name === this.name && m.data?.version === this.version) {
|
|
107
|
+
console.log('Topic', this.name, ':', this.version, 'received message via window', m.data);
|
|
46
108
|
}
|
|
47
109
|
switch (m.data.type) {
|
|
48
110
|
case "TopicNext" /* TopicMessageType.TopicNext */: {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (!this.data.value ||
|
|
53
|
-
(this.isInit &&
|
|
54
|
-
m.data.id !== undefined &&
|
|
55
|
-
this.data.value.id !== undefined &&
|
|
56
|
-
m.data.id > this.data.value.id) ||
|
|
57
|
-
(this.isInit && m.data.timestamp > this.data.value.timestamp)) {
|
|
58
|
-
this.isInit = true;
|
|
59
|
-
this.data.next(m.data);
|
|
60
|
-
this.resolveInitPromise();
|
|
61
|
-
}
|
|
62
|
-
else if (this.data.value &&
|
|
63
|
-
this.isInit &&
|
|
64
|
-
m.data.timestamp === this.data.value.timestamp &&
|
|
65
|
-
((m.data.id && !this.data.value.id) || (!m.data.id && this.data.value.id))) {
|
|
66
|
-
console.warn('Message was dropped because of equal timestamps, because there was an old style message in the system. Please upgrade all libraries to the latest version.');
|
|
111
|
+
this.disableBroadcastChannel();
|
|
112
|
+
if (m.data.name === this.name && m.data.version === this.version) {
|
|
113
|
+
this.handleTopicNextMessage(m);
|
|
67
114
|
}
|
|
68
115
|
break;
|
|
69
116
|
}
|
|
70
117
|
case "TopicGet" /* TopicMessageType.TopicGet */: {
|
|
118
|
+
this.disableBroadcastChannel();
|
|
71
119
|
if (m.data.name === this.name && m.data.version === this.version && this.isInit && this.data.value) {
|
|
72
|
-
|
|
73
|
-
m.stopImmediatePropagation();
|
|
74
|
-
m.stopPropagation();
|
|
120
|
+
this.handleTopicGetMessage(m);
|
|
75
121
|
}
|
|
76
122
|
break;
|
|
77
123
|
}
|
|
78
124
|
case "TopicResolve" /* TopicMessageType.TopicResolve */: {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
125
|
+
this.disableBroadcastChannel();
|
|
126
|
+
this.handleTopicResolveMessage(m);
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
onBroadcastChannelMessage(m) {
|
|
132
|
+
if (this.isLogEnabled()) {
|
|
133
|
+
console.log('Topic', this.name, ':', this.version, 'received message', m.data);
|
|
134
|
+
}
|
|
135
|
+
switch (m.data.type) {
|
|
136
|
+
case "TopicNext" /* TopicMessageType.TopicNext */: {
|
|
137
|
+
this.handleTopicNextMessage(m);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "TopicGet" /* TopicMessageType.TopicGet */: {
|
|
141
|
+
if (this.isInit && this.data.value) {
|
|
142
|
+
this.handleTopicGetMessage(m);
|
|
85
143
|
}
|
|
86
144
|
break;
|
|
87
145
|
}
|
|
146
|
+
case "TopicResolve" /* TopicMessageType.TopicResolve */: {
|
|
147
|
+
this.handleTopicResolveMessage(m);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
disableBroadcastChannel() {
|
|
153
|
+
window['@onecx/accelerator'] ??= {};
|
|
154
|
+
window['@onecx/accelerator'].topic ??= {};
|
|
155
|
+
if (window['@onecx/accelerator'].topic.useBroadcastChannel === true) {
|
|
156
|
+
console.log('Disabling BroadcastChannel for topic');
|
|
157
|
+
}
|
|
158
|
+
window['@onecx/accelerator'].topic.useBroadcastChannel = false;
|
|
159
|
+
}
|
|
160
|
+
isLogEnabled() {
|
|
161
|
+
return window['@onecx/accelerator']?.topic?.debug?.includes(this.name);
|
|
162
|
+
}
|
|
163
|
+
handleTopicResolveMessage(m) {
|
|
164
|
+
const publishPromiseResolver = this.publishPromiseResolver[m.data.resolveId];
|
|
165
|
+
if (publishPromiseResolver) {
|
|
166
|
+
try {
|
|
167
|
+
publishPromiseResolver();
|
|
168
|
+
m.stopImmediatePropagation();
|
|
169
|
+
m.stopPropagation();
|
|
170
|
+
delete this.publishPromiseResolver[m.data.resolveId];
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error('Error handling TopicResolveMessage:', error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
handleTopicGetMessage(m) {
|
|
178
|
+
if (this.data.value) {
|
|
179
|
+
this.sendMessage(this.data.value);
|
|
180
|
+
m.stopImmediatePropagation();
|
|
181
|
+
m.stopPropagation();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
handleTopicNextMessage(m) {
|
|
185
|
+
if (!this.data.value ||
|
|
186
|
+
(this.isInit && m.data.id !== undefined && this.data.value.id !== undefined && m.data.id > this.data.value.id) ||
|
|
187
|
+
(this.isInit && m.data.timestamp > this.data.value.timestamp)) {
|
|
188
|
+
this.isInit = true;
|
|
189
|
+
this.data.next(m.data);
|
|
190
|
+
this.resolveInitPromise();
|
|
191
|
+
}
|
|
192
|
+
else if (this.data.value &&
|
|
193
|
+
this.isInit &&
|
|
194
|
+
m.data.timestamp === this.data.value.timestamp &&
|
|
195
|
+
((m.data.id && !this.data.value.id) || (!m.data.id && this.data.value.id))) {
|
|
196
|
+
console.warn('Message was dropped because of equal timestamps, because there was an old style message in the system. Please upgrade all libraries to the latest version.');
|
|
88
197
|
}
|
|
89
198
|
}
|
|
90
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topic.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/topic/topic.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAC5C,+BAQa;AAEb,mDAA8C;AAE9C,uDAAkD;AAElD,2BAAwB;
|
|
1
|
+
{"version":3,"file":"topic.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/topic/topic.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AAC5C,+BAQa;AAEb,mDAA8C;AA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IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;YAClB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAsB,CAAC,CAAC,IAAI,CAAC,CAAA;YAC3C,IAAI,CAAC,kBAAkB,EAAE,CAAA;QAC3B,CAAC;aAAM,IACL,IAAI,CAAC,IAAI,CAAC,KAAK;YACf,IAAI,CAAC,MAAM;YACX,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS;YAC9C,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,EAC1E,CAAC;YACD,OAAO,CAAC,IAAI,CACV,4JAA4J,CAC7J,CAAA;QACH,CAAC;IACH,CAAC;CACF;AAtTD,sBAsTC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import '../declarations';
|
|
2
|
+
import { TopicMessageType } from '../topic/topic-message-type';
|
|
3
|
+
export declare function isStatsEnabled(): boolean;
|
|
4
|
+
export declare function increaseMessageCount(topicName: string, messageType: TopicMessageType): void;
|
|
5
|
+
export declare function increaseInstanceCount(topicName: string): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStatsEnabled = isStatsEnabled;
|
|
4
|
+
exports.increaseMessageCount = increaseMessageCount;
|
|
5
|
+
exports.increaseInstanceCount = increaseInstanceCount;
|
|
6
|
+
require("../declarations");
|
|
7
|
+
function isStatsEnabled() {
|
|
8
|
+
return window['@onecx/accelerator']?.topic?.statsEnabled === true;
|
|
9
|
+
}
|
|
10
|
+
function increaseMessageCount(topicName, messageType) {
|
|
11
|
+
window['@onecx/accelerator'].topic ??= {};
|
|
12
|
+
window['@onecx/accelerator'].topic.stats ??= {};
|
|
13
|
+
window['@onecx/accelerator'].topic.stats.messagesPublished ??= {};
|
|
14
|
+
if (isStatsEnabled()) {
|
|
15
|
+
const messageStats = window['@onecx/accelerator'].topic.stats.messagesPublished;
|
|
16
|
+
if (!messageStats[topicName]) {
|
|
17
|
+
messageStats[topicName] = {
|
|
18
|
+
TopicNext: 0,
|
|
19
|
+
TopicGet: 0,
|
|
20
|
+
TopicResolve: 0,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
messageStats[topicName][messageType]++;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function increaseInstanceCount(topicName) {
|
|
27
|
+
window['@onecx/accelerator'].topic ??= {};
|
|
28
|
+
window['@onecx/accelerator'].topic.stats ??= {};
|
|
29
|
+
window['@onecx/accelerator'].topic.stats.instancesCreated ??= {};
|
|
30
|
+
if (isStatsEnabled()) {
|
|
31
|
+
const instanceStats = window['@onecx/accelerator'].topic.stats.instancesCreated;
|
|
32
|
+
if (!instanceStats[topicName]) {
|
|
33
|
+
instanceStats[topicName] = 0;
|
|
34
|
+
}
|
|
35
|
+
instanceStats[topicName]++;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=logs.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.utils.js","sourceRoot":"","sources":["../../../../../../libs/accelerator/src/lib/utils/logs.utils.ts"],"names":[],"mappings":";;AAGA,wCAEC;AAED,oDAeC;AAED,sDAWC;AAnCD,2BAAwB;AAGxB,SAAgB,cAAc;IAC5B,OAAO,MAAM,CAAC,oBAAoB,CAAC,EAAE,KAAK,EAAE,YAAY,KAAK,IAAI,CAAA;AACnE,CAAC;AAED,SAAgB,oBAAoB,CAAC,SAAiB,EAAE,WAA6B;IACnF,MAAM,CAAC,oBAAoB,CAAC,CAAC,KAAK,KAAK,EAAE,CAAA;IACzC,MAAM,CAAC,oBA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