scrabble-solver 2.13.4 → 2.13.5-alpha.1

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 (384) hide show
  1. package/.gitattributes +2 -2
  2. package/.nx/cache/file-map.json +1297 -1313
  3. package/.nx/cache/lockfile.hash +1 -1
  4. package/.nx/cache/nx_files.nxt +0 -0
  5. package/.nx/cache/project-graph.json +5 -5
  6. package/README.md +23 -8
  7. package/lerna.json +1 -1
  8. package/package.json +7 -9
  9. package/packages/configs/build/getConfig.d.ts +1 -2
  10. package/packages/configs/build/getConfig.js +4 -3
  11. package/packages/configs/build/hasConfig.d.ts +1 -2
  12. package/packages/configs/build/hasConfig.js +4 -3
  13. package/packages/configs/build/index.d.ts +4 -7
  14. package/packages/configs/build/index.js +5 -10
  15. package/packages/configs/build/languages/english.d.ts +7 -0
  16. package/packages/configs/build/languages/english.js +199 -0
  17. package/packages/configs/build/languages/french.d.ts +2 -0
  18. package/packages/configs/build/languages/french.js +37 -0
  19. package/packages/configs/build/languages/german.d.ts +2 -0
  20. package/packages/configs/build/languages/german.js +40 -0
  21. package/packages/configs/build/languages/index.d.ts +7 -0
  22. package/packages/configs/build/languages/index.js +23 -0
  23. package/packages/configs/build/languages/persian.d.ts +2 -0
  24. package/packages/configs/build/languages/persian.js +43 -0
  25. package/packages/configs/build/languages/polish.d.ts +3 -0
  26. package/packages/configs/build/languages/polish.js +81 -0
  27. package/packages/configs/build/languages/romanian.d.ts +2 -0
  28. package/packages/configs/build/languages/romanian.js +36 -0
  29. package/packages/configs/build/languages/spanish.d.ts +2 -0
  30. package/packages/configs/build/languages/spanish.js +39 -0
  31. package/packages/configs/package.json +3 -3
  32. package/packages/configs/src/games/superScrabble.ts +2 -2
  33. package/packages/configs/src/getConfig.ts +3 -5
  34. package/packages/configs/src/hasConfig.ts +3 -5
  35. package/packages/configs/src/index.ts +4 -6
  36. package/packages/configs/src/languages/english.ts +203 -0
  37. package/packages/configs/src/languages/french.ts +36 -0
  38. package/packages/configs/src/languages/german.ts +39 -0
  39. package/packages/configs/src/languages/index.ts +7 -0
  40. package/packages/configs/src/languages/persian.ts +42 -0
  41. package/packages/configs/src/languages/polish.ts +81 -0
  42. package/packages/configs/src/languages/romanian.ts +35 -0
  43. package/packages/configs/src/languages/spanish.ts +38 -0
  44. package/packages/constants/package.json +1 -1
  45. package/packages/dictionaries/package-lock.json +2 -2
  46. package/packages/dictionaries/package.json +4 -4
  47. package/packages/logger/package-lock.json +2 -2
  48. package/packages/logger/package.json +1 -1
  49. package/packages/scrabble-solver/.next/build-manifest.json +15 -24
  50. package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
  51. package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
  52. package/packages/scrabble-solver/.next/cache/webpack/client-development/0.pack.gz +0 -0
  53. package/packages/scrabble-solver/.next/cache/webpack/client-development/1.pack.gz +0 -0
  54. package/packages/scrabble-solver/.next/cache/webpack/client-development/10.pack.gz +0 -0
  55. package/packages/scrabble-solver/.next/cache/webpack/client-development/11.pack.gz +0 -0
  56. package/packages/scrabble-solver/.next/cache/webpack/client-development/12.pack.gz +0 -0
  57. package/packages/scrabble-solver/.next/cache/webpack/client-development/13.pack.gz +0 -0
  58. package/packages/scrabble-solver/.next/cache/webpack/client-development/14.pack.gz +0 -0
  59. package/packages/scrabble-solver/.next/cache/webpack/client-development/15.pack.gz +0 -0
  60. package/packages/scrabble-solver/.next/cache/webpack/client-development/2.pack.gz +0 -0
  61. package/packages/scrabble-solver/.next/cache/webpack/client-development/3.pack.gz +0 -0
  62. package/packages/scrabble-solver/.next/cache/webpack/client-development/4.pack.gz +0 -0
  63. package/packages/scrabble-solver/.next/cache/webpack/client-development/5.pack.gz +0 -0
  64. package/packages/scrabble-solver/.next/cache/webpack/client-development/6.pack.gz +0 -0
  65. package/packages/scrabble-solver/.next/cache/webpack/client-development/7.pack.gz +0 -0
  66. package/packages/scrabble-solver/.next/cache/webpack/client-development/8.pack.gz +0 -0
  67. package/packages/scrabble-solver/.next/cache/webpack/client-development/9.pack.gz +0 -0
  68. package/packages/scrabble-solver/.next/cache/webpack/client-development/index.pack.gz +0 -0
  69. package/packages/scrabble-solver/.next/cache/webpack/client-development/index.pack.gz.old +0 -0
  70. package/packages/scrabble-solver/.next/cache/webpack/client-development-fallback/0.pack.gz +0 -0
  71. package/packages/scrabble-solver/.next/cache/webpack/client-development-fallback/index.pack.gz +0 -0
  72. package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
  73. package/packages/scrabble-solver/.next/cache/webpack/client-production/1.pack +0 -0
  74. package/packages/scrabble-solver/.next/cache/webpack/client-production/2.pack +0 -0
  75. package/packages/scrabble-solver/.next/cache/webpack/client-production/3.pack +0 -0
  76. package/packages/scrabble-solver/.next/cache/webpack/client-production/4.pack +0 -0
  77. package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
  78. package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack.old +0 -0
  79. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/0.pack +0 -0
  80. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/1.pack +0 -0
  81. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/2.pack +0 -0
  82. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack +0 -0
  83. package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
  84. package/packages/scrabble-solver/.next/cache/webpack/server-development/0.pack.gz +0 -0
  85. package/packages/scrabble-solver/.next/cache/webpack/server-development/1.pack.gz +0 -0
  86. package/packages/scrabble-solver/.next/cache/webpack/server-development/10.pack.gz +0 -0
  87. package/packages/scrabble-solver/.next/cache/webpack/server-development/11.pack.gz +0 -0
  88. package/packages/scrabble-solver/.next/cache/webpack/server-development/12.pack.gz +0 -0
  89. package/packages/scrabble-solver/.next/cache/webpack/server-development/13.pack.gz +0 -0
  90. package/packages/scrabble-solver/.next/cache/webpack/server-development/14.pack.gz +0 -0
  91. package/packages/scrabble-solver/.next/cache/webpack/server-development/15.pack.gz +0 -0
  92. package/packages/scrabble-solver/.next/cache/webpack/server-development/16.pack.gz +0 -0
  93. package/packages/scrabble-solver/.next/cache/webpack/server-development/17.pack.gz +0 -0
  94. package/packages/scrabble-solver/.next/cache/webpack/server-development/18.pack.gz +0 -0
  95. package/packages/scrabble-solver/.next/cache/webpack/server-development/19.pack.gz +0 -0
  96. package/packages/scrabble-solver/.next/cache/webpack/server-development/2.pack.gz +0 -0
  97. package/packages/scrabble-solver/.next/cache/webpack/server-development/20.pack.gz +0 -0
  98. package/packages/scrabble-solver/.next/cache/webpack/server-development/21.pack.gz +0 -0
  99. package/packages/scrabble-solver/.next/cache/webpack/server-development/22.pack.gz +0 -0
  100. package/packages/scrabble-solver/.next/cache/webpack/server-development/23.pack.gz +0 -0
  101. package/packages/scrabble-solver/.next/cache/webpack/server-development/3.pack.gz +0 -0
  102. package/packages/scrabble-solver/.next/cache/webpack/server-development/4.pack.gz +0 -0
  103. package/packages/scrabble-solver/.next/cache/webpack/server-development/5.pack.gz +0 -0
  104. package/packages/scrabble-solver/.next/cache/webpack/server-development/6.pack.gz +0 -0
  105. package/packages/scrabble-solver/.next/cache/webpack/server-development/7.pack.gz +0 -0
  106. package/packages/scrabble-solver/.next/cache/webpack/server-development/8.pack.gz +0 -0
  107. package/packages/scrabble-solver/.next/cache/webpack/server-development/9.pack.gz +0 -0
  108. package/packages/scrabble-solver/.next/cache/webpack/server-development/index.pack.gz +0 -0
  109. package/packages/scrabble-solver/.next/cache/webpack/server-development/index.pack.gz.old +0 -0
  110. package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
  111. package/packages/scrabble-solver/.next/cache/webpack/server-production/1.pack +0 -0
  112. package/packages/scrabble-solver/.next/cache/webpack/server-production/2.pack +0 -0
  113. package/packages/scrabble-solver/.next/cache/webpack/server-production/3.pack +0 -0
  114. package/packages/scrabble-solver/.next/cache/webpack/server-production/4.pack +0 -0
  115. package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
  116. package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack.old +0 -0
  117. package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
  118. package/packages/scrabble-solver/.next/server/middleware-react-loadable-manifest.js +1 -1
  119. package/packages/scrabble-solver/.next/server/next-font-manifest.js +1 -1
  120. package/packages/scrabble-solver/.next/server/pages/_app.js +3720 -1
  121. package/packages/scrabble-solver/.next/server/pages/_document.js +86 -1
  122. package/packages/scrabble-solver/.next/server/pages/_error.js +3742 -1
  123. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +1116 -2
  124. package/packages/scrabble-solver/.next/server/pages/api/solve.js +1496 -1
  125. package/packages/scrabble-solver/.next/server/pages/api/verify.js +946 -1
  126. package/packages/scrabble-solver/.next/server/pages/api/visit.js +176 -1
  127. package/packages/scrabble-solver/.next/server/pages/index.js +4312 -1
  128. package/packages/scrabble-solver/.next/server/pages-manifest.json +10 -1
  129. package/packages/scrabble-solver/.next/server/vendor-chunks/@swc.js +35 -0
  130. package/packages/scrabble-solver/.next/server/vendor-chunks/next.js +517 -0
  131. package/packages/scrabble-solver/.next/server/webpack-api-runtime.js +168 -1
  132. package/packages/scrabble-solver/.next/server/webpack-runtime.js +237 -1
  133. package/packages/scrabble-solver/.next/static/chunks/main.js +1285 -0
  134. package/packages/scrabble-solver/.next/static/chunks/pages/_app.js +4854 -0
  135. package/packages/scrabble-solver/.next/static/chunks/pages/_error.js +28 -0
  136. package/packages/scrabble-solver/.next/static/chunks/pages/index.js +717 -0
  137. package/packages/scrabble-solver/.next/static/chunks/react-refresh.js +62 -0
  138. package/packages/scrabble-solver/.next/static/chunks/webpack.js +1261 -0
  139. package/packages/scrabble-solver/.next/static/development/_buildManifest.js +1 -0
  140. package/packages/scrabble-solver/.next/static/development/_ssgManifest.js +1 -0
  141. package/packages/scrabble-solver/.next/static/webpack/29a2bd94727d51e6.webpack.hot-update.json +1 -0
  142. package/packages/scrabble-solver/.next/static/webpack/3754455b7d774808.webpack.hot-update.json +1 -0
  143. package/packages/scrabble-solver/.next/static/webpack/633457081244afec._.hot-update.json +1 -0
  144. package/packages/scrabble-solver/.next/static/webpack/b71388f846dd4d8b.webpack.hot-update.json +1 -0
  145. package/packages/scrabble-solver/.next/static/webpack/e7718e8f7cbe05a0.webpack.hot-update.json +1 -0
  146. package/packages/scrabble-solver/.next/static/webpack/pages/_app.29a2bd94727d51e6.hot-update.js +22 -0
  147. package/packages/scrabble-solver/.next/static/webpack/pages/_app.3754455b7d774808.hot-update.js +262 -0
  148. package/packages/scrabble-solver/.next/static/webpack/pages/_app.e7718e8f7cbe05a0.hot-update.js +251 -0
  149. package/packages/scrabble-solver/.next/static/webpack/pages/index.3754455b7d774808.hot-update.js +75 -0
  150. package/packages/scrabble-solver/.next/static/webpack/pages/index.b71388f846dd4d8b.hot-update.js +22 -0
  151. package/packages/scrabble-solver/.next/static/webpack/pages/index.e7718e8f7cbe05a0.hot-update.js +32 -0
  152. package/packages/scrabble-solver/.next/static/webpack/webpack.29a2bd94727d51e6.hot-update.js +18 -0
  153. package/packages/scrabble-solver/.next/static/webpack/webpack.3754455b7d774808.hot-update.js +18 -0
  154. package/packages/scrabble-solver/.next/static/webpack/webpack.b71388f846dd4d8b.hot-update.js +18 -0
  155. package/packages/scrabble-solver/.next/static/webpack/webpack.e7718e8f7cbe05a0.hot-update.js +18 -0
  156. package/packages/scrabble-solver/.next/trace +17 -44
  157. package/packages/scrabble-solver/package-lock.json +2 -3
  158. package/packages/scrabble-solver/package.json +9 -9
  159. package/packages/scrabble-solver/public/service-worker.js +2 -2
  160. package/packages/scrabble-solver/public/service-worker.js.map +1 -1
  161. package/packages/scrabble-solver/src/components/Board/Board.module.scss +14 -0
  162. package/packages/scrabble-solver/src/components/Board/Board.tsx +8 -1
  163. package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +76 -21
  164. package/packages/scrabble-solver/src/components/Board/hooks/useBackgroundImage.tsx +46 -7
  165. package/packages/scrabble-solver/src/components/Board/hooks/useBoardStyle.ts +8 -3
  166. package/packages/scrabble-solver/src/components/Board/lib/getCoordinate.ts +11 -0
  167. package/packages/scrabble-solver/src/components/Board/lib/index.ts +1 -0
  168. package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +17 -18
  169. package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +1 -1
  170. package/packages/scrabble-solver/src/components/Results/Results.module.scss +1 -0
  171. package/packages/scrabble-solver/src/hooks/useAppLayout.ts +18 -4
  172. package/packages/scrabble-solver/src/i18n/i18n.ts +15 -15
  173. package/packages/scrabble-solver/src/i18n/{en.json → languages/english.json} +4 -0
  174. package/packages/scrabble-solver/src/i18n/{fr.json → languages/french.json} +4 -0
  175. package/packages/scrabble-solver/src/i18n/{de.json → languages/german.json} +4 -0
  176. package/packages/scrabble-solver/src/i18n/{fa.json → languages/persian.json} +4 -0
  177. package/packages/scrabble-solver/src/i18n/{pl.json → languages/polish.json} +4 -0
  178. package/packages/scrabble-solver/src/i18n/{ro.json → languages/romanian.json} +4 -0
  179. package/packages/scrabble-solver/src/i18n/{es.json → languages/spanish.json} +4 -0
  180. package/packages/scrabble-solver/src/lib/extractCharacters.test.ts +3 -5
  181. package/packages/scrabble-solver/src/lib/extractCharactersByCase.test.ts +3 -5
  182. package/packages/scrabble-solver/src/modals/SettingsModal/SettingsModal.tsx +11 -1
  183. package/packages/scrabble-solver/src/modals/SettingsModal/components/ShowCoordinatesSetting/ShowCoordinatesSetting.module.scss +12 -0
  184. package/packages/scrabble-solver/src/modals/SettingsModal/components/ShowCoordinatesSetting/ShowCoordinatesSetting.tsx +59 -0
  185. package/packages/scrabble-solver/src/modals/SettingsModal/components/ShowCoordinatesSetting/index.ts +1 -0
  186. package/packages/scrabble-solver/src/modals/SettingsModal/components/index.ts +1 -0
  187. package/packages/scrabble-solver/src/parameters/index.ts +1 -0
  188. package/packages/scrabble-solver/src/state/localStorage.ts +10 -1
  189. package/packages/scrabble-solver/src/state/sagas.ts +6 -3
  190. package/packages/scrabble-solver/src/state/selectors.ts +2 -0
  191. package/packages/scrabble-solver/src/state/slices/settingsInitialState.ts +6 -4
  192. package/packages/scrabble-solver/src/state/slices/settingsSlice.ts +6 -1
  193. package/packages/scrabble-solver/src/state/store.ts +1 -1
  194. package/packages/scrabble-solver/src/styles/mixins.scss +9 -2
  195. package/packages/scrabble-solver/src/types/index.ts +4 -0
  196. package/packages/scrabble-solver/tsconfig.json +1 -0
  197. package/packages/solver/package-lock.json +2 -2
  198. package/packages/solver/package.json +5 -5
  199. package/packages/types/build/ShowCoordinates.d.ts +7 -0
  200. package/packages/types/build/ShowCoordinates.js +2 -0
  201. package/packages/types/build/index.d.ts +1 -0
  202. package/packages/types/package.json +2 -2
  203. package/packages/types/src/ShowCoordinates.ts +8 -0
  204. package/packages/types/src/index.ts +1 -0
  205. package/packages/word-definitions/build/crawl.d.ts +2 -0
  206. package/packages/word-definitions/build/crawl.js +19 -0
  207. package/packages/word-definitions/build/getWordDefinition.d.ts +1 -2
  208. package/packages/word-definitions/build/getWordDefinition.js +2 -1
  209. package/packages/word-definitions/build/index.d.ts +2 -1
  210. package/packages/word-definitions/build/index.js +2 -4
  211. package/packages/word-definitions/build/languages/english.d.ts +3 -0
  212. package/packages/word-definitions/build/languages/english.js +28 -0
  213. package/packages/word-definitions/build/languages/french.d.ts +3 -0
  214. package/packages/word-definitions/build/languages/french.js +22 -0
  215. package/packages/word-definitions/build/languages/german.d.ts +3 -0
  216. package/packages/word-definitions/build/languages/german.js +70 -0
  217. package/packages/word-definitions/build/languages/index.d.ts +7 -0
  218. package/packages/word-definitions/build/languages/index.js +33 -0
  219. package/packages/word-definitions/build/languages/persian.d.ts +3 -0
  220. package/packages/word-definitions/build/languages/persian.js +23 -0
  221. package/packages/word-definitions/build/languages/polish.d.ts +3 -0
  222. package/packages/word-definitions/build/languages/polish.js +24 -0
  223. package/packages/word-definitions/build/languages/romanian.d.ts +3 -0
  224. package/packages/word-definitions/build/languages/romanian.js +26 -0
  225. package/packages/word-definitions/build/languages/spanish.d.ts +3 -0
  226. package/packages/word-definitions/build/languages/spanish.js +39 -0
  227. package/packages/word-definitions/build/lib/index.d.ts +3 -3
  228. package/packages/word-definitions/build/lib/index.js +3 -6
  229. package/packages/word-definitions/build/lib/normalizeDefinition.d.ts +1 -2
  230. package/packages/word-definitions/build/lib/normalizeDefinition.js +3 -2
  231. package/packages/word-definitions/build/lib/request.d.ts +2 -2
  232. package/packages/word-definitions/build/lib/request.js +2 -1
  233. package/packages/word-definitions/build/lib/unique.d.ts +1 -2
  234. package/packages/word-definitions/build/lib/unique.js +2 -1
  235. package/packages/word-definitions/build/parse.d.ts +3 -0
  236. package/packages/word-definitions/build/parse.js +24 -0
  237. package/packages/word-definitions/build/types.d.ts +1 -1
  238. package/packages/word-definitions/package-lock.json +2 -2
  239. package/packages/word-definitions/package.json +2 -2
  240. package/packages/word-definitions/src/crawl.ts +18 -0
  241. package/packages/word-definitions/src/getWordDefinition.ts +1 -3
  242. package/packages/word-definitions/src/index.ts +2 -1
  243. package/packages/word-definitions/src/{parse/parseEnglish.ts → languages/english.ts} +11 -4
  244. package/packages/word-definitions/src/languages/french.ts +22 -0
  245. package/packages/word-definitions/src/{parse/parseGerman.ts → languages/german.ts} +12 -5
  246. package/packages/word-definitions/src/languages/index.ts +7 -0
  247. package/packages/word-definitions/src/{parse/parseFarsi.ts → languages/persian.ts} +11 -4
  248. package/packages/word-definitions/src/{parse/parsePolish.ts → languages/polish.ts} +11 -4
  249. package/packages/word-definitions/src/{parse/parseRomanian.ts → languages/romanian.ts} +11 -4
  250. package/packages/word-definitions/src/{parse/parseSpanish.ts → languages/spanish.ts} +11 -4
  251. package/packages/word-definitions/src/lib/index.ts +3 -3
  252. package/packages/word-definitions/src/lib/normalizeDefinition.ts +1 -3
  253. package/packages/word-definitions/src/lib/request.ts +1 -3
  254. package/packages/word-definitions/src/lib/unique.ts +1 -3
  255. package/packages/word-definitions/src/{parse/parse.test.ts → parse.test.ts} +5 -7
  256. package/packages/word-definitions/src/parse.ts +25 -0
  257. package/packages/word-definitions/src/types.ts +1 -1
  258. package/packages/word-lists/build/getWordList.d.ts +1 -2
  259. package/packages/word-lists/build/getWordList.js +11 -20
  260. package/packages/word-lists/build/index.d.ts +2 -6
  261. package/packages/word-lists/build/index.js +3 -15
  262. package/packages/word-lists/build/languages/english.d.ts +2 -0
  263. package/packages/word-lists/build/languages/english.js +15 -0
  264. package/packages/word-lists/build/languages/french.d.ts +1 -0
  265. package/packages/word-lists/build/languages/french.js +11 -0
  266. package/packages/word-lists/build/languages/german.d.ts +1 -0
  267. package/packages/word-lists/build/languages/german.js +10 -0
  268. package/packages/word-lists/build/languages/index.d.ts +7 -0
  269. package/packages/word-lists/build/languages/index.js +33 -0
  270. package/packages/word-lists/build/languages/persian.d.ts +1 -0
  271. package/packages/word-lists/build/languages/persian.js +10 -0
  272. package/packages/word-lists/build/languages/polish.d.ts +1 -0
  273. package/packages/word-lists/build/languages/polish.js +42 -0
  274. package/packages/word-lists/build/languages/romanian.d.ts +1 -0
  275. package/packages/word-lists/build/languages/romanian.js +11 -0
  276. package/packages/word-lists/build/languages/spanish.d.ts +1 -0
  277. package/packages/word-lists/build/languages/spanish.js +19 -0
  278. package/packages/word-lists/package-lock.json +2 -2
  279. package/packages/word-lists/package.json +2 -2
  280. package/packages/word-lists/src/getWordList.ts +10 -19
  281. package/packages/word-lists/src/index.ts +2 -6
  282. package/packages/word-lists/src/languages/english.ts +14 -0
  283. package/packages/word-lists/src/{getFrFrWordList.ts → languages/french.ts} +2 -4
  284. package/packages/word-lists/src/{getDeDeWordList.ts → languages/german.ts} +2 -4
  285. package/packages/word-lists/src/languages/index.ts +7 -0
  286. package/packages/word-lists/src/{getFaIrWordList.ts → languages/persian.ts} +2 -4
  287. package/packages/word-lists/src/{getPlPlWordList.ts → languages/polish.ts} +2 -4
  288. package/packages/word-lists/src/{getRoRoWordList.ts → languages/romanian.ts} +2 -4
  289. package/packages/word-lists/src/{getEsEsWordList.ts → languages/spanish.ts} +2 -4
  290. package/tsconfig.jest.json +1 -0
  291. package/packages/configs/src/locales/deDe.ts +0 -43
  292. package/packages/configs/src/locales/enGb.ts +0 -105
  293. package/packages/configs/src/locales/enUs.ts +0 -105
  294. package/packages/configs/src/locales/esEs.ts +0 -42
  295. package/packages/configs/src/locales/faIr.ts +0 -46
  296. package/packages/configs/src/locales/frFr.ts +0 -40
  297. package/packages/configs/src/locales/index.ts +0 -8
  298. package/packages/configs/src/locales/plPl.ts +0 -84
  299. package/packages/configs/src/locales/roRo.ts +0 -39
  300. package/packages/scrabble-solver/.next/BUILD_ID +0 -1
  301. package/packages/scrabble-solver/.next/export-marker.json +0 -1
  302. package/packages/scrabble-solver/.next/images-manifest.json +0 -1
  303. package/packages/scrabble-solver/.next/next-minimal-server.js.nft.json +0 -1
  304. package/packages/scrabble-solver/.next/next-server.js.nft.json +0 -1
  305. package/packages/scrabble-solver/.next/prerender-manifest.js +0 -1
  306. package/packages/scrabble-solver/.next/prerender-manifest.json +0 -1
  307. package/packages/scrabble-solver/.next/required-server-files.json +0 -1
  308. package/packages/scrabble-solver/.next/routes-manifest.json +0 -1
  309. package/packages/scrabble-solver/.next/server/InjectManifest.js.nft.json +0 -1
  310. package/packages/scrabble-solver/.next/server/chunks/28.js +0 -1
  311. package/packages/scrabble-solver/.next/server/chunks/331.js +0 -6
  312. package/packages/scrabble-solver/.next/server/chunks/577.js +0 -1
  313. package/packages/scrabble-solver/.next/server/chunks/911.js +0 -1
  314. package/packages/scrabble-solver/.next/server/chunks/977.js +0 -1
  315. package/packages/scrabble-solver/.next/server/chunks/font-manifest.json +0 -1
  316. package/packages/scrabble-solver/.next/server/font-manifest.json +0 -1
  317. package/packages/scrabble-solver/.next/server/functions-config-manifest.json +0 -1
  318. package/packages/scrabble-solver/.next/server/pages/404.html +0 -1
  319. package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +0 -1
  320. package/packages/scrabble-solver/.next/server/pages/500.html +0 -1
  321. package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +0 -1
  322. package/packages/scrabble-solver/.next/server/pages/_document.js.nft.json +0 -1
  323. package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +0 -1
  324. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +0 -1
  325. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js +0 -1
  326. package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale].js.nft.json +0 -1
  327. package/packages/scrabble-solver/.next/server/pages/api/solve.js.nft.json +0 -1
  328. package/packages/scrabble-solver/.next/server/pages/api/verify.js.nft.json +0 -1
  329. package/packages/scrabble-solver/.next/server/pages/api/visit.js.nft.json +0 -1
  330. package/packages/scrabble-solver/.next/server/pages/index.html +0 -1
  331. package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +0 -1
  332. package/packages/scrabble-solver/.next/server/pages/index.json +0 -1
  333. package/packages/scrabble-solver/.next/static/chunks/framework-1728d40275bc359a.js +0 -49
  334. package/packages/scrabble-solver/.next/static/chunks/main-5fb7abbfc135de15.js +0 -1
  335. package/packages/scrabble-solver/.next/static/chunks/pages/404-b6e238bb4117d451.js +0 -1
  336. package/packages/scrabble-solver/.next/static/chunks/pages/_app-b95404c40a0092e6.js +0 -17
  337. package/packages/scrabble-solver/.next/static/chunks/pages/_error-db043fa3544f8809.js +0 -1
  338. package/packages/scrabble-solver/.next/static/chunks/pages/index-59d569ef79bc2580.js +0 -1
  339. package/packages/scrabble-solver/.next/static/chunks/webpack-6ef43a8d4a395f49.js +0 -1
  340. package/packages/scrabble-solver/.next/static/css/8fa2fb99b90e109e.css +0 -1
  341. package/packages/scrabble-solver/.next/static/css/c80ebc6fd13311f1.css +0 -2
  342. package/packages/scrabble-solver/.next/static/jyVoCYlAT5PMzOeavr5AX/_buildManifest.js +0 -1
  343. package/packages/scrabble-solver/.next/static/jyVoCYlAT5PMzOeavr5AX/_ssgManifest.js +0 -1
  344. package/packages/word-definitions/src/crawl/crawl.ts +0 -26
  345. package/packages/word-definitions/src/crawl/crawlEnglish.ts +0 -11
  346. package/packages/word-definitions/src/crawl/crawlFarsi.ts +0 -11
  347. package/packages/word-definitions/src/crawl/crawlFrench.ts +0 -11
  348. package/packages/word-definitions/src/crawl/crawlGerman.ts +0 -11
  349. package/packages/word-definitions/src/crawl/crawlPolish.ts +0 -11
  350. package/packages/word-definitions/src/crawl/crawlRomanian.ts +0 -11
  351. package/packages/word-definitions/src/crawl/crawlSpanish.ts +0 -11
  352. package/packages/word-definitions/src/crawl/index.ts +0 -6
  353. package/packages/word-definitions/src/parse/index.ts +0 -8
  354. package/packages/word-definitions/src/parse/parse.ts +0 -34
  355. package/packages/word-definitions/src/parse/parseFrench.ts +0 -15
  356. package/packages/word-lists/src/getEnGbWordList.ts +0 -11
  357. package/packages/word-lists/src/getEnUsWordList.ts +0 -11
  358. /package/packages/scrabble-solver/.next/static/chunks/{polyfills-c67a75d1b6f99dc8.js → polyfills.js} +0 -0
  359. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/de-DE.hm.json +0 -0
  360. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/de-DE.ho.json +0 -0
  361. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/de-DE.kolla.json +0 -0
  362. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/de-DE.vom.json +0 -0
  363. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/en-US.awe.json +0 -0
  364. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/en-US.oe.json +0 -0
  365. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/en-US.pawn.json +0 -0
  366. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/en-US.pawnee.json +0 -0
  367. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/en-US.pean.json +0 -0
  368. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/en-US.wiz.json +0 -0
  369. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/es-ES.corma.json +0 -0
  370. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/es-ES.portero.json +0 -0
  371. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/expected/ro-RO.aciua.json +0 -0
  372. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/de-DE.hm.html +0 -0
  373. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/de-DE.ho.html +0 -0
  374. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/de-DE.kolla.html +0 -0
  375. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/de-DE.vom.html +0 -0
  376. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/en-US.awe.html +0 -0
  377. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/en-US.oe.html +0 -0
  378. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/en-US.pawn.html +0 -0
  379. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/en-US.pawnee.html +0 -0
  380. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/en-US.pean.html +0 -0
  381. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/en-US.wiz.html +0 -0
  382. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/es-ES.corma.html +0 -0
  383. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/es-ES.portero.html +0 -0
  384. /package/packages/word-definitions/src/{parse/__tests__ → __tests__}/input/ro-RO.aciua.html +0 -0
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = exports.crawl = void 0;
4
+ const cheerio_1 = require("cheerio");
5
+ const lib_1 = require("../lib");
6
+ const crawl = (word) => {
7
+ return (0, lib_1.request)({
8
+ protocol: 'https',
9
+ hostname: 'sjp.pl',
10
+ path: `/${encodeURIComponent(word)}`,
11
+ });
12
+ };
13
+ exports.crawl = crawl;
14
+ const parse = (html) => {
15
+ const $ = (0, cheerio_1.load)(html);
16
+ const $header = $($('h1')[0]);
17
+ const $isAllowed = $header.next();
18
+ const $definitions = $header.next().next().next().next();
19
+ return {
20
+ definitions: $definitions.text().trim().split(/\d+\./),
21
+ exists: $isAllowed.text().trim().indexOf('dopuszczalne w grach') >= 0,
22
+ };
23
+ };
24
+ exports.parse = parse;
@@ -0,0 +1,3 @@
1
+ import { ParsingResult } from '../types';
2
+ export declare const crawl: (word: string) => Promise<string>;
3
+ export declare const parse: (html: string) => ParsingResult;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = exports.crawl = void 0;
4
+ const cheerio_1 = require("cheerio");
5
+ const lib_1 = require("../lib");
6
+ const crawl = (word) => {
7
+ return (0, lib_1.request)({
8
+ protocol: 'https',
9
+ hostname: 'dexonline.ro',
10
+ path: `/definitie/${encodeURIComponent(word)}`,
11
+ });
12
+ };
13
+ exports.crawl = crawl;
14
+ const parse = (html) => {
15
+ const $ = (0, cheerio_1.load)(html);
16
+ const $activeTab = $('.tab-pane.show.active');
17
+ $('.type-example').remove();
18
+ const $definitions = $activeTab.find('li.type-meaning.depth-0 > .meaningContainer .def.html');
19
+ $definitions.find('.meaningTree').remove();
20
+ const definitions = Array.from($definitions).map((definition) => $(definition).text().replace(/\n/g, ''));
21
+ return {
22
+ definitions,
23
+ exists: definitions.length > 0,
24
+ };
25
+ };
26
+ exports.parse = parse;
@@ -0,0 +1,3 @@
1
+ import { ParsingResult } from '../types';
2
+ export declare const crawl: (word: string) => Promise<string>;
3
+ export declare const parse: (html: string) => ParsingResult;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = exports.crawl = void 0;
4
+ const cheerio_1 = require("cheerio");
5
+ const lib_1 = require("../lib");
6
+ const crawl = (word) => {
7
+ return (0, lib_1.request)({
8
+ protocol: 'https',
9
+ hostname: 'www.diccionarios.com',
10
+ path: `/diccionario/espanol/${encodeURIComponent(word)}`,
11
+ });
12
+ };
13
+ exports.crawl = crawl;
14
+ const parse = (html) => {
15
+ const $ = (0, cheerio_1.load)(html);
16
+ $('.verdBold14 + .gris11 + .gris13').remove();
17
+ $('br + .gris13').remove();
18
+ $('.grisItalic13 + .gris13').remove();
19
+ $('font[class^="verd"]').remove();
20
+ $('font.gris11').remove();
21
+ $('font[class^="grisBold"]').remove();
22
+ $('font[class^="grisItalic"]').remove();
23
+ Array.from($('.gris13')).forEach((element) => {
24
+ const children = $(element).find('.gris13');
25
+ if (children && children.length > 0) {
26
+ children.remove();
27
+ }
28
+ });
29
+ const definitions = Array.from($('.dcom-search-result .gris13'));
30
+ return {
31
+ definitions: definitions
32
+ .map((definition) => $(definition).text().trim())
33
+ .filter(Boolean)
34
+ .map((definition) => definition.replace(/\s+\.$/g, ''))
35
+ .map((definition) => (definition.endsWith('.') ? definition : `${definition}.`)),
36
+ exists: $('.wrapper > p > strong').text() !== 'No se ha encontrado la palabra exacta',
37
+ };
38
+ };
39
+ exports.parse = parse;
@@ -1,3 +1,3 @@
1
- export { default as normalizeDefinition } from './normalizeDefinition';
2
- export { default as request } from './request';
3
- export { default as unique } from './unique';
1
+ export { normalizeDefinition } from './normalizeDefinition';
2
+ export { request } from './request';
3
+ export { unique } from './unique';
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.unique = exports.request = exports.normalizeDefinition = void 0;
7
4
  var normalizeDefinition_1 = require("./normalizeDefinition");
8
- Object.defineProperty(exports, "normalizeDefinition", { enumerable: true, get: function () { return __importDefault(normalizeDefinition_1).default; } });
5
+ Object.defineProperty(exports, "normalizeDefinition", { enumerable: true, get: function () { return normalizeDefinition_1.normalizeDefinition; } });
9
6
  var request_1 = require("./request");
10
- Object.defineProperty(exports, "request", { enumerable: true, get: function () { return __importDefault(request_1).default; } });
7
+ Object.defineProperty(exports, "request", { enumerable: true, get: function () { return request_1.request; } });
11
8
  var unique_1 = require("./unique");
12
- Object.defineProperty(exports, "unique", { enumerable: true, get: function () { return __importDefault(unique_1).default; } });
9
+ Object.defineProperty(exports, "unique", { enumerable: true, get: function () { return unique_1.unique; } });
@@ -1,2 +1 @@
1
- declare const normalizeDefinition: (definition: string) => string;
2
- export default normalizeDefinition;
1
+ export declare const normalizeDefinition: (definition: string) => string;
@@ -3,6 +3,7 @@ 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
+ exports.normalizeDefinition = void 0;
6
7
  const striptags_1 = __importDefault(require("striptags"));
7
8
  const EMPHASIS_TAGS = ['a', 'b', 'em', 'internalXref'];
8
9
  const normalizeHtmlTags = (definition) => (0, striptags_1.default)((0, striptags_1.default)(definition, EMPHASIS_TAGS), undefined, '"');
@@ -40,6 +41,6 @@ const normalizers = [
40
41
  const normalizeDefinition = (definition) => {
41
42
  const normalized = normalizers.reduce((result, normalize) => normalize(result), definition);
42
43
  const hasChanged = normalized !== definition;
43
- return hasChanged ? normalizeDefinition(normalized) : normalized;
44
+ return hasChanged ? (0, exports.normalizeDefinition)(normalized) : normalized;
44
45
  };
45
- exports.default = normalizeDefinition;
46
+ exports.normalizeDefinition = normalizeDefinition;
@@ -3,5 +3,5 @@ import { RequestOptions } from 'http';
3
3
  interface Options extends RequestOptions {
4
4
  protocol?: 'http' | 'https';
5
5
  }
6
- declare const request: ({ protocol, ...options }: Options) => Promise<string>;
7
- export default request;
6
+ export declare const request: ({ protocol, ...options }: Options) => Promise<string>;
7
+ export {};
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.request = void 0;
3
4
  const follow_redirects_1 = require("follow-redirects");
4
5
  const request = ({ protocol, ...options }) => {
5
6
  const agent = protocol === 'https' ? follow_redirects_1.https : follow_redirects_1.http;
@@ -23,4 +24,4 @@ const request = ({ protocol, ...options }) => {
23
24
  .on('error', reject);
24
25
  });
25
26
  };
26
- exports.default = request;
27
+ exports.request = request;
@@ -1,2 +1 @@
1
- declare const unique: <T>(array: T[]) => T[];
2
- export default unique;
1
+ export declare const unique: <T>(array: T[]) => T[];
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unique = void 0;
3
4
  const unique = (array) => Array.from(new Set(array));
4
- exports.default = unique;
5
+ exports.unique = unique;
@@ -0,0 +1,3 @@
1
+ import { Locale } from '@scrabble-solver/types';
2
+ import { ParsingResult } from './types';
3
+ export declare const parse: (locale: Locale, html: string) => ParsingResult;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ const types_1 = require("@scrabble-solver/types");
5
+ const languages_1 = require("./languages");
6
+ const lib_1 = require("./lib");
7
+ const parsePerLocale = {
8
+ [types_1.Locale.DE_DE]: languages_1.german.parse,
9
+ [types_1.Locale.EN_GB]: languages_1.english.parse,
10
+ [types_1.Locale.EN_US]: languages_1.english.parse,
11
+ [types_1.Locale.ES_ES]: languages_1.spanish.parse,
12
+ [types_1.Locale.FA_IR]: languages_1.persian.parse,
13
+ [types_1.Locale.FR_FR]: languages_1.french.parse,
14
+ [types_1.Locale.PL_PL]: languages_1.polish.parse,
15
+ [types_1.Locale.RO_RO]: languages_1.romanian.parse,
16
+ };
17
+ const parse = (locale, html) => {
18
+ const { definitions, exists } = parsePerLocale[locale](html);
19
+ return {
20
+ definitions: (0, lib_1.unique)(definitions.map(lib_1.normalizeDefinition).filter(Boolean)),
21
+ exists,
22
+ };
23
+ };
24
+ exports.parse = parse;
@@ -1,4 +1,4 @@
1
- export interface ParseResult {
1
+ export interface ParsingResult {
2
2
  definitions: string[];
3
3
  exists: boolean;
4
4
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@scrabble-solver/word-definitions",
3
- "version": "2.13.4",
3
+ "version": "2.13.5-alpha.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@scrabble-solver/word-definitions",
9
- "version": "2.13.4",
9
+ "version": "2.13.5-alpha.1",
10
10
  "license": "CC-BY-NC-ND-4.0",
11
11
  "dependencies": {
12
12
  "cheerio": "^1.0.0-rc.12",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scrabble-solver/word-definitions",
3
- "version": "2.13.4",
3
+ "version": "2.13.5-alpha.1",
4
4
  "description": "Scrabble Solver 2 - Word definitions",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "clean": "rimraf build/"
24
24
  },
25
25
  "dependencies": {
26
- "@scrabble-solver/types": "^2.13.4",
26
+ "@scrabble-solver/types": "^2.13.5-alpha.1",
27
27
  "cheerio": "^1.0.0-rc.12",
28
28
  "follow-redirects": "^1.15.5",
29
29
  "striptags": "^3.2.0"
@@ -0,0 +1,18 @@
1
+ import { Locale } from '@scrabble-solver/types';
2
+
3
+ import { english, french, german, persian, polish, romanian, spanish } from './languages';
4
+
5
+ const crawlPerLocale: Record<Locale, (word: string) => Promise<string>> = {
6
+ [Locale.DE_DE]: german.crawl,
7
+ [Locale.EN_GB]: english.crawl,
8
+ [Locale.EN_US]: english.crawl,
9
+ [Locale.ES_ES]: spanish.crawl,
10
+ [Locale.FA_IR]: persian.crawl,
11
+ [Locale.FR_FR]: french.crawl,
12
+ [Locale.PL_PL]: polish.crawl,
13
+ [Locale.RO_RO]: romanian.crawl,
14
+ };
15
+
16
+ export const crawl = (locale: Locale, word: string): Promise<string> => {
17
+ return crawlPerLocale[locale](word);
18
+ };
@@ -3,11 +3,9 @@ import { Locale, WordDefinition } from '@scrabble-solver/types';
3
3
  import { crawl } from './crawl';
4
4
  import { parse } from './parse';
5
5
 
6
- const getWordDefinition = async (locale: Locale, word: string, isAllowed: boolean): Promise<WordDefinition> => {
6
+ export const getWordDefinition = async (locale: Locale, word: string, isAllowed: boolean): Promise<WordDefinition> => {
7
7
  const html = await crawl(locale, word);
8
8
  const { definitions, exists } = parse(locale, html);
9
9
  const wordDefinition = new WordDefinition({ definitions, exists, isAllowed, word });
10
10
  return wordDefinition;
11
11
  };
12
-
13
- export default getWordDefinition;
@@ -1,5 +1,6 @@
1
- export { default as getWordDefinition } from './getWordDefinition';
1
+ export { getWordDefinition } from './getWordDefinition';
2
2
 
3
3
  export * from './crawl';
4
+ export * from './languages';
4
5
  export * from './lib';
5
6
  export * from './parse';
@@ -1,12 +1,21 @@
1
1
  import { load } from 'cheerio';
2
2
 
3
- import { ParseResult } from '../types';
3
+ import { request } from '../lib';
4
+ import { ParsingResult } from '../types';
4
5
 
5
6
  const DOES_NOT_EXIST_MESSAGE =
6
7
  // eslint-disable-next-line max-len
7
8
  "The word you've entered isn't in the dictionary. Click on a spelling suggestion below or try again using the search bar above.";
8
9
 
9
- const parseEnglish = (html: string): ParseResult => {
10
+ export const crawl = (word: string): Promise<string> => {
11
+ return request({
12
+ protocol: 'https',
13
+ hostname: 'www.merriam-webster.com',
14
+ path: `/dictionary/${encodeURIComponent(word)}`,
15
+ });
16
+ };
17
+
18
+ export const parse = (html: string): ParsingResult => {
10
19
  const $ = load(html);
11
20
  $('strong.mw_t_bc').replaceWith(', ');
12
21
  $('.text-lowercase').remove();
@@ -19,5 +28,3 @@ const parseEnglish = (html: string): ParseResult => {
19
28
  exists: $('.spelling-suggestion-text').text().trim() !== DOES_NOT_EXIST_MESSAGE,
20
29
  };
21
30
  };
22
-
23
- export default parseEnglish;
@@ -0,0 +1,22 @@
1
+ import { load } from 'cheerio';
2
+
3
+ import { request } from '../lib';
4
+ import { ParsingResult } from '../types';
5
+
6
+ export const crawl = (word: string): Promise<string> => {
7
+ return request({
8
+ protocol: 'https',
9
+ hostname: 'www.cnrtl.fr',
10
+ path: `/definition/${encodeURIComponent(word)}`,
11
+ });
12
+ };
13
+
14
+ export const parse = (html: string): ParsingResult => {
15
+ const $ = load(html);
16
+ const $definitions = $('.tlf_cdefinition');
17
+
18
+ return {
19
+ definitions: Array.from($definitions).map((definition) => $(definition).text()),
20
+ exists: $('#vitemselected span').length > 0,
21
+ };
22
+ };
@@ -1,12 +1,21 @@
1
1
  import { Cheerio, CheerioAPI, Element, load } from 'cheerio';
2
2
 
3
- import { ParseResult } from '../types';
3
+ import { request } from '../lib';
4
+ import { ParsingResult } from '../types';
5
+
6
+ export const crawl = (word: string): Promise<string> => {
7
+ return request({
8
+ protocol: 'https',
9
+ hostname: 'www.dwds.de',
10
+ path: `/wb/${encodeURIComponent(word)}`,
11
+ });
12
+ };
4
13
 
5
- const parseGerman = (html: string): ParseResult => {
14
+ export const parse = (html: string): ParsingResult => {
6
15
  const $ = load(html);
7
16
 
8
17
  const definitions = [parseBedeutungsubersicht, parseBedeutungen, parseBedeutung].reduce<string[]>(
9
- (results, parse) => (results.length === 0 ? parse($) : results),
18
+ (results, parseDefinition) => (results.length === 0 ? parseDefinition($) : results),
10
19
  [],
11
20
  );
12
21
  const exists = Array.from($('.label-danger')).every((label) => $(label).text() !== 'Hinweis');
@@ -76,5 +85,3 @@ const parseDefinitions = ($: CheerioAPI, $definitions: Cheerio<Element>) => {
76
85
  .replace(/^[0-9]+\.\s/g, ''),
77
86
  );
78
87
  };
79
-
80
- export default parseGerman;
@@ -0,0 +1,7 @@
1
+ export * as english from './english';
2
+ export * as german from './german';
3
+ export * as french from './french';
4
+ export * as persian from './persian';
5
+ export * as polish from './polish';
6
+ export * as romanian from './romanian';
7
+ export * as spanish from './spanish';
@@ -1,10 +1,19 @@
1
1
  import { load } from 'cheerio';
2
2
 
3
- import { ParseResult } from '../types';
3
+ import { request } from '../lib';
4
+ import { ParsingResult } from '../types';
4
5
 
5
6
  const DOES_NOT_EXIST_MESSAGE = '404 Page Not Found';
6
7
 
7
- const parseFarsi = (html: string): ParseResult => {
8
+ export const crawl = (word: string): Promise<string> => {
9
+ return request({
10
+ protocol: 'https',
11
+ hostname: 'www.vajehyab.com',
12
+ path: `/moein/${encodeURIComponent(word)}`,
13
+ });
14
+ };
15
+
16
+ export const parse = (html: string): ParsingResult => {
8
17
  const $ = load(html);
9
18
  const $definitions = $('[itemprop=articleBody]');
10
19
 
@@ -13,5 +22,3 @@ const parseFarsi = (html: string): ParseResult => {
13
22
  exists: $('#container h1').text() !== DOES_NOT_EXIST_MESSAGE,
14
23
  };
15
24
  };
16
-
17
- export default parseFarsi;
@@ -1,8 +1,17 @@
1
1
  import { load } from 'cheerio';
2
2
 
3
- import { ParseResult } from '../types';
3
+ import { request } from '../lib';
4
+ import { ParsingResult } from '../types';
4
5
 
5
- const parsePolish = (html: string): ParseResult => {
6
+ export const crawl = (word: string): Promise<string> => {
7
+ return request({
8
+ protocol: 'https',
9
+ hostname: 'sjp.pl',
10
+ path: `/${encodeURIComponent(word)}`,
11
+ });
12
+ };
13
+
14
+ export const parse = (html: string): ParsingResult => {
6
15
  const $ = load(html);
7
16
  const $header = $($('h1')[0]);
8
17
  const $isAllowed = $header.next();
@@ -13,5 +22,3 @@ const parsePolish = (html: string): ParseResult => {
13
22
  exists: $isAllowed.text().trim().indexOf('dopuszczalne w grach') >= 0,
14
23
  };
15
24
  };
16
-
17
- export default parsePolish;
@@ -1,8 +1,17 @@
1
1
  import { load } from 'cheerio';
2
2
 
3
- import { ParseResult } from '../types';
3
+ import { request } from '../lib';
4
+ import { ParsingResult } from '../types';
4
5
 
5
- const parseRomanian = (html: string): ParseResult => {
6
+ export const crawl = (word: string): Promise<string> => {
7
+ return request({
8
+ protocol: 'https',
9
+ hostname: 'dexonline.ro',
10
+ path: `/definitie/${encodeURIComponent(word)}`,
11
+ });
12
+ };
13
+
14
+ export const parse = (html: string): ParsingResult => {
6
15
  const $ = load(html);
7
16
 
8
17
  const $activeTab = $('.tab-pane.show.active');
@@ -16,5 +25,3 @@ const parseRomanian = (html: string): ParseResult => {
16
25
  exists: definitions.length > 0,
17
26
  };
18
27
  };
19
-
20
- export default parseRomanian;
@@ -1,8 +1,17 @@
1
1
  import { load } from 'cheerio';
2
2
 
3
- import { ParseResult } from '../types';
3
+ import { request } from '../lib';
4
+ import { ParsingResult } from '../types';
4
5
 
5
- const parseSpanish = (html: string): ParseResult => {
6
+ export const crawl = (word: string): Promise<string> => {
7
+ return request({
8
+ protocol: 'https',
9
+ hostname: 'www.diccionarios.com',
10
+ path: `/diccionario/espanol/${encodeURIComponent(word)}`,
11
+ });
12
+ };
13
+
14
+ export const parse = (html: string): ParsingResult => {
6
15
  const $ = load(html);
7
16
  $('.verdBold14 + .gris11 + .gris13').remove();
8
17
  $('br + .gris13').remove();
@@ -31,5 +40,3 @@ const parseSpanish = (html: string): ParseResult => {
31
40
  exists: $('.wrapper > p > strong').text() !== 'No se ha encontrado la palabra exacta',
32
41
  };
33
42
  };
34
-
35
- export default parseSpanish;
@@ -1,3 +1,3 @@
1
- export { default as normalizeDefinition } from './normalizeDefinition';
2
- export { default as request } from './request';
3
- export { default as unique } from './unique';
1
+ export { normalizeDefinition } from './normalizeDefinition';
2
+ export { request } from './request';
3
+ export { unique } from './unique';
@@ -46,10 +46,8 @@ const normalizers: Normalize[] = [
46
46
  (definition) => definition.trim(),
47
47
  ];
48
48
 
49
- const normalizeDefinition = (definition: string): string => {
49
+ export const normalizeDefinition = (definition: string): string => {
50
50
  const normalized = normalizers.reduce((result, normalize) => normalize(result), definition);
51
51
  const hasChanged = normalized !== definition;
52
52
  return hasChanged ? normalizeDefinition(normalized) : normalized;
53
53
  };
54
-
55
- export default normalizeDefinition;
@@ -5,7 +5,7 @@ interface Options extends RequestOptions {
5
5
  protocol?: 'http' | 'https';
6
6
  }
7
7
 
8
- const request = ({ protocol, ...options }: Options): Promise<string> => {
8
+ export const request = ({ protocol, ...options }: Options): Promise<string> => {
9
9
  const agent = protocol === 'https' ? https : http;
10
10
 
11
11
  return new Promise((resolve, reject) => {
@@ -27,5 +27,3 @@ const request = ({ protocol, ...options }: Options): Promise<string> => {
27
27
  .on('error', reject);
28
28
  });
29
29
  };
30
-
31
- export default request;
@@ -1,3 +1 @@
1
- const unique = <T>(array: T[]): T[] => Array.from(new Set(array));
2
-
3
- export default unique;
1
+ export const unique = <T>(array: T[]): T[] => Array.from(new Set(array));
@@ -2,7 +2,7 @@ import { Locale } from '@scrabble-solver/types';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
 
5
- import parse from './parse';
5
+ import { parse } from './parse';
6
6
 
7
7
  export const readTestFile = (filepath: string): string => {
8
8
  const absoluteFilepath = path.resolve(__dirname, '__tests__', filepath);
@@ -26,11 +26,9 @@ const tests = [
26
26
  ];
27
27
 
28
28
  describe('parse', () => {
29
- tests.forEach(({ locale, word }) => {
30
- it(`${locale} - "${word}"`, () => {
31
- const input = readTestFile(`input/${locale}.${word}.html`);
32
- const expected = readTestFile(`expected/${locale}.${word}.json`);
33
- expect(parse(locale, input)).toEqual(JSON.parse(expected));
34
- });
29
+ it.each(tests)(`[$locale] "$word"`, ({ locale, word }) => {
30
+ const input = readTestFile(`input/${locale}.${word}.html`);
31
+ const expected = readTestFile(`expected/${locale}.${word}.json`);
32
+ expect(parse(locale, input)).toEqual(JSON.parse(expected));
35
33
  });
36
34
  });
@@ -0,0 +1,25 @@
1
+ import { Locale } from '@scrabble-solver/types';
2
+
3
+ import { english, french, german, persian, polish, romanian, spanish } from './languages';
4
+ import { normalizeDefinition, unique } from './lib';
5
+ import { ParsingResult } from './types';
6
+
7
+ const parsePerLocale: Record<Locale, (html: string) => ParsingResult> = {
8
+ [Locale.DE_DE]: german.parse,
9
+ [Locale.EN_GB]: english.parse,
10
+ [Locale.EN_US]: english.parse,
11
+ [Locale.ES_ES]: spanish.parse,
12
+ [Locale.FA_IR]: persian.parse,
13
+ [Locale.FR_FR]: french.parse,
14
+ [Locale.PL_PL]: polish.parse,
15
+ [Locale.RO_RO]: romanian.parse,
16
+ };
17
+
18
+ export const parse = (locale: Locale, html: string): ParsingResult => {
19
+ const { definitions, exists } = parsePerLocale[locale](html);
20
+
21
+ return {
22
+ definitions: unique(definitions.map(normalizeDefinition).filter(Boolean)),
23
+ exists,
24
+ };
25
+ };
@@ -1,4 +1,4 @@
1
- export interface ParseResult {
1
+ export interface ParsingResult {
2
2
  definitions: string[];
3
3
  exists: boolean;
4
4
  }
@@ -1,3 +1,2 @@
1
1
  import { Locale } from '@scrabble-solver/types';
2
- declare const getWordList: (locale: Locale) => Promise<string[]>;
3
- export default getWordList;
2
+ export declare const getWordList: (locale: Locale) => Promise<string[]>;