scrabble-solver 2.15.22 → 2.15.24
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.
- package/.claude/settings.local.json +17 -1
- package/.github/workflows/oxfmt.yml +20 -0
- package/.nx/workspace-data/file-map.json +967 -963
- package/.nx/workspace-data/lockfile-dependencies.hash +1 -1
- package/.nx/workspace-data/lockfile-nodes.hash +1 -1
- package/.nx/workspace-data/nx_files.nxt +0 -0
- package/.nx/workspace-data/parsed-lock-file.dependencies.json +107 -57
- package/.nx/workspace-data/parsed-lock-file.nodes.json +316 -156
- package/.nx/workspace-data/project-graph.json +412 -222
- package/.oxfmtrc.json +17 -0
- package/README.md +2 -1
- package/cypress/e2e/bugs/401-board-state-on-game-change.ts +36 -0
- package/cypress/e2e/bugs.spec.cy.ts +1 -0
- package/jest.config.js +5 -0
- package/lerna.json +1 -1
- package/package.json +13 -14
- package/packages/configs/package.json +3 -3
- package/packages/constants/package.json +1 -1
- package/packages/dictionaries/package.json +4 -4
- package/packages/logger/package.json +1 -1
- package/packages/scrabble-solver/.next/BUILD_ID +1 -1
- package/packages/scrabble-solver/.next/build-manifest.json +12 -12
- package/packages/scrabble-solver/.next/cache/.previewinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.rscinfo +1 -1
- package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
- package/packages/scrabble-solver/.next/cache/webpack/client-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/client-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/edge-server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack.old +0 -0
- package/packages/scrabble-solver/.next/diagnostics/framework.json +1 -1
- package/packages/scrabble-solver/.next/prerender-manifest.json +4 -4
- package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/chunks/712.js +1 -1
- package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/500.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.html +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/not-found.html +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{framework-906c47013125d174.js → framework-f7982db529c0590c.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/{main-f63f5bd5e9581250.js → main-ca07941c8a544c9a.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/{_app-6a68c941d55599c8.js → _app-369e5cb907606ad4.js} +5 -5
- package/packages/scrabble-solver/.next/static/chunks/pages/{index-6c5b582e7afc063c.js → index-08b3b0a754095919.js} +1 -1
- package/packages/scrabble-solver/.next/static/{MxQ5rcf448WOpfCa2_VVz → f_g0t0jBAscXxDrNYOuV0}/_buildManifest.js +1 -1
- package/packages/scrabble-solver/.next/trace +21 -21
- package/packages/scrabble-solver/.next/trace-build +1 -1
- package/packages/scrabble-solver/package.json +11 -11
- package/packages/scrabble-solver/public/service-worker.js +1 -1
- package/packages/scrabble-solver/src/app-layout/useAppLayoutValue.ts +4 -4
- package/packages/scrabble-solver/src/components/Alert/Alert.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/Board.tsx +4 -4
- package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +4 -4
- package/packages/scrabble-solver/src/components/Board/components/Actions/Actions.tsx +5 -5
- package/packages/scrabble-solver/src/components/Board/components/Actions/lib.ts +2 -2
- package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/InputPrompt/InputPrompt.tsx +3 -3
- package/packages/scrabble-solver/src/components/Board/components/ToggleDirectionButton/ToggleDirectionButton.tsx +4 -4
- package/packages/scrabble-solver/src/components/Board/hooks/useBackgroundImage.tsx +235 -172
- package/packages/scrabble-solver/src/components/Board/hooks/useBoardStyle.ts +4 -4
- package/packages/scrabble-solver/src/components/Board/hooks/useFloatingActions.ts +2 -2
- package/packages/scrabble-solver/src/components/Board/hooks/useFloatingInputPrompt.ts +1 -1
- package/packages/scrabble-solver/src/components/Board/hooks/useGrid.ts +5 -5
- package/packages/scrabble-solver/src/components/Board/lib.ts +2 -2
- package/packages/scrabble-solver/src/components/Board/selectors.ts +2 -2
- package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +2 -2
- package/packages/scrabble-solver/src/components/DictionaryInput/DictionaryInput.tsx +2 -2
- package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +13 -5
- package/packages/scrabble-solver/src/components/Keys/Arrows/Arrows.tsx +1 -1
- package/packages/scrabble-solver/src/components/Keys/index.tsx +2 -2
- package/packages/scrabble-solver/src/components/Loading/Loading.tsx +2 -2
- package/packages/scrabble-solver/src/components/Logo/Logo.tsx +2 -2
- package/packages/scrabble-solver/src/components/Modal/Modal.tsx +3 -3
- package/packages/scrabble-solver/src/components/NavButtons/NavButtons.tsx +4 -4
- package/packages/scrabble-solver/src/components/NavButtons/selectors.ts +1 -1
- package/packages/scrabble-solver/src/components/NotFound/NotFound.tsx +1 -1
- package/packages/scrabble-solver/src/components/PlainTiles/lib.ts +1 -1
- package/packages/scrabble-solver/src/components/Progress/Progress.tsx +2 -2
- package/packages/scrabble-solver/src/components/Rack/Rack.tsx +4 -4
- package/packages/scrabble-solver/src/components/Rack/components/InputPrompt/InputPrompt.tsx +2 -2
- package/packages/scrabble-solver/src/components/Rack/components/InputPrompt/lib.ts +1 -3
- package/packages/scrabble-solver/src/components/Rack/components/RackTile/RackTile.tsx +2 -2
- package/packages/scrabble-solver/src/components/Rack/selectors.ts +2 -2
- package/packages/scrabble-solver/src/components/Results/Cell.tsx +2 -2
- package/packages/scrabble-solver/src/components/Results/Header.tsx +5 -5
- package/packages/scrabble-solver/src/components/Results/HeaderButton.tsx +3 -3
- package/packages/scrabble-solver/src/components/Results/Result.tsx +6 -6
- package/packages/scrabble-solver/src/components/Results/Results.tsx +4 -4
- package/packages/scrabble-solver/src/components/Results/SolveButton.tsx +2 -2
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.tsx +2 -2
- package/packages/scrabble-solver/src/components/Solver/Solver.tsx +3 -3
- package/packages/scrabble-solver/src/components/Solver/components/InsertButton/InsertButton.tsx +2 -2
- package/packages/scrabble-solver/src/components/Solver/components/ResultCandidatePicker/ResultCandidatePicker.tsx +2 -2
- package/packages/scrabble-solver/src/components/Spinner/Spinner.tsx +1 -1
- package/packages/scrabble-solver/src/components/Tile/Tile.tsx +3 -3
- package/packages/scrabble-solver/src/components/Tile/TilePure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Tooltip/TooltipContent.tsx +1 -1
- package/packages/scrabble-solver/src/hooks/useColumns.ts +3 -3
- package/packages/scrabble-solver/src/hooks/useDirection.ts +1 -1
- package/packages/scrabble-solver/src/hooks/useLanguage.ts +1 -1
- package/packages/scrabble-solver/src/hooks/useLocalStorage.ts +1 -1
- package/packages/scrabble-solver/src/hooks/useMediaQuery.ts +1 -1
- package/packages/scrabble-solver/src/i18n/constants.ts +1 -1
- package/packages/scrabble-solver/src/i18n/i18n.ts +1 -1
- package/packages/scrabble-solver/src/i18n/languages/english.json +1 -1
- package/packages/scrabble-solver/src/i18n/languages/french.json +1 -1
- package/packages/scrabble-solver/src/i18n/languages/german.json +1 -1
- package/packages/scrabble-solver/src/i18n/languages/polish.json +1 -1
- package/packages/scrabble-solver/src/i18n/languages/romanian.json +1 -1
- package/packages/scrabble-solver/src/i18n/languages/spanish.json +1 -1
- package/packages/scrabble-solver/src/i18n/languages/turkish.json +1 -1
- package/packages/scrabble-solver/src/lib/createComparator.ts +1 -1
- package/packages/scrabble-solver/src/lib/createKeyComparator.ts +1 -1
- package/packages/scrabble-solver/src/lib/createStringComparator.ts +1 -1
- package/packages/scrabble-solver/src/lib/getTileSizes.ts +1 -1
- package/packages/scrabble-solver/src/lib/numberComparator.ts +1 -1
- package/packages/scrabble-solver/src/lib/reverseComparator.ts +1 -1
- package/packages/scrabble-solver/src/lib/zipCharactersAndTiles.ts +1 -1
- package/packages/scrabble-solver/src/modals/DictionaryModal/DictionaryModal.tsx +2 -2
- package/packages/scrabble-solver/src/modals/KeyMapModal/KeyMapModal.tsx +2 -2
- package/packages/scrabble-solver/src/modals/MenuModal/MenuModal.tsx +5 -5
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/RemainingTilesModal.tsx +5 -5
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/components/Character/Character.tsx +5 -5
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/lib.ts +1 -1
- package/packages/scrabble-solver/src/modals/RemainingTilesModal/selectors.ts +1 -1
- package/packages/scrabble-solver/src/modals/ResultsModal/ResultsModal.tsx +4 -4
- package/packages/scrabble-solver/src/modals/SettingsModal/SettingsModal.tsx +3 -3
- package/packages/scrabble-solver/src/modals/SettingsModal/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +2 -2
- package/packages/scrabble-solver/src/modals/SettingsModal/components/AutoGroupTilesSetting/lib.ts +1 -1
- package/packages/scrabble-solver/src/modals/SettingsModal/components/ConfigSetting/ConfigSetting.tsx +2 -2
- package/packages/scrabble-solver/src/modals/SettingsModal/components/InputModeSetting/InputModeSetting.tsx +2 -2
- package/packages/scrabble-solver/src/modals/SettingsModal/components/InputModeSetting/lib.ts +1 -1
- package/packages/scrabble-solver/src/modals/SettingsModal/components/LocaleSetting/LocaleSetting.tsx +3 -3
- package/packages/scrabble-solver/src/modals/SettingsModal/components/RemoveCellFiltersSetting/RemoveCellFiltersSetting.tsx +2 -2
- package/packages/scrabble-solver/src/modals/SettingsModal/components/RemoveCellFiltersSetting/lib.ts +1 -1
- package/packages/scrabble-solver/src/modals/SettingsModal/components/ShowCoordinatesSetting/ShowCoordinatesSetting.tsx +2 -2
- package/packages/scrabble-solver/src/modals/WordsModal/WordsModal.tsx +3 -3
- package/packages/scrabble-solver/src/pages/_app.tsx +3 -3
- package/packages/scrabble-solver/src/pages/api/dictionary/[locale]/[word].ts +1 -1
- package/packages/scrabble-solver/src/pages/api/dictionary/[locale]/index.ts +1 -1
- package/packages/scrabble-solver/src/pages/api/solve.ts +2 -2
- package/packages/scrabble-solver/src/pages/api/verify.ts +1 -1
- package/packages/scrabble-solver/src/pages/api/visit.ts +1 -1
- package/packages/scrabble-solver/src/pages/index.tsx +6 -6
- package/packages/scrabble-solver/src/pages/not-found.tsx +1 -1
- package/packages/scrabble-solver/src/parameters/index.ts +1 -1
- package/packages/scrabble-solver/src/service-worker/routeSolveRequests.ts +1 -1
- package/packages/scrabble-solver/src/service-worker/routeVerifyRequests.ts +1 -1
- package/packages/scrabble-solver/src/state/board/slice.ts +24 -1
- package/packages/scrabble-solver/src/state/cellFilters/lib.ts +1 -1
- package/packages/scrabble-solver/src/state/cellFilters/selectors.ts +1 -1
- package/packages/scrabble-solver/src/state/cellFilters/slice.ts +1 -1
- package/packages/scrabble-solver/src/state/cellFilters/types.ts +1 -1
- package/packages/scrabble-solver/src/state/lib.ts +2 -2
- package/packages/scrabble-solver/src/state/localStorage.ts +1 -1
- package/packages/scrabble-solver/src/state/rack/slice.ts +2 -2
- package/packages/scrabble-solver/src/state/rack/types.ts +1 -1
- package/packages/scrabble-solver/src/state/results/initialState.ts +1 -1
- package/packages/scrabble-solver/src/state/results/lib.ts +9 -2
- package/packages/scrabble-solver/src/state/results/selectors.ts +1 -1
- package/packages/scrabble-solver/src/state/results/slice.ts +1 -1
- package/packages/scrabble-solver/src/state/results/types.ts +1 -1
- package/packages/scrabble-solver/src/state/sagas.ts +3 -3
- package/packages/scrabble-solver/src/state/selectors.ts +1 -1
- package/packages/scrabble-solver/src/state/settings/selectors.ts +1 -1
- package/packages/scrabble-solver/src/state/settings/slice.ts +1 -1
- package/packages/scrabble-solver/src/state/settings/types.ts +1 -1
- package/packages/scrabble-solver/src/state/useTranslate.ts +1 -1
- package/packages/scrabble-solver/tsconfig.json +1 -15
- package/packages/scrabble-solver/tsconfig.tsbuildinfo +1 -1
- package/packages/solver/package.json +5 -5
- package/packages/solver/src/getPatternScore.test.ts +52 -4
- package/packages/types/package.json +2 -2
- package/packages/word-definitions/package.json +3 -3
- package/packages/word-lists/package.json +3 -3
- package/tsconfig.jest.json +5 -1
- package/.prettierignore +0 -8
- package/.prettierrc +0 -11
- /package/packages/scrabble-solver/.next/static/{MxQ5rcf448WOpfCa2_VVz → f_g0t0jBAscXxDrNYOuV0}/_ssgManifest.js +0 -0
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/* eslint-disable max-lines, max-statements */
|
|
2
2
|
|
|
3
3
|
import { BONUS_CHARACTER, BONUS_WORD } from '@scrabble-solver/constants';
|
|
4
|
-
import { useMemo } from 'react';
|
|
4
|
+
import { useCallback, useMemo } from 'react';
|
|
5
5
|
import { renderToString } from 'react-dom/server';
|
|
6
6
|
import { Provider } from 'react-redux';
|
|
7
7
|
|
|
8
|
-
import { useAppLayout } from 'app-layout';
|
|
9
|
-
import { useMediaQueries } from 'hooks';
|
|
10
|
-
import { LOCALE_FEATURES } from 'i18n';
|
|
11
|
-
import { Star } from 'icons';
|
|
12
|
-
import { getTileSizes } from 'lib';
|
|
13
|
-
import { BORDER_COLOR_LIGHT, BORDER_RADIUS, BORDER_WIDTH, COLOR_BACKGROUND, COLOR_BONUS_START } from 'parameters';
|
|
14
|
-
import { selectConfig, selectLocale, selectShowCoordinates, store, useTypedSelector } from 'state';
|
|
15
|
-
import { type Point } from 'types';
|
|
8
|
+
import { useAppLayout } from '@/app-layout';
|
|
9
|
+
import { useMediaQueries } from '@/hooks';
|
|
10
|
+
import { LOCALE_FEATURES } from '@/i18n';
|
|
11
|
+
import { Star } from '@/icons';
|
|
12
|
+
import { getTileSizes } from '@/lib';
|
|
13
|
+
import { BORDER_COLOR_LIGHT, BORDER_RADIUS, BORDER_WIDTH, COLOR_BACKGROUND, COLOR_BONUS_START } from '@/parameters';
|
|
14
|
+
import { selectConfig, selectLocale, selectShowCoordinates, store, useTypedSelector } from '@/state';
|
|
15
|
+
import { type Point } from '@/types';
|
|
16
16
|
|
|
17
17
|
import { getBonusColor } from '../lib';
|
|
18
18
|
|
|
@@ -33,7 +33,10 @@ export const useBackgroundImage = () => {
|
|
|
33
33
|
const { isLessThanXs } = useMediaQueries();
|
|
34
34
|
const borderRadius = isLessThanXs ? BORDER_RADIUS_XS : BORDER_RADIUS;
|
|
35
35
|
const config = useTypedSelector(selectConfig);
|
|
36
|
-
const center =
|
|
36
|
+
const center = useMemo(
|
|
37
|
+
() => ({ x: Math.floor(config.boardWidth / 2), y: Math.floor(config.boardHeight / 2) }),
|
|
38
|
+
[config.boardHeight, config.boardWidth],
|
|
39
|
+
);
|
|
37
40
|
const viewBoxHeight = boardHeight;
|
|
38
41
|
const viewBoxWidth = boardWidth;
|
|
39
42
|
const bonusSize = cellSize * 0.8;
|
|
@@ -43,174 +46,234 @@ export const useBackgroundImage = () => {
|
|
|
43
46
|
const { tileFontSize } = getTileSizes(cellSize);
|
|
44
47
|
const fontSize = tileFontSize * 0.6;
|
|
45
48
|
const fontOffset = cellSize / 2;
|
|
46
|
-
const characterBonuses =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
49
|
+
const characterBonuses = useMemo(
|
|
50
|
+
() => config.bonuses.filter((bonus) => bonus.type === BONUS_CHARACTER),
|
|
51
|
+
[config.bonuses],
|
|
52
|
+
);
|
|
53
|
+
const word2Bonuses = useMemo(
|
|
54
|
+
() => config.bonuses.filter((bonus) => bonus.type === BONUS_WORD && bonus.multiplier === 2),
|
|
55
|
+
[config.bonuses],
|
|
56
|
+
);
|
|
57
|
+
const word3Bonuses = useMemo(
|
|
58
|
+
() => config.bonuses.filter((bonus) => bonus.type === BONUS_WORD && bonus.multiplier === 3),
|
|
59
|
+
[config.bonuses],
|
|
60
|
+
);
|
|
61
|
+
const word4Bonuses = useMemo(
|
|
62
|
+
() => config.bonuses.filter((bonus) => bonus.type === BONUS_WORD && bonus.multiplier === 4),
|
|
63
|
+
[config.bonuses],
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const getX = useCallback(
|
|
67
|
+
(point: Point): number => (direction === 'ltr' ? coordinatesSize : 0) + point.x * (cellSize + BORDER_WIDTH),
|
|
68
|
+
[coordinatesSize, cellSize, direction],
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const getY = useCallback(
|
|
72
|
+
(point: Point): number => coordinatesSize + point.y * (cellSize + BORDER_WIDTH),
|
|
73
|
+
[coordinatesSize, cellSize],
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const backgroundSvg = useMemo(
|
|
77
|
+
() =>
|
|
78
|
+
renderToString(
|
|
79
|
+
<Provider store={store}>
|
|
80
|
+
<svg
|
|
81
|
+
height={viewBoxHeight}
|
|
82
|
+
viewBox={`0 0 ${viewBoxWidth} ${viewBoxHeight}`}
|
|
83
|
+
width={viewBoxWidth}
|
|
84
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
85
|
+
>
|
|
86
|
+
<defs>
|
|
87
|
+
<symbol id={HORIZONTAL_LINE}>
|
|
88
|
+
<rect fill={BORDER_COLOR_LIGHT} height={GRID_LINE_SIZE} width={viewBoxWidth} />
|
|
89
|
+
</symbol>
|
|
90
|
+
|
|
91
|
+
<symbol id={VERTICAL_LINE}>
|
|
92
|
+
<rect fill={BORDER_COLOR_LIGHT} height={viewBoxHeight} width={GRID_LINE_SIZE} />
|
|
93
|
+
</symbol>
|
|
94
|
+
|
|
95
|
+
<symbol id={BONUS}>
|
|
96
|
+
<rect height={bonusSize} rx={borderRadius} width={bonusSize} x={bonusOffset} y={bonusOffset} />
|
|
97
|
+
</symbol>
|
|
98
|
+
|
|
99
|
+
<symbol id={BONUS_WORD_2}>
|
|
100
|
+
<rect height={bonusSize} rx={borderRadius} width={bonusSize} x={bonusOffset} y={bonusOffset} />
|
|
101
|
+
|
|
102
|
+
<text
|
|
103
|
+
dominantBaseline="central"
|
|
104
|
+
fill="white"
|
|
105
|
+
fontFamily="system-ui, sans-serif"
|
|
106
|
+
fontSize={fontSize}
|
|
107
|
+
fontWeight="bold"
|
|
108
|
+
textAnchor="middle"
|
|
109
|
+
x={fontOffset}
|
|
110
|
+
y={fontOffset}
|
|
111
|
+
>
|
|
112
|
+
×2
|
|
113
|
+
</text>
|
|
114
|
+
</symbol>
|
|
115
|
+
|
|
116
|
+
<symbol id={BONUS_WORD_3}>
|
|
117
|
+
<rect height={bonusSize} rx={borderRadius} width={bonusSize} x={bonusOffset} y={bonusOffset} />
|
|
118
|
+
|
|
119
|
+
<text
|
|
120
|
+
dominantBaseline="central"
|
|
121
|
+
fill="white"
|
|
122
|
+
fontFamily="system-ui, sans-serif"
|
|
123
|
+
fontSize={fontSize}
|
|
124
|
+
fontWeight="bold"
|
|
125
|
+
textAnchor="middle"
|
|
126
|
+
x={fontOffset}
|
|
127
|
+
y={fontOffset}
|
|
128
|
+
>
|
|
129
|
+
×3
|
|
130
|
+
</text>
|
|
131
|
+
</symbol>
|
|
132
|
+
|
|
133
|
+
<symbol id={BONUS_WORD_4}>
|
|
134
|
+
<rect height={bonusSize} rx={borderRadius} width={bonusSize} x={bonusOffset} y={bonusOffset} />
|
|
135
|
+
|
|
136
|
+
<text
|
|
137
|
+
dominantBaseline="central"
|
|
138
|
+
fill="white"
|
|
139
|
+
fontFamily="system-ui, sans-serif"
|
|
140
|
+
fontSize={fontSize}
|
|
141
|
+
fontWeight="bold"
|
|
142
|
+
textAnchor="middle"
|
|
143
|
+
x={fontOffset}
|
|
144
|
+
y={fontOffset}
|
|
145
|
+
>
|
|
146
|
+
×4
|
|
147
|
+
</text>
|
|
148
|
+
</symbol>
|
|
149
|
+
</defs>
|
|
150
|
+
|
|
151
|
+
{showCoordinates === 'hidden' && (
|
|
152
|
+
<rect fill="white" height={viewBoxHeight} rx={borderRadius} width={viewBoxWidth} x="0" y="0" />
|
|
153
|
+
)}
|
|
154
|
+
|
|
155
|
+
{showCoordinates !== 'hidden' && (
|
|
156
|
+
<>
|
|
157
|
+
<rect
|
|
158
|
+
fill={COLOR_BACKGROUND}
|
|
159
|
+
height={viewBoxHeight}
|
|
160
|
+
rx={borderRadius}
|
|
161
|
+
width={viewBoxWidth}
|
|
162
|
+
x="0"
|
|
163
|
+
y="0"
|
|
164
|
+
/>
|
|
165
|
+
<rect
|
|
166
|
+
fill="white"
|
|
167
|
+
height={viewBoxHeight - coordinatesSize}
|
|
168
|
+
width={viewBoxWidth - coordinatesSize}
|
|
169
|
+
x={direction === 'ltr' ? coordinatesSize : 0}
|
|
170
|
+
y={coordinatesSize}
|
|
171
|
+
/>
|
|
172
|
+
|
|
173
|
+
<rect
|
|
174
|
+
fill={COLOR_BACKGROUND}
|
|
175
|
+
height={coordinatesSize}
|
|
176
|
+
rx={borderRadius}
|
|
177
|
+
width={viewBoxWidth}
|
|
178
|
+
x="0"
|
|
179
|
+
y="0"
|
|
180
|
+
/>
|
|
181
|
+
<rect
|
|
182
|
+
fill={COLOR_BACKGROUND}
|
|
183
|
+
height={viewBoxHeight}
|
|
184
|
+
rx={borderRadius}
|
|
185
|
+
x={direction === 'ltr' ? 0 : viewBoxWidth - coordinatesSize}
|
|
186
|
+
y="0"
|
|
187
|
+
width={coordinatesSize}
|
|
188
|
+
/>
|
|
189
|
+
<use href={`#${HORIZONTAL_LINE}`} y={coordinatesSize - BORDER_WIDTH} />
|
|
190
|
+
<use
|
|
191
|
+
href={`#${VERTICAL_LINE}`}
|
|
192
|
+
x={
|
|
193
|
+
direction === 'ltr' ? coordinatesSize - BORDER_WIDTH : viewBoxWidth - coordinatesSize - BORDER_WIDTH
|
|
194
|
+
}
|
|
195
|
+
/>
|
|
196
|
+
</>
|
|
197
|
+
)}
|
|
198
|
+
|
|
199
|
+
{Array.from({ length: config.boardHeight - 1 }).map((_value, index) => (
|
|
200
|
+
<use
|
|
201
|
+
key={index}
|
|
202
|
+
href={`#${HORIZONTAL_LINE}`}
|
|
203
|
+
y={coordinatesSize + (index + 1) * (cellSize + BORDER_WIDTH) - BORDER_WIDTH}
|
|
204
|
+
/>
|
|
205
|
+
))}
|
|
206
|
+
|
|
207
|
+
{Array.from({ length: config.boardWidth - 1 }).map((_value, index) => (
|
|
208
|
+
<use
|
|
209
|
+
key={index}
|
|
210
|
+
href={`#${VERTICAL_LINE}`}
|
|
211
|
+
x={(direction === 'ltr' ? coordinatesSize : 0) + (index + 1) * (cellSize + BORDER_WIDTH) - BORDER_WIDTH}
|
|
212
|
+
/>
|
|
213
|
+
))}
|
|
214
|
+
|
|
215
|
+
{characterBonuses.map((bonus, index) => (
|
|
216
|
+
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS}`} x={getX(bonus)} y={getY(bonus)} />
|
|
217
|
+
))}
|
|
218
|
+
|
|
219
|
+
{word2Bonuses.map((bonus, index) => (
|
|
220
|
+
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS_WORD_2}`} x={getX(bonus)} y={getY(bonus)} />
|
|
221
|
+
))}
|
|
222
|
+
|
|
223
|
+
{word3Bonuses.map((bonus, index) => (
|
|
224
|
+
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS_WORD_3}`} x={getX(bonus)} y={getY(bonus)} />
|
|
225
|
+
))}
|
|
226
|
+
|
|
227
|
+
{word4Bonuses.map((bonus, index) => (
|
|
228
|
+
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS_WORD_4}`} x={getX(bonus)} y={getY(bonus)} />
|
|
229
|
+
))}
|
|
143
230
|
|
|
144
|
-
<rect fill={COLOR_BACKGROUND} height={coordinatesSize} rx={borderRadius} width={viewBoxWidth} x="0" y="0" />
|
|
145
231
|
<rect
|
|
146
|
-
fill={
|
|
147
|
-
height={
|
|
232
|
+
fill={COLOR_BONUS_START}
|
|
233
|
+
height={bonusSize}
|
|
148
234
|
rx={borderRadius}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
235
|
+
width={bonusSize}
|
|
236
|
+
x={getX(center) + bonusOffset}
|
|
237
|
+
y={getY(center) + bonusOffset}
|
|
152
238
|
/>
|
|
153
|
-
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
|
|
239
|
+
|
|
240
|
+
<Star
|
|
241
|
+
color="white"
|
|
242
|
+
height={iconSize}
|
|
243
|
+
width={iconSize}
|
|
244
|
+
x={getX(center) + iconOffset}
|
|
245
|
+
y={getY(center) + iconOffset}
|
|
157
246
|
/>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
{word3Bonuses.map((bonus, index) => (
|
|
186
|
-
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS_WORD_3}`} x={getX(bonus)} y={getY(bonus)} />
|
|
187
|
-
))}
|
|
188
|
-
|
|
189
|
-
{word4Bonuses.map((bonus, index) => (
|
|
190
|
-
<use fill={getBonusColor(bonus)} key={index} href={`#${BONUS_WORD_4}`} x={getX(bonus)} y={getY(bonus)} />
|
|
191
|
-
))}
|
|
192
|
-
|
|
193
|
-
<rect
|
|
194
|
-
fill={COLOR_BONUS_START}
|
|
195
|
-
height={bonusSize}
|
|
196
|
-
rx={borderRadius}
|
|
197
|
-
width={bonusSize}
|
|
198
|
-
x={getX(center) + bonusOffset}
|
|
199
|
-
y={getY(center) + bonusOffset}
|
|
200
|
-
/>
|
|
201
|
-
|
|
202
|
-
<Star
|
|
203
|
-
color="white"
|
|
204
|
-
height={iconSize}
|
|
205
|
-
width={iconSize}
|
|
206
|
-
x={getX(center) + iconOffset}
|
|
207
|
-
y={getY(center) + iconOffset}
|
|
208
|
-
/>
|
|
209
|
-
</svg>
|
|
210
|
-
</Provider>,
|
|
247
|
+
</svg>
|
|
248
|
+
</Provider>,
|
|
249
|
+
),
|
|
250
|
+
[
|
|
251
|
+
bonusOffset,
|
|
252
|
+
bonusSize,
|
|
253
|
+
borderRadius,
|
|
254
|
+
cellSize,
|
|
255
|
+
center,
|
|
256
|
+
characterBonuses,
|
|
257
|
+
config.boardHeight,
|
|
258
|
+
config.boardWidth,
|
|
259
|
+
coordinatesSize,
|
|
260
|
+
direction,
|
|
261
|
+
fontOffset,
|
|
262
|
+
fontSize,
|
|
263
|
+
getX,
|
|
264
|
+
getY,
|
|
265
|
+
iconOffset,
|
|
266
|
+
iconSize,
|
|
267
|
+
showCoordinates,
|
|
268
|
+
viewBoxHeight,
|
|
269
|
+
viewBoxWidth,
|
|
270
|
+
word2Bonuses,
|
|
271
|
+
word3Bonuses,
|
|
272
|
+
word4Bonuses,
|
|
273
|
+
],
|
|
211
274
|
);
|
|
212
275
|
|
|
213
|
-
const
|
|
214
|
-
|
|
276
|
+
const dataUrl = useMemo(() => `data:image/svg+xml,${encodeURIComponent(backgroundSvg)}`, [backgroundSvg]);
|
|
277
|
+
|
|
215
278
|
return dataUrl;
|
|
216
279
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type CSSProperties, useMemo } from 'react';
|
|
2
2
|
|
|
3
|
-
import { useAppLayout } from 'app-layout';
|
|
4
|
-
import { getTileSizes } from 'lib';
|
|
5
|
-
import { BORDER_WIDTH } from 'parameters';
|
|
6
|
-
import { selectConfig, selectShowCoordinates, useTypedSelector } from 'state';
|
|
3
|
+
import { useAppLayout } from '@/app-layout';
|
|
4
|
+
import { getTileSizes } from '@/lib';
|
|
5
|
+
import { BORDER_WIDTH } from '@/parameters';
|
|
6
|
+
import { selectConfig, selectShowCoordinates, useTypedSelector } from '@/state';
|
|
7
7
|
|
|
8
8
|
import { useBackgroundImage } from './useBackgroundImage';
|
|
9
9
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { autoUpdate, offset, shift, useFloating } from '@floating-ui/react';
|
|
2
2
|
|
|
3
|
-
import { useAppLayout } from 'app-layout';
|
|
4
|
-
import { BOARD_CELL_ACTIONS_OFFSET } from 'parameters';
|
|
3
|
+
import { useAppLayout } from '@/app-layout';
|
|
4
|
+
import { BOARD_CELL_ACTIONS_OFFSET } from '@/parameters';
|
|
5
5
|
|
|
6
6
|
export const useFloatingActions = () => {
|
|
7
7
|
const { actionsWidth } = useAppLayout();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { autoUpdate, offset, shift, useFloating } from '@floating-ui/react';
|
|
2
2
|
|
|
3
|
-
import { BOARD_CELL_ACTIONS_OFFSET } from 'parameters';
|
|
3
|
+
import { BOARD_CELL_ACTIONS_OFFSET } from '@/parameters';
|
|
4
4
|
|
|
5
5
|
export const useFloatingInputPrompt = () => {
|
|
6
6
|
return useFloating({
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
} from 'react';
|
|
16
16
|
import { useDispatch } from 'react-redux';
|
|
17
17
|
|
|
18
|
-
import { useLatest } from 'hooks';
|
|
19
|
-
import { LOCALE_FEATURES } from 'i18n';
|
|
20
|
-
import { createKeyboardNavigation, extractCharacters, extractInputValue, isCtrl } from 'lib';
|
|
21
|
-
import { boardSlice, cellFiltersSlice, selectConfig, selectLocale, useTypedSelector } from 'state';
|
|
22
|
-
import { type Direction, type Point } from 'types';
|
|
18
|
+
import { useLatest } from '@/hooks';
|
|
19
|
+
import { LOCALE_FEATURES } from '@/i18n';
|
|
20
|
+
import { createKeyboardNavigation, extractCharacters, extractInputValue, isCtrl } from '@/lib';
|
|
21
|
+
import { boardSlice, cellFiltersSlice, selectConfig, selectLocale, useTypedSelector } from '@/state';
|
|
22
|
+
import { type Direction, type Point } from '@/types';
|
|
23
23
|
|
|
24
24
|
import { createGrid, getPositionInGrid } from '../lib';
|
|
25
25
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BONUS_WORD } from '@scrabble-solver/constants';
|
|
2
2
|
import { type Bonus } from '@scrabble-solver/types';
|
|
3
3
|
|
|
4
|
-
import { COLOR_BONUS_CHARACTER, COLOR_BONUS_CHARACTER_MULTIPLIER, COLOR_BONUS_WORD } from 'parameters';
|
|
5
|
-
import { type Point } from 'types';
|
|
4
|
+
import { COLOR_BONUS_CHARACTER, COLOR_BONUS_CHARACTER_MULTIPLIER, COLOR_BONUS_WORD } from '@/parameters';
|
|
5
|
+
import { type Point } from '@/types';
|
|
6
6
|
|
|
7
7
|
export const createGrid = <T>(width: number, height: number, getInitialValue: (x: number, y: number) => T): T[][] => {
|
|
8
8
|
return Array.from({ length: height }).map((_row, y) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSelector } from '@reduxjs/toolkit';
|
|
2
2
|
|
|
3
|
-
import { findCell } from 'lib';
|
|
4
|
-
import { selectBoard, selectResultCandidateCells } from 'state';
|
|
3
|
+
import { findCell } from '@/lib';
|
|
4
|
+
import { selectBoard, selectResultCandidateCells } from '@/state';
|
|
5
5
|
|
|
6
6
|
export const selectRowsWithCandidate = createSelector([selectBoard, selectResultCandidateCells], (board, cells) => {
|
|
7
7
|
return board.rows.map((row, y) => row.map((cell, x) => findCell(cells, x, y) || cell));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { type FunctionComponent } from 'react';
|
|
3
3
|
|
|
4
|
-
import { useAppLayout } from 'app-layout';
|
|
4
|
+
import { useAppLayout } from '@/app-layout';
|
|
5
5
|
import {
|
|
6
6
|
selectDictionaryError,
|
|
7
7
|
selectDictionaryIsLoading,
|
|
8
8
|
selectDictionaryResults,
|
|
9
9
|
useTranslate,
|
|
10
10
|
useTypedSelector,
|
|
11
|
-
} from 'state';
|
|
11
|
+
} from '@/state';
|
|
12
12
|
|
|
13
13
|
import { EmptyState } from '../EmptyState';
|
|
14
14
|
import { Loading } from '../Loading';
|
|
@@ -2,8 +2,8 @@ import classNames from 'classnames';
|
|
|
2
2
|
import { type ChangeEvent, type FunctionComponent, type SubmitEvent } from 'react';
|
|
3
3
|
import { useDispatch } from 'react-redux';
|
|
4
4
|
|
|
5
|
-
import { LOCALE_FEATURES } from 'i18n';
|
|
6
|
-
import { dictionarySlice, selectDictionary, selectLocale, useTranslate, useTypedSelector } from 'state';
|
|
5
|
+
import { LOCALE_FEATURES } from '@/i18n';
|
|
6
|
+
import { dictionarySlice, selectDictionary, selectLocale, useTranslate, useTypedSelector } from '@/state';
|
|
7
7
|
|
|
8
8
|
import styles from './DictionaryInput.module.scss';
|
|
9
9
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { type FunctionComponent, type ReactNode, useMemo } from 'react';
|
|
3
3
|
|
|
4
|
-
import { LOCALE_FEATURES } from 'i18n';
|
|
5
|
-
import { COLOR_BLUE, COLOR_GREEN, COLOR_RED, COLOR_YELLOW } from 'parameters';
|
|
6
|
-
import { selectLocale, useTranslate, useTypedSelector } from 'state';
|
|
7
|
-
import { type Translations } from 'types';
|
|
4
|
+
import { LOCALE_FEATURES } from '@/i18n';
|
|
5
|
+
import { COLOR_BLUE, COLOR_GREEN, COLOR_RED, COLOR_YELLOW } from '@/parameters';
|
|
6
|
+
import { selectLocale, useTranslate, useTypedSelector } from '@/state';
|
|
7
|
+
import { type Translations } from '@/types';
|
|
8
8
|
|
|
9
9
|
import { PlainTiles } from '../PlainTiles';
|
|
10
10
|
|
|
@@ -30,12 +30,20 @@ const COLORS_PER_TYPE: Record<Props['variant'], string> = {
|
|
|
30
30
|
warning: COLOR_YELLOW,
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
34
|
+
|
|
35
|
+
const reverseGraphemes = (value: string): string => {
|
|
36
|
+
return Array.from(graphemeSegmenter.segment(value), (segment) => segment.segment)
|
|
37
|
+
.reverse()
|
|
38
|
+
.join('');
|
|
39
|
+
};
|
|
40
|
+
|
|
33
41
|
export const EmptyState: FunctionComponent<Props> = ({ children, className, variant }) => {
|
|
34
42
|
const translate = useTranslate();
|
|
35
43
|
const locale = useTypedSelector(selectLocale);
|
|
36
44
|
const { direction } = LOCALE_FEATURES[locale];
|
|
37
45
|
const title = translate(TITLE_KEY_PER_TYPE[variant]);
|
|
38
|
-
const message = direction === 'ltr' ? title : title
|
|
46
|
+
const message = direction === 'ltr' ? title : reverseGraphemes(title);
|
|
39
47
|
const content = useMemo(() => [message.toUpperCase().split(' ')], [message]);
|
|
40
48
|
|
|
41
49
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { type FunctionComponent } from 'react';
|
|
3
3
|
|
|
4
|
-
import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from 'icons';
|
|
4
|
+
import { ArrowDown, ArrowLeft, ArrowRight, ArrowUp } from '@/icons';
|
|
5
5
|
|
|
6
6
|
import { Key } from '../../Key';
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import { type FunctionComponent, useMemo } from 'react';
|
|
3
3
|
|
|
4
|
-
import { LOCALE_FEATURES } from 'i18n';
|
|
5
|
-
import { selectLocale, useTranslate, useTypedSelector } from 'state';
|
|
4
|
+
import { LOCALE_FEATURES } from '@/i18n';
|
|
5
|
+
import { selectLocale, useTranslate, useTypedSelector } from '@/state';
|
|
6
6
|
|
|
7
7
|
import { PlainTiles } from '../PlainTiles';
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Image from 'next/image';
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
|
|
4
|
-
import { useAppLayout } from 'app-layout';
|
|
5
|
-
import { LOGO_SRC } from 'parameters';
|
|
4
|
+
import { useAppLayout } from '@/app-layout';
|
|
5
|
+
import { LOGO_SRC } from '@/parameters';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
className?: string;
|
|
@@ -2,9 +2,9 @@ import classNames from 'classnames';
|
|
|
2
2
|
import { type FunctionComponent, type ReactNode, useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import ReactModal from 'react-modal';
|
|
4
4
|
|
|
5
|
-
import { CrossSquareFill } from 'icons';
|
|
6
|
-
import { TRANSITION_DURATION_LONG } from 'parameters';
|
|
7
|
-
import { useTranslate } from 'state';
|
|
5
|
+
import { CrossSquareFill } from '@/icons';
|
|
6
|
+
import { TRANSITION_DURATION_LONG } from '@/parameters';
|
|
7
|
+
import { useTranslate } from '@/state';
|
|
8
8
|
|
|
9
9
|
import { IconButton } from '../IconButton';
|
|
10
10
|
|