next-chessground 0.11.0 → 0.11.4

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/dist/index.es.js CHANGED
@@ -6371,19 +6371,20 @@ const cgProps = props => {
6371
6371
  if (cgProps.orientation === 'b') {
6372
6372
  cgProps.orientation = 'black';
6373
6373
  }
6374
- }
6375
-
6376
- if (props.drawable === false) {
6377
- cgProps.drawable = {
6378
- enabled: false
6379
- };
6380
6374
  } // pass props directly to Chessground
6381
6375
 
6382
6376
 
6383
- const passProps = ['shapes', 'onSelect'];
6377
+ const passProps = ['shapes', 'onSelect', 'drawable'];
6384
6378
 
6385
6379
  for (const prop of passProps) {
6386
6380
  cgProps[prop] = props[prop];
6381
+ } // helper that disables Chessground drawable option
6382
+
6383
+
6384
+ if (props.drawable === false) {
6385
+ cgProps.drawable = {
6386
+ enabled: false
6387
+ };
6387
6388
  }
6388
6389
 
6389
6390
  return cgProps;
@@ -6899,6 +6900,7 @@ class Stockfish {
6899
6900
  }
6900
6901
 
6901
6902
  this.skillLevel = 20;
6903
+ this.maxDepth = 40;
6902
6904
  this.resolveTimeout = null;
6903
6905
  this.isAnalyzing = false;
6904
6906
  this.fen = constants.initialFen;
@@ -7024,6 +7026,13 @@ class Stockfish {
7024
7026
  });
7025
7027
  }
7026
7028
 
7029
+ async new_position(fen) {
7030
+ await this.stop();
7031
+ await this.is_ready();
7032
+ this.set_position(fen);
7033
+ this.go_infinite();
7034
+ }
7035
+
7027
7036
  set_multipv(numPv) {
7028
7037
  window.chessEngineWorker.postMessage('setoption name MultiPV value ' + numPv);
7029
7038
  }
@@ -7080,6 +7089,23 @@ class Stockfish {
7080
7089
  });
7081
7090
  }
7082
7091
 
7092
+ go_infinite(callback) {
7093
+ window.chessEngineWorker.postMessage('go infinite');
7094
+ this.isAnalyzing = true;
7095
+
7096
+ window.chessEngineWorker.onmessage = message => {
7097
+ if (this.isInfoMessage(message) && typeof callback === 'function') {
7098
+ const msgData = this.parseData(message.data);
7099
+
7100
+ if (msgData.depth > this.maxDepth) {
7101
+ this.stop();
7102
+ }
7103
+
7104
+ callback(msgData);
7105
+ }
7106
+ };
7107
+ }
7108
+
7083
7109
  stop() {
7084
7110
  return new Promise(resolve => {
7085
7111
  if (!this.isAnalyzing) {
package/dist/index.js CHANGED
@@ -6380,19 +6380,20 @@ const cgProps = props => {
6380
6380
  if (cgProps.orientation === 'b') {
6381
6381
  cgProps.orientation = 'black';
6382
6382
  }
6383
- }
6384
-
6385
- if (props.drawable === false) {
6386
- cgProps.drawable = {
6387
- enabled: false
6388
- };
6389
6383
  } // pass props directly to Chessground
6390
6384
 
6391
6385
 
6392
- const passProps = ['shapes', 'onSelect'];
6386
+ const passProps = ['shapes', 'onSelect', 'drawable'];
6393
6387
 
6394
6388
  for (const prop of passProps) {
6395
6389
  cgProps[prop] = props[prop];
6390
+ } // helper that disables Chessground drawable option
6391
+
6392
+
6393
+ if (props.drawable === false) {
6394
+ cgProps.drawable = {
6395
+ enabled: false
6396
+ };
6396
6397
  }
6397
6398
 
6398
6399
  return cgProps;
@@ -6908,6 +6909,7 @@ class Stockfish {
6908
6909
  }
6909
6910
 
6910
6911
  this.skillLevel = 20;
6912
+ this.maxDepth = 40;
6911
6913
  this.resolveTimeout = null;
6912
6914
  this.isAnalyzing = false;
6913
6915
  this.fen = constants.initialFen;
@@ -7033,6 +7035,13 @@ class Stockfish {
7033
7035
  });
7034
7036
  }
7035
7037
 
7038
+ async new_position(fen) {
7039
+ await this.stop();
7040
+ await this.is_ready();
7041
+ this.set_position(fen);
7042
+ this.go_infinite();
7043
+ }
7044
+
7036
7045
  set_multipv(numPv) {
7037
7046
  window.chessEngineWorker.postMessage('setoption name MultiPV value ' + numPv);
7038
7047
  }
@@ -7089,6 +7098,23 @@ class Stockfish {
7089
7098
  });
7090
7099
  }
7091
7100
 
7101
+ go_infinite(callback) {
7102
+ window.chessEngineWorker.postMessage('go infinite');
7103
+ this.isAnalyzing = true;
7104
+
7105
+ window.chessEngineWorker.onmessage = message => {
7106
+ if (this.isInfoMessage(message) && typeof callback === 'function') {
7107
+ const msgData = this.parseData(message.data);
7108
+
7109
+ if (msgData.depth > this.maxDepth) {
7110
+ this.stop();
7111
+ }
7112
+
7113
+ callback(msgData);
7114
+ }
7115
+ };
7116
+ }
7117
+
7092
7118
  stop() {
7093
7119
  return new Promise(resolve => {
7094
7120
  if (!this.isAnalyzing) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-chessground",
3
- "version": "0.11.0",
3
+ "version": "0.11.4",
4
4
  "description": "React and Next wrapper for Chessground with chessboard and pieces out of the box",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",