From b648f57faa19e40ef8b74732078d18088c78b80f Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Wed, 30 Oct 2024 11:56:42 +0100 Subject: [PATCH] remove site.pubsub It's an internal implementation detail and shouldn't be exposed. It can be (and has been) used for cheating. --- ui/round/src/ctrl.ts | 2 +- ui/round/types/ab.d.ts | 3 ++- ui/site/src/site.ts | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/round/src/ctrl.ts b/ui/round/src/ctrl.ts index 61fe1c8d41c81..c5c581790f035 100644 --- a/ui/round/src/ctrl.ts +++ b/ui/round/src/ctrl.ts @@ -160,7 +160,7 @@ export default class RoundController implements MoveRootCtrl { }; private onUserMove = (orig: cg.Key, dest: cg.Key, meta: cg.MoveMetadata) => { - if (!this.keyboardMove?.usedSan) ab.move(this, meta); + if (!this.keyboardMove?.usedSan) ab.move(this, meta, pubsub.emit); if (!this.startPromotion(orig, dest, meta)) this.sendMove(orig, dest, undefined, meta); }; diff --git a/ui/round/types/ab.d.ts b/ui/round/types/ab.d.ts index 80a725ade8e7c..e5b7cbb3e36c8 100644 --- a/ui/round/types/ab.d.ts +++ b/ui/round/types/ab.d.ts @@ -1,5 +1,6 @@ declare module 'ab' { import { MoveMetadata } from 'chessground/types'; + import { Pubsub } from 'common/pubsub'; function init(round: unknown): void; - function move(round: unknown, meta: MoveMetadata): void; + function move(round: unknown, meta: MoveMetadata, emit: Pubsub['emit']): void; } diff --git a/ui/site/src/site.ts b/ui/site/src/site.ts index 79dac80afa1b8..93614a56a7274 100644 --- a/ui/site/src/site.ts +++ b/ui/site/src/site.ts @@ -7,10 +7,8 @@ import { unload, redirect, reload } from './reload'; import announce from './announce'; import { displayLocale } from 'common/i18n'; import sound from './sound'; -import { pubsub } from 'common/pubsub'; const site = window.site; -(site as any).pubsub = pubsub; // do not declare in index.d.ts. some extensions need this here // site.load is initialized in layout.scala embedded script tags // site.manifest is fetched // site.info, site.debug are populated by ui/build