scrabble-solver 2.8.2 → 2.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/.eslintrc.js +1 -1
  2. package/.gitattributes +2 -0
  3. package/HISTORY.md +17 -0
  4. package/README.md +8 -26
  5. package/lerna.json +1 -1
  6. package/package.json +13 -13
  7. package/packages/configs/build/getConfig.js +6 -12
  8. package/packages/configs/build/getLocaleConfig.js +2 -2
  9. package/packages/configs/build/isConfigId.js +5 -8
  10. package/packages/configs/build/literaki/bonuses.js +2 -2
  11. package/packages/configs/build/literaki/literaki.js +14 -27
  12. package/packages/configs/build/literaki/tiles/tilesDe.js +1 -1
  13. package/packages/configs/build/literaki/tiles/tilesEn.js +1 -1
  14. package/packages/configs/build/literaki/tiles/tilesEs.js +1 -1
  15. package/packages/configs/build/literaki/tiles/tilesFr.js +1 -1
  16. package/packages/configs/build/literaki/tiles/tilesPl.js +1 -1
  17. package/packages/configs/build/scrabble/bonuses.js +2 -2
  18. package/packages/configs/build/scrabble/scrabble.js +14 -27
  19. package/packages/configs/build/scrabble/tiles/tilesDe.js +1 -1
  20. package/packages/configs/build/scrabble/tiles/tilesEn.js +1 -1
  21. package/packages/configs/build/scrabble/tiles/tilesEs.js +1 -1
  22. package/packages/configs/build/scrabble/tiles/tilesFr.js +1 -1
  23. package/packages/configs/build/scrabble/tiles/tilesPl.js +1 -1
  24. package/packages/configs/package.json +3 -3
  25. package/packages/constants/package.json +1 -1
  26. package/packages/dictionaries/build/Dictionaries.js +37 -110
  27. package/packages/dictionaries/build/constants/index.js +2 -2
  28. package/packages/dictionaries/build/index.js +1 -1
  29. package/packages/dictionaries/build/lib/DiskCache.js +29 -91
  30. package/packages/dictionaries/build/lib/LayeredCache.js +37 -101
  31. package/packages/dictionaries/build/lib/MemoryCache.js +16 -17
  32. package/packages/dictionaries/build/lib/createAsyncProxy.js +14 -58
  33. package/packages/dictionaries/build/lib/createCacheTimestampComparator.js +4 -4
  34. package/packages/dictionaries/build/lib/downloadDictionary.js +10 -54
  35. package/packages/dictionaries/build/lib/getDictionaryFilepath.js +4 -4
  36. package/packages/dictionaries/build/lib/index.d.ts +0 -2
  37. package/packages/dictionaries/build/lib/index.js +1 -5
  38. package/packages/dictionaries/package-lock.json +10 -10
  39. package/packages/dictionaries/package.json +5 -5
  40. package/packages/dictionaries/src/lib/DiskCache.ts +2 -4
  41. package/packages/dictionaries/src/lib/LayeredCache.ts +17 -8
  42. package/packages/dictionaries/src/lib/index.ts +0 -2
  43. package/packages/logger/build/constants.js +2 -2
  44. package/packages/logger/build/logger.js +4 -4
  45. package/packages/logger/package-lock.json +2 -2
  46. package/packages/logger/package.json +1 -1
  47. package/packages/scrabble-solver/.next/BUILD_ID +1 -1
  48. package/packages/scrabble-solver/.next/build-manifest.json +10 -10
  49. package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
  50. package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
  51. package/packages/scrabble-solver/.next/cache/next-server.js.nft.json +1 -1
  52. package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
  53. package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
  54. package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
  55. package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
  56. package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
  57. package/packages/scrabble-solver/.next/prerender-manifest.json +1 -1
  58. package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
  59. package/packages/scrabble-solver/.next/server/chunks/206.js +98 -97
  60. package/packages/scrabble-solver/.next/server/chunks/413.js +396 -677
  61. package/packages/scrabble-solver/.next/server/chunks/515.js +546 -550
  62. package/packages/scrabble-solver/.next/server/chunks/907.js +399 -681
  63. package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
  64. package/packages/scrabble-solver/.next/server/pages/404.html +5 -1
  65. package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +1 -1
  66. package/packages/scrabble-solver/.next/server/pages/500.html +2 -2
  67. package/packages/scrabble-solver/.next/server/pages/_app.js +7 -10
  68. package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
  69. package/packages/scrabble-solver/.next/server/pages/_document.js +0 -3
  70. package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +1 -1
  71. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +114 -171
  72. package/packages/scrabble-solver/.next/server/pages/api/solve.js +426 -1206
  73. package/packages/scrabble-solver/.next/server/pages/index.html +17 -1
  74. package/packages/scrabble-solver/.next/server/pages/index.js +7 -14
  75. package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
  76. package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
  77. package/packages/scrabble-solver/.next/static/-UOLkxdxU0PlKbXa09-xO/_buildManifest.js +1 -0
  78. package/packages/scrabble-solver/.next/static/{nXSSCVI5pGlS_NxEidxkS → -UOLkxdxU0PlKbXa09-xO}/_ssgManifest.js +0 -0
  79. package/packages/scrabble-solver/.next/static/chunks/56-2d34867599a0ac66.js +1 -0
  80. package/packages/scrabble-solver/.next/static/chunks/pages/{404-02d949d2fe59e960.js → 404-30c06e61d256c5b2.js} +1 -1
  81. package/packages/scrabble-solver/.next/static/chunks/pages/_app-6ffa2ab900772b67.js +1 -0
  82. package/packages/scrabble-solver/.next/static/chunks/pages/{index-75517525489ab316.js → index-13ea7770a65c69ee.js} +1 -1
  83. package/packages/scrabble-solver/.next/static/css/{d676d43c6b9c9a57.css → 551d09cac435debb.css} +1 -1
  84. package/packages/scrabble-solver/.next/static/css/{6a9e5ba3f77c27f2.css → cdbc9e0afcff5473.css} +1 -1
  85. package/packages/scrabble-solver/.next/trace +42 -42
  86. package/packages/scrabble-solver/package-lock.json +85 -85
  87. package/packages/scrabble-solver/package.json +13 -13
  88. package/packages/scrabble-solver/src/components/Board/Board.tsx +1 -1
  89. package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +1 -1
  90. package/packages/scrabble-solver/src/components/Board/components/Cell/Button.tsx +1 -1
  91. package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +1 -1
  92. package/packages/scrabble-solver/src/components/Board/components/Cell/CellPure.tsx +1 -1
  93. package/packages/scrabble-solver/src/components/Board/hooks/useGrid.ts +9 -0
  94. package/packages/scrabble-solver/src/components/Button/Button.tsx +1 -1
  95. package/packages/scrabble-solver/src/components/Checkbox/Checkbox.tsx +1 -1
  96. package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +1 -1
  97. package/packages/scrabble-solver/src/components/DictionaryInput/DictionaryInput.tsx +1 -1
  98. package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +1 -1
  99. package/packages/scrabble-solver/src/components/Key/Key.tsx +1 -1
  100. package/packages/scrabble-solver/src/components/KeyMap/KeyMap.tsx +2 -2
  101. package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.module.scss +4 -0
  102. package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.tsx +16 -12
  103. package/packages/scrabble-solver/src/components/Loading/Loading.tsx +1 -1
  104. package/packages/scrabble-solver/src/components/Logo/Logo.tsx +1 -1
  105. package/packages/scrabble-solver/src/components/NavButtons/NavButtons.tsx +1 -1
  106. package/packages/scrabble-solver/src/components/NotFound/NotFound.tsx +1 -1
  107. package/packages/scrabble-solver/src/components/PlainTiles/PlainTiles.tsx +5 -1
  108. package/packages/scrabble-solver/src/components/PlainTiles/Tile.tsx +1 -1
  109. package/packages/scrabble-solver/src/components/Rack/Rack.tsx +1 -1
  110. package/packages/scrabble-solver/src/components/Rack/RackTile.tsx +1 -1
  111. package/packages/scrabble-solver/src/components/Radio/Radio.tsx +1 -1
  112. package/packages/scrabble-solver/src/components/RemainingTiles/Character.tsx +1 -1
  113. package/packages/scrabble-solver/src/components/RemainingTiles/RemainingTiles.tsx +1 -1
  114. package/packages/scrabble-solver/src/components/Results/Cell.tsx +1 -1
  115. package/packages/scrabble-solver/src/components/Results/HeaderButton.tsx +1 -1
  116. package/packages/scrabble-solver/src/components/Results/Result.tsx +1 -1
  117. package/packages/scrabble-solver/src/components/Results/Results.tsx +1 -1
  118. package/packages/scrabble-solver/src/components/Results/SolveButton.tsx +1 -1
  119. package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.tsx +1 -1
  120. package/packages/scrabble-solver/src/components/Screen/Screen.tsx +1 -1
  121. package/packages/scrabble-solver/src/components/Settings/Settings.tsx +1 -1
  122. package/packages/scrabble-solver/src/components/Settings/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -1
  123. package/packages/scrabble-solver/src/components/Settings/components/ConfigSetting/ConfigSetting.tsx +1 -1
  124. package/packages/scrabble-solver/src/components/Settings/components/LocaleSetting/LocaleSetting.tsx +1 -1
  125. package/packages/scrabble-solver/src/components/Sidebar/Sidebar.tsx +1 -1
  126. package/packages/scrabble-solver/src/components/Sidebar/components/Section/Section.tsx +1 -1
  127. package/packages/scrabble-solver/src/components/Splash/Splash.tsx +1 -1
  128. package/packages/scrabble-solver/src/components/SquareButton/Link.tsx +1 -1
  129. package/packages/scrabble-solver/src/components/SquareButton/SquareButton.tsx +1 -1
  130. package/packages/scrabble-solver/src/components/SvgFontCss/SvgFontCss.tsx +12 -0
  131. package/packages/scrabble-solver/src/components/SvgFontCss/index.ts +1 -0
  132. package/packages/scrabble-solver/src/components/Tile/Tile.tsx +1 -1
  133. package/packages/scrabble-solver/src/components/Tile/TilePure.tsx +2 -2
  134. package/packages/scrabble-solver/src/components/Tooltip/useTooltip.tsx +1 -1
  135. package/packages/scrabble-solver/src/components/Well/Well.tsx +1 -1
  136. package/packages/scrabble-solver/src/components/index.ts +1 -0
  137. package/packages/scrabble-solver/src/hooks/usePortal.tsx +19 -9
  138. package/packages/scrabble-solver/src/lib/createKeyboardNavigation.ts +3 -0
  139. package/packages/scrabble-solver/src/lib/memoize.ts +1 -1
  140. package/packages/scrabble-solver/src/pages/_app.tsx +1 -1
  141. package/packages/scrabble-solver/src/pages/_document.tsx +1 -1
  142. package/packages/scrabble-solver/src/pages/index.tsx +6 -15
  143. package/packages/scrabble-solver/src/styles/global.scss +3 -0
  144. package/packages/solver/build/PatternsFiller.js +38 -72
  145. package/packages/solver/build/PatternsGenerator.js +43 -72
  146. package/packages/solver/build/ScoresCalculator.js +20 -24
  147. package/packages/solver/build/Solver.js +19 -24
  148. package/packages/solver/package-lock.json +17 -17
  149. package/packages/solver/package.json +7 -7
  150. package/packages/solver/src/PatternsFiller.ts +5 -10
  151. package/packages/solver/src/PatternsGenerator.ts +17 -16
  152. package/packages/solver/src/Solver.ts +4 -8
  153. package/packages/types/build/Board.js +68 -85
  154. package/packages/types/build/Bonus.js +15 -21
  155. package/packages/types/build/Cell.js +31 -33
  156. package/packages/types/build/CharacterBonus.js +18 -40
  157. package/packages/types/build/Config.js +62 -117
  158. package/packages/types/build/HorizontalPattern.js +17 -63
  159. package/packages/types/build/Pattern.js +37 -41
  160. package/packages/types/build/Result.js +23 -46
  161. package/packages/types/build/Tile.js +22 -24
  162. package/packages/types/build/VerticalPattern.js +17 -63
  163. package/packages/types/build/WordBonus.js +13 -35
  164. package/packages/types/build/WordDefinition.js +13 -15
  165. package/packages/types/package.json +2 -2
  166. package/packages/types/src/Cell.ts +1 -1
  167. package/packages/types/src/Pattern.ts +1 -1
  168. package/packages/word-definitions/build/crawl/crawl.js +15 -16
  169. package/packages/word-definitions/build/crawl/crawlEnglish.js +3 -3
  170. package/packages/word-definitions/build/crawl/crawlFrench.js +3 -3
  171. package/packages/word-definitions/build/crawl/crawlGerman.js +3 -3
  172. package/packages/word-definitions/build/crawl/crawlPolish.js +3 -3
  173. package/packages/word-definitions/build/crawl/crawlSpanish.js +3 -3
  174. package/packages/word-definitions/build/getWordDefinition.js +9 -52
  175. package/packages/word-definitions/build/lib/normalizeDefinition.js +15 -15
  176. package/packages/word-definitions/build/lib/request.js +8 -20
  177. package/packages/word-definitions/build/lib/unique.js +1 -1
  178. package/packages/word-definitions/build/parse/parse.js +18 -19
  179. package/packages/word-definitions/build/parse/parseEnglish.js +5 -5
  180. package/packages/word-definitions/build/parse/parseFrench.js +5 -5
  181. package/packages/word-definitions/build/parse/parseGerman.js +6 -6
  182. package/packages/word-definitions/build/parse/parsePolish.js +6 -6
  183. package/packages/word-definitions/build/parse/parseSpanish.js +9 -9
  184. package/packages/word-definitions/package-lock.json +8 -8
  185. package/packages/word-definitions/package.json +2 -2
  186. package/packages/word-lists/build/getDeDeWordList.js +5 -43
  187. package/packages/word-lists/build/getEnGbWordList.js +5 -43
  188. package/packages/word-lists/build/getEnUsWordList.js +5 -43
  189. package/packages/word-lists/build/getEsEsWordList.js +7 -50
  190. package/packages/word-lists/build/getFrFrWordList.js +9 -50
  191. package/packages/word-lists/build/getPlPlWordList.js +33 -91
  192. package/packages/word-lists/build/getWordList.js +16 -17
  193. package/packages/word-lists/build/lib/downloadFile.d.ts +1 -2
  194. package/packages/word-lists/build/lib/downloadFile.js +28 -10
  195. package/packages/word-lists/build/lib/downloadHtml.js +8 -8
  196. package/packages/word-lists/build/lib/extractWords.js +5 -5
  197. package/packages/word-lists/build/lib/findFirstWordIndex.js +6 -6
  198. package/packages/word-lists/build/lib/getHash.js +2 -5
  199. package/packages/word-lists/build/lib/getTempFilename.js +3 -3
  200. package/packages/word-lists/build/lib/getTxtWordList.js +10 -56
  201. package/packages/word-lists/package-lock.json +2 -2
  202. package/packages/word-lists/package.json +2 -2
  203. package/packages/word-lists/src/getFrFrWordList.ts +1 -0
  204. package/packages/word-lists/src/getPlPlWordList.ts +2 -3
  205. package/packages/word-lists/src/lib/downloadFile.ts +25 -7
  206. package/packages/word-lists/src/lib/getTxtWordList.ts +2 -4
  207. package/tsconfig.json +1 -1
  208. package/packages/dictionaries/build/lib/readFile.d.ts +0 -2
  209. package/packages/dictionaries/build/lib/readFile.js +0 -57
  210. package/packages/dictionaries/build/lib/writeFile.d.ts +0 -2
  211. package/packages/dictionaries/build/lib/writeFile.js +0 -57
  212. package/packages/dictionaries/src/lib/readFile.ts +0 -15
  213. package/packages/dictionaries/src/lib/writeFile.ts +0 -15
  214. package/packages/scrabble-solver/.next/static/chunks/195-fcadef5c6eed8338.js +0 -1
  215. package/packages/scrabble-solver/.next/static/chunks/pages/_app-f4030148d742bcd2.js +0 -1
  216. package/packages/scrabble-solver/.next/static/nXSSCVI5pGlS_NxEidxkS/_buildManifest.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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ packages/word-definitions/src/parse/__tests__/expected/** linguist-vendored
2
+ packages/word-definitions/src/parse/__tests__/input/** linguist-vendored
package/HISTORY.md ADDED
@@ -0,0 +1,17 @@
1
+ # History
2
+
3
+ Back in January 2012 I wrote 200 lines of C++ code to load up a dictionary, store it in a Trie structure, read up to 7 letters from console input and traverse the Trie structure to find all the words that could be created from provided letters. I did it for 200 PLN (about 60 USD back then) and it was my first money earned by programming (assuming that beer is not a currency).
4
+
5
+ I enjoyed working on it and wanted to enhance that with some visuals to take it to the next level. So I created a simple Windows Forms project in C#, added support for "blank" characters & displayed the results grouped by word length. And I left it like that.
6
+
7
+ Some time later I got familiar with WPF and somehow I got the idea it would be fun to enhance the C# solver with a visual board input. This would provide solver with information which would allow to find a move that will give you the most points. So in September 2014 I started working on a new C# WPF project, but I haven't got far with it.
8
+
9
+ After getting experienced with JavaScript, I decided to tackle the challenge once again. I started a new project in February 2017. React on the front, node.js in the back. On September 13th 2017, five and a half years since the beginning, `scrabble-solver@1.0.0` was released. And I saw it was good.
10
+
11
+ It got to `1.4.0` - I have added en-US & en-GB locales support, a mini tutorial and kept the dependencies up to date (e.g. upgraded React from 15 to 16).
12
+
13
+ Frontend development has changed, I've learned a few things - it was time for `scrabble-solver@2.0.0`. In 2019 I started to work on a new version. But due to many distractions the work took around 2 years to complete. Nevertheless, here it is, a shiny, state-of-the-art frontend app, January 2021 - 9 years after the first project.
14
+
15
+ ## Scrabble Solver 1
16
+
17
+ A piece of history, available at http://scrabble-solver-v1.kamilmielnik.com/.
package/README.md CHANGED
@@ -56,14 +56,14 @@ rm -rf $HOME/.scrabble-solver
56
56
 
57
57
  ## Dictionaries
58
58
 
59
- | Language | Locale | Word list | Word list (source) | Word definitions |
60
- |--------------|--------|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------|
61
- | 🇬🇧 English | en-GB | [SOWPODS](https://en.wikipedia.org/wiki/Collins_Scrabble_Words) | [download](https://www.wordgamedictionary.com/sowpods/download/sowpods.txt) | [Merriam-Webster](https://www.merriam-webster.com/) |
62
- | 🇺🇸 English | en-US | [TWL06](https://en.wikipedia.org/wiki/NASPA_Word_List) | [download](https://www.wordgamedictionary.com/twl06/download/twl06.txt) | [Merriam-Webster](https://www.merriam-webster.com/) |
63
- | 🇫🇷 French | fr-FR | [hbenbel/French-Dictionary](https://github.com/hbenbel/French-Dictionary/) | [download](https://raw.githubusercontent.com/hbenbel/French-Dictionary/master/dictionary/dictionary.txt) | [Centre National de Ressources Textuelles et Lexicales](https://www.cnrtl.fr/) |
64
- | 🇩🇪 German | de-DE | [HanSolo80/German-Dictionary](https://github.com/HanSolo80/German-Dictionary) | [download](https://raw.githubusercontent.com/HanSolo80/German-Dictionary/master/dictionary.txt) | [DWDS](https://www.dwds.de) |
65
- | 🇵🇱 Polish | pl-PL | [SJP.PL](https://sjp.pl/slownik/dp.phtml) | [download](https://sjp.pl/slownik/growy/) | [SJP.PL](https://sjp.pl) |
66
- | 🇪🇸 Spanish | es-ES | [FISE-2](https://fisescrabble.org/) | [download](https://github.com/kamilmielnik/fise-2/blob/master/fise-2.txt) | [Diccionarios.com](www.diccionarios.com) |
59
+ | Language | Word list | Word list | Word definitions |
60
+ |------------|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------|
61
+ | 🇬🇧 English | [SOWPODS](https://en.wikipedia.org/wiki/Collins_Scrabble_Words) | [Source](https://www.wordgamedictionary.com/sowpods/download/sowpods.txt) | [Merriam-Webster](https://www.merriam-webster.com/) |
62
+ | 🇺🇸 English | [TWL06](https://en.wikipedia.org/wiki/NASPA_Word_List) | [Source](https://www.wordgamedictionary.com/twl06/download/twl06.txt) | [Merriam-Webster](https://www.merriam-webster.com/) |
63
+ | 🇫🇷 French | [hbenbel/French-Dictionary](https://github.com/hbenbel/French-Dictionary/) | [Source](https://raw.githubusercontent.com/hbenbel/French-Dictionary/a573eab10cc798d7d5da7daab4d2ac0259bb46a3/dictionary/dictionary.txt) | [CNRTL](https://www.cnrtl.fr/) |
64
+ | 🇩🇪 German | [HanSolo80/German-Dictionary](https://github.com/HanSolo80/German-Dictionary) | [Source](https://raw.githubusercontent.com/HanSolo80/German-Dictionary/master/dictionary.txt) | [DWDS](https://www.dwds.de) |
65
+ | 🇵🇱 Polish | [SJP.PL](https://sjp.pl/slownik/dp.phtml) | [Source](https://sjp.pl/slownik/growy/) | [SJP.PL](https://sjp.pl) |
66
+ | 🇪🇸 Spanish | [FISE-2](https://fisescrabble.org/) | [Source](https://github.com/kamilmielnik/fise-2/blob/master/fise-2.txt) | [Diccionarios.com](https://www.diccionarios.com/) |
67
67
 
68
68
  ## Tech stack
69
69
 
@@ -77,21 +77,3 @@ rm -rf $HOME/.scrabble-solver
77
77
  - [Jest](https://jestjs.io/)
78
78
  - [ESLint](https://eslint.org/)
79
79
  - [Prettier](https://prettier.io/)
80
-
81
- ## History
82
-
83
- Back in January 2012 I wrote 200 lines of C++ code to load up a dictionary, store it in a Trie structure, read up to 7 letters from console input and traverse the Trie structure to find all the words that could be created from provided letters. I did it for 200 PLN (about 60 USD back then) and it was my first money earned by programming (assuming that beer is not a currency).
84
-
85
- I enjoyed working on it and wanted to enhance that with some visuals to take it to the next level. So I created a simple Windows Forms project in C#, added support for "blank" characters & displayed the results grouped by word length. And I left it like that.
86
-
87
- Some time later I got familiar with WPF and somehow I got the idea it would be fun to enhance the C# solver with a visual board input. This would provide solver with information which would allow to find a move that will give you the most points. So in September 2014 I started working on a new C# WPF project, but I haven't got far with it.
88
-
89
- After getting experienced with JavaScript, I decided to tackle the challenge once again. I started a new project in February 2017. React on the front, node.js in the back. On September 13th 2017, five and a half years since the beginning, `scrabble-solver@1.0.0` was released. And I saw it was good.
90
-
91
- It got to `1.4.0` - I have added en-US & en-GB locales support, a mini tutorial and kept the dependencies up to date (e.g. upgraded React from 15 to 16).
92
-
93
- Frontend development has changed, I've learned a few things - it was time for `scrabble-solver@2.0.0`. In 2019 I started to work on a new version. But due to many distractions the work took around 2 years to complete. Nevertheless, here it is, a shiny, state-of-the-art frontend app, January 2021 - 9 years after the first project.
94
-
95
- ### Scrabble Solver 1
96
-
97
- A piece of history, available at http://scrabble-solver-v1.kamilmielnik.com/.
package/lerna.json CHANGED
@@ -6,5 +6,5 @@
6
6
  "access": "public"
7
7
  },
8
8
  "tagVersionPrefix": "",
9
- "version": "2.8.2"
9
+ "version": "2.8.4"
10
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scrabble-solver",
3
- "version": "2.8.2",
3
+ "version": "2.8.4",
4
4
  "description": "Scrabble Solver 2 - The ultimate, open-source cheating app for Scrabble and Literaki",
5
5
  "keywords": [
6
6
  "Scrabble",
@@ -25,7 +25,7 @@
25
25
  "App"
26
26
  ],
27
27
  "engines": {
28
- "node": ">=16.0.0"
28
+ "node": ">=16"
29
29
  },
30
30
  "bin": {
31
31
  "scrabble-solver": "./bin/scrabble-solver.js"
@@ -74,31 +74,31 @@
74
74
  },
75
75
  "homepage": "https://github.com/kamilmielnik/scrabble-solver#readme",
76
76
  "dependencies": {
77
- "lerna": "^5.5.2",
77
+ "lerna": "^5.5.4",
78
78
  "npm-run-all": "^4.1.5",
79
79
  "open-cli": "^7.0.1"
80
80
  },
81
81
  "devDependencies": {
82
- "@babel/core": "^7.19.1",
82
+ "@babel/core": "^7.19.3",
83
83
  "@babel/plugin-proposal-class-properties": "^7.18.6",
84
- "@babel/preset-env": "^7.19.1",
85
- "@types/jest": "^29.0.3",
86
- "@types/node": "^18.7.18",
87
- "@typescript-eslint/eslint-plugin": "^5.38.0",
88
- "@typescript-eslint/parser": "^5.38.0",
84
+ "@babel/preset-env": "^7.19.3",
85
+ "@types/jest": "^29.1.1",
86
+ "@types/node": "^18.7.23",
87
+ "@typescript-eslint/eslint-plugin": "^5.38.1",
88
+ "@typescript-eslint/parser": "^5.38.1",
89
89
  "babel-eslint": "10.1.0",
90
- "eslint": "^8.23.1",
90
+ "eslint": "^8.24.0",
91
91
  "eslint-config-prettier": "^8.5.0",
92
92
  "eslint-import-resolver-node": "^0.3.6",
93
93
  "eslint-plugin-import": "^2.26.0",
94
94
  "eslint-plugin-prettier": "^4.2.1",
95
95
  "eslint-plugin-react": "^7.31.8",
96
96
  "eslint-plugin-react-hooks": "^4.6.0",
97
- "jest": "29.0.3",
97
+ "jest": "29.1.2",
98
98
  "np": "^7.6.2",
99
99
  "prettier": "^2.7.1",
100
100
  "rimraf": "^3.0.2",
101
- "ts-jest": "^29.0.1",
102
- "typescript": "^4.8.3"
101
+ "ts-jest": "^29.0.3",
102
+ "typescript": "^4.8.4"
103
103
  }
104
104
  }
@@ -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.2",
3
+ "version": "2.8.4",
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.2",
28
- "@scrabble-solver/types": "^2.8.2"
27
+ "@scrabble-solver/constants": "^2.8.4",
28
+ "@scrabble-solver/types": "^2.8.4"
29
29
  },
30
30
  "gitHead": "1e2d1ad49a288d4a44196d8e3336740da132c637"
31
31
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/constants",
3
- "version": "2.8.2",
3
+ "version": "2.8.4",
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;