Compare commits
No commits in common. "eb89ba03db61981b27834d263f6ad164b77173ff" and "7d296e6a3d5e2a49c6a9ea77ae296d91fbb8bdb7" have entirely different histories.
eb89ba03db
...
7d296e6a3d
@ -24,7 +24,6 @@ export interface EventBusContext {
|
|||||||
// port?: string;
|
// port?: string;
|
||||||
|
|
||||||
visitedBusses?: string[];
|
visitedBusses?: string[];
|
||||||
commandId?: string;
|
|
||||||
|
|
||||||
comms?: {
|
comms?: {
|
||||||
forwardTo?: 'all' | 'active' | 'popup' | 'contentScript' | 'all-frames';
|
forwardTo?: 'all' | 'active' | 'popup' | 'contentScript' | 'all-frames';
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import { PlayerDetectionMode } from '@src/common/enums/PlayerDetectionMode.enum'
|
|||||||
import { SiteSupportLevel } from '@src/common/enums/SiteSupportLevel.enum';
|
import { SiteSupportLevel } from '@src/common/enums/SiteSupportLevel.enum';
|
||||||
import StretchType from '@src/common/enums/StretchType.enum';
|
import StretchType from '@src/common/enums/StretchType.enum';
|
||||||
import VideoAlignmentType from '@src/common/enums/VideoAlignmentType.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 SettingsInterface from '@src/common/interfaces/SettingsInterface';
|
||||||
import Debug from '@src/ext/conf/Debug';
|
import Debug from '@src/ext/conf/Debug';
|
||||||
import { AardPollingOptions } from '@src/ext/module/aard/enums/aard-polling-options.enum';
|
import { AardPollingOptions } from '@src/ext/module/aard/enums/aard-polling-options.enum';
|
||||||
@ -267,7 +266,7 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
activation: 'player',
|
activation: 'player',
|
||||||
activationDistance: 100,
|
activationDistance: 100,
|
||||||
activationDistanceUnits: '%',
|
activationDistanceUnits: '%',
|
||||||
activatorAlignment: MenuPosition.Left,
|
activatorAlignment: 'left',
|
||||||
activatorPadding: {x: 16, y: 16},
|
activatorPadding: {x: 16, y: 16},
|
||||||
activatorPaddingUnit: {x: 'px', y: 'px'},
|
activatorPaddingUnit: {x: 'px', y: 'px'},
|
||||||
triggerZoneDimensions: {
|
triggerZoneDimensions: {
|
||||||
|
|||||||
@ -14,8 +14,6 @@ export default class EventBus {
|
|||||||
private comms?: CommsClient | CommsServer;
|
private comms?: CommsClient | CommsServer;
|
||||||
private commsOrigin: CommsOrigin;
|
private commsOrigin: CommsOrigin;
|
||||||
|
|
||||||
private lastExecutedCommandIds: string[] = new Array(32);
|
|
||||||
private lastExecutedCommandIndex: number = 0;
|
|
||||||
|
|
||||||
private disableTunnel: boolean = false;
|
private disableTunnel: boolean = false;
|
||||||
private popupContext: any = {};
|
private popupContext: any = {};
|
||||||
@ -91,32 +89,19 @@ export default class EventBus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send(command: string, commandData: any, context: EventBusContext = {}) {
|
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];
|
context.visitedBusses = [...context.visitedBusses ?? [], this.uuid];
|
||||||
|
|
||||||
// execute commands we have subscriptions for
|
// execute commands we have subscriptions for
|
||||||
|
|
||||||
if (this.commands?.[command]) {
|
if (this.commands?.[command]) {
|
||||||
for (const eventBusCommand of this.commands[command]) {
|
for (const eventBusCommand of this.commands[command]) {
|
||||||
eventBusCommand.function(commandData, context);
|
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
|
// preventing messages from flowing back to their original senders is
|
||||||
// CommsServer's job. EventBus does not have enough data for this decision.
|
// CommsServer's job. EventBus does not have enough data for this decision.
|
||||||
// We do, however, have enough data to prevent backflow of messages that
|
// We do, however, have enough data to prevent backflow of messages that
|
||||||
// crossed CommsServer once already.
|
// crossed CommsServer once already.
|
||||||
if (!context.commandId) {
|
|
||||||
context.commandId = crypto.randomUUID();
|
|
||||||
}
|
|
||||||
if (
|
if (
|
||||||
this.comms
|
this.comms
|
||||||
&& context?.origin !== CommsOrigin.Server
|
&& context?.origin !== CommsOrigin.Server
|
||||||
@ -127,7 +112,7 @@ export default class EventBus {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (command !== 'reload-required') {
|
if (command !== 'reload-required') {
|
||||||
// We shouldn't let reload-required command to trigger new reload-required commands.
|
// 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 command
|
||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
private sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
|
sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
|
||||||
if (!context.visitedBusses) {
|
if (!context.visitedBusses) {
|
||||||
console.error('Visited busses is missing from contextn. This is illegal.');
|
console.error('Visited busses is missing from contextn. This is illegal.');
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user