Skip to content

Commit

Permalink
remove site.pubsub
Browse files Browse the repository at this point in the history
It's an internal implementation detail and shouldn't be exposed.
It can be (and has been) used for cheating.
  • Loading branch information
ornicar committed Oct 30, 2024
1 parent 1bb7aa5 commit b648f57
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/round/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
3 changes: 2 additions & 1 deletion ui/round/types/ab.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 0 additions & 2 deletions ui/site/src/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit b648f57

@Siderite
Copy link

@Siderite Siderite commented on b648f57 Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, also for LiChess Tools, which is now unusable. There was even a comment about it:

(site as any).pubsub = pubsub; // do not declare in index.d.ts. some extensions need this here

@ornicar
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's discuss it in discord if you're available

Please sign in to comment.