scrabble-solver 2.8.1 → 2.8.3

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 (184) hide show
  1. package/.eslintrc.js +1 -1
  2. package/lerna.json +1 -1
  3. package/package.json +1 -1
  4. package/packages/configs/build/getConfig.js +6 -12
  5. package/packages/configs/build/getLocaleConfig.js +2 -2
  6. package/packages/configs/build/isConfigId.js +5 -8
  7. package/packages/configs/build/literaki/bonuses.js +2 -2
  8. package/packages/configs/build/literaki/literaki.js +14 -27
  9. package/packages/configs/build/literaki/tiles/tilesDe.js +1 -1
  10. package/packages/configs/build/literaki/tiles/tilesEn.js +1 -1
  11. package/packages/configs/build/literaki/tiles/tilesEs.js +1 -1
  12. package/packages/configs/build/literaki/tiles/tilesFr.js +1 -1
  13. package/packages/configs/build/literaki/tiles/tilesPl.js +1 -1
  14. package/packages/configs/build/scrabble/bonuses.js +2 -2
  15. package/packages/configs/build/scrabble/scrabble.js +14 -27
  16. package/packages/configs/build/scrabble/tiles/tilesDe.js +1 -1
  17. package/packages/configs/build/scrabble/tiles/tilesEn.js +1 -1
  18. package/packages/configs/build/scrabble/tiles/tilesEs.js +1 -1
  19. package/packages/configs/build/scrabble/tiles/tilesFr.js +1 -1
  20. package/packages/configs/build/scrabble/tiles/tilesPl.js +1 -1
  21. package/packages/configs/package.json +3 -3
  22. package/packages/constants/package.json +1 -1
  23. package/packages/dictionaries/build/Dictionaries.js +37 -110
  24. package/packages/dictionaries/build/constants/index.js +2 -2
  25. package/packages/dictionaries/build/index.js +1 -1
  26. package/packages/dictionaries/build/lib/DiskCache.js +31 -91
  27. package/packages/dictionaries/build/lib/LayeredCache.js +37 -101
  28. package/packages/dictionaries/build/lib/MemoryCache.js +16 -17
  29. package/packages/dictionaries/build/lib/createAsyncProxy.js +14 -58
  30. package/packages/dictionaries/build/lib/createCacheTimestampComparator.js +4 -4
  31. package/packages/dictionaries/build/lib/downloadDictionary.js +10 -54
  32. package/packages/dictionaries/build/lib/getDictionaryFilepath.js +4 -4
  33. package/packages/dictionaries/build/lib/readFile.js +12 -50
  34. package/packages/dictionaries/build/lib/writeFile.js +12 -50
  35. package/packages/dictionaries/package-lock.json +2 -2
  36. package/packages/dictionaries/package.json +4 -4
  37. package/packages/dictionaries/src/lib/LayeredCache.ts +17 -8
  38. package/packages/logger/build/constants.js +2 -2
  39. package/packages/logger/build/logger.js +4 -4
  40. package/packages/logger/package-lock.json +2 -2
  41. package/packages/logger/package.json +1 -1
  42. package/packages/scrabble-solver/.next/BUILD_ID +1 -1
  43. package/packages/scrabble-solver/.next/build-manifest.json +5 -5
  44. package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
  45. package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
  46. package/packages/scrabble-solver/.next/cache/next-server.js.nft.json +1 -1
  47. package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
  48. package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
  49. package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
  50. package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
  51. package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
  52. package/packages/scrabble-solver/.next/prerender-manifest.json +1 -1
  53. package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
  54. package/packages/scrabble-solver/.next/server/chunks/413.js +391 -673
  55. package/packages/scrabble-solver/.next/server/chunks/515.js +414 -500
  56. package/packages/scrabble-solver/.next/server/chunks/907.js +397 -679
  57. package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
  58. package/packages/scrabble-solver/.next/server/pages/404.html +1 -1
  59. package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +1 -1
  60. package/packages/scrabble-solver/.next/server/pages/500.html +2 -2
  61. package/packages/scrabble-solver/.next/server/pages/_app.js +7 -10
  62. package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
  63. package/packages/scrabble-solver/.next/server/pages/_document.js +0 -3
  64. package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +1 -1
  65. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +114 -171
  66. package/packages/scrabble-solver/.next/server/pages/api/solve.js +428 -1164
  67. package/packages/scrabble-solver/.next/server/pages/index.html +1 -1
  68. package/packages/scrabble-solver/.next/server/pages/index.js +2 -2
  69. package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
  70. package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
  71. package/packages/scrabble-solver/.next/static/OhUvTNKwyrrzmNwKBnpUU/_buildManifest.js +1 -0
  72. package/packages/scrabble-solver/.next/static/{CQTUJjnUaobzo-T6zRWj1 → OhUvTNKwyrrzmNwKBnpUU}/_ssgManifest.js +0 -0
  73. package/packages/scrabble-solver/.next/static/chunks/{195-fcadef5c6eed8338.js → 195-4b75c9c697b7b455.js} +1 -1
  74. package/packages/scrabble-solver/.next/static/chunks/pages/_app-72522bfb306a8aef.js +1 -0
  75. package/packages/scrabble-solver/.next/trace +42 -42
  76. package/packages/scrabble-solver/package-lock.json +2 -2
  77. package/packages/scrabble-solver/package.json +8 -8
  78. package/packages/scrabble-solver/src/components/Board/Board.tsx +1 -1
  79. package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +1 -1
  80. package/packages/scrabble-solver/src/components/Board/components/Cell/Button.tsx +1 -1
  81. package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +1 -1
  82. package/packages/scrabble-solver/src/components/Board/components/Cell/CellPure.tsx +1 -1
  83. package/packages/scrabble-solver/src/components/Button/Button.tsx +1 -1
  84. package/packages/scrabble-solver/src/components/Checkbox/Checkbox.tsx +1 -1
  85. package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +1 -1
  86. package/packages/scrabble-solver/src/components/DictionaryInput/DictionaryInput.tsx +1 -1
  87. package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +1 -1
  88. package/packages/scrabble-solver/src/components/Key/Key.tsx +1 -1
  89. package/packages/scrabble-solver/src/components/KeyMap/KeyMap.tsx +1 -1
  90. package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.tsx +1 -1
  91. package/packages/scrabble-solver/src/components/Loading/Loading.tsx +1 -1
  92. package/packages/scrabble-solver/src/components/Logo/Logo.tsx +1 -1
  93. package/packages/scrabble-solver/src/components/NavButtons/NavButtons.tsx +1 -1
  94. package/packages/scrabble-solver/src/components/NotFound/NotFound.tsx +1 -1
  95. package/packages/scrabble-solver/src/components/PlainTiles/PlainTiles.tsx +1 -1
  96. package/packages/scrabble-solver/src/components/PlainTiles/Tile.tsx +1 -1
  97. package/packages/scrabble-solver/src/components/Rack/Rack.tsx +1 -1
  98. package/packages/scrabble-solver/src/components/Rack/RackTile.tsx +1 -1
  99. package/packages/scrabble-solver/src/components/Radio/Radio.tsx +1 -1
  100. package/packages/scrabble-solver/src/components/RemainingTiles/Character.tsx +1 -1
  101. package/packages/scrabble-solver/src/components/RemainingTiles/RemainingTiles.tsx +1 -1
  102. package/packages/scrabble-solver/src/components/Results/Cell.tsx +1 -1
  103. package/packages/scrabble-solver/src/components/Results/HeaderButton.tsx +1 -1
  104. package/packages/scrabble-solver/src/components/Results/Result.tsx +1 -1
  105. package/packages/scrabble-solver/src/components/Results/Results.tsx +1 -1
  106. package/packages/scrabble-solver/src/components/Results/SolveButton.tsx +1 -1
  107. package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.tsx +1 -1
  108. package/packages/scrabble-solver/src/components/Screen/Screen.tsx +1 -1
  109. package/packages/scrabble-solver/src/components/Settings/Settings.tsx +1 -1
  110. package/packages/scrabble-solver/src/components/Settings/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -1
  111. package/packages/scrabble-solver/src/components/Settings/components/ConfigSetting/ConfigSetting.tsx +1 -1
  112. package/packages/scrabble-solver/src/components/Settings/components/LocaleSetting/LocaleSetting.tsx +1 -1
  113. package/packages/scrabble-solver/src/components/Sidebar/Sidebar.tsx +1 -1
  114. package/packages/scrabble-solver/src/components/Sidebar/components/Section/Section.tsx +1 -1
  115. package/packages/scrabble-solver/src/components/Splash/Splash.tsx +1 -1
  116. package/packages/scrabble-solver/src/components/SquareButton/Link.tsx +1 -1
  117. package/packages/scrabble-solver/src/components/SquareButton/SquareButton.tsx +1 -1
  118. package/packages/scrabble-solver/src/components/Tile/Tile.tsx +1 -1
  119. package/packages/scrabble-solver/src/components/Tile/TilePure.tsx +1 -1
  120. package/packages/scrabble-solver/src/components/Tooltip/useTooltip.tsx +1 -1
  121. package/packages/scrabble-solver/src/components/Well/Well.tsx +1 -1
  122. package/packages/scrabble-solver/src/hooks/usePortal.tsx +19 -9
  123. package/packages/scrabble-solver/src/lib/memoize.ts +1 -1
  124. package/packages/scrabble-solver/src/pages/_app.tsx +1 -1
  125. package/packages/scrabble-solver/src/pages/_document.tsx +1 -1
  126. package/packages/scrabble-solver/src/pages/index.tsx +1 -1
  127. package/packages/solver/build/PatternsFiller.js +37 -67
  128. package/packages/solver/build/PatternsGenerator.js +42 -75
  129. package/packages/solver/build/ScoresCalculator.js +20 -24
  130. package/packages/solver/build/Solver.js +19 -23
  131. package/packages/solver/package-lock.json +2 -2
  132. package/packages/solver/package.json +5 -5
  133. package/packages/solver/src/PatternsFiller.ts +3 -2
  134. package/packages/types/build/Board.js +68 -85
  135. package/packages/types/build/Bonus.js +15 -21
  136. package/packages/types/build/Cell.js +30 -32
  137. package/packages/types/build/CharacterBonus.js +18 -40
  138. package/packages/types/build/Config.js +62 -117
  139. package/packages/types/build/HorizontalPattern.js +17 -63
  140. package/packages/types/build/Pattern.js +36 -40
  141. package/packages/types/build/Result.js +23 -46
  142. package/packages/types/build/Tile.js +22 -24
  143. package/packages/types/build/VerticalPattern.js +17 -63
  144. package/packages/types/build/WordBonus.js +13 -35
  145. package/packages/types/build/WordDefinition.js +13 -15
  146. package/packages/types/package.json +2 -2
  147. package/packages/word-definitions/build/crawl/crawl.js +15 -16
  148. package/packages/word-definitions/build/crawl/crawlEnglish.js +3 -3
  149. package/packages/word-definitions/build/crawl/crawlFrench.js +3 -3
  150. package/packages/word-definitions/build/crawl/crawlGerman.js +3 -3
  151. package/packages/word-definitions/build/crawl/crawlPolish.js +3 -3
  152. package/packages/word-definitions/build/crawl/crawlSpanish.js +3 -3
  153. package/packages/word-definitions/build/getWordDefinition.js +9 -52
  154. package/packages/word-definitions/build/lib/normalizeDefinition.js +15 -15
  155. package/packages/word-definitions/build/lib/request.js +8 -20
  156. package/packages/word-definitions/build/lib/unique.js +1 -1
  157. package/packages/word-definitions/build/parse/parse.js +18 -19
  158. package/packages/word-definitions/build/parse/parseEnglish.js +5 -5
  159. package/packages/word-definitions/build/parse/parseFrench.js +5 -5
  160. package/packages/word-definitions/build/parse/parseGerman.js +6 -6
  161. package/packages/word-definitions/build/parse/parsePolish.js +6 -6
  162. package/packages/word-definitions/build/parse/parseSpanish.js +9 -9
  163. package/packages/word-definitions/package-lock.json +8 -8
  164. package/packages/word-definitions/package.json +2 -2
  165. package/packages/word-lists/build/getDeDeWordList.js +5 -43
  166. package/packages/word-lists/build/getEnGbWordList.js +5 -43
  167. package/packages/word-lists/build/getEnUsWordList.js +5 -43
  168. package/packages/word-lists/build/getEsEsWordList.js +7 -50
  169. package/packages/word-lists/build/getFrFrWordList.js +9 -50
  170. package/packages/word-lists/build/getPlPlWordList.js +34 -91
  171. package/packages/word-lists/build/getWordList.js +16 -17
  172. package/packages/word-lists/build/lib/downloadFile.js +5 -5
  173. package/packages/word-lists/build/lib/downloadHtml.js +8 -8
  174. package/packages/word-lists/build/lib/extractWords.js +5 -5
  175. package/packages/word-lists/build/lib/findFirstWordIndex.js +6 -6
  176. package/packages/word-lists/build/lib/getHash.js +2 -5
  177. package/packages/word-lists/build/lib/getTempFilename.js +3 -3
  178. package/packages/word-lists/build/lib/getTxtWordList.js +12 -56
  179. package/packages/word-lists/package-lock.json +2 -2
  180. package/packages/word-lists/package.json +2 -2
  181. package/packages/word-lists/src/getFrFrWordList.ts +3 -1
  182. package/tsconfig.json +1 -1
  183. package/packages/scrabble-solver/.next/static/CQTUJjnUaobzo-T6zRWj1/_buildManifest.js +0 -1
  184. package/packages/scrabble-solver/.next/static/chunks/pages/_app-f4030148d742bcd2.js +0 -1
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var Bonus = /** @class */ (function () {
4
- function Bonus(_a) {
5
- var multiplier = _a.multiplier, score = _a.score, x = _a.x, y = _a.y;
3
+ class Bonus {
4
+ constructor({ multiplier, score, x, y }) {
6
5
  this.multiplier = multiplier;
7
6
  this.score = score;
8
7
  this.x = x;
9
8
  this.y = y;
10
9
  }
11
- Bonus.prototype.canApply = function (_config, cell) {
10
+ canApply(_config, cell) {
12
11
  return cell.isEmpty && this.matchesCellCoordinates(cell);
13
- };
14
- Bonus.prototype.matchesCellCoordinates = function (cell) {
12
+ }
13
+ matchesCellCoordinates(cell) {
15
14
  return this.x === cell.x && this.y === cell.y;
16
- };
17
- Bonus.prototype.toJson = function () {
15
+ }
16
+ toJson() {
18
17
  return {
19
18
  multiplier: this.multiplier,
20
19
  score: this.score,
@@ -22,17 +21,12 @@ var Bonus = /** @class */ (function () {
22
21
  x: this.x,
23
22
  y: this.y,
24
23
  };
25
- };
26
- Object.defineProperty(Bonus.prototype, "value", {
27
- get: function () {
28
- return {
29
- characterMultiplier: 1,
30
- wordMultiplier: 1,
31
- };
32
- },
33
- enumerable: false,
34
- configurable: true
35
- });
36
- return Bonus;
37
- }());
24
+ }
25
+ get value() {
26
+ return {
27
+ characterMultiplier: 1,
28
+ wordMultiplier: 1,
29
+ };
30
+ }
31
+ }
38
32
  exports.default = Bonus;
@@ -3,17 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var Tile_1 = __importDefault(require("./Tile"));
7
- var Cell = /** @class */ (function () {
6
+ const Tile_1 = __importDefault(require("./Tile"));
7
+ class Cell {
8
8
  // eslint-disable-next-line no-undef
9
- function Cell(_a) {
10
- var _b = _a.isEmpty, isEmpty = _b === void 0 ? true : _b, _c = _a.tile, tile = _c === void 0 ? Tile_1.default.Null : _c, x = _a.x, y = _a.y;
9
+ constructor({ isEmpty = true, tile = Tile_1.default.Null, x, y }) {
11
10
  this.isEmpty = isEmpty;
12
11
  this.tile = tile;
13
12
  this.x = x;
14
13
  this.y = y;
15
14
  }
16
- Cell.fromJson = function (json) {
15
+ static fromJson(json) {
17
16
  if (!json) {
18
17
  return Cell.Null;
19
18
  }
@@ -23,47 +22,46 @@ var Cell = /** @class */ (function () {
23
22
  x: json.x,
24
23
  y: json.y,
25
24
  });
26
- };
27
- Cell.prototype.clone = function () {
25
+ }
26
+ clone() {
28
27
  return new Cell({
29
28
  isEmpty: this.isEmpty,
30
29
  tile: this.tile.clone(),
31
30
  x: this.x,
32
31
  y: this.y,
33
32
  });
34
- };
35
- Cell.prototype.equals = function (other) {
33
+ }
34
+ equals(other) {
36
35
  return this.x === other.x && this.y === other.y && this.isEmpty === other.isEmpty && this.tile.equals(other.tile);
37
- };
38
- Cell.prototype.hasTile = function () {
36
+ }
37
+ hasTile() {
39
38
  return this.tile !== Tile_1.default.Null;
40
- };
41
- Cell.prototype.isCandidate = function () {
39
+ }
40
+ isCandidate() {
42
41
  return this.isEmpty && this.hasTile();
43
- };
44
- Cell.prototype.toJson = function () {
42
+ }
43
+ toJson() {
45
44
  return {
46
45
  isEmpty: this.isEmpty,
47
46
  tile: this.tile.toJson(),
48
47
  x: this.x,
49
48
  y: this.y,
50
49
  };
51
- };
52
- Cell.prototype.toString = function () {
50
+ }
51
+ toString() {
53
52
  return String(this.tile);
54
- };
55
- Cell.Null = Object.freeze({
56
- isEmpty: true,
57
- tile: Tile_1.default.Null,
58
- x: 0,
59
- y: 0,
60
- clone: function () { return Cell.Null; },
61
- equals: function (other) { return other === Cell.Null; },
62
- hasTile: function () { return false; },
63
- isCandidate: function () { return false; },
64
- toString: function () { return ''; },
65
- toJson: function () { return null; },
66
- });
67
- return Cell;
68
- }());
53
+ }
54
+ }
55
+ Cell.Null = Object.freeze({
56
+ isEmpty: true,
57
+ tile: Tile_1.default.Null,
58
+ x: 0,
59
+ y: 0,
60
+ clone: () => Cell.Null,
61
+ equals: (other) => other === Cell.Null,
62
+ hasTile: () => false,
63
+ isCandidate: () => false,
64
+ toString: () => '',
65
+ toJson: () => null,
66
+ });
69
67
  exports.default = Cell;
@@ -1,51 +1,29 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
18
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
4
  };
20
5
  Object.defineProperty(exports, "__esModule", { value: true });
21
- var constants_1 = require("@scrabble-solver/constants");
22
- var Bonus_1 = __importDefault(require("./Bonus"));
23
- var CharacterBonus = /** @class */ (function (_super) {
24
- __extends(CharacterBonus, _super);
25
- function CharacterBonus() {
26
- var _this = _super !== null && _super.apply(this, arguments) || this;
27
- _this.type = constants_1.BONUS_CHARACTER;
28
- return _this;
6
+ const constants_1 = require("@scrabble-solver/constants");
7
+ const Bonus_1 = __importDefault(require("./Bonus"));
8
+ class CharacterBonus extends Bonus_1.default {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.type = constants_1.BONUS_CHARACTER;
29
12
  }
30
- CharacterBonus.prototype.canApply = function (config, cell) {
31
- return _super.prototype.canApply.call(this, config, cell) && this.matchesCellTileScore(config, cell);
32
- };
33
- CharacterBonus.prototype.matchesCellTileScore = function (config, cell) {
13
+ canApply(config, cell) {
14
+ return super.canApply(config, cell) && this.matchesCellTileScore(config, cell);
15
+ }
16
+ matchesCellTileScore(config, cell) {
34
17
  if (typeof this.score === 'undefined') {
35
18
  return true;
36
19
  }
37
20
  return this.score === config.pointsMap[cell.tile.character];
38
- };
39
- Object.defineProperty(CharacterBonus.prototype, "value", {
40
- get: function () {
41
- return {
42
- characterMultiplier: this.multiplier,
43
- wordMultiplier: 1,
44
- };
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- return CharacterBonus;
50
- }(Bonus_1.default));
21
+ }
22
+ get value() {
23
+ return {
24
+ characterMultiplier: this.multiplier,
25
+ wordMultiplier: 1,
26
+ };
27
+ }
28
+ }
51
29
  exports.default = CharacterBonus;
@@ -1,81 +1,45 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
- var constants_1 = require("@scrabble-solver/constants");
18
- var CharacterBonus_1 = __importDefault(require("./CharacterBonus"));
19
- var WordBonus_1 = __importDefault(require("./WordBonus"));
20
- var Config = /** @class */ (function () {
21
- function Config(config) {
6
+ const constants_1 = require("@scrabble-solver/constants");
7
+ const CharacterBonus_1 = __importDefault(require("./CharacterBonus"));
8
+ const WordBonus_1 = __importDefault(require("./WordBonus"));
9
+ class Config {
10
+ constructor(config) {
22
11
  this.bonuses = getBonuses(config);
23
12
  this.config = config;
24
13
  this.pointsMap = getPointsMap(this.config);
25
14
  }
26
- Config.fromJson = function (json) {
15
+ static fromJson(json) {
27
16
  return new Config(json);
28
- };
29
- Object.defineProperty(Config.prototype, "allTilesBonusScore", {
30
- get: function () {
31
- return this.config.allTilesBonusScore;
32
- },
33
- enumerable: false,
34
- configurable: true
35
- });
36
- Object.defineProperty(Config.prototype, "alphabet", {
37
- get: function () {
38
- return getAlphabet(this.config);
39
- },
40
- enumerable: false,
41
- configurable: true
42
- });
43
- Object.defineProperty(Config.prototype, "blankScore", {
44
- get: function () {
45
- return this.config.blankScore;
46
- },
47
- enumerable: false,
48
- configurable: true
49
- });
50
- Object.defineProperty(Config.prototype, "boardHeight", {
51
- get: function () {
52
- return this.config.boardHeight;
53
- },
54
- enumerable: false,
55
- configurable: true
56
- });
57
- Object.defineProperty(Config.prototype, "boardWidth", {
58
- get: function () {
59
- return this.config.boardWidth;
60
- },
61
- enumerable: false,
62
- configurable: true
63
- });
64
- Object.defineProperty(Config.prototype, "twoCharacterTiles", {
65
- get: function () {
66
- return this.config.tiles.filter(function (tile) { return tile.character.length === 2; }).map(function (tile) { return tile.character; });
67
- },
68
- enumerable: false,
69
- configurable: true
70
- });
71
- Config.prototype.getCellBonus = function (cell) {
72
- return this.bonuses.find(function (bonus) { return bonus.matchesCellCoordinates(cell); });
73
- };
74
- Config.prototype.getCellBonusValue = function (cell) {
75
- var _a;
76
- return ((_a = this.getCellBonus(cell)) === null || _a === void 0 ? void 0 : _a.value) || constants_1.NO_BONUS;
77
- };
78
- Config.prototype.getCharacterPoints = function (character) {
17
+ }
18
+ get allTilesBonusScore() {
19
+ return this.config.allTilesBonusScore;
20
+ }
21
+ get alphabet() {
22
+ return getAlphabet(this.config);
23
+ }
24
+ get blankScore() {
25
+ return this.config.blankScore;
26
+ }
27
+ get boardHeight() {
28
+ return this.config.boardHeight;
29
+ }
30
+ get boardWidth() {
31
+ return this.config.boardWidth;
32
+ }
33
+ get twoCharacterTiles() {
34
+ return this.config.tiles.filter((tile) => tile.character.length === 2).map((tile) => tile.character);
35
+ }
36
+ getCellBonus(cell) {
37
+ return this.bonuses.find((bonus) => bonus.matchesCellCoordinates(cell));
38
+ }
39
+ getCellBonusValue(cell) {
40
+ return this.getCellBonus(cell)?.value || constants_1.NO_BONUS;
41
+ }
42
+ getCharacterPoints(character) {
79
43
  if (character === null) {
80
44
  return undefined;
81
45
  }
@@ -83,71 +47,52 @@ var Config = /** @class */ (function () {
83
47
  return this.blankScore;
84
48
  }
85
49
  return this.pointsMap[character];
86
- };
87
- Config.prototype.getTwoCharacterTileByPrefix = function (character) {
50
+ }
51
+ getTwoCharacterTileByPrefix(character) {
88
52
  if (character.length !== 1) {
89
53
  return undefined;
90
54
  }
91
- return this.twoCharacterTiles.find(function (characters) { return characters.startsWith(character); });
92
- };
93
- Config.prototype.getTilePoints = function (tile) {
55
+ return this.twoCharacterTiles.find((characters) => characters.startsWith(character));
56
+ }
57
+ getTilePoints(tile) {
94
58
  if (tile === null) {
95
59
  return undefined;
96
60
  }
97
61
  return tile.isBlank ? this.blankScore : this.getCharacterPoints(tile.character);
98
- };
99
- Config.prototype.hasCharacter = function (character) {
62
+ }
63
+ hasCharacter(character) {
100
64
  return this.alphabet.includes(character);
101
- };
102
- Config.prototype.isTwoCharacterTilePrefix = function (character) {
65
+ }
66
+ isTwoCharacterTilePrefix(character) {
103
67
  return typeof this.getTwoCharacterTileByPrefix(character) !== 'undefined';
104
- };
105
- Object.defineProperty(Config.prototype, "maximumNumberOfCharacters", {
106
- get: function () {
107
- return this.config.maximumNumberOfCharacters;
108
- },
109
- enumerable: false,
110
- configurable: true
111
- });
112
- Object.defineProperty(Config.prototype, "numberOfBlanks", {
113
- get: function () {
114
- return this.config.numberOfBlanks;
115
- },
116
- enumerable: false,
117
- configurable: true
118
- });
119
- Object.defineProperty(Config.prototype, "tiles", {
120
- get: function () {
121
- return this.config.tiles;
122
- },
123
- enumerable: false,
124
- configurable: true
125
- });
126
- Config.prototype.toJson = function () {
68
+ }
69
+ get maximumNumberOfCharacters() {
70
+ return this.config.maximumNumberOfCharacters;
71
+ }
72
+ get numberOfBlanks() {
73
+ return this.config.numberOfBlanks;
74
+ }
75
+ get tiles() {
76
+ return this.config.tiles;
77
+ }
78
+ toJson() {
127
79
  return this.config;
128
- };
129
- return Config;
130
- }());
131
- var getBonuses = function (config) {
132
- return config.bonuses.map(function (bonus) {
80
+ }
81
+ }
82
+ const getBonuses = (config) => {
83
+ return config.bonuses.map((bonus) => {
133
84
  if (bonus.type === constants_1.BONUS_CHARACTER) {
134
85
  return new CharacterBonus_1.default(bonus);
135
86
  }
136
87
  if (bonus.type === constants_1.BONUS_WORD) {
137
88
  return new WordBonus_1.default(bonus);
138
89
  }
139
- throw new Error("Unsupported Bonus type: \"".concat(bonus.type, "\""));
90
+ throw new Error(`Unsupported Bonus type: "${bonus.type}"`);
140
91
  });
141
92
  };
142
- var getAlphabet = function (config) { return config.tiles.map(function (_a) {
143
- var character = _a.character;
144
- return character;
145
- }); };
146
- var getPointsMap = function (config) {
147
- return config.tiles.reduce(function (pointsMap, _a) {
148
- var _b;
149
- var character = _a.character, score = _a.score;
150
- return (__assign(__assign({}, pointsMap), (_b = {}, _b[character] = score, _b)));
151
- }, {});
152
- };
93
+ const getAlphabet = (config) => config.tiles.map(({ character }) => character);
94
+ const getPointsMap = (config) => config.tiles.reduce((pointsMap, { character, score }) => ({
95
+ ...pointsMap,
96
+ [character]: score,
97
+ }), {});
153
98
  exports.default = Config;
@@ -1,85 +1,39 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __read = (this && this.__read) || function (o, n) {
18
- var m = typeof Symbol === "function" && o[Symbol.iterator];
19
- if (!m) return o;
20
- var i = m.call(o), r, ar = [], e;
21
- try {
22
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
23
- }
24
- catch (error) { e = { error: error }; }
25
- finally {
26
- try {
27
- if (r && !r.done && (m = i["return"])) m.call(i);
28
- }
29
- finally { if (e) throw e.error; }
30
- }
31
- return ar;
32
- };
33
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
34
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
35
- if (ar || !(i in from)) {
36
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
37
- ar[i] = from[i];
38
- }
39
- }
40
- return to.concat(ar || Array.prototype.slice.call(from));
41
- };
42
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
43
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
44
4
  };
45
5
  Object.defineProperty(exports, "__esModule", { value: true });
46
- var Pattern_1 = __importDefault(require("./Pattern"));
47
- var HorizontalPattern = /** @class */ (function (_super) {
48
- __extends(HorizontalPattern, _super);
49
- function HorizontalPattern() {
50
- return _super !== null && _super.apply(this, arguments) || this;
51
- }
52
- HorizontalPattern.prototype.clone = function () {
6
+ const Pattern_1 = __importDefault(require("./Pattern"));
7
+ class HorizontalPattern extends Pattern_1.default {
8
+ clone() {
53
9
  return new HorizontalPattern({
54
10
  board: this.board,
55
- cells: this.cells.map(function (cell) { return cell.clone(); }),
11
+ cells: this.cells.map((cell) => cell.clone()),
56
12
  });
57
- };
58
- HorizontalPattern.prototype.getCollisions = function () {
59
- var _this = this;
60
- var collisions = [];
13
+ }
14
+ getCollisions() {
15
+ const collisions = [];
61
16
  this.cells
62
- .filter(function (cell) { return cell.isEmpty && (_this.board.collidesUp(cell) || _this.board.collidesDown(cell)); })
63
- .forEach(function (cell) {
64
- var column = _this.board.getColumn(cell.x);
65
- var y = cell.y - 1;
17
+ .filter((cell) => cell.isEmpty && (this.board.collidesUp(cell) || this.board.collidesDown(cell)))
18
+ .forEach((cell) => {
19
+ const column = this.board.getColumn(cell.x);
20
+ let y = cell.y - 1;
66
21
  while (y >= 0 && column[y].hasTile()) {
67
22
  --y;
68
23
  }
69
- var previousCells = column.slice(y + 1, cell.y);
24
+ const previousCells = column.slice(y + 1, cell.y);
70
25
  y = cell.y + 1;
71
26
  while (y < column.length && column[y].hasTile()) {
72
27
  ++y;
73
28
  }
74
- var nextCells = column.slice(cell.y + 1, y);
75
- var cells = __spreadArray(__spreadArray(__spreadArray([], __read(previousCells), false), [cell], false), __read(nextCells), false);
29
+ const nextCells = column.slice(cell.y + 1, y);
30
+ const cells = [...previousCells, cell, ...nextCells];
76
31
  if (cells.length > 1) {
77
- var pattern = new Pattern_1.default({ board: _this.board, cells: cells });
32
+ const pattern = new Pattern_1.default({ board: this.board, cells });
78
33
  collisions.push(pattern);
79
34
  }
80
35
  });
81
36
  return collisions;
82
- };
83
- return HorizontalPattern;
84
- }(Pattern_1.default));
37
+ }
38
+ }
85
39
  exports.default = HorizontalPattern;
@@ -1,56 +1,52 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var Pattern = /** @class */ (function () {
4
- function Pattern(_a) {
5
- var board = _a.board, cells = _a.cells;
3
+ class Pattern {
4
+ constructor({ board, cells }) {
6
5
  this.board = board;
7
6
  this.cells = cells;
8
7
  }
9
- Pattern.prototype.canBePlaced = function (config) {
10
- var numberOfEmptyCells = this.getNumberOfEmptyCells();
11
- var isNumberOfUsedCellsInRange = numberOfEmptyCells >= 1 && numberOfEmptyCells <= config.maximumNumberOfCharacters;
8
+ canBePlaced(config) {
9
+ const numberOfEmptyCells = this.getNumberOfEmptyCells();
10
+ const isNumberOfUsedCellsInRange = numberOfEmptyCells >= 1 && numberOfEmptyCells <= config.maximumNumberOfCharacters;
12
11
  return (isNumberOfUsedCellsInRange &&
13
12
  (this.hasAtLeast1NonEmptyCell() || this.collides() || (this.goesThroughBoardCenter() && this.board.isEmpty())));
14
- };
15
- Pattern.prototype.clone = function () {
13
+ }
14
+ clone() {
16
15
  return new Pattern({
17
16
  board: this.board,
18
- cells: this.cells.map(function (cell) { return cell.clone(); }),
17
+ cells: this.cells.map((cell) => cell.clone()),
19
18
  });
20
- };
21
- Pattern.prototype.collides = function () {
22
- var _this = this;
23
- return this.cells.some(function (cell) { return cell.isEmpty && _this.board.collides(cell); });
24
- };
25
- Pattern.prototype.getIndexOfFirstCellWithoutTile = function () {
26
- return this.cells.findIndex(function (cell) { return !cell.hasTile(); });
27
- };
28
- Pattern.prototype.getNumberOfEmptyCells = function () {
29
- return this.cells.filter(function (cell) { return cell.isEmpty; }).length;
30
- };
31
- Pattern.prototype.goesThroughBoardCenter = function () {
32
- var _this = this;
33
- return this.cells.some(function (cell) { return cell.x === _this.board.center.x && cell.y === _this.board.center.y && cell.isEmpty; });
34
- };
35
- Pattern.prototype.hasAtLeast1EmptyCell = function () {
36
- return this.cells.some(function (cell) { return cell.isEmpty; });
37
- };
38
- Pattern.prototype.hasAtLeast1NonEmptyCell = function () {
39
- return this.cells.some(function (cell) { return !cell.isEmpty; });
40
- };
41
- Pattern.prototype.getCollisions = function () {
19
+ }
20
+ collides() {
21
+ return this.cells.some((cell) => cell.isEmpty && this.board.collides(cell));
22
+ }
23
+ getIndexOfFirstCellWithoutTile() {
24
+ return this.cells.findIndex((cell) => !cell.hasTile());
25
+ }
26
+ getNumberOfEmptyCells() {
27
+ return this.cells.filter((cell) => cell.isEmpty).length;
28
+ }
29
+ goesThroughBoardCenter() {
30
+ return this.cells.some((cell) => cell.x === this.board.center.x && cell.y === this.board.center.y && cell.isEmpty);
31
+ }
32
+ hasAtLeast1EmptyCell() {
33
+ return this.cells.some((cell) => cell.isEmpty);
34
+ }
35
+ hasAtLeast1NonEmptyCell() {
36
+ return this.cells.some((cell) => !cell.isEmpty);
37
+ }
38
+ getCollisions() {
42
39
  return [];
43
- };
44
- Pattern.prototype.toJson = function () {
40
+ }
41
+ toJson() {
45
42
  return {
46
- cells: this.cells.map(function (cell) { return cell.toJson(); }),
47
- collisions: this.getCollisions().map(function (collision) { return collision.toJson(); }),
43
+ cells: this.cells.map((cell) => cell.toJson()),
44
+ collisions: this.getCollisions().map((collision) => collision.toJson()),
48
45
  word: this.toString(),
49
46
  };
50
- };
51
- Pattern.prototype.toString = function () {
47
+ }
48
+ toString() {
52
49
  return this.cells.map(String).join('');
53
- };
54
- return Pattern;
55
- }());
50
+ }
51
+ }
56
52
  exports.default = Pattern;