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.
- package/.eslintrc.js +1 -1
- package/.gitattributes +2 -0
- package/HISTORY.md +17 -0
- package/README.md +8 -26
- package/lerna.json +1 -1
- package/package.json +13 -13
- package/packages/configs/build/getConfig.js +6 -12
- package/packages/configs/build/getLocaleConfig.js +2 -2
- package/packages/configs/build/isConfigId.js +5 -8
- package/packages/configs/build/literaki/bonuses.js +2 -2
- package/packages/configs/build/literaki/literaki.js +14 -27
- package/packages/configs/build/literaki/tiles/tilesDe.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesEn.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesEs.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesFr.js +1 -1
- package/packages/configs/build/literaki/tiles/tilesPl.js +1 -1
- package/packages/configs/build/scrabble/bonuses.js +2 -2
- package/packages/configs/build/scrabble/scrabble.js +14 -27
- package/packages/configs/build/scrabble/tiles/tilesDe.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesEn.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesEs.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesFr.js +1 -1
- package/packages/configs/build/scrabble/tiles/tilesPl.js +1 -1
- package/packages/configs/package.json +3 -3
- package/packages/constants/package.json +1 -1
- package/packages/dictionaries/build/Dictionaries.js +37 -110
- package/packages/dictionaries/build/constants/index.js +2 -2
- package/packages/dictionaries/build/index.js +1 -1
- package/packages/dictionaries/build/lib/DiskCache.js +29 -91
- package/packages/dictionaries/build/lib/LayeredCache.js +37 -101
- package/packages/dictionaries/build/lib/MemoryCache.js +16 -17
- package/packages/dictionaries/build/lib/createAsyncProxy.js +14 -58
- package/packages/dictionaries/build/lib/createCacheTimestampComparator.js +4 -4
- package/packages/dictionaries/build/lib/downloadDictionary.js +10 -54
- package/packages/dictionaries/build/lib/getDictionaryFilepath.js +4 -4
- package/packages/dictionaries/build/lib/index.d.ts +0 -2
- package/packages/dictionaries/build/lib/index.js +1 -5
- package/packages/dictionaries/package-lock.json +10 -10
- package/packages/dictionaries/package.json +5 -5
- package/packages/dictionaries/src/lib/DiskCache.ts +2 -4
- package/packages/dictionaries/src/lib/LayeredCache.ts +17 -8
- package/packages/dictionaries/src/lib/index.ts +0 -2
- package/packages/logger/build/constants.js +2 -2
- package/packages/logger/build/logger.js +4 -4
- package/packages/logger/package-lock.json +2 -2
- package/packages/logger/package.json +1 -1
- package/packages/scrabble-solver/.next/BUILD_ID +1 -1
- package/packages/scrabble-solver/.next/build-manifest.json +10 -10
- package/packages/scrabble-solver/.next/cache/.tsbuildinfo +1 -1
- package/packages/scrabble-solver/.next/cache/eslint/.cache_8dgz12 +1 -1
- package/packages/scrabble-solver/.next/cache/next-server.js.nft.json +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/server-production/0.pack +0 -0
- package/packages/scrabble-solver/.next/cache/webpack/server-production/index.pack +0 -0
- package/packages/scrabble-solver/.next/next-server.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/prerender-manifest.json +1 -1
- package/packages/scrabble-solver/.next/routes-manifest.json +1 -1
- package/packages/scrabble-solver/.next/server/chunks/206.js +98 -97
- package/packages/scrabble-solver/.next/server/chunks/413.js +396 -677
- package/packages/scrabble-solver/.next/server/chunks/515.js +546 -550
- package/packages/scrabble-solver/.next/server/chunks/907.js +399 -681
- package/packages/scrabble-solver/.next/server/middleware-build-manifest.js +1 -1
- package/packages/scrabble-solver/.next/server/pages/404.html +5 -1
- package/packages/scrabble-solver/.next/server/pages/404.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/500.html +2 -2
- package/packages/scrabble-solver/.next/server/pages/_app.js +7 -10
- package/packages/scrabble-solver/.next/server/pages/_app.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/_document.js +0 -3
- package/packages/scrabble-solver/.next/server/pages/_error.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/api/dictionary/[locale]/[word].js +114 -171
- package/packages/scrabble-solver/.next/server/pages/api/solve.js +426 -1206
- package/packages/scrabble-solver/.next/server/pages/index.html +17 -1
- package/packages/scrabble-solver/.next/server/pages/index.js +7 -14
- package/packages/scrabble-solver/.next/server/pages/index.js.nft.json +1 -1
- package/packages/scrabble-solver/.next/server/pages/index.json +1 -1
- package/packages/scrabble-solver/.next/static/-UOLkxdxU0PlKbXa09-xO/_buildManifest.js +1 -0
- package/packages/scrabble-solver/.next/static/{nXSSCVI5pGlS_NxEidxkS → -UOLkxdxU0PlKbXa09-xO}/_ssgManifest.js +0 -0
- package/packages/scrabble-solver/.next/static/chunks/56-2d34867599a0ac66.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/{404-02d949d2fe59e960.js → 404-30c06e61d256c5b2.js} +1 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-6ffa2ab900772b67.js +1 -0
- package/packages/scrabble-solver/.next/static/chunks/pages/{index-75517525489ab316.js → index-13ea7770a65c69ee.js} +1 -1
- package/packages/scrabble-solver/.next/static/css/{d676d43c6b9c9a57.css → 551d09cac435debb.css} +1 -1
- package/packages/scrabble-solver/.next/static/css/{6a9e5ba3f77c27f2.css → cdbc9e0afcff5473.css} +1 -1
- package/packages/scrabble-solver/.next/trace +42 -42
- package/packages/scrabble-solver/package-lock.json +85 -85
- package/packages/scrabble-solver/package.json +13 -13
- package/packages/scrabble-solver/src/components/Board/Board.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/BoardPure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/Button.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/Cell.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/components/Cell/CellPure.tsx +1 -1
- package/packages/scrabble-solver/src/components/Board/hooks/useGrid.ts +9 -0
- package/packages/scrabble-solver/src/components/Button/Button.tsx +1 -1
- package/packages/scrabble-solver/src/components/Checkbox/Checkbox.tsx +1 -1
- package/packages/scrabble-solver/src/components/Dictionary/Dictionary.tsx +1 -1
- package/packages/scrabble-solver/src/components/DictionaryInput/DictionaryInput.tsx +1 -1
- package/packages/scrabble-solver/src/components/EmptyState/EmptyState.tsx +1 -1
- package/packages/scrabble-solver/src/components/Key/Key.tsx +1 -1
- package/packages/scrabble-solver/src/components/KeyMap/KeyMap.tsx +2 -2
- package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.module.scss +4 -0
- package/packages/scrabble-solver/src/components/KeyMap/components/Mapping/Mapping.tsx +16 -12
- package/packages/scrabble-solver/src/components/Loading/Loading.tsx +1 -1
- package/packages/scrabble-solver/src/components/Logo/Logo.tsx +1 -1
- package/packages/scrabble-solver/src/components/NavButtons/NavButtons.tsx +1 -1
- package/packages/scrabble-solver/src/components/NotFound/NotFound.tsx +1 -1
- package/packages/scrabble-solver/src/components/PlainTiles/PlainTiles.tsx +5 -1
- package/packages/scrabble-solver/src/components/PlainTiles/Tile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Rack/Rack.tsx +1 -1
- package/packages/scrabble-solver/src/components/Rack/RackTile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Radio/Radio.tsx +1 -1
- package/packages/scrabble-solver/src/components/RemainingTiles/Character.tsx +1 -1
- package/packages/scrabble-solver/src/components/RemainingTiles/RemainingTiles.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Cell.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/HeaderButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Result.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/Results.tsx +1 -1
- package/packages/scrabble-solver/src/components/Results/SolveButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/ResultsInput/ResultsInput.tsx +1 -1
- package/packages/scrabble-solver/src/components/Screen/Screen.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/Settings.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/AutoGroupTilesSetting/AutoGroupTilesSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/ConfigSetting/ConfigSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Settings/components/LocaleSetting/LocaleSetting.tsx +1 -1
- package/packages/scrabble-solver/src/components/Sidebar/Sidebar.tsx +1 -1
- package/packages/scrabble-solver/src/components/Sidebar/components/Section/Section.tsx +1 -1
- package/packages/scrabble-solver/src/components/Splash/Splash.tsx +1 -1
- package/packages/scrabble-solver/src/components/SquareButton/Link.tsx +1 -1
- package/packages/scrabble-solver/src/components/SquareButton/SquareButton.tsx +1 -1
- package/packages/scrabble-solver/src/components/SvgFontCss/SvgFontCss.tsx +12 -0
- package/packages/scrabble-solver/src/components/SvgFontCss/index.ts +1 -0
- package/packages/scrabble-solver/src/components/Tile/Tile.tsx +1 -1
- package/packages/scrabble-solver/src/components/Tile/TilePure.tsx +2 -2
- package/packages/scrabble-solver/src/components/Tooltip/useTooltip.tsx +1 -1
- package/packages/scrabble-solver/src/components/Well/Well.tsx +1 -1
- package/packages/scrabble-solver/src/components/index.ts +1 -0
- package/packages/scrabble-solver/src/hooks/usePortal.tsx +19 -9
- package/packages/scrabble-solver/src/lib/createKeyboardNavigation.ts +3 -0
- package/packages/scrabble-solver/src/lib/memoize.ts +1 -1
- package/packages/scrabble-solver/src/pages/_app.tsx +1 -1
- package/packages/scrabble-solver/src/pages/_document.tsx +1 -1
- package/packages/scrabble-solver/src/pages/index.tsx +6 -15
- package/packages/scrabble-solver/src/styles/global.scss +3 -0
- package/packages/solver/build/PatternsFiller.js +38 -72
- package/packages/solver/build/PatternsGenerator.js +43 -72
- package/packages/solver/build/ScoresCalculator.js +20 -24
- package/packages/solver/build/Solver.js +19 -24
- package/packages/solver/package-lock.json +17 -17
- package/packages/solver/package.json +7 -7
- package/packages/solver/src/PatternsFiller.ts +5 -10
- package/packages/solver/src/PatternsGenerator.ts +17 -16
- package/packages/solver/src/Solver.ts +4 -8
- package/packages/types/build/Board.js +68 -85
- package/packages/types/build/Bonus.js +15 -21
- package/packages/types/build/Cell.js +31 -33
- package/packages/types/build/CharacterBonus.js +18 -40
- package/packages/types/build/Config.js +62 -117
- package/packages/types/build/HorizontalPattern.js +17 -63
- package/packages/types/build/Pattern.js +37 -41
- package/packages/types/build/Result.js +23 -46
- package/packages/types/build/Tile.js +22 -24
- package/packages/types/build/VerticalPattern.js +17 -63
- package/packages/types/build/WordBonus.js +13 -35
- package/packages/types/build/WordDefinition.js +13 -15
- package/packages/types/package.json +2 -2
- package/packages/types/src/Cell.ts +1 -1
- package/packages/types/src/Pattern.ts +1 -1
- package/packages/word-definitions/build/crawl/crawl.js +15 -16
- package/packages/word-definitions/build/crawl/crawlEnglish.js +3 -3
- package/packages/word-definitions/build/crawl/crawlFrench.js +3 -3
- package/packages/word-definitions/build/crawl/crawlGerman.js +3 -3
- package/packages/word-definitions/build/crawl/crawlPolish.js +3 -3
- package/packages/word-definitions/build/crawl/crawlSpanish.js +3 -3
- package/packages/word-definitions/build/getWordDefinition.js +9 -52
- package/packages/word-definitions/build/lib/normalizeDefinition.js +15 -15
- package/packages/word-definitions/build/lib/request.js +8 -20
- package/packages/word-definitions/build/lib/unique.js +1 -1
- package/packages/word-definitions/build/parse/parse.js +18 -19
- package/packages/word-definitions/build/parse/parseEnglish.js +5 -5
- package/packages/word-definitions/build/parse/parseFrench.js +5 -5
- package/packages/word-definitions/build/parse/parseGerman.js +6 -6
- package/packages/word-definitions/build/parse/parsePolish.js +6 -6
- package/packages/word-definitions/build/parse/parseSpanish.js +9 -9
- package/packages/word-definitions/package-lock.json +8 -8
- package/packages/word-definitions/package.json +2 -2
- package/packages/word-lists/build/getDeDeWordList.js +5 -43
- package/packages/word-lists/build/getEnGbWordList.js +5 -43
- package/packages/word-lists/build/getEnUsWordList.js +5 -43
- package/packages/word-lists/build/getEsEsWordList.js +7 -50
- package/packages/word-lists/build/getFrFrWordList.js +9 -50
- package/packages/word-lists/build/getPlPlWordList.js +33 -91
- package/packages/word-lists/build/getWordList.js +16 -17
- package/packages/word-lists/build/lib/downloadFile.d.ts +1 -2
- package/packages/word-lists/build/lib/downloadFile.js +28 -10
- package/packages/word-lists/build/lib/downloadHtml.js +8 -8
- package/packages/word-lists/build/lib/extractWords.js +5 -5
- package/packages/word-lists/build/lib/findFirstWordIndex.js +6 -6
- package/packages/word-lists/build/lib/getHash.js +2 -5
- package/packages/word-lists/build/lib/getTempFilename.js +3 -3
- package/packages/word-lists/build/lib/getTxtWordList.js +10 -56
- package/packages/word-lists/package-lock.json +2 -2
- package/packages/word-lists/package.json +2 -2
- package/packages/word-lists/src/getFrFrWordList.ts +1 -0
- package/packages/word-lists/src/getPlPlWordList.ts +2 -3
- package/packages/word-lists/src/lib/downloadFile.ts +25 -7
- package/packages/word-lists/src/lib/getTxtWordList.ts +2 -4
- package/tsconfig.json +1 -1
- package/packages/dictionaries/build/lib/readFile.d.ts +0 -2
- package/packages/dictionaries/build/lib/readFile.js +0 -57
- package/packages/dictionaries/build/lib/writeFile.d.ts +0 -2
- package/packages/dictionaries/build/lib/writeFile.js +0 -57
- package/packages/dictionaries/src/lib/readFile.ts +0 -15
- package/packages/dictionaries/src/lib/writeFile.ts +0 -15
- package/packages/scrabble-solver/.next/static/chunks/195-fcadef5c6eed8338.js +0 -1
- package/packages/scrabble-solver/.next/static/chunks/pages/_app-f4030148d742bcd2.js +0 -1
- package/packages/scrabble-solver/.next/static/nXSSCVI5pGlS_NxEidxkS/_buildManifest.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BLANK } from '@scrabble-solver/constants';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import
|
|
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 classNames from 'classnames';
|
|
3
|
-
import
|
|
3
|
+
import { FunctionComponent } from 'react';
|
|
4
4
|
|
|
5
5
|
import { REMAINING_TILES_TILE_SIZE } from 'parameters';
|
|
6
6
|
import { selectCharacterPoints, useTypedSelector } from 'state';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
|
-
import
|
|
2
|
+
import { ChangeEvent, FunctionComponent } from 'react';
|
|
3
3
|
import { useDispatch } from 'react-redux';
|
|
4
4
|
|
|
5
5
|
import { resultsSlice, selectResultsQuery, useTranslate, useTypedSelector } from 'state';
|
package/packages/scrabble-solver/src/components/Settings/components/LocaleSetting/LocaleSetting.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Locale } from '@scrabble-solver/types';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import
|
|
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
|
|
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 classNames from 'classnames';
|
|
2
|
-
import
|
|
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="
|
|
69
|
+
autoCapitalize="none"
|
|
70
70
|
autoComplete="off"
|
|
71
71
|
autoCorrect="off"
|
|
72
72
|
autoFocus={autoFocus}
|
|
@@ -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
|
|
2
|
-
import {
|
|
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
|
|
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
|
-
|
|
26
|
-
|
|
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,
|
|
38
|
+
}, [disabled, tagName]);
|
|
29
39
|
|
|
30
40
|
useLayoutEffect(() => {
|
|
31
|
-
if (
|
|
32
|
-
render(<Portal>{children}</Portal
|
|
41
|
+
if (rootRef.current) {
|
|
42
|
+
rootRef.current.render(<Portal>{children}</Portal>);
|
|
33
43
|
}
|
|
34
|
-
}, [children, disabled,
|
|
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,7 +1,7 @@
|
|
|
1
1
|
import classNames from 'classnames';
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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;
|
|
@@ -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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
36
|
-
|
|
10
|
+
fill(pattern, tiles) {
|
|
11
|
+
const patterns = [];
|
|
37
12
|
if (pattern.getNumberOfEmptyCells() > tiles.length) {
|
|
38
13
|
return [];
|
|
39
14
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
for (
|
|
43
|
-
|
|
44
|
-
this.fillPattern(pattern,
|
|
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
|
-
|
|
49
|
-
|
|
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 (
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
96
|
-
return this.config.alphabet.reduce(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return permutations.concat(
|
|
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
|
-
|
|
103
|
-
}());
|
|
68
|
+
}
|
|
69
|
+
}
|
|
104
70
|
exports.default = PatternsFiller;
|