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
package/.eslintrc.js CHANGED
@@ -458,7 +458,7 @@ module.exports = {
458
458
  'react/prefer-es6-class': 'error',
459
459
  // 'react/prefer-stateless-function': 'error',
460
460
  'react/prop-types': 'error',
461
- 'react/react-in-jsx-scope': 'error',
461
+ 'react/react-in-jsx-scope': 'off',
462
462
  // 'react/require-optimization': 'error',
463
463
  'react/require-render-return': 'error',
464
464
  'react/self-closing-comp': 'error',
package/lerna.json CHANGED
@@ -6,5 +6,5 @@
6
6
  "access": "public"
7
7
  },
8
8
  "tagVersionPrefix": "",
9
- "version": "2.8.1"
9
+ "version": "2.8.3"
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scrabble-solver",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "Scrabble Solver 2 - The ultimate, open-source cheating app for Scrabble and Literaki",
5
5
  "keywords": [
6
6
  "Scrabble",
@@ -3,19 +3,13 @@ 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 literaki_1 = __importDefault(require("./literaki"));
7
- var scrabble_1 = __importDefault(require("./scrabble"));
8
- var configs = [literaki_1.default, scrabble_1.default];
9
- var getConfig = function (configId) {
10
- var config = configs.find(function (_a) {
11
- var id = _a.id;
12
- return id === configId;
13
- });
6
+ const literaki_1 = __importDefault(require("./literaki"));
7
+ const scrabble_1 = __importDefault(require("./scrabble"));
8
+ const configs = [literaki_1.default, scrabble_1.default];
9
+ const getConfig = (configId) => {
10
+ const config = configs.find(({ id }) => id === configId);
14
11
  if (!config) {
15
- throw new Error("Invalid \"configId\" parameter: not one of ".concat(configs.map(function (_a) {
16
- var id = _a.id;
17
- return id;
18
- }).join('/')));
12
+ throw new Error(`Invalid "configId" parameter: not one of ${configs.map(({ id }) => id).join('/')}`);
19
13
  }
20
14
  return config;
21
15
  };
@@ -3,8 +3,8 @@ 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 getConfig_1 = __importDefault(require("./getConfig"));
7
- var getLocaleConfig = function (configId, locale) {
6
+ const getConfig_1 = __importDefault(require("./getConfig"));
7
+ const getLocaleConfig = (configId, locale) => {
8
8
  return (0, getConfig_1.default)(configId)[locale];
9
9
  };
10
10
  exports.default = getLocaleConfig;
@@ -3,13 +3,10 @@ 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 literaki_1 = __importDefault(require("./literaki"));
7
- var scrabble_1 = __importDefault(require("./scrabble"));
8
- var configs = [literaki_1.default, scrabble_1.default];
9
- var isConfigId = function (configId) {
10
- return configs.some(function (_a) {
11
- var id = _a.id;
12
- return id === configId;
13
- });
6
+ const literaki_1 = __importDefault(require("./literaki"));
7
+ const scrabble_1 = __importDefault(require("./scrabble"));
8
+ const configs = [literaki_1.default, scrabble_1.default];
9
+ const isConfigId = (configId) => {
10
+ return configs.some(({ id }) => id === configId);
14
11
  };
15
12
  exports.default = isConfigId;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var constants_1 = require("@scrabble-solver/constants");
4
- var bonuses = [
3
+ const constants_1 = require("@scrabble-solver/constants");
4
+ const bonuses = [
5
5
  { multiplier: 3, score: 5, type: constants_1.BONUS_CHARACTER, x: 0, y: 0 },
6
6
  { multiplier: 3, type: constants_1.BONUS_WORD, x: 2, y: 0 },
7
7
  { multiplier: 3, score: 2, type: constants_1.BONUS_CHARACTER, x: 5, y: 0 },
@@ -1,24 +1,12 @@
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
- var _a;
17
5
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var types_1 = require("@scrabble-solver/types");
19
- var bonuses_1 = __importDefault(require("./bonuses"));
20
- var tiles_1 = require("./tiles");
21
- var base = {
6
+ const types_1 = require("@scrabble-solver/types");
7
+ const bonuses_1 = __importDefault(require("./bonuses"));
8
+ const tiles_1 = require("./tiles");
9
+ const base = {
22
10
  allTilesBonusScore: 50,
23
11
  blankScore: 0,
24
12
  boardHeight: 15,
@@ -29,15 +17,14 @@ var base = {
29
17
  name: 'Literaki',
30
18
  numberOfBlanks: 2,
31
19
  };
32
- var literaki = (_a = {
33
- id: base.id,
34
- name: base.name
35
- },
36
- _a[types_1.Locale.DE_DE] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesDe })),
37
- _a[types_1.Locale.EN_GB] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesEn })),
38
- _a[types_1.Locale.EN_US] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesEn })),
39
- _a[types_1.Locale.ES_ES] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesEs })),
40
- _a[types_1.Locale.FR_FR] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesFr })),
41
- _a[types_1.Locale.PL_PL] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesPl })),
42
- _a);
20
+ const literaki = {
21
+ id: base.id,
22
+ name: base.name,
23
+ [types_1.Locale.DE_DE]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesDe }),
24
+ [types_1.Locale.EN_GB]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesEn }),
25
+ [types_1.Locale.EN_US]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesEn }),
26
+ [types_1.Locale.ES_ES]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesEs }),
27
+ [types_1.Locale.FR_FR]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesFr }),
28
+ [types_1.Locale.PL_PL]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesPl }),
29
+ };
43
30
  exports.default = literaki;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesDe = [
3
+ const tilesDe = [
4
4
  { character: 'a', count: 5, score: 1 },
5
5
  { character: 'ä', count: 1, score: 6 },
6
6
  { character: 'b', count: 2, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesEn = [
3
+ const tilesEn = [
4
4
  { character: 'a', count: 9, score: 1 },
5
5
  { character: 'b', count: 2, score: 3 },
6
6
  { character: 'c', count: 2, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesEs = [
3
+ const tilesEs = [
4
4
  { character: 'a', count: 12, score: 1 },
5
5
  { character: 'b', count: 2, score: 3 },
6
6
  { character: 'c', count: 4, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesFr = [
3
+ const tilesFr = [
4
4
  { character: 'a', count: 9, score: 1 },
5
5
  { character: 'b', count: 2, score: 3 },
6
6
  { character: 'c', count: 2, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesPl = [
3
+ const tilesPl = [
4
4
  { character: 'a', count: 9, score: 1 },
5
5
  { character: 'ą', count: 1, score: 5 },
6
6
  { character: 'b', count: 2, score: 3 },
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var constants_1 = require("@scrabble-solver/constants");
4
- var bonuses = [
3
+ const constants_1 = require("@scrabble-solver/constants");
4
+ const bonuses = [
5
5
  { multiplier: 3, type: constants_1.BONUS_WORD, x: 0, y: 0 },
6
6
  { multiplier: 2, type: constants_1.BONUS_CHARACTER, x: 3, y: 0 },
7
7
  { multiplier: 3, type: constants_1.BONUS_WORD, x: 7, y: 0 },
@@ -1,24 +1,12 @@
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
- var _a;
17
5
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var types_1 = require("@scrabble-solver/types");
19
- var bonuses_1 = __importDefault(require("./bonuses"));
20
- var tiles_1 = require("./tiles");
21
- var base = {
6
+ const types_1 = require("@scrabble-solver/types");
7
+ const bonuses_1 = __importDefault(require("./bonuses"));
8
+ const tiles_1 = require("./tiles");
9
+ const base = {
22
10
  allTilesBonusScore: 50,
23
11
  blankScore: 0,
24
12
  boardHeight: 15,
@@ -29,15 +17,14 @@ var base = {
29
17
  name: 'Scrabble',
30
18
  numberOfBlanks: 2,
31
19
  };
32
- var scrabble = (_a = {
33
- id: base.id,
34
- name: base.name
35
- },
36
- _a[types_1.Locale.EN_GB] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesEn })),
37
- _a[types_1.Locale.DE_DE] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesDe })),
38
- _a[types_1.Locale.EN_US] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesEn })),
39
- _a[types_1.Locale.ES_ES] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesEs })),
40
- _a[types_1.Locale.FR_FR] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesFr })),
41
- _a[types_1.Locale.PL_PL] = types_1.Config.fromJson(__assign(__assign({}, base), { tiles: tiles_1.tilesPl })),
42
- _a);
20
+ const scrabble = {
21
+ id: base.id,
22
+ name: base.name,
23
+ [types_1.Locale.EN_GB]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesEn }),
24
+ [types_1.Locale.DE_DE]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesDe }),
25
+ [types_1.Locale.EN_US]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesEn }),
26
+ [types_1.Locale.ES_ES]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesEs }),
27
+ [types_1.Locale.FR_FR]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesFr }),
28
+ [types_1.Locale.PL_PL]: types_1.Config.fromJson({ ...base, tiles: tiles_1.tilesPl }),
29
+ };
43
30
  exports.default = scrabble;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesDe = [
3
+ const tilesDe = [
4
4
  { character: 'a', count: 5, score: 1 },
5
5
  { character: 'ä', count: 1, score: 6 },
6
6
  { character: 'b', count: 2, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesEn = [
3
+ const tilesEn = [
4
4
  { character: 'a', count: 9, score: 1 },
5
5
  { character: 'b', count: 2, score: 3 },
6
6
  { character: 'c', count: 2, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesEs = [
3
+ const tilesEs = [
4
4
  { character: 'a', count: 12, score: 1 },
5
5
  { character: 'b', count: 2, score: 3 },
6
6
  { character: 'c', count: 4, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesFr = [
3
+ const tilesFr = [
4
4
  { character: 'a', count: 9, score: 1 },
5
5
  { character: 'b', count: 2, score: 3 },
6
6
  { character: 'c', count: 2, score: 3 },
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tilesPl = [
3
+ const tilesPl = [
4
4
  { character: 'a', count: 9, score: 1 },
5
5
  { character: 'ą', count: 1, score: 5 },
6
6
  { character: 'b', count: 2, score: 3 },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/configs",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "Scrabble Solver 2 - Configs",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "clean:force": "npm run clean && rimraf package-lock.json"
25
25
  },
26
26
  "dependencies": {
27
- "@scrabble-solver/constants": "^2.8.1",
28
- "@scrabble-solver/types": "^2.8.1"
27
+ "@scrabble-solver/constants": "^2.8.3",
28
+ "@scrabble-solver/types": "^2.8.3"
29
29
  },
30
30
  "gitHead": "1e2d1ad49a288d4a44196d8e3336740da132c637"
31
31
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/constants",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "Scrabble Solver 2 - Constants",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1,119 +1,46 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
41
5
  Object.defineProperty(exports, "__esModule", { value: true });
42
- var logger_1 = __importDefault(require("@scrabble-solver/logger"));
43
- var types_1 = require("@scrabble-solver/types");
44
- var fs_1 = __importDefault(require("fs"));
45
- var constants_1 = require("./constants");
46
- var lib_1 = require("./lib");
47
- var Dictionaries = /** @class */ (function () {
48
- function Dictionaries() {
6
+ const logger_1 = __importDefault(require("@scrabble-solver/logger"));
7
+ const types_1 = require("@scrabble-solver/types");
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const constants_1 = require("./constants");
10
+ const lib_1 = require("./lib");
11
+ class Dictionaries {
12
+ constructor() {
49
13
  this.cache = new lib_1.LayeredCache();
50
- this.downloadDictionaryProxies = Object.fromEntries(Object.values(types_1.Locale).map(function (locale) { return [locale, (0, lib_1.createAsyncProxy)(function () { return (0, lib_1.downloadDictionary)(locale); })]; }));
14
+ this.downloadDictionaryProxies = Object.fromEntries(Object.values(types_1.Locale).map((locale) => [locale, (0, lib_1.createAsyncProxy)(() => (0, lib_1.downloadDictionary)(locale))]));
15
+ }
16
+ async get(locale) {
17
+ if (this.cache.has(locale)) {
18
+ const trie = await this.cache.get(locale);
19
+ if (trie) {
20
+ return trie;
21
+ }
22
+ }
23
+ logger_1.default.info('Dictionaries - cache miss', { locale });
24
+ return this.updateDictionary(locale);
51
25
  }
52
- Dictionaries.prototype.get = function (locale) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var trie;
55
- return __generator(this, function (_a) {
56
- switch (_a.label) {
57
- case 0:
58
- if (!this.cache.has(locale)) return [3 /*break*/, 2];
59
- return [4 /*yield*/, this.cache.get(locale)];
60
- case 1:
61
- trie = _a.sent();
62
- if (trie) {
63
- return [2 /*return*/, trie];
64
- }
65
- _a.label = 2;
66
- case 2:
67
- logger_1.default.info('Dictionaries - cache miss', { locale: locale });
68
- return [2 /*return*/, this.updateDictionary(locale)];
69
- }
70
- });
71
- });
72
- };
73
- Dictionaries.prototype.remove = function () {
26
+ remove() {
74
27
  fs_1.default.rmdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
75
- };
76
- Dictionaries.prototype.update = function (force) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- var locales;
79
- var _this = this;
80
- return __generator(this, function (_a) {
81
- switch (_a.label) {
82
- case 0:
83
- locales = force ? Object.values(types_1.Locale) : this.getLocalesToUpdate();
84
- logger_1.default.info('Dictionaries - update', { force: force, locales: locales });
85
- return [4 /*yield*/, Promise.all(locales.map(function (locale) { return _this.updateDictionary(locale); }))];
86
- case 1:
87
- _a.sent();
88
- return [2 /*return*/];
89
- }
90
- });
91
- });
92
- };
93
- Dictionaries.prototype.getLocalesToUpdate = function () {
94
- var _this = this;
95
- return Object.values(types_1.Locale).filter(function (locale) { return _this.cache.isStale(locale) !== false; });
96
- };
97
- Dictionaries.prototype.updateDictionary = function (locale) {
98
- return __awaiter(this, void 0, void 0, function () {
99
- var downloadDictionaryProxy, trie;
100
- return __generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0:
103
- logger_1.default.info('Dictionaries - updateDictionary', { locale: locale });
104
- fs_1.default.mkdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
105
- downloadDictionaryProxy = this.downloadDictionaryProxies[locale];
106
- return [4 /*yield*/, downloadDictionaryProxy()];
107
- case 1:
108
- trie = _a.sent();
109
- return [4 /*yield*/, this.cache.set(locale, trie)];
110
- case 2:
111
- _a.sent();
112
- return [2 /*return*/, trie];
113
- }
114
- });
115
- });
116
- };
117
- return Dictionaries;
118
- }());
28
+ }
29
+ async update(force) {
30
+ const locales = force ? Object.values(types_1.Locale) : this.getLocalesToUpdate();
31
+ logger_1.default.info('Dictionaries - update', { force, locales });
32
+ await Promise.all(locales.map((locale) => this.updateDictionary(locale)));
33
+ }
34
+ getLocalesToUpdate() {
35
+ return Object.values(types_1.Locale).filter((locale) => this.cache.isStale(locale) !== false);
36
+ }
37
+ async updateDictionary(locale) {
38
+ logger_1.default.info('Dictionaries - updateDictionary', { locale });
39
+ fs_1.default.mkdirSync(constants_1.OUTPUT_DIRECTORY, { recursive: true });
40
+ const downloadDictionaryProxy = this.downloadDictionaryProxies[locale];
41
+ const trie = await downloadDictionaryProxy();
42
+ await this.cache.set(locale, trie);
43
+ return trie;
44
+ }
45
+ }
119
46
  exports.default = Dictionaries;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.OUTPUT_DIRECTORY = exports.CACHE_STALE_THRESHOLD = exports.DAY = void 0;
7
- var os_1 = __importDefault(require("os"));
8
- var path_1 = __importDefault(require("path"));
7
+ const os_1 = __importDefault(require("os"));
8
+ const path_1 = __importDefault(require("path"));
9
9
  exports.DAY = 24 * 60 * 60 * 1000;
10
10
  exports.CACHE_STALE_THRESHOLD = 30 * exports.DAY;
11
11
  exports.OUTPUT_DIRECTORY = path_1.default.resolve(os_1.default.homedir(), '.scrabble-solver', 'dictionaries');
@@ -18,6 +18,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.dictionaries = void 0;
21
- var Dictionaries_1 = __importDefault(require("./Dictionaries"));
21
+ const Dictionaries_1 = __importDefault(require("./Dictionaries"));
22
22
  __exportStar(require("./lib"), exports);
23
23
  exports.dictionaries = new Dictionaries_1.default();