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
@@ -1,4 +1,4 @@
1
- import React, { FunctionComponent } from 'react';
1
+ import { FunctionComponent } from 'react';
2
2
 
3
3
  interface Props {
4
4
  character: string;
@@ -1,6 +1,6 @@
1
1
  import { BLANK } from '@scrabble-solver/constants';
2
2
  import classNames from 'classnames';
3
- import React, { createRef, FunctionComponent, useCallback, useMemo, useRef } from 'react';
3
+ import { createRef, FunctionComponent, useCallback, useMemo, useRef } from 'react';
4
4
 
5
5
  import { createArray, createKeyboardNavigation, zipCharactersAndTiles } from 'lib';
6
6
  import { selectConfig, selectRack, selectResultCandidateTiles, useTypedSelector } from 'state';
@@ -1,6 +1,6 @@
1
1
  import { BLANK } from '@scrabble-solver/constants';
2
2
  import { Tile as TileModel } from '@scrabble-solver/types';
3
- import React, {
3
+ import {
4
4
  FunctionComponent,
5
5
  KeyboardEventHandler,
6
6
  MutableRefObject,
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { ChangeEventHandler, FunctionComponent, ReactNode } from 'react';
2
+ import { ChangeEventHandler, FunctionComponent, ReactNode } from 'react';
3
3
 
4
4
  import styles from './Radio.module.scss';
5
5
 
@@ -1,6 +1,6 @@
1
1
  import { BLANK } from '@scrabble-solver/constants';
2
2
  import classNames from 'classnames';
3
- import React, { FunctionComponent } from 'react';
3
+ import { FunctionComponent } from 'react';
4
4
 
5
5
  import { REMAINING_TILES_TILE_SIZE } from 'parameters';
6
6
  import { selectCharacterPoints, useTypedSelector } from 'state';
@@ -1,4 +1,4 @@
1
- import React, { FunctionComponent } from 'react';
1
+ import { FunctionComponent } from 'react';
2
2
 
3
3
  import { selectRemainingTilesGroups, useTranslate, useTypedSelector } from 'state';
4
4
 
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { FunctionComponent } from 'react';
2
+ import { FunctionComponent } from 'react';
3
3
 
4
4
  import { useTranslate } from 'state';
5
5
  import { TranslationKey } from 'types';
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { ReactElement } from 'react';
2
+ import { ReactElement } from 'react';
3
3
  import { useDispatch } from 'react-redux';
4
4
 
5
5
  import { SortDown, SortUp } from 'icons';
@@ -1,4 +1,4 @@
1
- import React, { CSSProperties, ReactElement } from 'react';
1
+ import { CSSProperties, ReactElement } from 'react';
2
2
  import { useDispatch } from 'react-redux';
3
3
 
4
4
  import { resultsSlice, selectSortedFilteredResults, useTypedSelector } from 'state';
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { FunctionComponent } from 'react';
2
+ import { FunctionComponent } from 'react';
3
3
  import { FixedSizeList } from 'react-window';
4
4
 
5
5
  import { RESULTS_HEADER_HEIGHT, RESULTS_INPUT_HEIGHT, RESULTS_ITEM_HEIGHT } from 'parameters';
@@ -1,4 +1,4 @@
1
- import React, { FunctionComponent } from 'react';
1
+ import { FunctionComponent } from 'react';
2
2
  import { useDispatch } from 'react-redux';
3
3
 
4
4
  import { Play } from 'icons';
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { ChangeEvent, FunctionComponent } from 'react';
2
+ import { ChangeEvent, FunctionComponent } from 'react';
3
3
  import { useDispatch } from 'react-redux';
4
4
 
5
5
  import { resultsSlice, selectResultsQuery, useTranslate, useTypedSelector } from 'state';
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { AnimationEventHandler, FunctionComponent, ReactNode } from 'react';
2
+ import { AnimationEventHandler, FunctionComponent, ReactNode } from 'react';
3
3
 
4
4
  import styles from './Screen.module.scss';
5
5
 
@@ -1,4 +1,4 @@
1
- import React, { FunctionComponent } from 'react';
1
+ import { FunctionComponent } from 'react';
2
2
 
3
3
  import { useTranslate } from 'state';
4
4
 
@@ -1,4 +1,4 @@
1
- import React, { ChangeEvent, FunctionComponent } from 'react';
1
+ import { ChangeEvent, FunctionComponent } from 'react';
2
2
  import { useDispatch } from 'react-redux';
3
3
 
4
4
  import { selectAutoGroupTiles, settingsSlice, useTranslate, useTypedSelector } from 'state';
@@ -1,4 +1,4 @@
1
- import React, { ChangeEvent, FunctionComponent } from 'react';
1
+ import { ChangeEvent, FunctionComponent } from 'react';
2
2
  import { useDispatch } from 'react-redux';
3
3
 
4
4
  import { selectConfigId, settingsSlice, useTypedSelector } from 'state';
@@ -1,6 +1,6 @@
1
1
  import { Locale } from '@scrabble-solver/types';
2
2
  import classNames from 'classnames';
3
- import React, { ChangeEvent, FunctionComponent } from 'react';
3
+ import { ChangeEvent, FunctionComponent } from 'react';
4
4
  import { useDispatch } from 'react-redux';
5
5
 
6
6
  import { selectLocale, settingsSlice, useTypedSelector } from 'state';
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { FunctionComponent, ReactNode } from 'react';
2
+ import { FunctionComponent, ReactNode } from 'react';
3
3
  import Modal from 'react-modal';
4
4
 
5
5
  import { Cross } from 'icons';
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { FunctionComponent, ReactNode } from 'react';
2
+ import { FunctionComponent, ReactNode } from 'react';
3
3
 
4
4
  import styles from './Section.module.scss';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { AnimationEventHandler, FunctionComponent } from 'react';
2
+ import { AnimationEventHandler, FunctionComponent } from 'react';
3
3
 
4
4
  import Logo from '../Logo';
5
5
  import Screen from '../Screen';
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { AnchorHTMLAttributes, FunctionComponent, SVGAttributes } from 'react';
2
+ import { AnchorHTMLAttributes, FunctionComponent, SVGAttributes } from 'react';
3
3
 
4
4
  import { useTooltip } from '../Tooltip';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { ButtonHTMLAttributes, FunctionComponent, MouseEventHandler, SVGAttributes } from 'react';
2
+ import { ButtonHTMLAttributes, FunctionComponent, MouseEventHandler, SVGAttributes } from 'react';
3
3
 
4
4
  import { useTooltip } from '../Tooltip';
5
5
 
@@ -0,0 +1,12 @@
1
+ import { FunctionComponent } from 'react';
2
+
3
+ // eslint-disable-next-line max-len
4
+ const CSS = `@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&family=Open+Sans:wght@400;700&family=Roboto+Mono&display=swap');
5
+
6
+ text {
7
+ font-family: 'Open Sans';
8
+ }`;
9
+
10
+ const SvgFontCss: FunctionComponent = () => <style type="text/css">{CSS}</style>;
11
+
12
+ export default SvgFontCss;
@@ -0,0 +1 @@
1
+ export { default } from './SvgFontCss';
@@ -1,5 +1,5 @@
1
1
  import { EMPTY_CELL } from '@scrabble-solver/constants';
2
- import React, {
2
+ import {
3
3
  createRef,
4
4
  FocusEventHandler,
5
5
  FunctionComponent,
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, {
2
+ import {
3
3
  ChangeEventHandler,
4
4
  CSSProperties,
5
5
  FocusEventHandler,
@@ -66,7 +66,7 @@ const TilePure: FunctionComponent<Props> = ({
66
66
  style={style}
67
67
  >
68
68
  <input
69
- autoCapitalize="off"
69
+ autoCapitalize="none"
70
70
  autoComplete="off"
71
71
  autoCorrect="off"
72
72
  autoFocus={autoFocus}
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, {
2
+ import {
3
3
  FocusEvent,
4
4
  FocusEventHandler,
5
5
  MouseEvent,
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { forwardRef, HTMLAttributes, ReactNode } from 'react';
2
+ import { forwardRef, HTMLAttributes, ReactNode } from 'react';
3
3
 
4
4
  import styles from './Well.module.scss';
5
5
 
@@ -21,6 +21,7 @@ export { default as Settings } from './Settings';
21
21
  export { default as Sidebar } from './Sidebar';
22
22
  export { default as Splash } from './Splash';
23
23
  export { default as SquareButton } from './SquareButton';
24
+ export { default as SvgFontCss } from './SvgFontCss';
24
25
  export { default as Tile } from './Tile';
25
26
  export { useTooltip } from './Tooltip';
26
27
  export { default as Well } from './Well';
@@ -1,5 +1,5 @@
1
- import React, { ReactNode, useLayoutEffect, useMemo } from 'react';
2
- import { render, unmountComponentAtNode } from 'react-dom';
1
+ import { ReactNode, useLayoutEffect, useRef } from 'react';
2
+ import { createRoot, Root } from 'react-dom/client';
3
3
  import { Portal } from 'react-portal';
4
4
 
5
5
  import { canUseDom, noop } from 'lib';
@@ -12,26 +12,36 @@ interface Props {
12
12
  type TagName = Parameters<typeof document.createElement>[0];
13
13
 
14
14
  const usePortal = (children: ReactNode, { disabled = false, tagName = 'div' }: Props = {}): void => {
15
- const element = useMemo(() => document.createElement(tagName), [tagName]);
15
+ const rootRef = useRef<Root | null>(null);
16
16
 
17
17
  useLayoutEffect(() => {
18
18
  if (disabled) {
19
19
  return noop;
20
20
  }
21
21
 
22
+ const element = document.createElement(tagName);
22
23
  document.body.appendChild(element);
24
+ const root = createRoot(element);
25
+ rootRef.current = root;
23
26
 
24
27
  return () => {
25
- unmountComponentAtNode(element);
26
- document.body.removeChild(element);
28
+ // We need setTimeout for async unmount, otherwise we get this warning:
29
+ // "Attempted to synchronously unmount a root while React was already
30
+ // rendering. React cannot finish unmounting the root until the current
31
+ // render has completed, which may lead to a race condition.""
32
+ setTimeout(() => {
33
+ rootRef.current = null;
34
+ root.unmount();
35
+ element.remove();
36
+ }, 0);
27
37
  };
28
- }, [disabled, element]);
38
+ }, [disabled, tagName]);
29
39
 
30
40
  useLayoutEffect(() => {
31
- if (!disabled) {
32
- render(<Portal>{children}</Portal>, element);
41
+ if (rootRef.current) {
42
+ rootRef.current.render(<Portal>{children}</Portal>);
33
43
  }
34
- }, [children, disabled, element]);
44
+ }, [children, disabled, rootRef]);
35
45
  };
36
46
 
37
47
  export default canUseDom ? usePortal : noop;
@@ -11,6 +11,7 @@ interface Parameters {
11
11
  onDelete?: KeyboardEventHandler<HTMLInputElement>;
12
12
  onEnter?: KeyboardEventHandler<HTMLInputElement>;
13
13
  onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
14
+ onSpace?: KeyboardEventHandler<HTMLInputElement>;
14
15
  }
15
16
 
16
17
  const createKeyboardNavigation = ({
@@ -22,6 +23,7 @@ const createKeyboardNavigation = ({
22
23
  onDelete = noop,
23
24
  onEnter = noop,
24
25
  onKeyDown = noop,
26
+ onSpace = noop,
25
27
  }: Parameters): KeyboardEventHandler<HTMLInputElement> => {
26
28
  const handlers: Record<string, KeyboardEventHandler<HTMLInputElement>> = {
27
29
  ArrowUp: onArrowUp,
@@ -31,6 +33,7 @@ const createKeyboardNavigation = ({
31
33
  Backspace: onBackspace,
32
34
  Delete: onDelete,
33
35
  Enter: onEnter,
36
+ ' ': onSpace,
34
37
  };
35
38
 
36
39
  const handleKeyDown: KeyboardEventHandler<HTMLInputElement> = (event) => {
@@ -1,5 +1,5 @@
1
1
  interface AnyFunction {
2
- (...parameters: any): any; // eslint-disable-line @typescript-eslint/no-explicit-any
2
+ (...parameters: any[]): any; // eslint-disable-line @typescript-eslint/no-explicit-any
3
3
  }
4
4
 
5
5
  interface AnyCachedFunction<T extends AnyFunction> extends AnyFunction {
@@ -1,6 +1,6 @@
1
1
  import { AppProps } from 'next/app';
2
2
  import Head from 'next/head';
3
- import React, { FunctionComponent } from 'react';
3
+ import { FunctionComponent } from 'react';
4
4
  import { Provider } from 'react-redux';
5
5
 
6
6
  import { createAppStore } from 'state';
@@ -1,5 +1,5 @@
1
1
  import Document, { Head, Html, Main, NextScript } from 'next/document';
2
- import React, { ReactElement } from 'react';
2
+ import { ReactElement } from 'react';
3
3
 
4
4
  class MyDocument extends Document {
5
5
  render(): ReactElement {
@@ -1,7 +1,7 @@
1
1
  import classNames from 'classnames';
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
- import React, { AnimationEvent, FormEvent, FunctionComponent, useState } from 'react';
4
+ import { AnimationEvent, FormEvent, FunctionComponent, useState } from 'react';
5
5
  import Modal from 'react-modal';
6
6
  import { useDispatch } from 'react-redux';
7
7
  import { useEffectOnce, useMeasure } from 'react-use';
@@ -134,20 +134,11 @@ export const getStaticProps = async (): Promise<{ props: Props }> => {
134
134
  return { props: { version } };
135
135
  };
136
136
 
137
- const readVersion = (): Promise<string> => {
138
- return new Promise((resolve, reject) => {
139
- const packageJsonFilepath = path.resolve(process.cwd(), 'package.json');
140
-
141
- fs.readFile(packageJsonFilepath, 'utf-8', (error, data) => {
142
- if (error) {
143
- reject(error);
144
- return;
145
- }
146
-
147
- const packageJson = JSON.parse(data);
148
- resolve(packageJson.version);
149
- });
150
- });
137
+ const readVersion = async (): Promise<string> => {
138
+ const packageJsonFilepath = path.resolve(process.cwd(), 'package.json');
139
+ const data = await fs.promises.readFile(packageJsonFilepath, 'utf-8');
140
+ const packageJson = JSON.parse(data);
141
+ return packageJson.version;
151
142
  };
152
143
 
153
144
  export default Index;
@@ -15,6 +15,9 @@ html,
15
15
  body {
16
16
  margin: 0 auto;
17
17
  padding: 0;
18
+ }
19
+
20
+ body {
18
21
  background-color: var(--color--background);
19
22
  color: var(--color--foreground);
20
23
  font-family: var(--font--family);
@@ -1,104 +1,70 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
20
- if (ar || !(i in from)) {
21
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
22
- ar[i] = from[i];
23
- }
24
- }
25
- return to.concat(ar || Array.prototype.slice.call(from));
26
- };
27
2
  Object.defineProperty(exports, "__esModule", { value: true });
28
- var constants_1 = require("@scrabble-solver/constants");
29
- var types_1 = require("@scrabble-solver/types");
30
- var PatternsFiller = /** @class */ (function () {
31
- function PatternsFiller(config, trie) {
3
+ const constants_1 = require("@scrabble-solver/constants");
4
+ const types_1 = require("@scrabble-solver/types");
5
+ class PatternsFiller {
6
+ constructor(config, trie) {
32
7
  this.config = config;
33
8
  this.trie = trie;
34
9
  }
35
- PatternsFiller.prototype.fill = function (pattern, tiles) {
36
- var patterns = [];
10
+ fill(pattern, tiles) {
11
+ const patterns = [];
37
12
  if (pattern.getNumberOfEmptyCells() > tiles.length) {
38
13
  return [];
39
14
  }
40
- var onPatternFound = function (newPattern) { return patterns.push(newPattern); };
41
- var tilesPermutations = this.generateBlankTilesPermutations(tiles);
42
- for (var index = 0; index < tilesPermutations.length; ++index) {
43
- var tilesPermutation = tilesPermutations[index];
44
- this.fillPattern(pattern, String(pattern), tilesPermutation, onPatternFound);
15
+ const onPatternFound = (newPattern) => patterns.push(newPattern);
16
+ const tilesPermutations = this.generateBlankTilesPermutations(tiles);
17
+ for (let index = 0; index < tilesPermutations.length; ++index) {
18
+ const tilesPermutation = tilesPermutations[index];
19
+ this.fillPattern(pattern, pattern.toString(), tilesPermutation, onPatternFound);
45
20
  }
46
21
  return patterns;
47
- };
48
- PatternsFiller.prototype.fillPattern = function (pattern, word, tiles, onPatternFound) {
49
- var indexOfFirstCellWithoutTile = pattern.getIndexOfFirstCellWithoutTile();
22
+ }
23
+ fillPattern(pattern, word, tiles, onPatternFound) {
24
+ const indexOfFirstCellWithoutTile = pattern.getIndexOfFirstCellWithoutTile();
50
25
  if (indexOfFirstCellWithoutTile === -1) {
51
26
  if (this.canAddPattern(pattern, word)) {
52
27
  onPatternFound(pattern.clone());
53
28
  }
54
29
  }
55
30
  else {
56
- for (var index = 0; index < tiles.length; ++index) {
57
- var tile = tiles[index];
58
- var remainingTiles = tiles.slice(0, index).concat(tiles.slice(index + 1));
59
- var previousTile = pattern.cells[indexOfFirstCellWithoutTile].tile;
31
+ for (let index = 0; index < tiles.length; ++index) {
32
+ const tile = tiles[index];
33
+ const previousTile = pattern.cells[indexOfFirstCellWithoutTile].tile;
60
34
  pattern.cells[indexOfFirstCellWithoutTile].tile = tile;
61
- var indexOfNextCellWithoutTile = pattern.getIndexOfFirstCellWithoutTile();
62
- var indexOfFirstEmptyLetter = word.indexOf(constants_1.EMPTY_CELL);
63
- var newWordPrefix = word.substring(0, indexOfFirstEmptyLetter) + tile.character;
64
- var newWord = newWordPrefix + word.substring(indexOfFirstEmptyLetter + 1);
35
+ const indexOfNextCellWithoutTile = pattern.getIndexOfFirstCellWithoutTile();
36
+ const indexOfFirstEmptyLetter = word.indexOf(constants_1.EMPTY_CELL);
37
+ const newWordPrefix = word.substring(0, indexOfFirstEmptyLetter) + tile.character;
38
+ const newWord = newWordPrefix + word.substring(indexOfFirstEmptyLetter + 1);
65
39
  if (indexOfNextCellWithoutTile === -1) {
66
40
  if (this.canAddPattern(pattern, newWord)) {
67
41
  onPatternFound(pattern.clone());
68
42
  }
69
43
  }
70
44
  else if (this.trie.hasPrefix(newWordPrefix)) {
71
- this.fillPattern(pattern, newWord, remainingTiles, onPatternFound);
45
+ tiles.splice(index, 1);
46
+ this.fillPattern(pattern, newWord, tiles, onPatternFound);
47
+ tiles.splice(index, 0, tile);
72
48
  }
73
49
  pattern.cells[indexOfFirstCellWithoutTile].tile = previousTile;
74
50
  }
75
51
  }
76
- };
77
- PatternsFiller.prototype.canAddPattern = function (pattern, word) {
78
- var _this = this;
79
- return (this.trie.has(word) &&
80
- pattern
81
- .getCollisions()
82
- .map(String)
83
- .every(function (collision) { return _this.trie.has(collision); }));
84
- };
85
- PatternsFiller.prototype.generateBlankTilesPermutations = function (tiles) {
86
- var _this = this;
87
- var alphabet = this.config.alphabet;
88
- var firstBlankIndex = tiles.findIndex(function (_a) {
89
- var character = _a.character, isBlank = _a.isBlank;
90
- return isBlank && !alphabet.includes(character);
91
- });
52
+ }
53
+ canAddPattern(pattern, word) {
54
+ return this.trie.has(word) && pattern.getCollisions().every((collision) => this.trie.has(collision.toString()));
55
+ }
56
+ generateBlankTilesPermutations(tiles) {
57
+ const { alphabet } = this.config;
58
+ const firstBlankIndex = tiles.findIndex(({ character, isBlank }) => isBlank && !alphabet.includes(character));
92
59
  if (firstBlankIndex === -1) {
93
60
  return [tiles];
94
61
  }
95
- var remainingTiles = tiles.slice(0, firstBlankIndex).concat(tiles.slice(firstBlankIndex + 1));
96
- return this.config.alphabet.reduce(function (permutations, character) {
97
- var newTile = new types_1.Tile({ character: character, isBlank: true });
98
- var newTiles = __spreadArray(__spreadArray([], __read(remainingTiles), false), [newTile], false);
99
- return permutations.concat(_this.generateBlankTilesPermutations(newTiles));
62
+ const remainingTiles = tiles.slice(0, firstBlankIndex).concat(tiles.slice(firstBlankIndex + 1));
63
+ return this.config.alphabet.reduce((permutations, character) => {
64
+ const newTile = new types_1.Tile({ character, isBlank: true });
65
+ const newTiles = [...remainingTiles, newTile];
66
+ return permutations.concat(this.generateBlankTilesPermutations(newTiles));
100
67
  }, []);
101
- };
102
- return PatternsFiller;
103
- }());
68
+ }
69
+ }
104
70
  exports.default = PatternsFiller;