@lichess-org/pgn-viewer 2.5.3 → 2.5.5

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/README.md CHANGED
@@ -112,7 +112,7 @@ If you use [SCSS](https://sass-lang.com/), you can import the styles with:
112
112
  @import '../../node_modules/@lichess-org/pgn-viewer/scss/lichess-pgn-viewer.lib';
113
113
  ```
114
114
 
115
- Customisable SCSS variables are [available](https://github.com/lichess-org/pgn-viewer/blob/master/scss/_lichess-pgn-viewer.lib.scss), see [how lichess configures pgn-viewer with SCSS](https://github.com/lichess-org/lila/blob/master/ui/common/css/component/_lichess-pgn-viewer.scss).
115
+ Customisable CSS variables are [available](https://github.com/lichess-org/pgn-viewer/blob/master/scss/_lichess-pgn-viewer.lib.scss), see [how lichess configures pgn-viewer with CSS](https://github.com/lichess-org/lila/blob/master/ui/lib/css/component/_pgn-viewer.scss).
116
116
 
117
117
  ### CSS
118
118
 
@@ -2669,10 +2669,10 @@ var defaultTranslations = {
2669
2669
  "aria.variation": "Variation",
2670
2670
  "aria.navigationControls": "Game navigation controls",
2671
2671
  "aria.viewProfileOnLichess": "View %s's profile on Lichess",
2672
- "aria.chessGameBetween": "Chess game between %1$s, whites, and %2$s, blacks. %3$s",
2672
+ "aria.chessGameBetween": "Chess game between %1$s as white and %2$s as black. %3$s",
2673
2673
  "aria.gameInProgress": "Game in progress",
2674
- "aria.whitesWin": "Whites win",
2675
- "aria.blacksWin": "Blacks win",
2674
+ "aria.whiteWins": "White wins",
2675
+ "aria.blackWins": "Black wins",
2676
2676
  "aria.draw": "Draw",
2677
2677
  "aria.unknownPlayer": "Unknown player",
2678
2678
  "aria.rated": "rated %s",
@@ -3059,8 +3059,12 @@ var PgnViewer = class {
3059
3059
  turnColor: data.turn
3060
3060
  };
3061
3061
  };
3062
- this.analysisUrl = () => this.game.metadata.isLichess && this.game.metadata.externalLink || `https://lichess.org/analysis/${this.curData().fen.replace(" ", "_")}?color=${this.orientation()}`;
3063
- this.practiceUrl = () => `${this.analysisUrl()}#practice`;
3062
+ this.analysisUrl = (forPractice) => {
3063
+ const mainlinePly = this.plyOnMainline();
3064
+ const onMainline = mainlinePly !== void 0;
3065
+ return this.game.metadata.isLichess && this.game.metadata.externalLink && onMainline && !forPractice ? this.game.metadata.externalLink + `#${mainlinePly}` : `https://lichess.org/analysis/${this.curData().fen.replace(" ", "_")}?color=${this.orientation()}`;
3066
+ };
3067
+ this.practiceUrl = () => `${this.analysisUrl(true)}#practice`;
3064
3068
  this.setGround = (cg) => {
3065
3069
  this.ground = cg;
3066
3070
  this.redrawGround();
@@ -3081,6 +3085,12 @@ var PgnViewer = class {
3081
3085
  this.translate = translate(opts.translate);
3082
3086
  this.path = this.game.pathAtMainlinePly(opts.initialPly);
3083
3087
  }
3088
+ plyOnMainline() {
3089
+ const data = this.curData();
3090
+ const ply = isMoveData(data) ? data.ply : 0;
3091
+ const onMainline = ply === 0 ? this.path.empty() : !!this.game.mainline[ply - 1] && this.game.mainline[ply - 1].path.equals(this.path);
3092
+ return onMainline ? ply : void 0;
3093
+ }
3084
3094
  };
3085
3095
 
3086
3096
  // node_modules/.pnpm/@lichess-org+chessground@9.8.5/node_modules/@lichess-org/chessground/dist/premove.js
@@ -5785,7 +5795,7 @@ var renderMenu = (ctrl) => h(
5785
5795
  {
5786
5796
  attrs: {
5787
5797
  role: "menuitem",
5788
- href: ctrl.analysisUrl(),
5798
+ href: ctrl.analysisUrl(false),
5789
5799
  target: "_blank",
5790
5800
  "aria-label": ctrl.translate("aria.linkOpensInNewTab", ctrl.translate("analysisBoard"))
5791
5801
  }
@@ -5815,7 +5825,7 @@ var renderMenu = (ctrl) => h(
5815
5825
  },
5816
5826
  ctrl.translate("getPgn")
5817
5827
  ) : void 0,
5818
- renderExternalLink(ctrl)
5828
+ !ctrl.game.metadata.isLichess || !ctrl.opts.menu.analysisBoard?.enabled ? renderExternalLink(ctrl) : void 0
5819
5829
  ]
5820
5830
  );
5821
5831
  var renderExternalLink = (ctrl) => {
@@ -5942,8 +5952,8 @@ var renderRootAriaLabel = (ctrl) => {
5942
5952
  };
5943
5953
  const formatResult = (result2) => {
5944
5954
  if (!result2 || result2 === "*") return ctrl.translate("aria.gameInProgress");
5945
- if (result2 === "1-0") return ctrl.translate("aria.whitesWin");
5946
- if (result2 === "0-1") return ctrl.translate("aria.blacksWin");
5955
+ if (result2 === "1-0") return ctrl.translate("aria.whiteWins");
5956
+ if (result2 === "0-1") return ctrl.translate("aria.blackWins");
5947
5957
  if (result2 === "1/2-1/2") return ctrl.translate("aria.draw");
5948
5958
  return result2;
5949
5959
  };