@scrabble-solver/scrabble-solver 2.8.6 → 2.8.7

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.
Files changed (85) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +9 -9
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_8dgz12 +1 -1
  5. package/.next/cache/next-server.js.nft.json +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/.next/next-server.js.nft.json +1 -1
  11. package/.next/prerender-manifest.json +1 -1
  12. package/.next/routes-manifest.json +1 -1
  13. package/.next/server/chunks/413.js +183 -94
  14. package/.next/server/chunks/{206.js → 429.js} +2 -4137
  15. package/.next/server/chunks/515.js +92 -70
  16. package/.next/server/chunks/{907.js → 911.js} +134 -367
  17. package/.next/server/chunks/939.js +218 -0
  18. package/.next/server/middleware-build-manifest.js +1 -1
  19. package/.next/server/pages/404.html +2 -2
  20. package/.next/server/pages/404.js.nft.json +1 -1
  21. package/.next/server/pages/500.html +2 -2
  22. package/.next/server/pages/_app.js.nft.json +1 -1
  23. package/.next/server/pages/_document.js.nft.json +1 -1
  24. package/.next/server/pages/_error.js.nft.json +1 -1
  25. package/.next/server/pages/api/dictionary/[locale]/[word].js +33 -17
  26. package/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
  27. package/.next/server/pages/api/solve.js +399 -56
  28. package/.next/server/pages/api/solve.js.nft.json +1 -1
  29. package/.next/server/pages/api/visit.js +3 -2
  30. package/.next/server/pages/api/visit.js.nft.json +1 -1
  31. package/.next/server/pages/index.html +3 -7
  32. package/.next/server/pages/index.js +12 -14
  33. package/.next/server/pages/index.js.nft.json +1 -1
  34. package/.next/server/pages/index.json +1 -1
  35. package/.next/static/chunks/56-cf37c430261bbea5.js +1 -0
  36. package/.next/static/chunks/pages/_app-0b12a65bea70a0df.js +1 -0
  37. package/.next/static/chunks/pages/index-fcb69802550afb81.js +1 -0
  38. package/.next/static/css/1f39b55d50f5b30b.css +1 -0
  39. package/.next/static/css/751e8a14776d05d8.css +1 -0
  40. package/.next/static/z_0_lqfmiI_ISokr6NNRq/_buildManifest.js +1 -0
  41. package/.next/static/{VjSpyGDWyVaO0muz54q_j → z_0_lqfmiI_ISokr6NNRq}/_ssgManifest.js +0 -0
  42. package/.next/trace +40 -42
  43. package/package.json +9 -9
  44. package/src/api/index.ts +3 -9
  45. package/src/api/isBoardValid.ts +43 -0
  46. package/src/api/isCellValid.ts +26 -0
  47. package/src/api/isRowValid.ts +19 -0
  48. package/src/components/Dictionary/Dictionary.module.scss +20 -0
  49. package/src/components/Dictionary/Dictionary.tsx +40 -29
  50. package/src/components/Results/Cell.tsx +3 -2
  51. package/src/components/Results/Result.tsx +16 -6
  52. package/src/components/ResultsInput/ResultsInput.tsx +11 -3
  53. package/src/hooks/useIsTablet.ts +2 -2
  54. package/src/lib/getRemainingTiles.ts +1 -1
  55. package/src/lib/index.ts +2 -1
  56. package/src/lib/isRegExp.ts +11 -0
  57. package/src/lib/isStringArray.ts +5 -0
  58. package/src/lib/sortResults.ts +5 -5
  59. package/src/pages/api/dictionary/[locale]/[word].ts +35 -11
  60. package/src/pages/api/solve.ts +39 -19
  61. package/src/pages/api/visit.ts +1 -0
  62. package/src/pages/index.module.scss +5 -11
  63. package/src/pages/index.tsx +5 -5
  64. package/src/sdk/{findWordDefinition.ts → findWordDefinitions.ts} +3 -3
  65. package/src/sdk/index.ts +1 -1
  66. package/src/state/sagas.ts +11 -11
  67. package/src/state/selectors.ts +6 -2
  68. package/src/state/slices/dictionaryInitialState.ts +3 -3
  69. package/src/state/slices/dictionarySlice.ts +4 -10
  70. package/.next/static/VjSpyGDWyVaO0muz54q_j/_buildManifest.js +0 -1
  71. package/.next/static/chunks/56-e2797384ae4b0fc0.js +0 -1
  72. package/.next/static/chunks/pages/_app-5136d33b9b007fd7.js +0 -1
  73. package/.next/static/chunks/pages/index-13ea7770a65c69ee.js +0 -1
  74. package/.next/static/css/3159cfe62ff742a3.css +0 -1
  75. package/.next/static/css/729bb37fe8f9bee6.css +0 -1
  76. package/src/api/validateBoard.ts +0 -45
  77. package/src/api/validateCell.ts +0 -40
  78. package/src/api/validateCharacter.ts +0 -14
  79. package/src/api/validateCharacters.ts +0 -24
  80. package/src/api/validateConfigId.ts +0 -9
  81. package/src/api/validateLocale.ts +0 -15
  82. package/src/api/validateRow.ts +0 -17
  83. package/src/api/validateTile.ts +0 -21
  84. package/src/api/validateWord.ts +0 -11
  85. package/src/lib/isLocale.ts +0 -7
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- exports.id = 907;
3
- exports.ids = [907];
2
+ exports.id = 911;
3
+ exports.ids = [911];
4
4
  exports.modules = {
5
5
 
6
6
  /***/ 64873:
@@ -220,13 +220,13 @@ const tiles_1 = __webpack_require__(48060);
220
220
  const base = {
221
221
  allTilesBonusScore: 50,
222
222
  blankScore: 0,
223
+ blanksCount: 2,
223
224
  boardHeight: 15,
224
225
  boardWidth: 15,
225
226
  bonuses: bonuses_1.default,
226
227
  id: 'literaki',
227
- maximumNumberOfCharacters: 7,
228
+ maximumCharactersCount: 7,
228
229
  name: 'Literaki',
229
- numberOfBlanks: 2,
230
230
  };
231
231
  const literaki = {
232
232
  id: base.id,
@@ -570,13 +570,13 @@ const tiles_1 = __webpack_require__(75797);
570
570
  const base = {
571
571
  allTilesBonusScore: 50,
572
572
  blankScore: 0,
573
+ blanksCount: 2,
573
574
  boardHeight: 15,
574
575
  boardWidth: 15,
575
576
  bonuses: bonuses_1.default,
576
577
  id: 'scrabble',
577
- maximumNumberOfCharacters: 7,
578
+ maximumCharactersCount: 7,
578
579
  name: 'Scrabble',
579
- numberOfBlanks: 2,
580
580
  };
581
581
  const scrabble = {
582
582
  id: base.id,
@@ -815,324 +815,6 @@ const tilesPl = [
815
815
  exports["default"] = tilesPl;
816
816
 
817
817
 
818
- /***/ }),
819
-
820
- /***/ 38436:
821
- /***/ ((__unused_webpack_module, exports) => {
822
-
823
-
824
- Object.defineProperty(exports, "__esModule", ({ value: true }));
825
- exports.VOWELS = exports.CONSONANTS = exports.NO_BONUS = exports.EMPTY_CELL = exports.BONUS_WORD = exports.BONUS_CHARACTER = exports.BLANK = void 0;
826
- exports.BLANK = ' ';
827
- exports.BONUS_CHARACTER = 'BONUS_CHARACTER';
828
- exports.BONUS_WORD = 'BONUS_WORD';
829
- exports.EMPTY_CELL = ' ';
830
- exports.NO_BONUS = { characterMultiplier: 1, wordMultiplier: 1 };
831
- exports.CONSONANTS = [
832
- 'b',
833
- 'c',
834
- 'ć',
835
- 'd',
836
- 'f',
837
- 'g',
838
- 'h',
839
- 'j',
840
- 'k',
841
- 'l',
842
- 'ł',
843
- 'm',
844
- 'n',
845
- 'ń',
846
- 'p',
847
- 'q',
848
- 'r',
849
- 's',
850
- 'ś',
851
- 't',
852
- 'v',
853
- 'w',
854
- 'x',
855
- 'z',
856
- 'ź',
857
- 'ż',
858
- ];
859
- exports.VOWELS = ['a', 'ą', 'ä', 'e', 'ę', 'i', 'o', 'ó', 'ö', 'u', 'ü', 'y'];
860
-
861
-
862
- /***/ }),
863
-
864
- /***/ 98793:
865
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
866
-
867
-
868
- var __importDefault = (this && this.__importDefault) || function (mod) {
869
- return (mod && mod.__esModule) ? mod : { "default": mod };
870
- };
871
- Object.defineProperty(exports, "__esModule", ({ value: true }));
872
- exports.OUTPUT_DIRECTORY = void 0;
873
- const os_1 = __importDefault(__webpack_require__(22037));
874
- const path_1 = __importDefault(__webpack_require__(71017));
875
- exports.OUTPUT_DIRECTORY = path_1.default.resolve(os_1.default.homedir(), '.scrabble-solver', 'logs');
876
-
877
-
878
- /***/ }),
879
-
880
- /***/ 52954:
881
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
882
-
883
-
884
- var __importDefault = (this && this.__importDefault) || function (mod) {
885
- return (mod && mod.__esModule) ? mod : { "default": mod };
886
- };
887
- Object.defineProperty(exports, "__esModule", ({ value: true }));
888
- exports["default"] = void 0;
889
- var logger_1 = __webpack_require__(6730);
890
- Object.defineProperty(exports, "default", ({ enumerable: true, get: function () { return __importDefault(logger_1).default; } }));
891
-
892
-
893
- /***/ }),
894
-
895
- /***/ 6730:
896
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
897
-
898
-
899
- var __importDefault = (this && this.__importDefault) || function (mod) {
900
- return (mod && mod.__esModule) ? mod : { "default": mod };
901
- };
902
- Object.defineProperty(exports, "__esModule", ({ value: true }));
903
- const path_1 = __importDefault(__webpack_require__(71017));
904
- const winston_1 = __webpack_require__(46050);
905
- const constants_1 = __webpack_require__(98793);
906
- const logger = (0, winston_1.createLogger)({
907
- level: 'info',
908
- format: winston_1.format.combine(winston_1.format.timestamp({
909
- format: 'YYYY-MM-DD HH:mm:ss',
910
- }), winston_1.format.errors({ stack: true }), winston_1.format.splat(), winston_1.format.json(), winston_1.format.prettyPrint()),
911
- transports: [
912
- new winston_1.transports.File({
913
- filename: path_1.default.resolve(constants_1.OUTPUT_DIRECTORY, 'error.log'),
914
- level: 'error',
915
- }),
916
- new winston_1.transports.File({
917
- filename: path_1.default.resolve(constants_1.OUTPUT_DIRECTORY, 'all.log'),
918
- }),
919
- new winston_1.transports.Console({
920
- format: winston_1.format.combine(winston_1.format.colorize(), winston_1.format.simple()),
921
- level: 'error',
922
- }),
923
- ],
924
- });
925
- exports["default"] = logger;
926
-
927
-
928
- /***/ }),
929
-
930
- /***/ 53888:
931
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
932
-
933
-
934
- // EXPORTS
935
- __webpack_require__.d(__webpack_exports__, {
936
- "X8": () => (/* reexport */ api_getServerLoggingData),
937
- "U4": () => (/* reexport */ api_validateBoard),
938
- "EN": () => (/* reexport */ api_validateCharacters),
939
- "Qm": () => (/* reexport */ api_validateConfigId),
940
- "Qb": () => (/* reexport */ api_validateLocale),
941
- "yd": () => (/* reexport */ api_validateWord)
942
- });
943
-
944
- // UNUSED EXPORTS: validateCell, validateCharacter, validateRow, validateTile
945
-
946
- ;// CONCATENATED MODULE: ./src/api/getServerLoggingData.ts
947
- const getServerLoggingData = (request)=>({
948
- origin: request.headers.origin,
949
- referer: request.headers.referer,
950
- userAgent: request.headers["user-agent"],
951
- xForwardedFor: request.headers["x-forwarded-for"],
952
- xRealIp: request.headers["x-real-ip"]
953
- });
954
- /* harmony default export */ const api_getServerLoggingData = (getServerLoggingData);
955
-
956
- // EXTERNAL MODULE: ../constants/build/index.js
957
- var build = __webpack_require__(38436);
958
- ;// CONCATENATED MODULE: ./src/api/validateCharacter.ts
959
-
960
- const validateCharacter = (character, config)=>{
961
- if (typeof character !== "string") {
962
- throw new Error("character is not a string");
963
- }
964
- if (!config.hasCharacter(character) && character !== build.BLANK) {
965
- throw new Error("character is not valid");
966
- }
967
- };
968
- /* harmony default export */ const api_validateCharacter = (validateCharacter);
969
-
970
- ;// CONCATENATED MODULE: ./src/api/validateTile.ts
971
-
972
- const validateTile = (tile, config)=>{
973
- if (typeof tile !== "object") {
974
- throw new Error("is not an object");
975
- }
976
- if (tile !== null) {
977
- const { character , isBlank } = tile;
978
- api_validateCharacter(character, config);
979
- if (typeof isBlank !== "boolean") {
980
- throw new Error("isBlank is not a boolean");
981
- }
982
- }
983
- };
984
- /* harmony default export */ const api_validateTile = (validateTile);
985
-
986
- ;// CONCATENATED MODULE: ./src/api/validateCell.ts
987
-
988
- const validateCell = (cell, rowIndex, cellIndex, config)=>{
989
- if (typeof cell !== "object") {
990
- throw new Error(`board[${rowIndex}][${cellIndex}] is not an object`);
991
- }
992
- const { x , y , tile , isEmpty } = cell;
993
- if (typeof x !== "number") {
994
- throw new Error(`board[${rowIndex}][${cellIndex}].x is not a number`);
995
- }
996
- if (x < 0 || x >= config.boardWidth) {
997
- throw new Error(`board[${rowIndex}][${cellIndex}].x is out of bounds`);
998
- }
999
- if (typeof y !== "number") {
1000
- throw new Error(`board[${rowIndex}][${cellIndex}].y is not a number`);
1001
- }
1002
- if (y < 0 || y >= config.boardHeight) {
1003
- throw new Error(`board[${rowIndex}][${cellIndex}].y is out of bounds`);
1004
- }
1005
- if (typeof isEmpty !== "boolean") {
1006
- throw new Error(`board[${rowIndex}][${cellIndex}].isEmpty is not a boolean`);
1007
- }
1008
- try {
1009
- api_validateTile(tile, config);
1010
- } catch (error) {
1011
- const message = error instanceof Error ? error.message : "unknown";
1012
- throw new Error(`board[${rowIndex}][${cellIndex}].tile ${message}`);
1013
- }
1014
- };
1015
- /* harmony default export */ const api_validateCell = (validateCell);
1016
-
1017
- ;// CONCATENATED MODULE: ./src/api/validateRow.ts
1018
-
1019
- const validateRow = (row, rowIndex, config)=>{
1020
- if (!Array.isArray(row)) {
1021
- throw new Error(`board[${rowIndex}] is not an array`);
1022
- }
1023
- if (row.length !== config.boardWidth) {
1024
- throw new Error(`board[${rowIndex}] does not have ${config.boardWidth} cells`);
1025
- }
1026
- row.forEach((cell, cellIndex)=>api_validateCell(cell, rowIndex, cellIndex, config));
1027
- };
1028
- /* harmony default export */ const api_validateRow = (validateRow);
1029
-
1030
- ;// CONCATENATED MODULE: ./src/api/validateBoard.ts
1031
-
1032
- const validateBoard = (board, config)=>{
1033
- if (!Array.isArray(board)) {
1034
- throw new Error('Invalid "board" parameter: not an array');
1035
- }
1036
- if (board.length !== config.boardHeight) {
1037
- throw new Error(`Invalid "board" parameter: does not have ${config.boardHeight} rows`);
1038
- }
1039
- try {
1040
- board.forEach((row, rowIndex)=>api_validateRow(row, rowIndex, config));
1041
- validateTwoCharacterTiles(board, config);
1042
- } catch (error) {
1043
- const message = error instanceof Error ? error.message : "unknown";
1044
- throw new Error(`Invalid "board" parameter: ${message}`);
1045
- }
1046
- };
1047
- const validateTwoCharacterTiles = (board, config)=>{
1048
- const cells = board.flat().filter((cell)=>cell.tile && config.isTwoCharacterTilePrefix(cell.tile.character));
1049
- for (const cell of cells){
1050
- for (const characters of config.twoCharacterTiles){
1051
- const canCheckDown = cell.y + 1 < board.length;
1052
- const canCheckRight = cell.x + 1 < board[0].length;
1053
- const cellDown = board[cell.y + 1][cell.x];
1054
- const cellRight = board[cell.y][cell.x + 1];
1055
- const collidesDown = canCheckDown && cellDown.tile && cellDown.tile.character === characters[1];
1056
- const collidesRight = canCheckRight && cellRight.tile && cellRight.tile.character === characters[1];
1057
- const collides = collidesDown || collidesRight;
1058
- if (cell.tile && characters.startsWith(cell.tile.character) && collides) {
1059
- throw new Error(`${characters} can only be used as a single tile`);
1060
- }
1061
- }
1062
- }
1063
- };
1064
- /* harmony default export */ const api_validateBoard = (validateBoard);
1065
-
1066
- ;// CONCATENATED MODULE: ./src/api/validateCharacters.ts
1067
-
1068
- const validateCharacters = (characters, config)=>{
1069
- if (!Array.isArray(characters)) {
1070
- throw new Error('Invalid "characters" parameter: not an array');
1071
- }
1072
- if (characters.length === 0) {
1073
- throw new Error('Invalid "characters" parameter: empty array');
1074
- }
1075
- characters.forEach((character, characterIndex)=>{
1076
- try {
1077
- api_validateCharacter(character, config);
1078
- } catch (error) {
1079
- const message = error instanceof Error ? error.message : "unknown";
1080
- throw new Error(`Invalid "characters" parameter: characters[${characterIndex}] ${message}`);
1081
- }
1082
- });
1083
- };
1084
- /* harmony default export */ const api_validateCharacters = (validateCharacters);
1085
-
1086
- // EXTERNAL MODULE: ../configs/build/index.js
1087
- var configs_build = __webpack_require__(27911);
1088
- ;// CONCATENATED MODULE: ./src/api/validateConfigId.ts
1089
-
1090
- const validateConfigId = (configId)=>{
1091
- if (!(0,configs_build.isConfigId)(configId)) {
1092
- throw new Error('Invalid "configId" parameter');
1093
- }
1094
- };
1095
- /* harmony default export */ const api_validateConfigId = (validateConfigId);
1096
-
1097
- // EXTERNAL MODULE: ../types/build/index.js
1098
- var types_build = __webpack_require__(46452);
1099
- ;// CONCATENATED MODULE: ./src/api/validateLocale.ts
1100
-
1101
- const locales = Object.values(types_build.Locale);
1102
- const validateLocale = (locale)=>{
1103
- if (typeof locale !== "string") {
1104
- throw new Error('Invalid "locale" parameter: not a string');
1105
- }
1106
- if (!locales.includes(locale)) {
1107
- throw new Error(`Invalid "locale" parameter: must be one of: ${locales.join(", ")}`);
1108
- }
1109
- };
1110
- /* harmony default export */ const api_validateLocale = (validateLocale);
1111
-
1112
- ;// CONCATENATED MODULE: ./src/api/validateWord.ts
1113
- const validateWord = (word)=>{
1114
- if (typeof word !== "string") {
1115
- throw new Error('"word" is not a string');
1116
- }
1117
- if (word.length === 0) {
1118
- throw new Error('"word" is an empty string');
1119
- }
1120
- };
1121
- /* harmony default export */ const api_validateWord = (validateWord);
1122
-
1123
- ;// CONCATENATED MODULE: ./src/api/index.ts
1124
-
1125
-
1126
-
1127
-
1128
-
1129
-
1130
-
1131
-
1132
-
1133
-
1134
-
1135
-
1136
818
  /***/ }),
1137
819
 
1138
820
  /***/ 83017:
@@ -1149,8 +831,8 @@ const Tile_1 = __importDefault(__webpack_require__(580));
1149
831
  class Board {
1150
832
  constructor({ rows }) {
1151
833
  this.rows = rows;
1152
- this.numberOfColumns = rows[0].length;
1153
- this.numberOfRows = rows.length;
834
+ this.columnsCount = rows[0].length;
835
+ this.rowsCount = rows.length;
1154
836
  }
1155
837
  static create(width, height) {
1156
838
  return Board.fromStringArray(Array(height).fill(Array(width).fill(' ').join('')));
@@ -1171,8 +853,8 @@ class Board {
1171
853
  });
1172
854
  }
1173
855
  get center() {
1174
- const x = Math.floor(this.numberOfColumns / 2);
1175
- const y = Math.floor(this.numberOfRows / 2);
856
+ const x = Math.floor(this.columnsCount / 2);
857
+ const y = Math.floor(this.rowsCount / 2);
1176
858
  return this.rows[y][x];
1177
859
  }
1178
860
  clone() {
@@ -1183,20 +865,20 @@ class Board {
1183
865
  return this.collidesUp(cell) || this.collidesDown(cell) || this.collidesLeft(cell) || this.collidesRight(cell);
1184
866
  }
1185
867
  collidesDown({ x, y }) {
1186
- return y < this.numberOfRows - 1 && !this.rows[y + 1][x].isEmpty;
868
+ return y < this.rowsCount - 1 && !this.rows[y + 1][x].isEmpty;
1187
869
  }
1188
870
  collidesLeft({ x, y }) {
1189
871
  return x > 0 && !this.rows[y][x - 1].isEmpty;
1190
872
  }
1191
873
  collidesRight({ x, y }) {
1192
- return x < this.numberOfColumns - 1 && !this.rows[y][x + 1].isEmpty;
874
+ return x < this.columnsCount - 1 && !this.rows[y][x + 1].isEmpty;
1193
875
  }
1194
876
  collidesUp({ x, y }) {
1195
877
  return y > 0 && !this.rows[y - 1][x].isEmpty;
1196
878
  }
1197
879
  equals(other) {
1198
- return (this.numberOfColumns === other.numberOfColumns &&
1199
- this.numberOfRows === other.numberOfRows &&
880
+ return (this.columnsCount === other.columnsCount &&
881
+ this.rowsCount === other.rowsCount &&
1200
882
  this.rows.every((row, rowIndex) => {
1201
883
  return row.every((cell, cellIndex) => {
1202
884
  return cell.equals(other.rows[rowIndex][cellIndex]);
@@ -1238,6 +920,34 @@ class Board {
1238
920
  exports["default"] = Board;
1239
921
 
1240
922
 
923
+ /***/ }),
924
+
925
+ /***/ 28508:
926
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
927
+
928
+
929
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
930
+ exports.isBoardJson = void 0;
931
+ const CellJson_1 = __webpack_require__(56508);
932
+ const isBoardJson = (value) => {
933
+ if (!Array.isArray(value)) {
934
+ return false;
935
+ }
936
+ for (const row of value) {
937
+ if (!Array.isArray(value)) {
938
+ return false;
939
+ }
940
+ for (const cell of row) {
941
+ if (!(0, CellJson_1.isCellJson)(cell)) {
942
+ return false;
943
+ }
944
+ }
945
+ }
946
+ return true;
947
+ };
948
+ exports.isBoardJson = isBoardJson;
949
+
950
+
1241
951
  /***/ }),
1242
952
 
1243
953
  /***/ 80769:
@@ -1297,9 +1007,6 @@ class Cell {
1297
1007
  this.y = y;
1298
1008
  }
1299
1009
  static fromJson(json) {
1300
- if (!json) {
1301
- return Cell.Null;
1302
- }
1303
1010
  return new Cell({
1304
1011
  isEmpty: json.isEmpty,
1305
1012
  tile: Tile_1.default.fromJson(json.tile),
@@ -1336,21 +1043,32 @@ class Cell {
1336
1043
  return this.tile.toString();
1337
1044
  }
1338
1045
  }
1339
- Cell.Null = Object.freeze({
1340
- isEmpty: true,
1341
- tile: Tile_1.default.Null,
1342
- x: 0,
1343
- y: 0,
1344
- clone: () => Cell.Null,
1345
- equals: (other) => other === Cell.Null,
1346
- hasTile: () => false,
1347
- isCandidate: () => false,
1348
- toString: () => '',
1349
- toJson: () => null,
1350
- });
1351
1046
  exports["default"] = Cell;
1352
1047
 
1353
1048
 
1049
+ /***/ }),
1050
+
1051
+ /***/ 56508:
1052
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1053
+
1054
+
1055
+ var __importDefault = (this && this.__importDefault) || function (mod) {
1056
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1057
+ };
1058
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1059
+ exports.isCellJson = void 0;
1060
+ const isObject_1 = __importDefault(__webpack_require__(93518));
1061
+ const TileJson_1 = __webpack_require__(92298);
1062
+ const isCellJson = (value) => {
1063
+ return ((0, isObject_1.default)(value) &&
1064
+ typeof value.isEmpty === 'boolean' &&
1065
+ ((0, TileJson_1.isTileJson)(value.tile) || value.tile === null) &&
1066
+ typeof value.x === 'number' &&
1067
+ typeof value.y === 'number');
1068
+ };
1069
+ exports.isCellJson = isCellJson;
1070
+
1071
+
1354
1072
  /***/ }),
1355
1073
 
1356
1074
  /***/ 95699:
@@ -1418,6 +1136,9 @@ class Config {
1418
1136
  get blankScore() {
1419
1137
  return this.config.blankScore;
1420
1138
  }
1139
+ get blanksCount() {
1140
+ return this.config.blanksCount;
1141
+ }
1421
1142
  get boardHeight() {
1422
1143
  return this.config.boardHeight;
1423
1144
  }
@@ -1460,11 +1181,8 @@ class Config {
1460
1181
  isTwoCharacterTilePrefix(character) {
1461
1182
  return typeof this.getTwoCharacterTileByPrefix(character) !== 'undefined';
1462
1183
  }
1463
- get maximumNumberOfCharacters() {
1464
- return this.config.maximumNumberOfCharacters;
1465
- }
1466
- get numberOfBlanks() {
1467
- return this.config.numberOfBlanks;
1184
+ get maximumCharactersCount() {
1185
+ return this.config.maximumCharactersCount;
1468
1186
  }
1469
1187
  get tiles() {
1470
1188
  return this.config.tiles;
@@ -1545,6 +1263,7 @@ exports["default"] = HorizontalPattern;
1545
1263
 
1546
1264
 
1547
1265
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1266
+ exports.isLocale = void 0;
1548
1267
  // eslint-disable-next-line no-shadow
1549
1268
  var Locale;
1550
1269
  (function (Locale) {
@@ -1555,6 +1274,9 @@ var Locale;
1555
1274
  Locale["PL_PL"] = "pl-PL";
1556
1275
  Locale["DE_DE"] = "de-DE";
1557
1276
  })(Locale || (Locale = {}));
1277
+ const locales = Object.values(Locale);
1278
+ const isLocale = (locale) => locales.includes(locale);
1279
+ exports.isLocale = isLocale;
1558
1280
  exports["default"] = Locale;
1559
1281
 
1560
1282
 
@@ -1571,9 +1293,9 @@ class Pattern {
1571
1293
  this.cells = cells;
1572
1294
  }
1573
1295
  canBePlaced(config) {
1574
- const numberOfEmptyCells = this.getNumberOfEmptyCells();
1575
- const isNumberOfUsedCellsInRange = numberOfEmptyCells >= 1 && numberOfEmptyCells <= config.maximumNumberOfCharacters;
1576
- return (isNumberOfUsedCellsInRange &&
1296
+ const emptyCellsCount = this.getEmptyCellsCount();
1297
+ const isUsedCellsCountInRange = emptyCellsCount >= 1 && emptyCellsCount <= config.maximumCharactersCount;
1298
+ return (isUsedCellsCountInRange &&
1577
1299
  (this.hasAtLeast1NonEmptyCell() || this.collides() || (this.goesThroughBoardCenter() && this.board.isEmpty())));
1578
1300
  }
1579
1301
  clone() {
@@ -1588,7 +1310,7 @@ class Pattern {
1588
1310
  getIndexOfFirstCellWithoutTile() {
1589
1311
  return this.cells.findIndex((cell) => !cell.hasTile());
1590
1312
  }
1591
- getNumberOfEmptyCells() {
1313
+ getEmptyCellsCount() {
1592
1314
  return this.cells.filter((cell) => cell.isEmpty).length;
1593
1315
  }
1594
1316
  goesThroughBoardCenter() {
@@ -1630,28 +1352,29 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
1630
1352
  const constants_1 = __webpack_require__(38436);
1631
1353
  const Cell_1 = __importDefault(__webpack_require__(70902));
1632
1354
  class Result {
1633
- constructor({ cells, id, numberOfCollisions, points, }) {
1355
+ constructor({ cells, id, collisions, points, }) {
1634
1356
  const tiles = getTiles(cells);
1357
+ this.blanksCount = getBlanks(tiles).length;
1635
1358
  this.cells = cells;
1359
+ this.collisions = collisions;
1360
+ this.consonantsCount = getConsonants(tiles).length;
1636
1361
  this.id = id;
1637
1362
  this.length = cells.length;
1638
- this.numberOfCollisions = numberOfCollisions;
1639
- this.numberOfConsonants = getConsonants(tiles).length;
1640
- this.numberOfBlanks = getBlanks(tiles).length;
1641
- this.numberOfTiles = tiles.length;
1642
- this.numberOfVowels = getVowels(tiles).length;
1643
- this.numberOfWords = 1 + this.numberOfCollisions;
1644
1363
  this.points = points;
1645
1364
  this.pointsRatio = getPointsRatio(tiles, points);
1646
1365
  this.tiles = tiles;
1647
1366
  this.tilesCharacters = getTilesCharacters(tiles);
1367
+ this.tilesCount = tiles.length;
1368
+ this.vowelsCount = getVowels(tiles).length;
1648
1369
  this.word = getWord(cells);
1370
+ this.words = getWords(cells, collisions);
1371
+ this.wordsCount = 1 + this.collisions.length;
1649
1372
  }
1650
1373
  static fromJson(json) {
1651
1374
  return new Result({
1652
- cells: json.cells.map(Cell_1.default.fromJson),
1653
1375
  id: json.id,
1654
- numberOfCollisions: json.numberOfCollisions,
1376
+ cells: json.cells.map(Cell_1.default.fromJson),
1377
+ collisions: json.collisions.map((collision) => collision.map(Cell_1.default.fromJson)),
1655
1378
  points: json.points,
1656
1379
  });
1657
1380
  }
@@ -1659,7 +1382,7 @@ class Result {
1659
1382
  return {
1660
1383
  cells: this.cells.map((cell) => cell.toJson()),
1661
1384
  id: this.id,
1662
- numberOfCollisions: this.numberOfCollisions,
1385
+ collisions: this.collisions.map((collision) => collision.map((cell) => cell.toJson())),
1663
1386
  points: this.points,
1664
1387
  };
1665
1388
  }
@@ -1674,6 +1397,10 @@ const getPointsRatio = (tiles, points) => points / tiles.length;
1674
1397
  const getTiles = (cells) => cells.filter(({ isEmpty }) => isEmpty).map(({ tile }) => tile);
1675
1398
  const getTilesCharacters = (tiles) => getNonBlankCharacters(tiles).sort(charactersComparator).join('');
1676
1399
  const getWord = (cells) => cells.map(String).join('');
1400
+ const getWords = (cells, collisions) => [
1401
+ getWord(cells),
1402
+ ...collisions.map((collision) => collision.map(String).join('')),
1403
+ ];
1677
1404
  const isConsonant = ({ character, isBlank }) => constants_1.CONSONANTS.includes(character) && !isBlank;
1678
1405
  const isVowel = ({ character, isBlank }) => constants_1.VOWELS.includes(character) && !isBlank;
1679
1406
  exports["default"] = Result;
@@ -1731,6 +1458,24 @@ Tile.Null = Object.freeze({
1731
1458
  exports["default"] = Tile;
1732
1459
 
1733
1460
 
1461
+ /***/ }),
1462
+
1463
+ /***/ 92298:
1464
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
1465
+
1466
+
1467
+ var __importDefault = (this && this.__importDefault) || function (mod) {
1468
+ return (mod && mod.__esModule) ? mod : { "default": mod };
1469
+ };
1470
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1471
+ exports.isTileJson = void 0;
1472
+ const isObject_1 = __importDefault(__webpack_require__(93518));
1473
+ const isTileJson = (value) => {
1474
+ return (0, isObject_1.default)(value) && typeof value.character === 'string' && typeof value.isBlank === 'boolean';
1475
+ };
1476
+ exports.isTileJson = isTileJson;
1477
+
1478
+
1734
1479
  /***/ }),
1735
1480
 
1736
1481
  /***/ 36161:
@@ -1854,27 +1599,36 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1854
1599
  return (mod && mod.__esModule) ? mod : { "default": mod };
1855
1600
  };
1856
1601
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1857
- exports.WordDefinition = exports.WordBonus = exports.VerticalPattern = exports.Tile = exports.Result = exports.Pattern = exports.Locale = exports.HorizontalPattern = exports.Config = exports.CharacterBonus = exports.Cell = exports.Bonus = exports.Board = void 0;
1602
+ exports.WordDefinition = exports.WordBonus = exports.VerticalPattern = exports.isTileJson = exports.Tile = exports.Result = exports.Pattern = exports.isLocale = exports.Locale = exports.isObject = exports.HorizontalPattern = exports.Config = exports.CharacterBonus = exports.isCellJson = exports.Cell = exports.Bonus = exports.isBoardJson = exports.Board = void 0;
1858
1603
  var Board_1 = __webpack_require__(83017);
1859
1604
  Object.defineProperty(exports, "Board", ({ enumerable: true, get: function () { return __importDefault(Board_1).default; } }));
1605
+ var BoardJson_1 = __webpack_require__(28508);
1606
+ Object.defineProperty(exports, "isBoardJson", ({ enumerable: true, get: function () { return BoardJson_1.isBoardJson; } }));
1860
1607
  var Bonus_1 = __webpack_require__(80769);
1861
1608
  Object.defineProperty(exports, "Bonus", ({ enumerable: true, get: function () { return __importDefault(Bonus_1).default; } }));
1862
1609
  var Cell_1 = __webpack_require__(70902);
1863
1610
  Object.defineProperty(exports, "Cell", ({ enumerable: true, get: function () { return __importDefault(Cell_1).default; } }));
1611
+ var CellJson_1 = __webpack_require__(56508);
1612
+ Object.defineProperty(exports, "isCellJson", ({ enumerable: true, get: function () { return CellJson_1.isCellJson; } }));
1864
1613
  var CharacterBonus_1 = __webpack_require__(95699);
1865
1614
  Object.defineProperty(exports, "CharacterBonus", ({ enumerable: true, get: function () { return __importDefault(CharacterBonus_1).default; } }));
1866
1615
  var Config_1 = __webpack_require__(68725);
1867
1616
  Object.defineProperty(exports, "Config", ({ enumerable: true, get: function () { return __importDefault(Config_1).default; } }));
1868
1617
  var HorizontalPattern_1 = __webpack_require__(44405);
1869
1618
  Object.defineProperty(exports, "HorizontalPattern", ({ enumerable: true, get: function () { return __importDefault(HorizontalPattern_1).default; } }));
1619
+ var isObject_1 = __webpack_require__(93518);
1620
+ Object.defineProperty(exports, "isObject", ({ enumerable: true, get: function () { return __importDefault(isObject_1).default; } }));
1870
1621
  var Locale_1 = __webpack_require__(28044);
1871
1622
  Object.defineProperty(exports, "Locale", ({ enumerable: true, get: function () { return __importDefault(Locale_1).default; } }));
1623
+ Object.defineProperty(exports, "isLocale", ({ enumerable: true, get: function () { return Locale_1.isLocale; } }));
1872
1624
  var Pattern_1 = __webpack_require__(43600);
1873
1625
  Object.defineProperty(exports, "Pattern", ({ enumerable: true, get: function () { return __importDefault(Pattern_1).default; } }));
1874
1626
  var Result_1 = __webpack_require__(28211);
1875
1627
  Object.defineProperty(exports, "Result", ({ enumerable: true, get: function () { return __importDefault(Result_1).default; } }));
1876
1628
  var Tile_1 = __webpack_require__(580);
1877
1629
  Object.defineProperty(exports, "Tile", ({ enumerable: true, get: function () { return __importDefault(Tile_1).default; } }));
1630
+ var TileJson_1 = __webpack_require__(92298);
1631
+ Object.defineProperty(exports, "isTileJson", ({ enumerable: true, get: function () { return TileJson_1.isTileJson; } }));
1878
1632
  var VerticalPattern_1 = __webpack_require__(36161);
1879
1633
  Object.defineProperty(exports, "VerticalPattern", ({ enumerable: true, get: function () { return __importDefault(VerticalPattern_1).default; } }));
1880
1634
  var WordBonus_1 = __webpack_require__(39667);
@@ -1883,6 +1637,19 @@ var WordDefinition_1 = __webpack_require__(43184);
1883
1637
  Object.defineProperty(exports, "WordDefinition", ({ enumerable: true, get: function () { return __importDefault(WordDefinition_1).default; } }));
1884
1638
 
1885
1639
 
1640
+ /***/ }),
1641
+
1642
+ /***/ 93518:
1643
+ /***/ ((__unused_webpack_module, exports) => {
1644
+
1645
+
1646
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
1647
+ const isObject = (value) => {
1648
+ return typeof value === 'object' && value !== null;
1649
+ };
1650
+ exports["default"] = isObject;
1651
+
1652
+
1886
1653
  /***/ })
1887
1654
 
1888
1655
  };