Compare commits

..

No commits in common. "eb89ba03db61981b27834d263f6ad164b77173ff" and "7d296e6a3d5e2a49c6a9ea77ae296d91fbb8bdb7" have entirely different histories.

3 changed files with 4 additions and 21 deletions

View File

@ -24,7 +24,6 @@ export interface EventBusContext {
// port?: string;
visitedBusses?: string[];
commandId?: string;
comms?: {
forwardTo?: 'all' | 'active' | 'popup' | 'contentScript' | 'all-frames';

View File

@ -7,7 +7,6 @@ import { PlayerDetectionMode } from '@src/common/enums/PlayerDetectionMode.enum'
import { SiteSupportLevel } from '@src/common/enums/SiteSupportLevel.enum';
import StretchType from '@src/common/enums/StretchType.enum';
import VideoAlignmentType from '@src/common/enums/VideoAlignmentType.enum';
import { MenuPosition } from '@src/common/interfaces/ClientUiMenu.interface';
import SettingsInterface from '@src/common/interfaces/SettingsInterface';
import Debug from '@src/ext/conf/Debug';
import { AardPollingOptions } from '@src/ext/module/aard/enums/aard-polling-options.enum';
@ -267,7 +266,7 @@ const ExtensionConf: SettingsInterface = {
activation: 'player',
activationDistance: 100,
activationDistanceUnits: '%',
activatorAlignment: MenuPosition.Left,
activatorAlignment: 'left',
activatorPadding: {x: 16, y: 16},
activatorPaddingUnit: {x: 'px', y: 'px'},
triggerZoneDimensions: {

View File

@ -14,8 +14,6 @@ export default class EventBus {
private comms?: CommsClient | CommsServer;
private commsOrigin: CommsOrigin;
private lastExecutedCommandIds: string[] = new Array(32);
private lastExecutedCommandIndex: number = 0;
private disableTunnel: boolean = false;
private popupContext: any = {};
@ -91,32 +89,19 @@ export default class EventBus {
}
send(command: string, commandData: any, context: EventBusContext = {}) {
if (context.visitedBusses?.includes(this.uuid)) {
return;
}
if (context.commandId && this.lastExecutedCommandIds.includes(context.commandId)) {
return;
}
context.visitedBusses = [...context.visitedBusses ?? [], this.uuid];
// execute commands we have subscriptions for
if (this.commands?.[command]) {
for (const eventBusCommand of this.commands[command]) {
eventBusCommand.function(commandData, context);
}
}
if (context.commandId) {
const i = this.lastExecutedCommandIndex++ % this.lastExecutedCommandIds.length;
this.lastExecutedCommandIds[i] = context.commandId;
}
// preventing messages from flowing back to their original senders is
// CommsServer's job. EventBus does not have enough data for this decision.
// We do, however, have enough data to prevent backflow of messages that
// crossed CommsServer once already.
if (!context.commandId) {
context.commandId = crypto.randomUUID();
}
if (
this.comms
&& context?.origin !== CommsOrigin.Server
@ -127,7 +112,7 @@ export default class EventBus {
} catch (e) {
if (command !== 'reload-required') {
// We shouldn't let reload-required command to trigger new reload-required commands.
this.send('reload-required', {});
this.send('reload-required', {}, {visitedBusses: [this.uuid]});
}
}
};
@ -159,7 +144,7 @@ export default class EventBus {
* @param command
* @param config
*/
private sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
if (!context.visitedBusses) {
console.error('Visited busses is missing from contextn. This is illegal.');
return;