@scrabble-solver/scrabble-solver 2.8.6 → 2.8.8

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 (101) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +10 -10
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/eslint/.cache_8dgz12 +1 -1
  5. package/.next/cache/next-server.js.nft.json +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/.next/next-server.js.nft.json +1 -1
  11. package/.next/prerender-manifest.json +1 -1
  12. package/.next/routes-manifest.json +1 -1
  13. package/.next/server/chunks/413.js +266 -110
  14. package/.next/server/chunks/{206.js → 429.js} +2 -4137
  15. package/.next/server/chunks/515.js +197 -91
  16. package/.next/server/chunks/{907.js → 911.js} +134 -367
  17. package/.next/server/chunks/939.js +218 -0
  18. package/.next/server/middleware-build-manifest.js +1 -1
  19. package/.next/server/pages/404.html +2 -2
  20. package/.next/server/pages/404.js.nft.json +1 -1
  21. package/.next/server/pages/500.html +2 -2
  22. package/.next/server/pages/_app.js.nft.json +1 -1
  23. package/.next/server/pages/api/dictionary/[locale]/[word].js +33 -17
  24. package/.next/server/pages/api/dictionary/[locale]/[word].js.nft.json +1 -1
  25. package/.next/server/pages/api/solve.js +399 -56
  26. package/.next/server/pages/api/solve.js.nft.json +1 -1
  27. package/.next/server/pages/api/visit.js +3 -2
  28. package/.next/server/pages/api/visit.js.nft.json +1 -1
  29. package/.next/server/pages/index.html +3 -7
  30. package/.next/server/pages/index.js +12 -14
  31. package/.next/server/pages/index.js.nft.json +1 -1
  32. package/.next/server/pages/index.json +1 -1
  33. package/.next/static/chunks/615-d258f6c528c18622.js +1 -0
  34. package/.next/static/chunks/pages/{404-30c06e61d256c5b2.js → 404-8eb3ba4f0ba17e08.js} +1 -1
  35. package/.next/static/chunks/pages/_app-4a663fd3d5ca4524.js +1 -0
  36. package/.next/static/chunks/pages/index-1a9826d740cc8830.js +1 -0
  37. package/.next/static/css/180c6c26317ac90f.css +1 -0
  38. package/.next/static/css/751e8a14776d05d8.css +1 -0
  39. package/.next/static/z3J3qmq1nazbDv_ENIkCo/_buildManifest.js +1 -0
  40. package/.next/static/{VjSpyGDWyVaO0muz54q_j → z3J3qmq1nazbDv_ENIkCo}/_ssgManifest.js +0 -0
  41. package/.next/trace +41 -42
  42. package/package.json +9 -9
  43. package/src/api/index.ts +3 -9
  44. package/src/api/isBoardValid.ts +43 -0
  45. package/src/api/isCellValid.ts +26 -0
  46. package/src/api/isRowValid.ts +19 -0
  47. package/src/components/Board/components/Cell/Cell.module.scss +34 -9
  48. package/src/components/Board/components/Cell/Cell.tsx +23 -4
  49. package/src/components/Board/components/Cell/CellPure.tsx +29 -1
  50. package/src/components/Board/hooks/useGrid.ts +1 -0
  51. package/src/components/Dictionary/Dictionary.module.scss +20 -0
  52. package/src/components/Dictionary/Dictionary.tsx +40 -29
  53. package/src/components/Results/Cell.tsx +3 -2
  54. package/src/components/Results/Result.tsx +16 -6
  55. package/src/components/ResultsInput/ResultsInput.tsx +11 -3
  56. package/src/hooks/useIsTablet.ts +2 -2
  57. package/src/i18n/de.json +1 -0
  58. package/src/i18n/en.json +1 -0
  59. package/src/i18n/es.json +1 -0
  60. package/src/i18n/fr.json +1 -0
  61. package/src/i18n/pl.json +1 -0
  62. package/src/icons/Flag.svg +4 -0
  63. package/src/icons/Star.svg +4 -0
  64. package/src/icons/index.ts +2 -0
  65. package/src/lib/getRemainingTiles.ts +1 -1
  66. package/src/lib/index.ts +2 -1
  67. package/src/lib/isRegExp.ts +11 -0
  68. package/src/lib/isStringArray.ts +5 -0
  69. package/src/lib/sortResults.ts +5 -5
  70. package/src/pages/api/dictionary/[locale]/[word].ts +35 -11
  71. package/src/pages/api/solve.ts +39 -19
  72. package/src/pages/api/visit.ts +1 -0
  73. package/src/pages/index.module.scss +5 -11
  74. package/src/pages/index.tsx +5 -5
  75. package/src/sdk/{findWordDefinition.ts → findWordDefinitions.ts} +3 -3
  76. package/src/sdk/index.ts +1 -1
  77. package/src/state/rootReducer.ts +10 -1
  78. package/src/state/sagas.ts +32 -12
  79. package/src/state/selectors.ts +41 -7
  80. package/src/state/slices/cellFilterInitialState.ts +7 -0
  81. package/src/state/slices/cellFilterSlice.ts +24 -0
  82. package/src/state/slices/dictionaryInitialState.ts +3 -3
  83. package/src/state/slices/dictionarySlice.ts +4 -10
  84. package/src/state/slices/index.ts +2 -0
  85. package/src/types/index.ts +1 -0
  86. package/.next/static/VjSpyGDWyVaO0muz54q_j/_buildManifest.js +0 -1
  87. package/.next/static/chunks/56-e2797384ae4b0fc0.js +0 -1
  88. package/.next/static/chunks/pages/_app-5136d33b9b007fd7.js +0 -1
  89. package/.next/static/chunks/pages/index-13ea7770a65c69ee.js +0 -1
  90. package/.next/static/css/3159cfe62ff742a3.css +0 -1
  91. package/.next/static/css/729bb37fe8f9bee6.css +0 -1
  92. package/src/api/validateBoard.ts +0 -45
  93. package/src/api/validateCell.ts +0 -40
  94. package/src/api/validateCharacter.ts +0 -14
  95. package/src/api/validateCharacters.ts +0 -24
  96. package/src/api/validateConfigId.ts +0 -9
  97. package/src/api/validateLocale.ts +0 -15
  98. package/src/api/validateRow.ts +0 -17
  99. package/src/api/validateTile.ts +0 -21
  100. package/src/api/validateWord.ts +0 -11
  101. package/src/lib/isLocale.ts +0 -7
@@ -1,45 +0,0 @@
1
- import { CellJson, Config } from '@scrabble-solver/types';
2
-
3
- import validateRow from './validateRow';
4
-
5
- const validateBoard = (board: unknown, config: Config): void => {
6
- if (!Array.isArray(board)) {
7
- throw new Error('Invalid "board" parameter: not an array');
8
- }
9
-
10
- if (board.length !== config.boardHeight) {
11
- throw new Error(`Invalid "board" parameter: does not have ${config.boardHeight} rows`);
12
- }
13
-
14
- try {
15
- board.forEach((row, rowIndex) => validateRow(row, rowIndex, config));
16
- validateTwoCharacterTiles(board, config);
17
- } catch (error) {
18
- const message = error instanceof Error ? error.message : 'unknown';
19
- throw new Error(`Invalid "board" parameter: ${message}`);
20
- }
21
- };
22
-
23
- const validateTwoCharacterTiles = (board: CellJson[][], config: Config): void => {
24
- const cells: CellJson[] = board
25
- .flat()
26
- .filter((cell) => cell.tile && config.isTwoCharacterTilePrefix(cell.tile.character));
27
-
28
- for (const cell of cells) {
29
- for (const characters of config.twoCharacterTiles) {
30
- const canCheckDown = cell.y + 1 < board.length;
31
- const canCheckRight = cell.x + 1 < board[0].length;
32
- const cellDown = board[cell.y + 1][cell.x];
33
- const cellRight = board[cell.y][cell.x + 1];
34
- const collidesDown = canCheckDown && cellDown.tile && cellDown.tile.character === characters[1];
35
- const collidesRight = canCheckRight && cellRight.tile && cellRight.tile.character === characters[1];
36
- const collides = collidesDown || collidesRight;
37
-
38
- if (cell.tile && characters.startsWith(cell.tile.character) && collides) {
39
- throw new Error(`${characters} can only be used as a single tile`);
40
- }
41
- }
42
- }
43
- };
44
-
45
- export default validateBoard;
@@ -1,40 +0,0 @@
1
- import { Config } from '@scrabble-solver/types';
2
-
3
- import validateTile from './validateTile';
4
-
5
- const validateCell = (cell: unknown, rowIndex: number, cellIndex: number, config: Config): void => {
6
- if (typeof cell !== 'object') {
7
- throw new Error(`board[${rowIndex}][${cellIndex}] is not an object`);
8
- }
9
-
10
- const { x, y, tile, isEmpty } = cell as Record<string, unknown>;
11
-
12
- if (typeof x !== 'number') {
13
- throw new Error(`board[${rowIndex}][${cellIndex}].x is not a number`);
14
- }
15
-
16
- if (x < 0 || x >= config.boardWidth) {
17
- throw new Error(`board[${rowIndex}][${cellIndex}].x is out of bounds`);
18
- }
19
-
20
- if (typeof y !== 'number') {
21
- throw new Error(`board[${rowIndex}][${cellIndex}].y is not a number`);
22
- }
23
-
24
- if (y < 0 || y >= config.boardHeight) {
25
- throw new Error(`board[${rowIndex}][${cellIndex}].y is out of bounds`);
26
- }
27
-
28
- if (typeof isEmpty !== 'boolean') {
29
- throw new Error(`board[${rowIndex}][${cellIndex}].isEmpty is not a boolean`);
30
- }
31
-
32
- try {
33
- validateTile(tile, config);
34
- } catch (error) {
35
- const message = error instanceof Error ? error.message : 'unknown';
36
- throw new Error(`board[${rowIndex}][${cellIndex}].tile ${message}`);
37
- }
38
- };
39
-
40
- export default validateCell;
@@ -1,14 +0,0 @@
1
- import { BLANK } from '@scrabble-solver/constants';
2
- import { Config } from '@scrabble-solver/types';
3
-
4
- const validateCharacter = (character: unknown, config: Config): void => {
5
- if (typeof character !== 'string') {
6
- throw new Error('character is not a string');
7
- }
8
-
9
- if (!config.hasCharacter(character) && character !== BLANK) {
10
- throw new Error('character is not valid');
11
- }
12
- };
13
-
14
- export default validateCharacter;
@@ -1,24 +0,0 @@
1
- import { Config } from '@scrabble-solver/types';
2
-
3
- import validateCharacter from './validateCharacter';
4
-
5
- const validateCharacters = (characters: unknown, config: Config): void => {
6
- if (!Array.isArray(characters)) {
7
- throw new Error('Invalid "characters" parameter: not an array');
8
- }
9
-
10
- if (characters.length === 0) {
11
- throw new Error('Invalid "characters" parameter: empty array');
12
- }
13
-
14
- characters.forEach((character, characterIndex) => {
15
- try {
16
- validateCharacter(character, config);
17
- } catch (error) {
18
- const message = error instanceof Error ? error.message : 'unknown';
19
- throw new Error(`Invalid "characters" parameter: characters[${characterIndex}] ${message}`);
20
- }
21
- });
22
- };
23
-
24
- export default validateCharacters;
@@ -1,9 +0,0 @@
1
- import { isConfigId } from '@scrabble-solver/configs';
2
-
3
- const validateConfigId = (configId: unknown): void => {
4
- if (!isConfigId(configId)) {
5
- throw new Error('Invalid "configId" parameter');
6
- }
7
- };
8
-
9
- export default validateConfigId;
@@ -1,15 +0,0 @@
1
- import { Locale } from '@scrabble-solver/types';
2
-
3
- const locales = Object.values(Locale);
4
-
5
- const validateLocale = (locale: unknown): void => {
6
- if (typeof locale !== 'string') {
7
- throw new Error('Invalid "locale" parameter: not a string');
8
- }
9
-
10
- if (!locales.includes(locale as Locale)) {
11
- throw new Error(`Invalid "locale" parameter: must be one of: ${locales.join(', ')}`);
12
- }
13
- };
14
-
15
- export default validateLocale;
@@ -1,17 +0,0 @@
1
- import { Config } from '@scrabble-solver/types';
2
-
3
- import validateCell from './validateCell';
4
-
5
- const validateRow = (row: unknown, rowIndex: number, config: Config): void => {
6
- if (!Array.isArray(row)) {
7
- throw new Error(`board[${rowIndex}] is not an array`);
8
- }
9
-
10
- if (row.length !== config.boardWidth) {
11
- throw new Error(`board[${rowIndex}] does not have ${config.boardWidth} cells`);
12
- }
13
-
14
- row.forEach((cell, cellIndex) => validateCell(cell, rowIndex, cellIndex, config));
15
- };
16
-
17
- export default validateRow;
@@ -1,21 +0,0 @@
1
- import { Config } from '@scrabble-solver/types';
2
-
3
- import validateCharacter from './validateCharacter';
4
-
5
- const validateTile = (tile: unknown, config: Config): void => {
6
- if (typeof tile !== 'object') {
7
- throw new Error('is not an object');
8
- }
9
-
10
- if (tile !== null) {
11
- const { character, isBlank } = tile as Record<string, unknown>;
12
-
13
- validateCharacter(character, config);
14
-
15
- if (typeof isBlank !== 'boolean') {
16
- throw new Error('isBlank is not a boolean');
17
- }
18
- }
19
- };
20
-
21
- export default validateTile;
@@ -1,11 +0,0 @@
1
- const validateWord = (word: unknown): void => {
2
- if (typeof word !== 'string') {
3
- throw new Error('"word" is not a string');
4
- }
5
-
6
- if (word.length === 0) {
7
- throw new Error('"word" is an empty string');
8
- }
9
- };
10
-
11
- export default validateWord;
@@ -1,7 +0,0 @@
1
- import { Locale } from '@scrabble-solver/types';
2
-
3
- const locales = Object.values(Locale);
4
-
5
- const isLocale = (locale: unknown): locale is Locale => locales.includes(locale as Locale);
6
-
7
- export default isLocale;